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:
Dhanya Thattil 2020-03-10 09:08:08 +01:00 committed by GitHub
parent 013836bea5
commit 758afad02c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 156 additions and 304 deletions

View File

@ -4,4 +4,5 @@ add_subdirectory(gotthardDetectorServer)
add_subdirectory(jungfrauDetectorServer) add_subdirectory(jungfrauDetectorServer)
#add_subdirectory(moenchDetectorServer) #add_subdirectory(moenchDetectorServer)
add_subdirectory(mythen3DetectorServer) add_subdirectory(mythen3DetectorServer)
add_subdirectory(gotthard2DetectorServer) add_subdirectory(gotthard2DetectorServer)
add_subdirectory(moenchDetectorServer)

View File

@ -2552,9 +2552,39 @@ int calculateDataBytes(){
return dataBytes; 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 getNumberOfChips(){return NCHIP;}
int getNumberOfDACs(){return NDAC;} int getNumberOfDACs(){return NDAC;}
int getNumberOfChannelsPerChip(){return NCHAN;} int getNumberOfChannelsPerChip(){return NCHAN;}

View File

@ -2177,9 +2177,26 @@ int calculateDataBytes(){
return dataBytes; 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 getNumberOfChips(){return NCHIP;}
int getNumberOfDACs(){return NDAC;} int getNumberOfDACs(){return NDAC;}
int getNumberOfChannelsPerChip(){return NCHAN;} int getNumberOfChannelsPerChip(){return NCHAN;}

View File

@ -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 NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
#define CLK_FREQ (156.25) /* MHz */ #define CLK_FREQ (156.25) /* MHz */
#define NSAMPLES_PER_ROW (25) #define NSAMPLES_PER_ROW (25)
#define NCHANS_PER_ADC (25)
/** Default Parameters */ /** Default Parameters */
#define DEFAULT_PATTERN_FILE ("DefaultPattern.txt") #define DEFAULT_PATTERN_FILE ("DefaultPattern.txt")

View File

@ -574,8 +574,12 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod);
#endif #endif
int calculateDataBytes(); int calculateDataBytes();
int getTotalNumberOfChannels(); int getTotalNumberOfChannels();
#if defined(MOENCHD) || defined(CHIPTESTBOARDD)
int getNumberOfChannels(int* nchanx, int* nchany);
#endif
int getNumberOfChips(); int getNumberOfChips();
int getNumberOfDACs(); int getNumberOfDACs();
int getNumberOfChannelsPerChip(); int getNumberOfChannelsPerChip();

View File

@ -216,3 +216,4 @@ int get_current_source(int);
int set_current_source(int); int set_current_source(int);
int get_timing_source(int); int get_timing_source(int);
int set_timing_source(int); int set_timing_source(int);
int get_num_channels(int);

View File

@ -316,6 +316,7 @@ const char* getFunctionName(enum detFuncs func) {
case F_SET_CURRENT_SOURCE: return "F_SET_CURRENT_SOURCE"; case F_SET_CURRENT_SOURCE: return "F_SET_CURRENT_SOURCE";
case F_GET_TIMING_SOURCE: return "F_GET_TIMING_SOURCE"; case F_GET_TIMING_SOURCE: return "F_GET_TIMING_SOURCE";
case F_SET_TIMING_SOURCE: return "F_SET_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"; default: return "Unknown Function";
} }
@ -508,6 +509,7 @@ void function_table() {
flist[F_SET_CURRENT_SOURCE] = &set_current_source; flist[F_SET_CURRENT_SOURCE] = &set_current_source;
flist[F_GET_TIMING_SOURCE] = &get_timing_source; flist[F_GET_TIMING_SOURCE] = &get_timing_source;
flist[F_SET_TIMING_SOURCE] = &set_timing_source; flist[F_SET_TIMING_SOURCE] = &set_timing_source;
flist[F_GET_NUM_CHANNELS] = &get_num_channels;
// check // check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -2833,19 +2835,12 @@ int send_update(int file_des) {
if (n < 0) return printSocketReadError(); if (n < 0) return printSocketReadError();
#endif #endif
// threshold energy
#ifdef EIGERD
i32 = getThresholdEnergy(GET_FLAG);
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
#endif
// #frames // #frames
i64 = getNumFrames(); i64 = getNumFrames();
n = sendData(file_des,&i64,sizeof(i64),INT64); n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError(); if (n < 0) return printSocketReadError();
// #storage cell, storage_cell_delay // #storage cell
#ifdef JUNGFRAUD #ifdef JUNGFRAUD
i64 = getNumAdditionalStorageCells(); i64 = getNumAdditionalStorageCells();
n = sendData(file_des,&i64,sizeof(i64),INT64); n = sendData(file_des,&i64,sizeof(i64),INT64);
@ -2876,42 +2871,18 @@ int send_update(int file_des) {
if (n < 0) return printSocketReadError(); if (n < 0) return printSocketReadError();
#endif #endif
// readout mode // number of channels
#ifdef CHIPTESTBOARDD #if defined(MOENCHD) || defined(CHIPTESTBOARDD)
i32 = getReadoutMode(); {
n = sendData(file_des,&i32,sizeof(i32),INT32); int nx = 0, ny = 0;
if (n < 0) return printSocketReadError(); getNumberOfChannels(&nx, &ny);
#endif i32 = nx;
n = sendData(file_des,&i32,sizeof(i32),INT32);
// roi if (n < 0) return printSocketReadError();
#if defined(GOTTHARDD) i32 = ny;
ROI retval = getROI(); n = sendData(file_des,&i32,sizeof(i32),INT32);
sendData(file_des, &retval.xmin, sizeof(int), INT32); if (n < 0) return printSocketReadError();
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();
#endif #endif
// num udp interfaces // num udp interfaces
@ -6887,4 +6858,22 @@ int get_timing_source(int file_des) {
FILE_LOG(logDEBUG1, ("Get timing source retval:%d\n", retval)); FILE_LOG(logDEBUG1, ("Get timing source retval:%d\n", retval));
#endif #endif
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval)); 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));
} }

