mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer
This commit is contained in:
@ -15,7 +15,7 @@ class multiSlsDetector;
|
||||
class ServerInterface;
|
||||
class MySocketTCP;
|
||||
|
||||
#define SLS_SHMVERSION 0x181005
|
||||
#define SLS_SHMVERSION 0x190412
|
||||
#define NCHIPSMAX 10
|
||||
#define NCHANSMAX 65536
|
||||
#define NDACSMAX 16
|
||||
@ -120,6 +120,9 @@ struct sharedSlsDetector {
|
||||
/** timer values */
|
||||
int64_t timerValue[slsDetectorDefs::timerIndex::MAX_TIMERS];
|
||||
|
||||
/** rate correction in ns */
|
||||
int64_t deadTime;
|
||||
|
||||
/** ip address/hostname of the receiver for client control via TCP */
|
||||
char receiver_hostname[MAX_STR_LENGTH];
|
||||
|
||||
@ -1339,7 +1342,7 @@ class slsDetector : public virtual slsDetectorDefs{
|
||||
sls_detector_module *getModule();
|
||||
|
||||
/**
|
||||
* Set Rate correction (Mythen, Eiger)
|
||||
* Set Rate correction (Eiger)
|
||||
* @param t dead time in ns - if 0 disable correction,
|
||||
* if >0 set dead time to t, if < 0 set deadtime to default dead time
|
||||
* for current settings
|
||||
@ -1348,11 +1351,18 @@ class slsDetector : public virtual slsDetectorDefs{
|
||||
int setRateCorrection(int64_t t = 0);
|
||||
|
||||
/**
|
||||
* Get rate correction Eiger)
|
||||
* Get rate correction (Eiger)
|
||||
* @returns 0 if rate correction disabled, > 0 otherwise
|
||||
*/
|
||||
int64_t getRateCorrection();
|
||||
|
||||
/**
|
||||
* Update rate correction according to dynamic range (Eiger)
|
||||
* If rate correction enabled and dr is 8 or 16, it will throw
|
||||
* Otherwise update ratecorrection if enabled
|
||||
*/
|
||||
void updateRateCorrection();
|
||||
|
||||
/**
|
||||
* Prints receiver configuration
|
||||
* @param level print level
|
||||
|
@ -1264,36 +1264,46 @@ int multiSlsDetector::setDynamicRange(int dr, int detPos) {
|
||||
int prevGValue = multi_shm()->dataBytesInclGapPixels;
|
||||
multi_shm()->dataBytes = 0;
|
||||
multi_shm()->dataBytesInclGapPixels = 0;
|
||||
multi_shm()->numberOfChannels = 0;
|
||||
for (auto &d : detectors) {
|
||||
multi_shm()->dataBytes += d->getDataBytes();
|
||||
multi_shm()->dataBytesInclGapPixels += d->getDataBytesInclGapPixels();
|
||||
multi_shm()->numberOfChannels += d->getTotalNumberOfChannels();
|
||||
}
|
||||
|
||||
// for usability
|
||||
if (getDetectorTypeAsEnum() == EIGER) {
|
||||
switch (dr) {
|
||||
case 32:
|
||||
FILE_LOG(logINFO) << "Setting Clock to Quarter Speed to cope with "
|
||||
"Dynamic Range of 32";
|
||||
setSpeed(CLOCK_DIVIDER, 2);
|
||||
break;
|
||||
case 16:
|
||||
FILE_LOG(logINFO) << "Setting Clock to Half Speed for Dynamic Range of 16";
|
||||
setSpeed(CLOCK_DIVIDER, 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
// if there was a change FIXME:add dr to sls shm and check that instead
|
||||
if ((prevValue != multi_shm()->dataBytes) ||
|
||||
(prevGValue != multi_shm()->dataBytesInclGapPixels)) {
|
||||
|
||||
updateOffsets();
|
||||
|
||||
// update speed, check ratecorrection
|
||||
if (getDetectorTypeAsEnum() == EIGER) {
|
||||
|
||||
// rate correction before speed for consistency
|
||||
// (else exception at speed makes ratecorr inconsistent)
|
||||
parallelCall(&slsDetector::updateRateCorrection);
|
||||
|
||||
// speed(usability)
|
||||
switch (dr) {
|
||||
case 32:
|
||||
FILE_LOG(logINFO)
|
||||
<< "Setting Clock to Quarter Speed to cope with "
|
||||
"Dynamic Range of 32";
|
||||
setSpeed(CLOCK_DIVIDER, 2);
|
||||
break;
|
||||
case 16:
|
||||
FILE_LOG(logINFO)
|
||||
<< "Setting Clock to Half Speed for Dynamic Range of 16";
|
||||
setSpeed(CLOCK_DIVIDER, 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update offsets if there was a change FIXME:add dr to sls shm and check
|
||||
// that instead
|
||||
if ((prevValue != multi_shm()->dataBytes) ||
|
||||
(prevGValue != multi_shm()->dataBytesInclGapPixels)) {
|
||||
updateOffsets();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -322,6 +322,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||
detector_shm()->timerValue[SUBFRAME_ACQUISITION_TIME] = 0;
|
||||
detector_shm()->timerValue[STORAGE_CELL_NUMBER] = 0;
|
||||
detector_shm()->timerValue[SUBFRAME_DEADTIME] = 0;
|
||||
detector_shm()->deadTime = 0;
|
||||
sls::strcpy_safe(detector_shm()->receiver_hostname, "none");
|
||||
detector_shm()->receiverTCPPort = DEFAULT_PORTNO + 2;
|
||||
detector_shm()->receiverUDPPort = DEFAULT_UDP_PORTNO;
|
||||
@ -1951,7 +1952,7 @@ int slsDetector::setDynamicRange(int n) {
|
||||
client.close();
|
||||
ret = updateDetector();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// only for eiger
|
||||
// setting dr consequences on databytes shm
|
||||
@ -3810,6 +3811,7 @@ int slsDetector::setRateCorrection(int64_t t) {
|
||||
auto client = DetectorSocket(detector_shm()->hostname,
|
||||
detector_shm()->controlPort);
|
||||
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), nullptr, 0);
|
||||
detector_shm()->deadTime = t;
|
||||
}
|
||||
if (ret == FORCE_UPDATE) {
|
||||
ret = updateDetector();
|
||||
@ -3828,6 +3830,7 @@ int64_t slsDetector::getRateCorrection() {
|
||||
detector_shm()->controlPort);
|
||||
ret = client.sendCommandThenRead(fnum, nullptr, 0, &retval,
|
||||
sizeof(retval));
|
||||
detector_shm()->deadTime = retval;
|
||||
FILE_LOG(logDEBUG1) << "Rate correction: " << retval;
|
||||
}
|
||||
if (ret == FORCE_UPDATE) {
|
||||
@ -3836,6 +3839,24 @@ int64_t slsDetector::getRateCorrection() {
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::updateRateCorrection() {
|
||||
// rate correction is enabled
|
||||
if (detector_shm()->deadTime != 0) {
|
||||
switch (detector_shm()->dynamicRange) {
|
||||
// rate correction is allowed
|
||||
case 16:
|
||||
case 32:
|
||||
setRateCorrection(detector_shm()->deadTime);
|
||||
break;
|
||||
// not allowed
|
||||
default:
|
||||
setRateCorrection(0);
|
||||
throw sls::NonCriticalError(
|
||||
"Rate correction Deactivated, must be in 32 or 16 bit mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void slsDetector::printReceiverConfiguration(TLogLevel level) {
|
||||
FILE_LOG(level) << "#Detector " << detId << ":\n Receiver Hostname:\t"
|
||||
<< getReceiverHostname()
|
||||
@ -4824,7 +4845,7 @@ int slsDetector::setLEDEnable(int enable) {
|
||||
int arg = enable;
|
||||
int retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Sending LED Enable: " << arg;
|
||||
if (detector_shm()->receiverOnlineFlag == ONLINE_FLAG) {
|
||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||
auto client = DetectorSocket(detector_shm()->hostname,
|
||||
detector_shm()->controlPort);
|
||||
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval,
|
||||
@ -4845,7 +4866,7 @@ int slsDetector::setDigitalIODelay(uint64_t pinMask, int delay) {
|
||||
<< args[0] << ", delay: " << std::dec << args[1]
|
||||
<< " ps";
|
||||
|
||||
if (detector_shm()->receiverOnlineFlag == ONLINE_FLAG) {
|
||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||
auto client = DetectorSocket(detector_shm()->hostname,
|
||||
detector_shm()->controlPort);
|
||||
ret = client.sendCommandThenRead(fnum, args, sizeof(args), nullptr, 0);
|
||||
|
Reference in New Issue
Block a user