diff --git a/python/src/detector.cpp b/python/src/detector.cpp index de5f0fcae..5fce855e6 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -1143,6 +1143,9 @@ void init_det(py::module &m) { .def("setGainCaps", (void (Detector::*)(int, sls::Positions)) & Detector::setGainCaps, py::arg(), py::arg() = Positions{}) + .def("getGainCaps", + (Result(Detector::*)(sls::Positions)) & Detector::getGainCaps, + py::arg() = Positions{}) .def("getNumberOfAnalogSamples", (Result(Detector::*)(sls::Positions) const) & Detector::getNumberOfAnalogSamples, diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index 107403778..85cab48bd 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/mythen3.c b/slsDetectorServers/mythen3DetectorServer/mythen3.c index b34d0ed82..7ea679da1 100644 --- a/slsDetectorServers/mythen3DetectorServer/mythen3.c +++ b/slsDetectorServers/mythen3DetectorServer/mythen3.c @@ -35,6 +35,44 @@ int getChipStatusRegister(){ return chipStatusRegister; } +int gainCapsToCsr(int caps){ + //Translates bit representation + int csr = 0; + if (!(caps & M3_C10pre)) + csr |= 1 << _CSR_C10pre; + if (caps & M3_C15sh) + csr |= 1 << CSR_C15sh; + if (caps & M3_C30sh) + csr |= 1 << CSR_C30sh; + if (caps & M3_C50sh) + csr |= 1 << CSR_C50sh; + if (caps & M3_C225ACsh) + csr |= 1 << CSR_C225ACsh; + if (!(caps & M3_C15pre)) + csr |= 1 << _CSR_C15pre; + + return csr; +} + +int csrToGainCaps(int csr){ + //Translates bit representation + int caps = 0; + if (!(csr & (1 << _CSR_C10pre))) + caps |= M3_C10pre; + if (csr & (1 << CSR_C15sh)) + caps |= M3_C15sh; + if (csr & (1 << CSR_C30sh)) + caps |= M3_C30sh; + if (csr & (1 << CSR_C50sh)) + caps |= M3_C50sh; + if (csr & (1 << CSR_C225ACsh)) + caps |= M3_C225ACsh; + if (!(csr & (1 << _CSR_C15pre))) + caps |= M3_C15pre; + + return caps; +} + patternParameters *setChipStatusRegisterPattern(int csr) { int iaddr=0; int nbits=18; diff --git a/slsDetectorServers/mythen3DetectorServer/mythen3.h b/slsDetectorServers/mythen3DetectorServer/mythen3.h index a0289441b..c27e7189e 100644 --- a/slsDetectorServers/mythen3DetectorServer/mythen3.h +++ b/slsDetectorServers/mythen3DetectorServer/mythen3.h @@ -37,23 +37,25 @@ #define CSR_invpol 4 #define CSR_dpulse 5 #define CSR_interp 6 -#define CSR_C10pre 7 //#default +#define _CSR_C10pre 7 //#default, negative polarity #define CSR_pumprobe 8 #define CSR_apulse 9 #define CSR_C15sh 10 #define CSR_C30sh 11 //#default #define CSR_C50sh 12 #define CSR_C225ACsh 13 // Connects 225fF SHAPER AC cap (1: 225 to shaper, 225 to GND. 0: 450 to shaper) -#define CSR_C15pre 14 +#define _CSR_C15pre 14 // negative polarity -#define CSR_default (1<= RECEIVER_ENUM_START) { @@ -8423,3 +8424,25 @@ int set_gain_caps(int file_des){ #endif return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } + +int get_gain_caps(int file_des){ + ret = OK; + memset(mess, 0, sizeof(mess)); + // int arg = 0; + + // if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + // return printSocketReadError(); + LOG(logINFO, ("Getting gain caps\n")); + + int retval = -1; + +#ifndef MYTHEN3D + functionNotImplemented(); +#else + if (Server_VerifyLock() == OK) { + retval = getGainCaps(); + LOG(logDEBUG1, ("Gain caps: %u\n", retval)); + } +#endif + return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); +} diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index 8f2ad55f9..db7b3e8d4 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -1314,6 +1314,8 @@ class Detector { void setGainCaps(int caps, Positions pos = {}); + Result getGainCaps(Positions pos = {}); + ///@{ /** @name CTB / Moench Specific */ diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index 16c451705..183c94490 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -1992,7 +1992,7 @@ std::string CmdProxy::GainCaps(int action){ if (!args.empty()) WrongNumberOfParameters(0); - auto tmp = det->getChipStatusRegister(); + auto tmp = det->getGainCaps(); sls::Result csr; for (auto val : tmp){ if (val) diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index ab2d44f84..89e506ac8 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1623,6 +1623,10 @@ void Detector::setGainCaps(int caps, Positions pos){ return pimpl->Parallel(&Module::setGainCaps, pos, caps); } +Result Detector::getGainCaps(Positions pos){ + return pimpl->Parallel(&Module::getGainCaps, pos); +} + // CTB/ Moench Specific diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 8582e15e5..7ce014571 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -2006,6 +2006,10 @@ void Module::setGainCaps(int caps){ sendToDetector(F_SET_GAIN_CAPS, caps); } +int Module::getGainCaps(){ + return sendToDetector(F_GET_GAIN_CAPS); +} + // CTB / Moench Specific int Module::getNumberOfAnalogSamples() const { return sendToDetector(F_GET_NUM_ANALOG_SAMPLES); diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index a61951d66..445bccc40 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -428,6 +428,7 @@ class Module : public virtual slsDetectorDefs { bool isMaster() const; int getChipStatusRegister() const; void setGainCaps(int caps); + int getGainCaps(); /************************************************** * * diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index 89acac836..bfc3eecdb 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -223,6 +223,7 @@ enum detFuncs { F_GET_MASTER, F_GET_CSR, F_SET_GAIN_CAPS, + F_GET_GAIN_CAPS, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 256, /**< detector function should not exceed this