mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 10:30:41 +02:00
moench: adding enums for zmq parameters, needs modification in naming
This commit is contained in:
parent
421dbdb9b5
commit
f5244faa02
@ -1955,6 +1955,53 @@ std::string multiSlsDetector::getAdditionalJsonParameter(const std::string &key,
|
||||
return sls::concatenateIfDifferent(r);
|
||||
}
|
||||
|
||||
|
||||
int multiSlsDetector::setDetectorMinMaxEnergyThreshold(const int index, int value, int detPos) {
|
||||
std::string parameter = (index ? "emax" : "emin");
|
||||
|
||||
std::string result;
|
||||
if (value < 0) {
|
||||
result = getAdditionalJsonParameter(parameter, detPos);
|
||||
} else {
|
||||
result = setAdditionalJsonParameter(parameter, std::to_string(value), detPos);
|
||||
}
|
||||
|
||||
// convert to integer
|
||||
try {
|
||||
return stoi(result);
|
||||
}
|
||||
// not found or cannot scan integer
|
||||
catch(...) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int multiSlsDetector::setFrameMode(frameModeType value, int detPos) {
|
||||
std::string parameter = "frameMode";
|
||||
std::string result;
|
||||
|
||||
if (value == GET_FRAME_MODE) {
|
||||
result = getAdditionalJsonParameter(parameter, detPos);
|
||||
} else {
|
||||
result = setAdditionalJsonParameter(parameter, getFrameModeType(value), detPos);
|
||||
}
|
||||
|
||||
return getFrameModeType(result);
|
||||
}
|
||||
|
||||
int multiSlsDetector::setDetectorMode(detectorModeType value, int detPos) {
|
||||
std::string parameter = "detectorMode";
|
||||
std::string result;
|
||||
|
||||
if (value == GET_DETECTOR_MODE) {
|
||||
result = getAdditionalJsonParameter(parameter, detPos);
|
||||
} else {
|
||||
result = setAdditionalJsonParameter(parameter, getDetectorModeType(value), detPos);
|
||||
}
|
||||
|
||||
return getDetectorModeType(result);
|
||||
}
|
||||
|
||||
int multiSlsDetector::setReceiverUDPSocketBufferSize(int udpsockbufsize, int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
|
@ -1087,6 +1087,30 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
||||
*/
|
||||
std::string getAdditionalJsonParameter(const std::string& key, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Sets the detector minimum/maximum energy threshold in processor (for Moench only)
|
||||
* @param index 0 for emin, antyhing else for emax
|
||||
* @param v value to set (-1 gets)
|
||||
* @returns detector minimum/maximum energy threshold (-1 for not found or error in computing json parameter value)
|
||||
*/
|
||||
int setDetectorMinMaxEnergyThreshold(const int index, int value, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Sets the frame mode in processor (Moench only)
|
||||
* @param value frameModeType (-1 gets)
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns frame mode (-1 for not found or error in computing json parameter value)
|
||||
*/
|
||||
int setFrameMode(frameModeType value, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Sets the detector mode in processor (Moench only)
|
||||
* @param value detectorModetype (-1 gets)
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns detector mode (-1 for not found or error in computing json parameter value)
|
||||
*/
|
||||
int setDetectorMode(detectorModeType value, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Sets the receiver UDP socket buffer size
|
||||
* @param udpsockbufsize additional json header
|
||||
|
@ -63,7 +63,7 @@ The commands are sudivided into different pages depending on their functionaliti
|
||||
- \ref output "Output": commands to define output file destination and format
|
||||
- \ref network "Network": commands to setup the network between client, detector and receiver
|
||||
- \ref receiver "Receiver": commands to configure the receiver
|
||||
- \ref prototype "Prototype (Chip Test Board / Moench)": commands specific for the chiptest board or moench
|
||||
- \ref prototype "Chip Test Board / Moench": commands specific for the chiptest board or moench
|
||||
- \ref test "Developer": commands to be used only for software debugging. Avoid using them!
|
||||
|
||||
*/
|
||||
@ -1796,10 +1796,37 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
|
||||
/* pattern generator */
|
||||
|
||||
/*! \page prototype Protoype (Chip Test Board / Moench)
|
||||
/*! \page prototype Chip Test Board / 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
|
||||
- <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;
|
||||
|
||||
/*! \page prototype
|
||||
- <b>adcinvert [mask]</b> Sets/gets ADC inversion mask (8 digits hex format)
|
||||
@ -5443,3 +5470,62 @@ std::string slsDetectorCommand::cmdPulse(int narg, char *args[], int action, int
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdProcessor(int narg, char *args[], int action, int detPos) {
|
||||
if (action == HELP_ACTION)
|
||||
return helpProcessor(action);
|
||||
|
||||
myDet->setOnline(ONLINE_FLAG, detPos);
|
||||
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
||||
|
||||
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 (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 action");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -79,7 +79,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
static std::string helpReceiver(int action);
|
||||
static std::string helpPattern(int action);
|
||||
static std::string helpPulse(int action);
|
||||
|
||||
static std::string helpProcessor(int action);
|
||||
|
||||
|
||||
|
||||
@ -141,6 +141,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
std::string cmdReceiver(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdPattern(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdPulse(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdProcessor(int narg, char *args[], int action, int detPos = -1);
|
||||
|
||||
int numberOfCommands;
|
||||
std::string cmd;
|
||||
|
@ -359,14 +359,19 @@ int slsDetectorUsers::setReceiverFramesPerFile(int f, int detPos) {
|
||||
return detector.setReceiverFramesPerFile(f, detPos);
|
||||
}
|
||||
|
||||
std::string slsDetectorUsers::setAdditionalJsonParameter(const std::string& key, const std::string& value, int detPos) {
|
||||
return detector.setAdditionalJsonParameter(key, value, detPos);
|
||||
int slsDetectorUsers::setDetectorMinMaxEnergyThreshold(const int index, int v, int detPos) {
|
||||
return detector.setDetectorMinMaxEnergyThreshold(index, v, detPos);
|
||||
}
|
||||
|
||||
std::string slsDetectorUsers::getAdditionalJsonParameter(const std::string& key, int detPos) {
|
||||
return detector.getAdditionalJsonParameter(key, detPos);
|
||||
int slsDetectorUsers::setFrameMode(int value, int detPos) {
|
||||
return detector.setFrameMode(slsDetectorDefs::frameModeType(value), detPos);
|
||||
}
|
||||
|
||||
int slsDetectorUsers::setDetectorMode(int value, int detPos) {
|
||||
return detector.setDetectorMode(slsDetectorDefs::detectorModeType(value), detPos);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
|
||||
CALLBACKS & COMMAND LINE PARSING
|
||||
|
@ -769,24 +769,34 @@ public:
|
||||
*/
|
||||
int setReceiverFramesPerFile(int f = -1, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Sets the value for the additional json header parameter if found, else append it
|
||||
* @param key additional json header parameter
|
||||
* @param value additional json header parameter value (cannot be empty)
|
||||
/**
|
||||
* Sets the detector minimum/maximum energy threshold in processor (for Moench only)
|
||||
* @param index 0 for emin, antyhing else for emax
|
||||
* @param v value to set (-1 gets)
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns the additional json header parameter value,
|
||||
* empty if no parameter found in additional json header
|
||||
*/
|
||||
std::string setAdditionalJsonParameter(const std::string& key, const std::string& value, int detPos = -1);
|
||||
* @returns detector minimum/maximum energy threshold
|
||||
*/
|
||||
int setDetectorMinMaxEnergyThreshold(const int index, int v, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Sets the frame mode in processor (Moench only)
|
||||
* @param value frame mode value (-1 gets)
|
||||
* Options (slsDetectorDefs::frameModeType)
|
||||
* PEDESTAL, NEW_PEDESTAL, FLATFIELD, NEW_FLATFIELD
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns frame mode (-1 for not found or error in computing json parameter value)
|
||||
*/
|
||||
int setFrameMode(int value, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Returns the additional json header parameter value
|
||||
* @param key additional json header parameter
|
||||
* Sets the detector mode in processor (Moench only)
|
||||
* @param value detector mode value (-1 gets)
|
||||
* Options (slsDetectorDefs::detectorModeType)
|
||||
* COUNTING, INTERPOLATING, ANALOG
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns the additional json header parameter value,
|
||||
* empty if no parameter found in additional json header
|
||||
* @returns detector mode (-1 for not found or error in computing json parameter value)
|
||||
*/
|
||||
std::string getAdditionalJsonParameter(const std::string& key, int detPos = -1);
|
||||
int setDetectorMode(int value, int detPos = -1);
|
||||
|
||||
/************************************************************************
|
||||
|
||||
|
@ -557,6 +557,28 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* frame mode for processor
|
||||
*/
|
||||
enum frameModeType {
|
||||
GET_FRAME_MODE = -1,
|
||||
PEDESTAL, /** < pedestal */
|
||||
NEW_PEDESTAL, /** < new pedestal */
|
||||
FLATFIELD, /** < flatfield */
|
||||
NEW_FLATFIELD /** < new flatfield */
|
||||
};
|
||||
|
||||
/**
|
||||
* detector mode for processor
|
||||
*/
|
||||
enum detectorModeType {
|
||||
GET_DETECTOR_MODE = -1,
|
||||
COUNTING, /** < counting */
|
||||
INTERPOLATING, /** < interpolating */
|
||||
ANALOG /** < analog */
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
/** returns string from enabled/disabled
|
||||
\param b true or false
|
||||
@ -875,6 +897,64 @@ public:
|
||||
}}; \
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Loading…
x
Reference in New Issue
Block a user