ctb:separated analog and digital samples in server and send analog and digital data packed separately per frame to reciever

This commit is contained in:
2019-04-30 18:55:32 +02:00
parent b0cffcd570
commit 2f3b0e0b06
17 changed files with 489 additions and 300 deletions

View File

@ -284,7 +284,8 @@ void multiSlsDetector::initSharedMemory(bool verify) {
<< ") version mismatch "
"(expected 0x"
<< std::hex << MULTI_SHMVERSION << " but got 0x"
<< multi_shm()->shmversion << std::dec;
<< multi_shm()->shmversion << std::dec
<< ". Clear Shared memory to continue.";
throw SharedMemoryError("Shared memory version mismatch!");
}
}
@ -1080,10 +1081,6 @@ int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t, int detPos) {
auto r = parallelCall(&slsDetector::setTimer, index, t);
int64_t ret = sls::minusOneIfDifferent(r);
if (index == SAMPLES) {
setDynamicRange();
}
// set progress
if (t != -1) {
switch (index) {

View File

@ -281,7 +281,7 @@ void slsDetector::initSharedMemory(detectorType type, int multi_id,
ss << "Single shared memory (" << multi_id << "-" << detId
<< ":) version mismatch (expected 0x" << std::hex
<< SLS_SHMVERSION << " but got 0x" << shm()->shmversion << ")"
<< std::dec;
<< std::dec << ". Clear Shared memory to continue.";
throw SharedMemoryError(ss.str());
}
}
@ -322,7 +322,8 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
shm()->timerValue[MEASUREMENTS_NUMBER] = 1;
shm()->timerValue[FRAMES_FROM_START] = 0;
shm()->timerValue[FRAMES_FROM_START_PG] = 0;
shm()->timerValue[SAMPLES] = 1;
shm()->timerValue[ANALOG_SAMPLES] = 1;
shm()->timerValue[DIGITAL_SAMPLES] = 1;
shm()->timerValue[SUBFRAME_ACQUISITION_TIME] = 0;
shm()->timerValue[STORAGE_CELL_NUMBER] = 0;
shm()->timerValue[SUBFRAME_DEADTIME] = 0;
@ -418,10 +419,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
// update #nchans and databytes, as it depends on #samples, adcmask,
// readoutflags (ctb only)
if (shm()->myDetectorType == CHIPTESTBOARD ||
shm()->myDetectorType == MOENCH) {
updateTotalNumberOfChannels();
}
updateTotalNumberOfChannels();
}
int slsDetector::sendModule(sls_detector_module *myMod,
@ -519,7 +517,8 @@ slsDetectorDefs::detectorType slsDetector::getDetectorTypeFromShm(int multi_id,
std::ostringstream ss;
ss << "Single shared memory (" << multi_id << "-" << detId
<< ":)version mismatch (expected 0x" << std::hex << SLS_SHMVERSION
<< " but got 0x" << shm()->shmversion << ")" << std::dec;
<< " but got 0x" << shm()->shmversion << ")" << std::dec
<< ". Clear Shared memory to continue.";
shm.UnmapSharedMemory();
throw SharedMemoryError(ss.str());
}
@ -584,34 +583,38 @@ void slsDetector::updateTotalNumberOfChannels() {
if (shm()->myDetectorType == CHIPTESTBOARD ||
shm()->myDetectorType == MOENCH) {
int nchans = 0;
// calculate analog channels
uint32_t mask = shm()->adcEnableMask;
if (mask == BIT32_MASK) {
nchans = 32;
} else {
nchans = 0;
for (int ich = 0; ich < 32; ++ich) {
if (mask & (1 << ich))
++nchans;
int nachans = 0, ndchans = 0;
int adatabytes = 0, ddatabytes = 0;
// analog channels (normal, analog/digital readout)
if (shm()->roFlags == slsDetectorDefs::NORMAL_READOUT ||
shm()->roFlags & slsDetectorDefs::ANALOG_AND_DIGITAL) {
uint32_t mask = shm()->adcEnableMask;
if (mask == BIT32_MASK) {
nachans = 32;
} else {
for (int ich = 0; ich < 32; ++ich) {
if (mask & (1 << ich))
++nachans;
}
}
adatabytes = nachans * (shm()->dynamicRange / 8) *
shm()->timerValue[ANALOG_SAMPLES];
FILE_LOG(logDEBUG1)
<< "#Analog Channels:" << nachans << " Databytes: " << adatabytes;
}
// calculate digital channels
// digital channels (ctb only, digital, analog/digital readout)
if (shm()->myDetectorType == CHIPTESTBOARD &&
(((shm()->roFlags & DIGITAL_ONLY) != 0) ||
((shm()->roFlags & ANALOG_AND_DIGITAL) != 0))) {
nchans += 4;
((shm()->roFlags & DIGITAL_ONLY) || (shm()->roFlags & ANALOG_AND_DIGITAL))) {
ndchans = 64;
ddatabytes = (sizeof(uint64_t) * shm()->timerValue[DIGITAL_SAMPLES]);
FILE_LOG(logDEBUG1) << "#Digital Channels:" << ndchans
<< " Databytes: " << ddatabytes;
}
shm()->nChan[X] = nchans;
// recalculate derived parameters chans and databytes
shm()->nChans = nchans;
shm()->dataBytes = shm()->nChans * shm()->nChips *
(shm()->dynamicRange / 8) *
shm()->timerValue[SAMPLES];
FILE_LOG(logDEBUG1) << "Number of Channels:" << shm()->nChans
<< " Databytes: " << shm()->dataBytes;
shm()->nChans = nachans + ndchans;
shm()->dataBytes = adatabytes + ddatabytes;
FILE_LOG(logDEBUG1) << "# Total #Channels:" << shm()->nChans
<< " Databytes: " << shm()->dataBytes;
}
}
@ -882,10 +885,16 @@ int slsDetector::updateDetectorNoWait(sls::ClientSocket &client) {
if (shm()->myDetectorType == CHIPTESTBOARD ||
shm()->myDetectorType == MOENCH) {
// samples
// analog samples
n += client.receiveData(&i64, sizeof(i64));
if (i64 >= 0) {
shm()->timerValue[SAMPLES] = i64;
shm()->timerValue[ANALOG_SAMPLES] = i64;
}
// digital samples
n += client.receiveData(&i64, sizeof(i64));
if (i64 >= 0) {
shm()->timerValue[DIGITAL_SAMPLES] = i64;
}
// adcmask
@ -1518,8 +1527,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
shm()->timerValue[index] = retval;
// update #nchans and databytes, as it depends on #samples, adcmask,
// readoutflags
if (index == SAMPLES && (shm()->myDetectorType == CHIPTESTBOARD ||
shm()->myDetectorType == MOENCH)) {
if (index == ANALOG_SAMPLES || index == DIGITAL_SAMPLES) {
updateTotalNumberOfChannels();
}
}
@ -1548,7 +1556,8 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
ACQUISITION_TIME,
SUBFRAME_ACQUISITION_TIME,
SUBFRAME_DEADTIME,
SAMPLES,
ANALOG_SAMPLES,
DIGITAL_SAMPLES,
STORAGE_CELL_NUMBER};
if (std::any_of(std::begin(rt), std::end(rt),
@ -1884,7 +1893,8 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
<< "\nsub exp time:"
<< (shm()->timerValue[SUBFRAME_ACQUISITION_TIME])
<< "\nsub dead time:" << (shm()->timerValue[SUBFRAME_DEADTIME])
<< "\nsamples:" << (shm()->timerValue[SAMPLES])
<< "\nasamples:" << (shm()->timerValue[ANALOG_SAMPLES])
<< "\ndsamples:" << (shm()->timerValue[DIGITAL_SAMPLES])
<< "\ndynamic range:" << shm()->dynamicRange
<< "\nflippeddatax:" << (shm()->flippedData[X])
<< "\nactivated: " << shm()->activated
@ -1939,14 +1949,16 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
break;
case CHIPTESTBOARD:
setTimer(SAMPLES, shm()->timerValue[SAMPLES]);
setTimer(ANALOG_SAMPLES, shm()->timerValue[ANALOG_SAMPLES]);
setTimer(DIGITAL_SAMPLES, shm()->timerValue[DIGITAL_SAMPLES]);
enableTenGigabitEthernet(shm()->tenGigaEnable);
setReadOutFlags(GET_READOUT_FLAGS);
setADCEnableMask(shm()->adcEnableMask);
break;
case MOENCH:
setTimer(SAMPLES, shm()->timerValue[SAMPLES]);
setTimer(ANALOG_SAMPLES, shm()->timerValue[ANALOG_SAMPLES]);
setTimer(DIGITAL_SAMPLES, shm()->timerValue[DIGITAL_SAMPLES]);
enableTenGigabitEthernet(shm()->tenGigaEnable);
setADCEnableMask(shm()->adcEnableMask);
break;

View File

@ -609,12 +609,26 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page timing
- <b>samples [i]</b> sets/gets number of samples expected from the jctb. Used in CHIP TEST BOARD only. \c Returns \c (long long int)
- <b>samples [i]</b> sets/gets number of samples (both analog and digital) expected from the ctb. Used in CHIP TEST BOARD and MOENCH only. \c Returns \c (long long int)
*/
descrToFuncMap[i].m_pFuncName = "samples";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimer;
++i;
/*! \page timing
- <b>asamples [i]</b> sets/gets number of analog samples expected from the ctb. Used in CHIP TEST BOARD and MOENCH only. \c Returns \c (long long int)
*/
descrToFuncMap[i].m_pFuncName = "asamples";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimer;
++i;
/*! \page timing
- <b>bsamples [i]</b> sets/gets number of digital samples expected from the ctb. Used in CHIP TEST BOARD and MOENCH only. \c Returns \c (long long int)
*/
descrToFuncMap[i].m_pFuncName = "bsamples";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimer;
++i;
/*! \page timing
- <b>storagecells [i]</b> sets/gets number of additional storage cells per acquisition. For very advanced users only! For JUNGFRAU only. Range: 0-15. The #images = #frames * #cycles * (#storagecells +1). \c Returns \c (long long int)
*/
@ -1934,6 +1948,11 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
++i;
/** not documenting this, but keeping this for backwards compatibility */
descrToFuncMap[i].m_pFuncName = "adcdisable";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
++i;
/*! \page prototype
- <b>pattern fn</b> loads binary pattern file fn
*/
@ -4426,8 +4445,13 @@ std::string slsDetectorCommand::cmdTimer(int narg, char *args[], int action, int
index = CYCLES_NUMBER;
else if (cmd == "measurements")
index = MEASUREMENTS_NUMBER;
else if (cmd == "samples")
index = SAMPLES;
// also does digital sample
else if (cmd == "samples")
index = ANALOG_SAMPLES;
else if (cmd == "asamples")
index = ANALOG_SAMPLES;
else if (cmd == "bsamples")
index = DIGITAL_SAMPLES;
else if (cmd == "storagecells")
index = STORAGE_CELL_NUMBER;
else if (cmd == "storagecell_delay")
@ -4466,6 +4490,14 @@ std::string slsDetectorCommand::cmdTimer(int narg, char *args[], int action, int
ret = myDet->setTimer(index, t, detPos);
// samples command does both asamples and dsamples
if (cmd == "samples" ) {
int64_t dret = myDet->setTimer(DIGITAL_SAMPLES, t, detPos);
if (dret != ret) {
throw sls::RuntimeError("Analog and digital number of samples are different. Check with asamples and dsamples command");
}
}
if ((ret != -1) && (index == ACQUISITION_TIME || index == SUBFRAME_ACQUISITION_TIME ||
index == FRAME_PERIOD || index == DELAY_AFTER_TRIGGER ||
index == SUBFRAME_DEADTIME || index == STORAGE_CELL_DELAY)) {
@ -4487,7 +4519,9 @@ std::string slsDetectorCommand::helpTimer(int action) {
os << "delay t \t sets the delay after trigger in s" << std::endl;
os << "frames t \t sets the number of frames per cycle (e.g. after each trigger)" << std::endl;
os << "cycles t \t sets the number of cycles (e.g. number of triggers)" << std::endl;
os << "samples t \t sets the number of samples expected from the jctb" << std::endl;
os << "samples t \t sets the number of samples (both analog and digital) expected from the ctb" << std::endl;
os << "asamples t \t sets the number of analog samples expected from the ctb" << std::endl;
os << "dsamples t \t sets the number of digital samples expected from the ctb" << std::endl;
os << "storagecells t \t sets number of storage cells per acquisition. For very advanced users only! For JUNGFRAU only. Range: 0-15. The #images = #frames * #cycles * (#storagecells+1)." << std::endl;
os << "storagecell_start t \t sets the storage cell that stores the first acquisition of the series. Default is 15(0xf). For very advanced users only! For JUNGFRAU only. Range: 0-15." << std::endl;
os << "storagecell_delay t \t sets additional time to t between 2 storage cells. For very advanced users only! For JUNGFRAU only. Range: 0-1638375 ns (resolution of 25ns).. " << std::endl;
@ -4502,7 +4536,9 @@ std::string slsDetectorCommand::helpTimer(int action) {
os << "delay \t gets the delay after trigger in s" << std::endl;
os << "frames \t gets the number of frames per cycle (e.g. after each trigger)" << std::endl;
os << "cycles \t gets the number of cycles (e.g. number of triggers)" << std::endl;
os << "samples \t gets the number of samples expected from the jctb" << std::endl;
os << "samples \t gets the number of samples (both analog and digital) expected from the ctb" << std::endl;
os << "asamples \t gets the number of analog samples expected from the ctb" << std::endl;
os << "dsamples \t gets the number of digital samples expected from the ctb" << std::endl;
os << "storagecells \t gets number of storage cells per acquisition.For JUNGFRAU only." << std::endl;
os << "storagecell_start \t gets the storage cell that stores the first acquisition of the series." << std::endl;
os << "storagecell_delay \tgets additional time between 2 storage cells. " << std::endl;
@ -5591,6 +5627,26 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
}
os << std::hex << myDet->getADCEnableMask(detPos) << std::dec;
}
// kept only for backwards compatibility, use adcenable
else if (cmd == "adcdisable") {
if (action == PUT_ACTION) {
uint32_t adcEnableMask = 0;
if (sscanf(args[1], "%x", &adcEnableMask))
;
else
return std::string("Could not scan adcdisable reg ") + std::string(args[1]);
// get enable mask from enable mask
adcEnableMask ^= BIT32_MASK;
myDet->setADCEnableMask(adcEnableMask, detPos);
}
uint32_t retval = myDet->getADCEnableMask(detPos);
// get disable mask
retval ^= BIT32_MASK;
os << std::hex << retval << std::dec;
}
else