From 0129c2c686dc306d721f36d342a1813565f3f235 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil <33750417+thattil@users.noreply.github.com> Date: Tue, 10 May 2022 15:23:39 +0200 Subject: [PATCH] M3: master starts twice (non blocking) part 2 (#445) * slaves and master vectors empty means all positions included: fixing double acquisition in masters * debug print out --- slsDetectorSoftware/src/DetectorImpl.cpp | 33 +++++++++++++++--------- slsDetectorSoftware/src/DetectorImpl.h | 2 +- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index 3522c5e21..45e1a1373 100644 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -1173,31 +1173,40 @@ int DetectorImpl::acquire() { return OK; } -void DetectorImpl::startAcquisition(bool blocking, Positions pos) { +void DetectorImpl::startAcquisition(bool blocking, std::vector positions) { if (shm()->detType == defs::MYTHEN3 && size() > 1) { std::vector master; std::vector slaves; - auto is_master = Parallel(&Module::isMaster, pos); - // could be all slaves in pos - slaves.reserve(pos.size()); - for (size_t i = 0; i != pos.size(); ++i) { + if (positions.empty() || + (positions.size() == 1 && positions[0] == -1)) { + positions.resize(modules.size()); + std::iota(begin(positions), end(positions), 0); + } + // could be all slaves in positions + slaves.reserve(positions.size()); + auto is_master = Parallel(&Module::isMaster, positions); + for (size_t i : positions) { if (is_master[i]) master.push_back(i); else slaves.push_back(i); } - Parallel(&Module::startAcquisition, slaves); - if (blocking) { - Parallel(&Module::startAndReadAll, master); - } else { - Parallel(&Module::startAcquisition, master); + if (!slaves.empty()) { + Parallel(&Module::startAcquisition, slaves); + } + if (!master.empty()) { + if (blocking) { + Parallel(&Module::startAndReadAll, master); + } else { + Parallel(&Module::startAcquisition, master); + } } } else { if (blocking) { - Parallel(&Module::startAndReadAll, pos); + Parallel(&Module::startAndReadAll, positions); } else { - Parallel(&Module::startAcquisition, pos); + Parallel(&Module::startAcquisition, positions); } } } diff --git a/slsDetectorSoftware/src/DetectorImpl.h b/slsDetectorSoftware/src/DetectorImpl.h index 1ef51fd75..7f6ec43be 100644 --- a/slsDetectorSoftware/src/DetectorImpl.h +++ b/slsDetectorSoftware/src/DetectorImpl.h @@ -279,7 +279,7 @@ class DetectorImpl : public virtual slsDetectorDefs { int acquire(); /** also takes care of master and slave for multi module mythen */ - void startAcquisition(bool blocking, Positions pos); + void startAcquisition(bool blocking, std::vector positions); /** * Combines data from all readouts and gives it to the gui