client: added command line and for APIfor framemode and detectormode. Refactorinng required in the future

This commit is contained in:
2019-02-13 20:19:08 +01:00
parent fd95550724
commit 46aa7769cc
7 changed files with 365 additions and 57 deletions

View File

@ -2729,6 +2729,84 @@ 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;