mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-12-15 17:11:20 +01:00
minor fixes in command line and help
This commit is contained in:
@@ -723,19 +723,30 @@ std::string Caller::rx_zmqip(int action) {
|
||||
std::string Caller::rx_roi(int action) {
|
||||
std::ostringstream os;
|
||||
std::string helpMessage =
|
||||
std::string("[xmin] [xmax] [ymin] [ymax]\n\tRegion of interest in "
|
||||
"receiver.\n\t") +
|
||||
"For a list of rois, use '[' and ']; ' to distinguish between "
|
||||
"rois and use comma inside the square brackets.\n\t If one fails to "
|
||||
"use space after semicolon, please use quotes" +
|
||||
"For example: [0,100,0,100]; [200,300,0,100] will set two "
|
||||
"rois.or '[0,100,0,100];[200,300,0,100]' when the vector is a single "
|
||||
"string\n\n\t" +
|
||||
"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"
|
||||
"Setting number of udp interfaces will clear the rx_roi\n";
|
||||
std::string("[xmin] [xmax] [ymin] [ymax]\n") +
|
||||
"\tDefines a single region of interest (ROI) in the receiver.\n"
|
||||
"\tFor example, to set a single ROI: 0 100 20 30\n\n"
|
||||
|
||||
"\tTo specify multiple ROIs, use square brackets between ROIs and "
|
||||
"commas inside for each ROI. \n"
|
||||
"\tInside each bracket, no spaces allowed.\n\n"
|
||||
|
||||
"\tIf you use semicolon (along with '['and ']' to separate rois), \n"
|
||||
"\tenclose the entire list in quotes.\n"
|
||||
"\tExamples:\n"
|
||||
"\t [0,100,0,100] [200,300,0,100]\n"
|
||||
"\t \"[0,100,0,100];[200,300,0,100]\"\n\n"
|
||||
|
||||
"\tNotes:\n"
|
||||
"\t- ROIs can only be set at the multi-module level.\n"
|
||||
"\t- ROIs coordinates assume no gap pixels, even if they are enabled "
|
||||
"in gui.\n"
|
||||
"\t- To retrieve ROIs per port, specify the module ID when using the "
|
||||
"get command.\n"
|
||||
"\t- Use the command 'rx_clearroi' to clear all ROIs.\n"
|
||||
"\t- Changing the number of UDP interfaces will automatically clear "
|
||||
"the current ROIs.\n";
|
||||
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << helpMessage;
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
@@ -751,9 +762,8 @@ std::string Caller::rx_roi(int action) {
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
std::vector<defs::ROI> rois;
|
||||
|
||||
// Support multiple args with bracketed ROIs, or single arg with
|
||||
// semicolon-separated vector
|
||||
// semicolon-separated vector in quotes
|
||||
bool isVectorInput =
|
||||
std::all_of(args.begin(), args.end(), [](const std::string &a) {
|
||||
return a.find('[') != std::string::npos &&
|
||||
@@ -781,7 +791,9 @@ std::string Caller::rx_roi(int action) {
|
||||
}
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
throw RuntimeError("Could not parse ROI: " + helpMessage);
|
||||
throw RuntimeError("Could not parse ROI: Did you use spaces inside "
|
||||
"the brackets? Use sls_detector_help " +
|
||||
cmd + " to get the right syntax expected.");
|
||||
}
|
||||
|
||||
// only multi level
|
||||
@@ -802,16 +814,19 @@ std::vector<defs::ROI> Caller::parseRoiVector(const std::string &input) {
|
||||
std::stringstream ss(input);
|
||||
std::string token;
|
||||
|
||||
while (std::getline(ss, token, ';')) {
|
||||
token.erase(std::remove_if(token.begin(), token.end(), ::isspace),
|
||||
token.end());
|
||||
while (std::getline(ss, token, ']')) {
|
||||
// remove spaces and semicolons
|
||||
token.erase(
|
||||
std::remove_if(token.begin(), token.end(),
|
||||
[](char c) { return std::isspace(c) || c == ';'; }),
|
||||
token.end());
|
||||
if (token.empty())
|
||||
continue;
|
||||
if (token.front() != '[' || token.back() != ']') {
|
||||
if (token.front() != '[') {
|
||||
throw RuntimeError("Each ROI must be enclosed in square brackets: "
|
||||
"[xmin,xmax,ymin,ymax]");
|
||||
}
|
||||
token = token.substr(1, token.size() - 2); // remove brackets
|
||||
token = token.substr(1, token.size() - 1); // remove brackets
|
||||
std::vector<std::string> parts;
|
||||
std::stringstream inner(token);
|
||||
std::string num;
|
||||
|
||||
@@ -507,13 +507,13 @@ TEST_CASE("rx_roi", "[.cmdcall]") {
|
||||
// vector of rois
|
||||
// square brackets missing
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[5, 20, -1, -1; 25, 30, -1, -1]"}, -1, PUT));
|
||||
"rx_roi", {"[5, 20, -1, -1] 25, 30, -1, -1]"}, -1, PUT));
|
||||
// invalid roi, 4 parts expected
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[5, 20, -1]; [25, 30, -1, -1]"}, -1, PUT));
|
||||
"rx_roi", {"[5, 20, -1] [25, 30, -1, -1]"}, -1, PUT));
|
||||
// overlapping rois
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[0, 10,-1, -1];[5, 15, -1, -1]"}, -1, PUT));
|
||||
"rx_roi", {"[0, 10,-1, -1] [5, 15, -1, -1]"}, -1, PUT));
|
||||
|
||||
if (det.size() == 2) {
|
||||
auto moduleSize = det.getModuleSize()[0];
|
||||
@@ -527,7 +527,8 @@ TEST_CASE("rx_roi", "[.cmdcall]") {
|
||||
"[" + stringMin + ", " + stringMax + ", -1, -1]"},
|
||||
-1, PUT));
|
||||
std::ostringstream oss;
|
||||
// separated by semicolon is allowed
|
||||
// separated by semicolon with quotes is allowed (skips
|
||||
// cmdParser)
|
||||
REQUIRE_NOTHROW(caller.call("rx_roi",
|
||||
{"[5, 10, -1, -1];[" + stringMin +
|
||||
", " + stringMax + ", -1, -1]"},
|
||||
@@ -598,15 +599,15 @@ TEST_CASE("rx_roi", "[.cmdcall]") {
|
||||
// vector of rois
|
||||
// square brackets missing
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[5, 20, 20, 30; 25, 30, 14, 15]"}, -1, PUT));
|
||||
"rx_roi", {"[5, 20, 20, 30] 25, 30, 14, 15]"}, -1, PUT));
|
||||
// invalid roi, 4 parts expected
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[5, 20, 20]; [25, 30, 14, 15]"}, -1, PUT));
|
||||
"rx_roi", {"[5, 20, 20] [25, 30, 14, 15]"}, -1, PUT));
|
||||
// overlapping rois
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[0, 10, 0, 10];[5, 15, 0, 10]"}, -1, PUT));
|
||||
"rx_roi", {"[0, 10, 0, 10] [5, 15, 0, 10]"}, -1, PUT));
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[0, 10, 0, 10];[0, 10, 9, 11]"}, -1, PUT));
|
||||
"rx_roi", {"[0, 10, 0, 10] [0, 10, 9, 11]"}, -1, PUT));
|
||||
|
||||
int numinterfaces = det.getNumberofUDPInterfaces().tsquash(
|
||||
"inconsistent number of interfaces");
|
||||
@@ -624,7 +625,8 @@ TEST_CASE("rx_roi", "[.cmdcall]") {
|
||||
"[" + stringMin + ", " + stringMax + ", 20, 30]"},
|
||||
-1, PUT));
|
||||
std::ostringstream oss;
|
||||
// separated by semicolon is allowed
|
||||
// separated by semicolon with quotes is allowed (skips
|
||||
// cmdParser)
|
||||
REQUIRE_NOTHROW(caller.call("rx_roi",
|
||||
{"[5, 10, 20, 30];[" + stringMin +
|
||||
", " + stringMax + ", 20, 30]"},
|
||||
@@ -676,7 +678,8 @@ TEST_CASE("rx_roi", "[.cmdcall]") {
|
||||
", " + stringMax + "]"},
|
||||
-1, PUT));
|
||||
std::ostringstream oss;
|
||||
// separated by semicolon is allowed
|
||||
// separated by semicolon is allowed with quotes (skips
|
||||
// cmdParser)
|
||||
REQUIRE_NOTHROW(
|
||||
caller.call("rx_roi",
|
||||
{"[5, 10, 20, 30];[25, 28, " + stringMin +
|
||||
|
||||
Reference in New Issue
Block a user