mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
ctb, moench, eiger, gotthard: get number of channels for moench and ctb, others removed unnecessary variables in shm, added moench virtual sever (#86)
This commit is contained in:
parent
013836bea5
commit
758afad02c
@ -4,4 +4,5 @@ add_subdirectory(gotthardDetectorServer)
|
||||
add_subdirectory(jungfrauDetectorServer)
|
||||
#add_subdirectory(moenchDetectorServer)
|
||||
add_subdirectory(mythen3DetectorServer)
|
||||
add_subdirectory(gotthard2DetectorServer)
|
||||
add_subdirectory(gotthard2DetectorServer)
|
||||
add_subdirectory(moenchDetectorServer)
|
||||
|
Binary file not shown.
@ -2552,9 +2552,39 @@ int calculateDataBytes(){
|
||||
return dataBytes;
|
||||
}
|
||||
|
||||
int getTotalNumberOfChannels() {return (getNumberOfChannelsPerChip() * getNumberOfChips());}
|
||||
int getTotalNumberOfChannels() {
|
||||
int nchanx = 0, nchany = 0;
|
||||
getTotalNumberOfChannels(&nchanx, &nchany);
|
||||
return nchanx * nchany;
|
||||
}
|
||||
|
||||
int getNumberOfChannels(int* nchanx, int* nchany) {
|
||||
int nachans = 0, ndchans = 0;
|
||||
// analog channels (normal, analog/digital readout)
|
||||
if (analogEnable) {
|
||||
uint32_t mask = enableTenGigabitEthernet(-1) ? adcEnableMask_10g : adcEnableMask_1g;
|
||||
if (mask == BIT32_MASK) {
|
||||
nachans = NCHAN_ANALOG;
|
||||
} else {
|
||||
int ich = 0;
|
||||
for (ich = 0; ich < NCHAN_ANALOG; ++ich) {
|
||||
if ((mask & (1 << ich)) != 0U)
|
||||
++nachans;
|
||||
}
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("Analog Channels: %d\n", nachans));
|
||||
}
|
||||
|
||||
// digital channels (digital, analog/digital readout)
|
||||
if (digitalEnable) {
|
||||
ndchans = 64;
|
||||
FILE_LOG(logDEBUG, ("Digital Channels: %d\n", ndchans));
|
||||
}
|
||||
*nchanx = nachans + ndchans;
|
||||
FILE_LOG(logDEBUG, ("Total #Channels: %d\n", *nchanx));
|
||||
*nchany = 1;
|
||||
}
|
||||
|
||||
int getNumberOfChips(){return NCHIP;}
|
||||
int getNumberOfDACs(){return NDAC;}
|
||||
int getNumberOfChannelsPerChip(){return NCHAN;}
|
||||
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2177,9 +2177,26 @@ int calculateDataBytes(){
|
||||
return dataBytes;
|
||||
}
|
||||
|
||||
int getTotalNumberOfChannels() {return (getNumberOfChannelsPerChip() * getNumberOfChips());}
|
||||
int getTotalNumberOfChannels() {
|
||||
int nchanx = 0, nchany = 0;
|
||||
getTotalNumberOfChannels(&nchanx, &nchany);
|
||||
return nchanx * nchany;
|
||||
}
|
||||
|
||||
int getNumberOfChannels(int* nchanx, int* nchany) {
|
||||
uint32_t mask = enableTenGigabitEthernet(-1) ? adcEnableMask_10g : adcEnableMask_1g;
|
||||
// count number of channels in x, each adc has 25 channels each
|
||||
int nchanTop = __builtin_popcount(mask & 0xF0F0F0F0) * NCHANS_PER_ADC;
|
||||
int nchanBot = __builtin_popcount(mask & 0x0F0F0F0F) * NCHANS_PER_ADC;
|
||||
*nchanx = nchanTop > 0 ? nchanTop : nchanBot;
|
||||
// if both top and bottom adcs enabled, rows = 2
|
||||
int nrows = 1;
|
||||
if (nchanTop > 0 && nchanBot > 0) {
|
||||
nrows = 2;
|
||||
}
|
||||
*nchany = nSamples / NSAMPLES_PER_ROW * nrows;
|
||||
}
|
||||
|
||||
int getNumberOfChips(){return NCHIP;}
|
||||
int getNumberOfDACs(){return NDAC;}
|
||||
int getNumberOfChannelsPerChip(){return NCHAN;}
|
||||
|
||||
|
||||
|
@ -59,6 +59,7 @@ enum CLKINDEX {RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS};
|
||||
#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
|
||||
#define CLK_FREQ (156.25) /* MHz */
|
||||
#define NSAMPLES_PER_ROW (25)
|
||||
#define NCHANS_PER_ADC (25)
|
||||
|
||||
/** Default Parameters */
|
||||
#define DEFAULT_PATTERN_FILE ("DefaultPattern.txt")
|
||||
|
@ -574,8 +574,12 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod);
|
||||
#endif
|
||||
int calculateDataBytes();
|
||||
int getTotalNumberOfChannels();
|
||||
#if defined(MOENCHD) || defined(CHIPTESTBOARDD)
|
||||
int getNumberOfChannels(int* nchanx, int* nchany);
|
||||
#endif
|
||||
int getNumberOfChips();
|
||||
int getNumberOfDACs();
|
||||
int getNumberOfChannelsPerChip();
|
||||
|
||||
|
||||
|
||||
|
@ -216,3 +216,4 @@ int get_current_source(int);
|
||||
int set_current_source(int);
|
||||
int get_timing_source(int);
|
||||
int set_timing_source(int);
|
||||
int get_num_channels(int);
|
||||
|
@ -316,6 +316,7 @@ const char* getFunctionName(enum detFuncs func) {
|
||||
case F_SET_CURRENT_SOURCE: return "F_SET_CURRENT_SOURCE";
|
||||
case F_GET_TIMING_SOURCE: return "F_GET_TIMING_SOURCE";
|
||||
case F_SET_TIMING_SOURCE: return "F_SET_TIMING_SOURCE";
|
||||
case F_GET_NUM_CHANNELS: return "F_GET_NUM_CHANNELS";
|
||||
|
||||
default: return "Unknown Function";
|
||||
}
|
||||
@ -508,6 +509,7 @@ void function_table() {
|
||||
flist[F_SET_CURRENT_SOURCE] = &set_current_source;
|
||||
flist[F_GET_TIMING_SOURCE] = &get_timing_source;
|
||||
flist[F_SET_TIMING_SOURCE] = &set_timing_source;
|
||||
flist[F_GET_NUM_CHANNELS] = &get_num_channels;
|
||||
|
||||
// check
|
||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||
@ -2833,19 +2835,12 @@ int send_update(int file_des) {
|
||||
if (n < 0) return printSocketReadError();
|
||||
#endif
|
||||
|
||||
// threshold energy
|
||||
#ifdef EIGERD
|
||||
i32 = getThresholdEnergy(GET_FLAG);
|
||||
n = sendData(file_des,&i32,sizeof(i32),INT32);
|
||||
if (n < 0) return printSocketReadError();
|
||||
#endif
|
||||
|
||||
// #frames
|
||||
i64 = getNumFrames();
|
||||
n = sendData(file_des,&i64,sizeof(i64),INT64);
|
||||
if (n < 0) return printSocketReadError();
|
||||
|
||||
// #storage cell, storage_cell_delay
|
||||
// #storage cell
|
||||
#ifdef JUNGFRAUD
|
||||
i64 = getNumAdditionalStorageCells();
|
||||
n = sendData(file_des,&i64,sizeof(i64),INT64);
|
||||
@ -2876,42 +2871,18 @@ int send_update(int file_des) {
|
||||
if (n < 0) return printSocketReadError();
|
||||
#endif
|
||||
|
||||
// readout mode
|
||||
#ifdef CHIPTESTBOARDD
|
||||
i32 = getReadoutMode();
|
||||
n = sendData(file_des,&i32,sizeof(i32),INT32);
|
||||
if (n < 0) return printSocketReadError();
|
||||
#endif
|
||||
|
||||
// roi
|
||||
#if defined(GOTTHARDD)
|
||||
ROI retval = getROI();
|
||||
sendData(file_des, &retval.xmin, sizeof(int), INT32);
|
||||
sendData(file_des, &retval.xmax, sizeof(int), INT32);
|
||||
#endif
|
||||
|
||||
// tengiga
|
||||
#if defined(EIGERD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
i32 = enableTenGigabitEthernet(-1);
|
||||
n = sendData(file_des,&i32,sizeof(i32),INT32);
|
||||
if (n < 0) return printSocketReadError();
|
||||
#endif
|
||||
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
// analog samples
|
||||
i32 = getNumAnalogSamples();
|
||||
n = sendData(file_des,&i32,sizeof(i32),INT32);
|
||||
if (n < 0) return printSocketReadError();
|
||||
|
||||
// 1g adcmask
|
||||
i32 = getADCEnableMask();
|
||||
n = sendData(file_des,&i32,sizeof(i32),INT32);
|
||||
if (n < 0) return printSocketReadError();
|
||||
|
||||
// 10g adc mask
|
||||
i32 = getADCEnableMask_10G();
|
||||
n = sendData(file_des,&i32,sizeof(i32),INT32);
|
||||
if (n < 0) return printSocketReadError();
|
||||
// number of channels
|
||||
#if defined(MOENCHD) || defined(CHIPTESTBOARDD)
|
||||
{
|
||||
int nx = 0, ny = 0;
|
||||
getNumberOfChannels(&nx, &ny);
|
||||
i32 = nx;
|
||||
n = sendData(file_des,&i32,sizeof(i32),INT32);
|
||||
if (n < 0) return printSocketReadError();
|
||||
i32 = ny;
|
||||
n = sendData(file_des,&i32,sizeof(i32),INT32);
|
||||
if (n < 0) return printSocketReadError();
|
||||
}
|
||||
#endif
|
||||
|
||||
// num udp interfaces
|
||||
@ -6887,4 +6858,22 @@ int get_timing_source(int file_des) {
|
||||
FILE_LOG(logDEBUG1, ("Get timing source retval:%d\n", retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
int get_num_channels(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retvals[2] = {-1, -1};
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Getting number of channels\n"));
|
||||
|
||||
#if !defined(MOENCHD) && !defined(CHIPTESTBOARDD)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
getNumberOfChannels(&retvals[0], &retvals[1]);
|
||||
FILE_LOG(logDEBUG1, ("Get number of channels sretval:[%d, %d]\n", retvals[0], retvals[1]));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, retvals, sizeof(retvals));
|
||||
}
|
@ -287,6 +287,8 @@ void DetectorImpl::addSlsDetector(const std::string &hostname) {
|
||||
multi_shm()->multiDetectorType =
|
||||
Parallel(&slsDetector::getDetectorType, {})
|
||||
.tsquash("Inconsistent detector types.");
|
||||
// for moench and ctb
|
||||
detectors[pos]->updateNumberOfChannels();
|
||||
}
|
||||
|
||||
void DetectorImpl::updateDetectorSize() {
|
||||
|
@ -329,14 +329,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||
shm()->controlPort = DEFAULT_PORTNO;
|
||||
shm()->stopPort = DEFAULT_PORTNO + 1;
|
||||
sls::strcpy_safe(shm()->settingsDir, getenv("HOME"));
|
||||
shm()->roi.xmin = -1;
|
||||
shm()->roi.xmax = -1;
|
||||
shm()->adcEnableMaskOneGiga = BIT32_MASK;
|
||||
shm()->adcEnableMaskTenGiga = BIT32_MASK;
|
||||
shm()->roMode = ANALOG_ONLY;
|
||||
shm()->currentSettings = UNINITIALIZED;
|
||||
shm()->currentThresholdEV = -1;
|
||||
shm()->nASamples = 1;
|
||||
shm()->nFrames = 1;
|
||||
shm()->nTriggers = 1;
|
||||
shm()->nBursts = 1;
|
||||
@ -347,7 +340,6 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||
sls::strcpy_safe(shm()->rxHostname, "none");
|
||||
shm()->rxTCPPort = DEFAULT_PORTNO + 2;
|
||||
shm()->useReceiverFlag = false;
|
||||
shm()->tenGigaEnable = false;
|
||||
shm()->flippedDataX = false;
|
||||
shm()->zmqport = DEFAULT_ZMQ_CL_PORTNO +
|
||||
(detId * ((shm()->myDetectorType == EIGER) ? 2 : 1));
|
||||
@ -410,9 +402,6 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||
shm()->dynamicRange = parameters.dynamicRange;
|
||||
shm()->nGappixels.x = parameters.nGappixelsX;
|
||||
shm()->nGappixels.y = parameters.nGappixelsY;
|
||||
|
||||
// update #nchan, as it depends on #samples, adcmask,
|
||||
updateNumberOfChannels();
|
||||
}
|
||||
|
||||
int slsDetector::sendModule(sls_detector_module *myMod,
|
||||
@ -558,48 +547,14 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType() const {
|
||||
}
|
||||
|
||||
void slsDetector::updateNumberOfChannels() {
|
||||
|
||||
if (shm()->myDetectorType == CHIPTESTBOARD) {
|
||||
|
||||
int nachans = 0, ndchans = 0;
|
||||
// analog channels (normal, analog/digital readout)
|
||||
if (shm()->roMode == slsDetectorDefs::ANALOG_ONLY ||
|
||||
shm()->roMode == slsDetectorDefs::ANALOG_AND_DIGITAL) {
|
||||
uint32_t mask = shm()->tenGigaEnable ? shm()->adcEnableMaskTenGiga : shm()->adcEnableMaskOneGiga;
|
||||
if (mask == BIT32_MASK) {
|
||||
nachans = 32;
|
||||
} else {
|
||||
for (int ich = 0; ich < 32; ++ich) {
|
||||
if ((mask & (1 << ich)) != 0U)
|
||||
++nachans;
|
||||
}
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "#Analog Channels:" << nachans;
|
||||
}
|
||||
|
||||
// digital channels (ctb only, digital, analog/digital readout)
|
||||
if (shm()->roMode == DIGITAL_ONLY ||
|
||||
shm()->roMode == ANALOG_AND_DIGITAL) {
|
||||
ndchans = 64;
|
||||
FILE_LOG(logDEBUG1) << "#Digital Channels:" << ndchans;
|
||||
}
|
||||
shm()->nChan.x = nachans + ndchans;
|
||||
FILE_LOG(logDEBUG1) << "# Total #Channels:" << shm()->nChan.x;
|
||||
}
|
||||
|
||||
|
||||
else if (shm()->myDetectorType == MOENCH) {
|
||||
uint32_t mask = shm()->tenGigaEnable ? shm()->adcEnableMaskTenGiga : shm()->adcEnableMaskOneGiga;
|
||||
// count number of channels in x, each adc has 25 channels each
|
||||
int nchanTop = __builtin_popcount(mask & 0xF0F0F0F0) * 25;
|
||||
int nchanBot = __builtin_popcount(mask & 0x0F0F0F0F) * 25;
|
||||
shm()->nChan.x = nchanTop > 0 ? nchanTop : nchanBot;
|
||||
// if both top and bottom adcs enabled, rows = 2
|
||||
int nrows = 1;
|
||||
if (nchanTop > 0 && nchanBot > 0) {
|
||||
nrows = 2;
|
||||
}
|
||||
shm()->nChan.y = shm()->nASamples / 25 * nrows;
|
||||
if (shm()->myDetectorType == CHIPTESTBOARD ||
|
||||
shm()->myDetectorType == MOENCH) {
|
||||
FILE_LOG(logDEBUG1) << "Updating number of channels";
|
||||
std::array<int, 2> retvals{};
|
||||
sendToDetector(F_GET_NUM_CHANNELS, nullptr, retvals);
|
||||
FILE_LOG(logDEBUG1) << "Number of channels retval: [" << retvals[0] << ", " << retvals[1] << ']';
|
||||
shm()->nChan.x = retvals[0];
|
||||
shm()->nChan.y = retvals[1];
|
||||
}
|
||||
}
|
||||
|
||||
@ -765,12 +720,6 @@ void slsDetector::updateCachedDetectorVariables() {
|
||||
shm()->currentSettings = static_cast<detectorSettings>(i32);
|
||||
}
|
||||
|
||||
// threshold
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
n += client.Receive(&i32, sizeof(i32));
|
||||
shm()->currentThresholdEV = i32;
|
||||
}
|
||||
|
||||
// frame number
|
||||
n += client.Receive(&i64, sizeof(i64));
|
||||
shm()->nFrames = i64;
|
||||
@ -801,51 +750,13 @@ void slsDetector::updateCachedDetectorVariables() {
|
||||
shm()->burstMode = static_cast<burstMode>(i32);
|
||||
}
|
||||
|
||||
// readout mode
|
||||
if (shm()->myDetectorType == CHIPTESTBOARD) {
|
||||
n += client.Receive(&i32, sizeof(i32));
|
||||
shm()->roMode = static_cast<readoutMode>(i32);
|
||||
}
|
||||
|
||||
// roi
|
||||
if (shm()->myDetectorType == GOTTHARD) {
|
||||
n += client.Receive(&i32, sizeof(i32));
|
||||
shm()->roi.xmin = i32;
|
||||
n += client.Receive(&i32, sizeof(i32));
|
||||
shm()->roi.xmax = i32;
|
||||
}
|
||||
|
||||
// 10GbE
|
||||
if (shm()->myDetectorType == EIGER ||
|
||||
shm()->myDetectorType == CHIPTESTBOARD ||
|
||||
shm()->myDetectorType == MOENCH) {
|
||||
n += client.Receive(&i32, sizeof(i32));
|
||||
shm()->tenGigaEnable = static_cast<bool>(i32);
|
||||
}
|
||||
|
||||
// analog samples and adc enable masks
|
||||
// number of channels (depends on #samples, adcmask)
|
||||
if (shm()->myDetectorType == CHIPTESTBOARD ||
|
||||
shm()->myDetectorType == MOENCH) {
|
||||
|
||||
// analog samples
|
||||
uint32_t u32 = 0;
|
||||
n += client.Receive(&u32, sizeof(u32));
|
||||
shm()->nASamples = u32;
|
||||
|
||||
// 1gb adcmask
|
||||
u32 = 0;
|
||||
n += client.Receive(&u32, sizeof(u32));
|
||||
shm()->adcEnableMaskOneGiga = u32;
|
||||
|
||||
// 10gb adcmask
|
||||
n += client.Receive(&u32, sizeof(u32));
|
||||
shm()->adcEnableMaskTenGiga = u32;
|
||||
|
||||
if (shm()->myDetectorType == MOENCH)
|
||||
setAdditionalJsonParameter("adcmask", std::to_string(shm()->tenGigaEnable ? shm()->adcEnableMaskTenGiga : shm()->adcEnableMaskOneGiga));
|
||||
|
||||
// update #nchan, as it depends on #samples, adcmask,
|
||||
updateNumberOfChannels();
|
||||
n += client.Receive(&i32, sizeof(i32));
|
||||
shm()->nChan.x = i32;
|
||||
n += client.Receive(&i32, sizeof(i32));
|
||||
shm()->nChan.y = i32;
|
||||
}
|
||||
|
||||
// num udp interfaces
|
||||
@ -989,9 +900,7 @@ int slsDetector::getThresholdEnergy() {
|
||||
std::string result = getAdditionalJsonParameter("threshold");
|
||||
// convert to integer
|
||||
try {
|
||||
// udpate shm
|
||||
shm()->currentThresholdEV = stoi(result);
|
||||
return shm()->currentThresholdEV;
|
||||
return stoi(result);
|
||||
}
|
||||
// not found or cannot scan integer
|
||||
catch (...) {
|
||||
@ -1003,8 +912,7 @@ int slsDetector::getThresholdEnergy() {
|
||||
int retval = -1;
|
||||
sendToDetector(F_GET_THRESHOLD_ENERGY, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "Threshold: " << retval;
|
||||
shm()->currentThresholdEV = retval;
|
||||
return shm()->currentThresholdEV;
|
||||
return retval;
|
||||
}
|
||||
|
||||
int slsDetector::setThresholdEnergy(int e_eV, detectorSettings isettings,
|
||||
@ -1013,7 +921,7 @@ int slsDetector::setThresholdEnergy(int e_eV, detectorSettings isettings,
|
||||
// check as there is client processing
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
setThresholdEnergyAndSettings(e_eV, isettings, tb);
|
||||
return shm()->currentThresholdEV;
|
||||
return e_eV;
|
||||
}
|
||||
|
||||
// moench - send threshold energy to processor
|
||||
@ -1021,9 +929,7 @@ int slsDetector::setThresholdEnergy(int e_eV, detectorSettings isettings,
|
||||
std::string result =
|
||||
setAdditionalJsonParameter("threshold", std::to_string(e_eV));
|
||||
if (result == std::to_string(e_eV)) {
|
||||
// update shm
|
||||
shm()->currentThresholdEV = e_eV;
|
||||
return shm()->currentThresholdEV;
|
||||
return e_eV;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@ -1344,7 +1250,6 @@ int slsDetector::getNumberOfAnalogSamples() {
|
||||
void slsDetector::setNumberOfAnalogSamples(int value) {
|
||||
FILE_LOG(logDEBUG1) << "Setting number of analog samples to " << value;
|
||||
sendToDetector(F_SET_NUM_ANALOG_SAMPLES, value, nullptr);
|
||||
shm()->nASamples = value;
|
||||
// update #nchan, as it depends on #samples, adcmask
|
||||
updateNumberOfChannels();
|
||||
if (shm()->useReceiverFlag) {
|
||||
@ -1694,7 +1599,6 @@ void slsDetector::setReadoutMode(const slsDetectorDefs::readoutMode mode) {
|
||||
auto arg = static_cast<uint32_t>(mode);
|
||||
FILE_LOG(logDEBUG1) << "Setting readout mode to " << arg;
|
||||
sendToDetector(F_SET_READOUT_MODE, arg, nullptr);
|
||||
shm()->roMode = mode;
|
||||
// update #nchan, as it depends on #samples, adcmask,
|
||||
if (shm()->myDetectorType == CHIPTESTBOARD) {
|
||||
updateNumberOfChannels();
|
||||
@ -1709,19 +1613,7 @@ slsDetectorDefs::readoutMode slsDetector::getReadoutMode() {
|
||||
FILE_LOG(logDEBUG1) << "Getting readout mode";
|
||||
sendToDetector(F_GET_READOUT_MODE, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "Readout mode: " << retval;
|
||||
readoutMode oldmode = shm()->roMode;
|
||||
shm()->roMode = static_cast<readoutMode>(retval);
|
||||
|
||||
if (oldmode != shm()->roMode) {
|
||||
// update #nchan, as it depends on #samples, adcmask,
|
||||
if (shm()->myDetectorType == CHIPTESTBOARD) {
|
||||
updateNumberOfChannels();
|
||||
}
|
||||
if (shm()->useReceiverFlag) {
|
||||
sendToReceiver(F_RECEIVER_SET_READOUT_MODE, shm()->roMode, nullptr);
|
||||
}
|
||||
}
|
||||
return shm()->roMode;
|
||||
return static_cast<readoutMode>(retval);
|
||||
}
|
||||
|
||||
void slsDetector::setInterruptSubframe(const bool enable) {
|
||||
@ -1843,30 +1735,30 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
|
||||
setDeactivatedRxrPaddingMode(
|
||||
static_cast<int>(shm()->rxPadDeactivatedModules));
|
||||
enableGapPixels(shm()->gappixels);
|
||||
enableTenGigabitEthernet(static_cast<int>(shm()->tenGigaEnable));
|
||||
enableTenGigabitEthernet(-1);
|
||||
setQuad(getQuad());
|
||||
break;
|
||||
|
||||
case CHIPTESTBOARD:
|
||||
setNumberOfAnalogSamples(getNumberOfAnalogSamples());
|
||||
setNumberOfDigitalSamples(getNumberOfDigitalSamples());
|
||||
enableTenGigabitEthernet(static_cast<int>(shm()->tenGigaEnable));
|
||||
setReadoutMode(shm()->roMode);
|
||||
setADCEnableMask(shm()->adcEnableMaskOneGiga);
|
||||
setTenGigaADCEnableMask(shm()->adcEnableMaskTenGiga);
|
||||
enableTenGigabitEthernet(-1);
|
||||
setReadoutMode(getReadoutMode());
|
||||
setADCEnableMask(getADCEnableMask());
|
||||
setTenGigaADCEnableMask(getTenGigaADCEnableMask());
|
||||
setReceiverDbitOffset(shm()->rxDbitOffset);
|
||||
setReceiverDbitList(shm()->rxDbitList);
|
||||
break;
|
||||
|
||||
case MOENCH:
|
||||
setNumberOfAnalogSamples(getNumberOfAnalogSamples());
|
||||
enableTenGigabitEthernet(static_cast<int>(shm()->tenGigaEnable));
|
||||
setADCEnableMask(shm()->adcEnableMaskOneGiga);
|
||||
setTenGigaADCEnableMask(shm()->adcEnableMaskTenGiga);
|
||||
enableTenGigabitEthernet(-1);
|
||||
setADCEnableMask(getADCEnableMask());
|
||||
setTenGigaADCEnableMask(getTenGigaADCEnableMask());
|
||||
break;
|
||||
|
||||
case GOTTHARD:
|
||||
sendROItoReceiver();
|
||||
setROI(getROI());
|
||||
break;
|
||||
|
||||
case MYTHEN3:
|
||||
@ -2612,73 +2504,29 @@ void slsDetector::clearROI() {
|
||||
}
|
||||
|
||||
void slsDetector::setROI(slsDetectorDefs::ROI arg) {
|
||||
int fnum = F_SET_ROI;
|
||||
int ret = FAIL;
|
||||
if (arg.xmin < 0 || arg.xmax >= getNumberOfChannels().x) {
|
||||
arg.xmin = -1;
|
||||
arg.xmax = -1;
|
||||
}
|
||||
std::array<int, 2> args{arg.xmin, arg.xmax};
|
||||
FILE_LOG(logDEBUG) << "Sending ROI to detector [" << arg.xmin << ", "
|
||||
<< arg.xmax << "]";
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
client.Send(&fnum, sizeof(fnum));
|
||||
client.Send(&arg.xmin, sizeof(int));
|
||||
client.Send(&arg.xmax, sizeof(int));
|
||||
client.Receive(&ret, sizeof(ret));
|
||||
// handle ret
|
||||
if (ret == FAIL) {
|
||||
char mess[MAX_STR_LENGTH]{};
|
||||
client.Receive(mess, MAX_STR_LENGTH);
|
||||
throw RuntimeError("Detector " + std::to_string(detId) +
|
||||
" returned error: " + std::string(mess));
|
||||
} else {
|
||||
memcpy(&shm()->roi, &arg, sizeof(ROI));
|
||||
if (ret == FORCE_UPDATE) {
|
||||
updateCachedDetectorVariables();
|
||||
}
|
||||
}
|
||||
|
||||
sendROItoReceiver();
|
||||
}
|
||||
|
||||
void slsDetector::sendROItoReceiver() {
|
||||
// update roi in receiver
|
||||
<< arg.xmax << "]";
|
||||
sendToDetector(F_SET_ROI, args, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
FILE_LOG(logDEBUG1) << "Sending ROI to receiver";
|
||||
sendToReceiver(F_RECEIVER_SET_ROI, shm()->roi, nullptr);
|
||||
sendToReceiver(F_RECEIVER_SET_ROI, arg, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
slsDetectorDefs::ROI slsDetector::getROI() {
|
||||
int fnum = F_GET_ROI;
|
||||
int ret = FAIL;
|
||||
FILE_LOG(logDEBUG1) << "Getting ROI from detector";
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
client.Send(&fnum, sizeof(fnum));
|
||||
client.Receive(&ret, sizeof(ret));
|
||||
// handle ret
|
||||
if (ret == FAIL) {
|
||||
char mess[MAX_STR_LENGTH]{};
|
||||
client.Receive(mess, MAX_STR_LENGTH);
|
||||
throw RuntimeError("Detector " + std::to_string(detId) +
|
||||
" returned error: " + std::string(mess));
|
||||
} else {
|
||||
ROI retval;
|
||||
client.Receive(&retval.xmin, sizeof(int));
|
||||
client.Receive(&retval.xmax, sizeof(int));
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "ROI retval [" << retval.xmin << "," << retval.xmax << "]";
|
||||
if (ret == FORCE_UPDATE) {
|
||||
updateCachedDetectorVariables();
|
||||
}
|
||||
// if different from shm, update and send to receiver
|
||||
if (shm()->roi.xmin != retval.xmin || shm()->roi.xmax != retval.xmax) {
|
||||
memcpy(&shm()->roi, &retval, sizeof(ROI));
|
||||
sendROItoReceiver();
|
||||
}
|
||||
}
|
||||
|
||||
return shm()->roi;
|
||||
std::array<int, 2> retvals{};
|
||||
sendToDetector(F_GET_ROI, nullptr, retvals);
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "ROI retval [" << retvals[0] << "," << retvals[1] << "]";
|
||||
slsDetectorDefs::ROI retval;
|
||||
retval.xmin = retvals[0];
|
||||
retval.xmax = retvals[1];
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setADCEnableMask(uint32_t mask) {
|
||||
@ -2686,20 +2534,17 @@ void slsDetector::setADCEnableMask(uint32_t mask) {
|
||||
FILE_LOG(logDEBUG1) << "Setting ADC Enable mask to 0x" << std::hex << arg
|
||||
<< std::dec;
|
||||
sendToDetector(F_SET_ADC_ENABLE_MASK, &arg, sizeof(arg), nullptr, 0);
|
||||
shm()->adcEnableMaskOneGiga = mask;
|
||||
|
||||
// update #nchan, as it depends on #samples, adcmask,
|
||||
updateNumberOfChannels();
|
||||
|
||||
// send to processor
|
||||
if (shm()->myDetectorType == MOENCH && !shm()->tenGigaEnable)
|
||||
setAdditionalJsonParameter("adcmask",
|
||||
std::to_string(shm()->adcEnableMaskOneGiga));
|
||||
if (shm()->myDetectorType == MOENCH)
|
||||
setAdditionalJsonParameter("adcmask_1g", std::to_string(mask));
|
||||
|
||||
if (shm()->useReceiverFlag) {
|
||||
int fnum = F_RECEIVER_SET_ADC_MASK;
|
||||
int retval = -1;
|
||||
mask = shm()->adcEnableMaskOneGiga;
|
||||
FILE_LOG(logDEBUG1) << "Setting ADC Enable mask to 0x" << std::hex
|
||||
<< mask << std::dec << " in receiver";
|
||||
sendToReceiver(fnum, mask, retval);
|
||||
@ -2708,12 +2553,10 @@ void slsDetector::setADCEnableMask(uint32_t mask) {
|
||||
|
||||
uint32_t slsDetector::getADCEnableMask() {
|
||||
uint32_t retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Getting ADC Enable mask";
|
||||
sendToDetector(F_GET_ADC_ENABLE_MASK, nullptr, 0, &retval, sizeof(retval));
|
||||
shm()->adcEnableMaskOneGiga = retval;
|
||||
FILE_LOG(logDEBUG1) << "ADC Enable Mask: 0x" << std::hex << retval
|
||||
<< std::dec;
|
||||
return shm()->adcEnableMaskOneGiga;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setTenGigaADCEnableMask(uint32_t mask) {
|
||||
@ -2721,20 +2564,17 @@ void slsDetector::setTenGigaADCEnableMask(uint32_t mask) {
|
||||
FILE_LOG(logDEBUG1) << "Setting 10Gb ADC Enable mask to 0x" << std::hex << arg
|
||||
<< std::dec;
|
||||
sendToDetector(F_SET_ADC_ENABLE_MASK_10G, &arg, sizeof(arg), nullptr, 0);
|
||||
shm()->adcEnableMaskTenGiga = mask;
|
||||
|
||||
// update #nchan, as it depends on #samples, adcmask,
|
||||
updateNumberOfChannels();
|
||||
|
||||
// send to processor
|
||||
if (shm()->myDetectorType == MOENCH && shm()->tenGigaEnable)
|
||||
setAdditionalJsonParameter("adcmask",
|
||||
std::to_string(shm()->adcEnableMaskTenGiga));
|
||||
if (shm()->myDetectorType == MOENCH)
|
||||
setAdditionalJsonParameter("adcmask_10g", std::to_string(mask));
|
||||
|
||||
if (shm()->useReceiverFlag) {
|
||||
int fnum = F_RECEIVER_SET_ADC_MASK_10G;
|
||||
int retval = -1;
|
||||
mask = shm()->adcEnableMaskTenGiga;
|
||||
FILE_LOG(logDEBUG1) << "Setting 10Gb ADC Enable mask to 0x" << std::hex
|
||||
<< mask << std::dec << " in receiver";
|
||||
sendToReceiver(fnum, mask, retval);
|
||||
@ -2743,12 +2583,10 @@ void slsDetector::setTenGigaADCEnableMask(uint32_t mask) {
|
||||
|
||||
uint32_t slsDetector::getTenGigaADCEnableMask() {
|
||||
uint32_t retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Getting 10Gb ADC Enable mask";
|
||||
sendToDetector(F_GET_ADC_ENABLE_MASK_10G, nullptr, 0, &retval, sizeof(retval));
|
||||
shm()->adcEnableMaskTenGiga = retval;
|
||||
FILE_LOG(logDEBUG1) << "10Gb ADC Enable Mask: 0x" << std::hex << retval
|
||||
<< std::dec;
|
||||
return shm()->adcEnableMaskTenGiga;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setADCInvert(uint32_t value) {
|
||||
@ -3190,10 +3028,6 @@ void slsDetector::setModule(sls_detector_module &module, int tb) {
|
||||
if (ret == FORCE_UPDATE) {
|
||||
updateCachedDetectorVariables();
|
||||
}
|
||||
// update client structure
|
||||
if (module.eV != -1) {
|
||||
shm()->currentThresholdEV = module.eV;
|
||||
}
|
||||
}
|
||||
|
||||
sls_detector_module slsDetector::getModule() {
|
||||
@ -3207,9 +3041,6 @@ sls_detector_module slsDetector::getModule() {
|
||||
if (ret == FORCE_UPDATE) {
|
||||
updateCachedDetectorVariables();
|
||||
}
|
||||
if (myMod.eV != -1) {
|
||||
shm()->currentThresholdEV = myMod.eV;
|
||||
}
|
||||
return myMod;
|
||||
}
|
||||
|
||||
@ -3767,15 +3598,14 @@ bool slsDetector::enableTenGigabitEthernet(int value) {
|
||||
FILE_LOG(logDEBUG1) << "Enabling / Disabling 10Gbe: " << value;
|
||||
sendToDetector(F_ENABLE_TEN_GIGA, value, retval);
|
||||
FILE_LOG(logDEBUG1) << "10Gbe: " << retval;
|
||||
shm()->tenGigaEnable = static_cast<bool>(retval);
|
||||
if (shm()->useReceiverFlag) {
|
||||
retval = -1;
|
||||
value = static_cast<int>(shm()->tenGigaEnable);
|
||||
value = retval;
|
||||
if (shm()->useReceiverFlag && value != -1) {
|
||||
int retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Sending 10Gbe enable to receiver: " << value;
|
||||
sendToReceiver(F_ENABLE_RECEIVER_TEN_GIGA, value, retval);
|
||||
FILE_LOG(logDEBUG1) << "Receiver 10Gbe enable: " << retval;
|
||||
}
|
||||
return shm()->tenGigaEnable;
|
||||
return static_cast<bool>(retval);
|
||||
}
|
||||
|
||||
int slsDetector::setReceiverFifoDepth(int n_frames) {
|
||||
|
@ -13,7 +13,7 @@
|
||||
class ServerInterface;
|
||||
|
||||
#define SLS_SHMAPIVERSION 0x190726
|
||||
#define SLS_SHMVERSION 0x200302
|
||||
#define SLS_SHMVERSION 0x200309
|
||||
|
||||
/**
|
||||
* @short structure allocated in shared memory to store detector settings for
|
||||
@ -62,27 +62,9 @@ struct sharedSlsDetector {
|
||||
/** dynamic range of the detector data */
|
||||
int dynamicRange;
|
||||
|
||||
/** roi */
|
||||
slsDetectorDefs::ROI roi;
|
||||
|
||||
/** 1gb adc enable mask */
|
||||
uint32_t adcEnableMaskOneGiga;
|
||||
|
||||
/** 10gb adc enable mask */
|
||||
uint32_t adcEnableMaskTenGiga;
|
||||
|
||||
/** readout mode */
|
||||
slsDetectorDefs::readoutMode roMode;
|
||||
|
||||
/** detector settings (standard, fast, etc.) */
|
||||
slsDetectorDefs::detectorSettings currentSettings;
|
||||
|
||||
/** detector threshold (eV) */
|
||||
int currentThresholdEV;
|
||||
|
||||
/** number of analog samples */
|
||||
int nASamples;
|
||||
|
||||
/** number of frames */
|
||||
int64_t nFrames;
|
||||
|
||||
@ -101,7 +83,7 @@ struct sharedSlsDetector {
|
||||
/** burst mode */
|
||||
slsDetectorDefs::burstMode burstMode;
|
||||
|
||||
/** rate correction in ns */
|
||||
/** rate correction in ns (needed for default -1) */
|
||||
int64_t deadTime;
|
||||
|
||||
/** ip address/hostname of the receiver for client control via TCP */
|
||||
@ -114,9 +96,6 @@ struct sharedSlsDetector {
|
||||
* unset if socket connection is not possible */
|
||||
bool useReceiverFlag;
|
||||
|
||||
/** 10 Gbe enable*/
|
||||
bool tenGigaEnable;
|
||||
|
||||
/** flipped data across x or y axis */
|
||||
bool flippedDataX;
|
||||
|
||||
@ -126,7 +105,8 @@ struct sharedSlsDetector {
|
||||
/** tcp port from receiver to gui/different process (only data) */
|
||||
int rxZmqport;
|
||||
|
||||
/** data streaming (up stream) enable in receiver */
|
||||
/** data streaming (up stream) enable in receiver
|
||||
* (needed for restreaming dummy packet) */
|
||||
bool rxUpstream;
|
||||
|
||||
/* Receiver read frequency */
|
||||
@ -298,7 +278,7 @@ class slsDetector : public virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* Update total number of channels (chiptestboard or moench)
|
||||
* depending on the number of samples, adcenablemask, readout flags(ctb)
|
||||
* from the detector server
|
||||
*/
|
||||
void updateNumberOfChannels();
|
||||
|
||||
@ -1190,11 +1170,6 @@ class slsDetector : public virtual slsDetectorDefs {
|
||||
*/
|
||||
void setROI(slsDetectorDefs::ROI arg);
|
||||
|
||||
/**
|
||||
* Send ROI from shared memory to Receiver (Gotthard)
|
||||
*/
|
||||
void sendROItoReceiver();
|
||||
|
||||
/**
|
||||
* Get ROI (Gotthard)
|
||||
* Update receiver if different from shm
|
||||
|
@ -196,6 +196,7 @@ enum detFuncs{
|
||||
F_SET_CURRENT_SOURCE,
|
||||
F_GET_TIMING_SOURCE,
|
||||
F_SET_TIMING_SOURCE,
|
||||
F_GET_NUM_CHANNELS,
|
||||
|
||||
NUM_DET_FUNCTIONS,
|
||||
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this (detector server should not compile anyway) */
|
||||
@ -460,6 +461,7 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_SET_CURRENT_SOURCE: return "F_SET_CURRENT_SOURCE";
|
||||
case F_GET_TIMING_SOURCE: return "F_GET_TIMING_SOURCE";
|
||||
case F_SET_TIMING_SOURCE: return "F_SET_TIMING_SOURCE";
|
||||
case F_GET_NUM_CHANNELS: return "F_GET_NUM_CHANNELS";
|
||||
|
||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||
|
@ -3,10 +3,10 @@
|
||||
#define APILIB 0x200227
|
||||
#define APIRECEIVER 0x200227
|
||||
#define APIGUI 0x200227
|
||||
#define APICTB 0x200305
|
||||
#define APIGOTTHARD 0x200305
|
||||
#define APIMYTHEN3 0x200305
|
||||
#define APIEIGER 0x200305
|
||||
#define APIGOTTHARD2 0x200305
|
||||
#define APIMOENCH 0x200306
|
||||
#define APIJUNGFRAU 0x200306
|
||||
#define APIGOTTHARD 0x200309
|
||||
#define APIEIGER 0x200309
|
||||
#define APIMOENCH 0x200309
|
||||
#define APICTB 0x200309
|
||||
|
Loading…
x
Reference in New Issue
Block a user