mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-06-30 20:18:21 +02:00
works in file. still needs refactoring
This commit is contained in:
@@ -1082,18 +1082,17 @@ Result<int> Detector::getNumberofUDPInterfaces(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getNumberofUDPInterfacesFromShm, pos);
|
||||
}
|
||||
|
||||
void Detector::setNumberofUDPInterfaces(int n, Positions pos) {
|
||||
void Detector::setNumberofUDPInterfaces(int n) {
|
||||
auto detType = getDetectorType().squash();
|
||||
if (detType != defs::JUNGFRAU && detType != defs::MOENCH) {
|
||||
throw RuntimeError(
|
||||
"Cannot set number of udp interfaces for this detector.");
|
||||
}
|
||||
// also called by vetostream (for gotthard2)
|
||||
setNumberofUDPInterfaces_(n, pos);
|
||||
pimpl->updateRxUDPDatastreamMetadata();
|
||||
setNumberofUDPInterfaces_(n);
|
||||
}
|
||||
|
||||
void Detector::setNumberofUDPInterfaces_(int n, Positions pos) {
|
||||
void Detector::setNumberofUDPInterfaces_(int n) {
|
||||
if (!size()) {
|
||||
throw RuntimeError("No modules added.");
|
||||
}
|
||||
@@ -1103,10 +1102,10 @@ void Detector::setNumberofUDPInterfaces_(int n, Positions pos) {
|
||||
bool previouslyReceiverStreaming = false;
|
||||
uint16_t rxStartingPort = 0;
|
||||
if (useReceiver) {
|
||||
previouslyReceiverStreaming = getRxZmqDataStream(pos).squash(true);
|
||||
previouslyReceiverStreaming = getRxZmqDataStream().squash(true);
|
||||
rxStartingPort = getRxZmqPort({0}).squash(0);
|
||||
}
|
||||
pimpl->Parallel(&Module::setNumberofUDPInterfaces, pos, n);
|
||||
pimpl->Parallel(&Module::setNumberofUDPInterfaces, {}, n);
|
||||
// ensure receiver zmq socket ports are multiplied by 2 (2 interfaces)
|
||||
setClientZmqPort(clientStartingPort, -1);
|
||||
if (getUseReceiverFlag().squash(false)) {
|
||||
@@ -1118,8 +1117,8 @@ void Detector::setNumberofUDPInterfaces_(int n, Positions pos) {
|
||||
pimpl->setDataStreamingToClient(true);
|
||||
}
|
||||
if (previouslyReceiverStreaming) {
|
||||
setRxZmqDataStream(false, pos);
|
||||
setRxZmqDataStream(true, pos);
|
||||
setRxZmqDataStream(false);
|
||||
setRxZmqDataStream(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1325,6 +1324,15 @@ Result<bool> Detector::getDataStream(const defs::portPosition port,
|
||||
|
||||
void Detector::setDataStream(const defs::portPosition port, const bool enable,
|
||||
Positions pos) {
|
||||
// check num interfaces
|
||||
auto numInterfaces =
|
||||
pimpl->Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
|
||||
.tsquash("Inconsistent number of UDP interfaces among modules");
|
||||
if (numInterfaces != 2) {
|
||||
throw RuntimeError(
|
||||
"Cannot enable/disable individual udp ports. Change number of udp "
|
||||
"interfaces to 2 (cmd = numinterfaces).");
|
||||
}
|
||||
pimpl->Parallel(&Module::setDataStream, pos, port, enable);
|
||||
pimpl->updateRxUDPDatastreamMetadata();
|
||||
}
|
||||
@@ -2014,7 +2022,7 @@ void Detector::setVetoStream(defs::streamingInterface interface,
|
||||
? 2
|
||||
: 1);
|
||||
if (numinterfaces != old_numinterfaces) {
|
||||
setNumberofUDPInterfaces_(numinterfaces, pos);
|
||||
setNumberofUDPInterfaces_(numinterfaces);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user