This commit is contained in:
2019-10-28 11:34:58 +01:00
parent 93bb0c9aed
commit 61d7c76d55
6 changed files with 62 additions and 51 deletions

View File

@ -1246,7 +1246,7 @@ std::string CmdProxy::JsonParameter(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[key1] [value1]\n\t[Moench] Additional json header parameter streamed out from receiver. This is same as calling rx_jsonaddheader \"key\":\"value1\"" << '\n';
os << "[key1] [value1]\n\tAdditional json header parameter streamed out from receiver. If empty in a get, then no parameter found. This is same as calling rx_jsonaddheader \"key\":\"value1\"." << '\n';
} else if (action == defs::GET_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
@ -1265,5 +1265,35 @@ std::string CmdProxy::JsonParameter(int action) {
return os.str();
}
std::string CmdProxy::MinMaxEnergyThreshold(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "emin") {
os << "[n_value]\n\t[Moench] Minimum energy threshold (soft setting) for processor." << '\n';
} else if (cmd == "emin") {
os << "[n_value]\n\t[Moench] Maximum energy threshold (soft setting) for processor." << '\n';
} else {
throw sls::RuntimeError("Unknown command, use list to list all commands");
}
} else if (action == defs::GET_ACTION) {
if (args.size() != 0) {
WrongNumberOfParameters(0);
}
auto t = det->getDetectorMinMaxEnergyThreshold((cmd == "emax" ? true :false), {det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
det->setDetectorMinMaxEnergyThreshold((cmd == "emax" ? true : false), std::stoi(args[0]), {det_id});
os << args.front() << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
} // namespace sls

View File

@ -1420,10 +1420,10 @@ void Detector::setDetectorMinMaxEnergyThreshold(const bool isEmax,
isEmax ? "emax" : "emin", std::to_string(value));
}
Result<int> Detector::getFrameMode(Positions pos) const {
Result<defs::frameModeType> Detector::getFrameMode(Positions pos) const {
auto res = pimpl->Parallel(&slsDetector::getAdditionalJsonParameter, pos,
"frameMode");
Result<int> intResult(res.size());
Result<defs::frameModeType> intResult(res.size());
try {
for (unsigned int i = 0; i < res.size(); ++i) {
intResult[i] = defs::getFrameModeType(res[i]);
@ -1440,10 +1440,10 @@ void Detector::setFrameMode(defs::frameModeType value, Positions pos) {
defs::getFrameModeType(value));
}
Result<int> Detector::getDetectorMode(Positions pos) const {
Result<defs::detectorModeType> Detector::getDetectorMode(Positions pos) const {
auto res = pimpl->Parallel(&slsDetector::getAdditionalJsonParameter, pos,
"detectorMode");
Result<int> intResult(res.size());
Result<defs::detectorModeType> intResult(res.size());
try {
for (unsigned int i = 0; i < res.size(); ++i) {
intResult[i] = defs::getDetectorModeType(res[i]);

View File

@ -929,13 +929,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver;
++i;
/*! \page receiver
- <b>rx_jsonpara [k] [v]</b> sets/gets value v for additional json header parameter k to be streamed out with the zmq from receiver. If empty, then no parameter found Use only if it needs to be processed by an intermediate process. \c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName = "rx_jsonpara";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver;
i++;
/* pattern generator */
@ -943,20 +936,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
Commands specific for the chiptest board or moench
*/
/*! \page prototype
- <b>emin [i] </b> Sets/gets detector minimum energy threshold for Moench (soft setting in processor)
*/
descrToFuncMap[i].m_pFuncName = "emin";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdProcessor;
++i;
/*! \page prototype
- <b>emax [i] </b> Sets/gets detector maximum energy threshold for Moench (soft setting in processor)
*/
descrToFuncMap[i].m_pFuncName = "emax";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdProcessor;
++i;
/*! \page prototype
- <b>framemode [i] </b> Sets/gets frame mode for Moench (soft setting in processor). Options: pedestal, newpedestal, flatfield, newflatfield
*/
@ -2066,12 +2045,6 @@ std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[],
}
}
else if (cmd == "rx_jsonpara") {
if (action == PUT_ACTION) {
myDet->setAdditionalJsonParameter(args[1], args[2], detPos);
}
return myDet->getAdditionalJsonParameter(args[1], detPos);
}
return std::string("could not decode command");
}
@ -2081,12 +2054,10 @@ std::string slsDetectorCommand::helpReceiver(int action) {
std::ostringstream os;
if (action == PUT_ACTION || action == HELP_ACTION) {
os << "resetframescaught [any value] \t resets frames caught by receiver" << std::endl;
os << "rx_jsonpara [k] [v]\n sets value to v for additional json header parameter k to be streamed out with the zmq from receiver." << std::endl;
}
if (action == GET_ACTION || action == HELP_ACTION) {
os << "frameindex \t returns the current frame index of receiver(average for multi)" << std::endl;
os << "rx_jsonpara [k] \n gets value of additional json header parameter k to be streamed out with the zmq from receiver. If empty, then no parameter found." << std::endl;
}
return os.str();
@ -2098,14 +2069,10 @@ std::string slsDetectorCommand::helpProcessor(int action) {
std::ostringstream os;
if (action == PUT_ACTION || action == HELP_ACTION) {
os << "emin [n] \t Sets detector minimum energy threshold to x for Moench (soft setting in processor)" << std::endl;
os << "emax [n] \t Sets detector maximum energy threshold to x for Moench (soft setting in processor)" << std::endl;
os << "framemode [n] \t Sets frame mode for Moench (soft setting in processor). Options: pedestal, newpedestal, flatfield, newflatfield" << std::endl;
os << "detectormode [n] \t Sets detector mode for Moench (soft setting in processor). Options: counting, interpolating, analog" << std::endl;
}
if (action == GET_ACTION || action == HELP_ACTION) {
os << "emin [n] \t Gets detector minimum energy threshold to x for Moench (soft setting in processor)" << std::endl;
os << "emax [n] \t Gets detector maximum energy threshold to x for Moench (soft setting in processor)" << std::endl;
os << "framemode [n] \t Gets frame mode for Moench (soft setting in processor). Options: pedestal, newpedestal, flatfield, newflatfield" << std::endl;
os << "detectormode [n] \t Gets detector mode for Moench (soft setting in processor). Options: counting, interpolating, analog" << std::endl;
}
@ -2117,17 +2084,8 @@ std::string slsDetectorCommand::cmdProcessor(int narg, const char * const args[]
return helpProcessor(action);
if (cmd == "emin" || cmd == "emax") {
if (action == PUT_ACTION) {
int ival = -1;
if(!sscanf(args[1],"%d",&ival))
return std::string("cannot parse emin/emax value");
myDet->setDetectorMinMaxEnergyThreshold((cmd == "emin" ? 0 : 1), ival, detPos);
}
return std::to_string(myDet->setDetectorMinMaxEnergyThreshold(0, -1, detPos));
}
else if (cmd == "framemode") {
if (cmd == "framemode") {
if (action == PUT_ACTION) {
frameModeType ival = getFrameModeType(args[1]);
if (ival == GET_FRAME_MODE)