mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
WIP
This commit is contained in:
@ -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){
|
||||
@ -468,11 +496,34 @@ inline defs::readoutMode StringTo(const std::string& s) {
|
||||
return defs::ANALOG_ONLY;
|
||||
if (s == "digital")
|
||||
return defs::DIGITAL_ONLY;
|
||||
if (s == "analog_digital")
|
||||
if (s == "analog_digital")
|
||||
return defs::ANALOG_AND_DIGITAL;
|
||||
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
|
||||
|
||||
|
Reference in New Issue
Block a user