From 89edf58f41a96d50f232400978e58ca33c8b0e3c Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 23 Feb 2022 12:26:37 +0100 Subject: [PATCH] wip, setmaster --- python/src/detector.cpp | 6 ++++++ .../slsDetectorFunctionList.c | 17 +++++++++-------- .../slsDetectorFunctionList.c | 4 +++- .../src/slsDetectorServer_funcs.c | 5 +++-- slsDetectorSoftware/include/sls/Detector.h | 2 +- slsDetectorSoftware/src/CmdProxy.h | 6 ++++++ slsDetectorSoftware/src/Detector.cpp | 10 ++++++++-- 7 files changed, 36 insertions(+), 14 deletions(-) diff --git a/python/src/detector.cpp b/python/src/detector.cpp index f796c3cbe..010f63de9 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -173,6 +173,12 @@ void init_det(py::module &m) { .def("setFlipRows", (void (Detector::*)(bool, sls::Positions)) & Detector::setFlipRows, py::arg(), py::arg() = Positions{}) + .def("getMaster", + (Result(Detector::*)(sls::Positions) const) & + Detector::getMaster, + py::arg() = Positions{}) + .def("setMaster", (void (Detector::*)(bool, int)) & Detector::setMaster, + py::arg(), py::arg() = -1) .def("isVirtualDetectorServer", (Result(Detector::*)(sls::Positions) const) & Detector::isVirtualDetectorServer, diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index cc3cab7ca..8034dd14a 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -400,6 +400,7 @@ void setVirtualDefaultModuleConfigurations() { #else normal = 1; #endif +#endif } int updateModuleConfiguration() { @@ -420,7 +421,7 @@ int getModuleConfiguration(int *m, int *t, int *n) { #ifdef VIRTUAL *m = master; *t = top; - *n = nomal; + *n = normal; #else if (Beb_GetModuleConfiguration(&m, &t, &n) == FAIL) { initError = FAIL; @@ -553,13 +554,13 @@ int readConfigFile() { line); break; } - if (m != 0 && m != 1)) { - sprintf(initErrorMessage, - "Invalid master argument from on-board server " - "config file. Line:[%s].\n", - line); - break; - } + if (m != 0 && m != 1) { + sprintf(initErrorMessage, + "Invalid master argument from on-board server " + "config file. Line:[%s].\n", + line); + break; + } if (setMaster(m) == FAIL) { sprintf(initErrorMessage, "Could not set master from config file. Line:[%s].\n", diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 29c448f4a..b66d47751 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -1554,7 +1554,9 @@ int isMaster(int *retval) { void setTiming(enum timingMode arg) { - if (!isMaster() && arg == AUTO_TIMING) + int master = 0; + isMaster(&master); + if (master && arg == AUTO_TIMING) arg = TRIGGER_EXPOSURE; uint32_t addr = CONFIG_REG; diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index f01a0d91d..d155f86db 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -468,7 +468,7 @@ void function_table() { flist[F_UPDATE_DETECTOR_SERVER] = &update_detector_server; flist[F_GET_UPDATE_MODE] = &get_update_mode; flist[F_SET_UPDATE_MODE] = &set_update_mode; - flist[F_SET_MASTER]] = &set_master; + flist[F_SET_MASTER] = &set_master; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { @@ -8228,9 +8228,10 @@ int set_master(int file_des) { } else { ret = setMaster(arg); if (ret == FAIL) { - strcpy("Could not set master\n"); + strcpy(mess, "Could not set master\n"); LOG(logERROR, (mess)); } else { + int retval = 0; ret = isMaster(&retval); if (ret == FAIL) { strcpy(mess, "Could not get master\n"); diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index c734ca31d..f232412ba 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -196,7 +196,7 @@ class Detector { /** [Eiger][Mythen3][Gotthard1] via stop server **/ Result getMaster(Positions pos = {}) const; - /** [Eiger] Set master */ + /** [Eiger] Set half module to master and the others to slaves */ void setMaster(bool value, int pos); Result isVirtualDetectorServer(Positions pos = {}) const; diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 01ac7cc70..b7037092c 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -1282,6 +1282,12 @@ class CmdProxy { "interfaces must be set to 2. slsReceiver and slsDetectorGui " "does not handle."); + INTEGER_COMMAND_VEC_ID_GET( + master, getMaster, setMaster, StringTo, + "[0, 1]\n\t[Eiger] Sets half module to master and " + "others to slaves.\n\t\t [Gotthard][Mythen3][Eiger] " + "Gets if the current module/ half module is master."); + /* acquisition parameters */ INTEGER_COMMAND_SET_NOID_GET_ID( diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 66203a228..4416bf834 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -303,10 +303,16 @@ Result Detector::getMaster(Positions pos) const { } void Detector::setMaster(bool master, int pos) { - if (pos == -1)) { + if (pos == -1 && size() > 1) { throw RuntimeError("Master can be set only to a single module"); } - pimpl->Parallel(&Module::setMaster, {pos}, value); + // multi mod, set slaves first + if (master && size() > 1) { + pimpl->Parallel(&Module::setMaster, {}, false); + pimpl->Parallel(&Module::setMaster, {pos}, master); + } else { + pimpl->Parallel(&Module::setMaster, {pos}, master); + } } Result Detector::isVirtualDetectorServer(Positions pos) const {