mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
reverted json_emin, emax, framemode and detectormode. All json parameters for moench will go through rx_jsonpara using strings
This commit is contained in:
@ -2729,84 +2729,6 @@ std::string slsDetector::getAdditionalJsonParameter(const std::string& key) {
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
int slsDetector::validateSpecificJsonParameterValue(jsonHeaderParameterType mode, int value) {
|
||||
|
||||
switch (mode) {
|
||||
|
||||
case JSON_EMIN:
|
||||
case JSON_EMAX:
|
||||
return OK;
|
||||
|
||||
case JSON_FRAME_MODE:
|
||||
switch (value) {
|
||||
case JSON_PEDESTAL:
|
||||
case JSON_N_PEDESTAL:
|
||||
case JSON_FLATFIELD:
|
||||
case JSON_N_FLATFIELD:
|
||||
case JSON_FRAME:
|
||||
return OK;
|
||||
default:
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
case JSON_DETECTOR_MODE:
|
||||
switch (value) {
|
||||
case JSON_ANALOG:
|
||||
case JSON_COUNTING:
|
||||
case JSON_INTERPOLATING:
|
||||
return OK;
|
||||
default:
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
default:
|
||||
FILE_LOG(logERROR) << "Unkown Json Parameter Type " << mode;
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
int slsDetector::setAdditionalJsonSpecificParameter(jsonHeaderParameterType mode, int value) {
|
||||
|
||||
if (validateSpecificJsonParameterValue(mode, value) == FAIL) {
|
||||
FILE_LOG(logERROR) << "Unknown mode " << value << " to set detector mode for json header";
|
||||
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
|
||||
return getAdditionalJsonSpecificParameter(mode);
|
||||
}
|
||||
|
||||
std::string smode = getJsonHeaderParameterTypeAsString(mode);
|
||||
std::string sval;
|
||||
if (mode == JSON_EMIN || mode == JSON_EMAX)
|
||||
sval = std::to_string(value);
|
||||
else
|
||||
sval = getJsonHeaderParameterValueAsString((jsonHeaderParameterValuesType)value);
|
||||
setAdditionalJsonParameter(smode, sval);
|
||||
return getAdditionalJsonSpecificParameter(mode);
|
||||
}
|
||||
|
||||
int slsDetector::getAdditionalJsonSpecificParameter(jsonHeaderParameterType mode) {
|
||||
std::string smode = getJsonHeaderParameterTypeAsString(mode);
|
||||
std::string sval = getAdditionalJsonParameter(smode);
|
||||
|
||||
int val = 0;
|
||||
if (mode == JSON_EMIN || mode == JSON_EMAX) {
|
||||
try{
|
||||
val = stoi(sval);
|
||||
} catch(...) {
|
||||
FILE_LOG(logERROR) << "json emin or emax set to a string. Fix additional json header";
|
||||
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
val = getJsonHeaderParameterValuesAsEnum(sval);
|
||||
|
||||
if (validateSpecificJsonParameterValue(mode, val) == FAIL) {
|
||||
FILE_LOG(logERROR) << "Unknown mode " << val << "(" <<sval << ") retrieved from detector mode for json header";
|
||||
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
|
||||
return -1;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
int slsDetector::setReceiverUDPSocketBufferSize(int udpsockbufsize) {
|
||||
int fnum = F_RECEIVER_UDP_SOCK_BUF_SIZE;
|
||||
int ret = FAIL;
|
||||
|
@ -994,28 +994,6 @@ public:
|
||||
*/
|
||||
std::string getAdditionalJsonParameter(const std::string& key);
|
||||
|
||||
/**
|
||||
* Validates the value parsed for the corresponding parameter type
|
||||
* @param mode specific parameter type
|
||||
* @value value enum of the value
|
||||
*/
|
||||
int validateSpecificJsonParameterValue(jsonHeaderParameterType mode, int value);
|
||||
|
||||
/**
|
||||
* Sets the value for a specific additional json header parameter
|
||||
* @param mode specific json header parameter (JSON_EMIN, JSON_EMAX, JSON_READOUT_MODE, JSON_DETECTOR_MODE)
|
||||
* @param value to set the parameter to, json_readout_mode and json_detector_mode can have only have values from jsonReadoutModeType or jsonDetectorModeType
|
||||
* @returns the specific additional json header parameter value or enum
|
||||
*/
|
||||
int setAdditionalJsonSpecificParameter(jsonHeaderParameterType mode, int value);
|
||||
|
||||
/**
|
||||
* Returns the specific additional json header parameter value
|
||||
* @param mode specific json header parameter (JSON_EMIN, JSON_EMAX, JSON_READOUT_MODE, JSON_DETECTOR_MODE)
|
||||
* @returns the specific additional json header parameter value or enum
|
||||
*/
|
||||
int getAdditionalJsonSpecificParameter(jsonHeaderParameterType mode);
|
||||
|
||||
/**
|
||||
* Sets the receiver UDP socket buffer size
|
||||
* @param udpsockbufsize additional json header
|
||||
|
@ -1815,34 +1815,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
|
||||
++i;
|
||||
|
||||
/*! \page prototype
|
||||
- <b>json_emin [i] </b> Sets/gets detector minimum energy threshold for the Moench (soft setting). It is only set in the json header for the processor. \c Returns string
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "json_emin"; //
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdProcessor;
|
||||
++i;
|
||||
|
||||
/*! \page prototype
|
||||
- <b>json_emax [i] </b> Sets/gets detector maximum energy threshold for the Moench (soft setting). It is only set in the json header for the processor. \c Returns string
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "json_emax"; //
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdProcessor;
|
||||
++i;
|
||||
|
||||
/*! \page prototype
|
||||
- <b>json_framemode [i] </b> Sets/gets readoutmode for the Moench (soft setting). It is only set in the json header for the processor. Options: pedestal, newpedestal, flatfield, newflatfield, frame. \c Returns string
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "json_framemode"; //
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdProcessor;
|
||||
++i;
|
||||
|
||||
/*! \page prototype
|
||||
- <b>json_detectormode [i] </b> Sets/gets detector mode for the Moench (soft setting). It is only set in the json header for the processor.Options: analog, counting, interpolating. \c Returns string
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "json_detectormode"; //
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdProcessor;
|
||||
++i;
|
||||
|
||||
/*! \page prototype
|
||||
- <b>pattern fn</b> loads binary pattern file fn
|
||||
*/
|
||||
@ -5463,58 +5435,3 @@ std::string slsDetectorCommand::cmdPulse(int narg, char *args[], int action, int
|
||||
}
|
||||
|
||||
|
||||
std::string slsDetectorCommand::helpProcessor(int action) {
|
||||
std::ostringstream os;
|
||||
if (action == PUT_ACTION || action == HELP_ACTION) {
|
||||
os << "json_emin [t]\n sets value to t for minimum threshold (emin) in additional json header to be streamed out with the zmq from receiver. For Moench." << std::endl;
|
||||
os << "json_emax [t]\n sets value to t for maximum threshold (emax) in additional json header to be streamed out with the zmq from receiver. For Moench." << std::endl;
|
||||
os << "json_framemode [s]\n sets readoutmode for the Moench (soft setting). It is only set in the json header for the processor. Options: pedestal, newpedestal, flatfield, newflatfield, frame. " << std::endl;
|
||||
os << "json_detectormode [s]\n sets detector mode for the Moench (soft setting). It is only set in the json header for the processor.Options: analog, counting, interpolating. " << std::endl;
|
||||
}
|
||||
if (action == GET_ACTION || action == HELP_ACTION) {
|
||||
os << "json_emin \n gets value of minimum threshold (emin) in additional json header to be streamed out with the zmq from receiver. If no parameter found, it returns empty string. For Moench." << std::endl;
|
||||
os << "json_emin \n gets value of maximum threshold (emax) in additional json header to be streamed out with the zmq from receiver. If no parameter found, it returns empty string. For Moench." << std::endl;
|
||||
os << "json_framemode [s]\n gets readoutmode for the Moench (soft setting). It is only set in the json header for the processor. Options: pedestal, newpedestal, flatfield, newflatfield, frame. " << std::endl;
|
||||
os << "json_detectormode [s]\n gets detector mode for the Moench (soft setting). It is only set in the json header for the processor.Options: analog, counting, interpolating. " << std::endl;
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdProcessor(int narg, char *args[], int action, int detPos) {
|
||||
if (action == HELP_ACTION)
|
||||
return helpProcessor(action);
|
||||
|
||||
myDet->setOnline(ONLINE_FLAG, detPos);
|
||||
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
||||
|
||||
int imode = getJsonHeaderParameterTypeAsEnum(cmd);
|
||||
jsonHeaderParameterType mode = JSON_EMIN;
|
||||
if (imode != -1)
|
||||
mode = (jsonHeaderParameterType)imode;
|
||||
int ival = -1;
|
||||
|
||||
if (cmd == "json_emin" || cmd == "json_emax") {
|
||||
if (action == PUT_ACTION) {
|
||||
if (!sscanf(args[1],"%d", &ival))
|
||||
return std::string("cannot scan value ") + std::string(args[1]) + std::string(" for command ") + cmd;
|
||||
myDet->setAdditionalJsonSpecificParameter(mode, ival);
|
||||
}
|
||||
return std::to_string(myDet->getAdditionalJsonSpecificParameter(mode));
|
||||
}
|
||||
|
||||
else if (cmd == "json_framemode" || cmd == "json_detectormode") {
|
||||
if (action == PUT_ACTION) {
|
||||
ival = getJsonHeaderParameterValuesAsEnum(args[1]);
|
||||
if (ival == -1)
|
||||
return std::string("cannot scan value ") + std::string(args[1]) + std::string(" for command ") + cmd;
|
||||
myDet->setAdditionalJsonSpecificParameter(mode, ival);
|
||||
}
|
||||
int retval = myDet->getAdditionalJsonSpecificParameter(mode);
|
||||
if (retval == -1)
|
||||
return std::string("unknown");
|
||||
return getJsonHeaderParameterValueAsString((jsonHeaderParameterValuesType)retval);
|
||||
}
|
||||
|
||||
return std::string("could not decode command");
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,6 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
static std::string helpReceiver(int action);
|
||||
static std::string helpPattern(int action);
|
||||
static std::string helpPulse(int action);
|
||||
static std::string helpProcessor(int action);
|
||||
|
||||
|
||||
|
||||
@ -142,7 +141,6 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
std::string cmdReceiver(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdPattern(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdPulse(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdProcessor(int narg, char *args[], int action, int detPos = -1);
|
||||
|
||||
int numberOfCommands;
|
||||
std::string cmd;
|
||||
|
Reference in New Issue
Block a user