View File

@ -287,6 +287,8 @@ void DetectorImpl::addSlsDetector(const std::string &hostname) {
multi_shm()->multiDetectorType = multi_shm()->multiDetectorType =
Parallel(&slsDetector::getDetectorType, {}) Parallel(&slsDetector::getDetectorType, {})
.tsquash("Inconsistent detector types."); .tsquash("Inconsistent detector types.");
// for moench and ctb
detectors[pos]->updateNumberOfChannels();
} }
void DetectorImpl::updateDetectorSize() { void DetectorImpl::updateDetectorSize() {

View File

@ -329,14 +329,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
shm()->controlPort = DEFAULT_PORTNO; shm()->controlPort = DEFAULT_PORTNO;
shm()->stopPort = DEFAULT_PORTNO + 1; shm()->stopPort = DEFAULT_PORTNO + 1;
sls::strcpy_safe(shm()->settingsDir, getenv("HOME")); 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()->currentSettings = UNINITIALIZED;
shm()->currentThresholdEV = -1;
shm()->nASamples = 1;
shm()->nFrames = 1; shm()->nFrames = 1;
shm()->nTriggers = 1; shm()->nTriggers = 1;
shm()->nBursts = 1; shm()->nBursts = 1;
@ -347,7 +340,6 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
sls::strcpy_safe(shm()->rxHostname, "none"); sls::strcpy_safe(shm()->rxHostname, "none");
shm()->rxTCPPort = DEFAULT_PORTNO + 2; shm()->rxTCPPort = DEFAULT_PORTNO + 2;
shm()->useReceiverFlag = false; shm()->useReceiverFlag = false;
shm()->tenGigaEnable = false;
shm()->flippedDataX = false; shm()->flippedDataX = false;
shm()->zmqport = DEFAULT_ZMQ_CL_PORTNO + shm()->zmqport = DEFAULT_ZMQ_CL_PORTNO +
(detId * ((shm()->myDetectorType == EIGER) ? 2 : 1)); (detId * ((shm()->myDetectorType == EIGER) ? 2 : 1));
@ -410,9 +402,6 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
shm()->dynamicRange = parameters.dynamicRange; shm()->dynamicRange = parameters.dynamicRange;
shm()->nGappixels.x = parameters.nGappixelsX; shm()->nGappixels.x = parameters.nGappixelsX;
shm()->nGappixels.y = parameters.nGappixelsY; shm()->nGappixels.y = parameters.nGappixelsY;
// update #nchan, as it depends on #samples, adcmask,
updateNumberOfChannels();
} }
int slsDetector::sendModule(sls_detector_module *myMod, int slsDetector::sendModule(sls_detector_module *myMod,
@ -558,48 +547,14 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType() const {
} }
void slsDetector::updateNumberOfChannels() { void slsDetector::updateNumberOfChannels() {
if (shm()->myDetectorType == CHIPTESTBOARD ||
if (shm()->myDetectorType == CHIPTESTBOARD) { shm()->myDetectorType == MOENCH) {
FILE_LOG(logDEBUG1) << "Updating number of channels";
int nachans = 0, ndchans = 0; std::array<int, 2> retvals{};
// analog channels (normal, analog/digital readout) sendToDetector(F_GET_NUM_CHANNELS, nullptr, retvals);
if (shm()->roMode == slsDetectorDefs::ANALOG_ONLY || FILE_LOG(logDEBUG1) << "Number of channels retval: [" << retvals[0] << ", " << retvals[1] << ']';
shm()->roMode == slsDetectorDefs::ANALOG_AND_DIGITAL) { shm()->nChan.x = retvals[0];
uint32_t mask = shm()->tenGigaEnable ? shm()->adcEnableMaskTenGiga : shm()->adcEnableMaskOneGiga; shm()->nChan.y = retvals[1];
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;
} }
} }
@ -765,12 +720,6 @@ void slsDetector::updateCachedDetectorVariables() {
shm()->currentSettings = static_cast<detectorSettings>(i32); shm()->currentSettings = static_cast<detectorSettings>(i32);
} }
// threshold
if (shm()->myDetectorType == EIGER) {
n += client.Receive(&i32, sizeof(i32));
shm()->currentThresholdEV = i32;
}
// frame number // frame number
n += client.Receive(&i64, sizeof(i64)); n += client.Receive(&i64, sizeof(i64));
shm()->nFrames = i64; shm()->nFrames = i64;
@ -801,51 +750,13 @@ void slsDetector::updateCachedDetectorVariables() {
shm()->burstMode = static_cast<burstMode>(i32); shm()->burstMode = static_cast<burstMode>(i32);
} }
// readout mode // number of channels (depends on #samples, adcmask)
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
if (shm()->myDetectorType == CHIPTESTBOARD || if (shm()->myDetectorType == CHIPTESTBOARD ||
shm()->myDetectorType == MOENCH) { shm()->myDetectorType == MOENCH) {
n += client.Receive(&i32, sizeof(i32));
// analog samples shm()->nChan.x = i32;
uint32_t u32 = 0; n += client.Receive(&i32, sizeof(i32));
n += client.Receive(&u32, sizeof(u32)); shm()->nChan.y = i32;
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();
} }
// num udp interfaces // num udp interfaces
@ -989,9 +900,7 @@ int slsDetector::getThresholdEnergy() {
std::string result = getAdditionalJsonParameter("threshold"); std::string result = getAdditionalJsonParameter("threshold");
// convert to integer // convert to integer
try { try {
// udpate shm return stoi(result);
shm()->currentThresholdEV = stoi(result);
return shm()->currentThresholdEV;
} }
// not found or cannot scan integer // not found or cannot scan integer
catch (...) { catch (...) {
@ -1003,8 +912,7 @@ int slsDetector::getThresholdEnergy() {
int retval = -1; int retval = -1;
sendToDetector(F_GET_THRESHOLD_ENERGY, nullptr, retval); sendToDetector(F_GET_THRESHOLD_ENERGY, nullptr, retval);
FILE_LOG(logDEBUG1) << "Threshold: " << retval; FILE_LOG(logDEBUG1) << "Threshold: " << retval;
shm()->currentThresholdEV = retval; return retval;
return shm()->currentThresholdEV;
} }
int slsDetector::setThresholdEnergy(int e_eV, detectorSettings isettings, 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 // check as there is client processing
if (shm()->myDetectorType == EIGER) { if (shm()->myDetectorType == EIGER) {
setThresholdEnergyAndSettings(e_eV, isettings, tb); setThresholdEnergyAndSettings(e_eV, isettings, tb);
return shm()->currentThresholdEV; return e_eV;
} }
// moench - send threshold energy to processor // moench - send threshold energy to processor
@ -1021,9 +929,7 @@ int slsDetector::setThresholdEnergy(int e_eV, detectorSettings isettings,
std::string result = std::string result =
setAdditionalJsonParameter("threshold", std::to_string(e_eV)); setAdditionalJsonParameter("threshold", std::to_string(e_eV));
if (result == std::to_string(e_eV)) { if (result == std::to_string(e_eV)) {
// update shm return e_eV;
shm()->currentThresholdEV = e_eV;
return shm()->currentThresholdEV;
} }
return -1; return -1;
} }
@ -1344,7 +1250,6 @@ int slsDetector::getNumberOfAnalogSamples() {
void slsDetector::setNumberOfAnalogSamples(int value) { void slsDetector::setNumberOfAnalogSamples(int value) {
FILE_LOG(logDEBUG1) << "Setting number of analog samples to " << value; FILE_LOG(logDEBUG1) << "Setting number of analog samples to " << value;
sendToDetector(F_SET_NUM_ANALOG_SAMPLES, value, nullptr); sendToDetector(F_SET_NUM_ANALOG_SAMPLES, value, nullptr);
shm()->nASamples = value;
// update #nchan, as it depends on #samples, adcmask // update #nchan, as it depends on #samples, adcmask
updateNumberOfChannels(); updateNumberOfChannels();
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
@ -1694,7 +1599,6 @@ void slsDetector::setReadoutMode(const slsDetectorDefs::readoutMode mode) {
auto arg = static_cast<uint32_t>(mode); auto arg = static_cast<uint32_t>(mode);
FILE_LOG(logDEBUG1) << "Setting readout mode to " << arg; FILE_LOG(logDEBUG1) << "Setting readout mode to " << arg;
sendToDetector(F_SET_READOUT_MODE, arg, nullptr); sendToDetector(F_SET_READOUT_MODE, arg, nullptr);
shm()->roMode = mode;
// update #nchan, as it depends on #samples, adcmask, // update #nchan, as it depends on #samples, adcmask,
if (shm()->myDetectorType == CHIPTESTBOARD) { if (shm()->myDetectorType == CHIPTESTBOARD) {
updateNumberOfChannels(); updateNumberOfChannels();
@ -1709,19 +1613,7 @@ slsDetectorDefs::readoutMode slsDetector::getReadoutMode() {
FILE_LOG(logDEBUG1) << "Getting readout mode"; FILE_LOG(logDEBUG1) << "Getting readout mode";
sendToDetector(F_GET_READOUT_MODE, nullptr, retval); sendToDetector(F_GET_READOUT_MODE, nullptr, retval);
FILE_LOG(logDEBUG1) << "Readout mode: " << retval; FILE_LOG(logDEBUG1) << "Readout mode: " << retval;
readoutMode oldmode = shm()->roMode; return static_cast<readoutMode>(retval);
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;
} }
void slsDetector::setInterruptSubframe(const bool enable) { void slsDetector::setInterruptSubframe(const bool enable) {
@ -1843,30 +1735,30 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
setDeactivatedRxrPaddingMode( setDeactivatedRxrPaddingMode(
static_cast<int>(shm()->rxPadDeactivatedModules)); static_cast<int>(shm()->rxPadDeactivatedModules));
enableGapPixels(shm()->gappixels); enableGapPixels(shm()->gappixels);
enableTenGigabitEthernet(static_cast<int>(shm()->tenGigaEnable)); enableTenGigabitEthernet(-1);
setQuad(getQuad()); setQuad(getQuad());
break; break;
case CHIPTESTBOARD: case CHIPTESTBOARD:
setNumberOfAnalogSamples(getNumberOfAnalogSamples()); setNumberOfAnalogSamples(getNumberOfAnalogSamples());
setNumberOfDigitalSamples(getNumberOfDigitalSamples()); setNumberOfDigitalSamples(getNumberOfDigitalSamples());
enableTenGigabitEthernet(static_cast<int>(shm()->tenGigaEnable)); enableTenGigabitEthernet(-1);
setReadoutMode(shm()->roMode); setReadoutMode(getReadoutMode());
setADCEnableMask(shm()->adcEnableMaskOneGiga); setADCEnableMask(getADCEnableMask());
setTenGigaADCEnableMask(shm()->adcEnableMaskTenGiga); setTenGigaADCEnableMask(getTenGigaADCEnableMask());
setReceiverDbitOffset(shm()->rxDbitOffset); setReceiverDbitOffset(shm()->rxDbitOffset);
setReceiverDbitList(shm()->rxDbitList); setReceiverDbitList(shm()->rxDbitList);
break; break;
case MOENCH: case MOENCH:
setNumberOfAnalogSamples(getNumberOfAnalogSamples()); setNumberOfAnalogSamples(getNumberOfAnalogSamples());
enableTenGigabitEthernet(static_cast<int>(shm()->tenGigaEnable)); enableTenGigabitEthernet(-1);
setADCEnableMask(shm()->adcEnableMaskOneGiga); setADCEnableMask(getADCEnableMask());
setTenGigaADCEnableMask(shm()->adcEnableMaskTenGiga); setTenGigaADCEnableMask(getTenGigaADCEnableMask());
break; break;
case GOTTHARD: case GOTTHARD:
sendROItoReceiver(); setROI(getROI());
break; break;
case MYTHEN3: case MYTHEN3:
@ -2612,73 +2504,29 @@ void slsDetector::clearROI() {
} }
void slsDetector::setROI(slsDetectorDefs::ROI arg) { void slsDetector::setROI(slsDetectorDefs::ROI arg) {
int fnum = F_SET_ROI;
int ret = FAIL;
if (arg.xmin < 0 || arg.xmax >= getNumberOfChannels().x) { if (arg.xmin < 0 || arg.xmax >= getNumberOfChannels().x) {
arg.xmin = -1; arg.xmin = -1;
arg.xmax = -1; arg.xmax = -1;
} }
std::array<int, 2> args{arg.xmin, arg.xmax};
FILE_LOG(logDEBUG) << "Sending ROI to detector [" << arg.xmin << ", " FILE_LOG(logDEBUG) << "Sending ROI to detector [" << arg.xmin << ", "
<< arg.xmax << "]"; << arg.xmax << "]";
auto client = DetectorSocket(shm()->hostname, shm()->controlPort); sendToDetector(F_SET_ROI, args, nullptr);
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
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
FILE_LOG(logDEBUG1) << "Sending ROI to receiver"; 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() { slsDetectorDefs::ROI slsDetector::getROI() {
int fnum = F_GET_ROI; std::array<int, 2> retvals{};
int ret = FAIL; sendToDetector(F_GET_ROI, nullptr, retvals);
FILE_LOG(logDEBUG1) << "Getting ROI from detector"; FILE_LOG(logDEBUG1)
auto client = DetectorSocket(shm()->hostname, shm()->controlPort); << "ROI retval [" << retvals[0] << "," << retvals[1] << "]";
client.Send(&fnum, sizeof(fnum)); slsDetectorDefs::ROI retval;
client.Receive(&ret, sizeof(ret)); retval.xmin = retvals[0];
// handle ret retval.xmax = retvals[1];
if (ret == FAIL) { return retval;
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;
} }
void slsDetector::setADCEnableMask(uint32_t mask) { 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 FILE_LOG(logDEBUG1) << "Setting ADC Enable mask to 0x" << std::hex << arg
<< std::dec; << std::dec;
sendToDetector(F_SET_ADC_ENABLE_MASK, &arg, sizeof(arg), nullptr, 0); sendToDetector(F_SET_ADC_ENABLE_MASK, &arg, sizeof(arg), nullptr, 0);
shm()->adcEnableMaskOneGiga = mask;
// update #nchan, as it depends on #samples, adcmask, // update #nchan, as it depends on #samples, adcmask,
updateNumberOfChannels(); updateNumberOfChannels();
// send to processor // send to processor
if (shm()->myDetectorType == MOENCH && !shm()->tenGigaEnable) if (shm()->myDetectorType == MOENCH)
setAdditionalJsonParameter("adcmask", setAdditionalJsonParameter("adcmask_1g", std::to_string(mask));
std::to_string(shm()->adcEnableMaskOneGiga));
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
int fnum = F_RECEIVER_SET_ADC_MASK; int fnum = F_RECEIVER_SET_ADC_MASK;
int retval = -1; int retval = -1;
mask = shm()->adcEnableMaskOneGiga;
FILE_LOG(logDEBUG1) << "Setting ADC Enable mask to 0x" << std::hex FILE_LOG(logDEBUG1) << "Setting ADC Enable mask to 0x" << std::hex
<< mask << std::dec << " in receiver"; << mask << std::dec << " in receiver";
sendToReceiver(fnum, mask, retval); sendToReceiver(fnum, mask, retval);
@ -2708,12 +2553,10 @@ void slsDetector::setADCEnableMask(uint32_t mask) {
uint32_t slsDetector::getADCEnableMask() { uint32_t slsDetector::getADCEnableMask() {
uint32_t retval = -1; uint32_t retval = -1;
FILE_LOG(logDEBUG1) << "Getting ADC Enable mask";
sendToDetector(F_GET_ADC_ENABLE_MASK, nullptr, 0, &retval, sizeof(retval)); sendToDetector(F_GET_ADC_ENABLE_MASK, nullptr, 0, &retval, sizeof(retval));
shm()->adcEnableMaskOneGiga = retval;
FILE_LOG(logDEBUG1) << "ADC Enable Mask: 0x" << std::hex << retval FILE_LOG(logDEBUG1) << "ADC Enable Mask: 0x" << std::hex << retval
<< std::dec; << std::dec;
return shm()->adcEnableMaskOneGiga; return retval;
} }
void slsDetector::setTenGigaADCEnableMask(uint32_t mask) { 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 FILE_LOG(logDEBUG1) << "Setting 10Gb ADC Enable mask to 0x" << std::hex << arg
<< std::dec; << std::dec;
sendToDetector(F_SET_ADC_ENABLE_MASK_10G, &arg, sizeof(arg), nullptr, 0); sendToDetector(F_SET_ADC_ENABLE_MASK_10G, &arg, sizeof(arg), nullptr, 0);
shm()->adcEnableMaskTenGiga = mask;
// update #nchan, as it depends on #samples, adcmask, // update #nchan, as it depends on #samples, adcmask,
updateNumberOfChannels(); updateNumberOfChannels();
// send to processor // send to processor
if (shm()->myDetectorType == MOENCH && shm()->tenGigaEnable) if (shm()->myDetectorType == MOENCH)
setAdditionalJsonParameter("adcmask", setAdditionalJsonParameter("adcmask_10g", std::to_string(mask));
std::to_string(shm()->adcEnableMaskTenGiga));
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
int fnum = F_RECEIVER_SET_ADC_MASK_10G; int fnum = F_RECEIVER_SET_ADC_MASK_10G;
int retval = -1; int retval = -1;
mask = shm()->adcEnableMaskTenGiga;
FILE_LOG(logDEBUG1) << "Setting 10Gb ADC Enable mask to 0x" << std::hex FILE_LOG(logDEBUG1) << "Setting 10Gb ADC Enable mask to 0x" << std::hex
<< mask << std::dec << " in receiver"; << mask << std::dec << " in receiver";
sendToReceiver(fnum, mask, retval); sendToReceiver(fnum, mask, retval);
@ -2743,12 +2583,10 @@ void slsDetector::setTenGigaADCEnableMask(uint32_t mask) {
uint32_t slsDetector::getTenGigaADCEnableMask() { uint32_t slsDetector::getTenGigaADCEnableMask() {
uint32_t retval = -1; uint32_t retval = -1;
FILE_LOG(logDEBUG1) << "Getting 10Gb ADC Enable mask";
sendToDetector(F_GET_ADC_ENABLE_MASK_10G, nullptr, 0, &retval, sizeof(retval)); 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 FILE_LOG(logDEBUG1) << "10Gb ADC Enable Mask: 0x" << std::hex << retval
<< std::dec; << std::dec;
return shm()->adcEnableMaskTenGiga; return retval;
} }
void slsDetector::setADCInvert(uint32_t value) { void slsDetector::setADCInvert(uint32_t value) {
@ -3190,10 +3028,6 @@ void slsDetector::setModule(sls_detector_module &module, int tb) {
if (ret == FORCE_UPDATE) { if (ret == FORCE_UPDATE) {
updateCachedDetectorVariables(); updateCachedDetectorVariables();
} }
// update client structure
if (module.eV != -1) {
shm()->currentThresholdEV = module.eV;
}
} }
sls_detector_module slsDetector::getModule() { sls_detector_module slsDetector::getModule() {
@ -3207,9 +3041,6 @@ sls_detector_module slsDetector::getModule() {
if (ret == FORCE_UPDATE) { if (ret == FORCE_UPDATE) {
updateCachedDetectorVariables(); updateCachedDetectorVariables();
} }
if (myMod.eV != -1) {
shm()->currentThresholdEV = myMod.eV;
}
return myMod; return myMod;
} }
@ -3767,15 +3598,14 @@ bool slsDetector::enableTenGigabitEthernet(int value) {
FILE_LOG(logDEBUG1) << "Enabling / Disabling 10Gbe: " << value; FILE_LOG(logDEBUG1) << "Enabling / Disabling 10Gbe: " << value;
sendToDetector(F_ENABLE_TEN_GIGA, value, retval); sendToDetector(F_ENABLE_TEN_GIGA, value, retval);
FILE_LOG(logDEBUG1) << "10Gbe: " << retval; FILE_LOG(logDEBUG1) << "10Gbe: " << retval;
shm()->tenGigaEnable = static_cast<bool>(retval); value = retval;
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag && value != -1) {
retval = -1; int retval = -1;
value = static_cast<int>(shm()->tenGigaEnable);
FILE_LOG(logDEBUG1) << "Sending 10Gbe enable to receiver: " << value; FILE_LOG(logDEBUG1) << "Sending 10Gbe enable to receiver: " << value;
sendToReceiver(F_ENABLE_RECEIVER_TEN_GIGA, value, retval); sendToReceiver(F_ENABLE_RECEIVER_TEN_GIGA, value, retval);
FILE_LOG(logDEBUG1) << "Receiver 10Gbe enable: " << retval; FILE_LOG(logDEBUG1) << "Receiver 10Gbe enable: " << retval;
} }
return shm()->tenGigaEnable; return static_cast<bool>(retval);
} }
int slsDetector::setReceiverFifoDepth(int n_frames) { int slsDetector::setReceiverFifoDepth(int n_frames) {

View File

@ -13,7 +13,7 @@
class ServerInterface; class ServerInterface;
#define SLS_SHMAPIVERSION 0x190726 #define SLS_SHMAPIVERSION 0x190726
#define SLS_SHMVERSION 0x200302 #define SLS_SHMVERSION 0x200309
/** /**
* @short structure allocated in shared memory to store detector settings for * @short structure allocated in shared memory to store detector settings for
@ -62,27 +62,9 @@ struct sharedSlsDetector {
/** dynamic range of the detector data */ /** dynamic range of the detector data */
int dynamicRange; 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.) */ /** detector settings (standard, fast, etc.) */
slsDetectorDefs::detectorSettings currentSettings; slsDetectorDefs::detectorSettings currentSettings;
/** detector threshold (eV) */
int currentThresholdEV;
/** number of analog samples */
int nASamples;
/** number of frames */ /** number of frames */
int64_t nFrames; int64_t nFrames;
@ -101,7 +83,7 @@ struct sharedSlsDetector {
/** burst mode */ /** burst mode */
slsDetectorDefs::burstMode burstMode; slsDetectorDefs::burstMode burstMode;
/** rate correction in ns */ /** rate correction in ns (needed for default -1) */
int64_t deadTime; int64_t deadTime;
/** ip address/hostname of the receiver for client control via TCP */ /** ip address/hostname of the receiver for client control via TCP */
@ -114,9 +96,6 @@ struct sharedSlsDetector {
* unset if socket connection is not possible */ * unset if socket connection is not possible */
bool useReceiverFlag; bool useReceiverFlag;
/** 10 Gbe enable*/
bool tenGigaEnable;
/** flipped data across x or y axis */ /** flipped data across x or y axis */
bool flippedDataX; bool flippedDataX;
@ -126,7 +105,8 @@ struct sharedSlsDetector {
/** tcp port from receiver to gui/different process (only data) */ /** tcp port from receiver to gui/different process (only data) */
int rxZmqport; int rxZmqport;
/** data streaming (up stream) enable in receiver */ /** data streaming (up stream) enable in receiver
* (needed for restreaming dummy packet) */
bool rxUpstream; bool rxUpstream;
/* Receiver read frequency */ /* Receiver read frequency */
@ -298,7 +278,7 @@ class slsDetector : public virtual slsDetectorDefs {
/** /**
* Update total number of channels (chiptestboard or moench) * Update total number of channels (chiptestboard or moench)
* depending on the number of samples, adcenablemask, readout flags(ctb) * from the detector server
*/ */
void updateNumberOfChannels(); void updateNumberOfChannels();
@ -1190,11 +1170,6 @@ class slsDetector : public virtual slsDetectorDefs {
*/ */
void setROI(slsDetectorDefs::ROI arg); void setROI(slsDetectorDefs::ROI arg);
/**
* Send ROI from shared memory to Receiver (Gotthard)
*/
void sendROItoReceiver();
/** /**
* Get ROI (Gotthard) * Get ROI (Gotthard)
* Update receiver if different from shm * Update receiver if different from shm

View File

@ -196,6 +196,7 @@ enum detFuncs{
F_SET_CURRENT_SOURCE, F_SET_CURRENT_SOURCE,
F_GET_TIMING_SOURCE, F_GET_TIMING_SOURCE,
F_SET_TIMING_SOURCE, F_SET_TIMING_SOURCE,
F_GET_NUM_CHANNELS,
NUM_DET_FUNCTIONS, NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this (detector server should not compile anyway) */ 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_SET_CURRENT_SOURCE: return "F_SET_CURRENT_SOURCE";
case F_GET_TIMING_SOURCE: return "F_GET_TIMING_SOURCE"; case F_GET_TIMING_SOURCE: return "F_GET_TIMING_SOURCE";
case F_SET_TIMING_SOURCE: return "F_SET_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 NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";

View File

@ -3,10 +3,10 @@
#define APILIB 0x200227 #define APILIB 0x200227
#define APIRECEIVER 0x200227 #define APIRECEIVER 0x200227
#define APIGUI 0x200227 #define APIGUI 0x200227
#define APICTB 0x200305
#define APIGOTTHARD 0x200305
#define APIMYTHEN3 0x200305 #define APIMYTHEN3 0x200305
#define APIEIGER 0x200305
#define APIGOTTHARD2 0x200305 #define APIGOTTHARD2 0x200305
#define APIMOENCH 0x200306
#define APIJUNGFRAU 0x200306 #define APIJUNGFRAU 0x200306
#define APIGOTTHARD 0x200309
#define APIEIGER 0x200309
#define APIMOENCH 0x200309
#define APICTB 0x200309