diff --git a/slsDetectorSoftware/src/CallerSpecial.cpp b/slsDetectorSoftware/src/CallerSpecial.cpp index 10330f1b6..5b9426ceb 100644 --- a/slsDetectorSoftware/src/CallerSpecial.cpp +++ b/slsDetectorSoftware/src/CallerSpecial.cpp @@ -756,7 +756,9 @@ std::string Caller::rx_roi(int action) { auto t = det->getRxROI(det_id); os << ToString(t) << '\n'; } else if (action == defs::PUT_ACTION) { - std::vector rois; + if (det_id != -1) { + throw RuntimeError("Cannot set receiver ROI at module level"); + } // Support multiple args with bracketed ROIs, or single arg with // semicolon-separated vector in quotes bool isVectorInput = @@ -764,25 +766,30 @@ std::string Caller::rx_roi(int action) { return a.find('[') != std::string::npos && a.find(']') != std::string::npos; }); + std::vector rois; try { - // previous format: 2 or 4 separate args - if ((args.size() == 2 || args.size() == 4) && !isVectorInput) { - defs::ROI t; - t.xmin = StringTo(args[0]); - t.xmax = StringTo(args[1]); - if (args.size() == 4) { - t.ymin = StringTo(args[2]); - t.ymax = StringTo(args[3]); - } - rois.emplace_back(t); - } else { - if (!isVectorInput) - WrongNumberOfParameters(2); - else { - for (const auto &arg : args) { - auto subRois = parseRoiVector(arg); - rois.insert(rois.end(), subRois.begin(), subRois.end()); + // single roi in previous format: [xmin,xmax,ymin,ymax] + if (!isVectorInput) { + if (args.size() == 2 || args.size() == 4) { + defs::ROI t; + t.xmin = StringTo(args[0]); + t.xmax = StringTo(args[1]); + if (args.size() == 4) { + t.ymin = StringTo(args[2]); + t.ymax = StringTo(args[3]); } + rois.emplace_back(t); + } else { + WrongNumberOfParameters(2); + } + } + // multiple roi or single roi with brackets + // multiple roi: multiple args with bracketed ROIs, or single arg + // with semicolon-bracketed Rois in quotes + else { + for (const auto &arg : args) { + auto subRois = parseRoiVector(arg); + rois.insert(rois.end(), subRois.begin(), subRois.end()); } } } catch (const std::exception &e) { @@ -791,11 +798,6 @@ std::string Caller::rx_roi(int action) { cmd + " to get the right syntax expected."); } - // only multi level - if (det_id != -1) { - throw RuntimeError("Cannot execute receiver ROI at module level"); - } - det->setRxROI(rois); os << ToString(rois) << '\n'; } else {