ctb, moench: implemented led enable feature

This commit is contained in:
2019-03-01 09:00:04 +01:00
parent ebee9e308e
commit bb81613900
13 changed files with 120 additions and 22 deletions

View File

@ -3595,6 +3595,17 @@ uint64_t multiSlsDetector::setCTBPatWaitTime(int level, uint64_t t, int detPos)
return sls::minusOneIfDifferent(r);
}
int multiSlsDetector::setLEDEnable(int enable, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setLEDEnable(enable);
}
// multi
auto r = parallelCall(&slsDetector::setLEDEnable, enable);
return sls::minusOneIfDifferent(r);
}
int multiSlsDetector::retrieveDetectorSetup(const std::string &fname1,
int level) {

View File

@ -1735,6 +1735,14 @@ class multiSlsDetector : public virtual slsDetectorDefs,
*/
uint64_t setCTBPatWaitTime(int level, uint64_t t = -1, int detPos = -1);
/**
* Set LED Enable (Moench, CTB only)
* @param enable 1 to switch on, 0 to switch off, -1 gets
* @param detPos -1 for all detectors in list or specific detector position
* @returns LED enable
*/
int setLEDEnable(int enable = -1, int detPos = -1);
/**
* Loads the detector setup from file
* @param fname file to read from

View File

@ -5084,6 +5084,30 @@ uint64_t slsDetector::setCTBPatWaitTime(uint64_t level, uint64_t t) {
return retval;
}
int slsDetector::setLEDEnable(int enable) {
int fnum = F_LED;
int ret = FAIL;
int arg = enable;
int retval = -1;
FILE_LOG(logDEBUG1) << "Sending LED Enable: " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
} else {
FILE_LOG(logDEBUG1) << "LED Enable: " << retval;
}
}
if (ret == FORCE_UPDATE) {
ret = updateDetector();
}
return retval;
}
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

@ -1596,6 +1596,13 @@ public:
*/
uint64_t setCTBPatWaitTime(uint64_t level, uint64_t t=-1);
/**
* Set LED Enable (Moench, CTB only)
* @param enable 1 to switch on, 0 to switch off, -1 gets
* @returns LED enable
*/
int setLEDEnable(int enable = -1);
private:
/**

View File

@ -4621,18 +4621,14 @@ std::string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action,
}
else if (cmd == "led") {
char ans[100];
int val = 0;
myDet->setOnline(ONLINE_FLAG, detPos);
if (action == PUT_ACTION) {
int ival = -1;
if (!sscanf(args[1], "%d", &ival))
return std::string("could not scan powerchip parameter " + std::string(args[1]));
val = myDet->readRegister(0x4d, detPos);
myDet->writeRegister(0x4d, (val & (~1)) | ((~ival) & 1), detPos); //config register
return std::string("could not scan led parameter " + std::string(args[1]));
myDet->setLEDEnable(ival, detPos);
}
sprintf(ans, "%d", ~(myDet->readRegister(0x4d, detPos)) & 1);
return std::string(ans);
return std::to_string(myDet->setLEDEnable(-1, detPos));
}
else if (cmd == "auto_comp_disable") {