Dev/reg bit change no validate (#970)

- do not validate write reg, setbit and clearbit by default anymore
- --validate will force validation on the bitmask or entire reg
- remove return value for write reg (across server to client, but thankfully not in the Detector class)
- extend validation into writereg, setbit and clearbit for Eiger (always special)
-  need to check python (TODO)
- missed the rx_zmqip implementations in detector.h and python bindings
This commit is contained in:
2024-09-30 16:54:12 +02:00
committed by GitHub
parent a44ba4dc35
commit 2dc0963c56
33 changed files with 499 additions and 171 deletions

View File

@ -1482,14 +1482,15 @@ std::string Caller::clearbit(int action) {
if (action == slsDetectorDefs::HELP_ACTION) {
os << "Command: clearbit" << std::endl;
os << R"V0G0N([reg address in hex] [bit index]
Clears bit in address. )V0G0N"
Clears bit in address.
Use --validate to force validation. )V0G0N"
<< std::endl;
return os.str();
}
// check if action and arguments are valid
if (action == slsDetectorDefs::PUT_ACTION) {
if (1 && args.size() != 2) {
if (1 && args.size() != 2 && args.size() != 3) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
@ -1504,6 +1505,29 @@ std::string Caller::clearbit(int action) {
} catch (...) {
throw RuntimeError("Could not convert argument 1 to int");
}
try {
StringTo<bool>("0");
} catch (...) {
throw RuntimeError("Could not convert argument 2 to bool");
}
}
if (args.size() == 3) {
try {
StringTo<uint32_t>(args[0]);
} catch (...) {
throw RuntimeError("Could not convert argument 0 to uint32_t");
}
try {
StringTo<int>(args[1]);
} catch (...) {
throw RuntimeError("Could not convert argument 1 to int");
}
try {
StringTo<bool>("1");
} catch (...) {
throw RuntimeError("Could not convert argument 2 to bool");
}
}
}
@ -1522,8 +1546,24 @@ std::string Caller::clearbit(int action) {
}
auto arg0 = StringTo<uint32_t>(args[0]);
auto arg1 = StringTo<int>(args[1]);
det->clearBit(arg0, arg1, std::vector<int>{det_id});
os << ToString(args) << '\n';
auto arg2 = StringTo<bool>("0");
det->clearBit(arg0, arg1, arg2, std::vector<int>{det_id});
os << "[" << args[0] << ", " << args[1] << "]" << '\n';
}
if (args.size() == 3) {
if (StringTo<int>(args[1]) < 0 || StringTo<int>(args[1]) > 31) {
throw RuntimeError("Bit number out of range: " + args[1]);
}
if (args[2] != "--validate") {
throw RuntimeError(
"Could not scan third argument. Did you mean --validate?");
}
auto arg0 = StringTo<uint32_t>(args[0]);
auto arg1 = StringTo<int>(args[1]);
auto arg2 = StringTo<bool>("1");
det->clearBit(arg0, arg1, arg2, std::vector<int>{det_id});
os << "[" << args[0] << ", " << args[1] << "]" << '\n';
}
}
@ -10307,9 +10347,10 @@ std::string Caller::reg(int action) {
// print help
if (action == slsDetectorDefs::HELP_ACTION) {
os << "Command: reg" << std::endl;
os << R"V0G0N([address] [32 bit value]
os << R"V0G0N([address] [32 bit value][(optional)--validate]
[Mythen3][Gotthard2] Reads/writes to a 32 bit register in hex. Advanced Function!
Goes to stop server. Hence, can be called while calling blocking acquire().
Use --validate to force validation when writing to it.
[Eiger] +0x100 for only left, +0x200 for only right. )V0G0N"
<< std::endl;
return os.str();
@ -10332,7 +10373,7 @@ std::string Caller::reg(int action) {
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (1 && args.size() != 2) {
if (1 && args.size() != 2 && args.size() != 3) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
@ -10347,6 +10388,29 @@ std::string Caller::reg(int action) {
} catch (...) {
throw RuntimeError("Could not convert argument 1 to uint32_t");
}
try {
StringTo<bool>("0");
} catch (...) {
throw RuntimeError("Could not convert argument 2 to bool");
}
}
if (args.size() == 3) {
try {
StringTo<uint32_t>(args[0]);
} catch (...) {
throw RuntimeError("Could not convert argument 0 to uint32_t");
}
try {
StringTo<uint32_t>(args[1]);
} catch (...) {
throw RuntimeError("Could not convert argument 1 to uint32_t");
}
try {
StringTo<bool>("1");
} catch (...) {
throw RuntimeError("Could not convert argument 2 to bool");
}
}
}
@ -10370,8 +10434,21 @@ std::string Caller::reg(int action) {
if (args.size() == 2) {
auto arg0 = StringTo<uint32_t>(args[0]);
auto arg1 = StringTo<uint32_t>(args[1]);
det->writeRegister(arg0, arg1, std::vector<int>{det_id});
os << ToString(args) << '\n';
auto arg2 = StringTo<bool>("0");
det->writeRegister(arg0, arg1, arg2, std::vector<int>{det_id});
os << "[" << args[0] << ", " << args[1] << "]" << '\n';
}
if (args.size() == 3) {
if (args[2] != "--validate") {
throw RuntimeError(
"Could not scan third argument. Did you mean --validate?");
}
auto arg0 = StringTo<uint32_t>(args[0]);
auto arg1 = StringTo<uint32_t>(args[1]);
auto arg2 = StringTo<bool>("1");
det->writeRegister(arg0, arg1, arg2, std::vector<int>{det_id});
os << "[" << args[0] << ", " << args[1] << "]" << '\n';
}
}
@ -12601,14 +12678,15 @@ std::string Caller::setbit(int action) {
if (action == slsDetectorDefs::HELP_ACTION) {
os << "Command: setbit" << std::endl;
os << R"V0G0N([reg address in hex] [bit index]
Sets bit in address. )V0G0N"
Sets bit in address.
Use --validate to force validation. )V0G0N"
<< std::endl;
return os.str();
}
// check if action and arguments are valid
if (action == slsDetectorDefs::PUT_ACTION) {
if (1 && args.size() != 2) {
if (1 && args.size() != 2 && args.size() != 3) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
@ -12623,6 +12701,29 @@ std::string Caller::setbit(int action) {
} catch (...) {
throw RuntimeError("Could not convert argument 1 to int");
}
try {
StringTo<bool>("0");
} catch (...) {
throw RuntimeError("Could not convert argument 2 to bool");
}
}
if (args.size() == 3) {
try {
StringTo<uint32_t>(args[0]);
} catch (...) {
throw RuntimeError("Could not convert argument 0 to uint32_t");
}
try {
StringTo<int>(args[1]);
} catch (...) {
throw RuntimeError("Could not convert argument 1 to int");
}
try {
StringTo<bool>("1");
} catch (...) {
throw RuntimeError("Could not convert argument 2 to bool");
}
}
}
@ -12641,8 +12742,24 @@ std::string Caller::setbit(int action) {
}
auto arg0 = StringTo<uint32_t>(args[0]);
auto arg1 = StringTo<int>(args[1]);
det->setBit(arg0, arg1, std::vector<int>{det_id});
os << ToString(args) << '\n';
auto arg2 = StringTo<bool>("0");
det->setBit(arg0, arg1, arg2, std::vector<int>{det_id});
os << "[" << args[0] << ", " << args[1] << "]" << '\n';
}
if (args.size() == 3) {
if (StringTo<int>(args[1]) < 0 || StringTo<int>(args[1]) > 31) {
throw RuntimeError("Bit number out of range: " + args[1]);
}
if (args[2] != "--validate") {
throw RuntimeError(
"Could not scan third argument. Did you mean --validate?");
}
auto arg0 = StringTo<uint32_t>(args[0]);
auto arg1 = StringTo<int>(args[1]);
auto arg2 = StringTo<bool>("1");
det->setBit(arg0, arg1, arg2, std::vector<int>{det_id});
os << "[" << args[0] << ", " << args[1] << "]" << '\n';
}
}