ctb moench: feature to set digital io pin delay, changed print from unsuccessful to failed, maxpatternlength in server is inclusive

This commit is contained in:
2019-03-01 10:45:01 +01:00
parent bb81613900
commit 35b1ad39f7
12 changed files with 173 additions and 32 deletions

View File

@ -3606,6 +3606,17 @@ int multiSlsDetector::setLEDEnable(int enable, int detPos) {
return sls::minusOneIfDifferent(r);
}
int multiSlsDetector::setDigitalIODelay(uint64_t pinMask, int delay, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setDigitalIODelay(pinMask, delay);
}
// multi
auto r = parallelCall(&slsDetector::setDigitalIODelay, pinMask, delay);
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
}
int multiSlsDetector::retrieveDetectorSetup(const std::string &fname1,
int level) {

View File

@ -1743,6 +1743,15 @@ class multiSlsDetector : public virtual slsDetectorDefs,
*/
int setLEDEnable(int enable = -1, int detPos = -1);
/**
* Set Digital IO Delay (Moench, CTB only)
* @param digital IO mask to select the pins
* @param delay delay in ps(1 bit=25ps, max of 775 ps)
* @param detPos -1 for all detectors in list or specific detector position
* @returns OK or FAIL
*/
int setDigitalIODelay(uint64_t pinMask, int delay, int detPos = -1);
/**
* Loads the detector setup from file
* @param fname file to read from

View File

@ -5108,6 +5108,30 @@ int slsDetector::setLEDEnable(int enable) {
return retval;
}
int slsDetector::setDigitalIODelay(uint64_t pinMask, int delay) {
int fnum = F_DIGITAL_IO_DELAY;
int ret = FAIL;
uint64_t args[2] = {pinMask, (uint64_t)delay};
FILE_LOG(logDEBUG1) << "Sending Digital IO Delay, pin mask: " << std::hex << args[0]
<< ", delay: " << std::dec << args[1] << " ps";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), nullptr, 0);
// handle ret
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
} else {
FILE_LOG(logDEBUG1) << "Digital IO Delay successful";
}
}
if (ret == FORCE_UPDATE) {
ret = updateDetector();
}
return ret;
}
slsDetectorDefs::sls_detector_module *slsDetector::interpolateTrim(
sls_detector_module *a, sls_detector_module *b,
const int energy, const int e1, const int e2, int tb) {

View File

@ -1603,6 +1603,14 @@ public:
*/
int setLEDEnable(int enable = -1);
/**
* Set Digital IO Delay (Moench, CTB only)
* @param digital IO mask to select the pins
* @param delay delay in ps(1 bit=25ps, max of 775 ps)
* @returns OK or FAIL
*/
int setDigitalIODelay(uint64_t pinMask, int delay);
private:
/**

View File

@ -191,7 +191,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
*/
/*! \page acquisition
- \b acquire blocking acquisition (like calling sls_detector_acquire). Starts receiver and detector, writes and processes the data, stops detector. Only get!
\c Returns (string)\c "acquire unsuccessful" if fails, else \c "Acquired (int)", where int is number of frames caught.
\c Returns (string)\c "acquire failed" if fails, else \c "Acquired (int)", where int is number of frames caught.
*/
descrToFuncMap[i].m_pFuncName = "acquire"; //
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAcquire;
@ -392,14 +392,14 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
/* fpga */
/*! \page config
- <b>programfpga [file]</b> programs the FPGA with file f (with .pof extension). Used for JUNGFRAU only. Only put! \c Returns \c ("successful", "unsuccessful")
- <b>programfpga [file]</b> programs the FPGA with file f (with .pof extension). Used for JUNGFRAU only. Only put! \c Returns \c ("successful", "failed")
*/
descrToFuncMap[i].m_pFuncName = "programfpga";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAdvanced;
++i;
/*! \page config
- <b>resetfpga [f]</b> resets FPGA, where f can be any value. Used for JUNGFRAU only. Only put! \c Returns \c ("successful", "unsuccessful")
- <b>resetfpga [f]</b> resets FPGA, where f can be any value. Used for JUNGFRAU only. Only put! \c Returns \c ("successful", "failed")
*/
descrToFuncMap[i].m_pFuncName = "resetfpga";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAdvanced;
@ -425,6 +425,13 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAdvanced;
++i;
/*! \page config
- <b>diodelay [i] [v]</b> sets the delay for the digital IO pins selected by mask i and delay set by v. mask is upto 64 bits in hex, delay is a max is 775ps, and set in steps of 25 ps. Used for MOENCH/CTB only. Cannot get. \c Returns \c ("successful", failed")
*/
descrToFuncMap[i].m_pFuncName = "diodelay";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAdvanced;
++i;
/*! \page config
- <b>auto_comp_disable i </b> Currently not implemented. this mode disables the on-chip gain switching comparator automatically after 93.75% of exposure time (only for longer than 100us). 1 enables mode, 0 disables mode. By default, mode is disabled (comparator is enabled throughout). (JUNGFRAU only). \c Returns \c (int)
*/
@ -433,21 +440,21 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page config
- <b>pulse [n] [x] [y]</b> pulses pixel at coordinates (x,y) n number of times. Used in EIGER only. Only put! \c Returns \c ("successful", "unsuccessful")
- <b>pulse [n] [x] [y]</b> pulses pixel at coordinates (x,y) n number of times. Used in EIGER only. Only put! \c Returns \c ("successful", "failed")
*/
descrToFuncMap[i].m_pFuncName = "pulse"; //
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPulse;
++i;
/*! \page config
- <b>pulsenmove [n] [x] [y]</b> pulses pixel n number of times and moves relatively by x value (x axis) and y value(y axis). Used in EIGER only. Only put! \c Returns \c ("successful", "unsuccessful")
- <b>pulsenmove [n] [x] [y]</b> pulses pixel n number of times and moves relatively by x value (x axis) and y value(y axis). Used in EIGER only. Only put! \c Returns \c ("successful", "failed")
*/
descrToFuncMap[i].m_pFuncName = "pulsenmove"; //
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPulse;
++i;
/*! \page config
- <b>pulsechip [n]</b>pulses chip n number of times, while n=-1 will reset it to normal mode. Used in EIGER only. Only put! \c Returns \c ("successful", "unsuccessful")
- <b>pulsechip [n]</b>pulses chip n number of times, while n=-1 will reset it to normal mode. Used in EIGER only. Only put! \c Returns \c ("successful", "failed")
*/
descrToFuncMap[i].m_pFuncName = "pulsechip"; //
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPulse;
@ -2054,11 +2061,11 @@ std::string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action, i
}
if (!myDet->getNumberOfDetectors()) {
cprintf(RED, "Error: This shared memory has no detectors added. Aborting.\n");
return std::string("acquire unsuccessful");
return std::string("acquire failed");
}
if (detPos >= 0) {
cprintf(RED, "Error: Individual detectors not allowed for readout. Aborting.\n");
return std::string("acquire unsuccessful");
return std::string("acquire failed");
}
myDet->setOnline(ONLINE_FLAG, detPos);
@ -2067,7 +2074,7 @@ std::string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action, i
if (myDet->acquire() == FAIL)
return std::string("acquire unsuccessful");
return std::string("acquire failed");
if (r_online) {
char answer[100];
sprintf(answer, "\nAcquired %d", myDet->getFramesCaughtByReceiver(detPos));
@ -3380,7 +3387,7 @@ std::string slsDetectorCommand::cmdSettings(int narg, char *args[], int action,
if (ret == OK)
return sval;
else
return std::string("not successful");
return std::string("failed");
}
return myDet->getSettingsFile(detPos);
} else if (cmd == "trimval") {
@ -4592,7 +4599,7 @@ std::string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action,
myDet->setOnline(ONLINE_FLAG, detPos);
if (myDet->programFPGA(sval, detPos) == OK)
return std::string("successful");
return std::string("unsuccessful");
return std::string("failed");
}
else if (cmd == "resetfpga") {
@ -4604,7 +4611,7 @@ std::string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action,
myDet->setOnline(ONLINE_FLAG, detPos);
if (myDet->resetFPGA(detPos) == OK)
return std::string("successful");
return std::string("unsuccessful");
return std::string("failed");
}
else if (cmd == "powerchip") {
@ -4631,6 +4638,25 @@ std::string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action,
return std::to_string(myDet->setLEDEnable(-1, detPos));
}
else if (cmd == "diodelay") {
if (action == GET_ACTION) {
return std::string("Cannot get");
}
myDet->setOnline(ONLINE_FLAG, detPos);
uint64_t pinMask = -1;
if (!sscanf(args[1], "%lx", &pinMask))
return std::string("could not scan diodelay pin mask(in hex) " + std::string(args[1]));
int delay = -1;
if (!sscanf(args[2], "%d", &delay))
return std::string("could not scan diodelay delay " + std::string(args[2]));
int retval = myDet->setDigitalIODelay(pinMask, delay, detPos);
if (retval == -1)
return std::to_string(-1);
return std::string((retval == OK) ? "successful" : "failed");
}
else if (cmd == "auto_comp_disable") {
char ans[100];
myDet->setOnline(ONLINE_FLAG, detPos);
@ -4658,6 +4684,7 @@ std::string slsDetectorCommand::helpAdvanced(int action) {
os << "resetfpga f \t resets fpga, f can be any value" << std::endl;
os << "led s \t sets led status (0 off, 1 on)" << std::endl;
os << "diodelay m v \tsets the delay for the digital IO pins selected by mask m and delay set by v. mask is upto 64 bits in hex, delay max is 775ps, and set in steps of 25 ps. Used for MOENCH/CTB only." << std::endl;
os << "powerchip i \t powers on or off the chip. i = 1 for on, i = 0 for off" << std::endl;
os << "auto_comp_disable i \t Currently not implemented. this mode disables the on-chip gain switching comparator automatically after 93.75% of exposure time (only for longer than 100us). 1 enables mode, 0 disables mode. By default, mode is disabled (comparator is enabled throughout). (JUNGFRAU only). " << std::endl;
}
@ -4778,10 +4805,10 @@ std::string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action,
if (action == GET_ACTION)
return std::string("cannot get");
else {
if (myDet->resetFramesCaught(detPos) == FAIL)
strcpy(answer, "failed");
else
if (myDet->resetFramesCaught(detPos) == OK)
strcpy(answer, "successful");
else
strcpy(answer, "failed");
return std::string(answer);
}
}
@ -5462,7 +5489,7 @@ std::string slsDetectorCommand::cmdPulse(int narg, char *args[], int action, int
if (retval == OK)
return std::string(" successful");
else
return std::string(" unsuccessful");
return std::string(" failed");
}