mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
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:
@ -21,8 +21,8 @@ type_values = {
|
||||
"special::currentSourceFix": ["fix", "nofix"],
|
||||
"special::currentSourceLow": ["normal", "low"],
|
||||
"special::path": [],
|
||||
"special::pedestal_parameters" : ["", "0"]
|
||||
|
||||
"special::pedestal_parameters" : ["", "0"],
|
||||
"special::validate": ["--validate"]
|
||||
}
|
||||
|
||||
|
||||
|
@ -330,6 +330,9 @@ fi
|
||||
if [[ "${cword}" == "3" ]]; then
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
if [[ "${cword}" == "4" ]]; then
|
||||
FCN_RETURN="--validate"
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@ -342,6 +345,9 @@ fi
|
||||
if [[ "${cword}" == "3" ]]; then
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
if [[ "${cword}" == "4" ]]; then
|
||||
FCN_RETURN="--validate"
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@ -1814,6 +1820,9 @@ fi
|
||||
if [[ "${cword}" == "3" ]]; then
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
if [[ "${cword}" == "4" ]]; then
|
||||
FCN_RETURN="--validate"
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@ -1826,6 +1835,9 @@ fi
|
||||
if [[ "${cword}" == "3" ]]; then
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
if [[ "${cword}" == "4" ]]; then
|
||||
FCN_RETURN="--validate"
|
||||
fi
|
||||
fi
|
||||
if [[ ${IS_GET} -eq 0 ]]; then
|
||||
if [[ "${cword}" == "2" ]]; then
|
||||
@ -2211,6 +2223,9 @@ fi
|
||||
if [[ "${cword}" == "3" ]]; then
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
if [[ "${cword}" == "4" ]]; then
|
||||
FCN_RETURN="--validate"
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
@ -254,6 +254,9 @@ fi
|
||||
if [[ "${cword}" == "3" ]]; then
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
if [[ "${cword}" == "4" ]]; then
|
||||
FCN_RETURN="--validate"
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@ -266,6 +269,9 @@ fi
|
||||
if [[ "${cword}" == "3" ]]; then
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
if [[ "${cword}" == "4" ]]; then
|
||||
FCN_RETURN="--validate"
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@ -1738,6 +1744,9 @@ fi
|
||||
if [[ "${cword}" == "3" ]]; then
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
if [[ "${cword}" == "4" ]]; then
|
||||
FCN_RETURN="--validate"
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@ -1750,6 +1759,9 @@ fi
|
||||
if [[ "${cword}" == "3" ]]; then
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
if [[ "${cword}" == "4" ]]; then
|
||||
FCN_RETURN="--validate"
|
||||
fi
|
||||
fi
|
||||
if [[ ${IS_GET} -eq 0 ]]; then
|
||||
if [[ "${cword}" == "2" ]]; then
|
||||
@ -2135,6 +2147,9 @@ fi
|
||||
if [[ "${cword}" == "3" ]]; then
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
if [[ "${cword}" == "4" ]]; then
|
||||
FCN_RETURN="--validate"
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
@ -4173,7 +4173,7 @@ update:
|
||||
output: [ '"successful"' ]
|
||||
|
||||
reg:
|
||||
help: "[address] [32 bit value]\n\t[Mythen3][Gotthard2] Reads/writes to a 32 bit register in hex. Advanced Function!\n\tGoes to stop server. Hence, can be called while calling blocking acquire().\n\t[Eiger] +0x100 for only left, +0x200 for only right."
|
||||
help: "[address] [32 bit value][(optional)--validate]\n\t[Mythen3][Gotthard2] Reads/writes to a 32 bit register in hex. Advanced Function!\n\tGoes to stop server. Hence, can be called while calling blocking acquire().\n\t\t Use --validate to force validation when writing to it.\n\t[Eiger] +0x100 for only left, +0x200 for only right."
|
||||
actions:
|
||||
GET:
|
||||
argc: 1
|
||||
@ -4184,13 +4184,23 @@ reg:
|
||||
cast_input: [ true ]
|
||||
output: [ OutStringHex(t) ]
|
||||
PUT:
|
||||
argc: 2
|
||||
require_det_id: true
|
||||
function: writeRegister
|
||||
input: [ 'args[0]', 'args[1]' ]
|
||||
input_types: [ uint32_t, uint32_t ]
|
||||
cast_input: [ true, true ]
|
||||
output: [ ToString(args) ]
|
||||
output: [ '"["', 'args[0]', '", "', 'args[1]', '"]"' ]
|
||||
args:
|
||||
- argc: 2
|
||||
input: [ 'args[0]', 'args[1]', '"0"' ]
|
||||
input_types: [ uint32_t, uint32_t, bool ]
|
||||
arg_types: [ uint32_t, uint32_t ]
|
||||
cast_input: [ true, true, true ]
|
||||
- argc: 3
|
||||
arg_types: [ uint32_t, uint32_t, special::validate ]
|
||||
exceptions:
|
||||
- condition: 'args[2] != "--validate"'
|
||||
message: '"Could not scan third argument. Did you mean --validate?"'
|
||||
input: [ 'args[0]', 'args[1]', '"1"' ]
|
||||
input_types: [ uint32_t, uint32_t, bool ]
|
||||
cast_input: [ true, true, true ]
|
||||
|
||||
adcreg:
|
||||
help: "[address] [value]\n\t[Jungfrau][Moench][Ctb][Gotthard] Writes to an adc register in hex. Advanced user Function!"
|
||||
@ -4223,27 +4233,40 @@ Setbit:
|
||||
template: true
|
||||
actions:
|
||||
PUT:
|
||||
argc: 2
|
||||
exceptions:
|
||||
- condition: 'StringTo<int>(args[1]) < 0 || StringTo<int>(args[1]) > 31'
|
||||
message: '"Bit number out of range: " + args[1]'
|
||||
require_det_id: true
|
||||
function: setBit
|
||||
input: [ 'args[0]', 'args[1]' ]
|
||||
input_types: [ uint32_t, int ]
|
||||
cast_input: [ true, true ]
|
||||
output: [ ToString(args) ]
|
||||
output: [ '"["', 'args[0]', '", "', 'args[1]', '"]"' ]
|
||||
args:
|
||||
- argc: 2
|
||||
exceptions:
|
||||
- condition: 'StringTo<int>(args[1]) < 0 || StringTo<int>(args[1]) > 31'
|
||||
message: '"Bit number out of range: " + args[1]'
|
||||
input: [ 'args[0]', 'args[1]', '"0"' ]
|
||||
input_types: [ uint32_t, int, bool ]
|
||||
arg_types: [ uint32_t, int ]
|
||||
cast_input: [ true, true, true ]
|
||||
- argc: 3
|
||||
arg_types: [ uint32_t, int, special::validate ]
|
||||
exceptions:
|
||||
- condition: 'StringTo<int>(args[1]) < 0 || StringTo<int>(args[1]) > 31'
|
||||
message: '"Bit number out of range: " + args[1]'
|
||||
- condition: 'args[2] != "--validate"'
|
||||
message: '"Could not scan third argument. Did you mean --validate?"'
|
||||
input: [ 'args[0]', 'args[1]', '"1"' ]
|
||||
input_types: [ uint32_t, int, bool ]
|
||||
cast_input: [ true, true, true ]
|
||||
|
||||
|
||||
setbit:
|
||||
inherit_actions: Setbit
|
||||
help: "[reg address in hex] [bit index]\n\tSets bit in address."
|
||||
help: "[reg address in hex] [bit index]\n\tSets bit in address.\n\tUse --validate to force validation."
|
||||
actions:
|
||||
PUT:
|
||||
function: setBit
|
||||
|
||||
clearbit:
|
||||
inherit_actions: Setbit
|
||||
help: "[reg address in hex] [bit index]\n\tClears bit in address."
|
||||
help: "[reg address in hex] [bit index]\n\tClears bit in address.\n\tUse --validate to force validation."
|
||||
actions:
|
||||
PUT:
|
||||
function: clearBit
|
||||
|
@ -1104,6 +1104,7 @@ clearbit:
|
||||
cast_input:
|
||||
- true
|
||||
- true
|
||||
- true
|
||||
check_det_id: false
|
||||
convert_det_id: true
|
||||
exceptions:
|
||||
@ -1113,16 +1114,56 @@ clearbit:
|
||||
input:
|
||||
- args[0]
|
||||
- args[1]
|
||||
- '"0"'
|
||||
input_types:
|
||||
- uint32_t
|
||||
- int
|
||||
- bool
|
||||
output:
|
||||
- ToString(args)
|
||||
- '"["'
|
||||
- args[0]
|
||||
- '", "'
|
||||
- args[1]
|
||||
- '"]"'
|
||||
require_det_id: true
|
||||
store_result_in_t: false
|
||||
- arg_types:
|
||||
- uint32_t
|
||||
- int
|
||||
- special::validate
|
||||
argc: 3
|
||||
cast_input:
|
||||
- true
|
||||
- true
|
||||
- true
|
||||
check_det_id: false
|
||||
convert_det_id: true
|
||||
exceptions:
|
||||
- condition: StringTo<int>(args[1]) < 0 || StringTo<int>(args[1]) > 31
|
||||
message: '"Bit number out of range: " + args[1]'
|
||||
- condition: args[2] != "--validate"
|
||||
message: '"Could not scan third argument. Did you mean --validate?"'
|
||||
function: clearBit
|
||||
input:
|
||||
- args[0]
|
||||
- args[1]
|
||||
- '"1"'
|
||||
input_types:
|
||||
- uint32_t
|
||||
- int
|
||||
- bool
|
||||
output:
|
||||
- '"["'
|
||||
- args[0]
|
||||
- '", "'
|
||||
- args[1]
|
||||
- '"]"'
|
||||
require_det_id: true
|
||||
store_result_in_t: false
|
||||
command_name: clearbit
|
||||
function_alias: clearbit
|
||||
help: "[reg address in hex] [bit index]\n\tClears bit in address."
|
||||
help: "[reg address in hex] [bit index]\n\tClears bit in address.\n\tUse --validate\
|
||||
\ to force validation."
|
||||
infer_action: true
|
||||
template: true
|
||||
clearbusy:
|
||||
@ -7973,25 +8014,64 @@ reg:
|
||||
cast_input:
|
||||
- true
|
||||
- true
|
||||
- true
|
||||
check_det_id: false
|
||||
convert_det_id: true
|
||||
function: writeRegister
|
||||
input:
|
||||
- args[0]
|
||||
- args[1]
|
||||
- '"0"'
|
||||
input_types:
|
||||
- uint32_t
|
||||
- uint32_t
|
||||
- bool
|
||||
output:
|
||||
- ToString(args)
|
||||
- '"["'
|
||||
- args[0]
|
||||
- '", "'
|
||||
- args[1]
|
||||
- '"]"'
|
||||
require_det_id: true
|
||||
store_result_in_t: false
|
||||
- arg_types:
|
||||
- uint32_t
|
||||
- uint32_t
|
||||
- special::validate
|
||||
argc: 3
|
||||
cast_input:
|
||||
- true
|
||||
- true
|
||||
- true
|
||||
check_det_id: false
|
||||
convert_det_id: true
|
||||
exceptions:
|
||||
- condition: args[2] != "--validate"
|
||||
message: '"Could not scan third argument. Did you mean --validate?"'
|
||||
function: writeRegister
|
||||
input:
|
||||
- args[0]
|
||||
- args[1]
|
||||
- '"1"'
|
||||
input_types:
|
||||
- uint32_t
|
||||
- uint32_t
|
||||
- bool
|
||||
output:
|
||||
- '"["'
|
||||
- args[0]
|
||||
- '", "'
|
||||
- args[1]
|
||||
- '"]"'
|
||||
require_det_id: true
|
||||
store_result_in_t: false
|
||||
command_name: reg
|
||||
function_alias: reg
|
||||
help: "[address] [32 bit value]\n\t[Mythen3][Gotthard2] Reads/writes to a 32 bit\
|
||||
\ register in hex. Advanced Function!\n\tGoes to stop server. Hence, can be called\
|
||||
\ while calling blocking acquire().\n\t[Eiger] +0x100 for only left, +0x200 for\
|
||||
\ only right."
|
||||
help: "[address] [32 bit value][(optional)--validate]\n\t[Mythen3][Gotthard2] Reads/writes\
|
||||
\ to a 32 bit register in hex. Advanced Function!\n\tGoes to stop server. Hence,\
|
||||
\ can be called while calling blocking acquire().\n\t\t Use --validate to force\
|
||||
\ validation when writing to it.\n\t[Eiger] +0x100 for only left, +0x200 for only\
|
||||
\ right."
|
||||
infer_action: true
|
||||
resetdacs:
|
||||
actions:
|
||||
@ -9646,6 +9726,7 @@ setbit:
|
||||
cast_input:
|
||||
- true
|
||||
- true
|
||||
- true
|
||||
check_det_id: false
|
||||
convert_det_id: true
|
||||
exceptions:
|
||||
@ -9655,16 +9736,56 @@ setbit:
|
||||
input:
|
||||
- args[0]
|
||||
- args[1]
|
||||
- '"0"'
|
||||
input_types:
|
||||
- uint32_t
|
||||
- int
|
||||
- bool
|
||||
output:
|
||||
- ToString(args)
|
||||
- '"["'
|
||||
- args[0]
|
||||
- '", "'
|
||||
- args[1]
|
||||
- '"]"'
|
||||
require_det_id: true
|
||||
store_result_in_t: false
|
||||
- arg_types:
|
||||
- uint32_t
|
||||
- int
|
||||
- special::validate
|
||||
argc: 3
|
||||
cast_input:
|
||||
- true
|
||||
- true
|
||||
- true
|
||||
check_det_id: false
|
||||
convert_det_id: true
|
||||
exceptions:
|
||||
- condition: StringTo<int>(args[1]) < 0 || StringTo<int>(args[1]) > 31
|
||||
message: '"Bit number out of range: " + args[1]'
|
||||
- condition: args[2] != "--validate"
|
||||
message: '"Could not scan third argument. Did you mean --validate?"'
|
||||
function: setBit
|
||||
input:
|
||||
- args[0]
|
||||
- args[1]
|
||||
- '"1"'
|
||||
input_types:
|
||||
- uint32_t
|
||||
- int
|
||||
- bool
|
||||
output:
|
||||
- '"["'
|
||||
- args[0]
|
||||
- '", "'
|
||||
- args[1]
|
||||
- '"]"'
|
||||
require_det_id: true
|
||||
store_result_in_t: false
|
||||
command_name: setbit
|
||||
function_alias: setbit
|
||||
help: "[reg address in hex] [bit index]\n\tSets bit in address."
|
||||
help: "[reg address in hex] [bit index]\n\tSets bit in address.\n\tUse --validate\
|
||||
\ to force validation."
|
||||
infer_action: true
|
||||
template: true
|
||||
settings:
|
||||
|
@ -2034,13 +2034,16 @@ class Detector {
|
||||
* Goes to stop server. Hence, can be called while calling blocking
|
||||
* acquire(). \n [Eiger] Address is +0x100 for only left, +0x200 for only
|
||||
* right. */
|
||||
void writeRegister(uint32_t addr, uint32_t val, Positions pos = {});
|
||||
void writeRegister(uint32_t addr, uint32_t val, bool validate = false,
|
||||
Positions pos = {});
|
||||
|
||||
/** Advanced user Function! */
|
||||
void setBit(uint32_t addr, int bitnr, Positions pos = {});
|
||||
void setBit(uint32_t addr, int bitnr, bool validate = false,
|
||||
Positions pos = {});
|
||||
|
||||
/** Advanced user Function! */
|
||||
void clearBit(uint32_t addr, int bitnr, Positions pos = {});
|
||||
void clearBit(uint32_t addr, int bitnr, bool validate = false,
|
||||
Positions pos = {});
|
||||
|
||||
/** Advanced user Function! */
|
||||
Result<int> getBit(uint32_t addr, int bitnr, Positions pos = {});
|
||||
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2673,16 +2673,18 @@ Result<uint32_t> Detector::readRegister(uint32_t addr, Positions pos) const {
|
||||
return pimpl->Parallel(&Module::readRegister, pos, addr);
|
||||
}
|
||||
|
||||
void Detector::writeRegister(uint32_t addr, uint32_t val, Positions pos) {
|
||||
pimpl->Parallel(&Module::writeRegister, pos, addr, val);
|
||||
void Detector::writeRegister(uint32_t addr, uint32_t val, bool validate,
|
||||
Positions pos) {
|
||||
pimpl->Parallel(&Module::writeRegister, pos, addr, val, validate);
|
||||
}
|
||||
|
||||
void Detector::setBit(uint32_t addr, int bitnr, Positions pos) {
|
||||
pimpl->Parallel(&Module::setBit, pos, addr, bitnr);
|
||||
void Detector::setBit(uint32_t addr, int bitnr, bool validate, Positions pos) {
|
||||
pimpl->Parallel(&Module::setBit, pos, addr, bitnr, validate);
|
||||
}
|
||||
|
||||
void Detector::clearBit(uint32_t addr, int bitnr, Positions pos) {
|
||||
pimpl->Parallel(&Module::clearBit, pos, addr, bitnr);
|
||||
void Detector::clearBit(uint32_t addr, int bitnr, bool validate,
|
||||
Positions pos) {
|
||||
pimpl->Parallel(&Module::clearBit, pos, addr, bitnr, validate);
|
||||
}
|
||||
|
||||
Result<int> Detector::getBit(uint32_t addr, int bitnr, Positions pos) {
|
||||
|
@ -2812,18 +2812,20 @@ uint32_t Module::readRegister(uint32_t addr) const {
|
||||
return sendToDetectorStop<uint32_t>(F_READ_REGISTER, addr);
|
||||
}
|
||||
|
||||
uint32_t Module::writeRegister(uint32_t addr, uint32_t val) {
|
||||
uint32_t args[]{addr, val};
|
||||
return sendToDetectorStop<uint32_t>(F_WRITE_REGISTER, args);
|
||||
void Module::writeRegister(uint32_t addr, uint32_t val, bool validate) {
|
||||
uint32_t args[]{addr, val, static_cast<uint32_t>(validate)};
|
||||
return sendToDetectorStop(F_WRITE_REGISTER, args, nullptr);
|
||||
}
|
||||
|
||||
void Module::setBit(uint32_t addr, int n) {
|
||||
uint32_t args[2] = {addr, static_cast<uint32_t>(n)};
|
||||
void Module::setBit(uint32_t addr, int n, bool validate) {
|
||||
uint32_t args[] = {addr, static_cast<uint32_t>(n),
|
||||
static_cast<uint32_t>(validate)};
|
||||
sendToDetectorStop(F_SET_BIT, args, nullptr);
|
||||
}
|
||||
|
||||
void Module::clearBit(uint32_t addr, int n) {
|
||||
uint32_t args[2] = {addr, static_cast<uint32_t>(n)};
|
||||
void Module::clearBit(uint32_t addr, int n, bool validate) {
|
||||
uint32_t args[] = {addr, static_cast<uint32_t>(n),
|
||||
static_cast<uint32_t>(validate)};
|
||||
sendToDetectorStop(F_CLEAR_BIT, args, nullptr);
|
||||
}
|
||||
|
||||
|
@ -589,9 +589,9 @@ class Module : public virtual slsDetectorDefs {
|
||||
bool getUpdateMode() const;
|
||||
void setUpdateMode(const bool updatemode);
|
||||
uint32_t readRegister(uint32_t addr) const;
|
||||
uint32_t writeRegister(uint32_t addr, uint32_t val);
|
||||
void setBit(uint32_t addr, int n);
|
||||
void clearBit(uint32_t addr, int n);
|
||||
void writeRegister(uint32_t addr, uint32_t val, bool validate);
|
||||
void setBit(uint32_t addr, int n, bool validate);
|
||||
void clearBit(uint32_t addr, int n, bool validate);
|
||||
int getBit(uint32_t addr, int n);
|
||||
void executeFirmwareTest();
|
||||
void executeBusTest();
|
||||
|
@ -404,6 +404,10 @@ int InferAction::clearbit() {
|
||||
return slsDetectorDefs::PUT_ACTION;
|
||||
}
|
||||
|
||||
if (args.size() == 3) {
|
||||
return slsDetectorDefs::PUT_ACTION;
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
throw RuntimeError("Could not infer action: Wrong number of arguments");
|
||||
@ -2490,6 +2494,10 @@ int InferAction::reg() {
|
||||
return slsDetectorDefs::PUT_ACTION;
|
||||
}
|
||||
|
||||
if (args.size() == 3) {
|
||||
return slsDetectorDefs::PUT_ACTION;
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
throw RuntimeError("Could not infer action: Wrong number of arguments");
|
||||
@ -3143,6 +3151,10 @@ int InferAction::setbit() {
|
||||
return slsDetectorDefs::PUT_ACTION;
|
||||
}
|
||||
|
||||
if (args.size() == 3) {
|
||||
return slsDetectorDefs::PUT_ACTION;
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
throw RuntimeError("Could not infer action: Wrong number of arguments");
|
||||
|
@ -3245,6 +3245,13 @@ TEST_CASE("CALLER::reg", "[.cmdcall]") {
|
||||
uint32_t addr = 0x64;
|
||||
std::string saddr = ToStringHex(addr);
|
||||
auto prev_val = det.readRegister(addr);
|
||||
{
|
||||
std::ostringstream oss1, oss2;
|
||||
caller.call("reg", {saddr, "0x6", "--validate"}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "reg [" + saddr + ", 0x6]\n");
|
||||
caller.call("reg", {saddr}, -1, GET, oss2);
|
||||
REQUIRE(oss2.str() == "reg 0x6\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss1, oss2;
|
||||
caller.call("reg", {saddr, "0x5"}, -1, PUT, oss1);
|
||||
@ -3253,7 +3260,7 @@ TEST_CASE("CALLER::reg", "[.cmdcall]") {
|
||||
REQUIRE(oss2.str() == "reg 0x5\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.writeRegister(addr, prev_val[i], {i});
|
||||
det.writeRegister(addr, prev_val[i], false, {i});
|
||||
}
|
||||
}
|
||||
// cannot check for eiger virtual server
|
||||
@ -3289,15 +3296,17 @@ TEST_CASE("CALLER::setbit", "[.cmdcall]") {
|
||||
std::string saddr = ToStringHex(addr);
|
||||
auto prev_val = det.readRegister(addr);
|
||||
{
|
||||
std::ostringstream oss1, oss2;
|
||||
std::ostringstream oss1, oss2, oss3;
|
||||
caller.call("reg", {saddr, "0x0"}, -1, PUT);
|
||||
caller.call("setbit", {saddr, "1"}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "setbit [" + saddr + ", 1]\n");
|
||||
caller.call("reg", {saddr}, -1, GET, oss2);
|
||||
REQUIRE(oss2.str() == "reg 0x2\n");
|
||||
caller.call("setbit", {saddr, "2", "--validate"}, -1, PUT, oss2);
|
||||
REQUIRE(oss2.str() == "setbit [" + saddr + ", 2]\n");
|
||||
caller.call("reg", {saddr}, -1, GET, oss3);
|
||||
REQUIRE(oss3.str() == "reg 0x6\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.writeRegister(addr, prev_val[i], {i});
|
||||
det.writeRegister(addr, prev_val[i], false, {i});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3311,15 +3320,17 @@ TEST_CASE("CALLER::clearbit", "[.cmdcall]") {
|
||||
std::string saddr = ToStringHex(addr);
|
||||
auto prev_val = det.readRegister(addr);
|
||||
{
|
||||
std::ostringstream oss1, oss2;
|
||||
caller.call("reg", {saddr, "0x3"}, -1, PUT);
|
||||
std::ostringstream oss1, oss2, oss3;
|
||||
caller.call("reg", {saddr, "0x7"}, -1, PUT);
|
||||
caller.call("clearbit", {saddr, "1"}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "clearbit [" + saddr + ", 1]\n");
|
||||
caller.call("reg", {saddr}, -1, GET, oss2);
|
||||
REQUIRE(oss2.str() == "reg 0x1\n");
|
||||
caller.call("clearbit", {saddr, "2", "--validate"}, -1, PUT, oss2);
|
||||
REQUIRE(oss2.str() == "clearbit [" + saddr + ", 2]\n");
|
||||
caller.call("reg", {saddr}, -1, GET, oss3);
|
||||
REQUIRE(oss3.str() == "reg 0x1\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.writeRegister(addr, prev_val[i], {i});
|
||||
det.writeRegister(addr, prev_val[i], false, {i});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3339,7 +3350,7 @@ TEST_CASE("CALLER::getbit", "[.cmdcall]") {
|
||||
REQUIRE(oss1.str() == "getbit 1\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.writeRegister(addr, prev_val[i], {i});
|
||||
det.writeRegister(addr, prev_val[i], false, {i});
|
||||
}
|
||||
}
|
||||
// cannot check for eiger virtual server
|
||||
|
Reference in New Issue
Block a user