mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-29 09:30:02 +02:00
WIP
This commit is contained in:
parent
61d7c76d55
commit
19b85b8e40
@ -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.");
|
||||
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -176,6 +176,34 @@ inline std::string ToString(const defs::readoutMode s){
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string ToString(const defs::frameModeType s){
|
||||
switch (s) {
|
||||
case defs::PEDESTAL:
|
||||
return std::string("pedestal");
|
||||
case defs::NEW_PEDESTAL:
|
||||
return std::string("newpedestal");
|
||||
case defs::FLATFIELD:
|
||||
return std::string("flatfield");
|
||||
case defs::NEW_FLATFIELD:
|
||||
return std::string("newflatfield");
|
||||
default:
|
||||
return std::string("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string ToString(const defs::detectorModeType s){
|
||||
switch (s) {
|
||||
case defs::COUNTING:
|
||||
return std::string("counting");
|
||||
case defs::INTERPOLATING:
|
||||
return std::string("interpolating");
|
||||
case defs::ANALOG:
|
||||
return std::string("analog");
|
||||
default:
|
||||
return std::string("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
// in case we already have a string
|
||||
// causes a copy but might be needed in generic code
|
||||
inline std::string ToString(const std::string& s){
|
||||
@ -473,6 +501,29 @@ inline defs::readoutMode StringTo(const std::string& s) {
|
||||
throw sls::RuntimeError("Unknown readout mode " + s);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline defs::frameModeType StringTo(const std::string& s) {
|
||||
if (s == "pedestal")
|
||||
return defs::PEDESTAL;
|
||||
if (s == "newpedestal")
|
||||
return defs::NEW_PEDESTAL;
|
||||
if (s == "flatfield")
|
||||
return defs::FLATFIELD;
|
||||
if (s == "newflatfield")
|
||||
return defs::NEW_FLATFIELD;
|
||||
throw sls::RuntimeError("Unknown frame mode " + s);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline defs::detectorModeType StringTo(const std::string& s) {
|
||||
if (s == "counting")
|
||||
return defs::COUNTING;
|
||||
if (s == "interpolating")
|
||||
return defs::INTERPOLATING;
|
||||
if (s == "analog")
|
||||
return defs::ANALOG;
|
||||
throw sls::RuntimeError("Unknown detector mode " + s);
|
||||
}
|
||||
|
||||
/** For types with a .str() method use this for conversion */
|
||||
template <typename T>
|
||||
|
@ -662,80 +662,6 @@ format
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* returns frameModeType as enum
|
||||
* @param s pedestal, newpedestal, flatfield, newflatfield
|
||||
* @returns PEDESTAL, NEW_PEDESTAL, FLATFIELD, NEW_FLATFIELD, GET_FRAME_MODE
|
||||
* (if unknown)
|
||||
*/
|
||||
static frameModeType getFrameModeType(std::string s) {
|
||||
for (auto &c : s)
|
||||
c = std::tolower(c);
|
||||
if (s == "pedestal")
|
||||
return PEDESTAL;
|
||||
if (s == "newpedestal")
|
||||
return NEW_PEDESTAL;
|
||||
if (s == "flatfield")
|
||||
return FLATFIELD;
|
||||
if (s == "newflatfield")
|
||||
return NEW_FLATFIELD;
|
||||
return GET_FRAME_MODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns frameModeType as string
|
||||
* @param f PEDESTAL, NEW_PEDESTAL, FLATFIELD, NEW_FLATFIELD
|
||||
* @return string pedestal, newpedestal, flatfield, newflatfield, unknown
|
||||
*/
|
||||
static std::string getFrameModeType(frameModeType f) {
|
||||
switch (f) {
|
||||
case PEDESTAL:
|
||||
return std::string("pedestal");
|
||||
case NEW_PEDESTAL:
|
||||
return std::string("newPedestal");
|
||||
case FLATFIELD:
|
||||
return std::string("flatfield");
|
||||
case NEW_FLATFIELD:
|
||||
return std::string("newFlatfield");
|
||||
default:
|
||||
return std::string("unknown");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns detectorModeType as enum
|
||||
* @param s counting, interpolating, analog
|
||||
* @returns COUNTING, INTERPOLATING, ANALOG, GET_DETECTOR_MODE (if unknown)
|
||||
*/
|
||||
static detectorModeType getDetectorModeType(std::string s) {
|
||||
for (auto &c : s)
|
||||
c = std::tolower(c);
|
||||
if (s == "counting")
|
||||
return COUNTING;
|
||||
if (s == "interpolating")
|
||||
return INTERPOLATING;
|
||||
if (s == "analog")
|
||||
return ANALOG;
|
||||
return GET_DETECTOR_MODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns frameModeType as string
|
||||
* @param f COUNTING, INTERPOLATING, ANALOG
|
||||
* @return string counting, interpolating, analog, unknown
|
||||
*/
|
||||
static std::string getDetectorModeType(detectorModeType f) {
|
||||
switch (f) {
|
||||
case COUNTING:
|
||||
return std::string("counting");
|
||||
case INTERPOLATING:
|
||||
return std::string("interpolating");
|
||||
case ANALOG:
|
||||
return std::string("analog");
|
||||
default:
|
||||
return std::string("unknown");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user