diff --git a/RELEASE.txt b/RELEASE.txt index e70f9e10a..a485871af 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -32,6 +32,14 @@ This document describes the differences between 5.1.0 and 5.x.x releases. ------ 1. Aded settings and threshold features for Mythen3. + 2. Internal modification of acquire for Mythen3. + 3. Added getMaster functio for M3 + + + Mythen3 server + ----------------- + + 1. Setting timing to auto, sets timing to trigger for slaves 3. Resolved Issues diff --git a/python/src/detector.cpp b/python/src/detector.cpp index e8d4ee993..444248d8b 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -1132,6 +1132,10 @@ void init_det(py::module &m) { (Result>(Detector::*)(sls::Positions) const) & Detector::getGateDelayForAllGates, py::arg() = Positions{}) + .def("getMaster", + (Result(Detector::*)(sls::Positions) const) & + Detector::getMaster, + 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 927ce6428..23c541edb 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index d20c52354..43580109f 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -1522,8 +1522,16 @@ int setHighVoltage(int val) { return highvoltage; } +int isMaster(){ + return !(bus_r(0x18) >> 31); +} + /* parameters - timing */ void setTiming(enum timingMode arg) { + + if (!isMaster() && arg == AUTO_TIMING) + arg = TRIGGER_EXPOSURE; + uint32_t addr = CONFIG_REG; switch (arg) { case AUTO_TIMING: diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 8b241b725..84103f61f 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -352,6 +352,7 @@ void setTiming(enum timingMode arg); enum timingMode getTiming(); #ifdef MYTHEN3D void setInitialExtSignals(); +int isMaster(); #endif #if defined(GOTTHARDD) || defined(MYTHEN3D) void setExtSignal(int signalIndex, enum externalSignalFlag mode); diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index 0938a328c..62a947254 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -245,4 +245,5 @@ int set_default_dacs(int); int is_virtual(int); int get_pattern(int); int load_default_pattern(int); -int get_all_threshold_energy(int); \ No newline at end of file +int get_all_threshold_energy(int); +int get_master(int); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index eae2ecd4e..09da78b48 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -368,6 +368,7 @@ void function_table() { flist[F_GET_PATTERN] = &get_pattern; flist[F_LOAD_DEFAULT_PATTERN] = &load_default_pattern; flist[F_GET_ALL_THRESHOLD_ENERGY] = &get_all_threshold_energy; + flist[F_GET_MASTER] = &get_master; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { @@ -638,7 +639,9 @@ int set_timing_mode(int file_des) { } // get retval = getTiming(); + #ifndef MYTHEN3D validate((int)arg, (int)retval, "set timing mode", DEC); + #endif LOG(logDEBUG1, ("Timing Mode: %d\n", retval)); return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); @@ -8365,3 +8368,18 @@ int get_all_threshold_energy(int file_des) { #endif return Server_SendResult(file_des, INT32, retvals, sizeof(retvals)); } + +int get_master(int file_des){ + ret = OK; + memset(mess, 0, sizeof(mess)); + int retval = -1; + + LOG(logDEBUG1, ("Getting master\n")); + +#ifndef MYTHEN3D + functionNotImplemented(); +#else + retval = isMaster(); +#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 bf4a64107..105d95dee 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -1305,6 +1305,9 @@ class Detector { /** [Mythen3] gate delay for all gates in auto or trigger timing mode * (internal gating). Gate index: 0-2, -1 for all */ Result> getGateDelayForAllGates(Positions pos = {}) const; + + Result getMaster(Positions pos = {}) const; + ///@{ /** @name CTB / Moench Specific */ diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 8cf4584e8..1d833a0e4 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -674,7 +674,23 @@ void Detector::startReceiver() { pimpl->Parallel(&Module::startReceiver, {}); } void Detector::stopReceiver() { pimpl->Parallel(&Module::stopReceiver, {}); } void Detector::startDetector() { - pimpl->Parallel(&Module::startAcquisition, {}); + auto detector_type = getDetectorType().squash(); + if (detector_type == defs::MYTHEN3){ + auto is_master = getMaster(); + std::vector master; + std::vector slaves; + for(int i=0; iParallel(&Module::startAcquisition, slaves); + pimpl->Parallel(&Module::startAcquisition, master); + }else{ + pimpl->Parallel(&Module::startAcquisition, {}); + } + } void Detector::startDetectorReadout() { @@ -717,6 +733,9 @@ Result Detector::getScan(Positions pos) const { } void Detector::setScan(const defs::scanParameters t) { + if(getDetectorType().squash() == defs::MYTHEN3 && size()>1 && t.enable != 0){ + throw DetectorError("Scan is only allowed for single module Mythen 3 because of synchronization"); + } pimpl->Parallel(&Module::setScan, {}, t); } @@ -1592,6 +1611,11 @@ Detector::getGateDelayForAllGates(Positions pos) const { return pimpl->Parallel(&Module::getGateDelayForAllGates, pos); } +Result Detector::getMaster(Positions pos) const{ + return pimpl->Parallel(&Module::isMaster, pos); +} + + // CTB/ Moench Specific Result Detector::getNumberOfAnalogSamples(Positions pos) const { diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index 925d95106..188b53167 100644 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -1056,11 +1056,15 @@ void DetectorImpl::registerDataCallback(void (*userCallback)(detectorData *, } int DetectorImpl::acquire() { + // ensure acquire isnt started multiple times by same client if (!isAcquireReady()) { return FAIL; } + // We need this to handle Mythen3 synchronization + auto detector_type = Parallel(&Module::getDetectorType, {}).squash(); + try { struct timespec begin, end; clock_gettime(CLOCK_REALTIME, &begin); @@ -1088,7 +1092,25 @@ int DetectorImpl::acquire() { // start and read all try { - Parallel(&Module::startAndReadAll, {}); + if(detector_type == defs::MYTHEN3 && detectors.size() > 1){ + //Multi module mythen + std::vector master; + std::vector slaves; + auto is_master = Parallel(&Module::isMaster, {}); + slaves.reserve(detectors.size()-1); //check this one!! + for (size_t i = 0; i Module::getGateDelayForAllGates() const { return sendToDetector>(F_GET_GATE_DELAY_ALL_GATES); } +bool Module::isMaster() const{ + return sendToDetector(F_GET_MASTER); +} + // 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 e8bd0f48f..a1c52d0f7 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -425,6 +425,7 @@ class Module : public virtual slsDetectorDefs { int64_t getGateDelay(int gateIndex) const; void setGateDelay(int gateIndex, int64_t value); std::array getGateDelayForAllGates() const; + bool isMaster() const; /************************************************** * * diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index d0f50f696..9abb18d7f 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -220,6 +220,7 @@ enum detFuncs { F_GET_PATTERN, F_LOAD_DEFAULT_PATTERN, F_GET_ALL_THRESHOLD_ENERGY, + F_GET_MASTER, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 256, /**< detector function should not exceed this @@ -546,6 +547,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_GET_PATTERN: return "F_GET_PATTERN"; case F_LOAD_DEFAULT_PATTERN: return "F_LOAD_DEFAULT_PATTERN"; case F_GET_ALL_THRESHOLD_ENERGY: return "F_GET_ALL_THRESHOLD_ENERGY"; + case F_GET_MASTER: return "F_GET_MASTER"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";