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

View File

@ -734,6 +734,8 @@ class CmdProxy {
/* Moench */ /* Moench */
{"rx_jsonaddheader", &CmdProxy::rx_jsonaddheader}, {"rx_jsonaddheader", &CmdProxy::rx_jsonaddheader},
{"rx_jsonpara", &CmdProxy::JsonParameter}, {"rx_jsonpara", &CmdProxy::JsonParameter},
{"emin", &CmdProxy::MinMaxEnergyThreshold},
{"emax", &CmdProxy::MinMaxEnergyThreshold},
@ -801,6 +803,7 @@ class CmdProxy {
std::string PatternWaitTime(int action); std::string PatternWaitTime(int action);
/* Moench */ /* Moench */
std::string JsonParameter(int action); std::string JsonParameter(int action);
std::string MinMaxEnergyThreshold(int action);
@ -1271,7 +1274,7 @@ class CmdProxy {
/* Moench */ /* Moench */
STRING_COMMAND(rx_jsonaddheader, getAdditionalJsonHeader, setAdditionalJsonHeader, STRING_COMMAND(rx_jsonaddheader, getAdditionalJsonHeader, setAdditionalJsonHeader,
"[\"label1\":\"value1\"], [\"label2\":\"value2\"]\n\t[Moench] Additional json header to be streamd out from receiver via zmq. Default is empty. Use only if to be processed by an intermediate user process listening to receiver zmq packets."); "[\"label1\":\"value1\"], [\"label2\":\"value2\"]\n\tAdditional json header to be streamd out from receiver via zmq. Default is empty. Use only if to be processed by an intermediate user process listening to receiver zmq packets.");

View File

@ -1096,13 +1096,13 @@ class Detector {
Positions pos = {}); Positions pos = {});
/** [Moench: -1 if unknown mode] */ /** [Moench: -1 if unknown mode] */
Result<int> getFrameMode(Positions pos = {}) const; Result<defs::frameModeType> getFrameMode(Positions pos = {}) const;
/** [Moench] */ /** [Moench] */
void setFrameMode(defs::frameModeType value, Positions pos = {}); void setFrameMode(defs::frameModeType value, Positions pos = {});
/** [Moench: -1 if unknown mode] */ /** [Moench: -1 if unknown mode] */
Result<int> getDetectorMode(Positions pos = {}) const; Result<defs::detectorModeType> getDetectorMode(Positions pos = {}) const;
/** [Moench] */ /** [Moench] */
void setDetectorMode(defs::detectorModeType value, Positions pos = {}); void setDetectorMode(defs::detectorModeType value, Positions pos = {});

View File

@ -1246,7 +1246,7 @@ std::string CmdProxy::JsonParameter(int action) {
std::ostringstream os; std::ostringstream os;
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { 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) { } else if (action == defs::GET_ACTION) {
if (args.size() != 1) { if (args.size() != 1) {
WrongNumberOfParameters(1); WrongNumberOfParameters(1);
@ -1265,5 +1265,35 @@ std::string CmdProxy::JsonParameter(int action) {
return os.str(); 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 } // namespace sls

View File

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

View File

@ -929,13 +929,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver; descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver;
++i; ++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 */ /* pattern generator */
@ -943,20 +936,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
Commands specific for the chiptest board or moench 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 /*! \page prototype
- <b>framemode [i] </b> Sets/gets frame mode for Moench (soft setting in processor). Options: pedestal, newpedestal, flatfield, newflatfield - <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"); return std::string("could not decode command");
} }
@ -2081,12 +2054,10 @@ std::string slsDetectorCommand::helpReceiver(int action) {
std::ostringstream os; std::ostringstream os;
if (action == PUT_ACTION || action == HELP_ACTION) { if (action == PUT_ACTION || action == HELP_ACTION) {
os << "resetframescaught [any value] \t resets frames caught by receiver" << std::endl; 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) { if (action == GET_ACTION || action == HELP_ACTION) {
os << "frameindex \t returns the current frame index of receiver(average for multi)" << std::endl; 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(); return os.str();
@ -2098,14 +2069,10 @@ std::string slsDetectorCommand::helpProcessor(int action) {
std::ostringstream os; std::ostringstream os;
if (action == PUT_ACTION || action == HELP_ACTION) { 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 << "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; 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) { 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 << "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; 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); 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) { if (action == PUT_ACTION) {
frameModeType ival = getFrameModeType(args[1]); frameModeType ival = getFrameModeType(args[1]);
if (ival == GET_FRAME_MODE) if (ival == GET_FRAME_MODE)

View File

@ -9,6 +9,26 @@
auto GET = slsDetectorDefs::GET_ACTION; auto GET = slsDetectorDefs::GET_ACTION;
auto PUT = slsDetectorDefs::PUT_ACTION; auto PUT = slsDetectorDefs::PUT_ACTION;
TEST_CASE("emin", "[.cmd][.moench]") {
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("emin 100", PUT, nullptr, oss));
REQUIRE(oss.str() == "emin 100\n");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("emax 200", PUT, nullptr, oss));
REQUIRE(oss.str() == "emax 200\n");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonpara emax", GET, nullptr, oss));
REQUIRE(oss.str() == "rx_jsonpara 200\n");
}
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonaddheader \"\"", PUT));
}
TEST_CASE("rx_jsonpara", "[.cmd][.moench]") { TEST_CASE("rx_jsonpara", "[.cmd][.moench]") {
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonaddheader \"key1\":\"value1\"", PUT)); REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonaddheader \"key1\":\"value1\"", PUT));
{ {