From 8ba37e99a75f629b0f2662e4e57ed0a4b36464c1 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 21 Jul 2021 09:25:27 +0200 Subject: [PATCH] added enum left right top bottom --- .../slsDetectorFunctionList.c | 8 +-- .../include/slsDetectorFunctionList.h | 4 +- .../src/slsDetectorServer_funcs.c | 2 +- slsDetectorSoftware/include/sls/Detector.h | 4 +- slsDetectorSoftware/src/CmdProxy.cpp | 1 - slsDetectorSoftware/src/Detector.cpp | 4 +- .../tests/test-CmdProxy-eiger.cpp | 8 +-- slsReceiverSoftware/src/ClientInterface.cpp | 4 +- slsSupportLib/src/ToString.cpp | 63 ++++++++++--------- 9 files changed, 50 insertions(+), 48 deletions(-) diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index 77ff32952..22044b709 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -2051,15 +2051,11 @@ int getActivate(int *retval) { return OK; } -int setDataStream(enum portPositiion port, int enable) { +int setDataStream(enum portPosition port, int enable) { if (enable < 0) { LOG(logERROR, ("Invalid setDataStream enable argument: %d\n", enable)); return FAIL; } - if (left < 0) { - LOG(logERROR, ("Invalid setDataStream port argument: %d\n", port)); - return FAIL; - } #ifdef VIRTUAL if (port == LEFT) { eiger_virtual_left_datastream = enable; @@ -2074,7 +2070,7 @@ int setDataStream(enum portPositiion port, int enable) { return OK; } -int getDataStream(enum portPositiion port, int *retval) { +int getDataStream(enum portPosition port, int *retval) { #ifdef VIRTUAL if (port == LEFT) { *retval = eiger_virtual_left_datastream; diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 158ea22e2..e5bf46a84 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -474,8 +474,8 @@ int getAllTrimbits(); int getBebFPGATemp(); int setActivate(int enable); int getActivate(int *retval); -int getDataStream(enum portPositiion port, int *retval); -int setDataStream(enum portPositiion port, int enable); +int getDataStream(enum portPosition port, int *retval); +int setDataStream(enum portPosition port, int enable); // gotthard specific - adc phase #elif GOTTHARDD diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 1e17da82d..f745e5d65 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -8298,7 +8298,7 @@ int set_datastream(int file_des) { #else // only set if (Server_VerifyLock() == OK) { - enum portPosition port = static_cast(args[0]); + enum portPosition port = args[0]; int enable = args[1]; char msg[256]; memset(msg, 0, sizeof(msg)); diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index ec88034b3..b17aa2986 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -1062,12 +1062,12 @@ class Detector { void setQuad(const bool enable); /** [Eiger] */ - Result getDataStream(const portPosition port, + Result getDataStream(const defs::portPosition port, Positions pos = {}) const; /** [Eiger] enable or disable data streaming from left or right of detector */ - void setDataStream(const portPosition port, const bool enable, + void setDataStream(const defs::portPosition port, const bool enable, Positions pos = {}); ///@{ diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index e3da0c531..a14a4a58a 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -1593,7 +1593,6 @@ std::string CmdProxy::Quad(int action) { std::string CmdProxy::DataStream(int action) { std::ostringstream os; os << cmd << ' '; - bool left = true; if (action == defs::HELP_ACTION) { os << "[left|right] [0, 1]\n\t[Eiger] Enables or disables data " "streaming from left or/and right side of detector. 1 (enabled) " diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 1ed1426c2..67c9d84c3 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1369,12 +1369,12 @@ void Detector::setQuad(const bool enable) { pimpl->Parallel(&Module::setQuad, {}, enable); } -Result Detector::getDataStream(const portPosition port, +Result Detector::getDataStream(const defs::portPosition port, Positions pos) const { return pimpl->Parallel(&Module::getDataStream, pos, port); } -void Detector::setDataStream(const portPosition port, const bool enable, +void Detector::setDataStream(const defs::portPosition port, const bool enable, Positions pos) { pimpl->Parallel(&Module::setDataStream, pos, port, enable); } diff --git a/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp b/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp index 29249720c..d47c0a75b 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp @@ -655,8 +655,8 @@ TEST_CASE("datastream", "[.cmd]") { CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); if (det_type == defs::EIGER) { - auto prev_val_left = det.getDataStream(true); - auto prev_val_right = det.getDataStream(false); + auto prev_val_left = det.getDataStream(defs::LEFT); + auto prev_val_right = det.getDataStream(defs::RIGHT); // no "left" or "right" REQUIRE_THROWS(proxy.Call("datastream", {"1"}, -1, PUT)); { @@ -680,8 +680,8 @@ TEST_CASE("datastream", "[.cmd]") { REQUIRE(oss.str() == "datastream right 1\n"); } for (int i = 0; i != det.size(); ++i) { - det.setDataStream(prev_val_left[i], {i}); - det.setDataStream(prev_val_right[i], {i}); + det.setDataStream(defs::LEFT, prev_val_left[i], {i}); + det.setDataStream(defs::RIGHT, prev_val_right[i], {i}); } } else { REQUIRE_THROWS(proxy.Call("datastream", {}, -1, GET)); diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index 71343797f..d882ba1d8 100644 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -403,8 +403,8 @@ int ClientInterface::setup_receiver(Interface &socket) { impl()->setSubPeriod(std::chrono::nanoseconds(arg.subExpTimeNs) + std::chrono::nanoseconds(arg.subDeadTimeNs)); impl()->setActivate(static_cast(arg.activate)); - impl()->setDetectorDataStream(1, arg.dataStreamLeft); - impl()->setDetectorDataStream(0, arg.dataStreamRight); + impl()->setDetectorDataStream(LEFT, arg.dataStreamLeft); + impl()->setDetectorDataStream(RIGHT, arg.dataStreamRight); try { impl()->setQuad(arg.quad == 0 ? false : true); } catch (const RuntimeError &e) { diff --git a/slsSupportLib/src/ToString.cpp b/slsSupportLib/src/ToString.cpp index 4dc25a1ce..211f31f2d 100644 --- a/slsSupportLib/src/ToString.cpp +++ b/slsSupportLib/src/ToString.cpp @@ -521,6 +521,25 @@ std::string ToString(const defs::timingSourceType s) { } } +std::string ToString(defs::M3_GainCaps s) { + std::ostringstream os; + if (s & defs::M3_C10pre) + os << "C10pre, "; + if (s & defs::M3_C15sh) + os << "C15sh, "; + if (s & defs::M3_C30sh) + os << "C30sh, "; + if (s & defs::M3_C50sh) + os << "C50sh, "; + if (s & defs::M3_C225ACsh) + os << "C225ACsh, "; + if (s & defs::M3_C15pre) + os << "C15pre, "; + auto rs = os.str(); + rs.erase(rs.end() - 2); + return rs; +} + std::string ToString(const defs::portPosition s) { switch (s) { case defs::LEFT: @@ -876,6 +895,22 @@ template <> defs::timingSourceType StringTo(const std::string &s) { throw sls::RuntimeError("Unknown timing source type " + s); } +template <> defs::M3_GainCaps StringTo(const std::string &s) { + if (s == "C10pre") + return defs::M3_C10pre; + if (s == "C15sh") + return defs::M3_C15sh; + if (s == "C30sh") + return defs::M3_C30sh; + if (s == "C50sh") + return defs::M3_C50sh; + if (s == "C225ACsh") + return defs::M3_C225ACsh; + if (s == "C15pre") + return defs::M3_C15pre; + throw sls::RuntimeError("Unknown gain cap " + s); +} + template <> defs::portPosition StringTo(const std::string &s) { if (s == "left") return defs::LEFT; @@ -888,34 +923,6 @@ template <> defs::portPosition StringTo(const std::string &s) { throw sls::RuntimeError("Unknown port position " + s); } -template <> defs::timingSourceType StringTo(const std::string &s) { - if (s == "internal") - return defs::TIMING_INTERNAL; - if (s == "external") - return defs::TIMING_EXTERNAL; - throw sls::RuntimeError("Unknown timing source type " + s); -} - -std::string ToString(defs::M3_GainCaps s){ - std::ostringstream os; - if (s & defs::M3_C10pre) - os << "C10pre, "; - if (s & defs::M3_C15sh) - os << "C15sh, "; - if (s & defs::M3_C30sh) - os << "C30sh, "; - if (s & defs::M3_C50sh) - os << "C50sh, "; - if (s & defs::M3_C225ACsh) - os << "C225ACsh, "; - if (s & defs::M3_C15pre) - os << "C15pre, "; - auto rs = os.str(); - rs.erase(rs.end()-2); - return rs; - -} - template <> uint32_t StringTo(const std::string &s) { int base = s.find("0x") != std::string::npos ? 16 : 10; return std::stoul(s, nullptr, base);