fix for empty roi vectors (which shouldnt be) as you cant know if its all or not in roi

This commit is contained in:
2025-06-24 17:05:40 +02:00
parent 7258adfe15
commit 24fcfb3f9d
8 changed files with 176 additions and 174 deletions

View File

@ -714,7 +714,7 @@ class Detector {
* restarts client and receiver zmq sockets if zmq streaming enabled. \n
* [Gotthard2] second interface enabled to send veto information via 10Gbps
* for debugging. By default, if veto enabled, it is sent via 2.5 gbps
* interface. */
* interface. \nSetting this resets the receiver roi */
void setNumberofUDPInterfaces(int n, Positions pos = {});
/** [Jungfrau][Moench] */
@ -995,7 +995,8 @@ class Detector {
/** Returns port level ROIs. Max 2 ports and hence max 2 elements per readout */
std::vector<defs::ROI> getRxROI(int module_id) const;
/** only at multi module level without gap pixels. At most, 1 ROI per UDP port */
/** only at multi module level without gap pixels. At most, 1 ROI per UDP
* port. Setting number of udp interfaces will clear the roi */
void setRxROI(const std::vector<defs::ROI> &args);
void clearRxROI();

View File

@ -734,7 +734,8 @@ std::string Caller::rx_roi(int action) {
"Only allowed to set at multi module level and without gap "
"ixels.\n\n\t" +
"One can get rx_roi also at port level, by specifying the module id "
"and it will return the roi for each port.\n";
"and it will return the roi for each port.\n"
"Setting number of udp interfaces will clear the rx_roi\n";
if (action == defs::HELP_ACTION) {
os << helpMessage;
} else if (action == defs::GET_ACTION) {

View File

@ -1534,8 +1534,10 @@ std::vector<defs::ROI> Module::getRxROI() const {
std::vector<ROI> retval(nPorts);
if (nPorts > 0)
client.Receive(retval);
if (nPorts > shm()->numUDPInterfaces) {
throw RuntimeError("Invalid number of rois: " + std::to_string(nPorts) + ". Max: " + std::to_string(shm()->numUDPInterfaces));
if (nPorts != shm()->numUDPInterfaces) {
throw RuntimeError(
"Invalid number of rois: " + std::to_string(nPorts) +
". Expected: " + std::to_string(shm()->numUDPInterfaces));
}
LOG(logDEBUG1) << "ROI of Receiver" << moduleIndex << ": "
<< ToString(retval);
@ -1548,11 +1550,11 @@ void Module::setRxROI(const std::vector<defs::ROI> &portRois) {
if (!shm()->useReceiverFlag) {
throw RuntimeError("No receiver to set ROI.");
}
if ((int)portRois.size() > shm()->numUDPInterfaces) {
throw RuntimeError("Invalid number of ROIs: " +
std::to_string(portRois.size()) +
". Max: " + std::to_string(shm()->numUDPInterfaces));
}
if ((int)portRois.size() != shm()->numUDPInterfaces) {
throw RuntimeError(
"Invalid number of ROIs: " + std::to_string(portRois.size()) +
". Expected: " + std::to_string(shm()->numUDPInterfaces));
}
// check number of ports
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
client.Send(F_RECEIVER_SET_RECEIVER_ROI);
@ -1577,6 +1579,10 @@ void Module::setRxROIMetadata(const std::vector<slsDetectorDefs::ROI> &args) {
receiver.Send(size);
if (size > 0)
receiver.Send(args);
if (size < 1) {
throw RuntimeError("Invalid number of ROI metadata: " +
std::to_string(size) + ". Min: 1.");
}
if (receiver.Receive<int>() == FAIL) {
throw ReceiverError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + receiver.readErrorMessage());