This commit is contained in:
2019-10-28 11:56:15 +01:00
parent 61d7c76d55
commit 19b85b8e40
8 changed files with 112 additions and 146 deletions

View File

@ -736,7 +736,8 @@ class CmdProxy {
{"rx_jsonpara", &CmdProxy::JsonParameter},
{"emin", &CmdProxy::MinMaxEnergyThreshold},
{"emax", &CmdProxy::MinMaxEnergyThreshold},
{"framemode", &CmdProxy::framemode},
{"detectormode", &CmdProxy::detectormode},
@ -1276,6 +1277,11 @@ class CmdProxy {
STRING_COMMAND(rx_jsonaddheader, getAdditionalJsonHeader, setAdditionalJsonHeader,
"[\"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.");
INTEGER_COMMAND(framemode, getFrameMode, setFrameMode, sls::StringTo<slsDetectorDefs::frameModeType>,
"[pedestal|newpedestal|flatfield|newflatfield]\n\t[Moench] Frame mode (soft setting) in processor.");
INTEGER_COMMAND(detectormode, getDetectorMode, setDetectorMode, sls::StringTo<slsDetectorDefs::detectorModeType>,
"[counting|interpolating|analog]\n\t[Moench] Detector mode (soft setting) in processor.");

View File

@ -57,7 +57,6 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
static std::string helpAdvanced(int action);
static std::string helpConfiguration(int action);
static std::string helpReceiver(int action);
static std::string helpProcessor(int action);
private:
multiSlsDetector *myDet;
@ -81,7 +80,6 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
std::string cmdAdvanced(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdConfiguration(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdReceiver(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdProcessor(int narg, const char * const args[], int action, int detPos = -1);
int numberOfCommands;
std::string cmd;

View File

@ -1426,7 +1426,7 @@ Result<defs::frameModeType> Detector::getFrameMode(Positions pos) const {
Result<defs::frameModeType> intResult(res.size());
try {
for (unsigned int i = 0; i < res.size(); ++i) {
intResult[i] = defs::getFrameModeType(res[i]);
intResult[i] = sls::StringTo<slsDetectorDefs::frameModeType>(res[i]);
}
} catch (...) {
throw RuntimeError(
@ -1437,7 +1437,7 @@ Result<defs::frameModeType> Detector::getFrameMode(Positions pos) const {
void Detector::setFrameMode(defs::frameModeType value, Positions pos) {
pimpl->Parallel(&slsDetector::setAdditionalJsonParameter, pos, "frameMode",
defs::getFrameModeType(value));
sls::ToString(value));
}
Result<defs::detectorModeType> Detector::getDetectorMode(Positions pos) const {
@ -1446,7 +1446,7 @@ Result<defs::detectorModeType> Detector::getDetectorMode(Positions pos) const {
Result<defs::detectorModeType> intResult(res.size());
try {
for (unsigned int i = 0; i < res.size(); ++i) {
intResult[i] = defs::getDetectorModeType(res[i]);
intResult[i] = sls::StringTo<slsDetectorDefs::detectorModeType>(res[i]);
}
} catch (...) {
throw RuntimeError(
@ -1457,7 +1457,7 @@ Result<defs::detectorModeType> Detector::getDetectorMode(Positions pos) const {
void Detector::setDetectorMode(defs::detectorModeType value, Positions pos) {
pimpl->Parallel(&slsDetector::setAdditionalJsonParameter, pos,
"detectorMode", defs::getDetectorModeType(value));
"detectorMode", sls::ToString(value));
}
// Advanced

View File

@ -1406,11 +1406,11 @@ int multiSlsDetector::setFrameMode(frameModeType value, int detPos) {
if (value == GET_FRAME_MODE) {
result = getAdditionalJsonParameter(parameter, detPos);
} else {
result = setAdditionalJsonParameter(parameter, getFrameModeType(value),
result = setAdditionalJsonParameter(parameter, sls::ToString(value),
detPos);
}
return getFrameModeType(result);
return sls::StringTo<slsDetectorDefs::frameModeType>(result);
}
int multiSlsDetector::setDetectorMode(detectorModeType value, int detPos) {
@ -1421,10 +1421,10 @@ int multiSlsDetector::setDetectorMode(detectorModeType value, int detPos) {
result = getAdditionalJsonParameter(parameter, detPos);
} else {
result = setAdditionalJsonParameter(parameter,
getDetectorModeType(value), detPos);
sls::ToString(value), detPos);
}
return getDetectorModeType(result);
return sls::StringTo<slsDetectorDefs::detectorModeType>(result);
}
int64_t multiSlsDetector::setReceiverUDPSocketBufferSize(int64_t udpsockbufsize,

View File

@ -932,23 +932,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
/* pattern generator */
/*! \page prototype Chip Test Board / Moench
Commands specific for the chiptest board or moench
*/
/*! \page prototype
- <b>framemode [i] </b> Sets/gets frame mode for Moench (soft setting in processor). Options: pedestal, newpedestal, flatfield, newflatfield
*/
descrToFuncMap[i].m_pFuncName = "framemode";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdProcessor;
++i;
/*! \page prototype
- <b>detectormode [i] </b> Sets/gets detector mode for Moench (soft setting in processor). Options: counting, interpolating, analog
*/
descrToFuncMap[i].m_pFuncName = "detectormode";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdProcessor;
++i;
numberOfCommands = i;
@ -2065,47 +2048,4 @@ std::string slsDetectorCommand::helpReceiver(int action) {
std::string slsDetectorCommand::helpProcessor(int action) {
std::ostringstream os;
if (action == PUT_ACTION || action == HELP_ACTION) {
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 << "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;
}
return os.str();
}
std::string slsDetectorCommand::cmdProcessor(int narg, const char * const args[], int action, int detPos) {
if (action == HELP_ACTION)
return helpProcessor(action);
if (cmd == "framemode") {
if (action == PUT_ACTION) {
frameModeType ival = getFrameModeType(args[1]);
if (ival == GET_FRAME_MODE)
return std::string("cannot parse frame mode value");
myDet->setFrameMode(ival, detPos);
}
return getFrameModeType(frameModeType(myDet->setFrameMode(GET_FRAME_MODE, detPos)));
}
else if (cmd == "detectormode") {
if (action == PUT_ACTION) {
detectorModeType ival = getDetectorModeType(args[1]);
if (ival == GET_DETECTOR_MODE)
return std::string("cannot parse detector mode value");
myDet->setDetectorMode(ival, detPos);
}
return getDetectorModeType(detectorModeType(myDet->setDetectorMode(GET_DETECTOR_MODE, detPos)));
}
return std::string("unknown command");
}

View File

@ -9,6 +9,51 @@
auto GET = slsDetectorDefs::GET_ACTION;
auto PUT = slsDetectorDefs::PUT_ACTION;
TEST_CASE("detectormode", "[.cmd][.moench]") {
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("detectormode counting", PUT, nullptr, oss));
REQUIRE(oss.str() == "detectormode counting\n");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("detectormode interpolating", PUT, nullptr, oss));
REQUIRE(oss.str() == "detectormode interpolating\n");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("detectormode analog", PUT, nullptr, oss));
REQUIRE(oss.str() == "detectormode analog\n");
}
REQUIRE_NOTHROW(multiSlsDetectorClient("detectormode counting", PUT));
REQUIRE_THROWS(multiSlsDetectorClient("detectormode pedestal", PUT));
}
TEST_CASE("framemode", "[.cmd][.moench]") {
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("framemode pedestal", PUT, nullptr, oss));
REQUIRE(oss.str() == "framemode pedestal\n");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("framemode newpedestal", PUT, nullptr, oss));
REQUIRE(oss.str() == "framemode newpedestal\n");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("framemode flatfield", PUT, nullptr, oss));
REQUIRE(oss.str() == "framemode flatfield\n");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("framemode newflatfield", PUT, nullptr, oss));
REQUIRE(oss.str() == "framemode newflatfield\n");
}
REQUIRE_NOTHROW(multiSlsDetectorClient("framemode pedestal", PUT));
REQUIRE_THROWS(multiSlsDetectorClient("framemode counting", PUT));
}
TEST_CASE("emin", "[.cmd][.moench]") {
{
std::ostringstream oss;