diff --git a/python/scripts/compile_servers.py b/python/scripts/compile_servers.py index e3395a06f..88de03ce6 100644 --- a/python/scripts/compile_servers.py +++ b/python/scripts/compile_servers.py @@ -52,7 +52,7 @@ servers = [ # "eigerDetectorServer", # "jungfrauDetectorServer", "mythen3DetectorServer", -# "gotthard2DetectorServer", + "gotthard2DetectorServer", # "gotthardDetectorServer", # "ctbDetectorServer", # "moenchDetectorServer", diff --git a/python/slsdet/enums.py b/python/slsdet/enums.py index 98c16b14e..6c42c454b 100644 --- a/python/slsdet/enums.py +++ b/python/slsdet/enums.py @@ -14,4 +14,5 @@ clockIndex = _slsdet.slsDetectorDefs.clockIndex readoutMode = _slsdet.slsDetectorDefs.readoutMode masterFlags = _slsdet.slsDetectorDefs.masterFlags burstMode = _slsdet.slsDetectorDefs.burstMode -timingSourceType = _slsdet.slsDetectorDefs.timingSourceType \ No newline at end of file +timingSourceType = _slsdet.slsDetectorDefs.timingSourceType +M3_GainCaps = _slsdet.slsDetectorDefs.M3_GainCaps \ No newline at end of file diff --git a/python/src/detector.cpp b/python/src/detector.cpp index 2ac8a2ce2..de5f0fcae 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -1140,6 +1140,9 @@ void init_det(py::module &m) { (Result(Detector::*)(sls::Positions) const) & Detector::getChipStatusRegister, py::arg() = Positions{}) + .def("setGainCaps", + (void (Detector::*)(int, sls::Positions)) & Detector::setGainCaps, + py::arg(), py::arg() = Positions{}) .def("getNumberOfAnalogSamples", (Result(Detector::*)(sls::Positions) const) & Detector::getNumberOfAnalogSamples, diff --git a/python/src/enums.cpp b/python/src/enums.cpp index 92391065d..00c4ea876 100644 --- a/python/src/enums.cpp +++ b/python/src/enums.cpp @@ -277,4 +277,13 @@ void init_enums(py::module &m) { .value("TIMING_EXTERNAL", slsDetectorDefs::timingSourceType::TIMING_EXTERNAL) .export_values(); + + py::enum_(Defs, "M3_GainCaps") + .value("CSR_C10pre", slsDetectorDefs::M3_GainCaps::CSR_C10pre) + .value("CSR_C15sh", slsDetectorDefs::M3_GainCaps::CSR_C15sh) + .value("CSR_C30sh", slsDetectorDefs::M3_GainCaps::CSR_C30sh) + .value("CSR_C50sh", slsDetectorDefs::M3_GainCaps::CSR_C50sh) + .value("CSR_C225ACsh", slsDetectorDefs::M3_GainCaps::CSR_C225ACsh) + .value("CSR_C15pre", slsDetectorDefs::M3_GainCaps::CSR_C15pre) + .export_values(); } diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index 347bb9f7c..fbae13647 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 3da3cd92d..04f4d5979 100644 --- a/slsDetectorServers/mythen3DetectorServer/mythen3.c +++ b/slsDetectorServers/mythen3DetectorServer/mythen3.c @@ -35,6 +35,32 @@ int getChipStatusRegister(){ return chipStatusRegister; } +// int setGainCaps(int caps){ +// int csr = getChipStatusRegister(); + +// int gain_mask = 0; +// gain_mask |= 1 << CSR_C10pre; +// gain_mask |= 1 << CSR_C15sh; +// gain_mask |= 1 << CSR_C30sh; +// gain_mask |= 1 << CSR_C50sh; +// gain_mask |= 1 << CSR_C225ACsh; +// gain_mask |= 1 << CSR_C15pre; + +// LOG(logINFO, ("gain_mask: 0x%x\n", gain_mask)); +// LOG(logINFO, ("csr: 0x%x\n", csr)); +// csr &= ~gain_mask; //zero out the bits in the gain mask +// LOG(logINFO, ("csr: 0x%x\n", csr)); +// caps &= gain_mask; +// csr |= caps; + +// LOG(logINFO, ("csr: 0x%x\n", csr)); + +// //now comes the actual setting + + +// return 0; +// } + patternParameters *setChipStatusRegister(int csr) { int iaddr=0; int nbits=18; diff --git a/slsDetectorServers/mythen3DetectorServer/mythen3.h b/slsDetectorServers/mythen3DetectorServer/mythen3.h index 890fdd2c8..e2c7be76e 100644 --- a/slsDetectorServers/mythen3DetectorServer/mythen3.h +++ b/slsDetectorServers/mythen3DetectorServer/mythen3.h @@ -48,6 +48,9 @@ #define CSR_default (1<= RECEIVER_ENUM_START) { @@ -8405,3 +8406,38 @@ int get_csr(int file_des){ return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } +int set_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, ("Setting gain caps to: %u\n", arg)); + + int retval = -1; + +#ifndef MYTHEN3D + functionNotImplemented(); +#else + // only set + + if (Server_VerifyLock() == OK) { + // if (arg != 0 && arg != 1) { + // ret = FAIL; + // sprintf(mess, + // "Could not set gain caps. Invalid value %d. " + // "Options [0-1]\n", + // arg); + // LOG(logERROR, (mess)); + // } else { + setGainCaps(arg); + retval = getChipStatusRegister(); //TODO! fix + LOG(logDEBUG1, ("gain caps retval: %u\n", retval)); + // validate(arg, retval, " cds gain enable", DEC); + // } + } +#endif + // return Server_SendResult(file_des, INT32, NULL, 0); + return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); +} diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index 7c24ff055..8f2ad55f9 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -1312,6 +1312,8 @@ class Detector { //TODO! check if we really want to expose this !!!!! Result getChipStatusRegister(Positions pos = {}) const; + void setGainCaps(int caps, Positions pos = {}); + ///@{ /** @name CTB / Moench Specific */ diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index f09056444..ab2d44f84 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1619,6 +1619,10 @@ Result Detector::getChipStatusRegister(Positions pos) const{ return pimpl->Parallel(&Module::getChipStatusRegister, pos); } +void Detector::setGainCaps(int caps, Positions pos){ + return pimpl->Parallel(&Module::setGainCaps, pos, caps); +} + // CTB/ Moench Specific diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 69ac21e59..bb57e9509 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -2002,6 +2002,10 @@ int Module::getChipStatusRegister() const{ return sendToDetector(F_GET_CSR); } +void Module::setGainCaps(int caps){ + sendToDetector(F_SET_GAIN_CAPS, 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 8b3c6e842..a61951d66 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -427,6 +427,7 @@ class Module : public virtual slsDetectorDefs { std::array getGateDelayForAllGates() const; bool isMaster() const; int getChipStatusRegister() const; + void setGainCaps(int caps); /************************************************** * * diff --git a/slsSupportLib/include/sls/sls_detector_defs.h b/slsSupportLib/include/sls/sls_detector_defs.h index 3e2c4bbee..412c66e4a 100644 --- a/slsSupportLib/include/sls/sls_detector_defs.h +++ b/slsSupportLib/include/sls/sls_detector_defs.h @@ -394,6 +394,16 @@ typedef struct { */ enum timingSourceType { TIMING_INTERNAL, TIMING_EXTERNAL }; + //gain caps Mythen3 + enum M3_GainCaps { + CSR_C10pre= 1<<7, + CSR_C15sh = 1<<10, + CSR_C30sh = 1<<11, + CSR_C50sh = 1<<12, + CSR_C225ACsh = 1<<13, + CSR_C15pre = 1<<14, + }; + #ifdef __cplusplus /** scan structure */ @@ -625,6 +635,10 @@ typedef struct { #endif #ifdef __cplusplus + + + + // TODO! discuss this #include //hmm... but currently no way around namespace sls { diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index a99ac0e02..89acac836 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -222,6 +222,7 @@ enum detFuncs { F_GET_ALL_THRESHOLD_ENERGY, F_GET_MASTER, F_GET_CSR, + F_SET_GAIN_CAPS, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 256, /**< detector function should not exceed this