set starting frame number of next acquisition for both jungfrau and e… (#27)

* set starting frame number of next acquisition for both jungfrau and eiger. firmware has not implemented a get, so workaround. tests included. frame number 0 not allowed due to Eiger. Eiger max frame is 48 bit, while jungfrau is 64 bit

* made argument of setstartingframenumber const
This commit is contained in:
Dhanya Thattil
2019-06-03 11:07:53 +02:00
committed by GitHub
parent 894cc1c9e0
commit 29141ac1a6
26 changed files with 398 additions and 40 deletions

View File

@ -1057,6 +1057,34 @@ int multiSlsDetector::configureMAC(int detPos) {
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
}
void multiSlsDetector::setStartingFrameNumber(const uint64_t value, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setStartingFrameNumber(value);
}
// multi
parallelCall(&slsDetector::setStartingFrameNumber, value);
}
uint64_t multiSlsDetector::getStartingFrameNumber(int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->getStartingFrameNumber();
}
// multi
auto r = parallelCall(&slsDetector::getStartingFrameNumber);
if (sls::allEqual(r)) {
return r.front();
}
// can't have different values for next acquisition
std::ostringstream ss;
ss << "Error: Different Values for starting frame number";
throw RuntimeError(ss.str());
}
int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t, int detPos) {
// single
if (detPos >= 0) {
@ -3121,7 +3149,7 @@ int multiSlsDetector::getFramesCaughtByReceiver(int detPos) {
return ((sls::sum(r)) / (int)detectors.size());
}
int multiSlsDetector::getReceiverCurrentFrameIndex(int detPos) {
uint64_t multiSlsDetector::getReceiverCurrentFrameIndex(int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->getReceiverCurrentFrameIndex();
@ -3131,7 +3159,7 @@ int multiSlsDetector::getReceiverCurrentFrameIndex(int detPos) {
auto r = parallelCall(&slsDetector::getReceiverCurrentFrameIndex);
// prevent divide by all or do not take avg when -1 for "did not connect"
if ((detectors.empty()) || (sls::anyEqualTo(r, -1))) {
if ((detectors.empty()) || (sls::anyEqualTo(r, static_cast<uint64_t>(-1)))) {
return -1;
}

View File

@ -1497,6 +1497,23 @@ int slsDetector::configureMAC() {
return ret;
}
void slsDetector::setStartingFrameNumber(const uint64_t value) {
FILE_LOG(logDEBUG1) << "Setting starting frame number to " << value;
if (shm()->onlineFlag == ONLINE_FLAG) {
sendToDetector(F_SET_STARTING_FRAME_NUMBER, value, nullptr);
}
}
uint64_t slsDetector::getStartingFrameNumber() {
uint64_t retval = -1;
FILE_LOG(logDEBUG1) << "Getting starting frame number";
if (shm()->onlineFlag == ONLINE_FLAG) {
sendToDetector(F_GET_STARTING_FRAME_NUMBER, nullptr, retval);
FILE_LOG(logDEBUG1) << "Starting frame number :" << retval;
}
return retval;
}
int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
int ret = FAIL;
int64_t args[]{static_cast<int64_t>(index), t};
@ -1554,6 +1571,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
DIGITAL_SAMPLES,
STORAGE_CELL_NUMBER};
// if in list (lambda)
if (std::any_of(std::begin(rt), std::end(rt),
[index](timerIndex t) { return t == index; })) {
args[1] = shm()->timerValue[index];
@ -1943,7 +1961,7 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
enableTenGigabitEthernet(shm()->tenGigaEnable);
setReadOutFlags(GET_READOUT_FLAGS);
break;
case CHIPTESTBOARD:
setTimer(ANALOG_SAMPLES, shm()->timerValue[ANALOG_SAMPLES]);
setTimer(DIGITAL_SAMPLES, shm()->timerValue[DIGITAL_SAMPLES]);
@ -3592,8 +3610,8 @@ int slsDetector::getFramesCaughtByReceiver() {
return retval;
}
int slsDetector::getReceiverCurrentFrameIndex() {
int retval = -1;
uint64_t slsDetector::getReceiverCurrentFrameIndex() {
uint64_t retval = -1;
FILE_LOG(logDEBUG1) << "Getting Current Frame Index of Receiver";
if (shm()->rxOnlineFlag == ONLINE_FLAG) {
sendToReceiver(F_GET_RECEIVER_FRAME_INDEX, nullptr, retval);

View File

@ -596,6 +596,13 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimer;
++i;
/*! \page timing
- <b>startingfnum [i]</b> sets/gets starting frame number for the next acquisition. Only for Jungfrau and Eiger. \c Returns \c (long long int)
*/
descrToFuncMap[i].m_pFuncName = "startingfnum";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimer;
++i;
/*! \page timing
- <b>cycles [i]</b> sets/gets number of triggers. Timing mode should be set appropriately. \c Returns \c (long long int)
*/
@ -4477,6 +4484,16 @@ std::string slsDetectorCommand::cmdTimer(int narg, const char * const args[], in
}
sprintf(answer, "%d", myDet->setStoragecellStart(-1, detPos));
return std::string(answer);
} else if (cmd == "startingfnum") {
myDet->setOnline(ONLINE_FLAG, detPos);
if (action == PUT_ACTION) {
uint64_t ival = -1;
if (!sscanf(args[1], "%lu", &ival))
return std::string("cannot scan starting frame number value ") + std::string(args[1]);
myDet->setStartingFrameNumber(ival, detPos);
return std::string(args[1]);
}
return std::to_string(myDet->getStartingFrameNumber(detPos));
} else
return std::string("could not decode timer ") + cmd;
@ -4528,6 +4545,7 @@ std::string slsDetectorCommand::helpTimer(int action) {
os << "period t \t sets the frame period in s" << std::endl;
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 << "startingfnum t \t sets starting frame number for the next acquisition. Only for Jungfrau and Eiger." << 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 (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;
@ -4545,6 +4563,7 @@ std::string slsDetectorCommand::helpTimer(int action) {
os << "period \t gets the frame period in s" << std::endl;
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 << "startingfnum \t gets starting frame number for the next acquisition. Only for Jungfrau and Eiger." << 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 (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;
@ -5078,7 +5097,7 @@ std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[],
if (action == PUT_ACTION)
return std::string("cannot put");
else {
sprintf(answer, "%d", myDet->getReceiverCurrentFrameIndex(detPos));
sprintf(answer, "%lu", myDet->getReceiverCurrentFrameIndex(detPos));
return std::string(answer);
}
} else if (cmd == "r_readfreq") {