diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 0453768dc..ca465c95c 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -747,8 +747,7 @@ Result Detector::getRxHostname(const int udpInterface, Positions po } void Detector::setRxHostname(const int udpInterface, const std::string &hostname, Positions pos) { - int port = 0; - pimpl->configureReceiver(udpInterface, pos, hostname, port); + pimpl->configureReceiver(udpInterface, pos, hostname); } void Detector::setRxHostname(const int udpInterface, const std::string &hostname, const int port, @@ -756,7 +755,7 @@ void Detector::setRxHostname(const int udpInterface, const std::string &hostname if (module_id == -1 && size() > 1) { throw sls::RuntimeError("Cannot set same rx_tcpport and rx_hostname for multiple receivers"); } - pimpl->configureReceiver(udpInterface, {module_id}, hostname, port); + pimpl->configureReceiver(udpInterface, module_id, hostname, port); } Result Detector::getRxPort(const int udpInterface, Positions pos) const { diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index ff0d023c9..ac9903295 100755 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -438,7 +438,7 @@ void DetectorImpl::removeReceivers(const int udpInterface) { } void DetectorImpl::configureReceiver(const int udpInterface, Positions pos, - const std::string &hostname, const int port) { + const std::string &hostname) { if (Parallel(&Module::getRunStatus, pos).squash(defs::ERROR) == defs::RUNNING) { LOG(logWARNING) << "Acquisition already running, Stopping it."; @@ -447,25 +447,50 @@ void DetectorImpl::configureReceiver(const int udpInterface, Positions pos, if (!isReceiverInitialized(udpInterface)) { initReceiver(udpInterface); } + auto t = Parallel(&Module::getReceiverParameters, pos); if (udpInterface == 1) { - if (port != 0) { - Parallel1(&Receiver::setTCPPort, pos, {}, port); - } Parallel1(&Receiver::setHostname, pos, {}, hostname); - auto t = Parallel(&Module::getReceiverParameters, pos).squash(); - auto m = Parallel1(&Receiver::configure, pos, {}, t).squash(); - if (m != 0) { - Parallel(&Module::setDestinationUDPMAC, pos, m); + for (int iMod = 0; iMod < size(); ++iMod) { + auto m = receivers[iMod][0]->configure(t[iMod]); + if (m != 0) { + detectors[iMod]->setDestinationUDPMAC(m); + } } } else { - if (port != 0) { - Parallel2(&Receiver::setTCPPort, pos, {}, port); - } Parallel2(&Receiver::setHostname, pos, {}, hostname); - auto t = Parallel(&Module::getReceiverParameters, pos).squash(); - auto m = Parallel2(&Receiver::configure, pos, {}, t).squash(); + for (int iMod = 0; iMod < size(); ++iMod) { + auto m = receivers2[iMod][0]->configure(t[iMod]); + if (m != 0) { + detectors[iMod]->setDestinationUDPMAC2(m); + } + } + } +} + +void DetectorImpl::configureReceiver(const int udpInterface, int module_id, + const std::string &hostname, const int port) { + + if (Parallel(&Module::getRunStatus, {}).squash(defs::ERROR) == defs::RUNNING) { + LOG(logWARNING) << "Acquisition already running, Stopping it."; + Parallel(&Module::stopAcquisition, {}); + } + if (!isReceiverInitialized(udpInterface)) { + initReceiver(udpInterface); + } + auto t = detectors[module_id]->getReceiverParameters(); + if (udpInterface == 1) { + receivers[module_id][0]->setTCPPort(port); + receivers[module_id][0]->setHostname(hostname); + auto m = receivers[module_id][0]->configure(t); if (m != 0) { - Parallel(&Module::setDestinationUDPMAC2, pos, m); + detectors[module_id]->setDestinationUDPMAC(m); + } + } else { + receivers2[module_id][0]->setTCPPort(port); + receivers2[module_id][0]->setHostname(hostname); + auto m = receivers2[module_id][0]->configure(t); + if (m != 0) { + detectors[module_id]->setDestinationUDPMAC2(m); } } } diff --git a/slsDetectorSoftware/src/DetectorImpl.h b/slsDetectorSoftware/src/DetectorImpl.h index 9fb617b15..7895b24a7 100755 --- a/slsDetectorSoftware/src/DetectorImpl.h +++ b/slsDetectorSoftware/src/DetectorImpl.h @@ -664,6 +664,8 @@ class DetectorImpl : public virtual slsDetectorDefs { bool isReceiverInitialized(const int udpInterface); void removeReceivers(const int udpInterface); void configureReceiver(const int udpInterface, Positions pos, + const std::string &hostname); + void configureReceiver(const int udpInterface, int module_id, const std::string &hostname, const int port); /** Gets the total number of detectors */