refactor cmd line

This commit is contained in:
2025-07-01 17:13:59 +02:00
parent f8a06d78f3
commit a28c78c47f

View File

@ -756,7 +756,9 @@ std::string Caller::rx_roi(int action) {
auto t = det->getRxROI(det_id); auto t = det->getRxROI(det_id);
os << ToString(t) << '\n'; os << ToString(t) << '\n';
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
std::vector<defs::ROI> rois; if (det_id != -1) {
throw RuntimeError("Cannot set receiver ROI at module level");
}
// Support multiple args with bracketed ROIs, or single arg with // Support multiple args with bracketed ROIs, or single arg with
// semicolon-separated vector in quotes // semicolon-separated vector in quotes
bool isVectorInput = bool isVectorInput =
@ -764,25 +766,30 @@ std::string Caller::rx_roi(int action) {
return a.find('[') != std::string::npos && return a.find('[') != std::string::npos &&
a.find(']') != std::string::npos; a.find(']') != std::string::npos;
}); });
std::vector<defs::ROI> rois;
try { try {
// previous format: 2 or 4 separate args // single roi in previous format: [xmin,xmax,ymin,ymax]
if ((args.size() == 2 || args.size() == 4) && !isVectorInput) { if (!isVectorInput) {
defs::ROI t; if (args.size() == 2 || args.size() == 4) {
t.xmin = StringTo<int>(args[0]); defs::ROI t;
t.xmax = StringTo<int>(args[1]); t.xmin = StringTo<int>(args[0]);
if (args.size() == 4) { t.xmax = StringTo<int>(args[1]);
t.ymin = StringTo<int>(args[2]); if (args.size() == 4) {
t.ymax = StringTo<int>(args[3]); t.ymin = StringTo<int>(args[2]);
} t.ymax = StringTo<int>(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());
} }
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) { } catch (const std::exception &e) {
@ -791,11 +798,6 @@ std::string Caller::rx_roi(int action) {
cmd + " to get the right syntax expected."); 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); det->setRxROI(rois);
os << ToString(rois) << '\n'; os << ToString(rois) << '\n';
} else { } else {