diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index e06df6040..7551c2053 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -46,7 +46,6 @@ int on_dst = 0; int dst_requested[32] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -enum masterFlags masterMode = IS_SLAVE; int top = 0; int master = 0; int normal = 0; @@ -1413,6 +1412,8 @@ int setHighVoltage(int val) { /* parameters - timing, extsig */ +int isMaster() { return master; } + void setTiming(enum timingMode arg) { int ret = 0; switch (arg) { diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c index dec892c75..94be9a283 100644 --- a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c @@ -1201,6 +1201,8 @@ int setHighVoltage(int val) { /* parameters - timing, extsig */ +int isMaster() { return (masterflags == IS_MASTER ? 1 : 0); } + void setTiming(enum timingMode arg) { u_int32_t addr = EXT_SIGNAL_REG; switch (arg) { diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index aa7c0b88f..eba6e76ac 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -1393,12 +1393,13 @@ int setHighVoltage(int val) { return highvoltage; } +/* parameters - timing */ + int isMaster() { return !((bus_r(SYSTEM_STATUS_REG) & SYSTEM_STATUS_SLV_BRD_DTCT_MSK) >> SYSTEM_STATUS_SLV_BRD_DTCT_OFST); } -/* parameters - timing */ void setTiming(enum timingMode arg) { if (!isMaster() && arg == AUTO_TIMING) diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index ee230f66d..b065d3b8b 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -350,6 +350,9 @@ int getADC(enum ADCINDEX ind); int setHighVoltage(int val); // parameters - timing, extsig +#if defined(MYTHEN3D) || defined(EIGERD) || defined(GOTTHARDD) +int isMaster(); +#endif #ifdef GOTTHARD2D void updatingRegisters(); #endif @@ -357,7 +360,6 @@ void setTiming(enum timingMode arg); enum timingMode getTiming(); #ifdef MYTHEN3D void setInitialExtSignals(); -int isMaster(); int setGainCaps(int caps); int getGainCaps(); int setChipStatusRegister(int csr); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index b73621f6b..ec0b5fb2f 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -8381,7 +8381,7 @@ int get_master(int file_des) { LOG(logDEBUG1, ("Getting master\n")); -#ifndef MYTHEN3D +#if !defined(MYTHEN3D) && !defined(EIGERD) && !defined(GOTTHARDD) functionNotImplemented(); #else retval = isMaster(); diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index 434c391e4..bd9211881 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -488,12 +488,14 @@ class Detector { void stopReceiver(); /** Non blocking: start detector acquisition. Status changes to RUNNING or - * WAITING and automatically returns to idle at the end of acquisition. */ + * WAITING and automatically returns to idle at the end of acquisition. + [Mythen3] Master starts acquisition first */ void startDetector(); /** [Mythen3] Non blocking: start detector readout of counters in chip. * Status changes to TRANSMITTING and automatically returns to idle at the - * end of readout. */ + * end of readout. + [Eiger] Master stops acquisition last */ void startDetectorReadout(); /** Non blocking: Abort detector acquisition. Status changes to IDLE or @@ -1308,6 +1310,7 @@ class Detector { * (internal gating). Gate index: 0-2, -1 for all */ Result> getGateDelayForAllGates(Positions pos = {}) const; + /** [Eiger][Mythen3][Gotthard1] **/ Result getMaster(Positions pos = {}) const; // TODO! check if we really want to expose this !!!!! diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 4cc64e6bc..2acc30749 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -675,29 +675,51 @@ void Detector::stopReceiver() { pimpl->Parallel(&Module::stopReceiver, {}); } void Detector::startDetector() { auto detector_type = getDetectorType().squash(); - if (detector_type == defs::MYTHEN3 && size() > 1){ + if (detector_type == defs::MYTHEN3 && size() > 1) { auto is_master = getMaster(); - std::vector master; + int masterPosition = 0; std::vector slaves; - for(int i=0; iParallel(&Module::startAcquisition, slaves); - pimpl->Parallel(&Module::startAcquisition, master); - }else{ + pimpl->Parallel(&Module::startAcquisition, {masterPosition}); + } else { pimpl->Parallel(&Module::startAcquisition, {}); } - } void Detector::startDetectorReadout() { pimpl->Parallel(&Module::startReadout, {}); } -void Detector::stopDetector(Positions pos) { pimpl->Parallel(&Module::stopAcquisition, pos); } +void Detector::stopDetector(Positions pos) { + auto detector_type = getDetectorType().squash(); + if (detector_type == defs::EIGER && size() > 1) { + auto is_master = getMaster(); + int masterPosition = -1; + std::vector slaves; + for (int i = 0; i < size(); ++i) { + if (!pos.empty() && pos[0] != -1 && + std::find(pos.begin(), pos.end(), i) != pos.end()) { + continue; + } + if (is_master[i]) + masterPosition = i; + else + slaves.push_back(i); + } + pimpl->Parallel(&Module::stopAcquisition, slaves); + if (masterPosition != -1) { + pimpl->Parallel(&Module::stopAcquisition, {masterPosition}); + } + } else { + pimpl->Parallel(&Module::stopAcquisition, pos); + } +} Result Detector::getDetectorStatus(Positions pos) const { return pimpl->Parallel(&Module::getRunStatus, pos); @@ -733,8 +755,10 @@ 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"); + 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); } @@ -1611,23 +1635,22 @@ Detector::getGateDelayForAllGates(Positions pos) const { return pimpl->Parallel(&Module::getGateDelayForAllGates, pos); } -Result Detector::getMaster(Positions pos) const{ +Result Detector::getMaster(Positions pos) const { return pimpl->Parallel(&Module::isMaster, pos); } -Result Detector::getChipStatusRegister(Positions pos) const{ +Result Detector::getChipStatusRegister(Positions pos) const { return pimpl->Parallel(&Module::getChipStatusRegister, pos); } -void Detector::setGainCaps(int caps, Positions pos){ +void Detector::setGainCaps(int caps, Positions pos) { return pimpl->Parallel(&Module::setGainCaps, pos, caps); } -Result Detector::getGainCaps(Positions pos){ +Result Detector::getGainCaps(Positions pos) { return pimpl->Parallel(&Module::getGainCaps, pos); } - // CTB/ Moench Specific Result Detector::getNumberOfAnalogSamples(Positions pos) const {