mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 05:17:13 +02:00
Moench rewrite (#597)
* copied jungfrau server to moench and adapted * fixed image size and num packets * read n rows allows 16 * commneted out configure_asic_timer at server startup. To be removed later the ASIC_CTRL_REG and storage cell options * moench:removing the decrement (which was in jf) in read n rows to register * removed lblsamples from gui
This commit is contained in:
@ -351,7 +351,7 @@ int ClientInterface::setup_receiver(Interface &socket) {
|
||||
}
|
||||
impl()->setUDPPortNumber(arg.udp_dstport);
|
||||
impl()->setUDPPortNumber2(arg.udp_dstport2);
|
||||
if (detType == JUNGFRAU || detType == GOTTHARD2) {
|
||||
if (detType == JUNGFRAU || detType == MOENCH || detType == GOTTHARD2) {
|
||||
try {
|
||||
impl()->setNumberofUDPInterfaces(arg.udpInterfaces);
|
||||
} catch (const RuntimeError &e) {
|
||||
@ -367,10 +367,10 @@ int ClientInterface::setup_receiver(Interface &socket) {
|
||||
if (detType == GOTTHARD2) {
|
||||
impl()->setNumberOfBursts(arg.bursts);
|
||||
}
|
||||
if (detType == JUNGFRAU) {
|
||||
if (detType == JUNGFRAU || detType == MOENCH) {
|
||||
impl()->setNumberOfAdditionalStorageCells(arg.additionalStorageCells);
|
||||
}
|
||||
if (detType == MOENCH || detType == CHIPTESTBOARD) {
|
||||
if (detType == CHIPTESTBOARD) {
|
||||
try {
|
||||
impl()->setNumberofAnalogSamples(arg.analogSamples);
|
||||
} catch (const RuntimeError &e) {
|
||||
@ -408,7 +408,7 @@ int ClientInterface::setup_receiver(Interface &socket) {
|
||||
}
|
||||
impl()->setThresholdEnergy(arg.thresholdEnergyeV[0]);
|
||||
}
|
||||
if (detType == EIGER || detType == JUNGFRAU) {
|
||||
if (detType == EIGER || detType == JUNGFRAU || detType == MOENCH) {
|
||||
impl()->setReadNRows(arg.readNRows);
|
||||
}
|
||||
if (detType == MYTHEN3) {
|
||||
@ -428,8 +428,7 @@ int ClientInterface::setup_receiver(Interface &socket) {
|
||||
}
|
||||
}
|
||||
impl()->setTimingMode(arg.timMode);
|
||||
if (detType == EIGER || detType == MOENCH || detType == CHIPTESTBOARD ||
|
||||
detType == MYTHEN3) {
|
||||
if (detType == EIGER || detType == CHIPTESTBOARD || detType == MYTHEN3) {
|
||||
try {
|
||||
impl()->setTenGigaEnable(arg.tenGiga);
|
||||
} catch (const RuntimeError &e) {
|
||||
@ -444,7 +443,7 @@ int ClientInterface::setup_receiver(Interface &socket) {
|
||||
"due to fifo memory allocation.");
|
||||
}
|
||||
}
|
||||
if (detType == CHIPTESTBOARD || detType == MOENCH) {
|
||||
if (detType == CHIPTESTBOARD) {
|
||||
try {
|
||||
impl()->setADCEnableMask(arg.adcMask);
|
||||
} catch (const RuntimeError &e) {
|
||||
@ -488,8 +487,8 @@ void ClientInterface::setDetectorType(detectorType arg) {
|
||||
case GOTTHARD:
|
||||
case EIGER:
|
||||
case CHIPTESTBOARD:
|
||||
case MOENCH:
|
||||
case JUNGFRAU:
|
||||
case MOENCH:
|
||||
case MYTHEN3:
|
||||
case GOTTHARD2:
|
||||
break;
|
||||
@ -611,7 +610,7 @@ int ClientInterface::set_burst_mode(Interface &socket) {
|
||||
int ClientInterface::set_num_analog_samples(Interface &socket) {
|
||||
auto value = socket.Receive<int>();
|
||||
LOG(logDEBUG1) << "Setting num analog samples to " << value;
|
||||
if (detType != CHIPTESTBOARD && detType != MOENCH) {
|
||||
if (detType != CHIPTESTBOARD) {
|
||||
functionNotImplemented();
|
||||
}
|
||||
try {
|
||||
@ -939,8 +938,7 @@ int ClientInterface::get_overwrite(Interface &socket) {
|
||||
|
||||
int ClientInterface::enable_tengiga(Interface &socket) {
|
||||
auto val = socket.Receive<int>();
|
||||
if (detType != EIGER && detType != CHIPTESTBOARD && detType != MOENCH &&
|
||||
detType != MYTHEN3)
|
||||
if (detType != EIGER && detType != CHIPTESTBOARD && detType != MYTHEN3)
|
||||
functionNotImplemented();
|
||||
|
||||
if (val >= 0) {
|
||||
@ -1365,7 +1363,7 @@ int ClientInterface::set_read_n_rows(Interface &socket) {
|
||||
auto arg = socket.Receive<int>();
|
||||
if (arg >= 0) {
|
||||
verifyIdle(socket);
|
||||
if (detType != EIGER && detType != JUNGFRAU) {
|
||||
if (detType != EIGER && detType != JUNGFRAU && detType != MOENCH) {
|
||||
throw RuntimeError("Could not set number of rows. Not implemented "
|
||||
"for this detector");
|
||||
}
|
||||
@ -1448,7 +1446,7 @@ MacAddr ClientInterface::setUdpIp2(IpAddr arg) {
|
||||
int ClientInterface::set_udp_ip2(Interface &socket) {
|
||||
auto arg = socket.Receive<IpAddr>();
|
||||
verifyIdle(socket);
|
||||
if (detType != JUNGFRAU && detType != GOTTHARD2) {
|
||||
if (detType != JUNGFRAU && detType != MOENCH && detType != GOTTHARD2) {
|
||||
throw RuntimeError(
|
||||
"UDP Destination IP2 not implemented for this detector");
|
||||
}
|
||||
@ -1467,7 +1465,8 @@ int ClientInterface::set_udp_port(Interface &socket) {
|
||||
int ClientInterface::set_udp_port2(Interface &socket) {
|
||||
auto arg = socket.Receive<int>();
|
||||
verifyIdle(socket);
|
||||
if (detType != JUNGFRAU && detType != EIGER && detType != GOTTHARD2) {
|
||||
if (detType != JUNGFRAU && detType != MOENCH && detType != EIGER &&
|
||||
detType != GOTTHARD2) {
|
||||
throw RuntimeError(
|
||||
"UDP Destination Port2 not implemented for this detector");
|
||||
}
|
||||
@ -1480,7 +1479,7 @@ int ClientInterface::set_num_interfaces(Interface &socket) {
|
||||
auto arg = socket.Receive<int>();
|
||||
arg = (arg > 1 ? 2 : 1);
|
||||
verifyIdle(socket);
|
||||
if (detType != JUNGFRAU && detType != GOTTHARD2) {
|
||||
if (detType != JUNGFRAU && detType != MOENCH && detType != GOTTHARD2) {
|
||||
throw RuntimeError(
|
||||
"Number of interfaces not implemented for this detector");
|
||||
}
|
||||
@ -1727,7 +1726,7 @@ int ClientInterface::get_receiver_roi(Interface &socket) {
|
||||
|
||||
int ClientInterface::set_receiver_roi(Interface &socket) {
|
||||
auto arg = socket.Receive<ROI>();
|
||||
if (detType == CHIPTESTBOARD || detType == MOENCH)
|
||||
if (detType == CHIPTESTBOARD)
|
||||
functionNotImplemented();
|
||||
LOG(logDEBUG1) << "Set Receiver ROI: " << ToString(arg);
|
||||
verifyIdle(socket);
|
||||
@ -1741,7 +1740,7 @@ int ClientInterface::set_receiver_roi(Interface &socket) {
|
||||
|
||||
int ClientInterface::set_receiver_roi_metadata(Interface &socket) {
|
||||
auto arg = socket.Receive<ROI>();
|
||||
if (detType == CHIPTESTBOARD || detType == MOENCH)
|
||||
if (detType == CHIPTESTBOARD)
|
||||
functionNotImplemented();
|
||||
LOG(logDEBUG1) << "Set Receiver ROI Metadata: " << ToString(arg);
|
||||
verifyIdle(socket);
|
||||
|
@ -480,7 +480,6 @@ void DataProcessor::PadMissingPackets(sls_receiver_header header, char *data) {
|
||||
memset(data + (pnum * dsize), 0xFF, dsize + 2);
|
||||
break;
|
||||
case CHIPTESTBOARD:
|
||||
case MOENCH:
|
||||
if (pnum == (pperFrame - 1))
|
||||
memset(data + (pnum * dsize), 0xFF, corrected_dsize);
|
||||
else
|
||||
|
@ -352,6 +352,36 @@ class JungfrauData : public GeneralData {
|
||||
};
|
||||
};
|
||||
|
||||
class MoenchData : public GeneralData {
|
||||
|
||||
public:
|
||||
MoenchData() {
|
||||
detType = slsDetectorDefs::MOENCH;
|
||||
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
||||
dataSize = 6400;
|
||||
packetSize = headerSizeinPacket + dataSize;
|
||||
framesPerFile = MOENCH_MAX_FRAMES_PER_FILE;
|
||||
fifoDepth = 1000;
|
||||
standardheader = true;
|
||||
maxRowsPerReadout = 400;
|
||||
UpdateImageSize();
|
||||
};
|
||||
|
||||
void SetNumberofInterfaces(const int n) {
|
||||
numUDPInterfaces = n;
|
||||
UpdateImageSize();
|
||||
};
|
||||
|
||||
private:
|
||||
void UpdateImageSize() {
|
||||
nPixelsX = (400);
|
||||
nPixelsY = (400) / numUDPInterfaces;
|
||||
imageSize = int(nPixelsX * nPixelsY * GetPixelDepth());
|
||||
packetsPerFrame = imageSize / dataSize;
|
||||
udpSocketBufferSize = (1000 * 1024 * 1024) / numUDPInterfaces;
|
||||
};
|
||||
};
|
||||
|
||||
class Mythen3Data : public GeneralData {
|
||||
private:
|
||||
int ncounters{0};
|
||||
@ -565,68 +595,4 @@ class ChipTestBoardData : public GeneralData {
|
||||
};
|
||||
};
|
||||
|
||||
class MoenchData : public GeneralData {
|
||||
|
||||
private:
|
||||
const int NUM_BYTES_PER_ANALOG_CHANNEL = 2;
|
||||
|
||||
public:
|
||||
MoenchData() {
|
||||
detType = slsDetectorDefs::MOENCH;
|
||||
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
||||
frameIndexMask = 0xFFFFFF;
|
||||
framesPerFile = MOENCH_MAX_FRAMES_PER_FILE;
|
||||
fifoDepth = 2500;
|
||||
standardheader = true;
|
||||
UpdateImageSize();
|
||||
};
|
||||
|
||||
void SetNumberOfAnalogSamples(int n) {
|
||||
nAnalogSamples = n;
|
||||
UpdateImageSize();
|
||||
};
|
||||
|
||||
void SetOneGigaAdcEnableMask(int n) {
|
||||
adcEnableMaskOneGiga = n;
|
||||
UpdateImageSize();
|
||||
};
|
||||
|
||||
void SetTenGigaAdcEnableMask(int n) {
|
||||
adcEnableMaskTenGiga = n;
|
||||
UpdateImageSize();
|
||||
};
|
||||
|
||||
void SetTenGigaEnable(bool tg) {
|
||||
tengigaEnable = tg;
|
||||
UpdateImageSize();
|
||||
};
|
||||
|
||||
private:
|
||||
void UpdateImageSize() {
|
||||
uint32_t adcEnableMask =
|
||||
(tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga);
|
||||
|
||||
// count number of channels in x, each adc has 25 channels each
|
||||
int nchanTop = __builtin_popcount(adcEnableMask & 0xF0F0F0F0) * 25;
|
||||
int nchanBot = __builtin_popcount(adcEnableMask & 0x0F0F0F0F) * 25;
|
||||
nPixelsX = nchanTop > 0 ? nchanTop : nchanBot;
|
||||
|
||||
// if both top and bottom adcs enabled, rows = 2
|
||||
int nrows = 1;
|
||||
if (nchanTop > 0 && nchanBot > 0) {
|
||||
nrows = 2;
|
||||
}
|
||||
nPixelsY = nAnalogSamples / 25 * nrows;
|
||||
LOG(logINFO) << "Number of Pixels: [" << nPixelsX << ", " << nPixelsY
|
||||
<< "]";
|
||||
|
||||
dataSize = tengigaEnable ? 8144 : UDP_PACKET_DATA_BYTES;
|
||||
packetSize = headerSizeinPacket + dataSize;
|
||||
imageSize = nPixelsX * nPixelsY * NUM_BYTES_PER_ANALOG_CHANNEL;
|
||||
packetsPerFrame = ceil((double)imageSize / (double)dataSize);
|
||||
|
||||
LOG(logDEBUG) << "Databytes: " << imageSize;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace sls
|
||||
|
@ -113,8 +113,8 @@ void Implementation::setDetectorType(const detectorType d) {
|
||||
case GOTTHARD:
|
||||
case EIGER:
|
||||
case JUNGFRAU:
|
||||
case CHIPTESTBOARD:
|
||||
case MOENCH:
|
||||
case CHIPTESTBOARD:
|
||||
case MYTHEN3:
|
||||
case GOTTHARD2:
|
||||
LOG(logINFO) << " ***** " << ToString(d) << " Receiver *****";
|
||||
@ -138,12 +138,12 @@ void Implementation::setDetectorType(const detectorType d) {
|
||||
case JUNGFRAU:
|
||||
generalData = new JungfrauData();
|
||||
break;
|
||||
case CHIPTESTBOARD:
|
||||
generalData = new ChipTestBoardData();
|
||||
break;
|
||||
case MOENCH:
|
||||
generalData = new MoenchData();
|
||||
break;
|
||||
case CHIPTESTBOARD:
|
||||
generalData = new ChipTestBoardData();
|
||||
break;
|
||||
case MYTHEN3:
|
||||
generalData = new Mythen3Data();
|
||||
break;
|
||||
|
@ -460,7 +460,6 @@ void Listener::CopyPacket(char *dst, char *src, uint32_t dataSize,
|
||||
memcpy(dst + dataSize - 2, &src[detHeaderSize], dataSize + 2);
|
||||
break;
|
||||
case CHIPTESTBOARD:
|
||||
case MOENCH:
|
||||
if (pnum == (generalData->packetsPerFrame - 1))
|
||||
memcpy(dst + (pnum * dataSize), &src[detHeaderSize],
|
||||
correctedDataSize);
|
||||
|
@ -16,6 +16,9 @@ void MasterAttributes::GetBinaryAttributes(
|
||||
case slsDetectorDefs::JUNGFRAU:
|
||||
GetJungfrauBinaryAttributes(w);
|
||||
break;
|
||||
case slsDetectorDefs::MOENCH:
|
||||
GetMoenchBinaryAttributes(w);
|
||||
break;
|
||||
case slsDetectorDefs::EIGER:
|
||||
GetEigerBinaryAttributes(w);
|
||||
break;
|
||||
@ -25,9 +28,6 @@ void MasterAttributes::GetBinaryAttributes(
|
||||
case slsDetectorDefs::GOTTHARD2:
|
||||
GetGotthard2BinaryAttributes(w);
|
||||
break;
|
||||
case slsDetectorDefs::MOENCH:
|
||||
GetMoenchBinaryAttributes(w);
|
||||
break;
|
||||
case slsDetectorDefs::CHIPTESTBOARD:
|
||||
GetCtbBinaryAttributes(w);
|
||||
break;
|
||||
@ -48,6 +48,9 @@ void MasterAttributes::WriteHDF5Attributes(H5::H5File *fd, H5::Group *group) {
|
||||
case slsDetectorDefs::JUNGFRAU:
|
||||
WriteJungfrauHDF5Attributes(fd, group);
|
||||
break;
|
||||
case slsDetectorDefs::MOENCH:
|
||||
WriteMoenchHDF5Attributes(fd, group);
|
||||
break;
|
||||
case slsDetectorDefs::EIGER:
|
||||
WriteEigerHDF5Attributes(fd, group);
|
||||
break;
|
||||
@ -57,9 +60,6 @@ void MasterAttributes::WriteHDF5Attributes(H5::H5File *fd, H5::Group *group) {
|
||||
case slsDetectorDefs::GOTTHARD2:
|
||||
WriteGotthard2HDF5Attributes(fd, group);
|
||||
break;
|
||||
case slsDetectorDefs::MOENCH:
|
||||
WriteMoenchHDF5Attributes(fd, group);
|
||||
break;
|
||||
case slsDetectorDefs::CHIPTESTBOARD:
|
||||
WriteCtbHDF5Attributes(fd, group);
|
||||
break;
|
||||
@ -622,6 +622,28 @@ void MasterAttributes::WriteJungfrauHDF5Attributes(H5::H5File *fd,
|
||||
}
|
||||
#endif
|
||||
|
||||
void MasterAttributes::GetMoenchBinaryAttributes(
|
||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
|
||||
w->Key("Exptime");
|
||||
w->String(ToString(exptime).c_str());
|
||||
w->Key("Period");
|
||||
w->String(ToString(period).c_str());
|
||||
w->Key("Number of UDP Interfaces");
|
||||
w->Uint(numUDPInterfaces);
|
||||
w->Key("Number of rows");
|
||||
w->Uint(readNRows);
|
||||
}
|
||||
|
||||
#ifdef HDF5C
|
||||
void MasterAttributes::WriteMoenchuHDF5Attributes(H5::H5File *fd,
|
||||
H5::Group *group) {
|
||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
MasterAttributes::WriteHDF5NumUDPInterfaces(fd, group);
|
||||
MasterAttributes::WriteHDF5ReadNRows(fd, group);
|
||||
}
|
||||
#endif
|
||||
|
||||
void MasterAttributes::GetEigerBinaryAttributes(
|
||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
|
||||
w->Key("Dynamic Range");
|
||||
@ -719,31 +741,6 @@ void MasterAttributes::WriteGotthard2HDF5Attributes(H5::H5File *fd,
|
||||
}
|
||||
#endif
|
||||
|
||||
void MasterAttributes::GetMoenchBinaryAttributes(
|
||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
|
||||
w->Key("Exptime");
|
||||
w->String(ToString(exptime).c_str());
|
||||
w->Key("Period");
|
||||
w->String(ToString(period).c_str());
|
||||
w->Key("Ten Giga");
|
||||
w->Uint(tenGiga);
|
||||
w->Key("ADC Mask");
|
||||
w->String(ToStringHex(adcmask).c_str());
|
||||
w->Key("Analog Samples");
|
||||
w->Uint(analogSamples);
|
||||
}
|
||||
|
||||
#ifdef HDF5C
|
||||
void MasterAttributes::WriteMoenchHDF5Attributes(H5::H5File *fd,
|
||||
H5::Group *group) {
|
||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
||||
MasterAttributes::WriteHDF5AdcMask(fd, group);
|
||||
MasterAttributes::WriteHDF5AnalogSamples(fd, group);
|
||||
}
|
||||
#endif
|
||||
|
||||
void MasterAttributes::GetCtbBinaryAttributes(
|
||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
|
||||
w->Key("Exptime");
|
||||
|
@ -24,9 +24,9 @@ namespace sls {
|
||||
|
||||
#define MAX_FRAMES_PER_FILE 20000
|
||||
#define SHORT_MAX_FRAMES_PER_FILE 100000
|
||||
#define MOENCH_MAX_FRAMES_PER_FILE 100000
|
||||
#define EIGER_MAX_FRAMES_PER_FILE 10000
|
||||
#define JFRAU_MAX_FRAMES_PER_FILE 10000
|
||||
#define MOENCH_MAX_FRAMES_PER_FILE 10000
|
||||
#define CTB_MAX_FRAMES_PER_FILE 20000
|
||||
#define MYTHEN3_MAX_FRAMES_PER_FILE 10000
|
||||
#define GOTTHARD2_MAX_FRAMES_PER_FILE 20000
|
||||
|
Reference in New Issue
Block a user