mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-11-14 14:33:52 +01:00
cli and test side wip
This commit is contained in:
1 parent
6df1aba669
commit
86ff8e7e79
13 files changed
+195
-4
No files matched your search
@@ -46,6 +46,7 @@ std::string ToString(const defs::gainMode s);
|
||||
std::string ToString(const defs::polarity s);
|
||||
std::string ToString(const defs::timingInfoDecoder s);
|
||||
std::string ToString(const defs::collectionMode s);
|
||||
std::string ToString(const defs::operationMode s);
|
||||
|
||||
std::string ToString(bool value);
|
||||
|
||||
@@ -59,6 +60,9 @@ std::ostream &operator<<(std::ostream &os,
|
||||
std::string ToString(const slsDetectorDefs::scanParameters &r);
|
||||
std::ostream &operator<<(std::ostream &os,
|
||||
const slsDetectorDefs::scanParameters &r);
|
||||
std::string ToString(const slsDetectorDefs::hdrParameters &r);
|
||||
std::ostream &operator<<(std::ostream &os,
|
||||
const slsDetectorDefs::hdrParameters &r);
|
||||
std::string ToString(const slsDetectorDefs::currentSrcParameters &r);
|
||||
std::ostream &operator<<(std::ostream &os,
|
||||
const slsDetectorDefs::currentSrcParameters &r);
|
||||
@@ -324,6 +328,7 @@ template <> defs::gainMode StringTo(const std::string &s);
|
||||
template <> defs::polarity StringTo(const std::string &s);
|
||||
template <> defs::timingInfoDecoder StringTo(const std::string &s);
|
||||
template <> defs::collectionMode StringTo(const std::string &s);
|
||||
template <> defs::operationMode StringTo(const std::string &s);
|
||||
|
||||
template <> uint8_t StringTo(const std::string &s);
|
||||
template <> uint16_t StringTo(const std::string &s);
|
||||
|
||||
@@ -527,6 +527,7 @@ enum streamingInterface {
|
||||
enum polarity { POSITIVE, NEGATIVE };
|
||||
enum timingInfoDecoder { SWISSFEL, SHINE };
|
||||
enum collectionMode { HOLE, ELECTRON };
|
||||
enum operationMode {SYNCHROTRON, FEL}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -560,6 +561,20 @@ enum streamingInterface {
|
||||
}
|
||||
} __attribute__((packed));
|
||||
|
||||
/** hdr structure */
|
||||
struct hdrParameters {
|
||||
int enable;
|
||||
operationMode opMode;
|
||||
|
||||
/** disable hdr mode */
|
||||
hdrParameters() : enable(0), opMode(SYNCHROTRON) {}
|
||||
/** enable hdr mode */
|
||||
hdrParameters(operationMode mode) : enable(1), opMode(mode) {}
|
||||
constexpr bool operator==(const hdrParameters &other) const {
|
||||
return ((enable == other.enable) && (opMode == other.opMode));
|
||||
}
|
||||
} __attribute__((packed));
|
||||
|
||||
struct currentSrcParameters {
|
||||
int enable;
|
||||
int fix;
|
||||
|
||||
@@ -123,6 +123,24 @@ std::ostream &operator<<(std::ostream &os,
|
||||
return os << ToString(r);
|
||||
}
|
||||
|
||||
std::string ToString(const slsDetectorDefs::hdrParameters &r) {
|
||||
std::ostringstream oss;
|
||||
oss << '[';
|
||||
if (r.enable) {
|
||||
oss << "enabled" << " " << ToString(r.opMode) << std::endl;
|
||||
} else {
|
||||
oss << "disabled";
|
||||
}
|
||||
oss << ']';
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os,
|
||||
const slsDetectorDefs::hdrParameters &r) {
|
||||
return os << ToString(r);
|
||||
}
|
||||
|
||||
|
||||
std::string ToString(const slsDetectorDefs::currentSrcParameters &r) {
|
||||
std::ostringstream oss;
|
||||
if (r.fix < -1 || r.fix > 1 || r.normal < -1 || r.normal > 1) {
|
||||
@@ -694,6 +712,17 @@ std::string ToString(const defs::collectionMode s) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string ToString(const defs::operationMode s) {
|
||||
switch (s) {
|
||||
case defs::SYNCHROTRON:
|
||||
return std::string("synchrotron");
|
||||
case defs::FEL:
|
||||
return std::string("fel");
|
||||
default:
|
||||
return std::string("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
const std::string &ToString(const std::string &s) { return s; }
|
||||
|
||||
template <> defs::detectorType StringTo(const std::string &s) {
|
||||
@@ -1127,6 +1156,14 @@ template <> defs::collectionMode StringTo(const std::string &s) {
|
||||
throw RuntimeError("Unknown collection mode " + s);
|
||||
}
|
||||
|
||||
template <> defs::operationMode StringTo(const std::string &s) {
|
||||
if (s == "synchrotron")
|
||||
return defs::SYNCHROTRON;
|
||||
if (s == "fel")
|
||||
return defs::FEL;
|
||||
throw RuntimeError("Unknown operation mode " + s);
|
||||
}
|
||||
|
||||
template <> uint8_t StringTo(const std::string &s) {
|
||||
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
||||
int value = std::stoi(s, nullptr, base);
|
||||
|
||||
Reference in new issue
Block a user