From 8e49a114dbbe7ecb8094a2a3e5bd29c470872ed1 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 8 Sep 2020 12:34:56 +0200 Subject: [PATCH 1/3] moench: removed api that goes only to processor (future: one has to use rX_jsonaddheader or rx_jsonpara to set key and values) --- slsDetectorSoftware/include/Detector.h | 25 +-------- slsDetectorSoftware/src/CmdProxy.cpp | 46 ---------------- slsDetectorSoftware/src/CmdProxy.h | 16 ------ slsDetectorSoftware/src/Detector.cpp | 65 ----------------------- slsDetectorSoftware/src/Module.cpp | 32 ----------- slsSupportLib/include/ToString.h | 4 -- slsSupportLib/include/sls_detector_defs.h | 10 ---- slsSupportLib/src/ToString.cpp | 50 ----------------- 8 files changed, 1 insertion(+), 247 deletions(-) diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 74701b48c..24a9b17e3 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -1396,7 +1396,7 @@ class Detector { /************************************************** * * - * Moench * + * Moench specific * * * * ************************************************/ @@ -1423,29 +1423,6 @@ class Detector { const std::string &value, Positions pos = {}); - /** [Moench] TODO! How do we do this best??? Can be refactored to something - * else? Use a generic zmq message passing system... - * For now limiting to all detectors working the same*/ - /** [Moench: -1 if not found or cannot convert to int] */ - Result getDetectorMinMaxEnergyThreshold(const bool isEmax, - Positions pos = {}) const; - - /** [Moench] */ - void setDetectorMinMaxEnergyThreshold(const bool isEmax, const int value, - Positions pos = {}); - - /** [Moench: -1 if unknown mode] */ - Result getFrameMode(Positions pos = {}) const; - - /** [Moench] */ - void setFrameMode(defs::frameModeType value, Positions pos = {}); - - /** [Moench: -1 if unknown mode] */ - Result getDetectorMode(Positions pos = {}) const; - - /** [Moench] */ - void setDetectorMode(defs::detectorModeType value, Positions pos = {}); - /************************************************** * * * Advanced * diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index 9e83a552f..63c51fc90 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -2389,52 +2389,6 @@ std::string CmdProxy::JsonParameter(int action) { return os.str(); } -std::string CmdProxy::MinMaxEnergyThreshold(int action) { - std::ostringstream os; - os << cmd << ' '; - if (action == defs::HELP_ACTION) { - if (cmd == "emin") { - os << "[n_value]\n\t[Moench] Minimum energy threshold (soft " - "setting) for processor." - << '\n'; - } else if (cmd == "emax") { - os << "[n_value]\n\t[Moench] Maximum energy threshold (soft " - "setting) for processor." - << '\n'; - } else { - throw sls::RuntimeError( - "Unknown command, use list to list all commands"); - } - } else { - bool emax = false; - if (cmd == "emin") { - emax = false; - } else if (cmd == "emax") { - emax = true; - } else { - throw sls::RuntimeError( - "Unknown command, use list to list all commands"); - } - if (action == defs::GET_ACTION) { - if (!args.empty()) { - WrongNumberOfParameters(0); - } - auto t = det->getDetectorMinMaxEnergyThreshold(emax, {det_id}); - os << OutString(t) << '\n'; - } else if (action == defs::PUT_ACTION) { - if (args.size() != 1) { - WrongNumberOfParameters(1); - } - det->setDetectorMinMaxEnergyThreshold(emax, StringTo(args[0]), - {det_id}); - os << args.front() << '\n'; - } else { - throw sls::RuntimeError("Unknown action"); - } - } - return os.str(); -} - /* Advanced */ std::string CmdProxy::ProgramFpga(int action) { diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 20874fcc0..0f69c8a31 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -971,10 +971,6 @@ class CmdProxy { /* Moench */ {"rx_jsonaddheader", &CmdProxy::AdditionalJsonHeader}, {"rx_jsonpara", &CmdProxy::JsonParameter}, - {"emin", &CmdProxy::MinMaxEnergyThreshold}, - {"emax", &CmdProxy::MinMaxEnergyThreshold}, - {"framemode", &CmdProxy::framemode}, - {"detectormode", &CmdProxy::detectormode}, /* Advanced */ {"programfpga", &CmdProxy::ProgramFpga}, @@ -1091,7 +1087,6 @@ class CmdProxy { /* Moench */ std::string AdditionalJsonHeader(int action); std::string JsonParameter(int action); - std::string MinMaxEnergyThreshold(int action); /* Advanced */ std::string ProgramFpga(int action); std::string CopyDetectorServer(int action); @@ -2209,17 +2204,6 @@ class CmdProxy { "\n\t[Mythen3] Starts Pattern"); /* Moench */ - - INTEGER_COMMAND(framemode, getFrameMode, setFrameMode, - sls::StringTo, - "[pedestal|newpedestal|flatfield|newflatfield]\n\t[Moench] " - "Frame mode (soft setting) in processor."); - - INTEGER_COMMAND(detectormode, getDetectorMode, setDetectorMode, - sls::StringTo, - "[counting|interpolating|analog]\n\t[Moench] Detector mode " - "(soft setting) in processor."); - /* Advanced */ EXECUTE_SET_COMMAND(resetfpga, resetFPGA, diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 2e17f2ff7..9de9e7e05 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1840,71 +1840,6 @@ void Detector::setAdditionalJsonParameter(const std::string &key, pimpl->Parallel(&Module::setAdditionalJsonParameter, pos, key, value); } -Result Detector::getDetectorMinMaxEnergyThreshold(const bool isEmax, - Positions pos) const { - auto res = pimpl->Parallel(&Module::getAdditionalJsonParameter, pos, - isEmax ? "emax" : "emin"); - Result intResult(res.size()); - try { - for (unsigned int i = 0; i < res.size(); ++i) { - intResult[i] = stoi(res[i]); - } - } catch (...) { - throw RuntimeError( - "Cannot find or convert emin/emax string to integer"); - } - return intResult; -} - -void Detector::setDetectorMinMaxEnergyThreshold(const bool isEmax, - const int value, - Positions pos) { - pimpl->Parallel(&Module::setAdditionalJsonParameter, pos, - isEmax ? "emax" : "emin", std::to_string(value)); -} - -Result Detector::getFrameMode(Positions pos) const { - auto res = - pimpl->Parallel(&Module::getAdditionalJsonParameter, pos, "frameMode"); - Result intResult(res.size()); - try { - for (unsigned int i = 0; i < res.size(); ++i) { - intResult[i] = - sls::StringTo(res[i]); - } - } catch (...) { - throw RuntimeError( - "Cannot find or convert frameMode string to integer"); - } - return intResult; -} - -void Detector::setFrameMode(defs::frameModeType value, Positions pos) { - pimpl->Parallel(&Module::setAdditionalJsonParameter, pos, "frameMode", - sls::ToString(value)); -} - -Result Detector::getDetectorMode(Positions pos) const { - auto res = pimpl->Parallel(&Module::getAdditionalJsonParameter, pos, - "detectorMode"); - Result intResult(res.size()); - try { - for (unsigned int i = 0; i < res.size(); ++i) { - intResult[i] = - sls::StringTo(res[i]); - } - } catch (...) { - throw RuntimeError( - "Cannot find or convert detectorMode string to integer"); - } - return intResult; -} - -void Detector::setDetectorMode(defs::detectorModeType value, Positions pos) { - pimpl->Parallel(&Module::setAdditionalJsonParameter, pos, "detectorMode", - sls::ToString(value)); -} - // Advanced void Detector::programFPGA(const std::string &fname, Positions pos) { diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 92fc0dce3..e24d39e53 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -792,13 +792,6 @@ void Module::setReceiverHostname(const std::string &receiverIP) { shm()->numUDPInterfaces = retval.udpInterfaces; - if (shm()->myDetectorType == MOENCH) { - setAdditionalJsonParameter("adcmask_1g", - std::to_string(retval.adcMask)); - setAdditionalJsonParameter("adcmask_10g", - std::to_string(retval.adc10gMask)); - } - // to use rx_hostname if empty and also update client zmqip updateReceiverStreamingIP(); } @@ -1073,19 +1066,6 @@ void Module::setSubDeadTime(int64_t value) { } int Module::getThresholdEnergy() const { - // moench - get threshold energy from json header - if (shm()->myDetectorType == MOENCH) { - getAdditionalJsonHeader(); - std::string result = getAdditionalJsonParameter("threshold"); - // convert to integer - try { - return std::stoi(result); - } - // not found or cannot scan integer - catch (...) { - return -1; - } - } return sendToDetector(F_GET_THRESHOLD_ENERGY); } @@ -1097,10 +1077,6 @@ void Module::setThresholdEnergy(int e_eV, detectorSettings isettings, if (shm()->useReceiverFlag) { sendToReceiver(F_RECEIVER_SET_THRESHOLD, e_eV, nullptr); } - } - // moench - send threshold energy to processor - else if (shm()->myDetectorType == MOENCH) { - setAdditionalJsonParameter("threshold", std::to_string(e_eV)); } else { throw RuntimeError( "Set threshold energy not implemented for this detector"); @@ -1789,10 +1765,6 @@ void Module::setADCEnableMask(uint32_t mask) { // update #nchan, as it depends on #samples, adcmask, updateNumberOfChannels(); - // send to processor - if (shm()->myDetectorType == MOENCH) - setAdditionalJsonParameter("adcmask_1g", std::to_string(mask)); - if (shm()->useReceiverFlag) { sendToReceiver(F_RECEIVER_SET_ADC_MASK, mask); } @@ -1806,10 +1778,6 @@ void Module::setTenGigaADCEnableMask(uint32_t mask) { sendToDetector(F_SET_ADC_ENABLE_MASK_10G, mask, nullptr); updateNumberOfChannels(); // depends on samples and adcmask - // send to processor - if (shm()->myDetectorType == MOENCH) - setAdditionalJsonParameter("adcmask_10g", std::to_string(mask)); - if (shm()->useReceiverFlag) { sendToReceiver(F_RECEIVER_SET_ADC_MASK_10G, mask); } diff --git a/slsSupportLib/include/ToString.h b/slsSupportLib/include/ToString.h index fb2c2747f..e3a179389 100644 --- a/slsSupportLib/include/ToString.h +++ b/slsSupportLib/include/ToString.h @@ -32,8 +32,6 @@ std::string ToString(const defs::frameDiscardPolicy s); std::string ToString(const defs::fileFormat s); std::string ToString(const defs::externalSignalFlag s); std::string ToString(const defs::readoutMode s); -std::string ToString(const defs::frameModeType s); -std::string ToString(const defs::detectorModeType s); std::string ToString(const defs::dacIndex s); std::string ToString(const std::vector &vec); std::string ToString(const defs::burstMode s); @@ -283,8 +281,6 @@ template <> defs::frameDiscardPolicy StringTo(const std::string &s); template <> defs::fileFormat StringTo(const std::string &s); template <> defs::externalSignalFlag StringTo(const std::string &s); template <> defs::readoutMode StringTo(const std::string &s); -template <> defs::frameModeType StringTo(const std::string &s); -template <> defs::detectorModeType StringTo(const std::string &s); template <> defs::dacIndex StringTo(const std::string &s); template <> defs::burstMode StringTo(const std::string &s); template <> defs::timingSourceType StringTo(const std::string &s); diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h index 2fa9919fa..fa0178177 100644 --- a/slsSupportLib/include/sls_detector_defs.h +++ b/slsSupportLib/include/sls_detector_defs.h @@ -377,16 +377,6 @@ typedef struct { /** hierarchy in multi-detector structure, if any */ enum masterFlags { NO_MASTER, IS_MASTER, IS_SLAVE }; - /** - * frame mode for processor - */ - enum frameModeType { PEDESTAL, NEW_PEDESTAL, FLATFIELD, NEW_FLATFIELD }; - - /** - * detector mode for processor - */ - enum detectorModeType { COUNTING, INTERPOLATING, ANALOG }; - /** * burst mode for gotthard2 */ diff --git a/slsSupportLib/src/ToString.cpp b/slsSupportLib/src/ToString.cpp index a69097365..c0ea67752 100644 --- a/slsSupportLib/src/ToString.cpp +++ b/slsSupportLib/src/ToString.cpp @@ -325,34 +325,6 @@ std::string ToString(const defs::readoutMode s) { } } -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"); - } -} - -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"); - } -} - std::string ToString(const defs::dacIndex s) { switch (s) { case defs::DAC_0: @@ -713,28 +685,6 @@ template <> defs::readoutMode StringTo(const std::string &s) { throw sls::RuntimeError("Unknown readout mode " + s); } -template <> 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 <> 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); -} - template <> defs::dacIndex StringTo(const std::string &s) { if (s == "dac 0") return defs::DAC_0; From 82e978e901ae8a29dd7134a350ec7411c2e73c10 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 9 Sep 2020 13:47:54 +0200 Subject: [PATCH 2/3] WIP --- slsSupportLib/include/versionAPI.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h index 4ead8bcae..7503eb385 100644 --- a/slsSupportLib/include/versionAPI.h +++ b/slsSupportLib/include/versionAPI.h @@ -9,5 +9,5 @@ #define APIJUNGFRAU 0x200909 #define APIMOENCH 0x200909 #define APIEIGER 0x200909 - #define APIMYTHEN3 0x200909 + From a0f9c6fe8c2a252fe83462ce5af3d8fbc377b413 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Wed, 9 Sep 2020 15:15:36 +0200 Subject: [PATCH 3/3] updated python API --- python/src/detector.cpp | 41 ++++++++--------------------------------- python/src/enums.cpp | 14 -------------- 2 files changed, 8 insertions(+), 47 deletions(-) diff --git a/python/src/detector.cpp b/python/src/detector.cpp index 64548f808..d3e61c998 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -346,6 +346,14 @@ void init_det(py::module &m) { sls::Positions)) & Detector::setExternalSignalFlags, py::arg(), py::arg(), py::arg() = Positions{}) + .def("getParallelMode", + (Result(Detector::*)(sls::Positions) const) & + Detector::getParallelMode, + py::arg() = Positions{}) + .def("setParallelMode", + (void (Detector::*)(bool, sls::Positions)) & + Detector::setParallelMode, + py::arg(), py::arg() = Positions{}) .def("acquire", (void (Detector::*)()) & Detector::acquire) .def("clearAcquiringFlag", (void (Detector::*)()) & Detector::clearAcquiringFlag) @@ -779,14 +787,6 @@ void init_det(py::module &m) { (void (Detector::*)(const std::string &, sls::Positions)) & Detector::setSettingsPath, py::arg(), py::arg() = Positions{}) - .def("getParallelMode", - (Result(Detector::*)(sls::Positions) const) & - Detector::getParallelMode, - py::arg() = Positions{}) - .def("setParallelMode", - (void (Detector::*)(bool, sls::Positions)) & - Detector::setParallelMode, - py::arg(), py::arg() = Positions{}) .def("getOverFlowMode", (Result(Detector::*)(sls::Positions) const) & Detector::getOverFlowMode, @@ -1344,31 +1344,6 @@ void init_det(py::module &m) { sls::Positions)) & Detector::setAdditionalJsonParameter, py::arg(), py::arg(), py::arg() = Positions{}) - .def("getDetectorMinMaxEnergyThreshold", - (Result(Detector::*)(const bool, sls::Positions) const) & - Detector::getDetectorMinMaxEnergyThreshold, - py::arg(), py::arg() = Positions{}) - .def("setDetectorMinMaxEnergyThreshold", - (void (Detector::*)(const bool, const int, sls::Positions)) & - Detector::setDetectorMinMaxEnergyThreshold, - py::arg(), py::arg(), py::arg() = Positions{}) - .def("getFrameMode", - (Result(Detector::*)(sls::Positions) const) & - Detector::getFrameMode, - py::arg() = Positions{}) - .def("setFrameMode", - (void (Detector::*)(defs::frameModeType, sls::Positions)) & - Detector::setFrameMode, - py::arg(), py::arg() = Positions{}) - .def("getDetectorMode", - (Result(Detector::*)(sls::Positions) - const) & - Detector::getDetectorMode, - py::arg() = Positions{}) - .def("setDetectorMode", - (void (Detector::*)(defs::detectorModeType, sls::Positions)) & - Detector::setDetectorMode, - py::arg(), py::arg() = Positions{}) .def("programFPGA", (void (Detector::*)(const std::string &, sls::Positions)) & Detector::programFPGA, diff --git a/python/src/enums.cpp b/python/src/enums.cpp index aa32559b8..2c854eca0 100644 --- a/python/src/enums.cpp +++ b/python/src/enums.cpp @@ -259,20 +259,6 @@ void init_enums(py::module &m) { .value("IS_SLAVE", slsDetectorDefs::masterFlags::IS_SLAVE) .export_values(); - py::enum_(Defs, "frameModeType") - .value("PEDESTAL", slsDetectorDefs::frameModeType::PEDESTAL) - .value("NEW_PEDESTAL", slsDetectorDefs::frameModeType::NEW_PEDESTAL) - .value("FLATFIELD", slsDetectorDefs::frameModeType::FLATFIELD) - .value("NEW_FLATFIELD", slsDetectorDefs::frameModeType::NEW_FLATFIELD) - .export_values(); - - py::enum_(Defs, "detectorModeType") - .value("COUNTING", slsDetectorDefs::detectorModeType::COUNTING) - .value("INTERPOLATING", - slsDetectorDefs::detectorModeType::INTERPOLATING) - .value("ANALOG", slsDetectorDefs::detectorModeType::ANALOG) - .export_values(); - py::enum_(Defs, "burstMode") .value("BURST_INTERNAL", slsDetectorDefs::burstMode::BURST_INTERNAL) .value("BURST_EXTERNAL", slsDetectorDefs::burstMode::BURST_EXTERNAL)