mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-09-01 01:40:43 +02:00
dacs with power dac names should work and do not take in dac units to avoid ambiguity, test with 0 value for power dacs should fail, to do: implement power commands
This commit is contained in:
@@ -2,6 +2,8 @@ name: Run Simulator Tests on local RHEL8
|
||||
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- dev/xilinx_power_cmd
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
|
||||
@@ -2,6 +2,8 @@ name: Run Simulator Tests on local RHEL9
|
||||
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- dev/xilinx_power_cmd
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
|
||||
@@ -1363,6 +1363,15 @@ int processDACEnums(enum dacIndex ind, int val, bool mV) {
|
||||
LOG(logERROR, (mess));
|
||||
return retval;
|
||||
}
|
||||
if (!mV) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set power. Can get Vchip only in mV and not dac "
|
||||
"units.\n",
|
||||
ind);
|
||||
LOG(logERROR, (mess));
|
||||
return retval;
|
||||
}
|
||||
ret = getVchip(&retval, mess);
|
||||
return retval;
|
||||
|
||||
@@ -1370,8 +1379,8 @@ int processDACEnums(enum dacIndex ind, int val, bool mV) {
|
||||
if (val != GET_FLAG) {
|
||||
if (!mV) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not set vlimit. VLimit should be in "
|
||||
"mV and not dac units.\n");
|
||||
strcpy(mess, "Could not set vlimit. VLimit should be in mV and "
|
||||
"not dac units.\n");
|
||||
LOG(logERROR, (mess));
|
||||
return retval;
|
||||
}
|
||||
@@ -1388,18 +1397,18 @@ int processDACEnums(enum dacIndex ind, int val, bool mV) {
|
||||
serverDacIndex = getDACIndex(ind);
|
||||
if (ret == FAIL)
|
||||
return retval;
|
||||
if (val != GET_FLAG) {
|
||||
if (!mV) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set power. Power regulator %d should be in "
|
||||
"mV and not dac units.\n",
|
||||
ind);
|
||||
LOG(logERROR, (mess));
|
||||
return retval;
|
||||
}
|
||||
if (!mV) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set/get power. Power regulator %d is in mV and "
|
||||
"not dac units.\n",
|
||||
ind);
|
||||
LOG(logERROR, (mess));
|
||||
return retval;
|
||||
}
|
||||
if (val != GET_FLAG)
|
||||
ret = setPower(serverDacIndex, val, mess);
|
||||
} else
|
||||
else
|
||||
ret = getPower(serverDacIndex, &retval, mess);
|
||||
return retval;
|
||||
|
||||
@@ -1427,8 +1436,8 @@ int processDACEnums(enum dacIndex ind, int val, bool mV) {
|
||||
if (val != GET_FLAG) {
|
||||
if (!mV) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not set vlimit. VLimit should be in "
|
||||
"mV and not dac units.\n");
|
||||
strcpy(mess, "Could not set vlimit. VLimit should be in mV and "
|
||||
"not dac units.\n");
|
||||
LOG(logERROR, (mess));
|
||||
return retval;
|
||||
}
|
||||
@@ -1445,18 +1454,18 @@ int processDACEnums(enum dacIndex ind, int val, bool mV) {
|
||||
serverDacIndex = getDACIndex(ind);
|
||||
if (ret == FAIL)
|
||||
return retval;
|
||||
if (val != GET_FLAG) {
|
||||
if (!mV) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set power. Power regulator %d should be in "
|
||||
"mV and not dac units.\n",
|
||||
ind);
|
||||
LOG(logERROR, (mess));
|
||||
return retval;
|
||||
}
|
||||
if (!mV) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set/get power. Power regulator %d is in mV and "
|
||||
"not dac units.\n",
|
||||
ind);
|
||||
LOG(logERROR, (mess));
|
||||
return retval;
|
||||
}
|
||||
if (val != GET_FLAG)
|
||||
ret = setPower(serverDacIndex, val, mess);
|
||||
} else
|
||||
else
|
||||
ret = getPower(serverDacIndex, &retval, mess);
|
||||
return retval;
|
||||
|
||||
|
||||
@@ -92,6 +92,8 @@ class Caller {
|
||||
// applicable
|
||||
RegisterAddress getRegisterAddress(const std::string &saddr) const;
|
||||
BitAddress getBitAddress() const;
|
||||
defs::dacIndex parseDacIndex(int argIndex, bool isCtb);
|
||||
bool parseMV(int argIndex);
|
||||
|
||||
FunctionMap functions{
|
||||
{"list", &Caller::list},
|
||||
|
||||
@@ -524,21 +524,21 @@ __dac() {
|
||||
FCN_RETURN=""
|
||||
if [[ ${IS_GET} -eq 1 ]]; then
|
||||
if [[ "${cword}" == "2" ]]; then
|
||||
FCN_RETURN="`sls_detector_get daclist | sed -e 's/.*\[\(.*\)\].*/\1/' | sed 's/,//g'`"
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
if [[ "${cword}" == "3" ]]; then
|
||||
FCN_RETURN="mV mv"
|
||||
FCN_RETURN="0 1"
|
||||
fi
|
||||
fi
|
||||
if [[ ${IS_GET} -eq 0 ]]; then
|
||||
if [[ "${cword}" == "2" ]]; then
|
||||
FCN_RETURN="`sls_detector_get daclist | sed -e 's/.*\[\(.*\)\].*/\1/' | sed 's/,//g'`"
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
if [[ "${cword}" == "3" ]]; then
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
if [[ "${cword}" == "4" ]]; then
|
||||
FCN_RETURN="mV mv"
|
||||
FCN_RETURN="0 1"
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
|
||||
@@ -448,21 +448,21 @@ __dac() {
|
||||
FCN_RETURN=""
|
||||
if [[ ${IS_GET} -eq 1 ]]; then
|
||||
if [[ "${cword}" == "2" ]]; then
|
||||
FCN_RETURN="`sls_detector_get daclist | sed -e 's/.*\[\(.*\)\].*/\1/' | sed 's/,//g'`"
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
if [[ "${cword}" == "3" ]]; then
|
||||
FCN_RETURN="mV mv"
|
||||
FCN_RETURN="0 1"
|
||||
fi
|
||||
fi
|
||||
if [[ ${IS_GET} -eq 0 ]]; then
|
||||
if [[ "${cword}" == "2" ]]; then
|
||||
FCN_RETURN="`sls_detector_get daclist | sed -e 's/.*\[\(.*\)\].*/\1/' | sed 's/,//g'`"
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
if [[ "${cword}" == "3" ]]; then
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
if [[ "${cword}" == "4" ]]; then
|
||||
FCN_RETURN="mV mv"
|
||||
FCN_RETURN="0 1"
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
|
||||
@@ -2788,6 +2788,25 @@ clearbit:
|
||||
arg_types: [ std::string, std::string, special::validate ]
|
||||
|
||||
|
||||
dac:
|
||||
is_description: true
|
||||
actions:
|
||||
PUT:
|
||||
args:
|
||||
- argc: 2
|
||||
arg_types: [ std::string, int ]
|
||||
- argc: 3
|
||||
arg_types: [ std::string, int, bool ]
|
||||
GET:
|
||||
args:
|
||||
- argc: 1
|
||||
arg_types: [ std::string ]
|
||||
- argc: 2
|
||||
arg_types: [ std::string, bool ]
|
||||
|
||||
|
||||
|
||||
|
||||
################# special commands ##########################
|
||||
|
||||
virtual:
|
||||
@@ -3268,56 +3287,6 @@ extsig:
|
||||
cast_input: [ true, true ]
|
||||
output: [ 'args[0]', "' '", 'args[1]' ]
|
||||
|
||||
dac:
|
||||
help: "code: return GetHelpDacWrapper(cmd, args);\n" # this is a special case
|
||||
actions:
|
||||
GET:
|
||||
exceptions:
|
||||
- condition: "is_int(args[0]) && det->getDetectorType().squash() != defs::CHIPTESTBOARD && det->getDetectorType().squash() != defs::XILINX_CHIPTESTBOARD"
|
||||
message: '"Dac indices can only be used for chip test board. Use daclist to get list of dac names for current detector."'
|
||||
extra_variables:
|
||||
- name: dacIndex
|
||||
type: defs::dacIndex
|
||||
value: "((det->getDetectorType().squash() == defs::CHIPTESTBOARD || det->getDetectorType().squash() == defs::XILINX_CHIPTESTBOARD) && !is_int(args[0])) ? det->getDacIndex(args[0]) : StringTo<defs::dacIndex>(args[0])"
|
||||
function: getDAC
|
||||
require_det_id: true
|
||||
input_types: [ defs::dacIndex, bool ]
|
||||
cast_input: [ false, true ]
|
||||
args:
|
||||
- argc: 1
|
||||
arg_types: [defs::dacIndex]
|
||||
input: [ dacIndex, '"0"' ]
|
||||
output: [ 'args[0]', "' '", OutString(t) ]
|
||||
- argc: 2
|
||||
exceptions:
|
||||
- condition: "is_int(args[0]) && det->getDetectorType().squash() != defs::CHIPTESTBOARD && det->getDetectorType().squash() != defs::XILINX_CHIPTESTBOARD"
|
||||
message: '"Dac indices can only be used for chip test board. Use daclist to get list of dac names for current detector."'
|
||||
- condition: 'args[1] != "mv" && args[1] != "mV"'
|
||||
message: '"Unknown argument " + args[1] + ". Did you mean mV?"'
|
||||
arg_types: [defs::dacIndex, special::mv]
|
||||
input: [ dacIndex, '"1"' ]
|
||||
output: [ 'args[0]', "' '" , OutString(t), '" mV"' ]
|
||||
PUT:
|
||||
exceptions:
|
||||
- condition: "is_int(args[0]) && det->getDetectorType().squash() != defs::CHIPTESTBOARD && det->getDetectorType().squash() != defs::XILINX_CHIPTESTBOARD"
|
||||
message: '"Dac indices can only be used for chip test board. Use daclist to get list of dac names for current detector."'
|
||||
extra_variables:
|
||||
- name: dacIndex
|
||||
type: defs::dacIndex
|
||||
value: "((det->getDetectorType().squash() == defs::CHIPTESTBOARD || det->getDetectorType().squash() == defs::XILINX_CHIPTESTBOARD) && !is_int(args[0])) ? det->getDacIndex(args[0]) : StringTo<defs::dacIndex>(args[0])"
|
||||
function: setDAC
|
||||
require_det_id: true
|
||||
input_types: [ defs::dacIndex, int, bool ]
|
||||
cast_input: [ false, true, true ]
|
||||
args:
|
||||
- argc: 2
|
||||
arg_types: [defs::dacIndex, int]
|
||||
input: [ dacIndex, "args[1]", '"0"' ]
|
||||
output: [ "args[0]", "' '", "args[1]" ]
|
||||
- argc: 3
|
||||
arg_types: [defs::dacIndex, int, special::mv]
|
||||
input: [ dacIndex, "args[1]", '"1"' ]
|
||||
output: [ "args[0]", "' '", "args[1]", '" mV"' ]
|
||||
|
||||
resetdacs:
|
||||
help: "[(optional) hard] \n\t[Eiger][Jungfrau][Moench][Gotthard2][Mythen3]Reset dac values to the defaults. A 'hard' optional reset will reset the dacs to the hardcoded defaults in on-board detector server."
|
||||
|
||||
@@ -1772,155 +1772,64 @@ dac:
|
||||
GET:
|
||||
args:
|
||||
- arg_types:
|
||||
- defs::dacIndex
|
||||
- std::string
|
||||
argc: 1
|
||||
cast_input:
|
||||
- false
|
||||
- true
|
||||
cast_input: []
|
||||
check_det_id: false
|
||||
convert_det_id: true
|
||||
exceptions:
|
||||
- condition: is_int(args[0]) && det->getDetectorType().squash() != defs::CHIPTESTBOARD
|
||||
&& det->getDetectorType().squash() != defs::XILINX_CHIPTESTBOARD
|
||||
message: '"Dac indices can only be used for chip test board. Use daclist
|
||||
to get list of dac names for current detector."'
|
||||
extra_variables:
|
||||
- name: dacIndex
|
||||
type: defs::dacIndex
|
||||
value: '((det->getDetectorType().squash() == defs::CHIPTESTBOARD || det->getDetectorType().squash()
|
||||
== defs::XILINX_CHIPTESTBOARD) && !is_int(args[0])) ? det->getDacIndex(args[0])
|
||||
: StringTo<defs::dacIndex>(args[0])'
|
||||
function: getDAC
|
||||
input:
|
||||
- dacIndex
|
||||
- '"0"'
|
||||
input_types:
|
||||
- defs::dacIndex
|
||||
- bool
|
||||
output:
|
||||
- args[0]
|
||||
- ''' '''
|
||||
- OutString(t)
|
||||
require_det_id: true
|
||||
function: ''
|
||||
input: []
|
||||
input_types: []
|
||||
output: []
|
||||
require_det_id: false
|
||||
store_result_in_t: true
|
||||
- arg_types:
|
||||
- defs::dacIndex
|
||||
- special::mv
|
||||
- std::string
|
||||
- bool
|
||||
argc: 2
|
||||
cast_input:
|
||||
- false
|
||||
- true
|
||||
cast_input: []
|
||||
check_det_id: false
|
||||
convert_det_id: true
|
||||
exceptions:
|
||||
- condition: is_int(args[0]) && det->getDetectorType().squash() != defs::CHIPTESTBOARD
|
||||
&& det->getDetectorType().squash() != defs::XILINX_CHIPTESTBOARD
|
||||
message: '"Dac indices can only be used for chip test board. Use daclist
|
||||
to get list of dac names for current detector."'
|
||||
- condition: args[1] != "mv" && args[1] != "mV"
|
||||
message: '"Unknown argument " + args[1] + ". Did you mean mV?"'
|
||||
extra_variables:
|
||||
- name: dacIndex
|
||||
type: defs::dacIndex
|
||||
value: '((det->getDetectorType().squash() == defs::CHIPTESTBOARD || det->getDetectorType().squash()
|
||||
== defs::XILINX_CHIPTESTBOARD) && !is_int(args[0])) ? det->getDacIndex(args[0])
|
||||
: StringTo<defs::dacIndex>(args[0])'
|
||||
function: getDAC
|
||||
input:
|
||||
- dacIndex
|
||||
- '"1"'
|
||||
input_types:
|
||||
- defs::dacIndex
|
||||
- bool
|
||||
output:
|
||||
- args[0]
|
||||
- ''' '''
|
||||
- OutString(t)
|
||||
- '" mV"'
|
||||
require_det_id: true
|
||||
function: ''
|
||||
input: []
|
||||
input_types: []
|
||||
output: []
|
||||
require_det_id: false
|
||||
store_result_in_t: true
|
||||
PUT:
|
||||
args:
|
||||
- arg_types:
|
||||
- defs::dacIndex
|
||||
- std::string
|
||||
- int
|
||||
argc: 2
|
||||
cast_input:
|
||||
- false
|
||||
- true
|
||||
- true
|
||||
cast_input: []
|
||||
check_det_id: false
|
||||
convert_det_id: true
|
||||
exceptions:
|
||||
- condition: is_int(args[0]) && det->getDetectorType().squash() != defs::CHIPTESTBOARD
|
||||
&& det->getDetectorType().squash() != defs::XILINX_CHIPTESTBOARD
|
||||
message: '"Dac indices can only be used for chip test board. Use daclist
|
||||
to get list of dac names for current detector."'
|
||||
extra_variables:
|
||||
- name: dacIndex
|
||||
type: defs::dacIndex
|
||||
value: '((det->getDetectorType().squash() == defs::CHIPTESTBOARD || det->getDetectorType().squash()
|
||||
== defs::XILINX_CHIPTESTBOARD) && !is_int(args[0])) ? det->getDacIndex(args[0])
|
||||
: StringTo<defs::dacIndex>(args[0])'
|
||||
function: setDAC
|
||||
input:
|
||||
- dacIndex
|
||||
- args[1]
|
||||
- '"0"'
|
||||
input_types:
|
||||
- defs::dacIndex
|
||||
- int
|
||||
- bool
|
||||
output:
|
||||
- args[0]
|
||||
- ''' '''
|
||||
- args[1]
|
||||
require_det_id: true
|
||||
function: ''
|
||||
input: []
|
||||
input_types: []
|
||||
output: []
|
||||
require_det_id: false
|
||||
store_result_in_t: false
|
||||
- arg_types:
|
||||
- defs::dacIndex
|
||||
- int
|
||||
- special::mv
|
||||
argc: 3
|
||||
cast_input:
|
||||
- false
|
||||
- true
|
||||
- true
|
||||
check_det_id: false
|
||||
convert_det_id: true
|
||||
exceptions:
|
||||
- condition: is_int(args[0]) && det->getDetectorType().squash() != defs::CHIPTESTBOARD
|
||||
&& det->getDetectorType().squash() != defs::XILINX_CHIPTESTBOARD
|
||||
message: '"Dac indices can only be used for chip test board. Use daclist
|
||||
to get list of dac names for current detector."'
|
||||
extra_variables:
|
||||
- name: dacIndex
|
||||
type: defs::dacIndex
|
||||
value: '((det->getDetectorType().squash() == defs::CHIPTESTBOARD || det->getDetectorType().squash()
|
||||
== defs::XILINX_CHIPTESTBOARD) && !is_int(args[0])) ? det->getDacIndex(args[0])
|
||||
: StringTo<defs::dacIndex>(args[0])'
|
||||
function: setDAC
|
||||
input:
|
||||
- dacIndex
|
||||
- args[1]
|
||||
- '"1"'
|
||||
input_types:
|
||||
- defs::dacIndex
|
||||
- std::string
|
||||
- int
|
||||
- bool
|
||||
output:
|
||||
- args[0]
|
||||
- ''' '''
|
||||
- args[1]
|
||||
- '" mV"'
|
||||
require_det_id: true
|
||||
argc: 3
|
||||
cast_input: []
|
||||
check_det_id: false
|
||||
convert_det_id: true
|
||||
function: ''
|
||||
input: []
|
||||
input_types: []
|
||||
output: []
|
||||
require_det_id: false
|
||||
store_result_in_t: false
|
||||
command_name: dac
|
||||
function_alias: dac
|
||||
help: 'code: return GetHelpDacWrapper(cmd, args);
|
||||
|
||||
'
|
||||
help: ''
|
||||
infer_action: true
|
||||
is_description: true
|
||||
dacindex:
|
||||
actions:
|
||||
GET:
|
||||
|
||||
@@ -2229,199 +2229,6 @@ std::string Caller::configtransceiver(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string Caller::dac(int action) {
|
||||
|
||||
std::ostringstream os;
|
||||
// print help
|
||||
if (action == slsDetectorDefs::HELP_ACTION) {
|
||||
return GetHelpDacWrapper(cmd, args);
|
||||
}
|
||||
|
||||
// check if action and arguments are valid
|
||||
if (action == slsDetectorDefs::GET_ACTION) {
|
||||
if (1 && args.size() != 1 && args.size() != 2) {
|
||||
throw RuntimeError("Wrong number of arguments for action GET");
|
||||
}
|
||||
|
||||
if (args.size() == 1) {
|
||||
defs::dacIndex dacIndex =
|
||||
((det->getDetectorType().squash() == defs::CHIPTESTBOARD ||
|
||||
det->getDetectorType().squash() ==
|
||||
defs::XILINX_CHIPTESTBOARD) &&
|
||||
!is_int(args[0]))
|
||||
? det->getDacIndex(args[0])
|
||||
: StringTo<defs::dacIndex>(args[0]);
|
||||
try {
|
||||
StringTo<bool>("0");
|
||||
} catch (...) {
|
||||
throw RuntimeError("Could not convert argument 1 to bool");
|
||||
}
|
||||
}
|
||||
|
||||
if (args.size() == 2) {
|
||||
defs::dacIndex dacIndex =
|
||||
((det->getDetectorType().squash() == defs::CHIPTESTBOARD ||
|
||||
det->getDetectorType().squash() ==
|
||||
defs::XILINX_CHIPTESTBOARD) &&
|
||||
!is_int(args[0]))
|
||||
? det->getDacIndex(args[0])
|
||||
: StringTo<defs::dacIndex>(args[0]);
|
||||
try {
|
||||
StringTo<bool>("1");
|
||||
} catch (...) {
|
||||
throw RuntimeError("Could not convert argument 1 to bool");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else if (action == slsDetectorDefs::PUT_ACTION) {
|
||||
if (1 && args.size() != 2 && args.size() != 3) {
|
||||
throw RuntimeError("Wrong number of arguments for action PUT");
|
||||
}
|
||||
|
||||
if (args.size() == 2) {
|
||||
defs::dacIndex dacIndex =
|
||||
((det->getDetectorType().squash() == defs::CHIPTESTBOARD ||
|
||||
det->getDetectorType().squash() ==
|
||||
defs::XILINX_CHIPTESTBOARD) &&
|
||||
!is_int(args[0]))
|
||||
? det->getDacIndex(args[0])
|
||||
: StringTo<defs::dacIndex>(args[0]);
|
||||
try {
|
||||
StringTo<int>(args[1]);
|
||||
} 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) {
|
||||
defs::dacIndex dacIndex =
|
||||
((det->getDetectorType().squash() == defs::CHIPTESTBOARD ||
|
||||
det->getDetectorType().squash() ==
|
||||
defs::XILINX_CHIPTESTBOARD) &&
|
||||
!is_int(args[0]))
|
||||
? det->getDacIndex(args[0])
|
||||
: StringTo<defs::dacIndex>(args[0]);
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
throw RuntimeError("INTERNAL ERROR: Invalid action: supported actions "
|
||||
"are ['GET', 'PUT']");
|
||||
}
|
||||
|
||||
// generate code for each action
|
||||
if (action == slsDetectorDefs::GET_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
defs::dacIndex dacIndex =
|
||||
((det->getDetectorType().squash() == defs::CHIPTESTBOARD ||
|
||||
det->getDetectorType().squash() ==
|
||||
defs::XILINX_CHIPTESTBOARD) &&
|
||||
!is_int(args[0]))
|
||||
? det->getDacIndex(args[0])
|
||||
: StringTo<defs::dacIndex>(args[0]);
|
||||
if (is_int(args[0]) &&
|
||||
det->getDetectorType().squash() != defs::CHIPTESTBOARD &&
|
||||
det->getDetectorType().squash() != defs::XILINX_CHIPTESTBOARD) {
|
||||
throw RuntimeError(
|
||||
"Dac indices can only be used for chip test board. Use "
|
||||
"daclist to get list of dac names for current detector.");
|
||||
}
|
||||
auto arg1 = StringTo<bool>("0");
|
||||
auto t = det->getDAC(dacIndex, arg1, std::vector<int>{det_id});
|
||||
os << args[0] << ' ' << OutString(t) << '\n';
|
||||
}
|
||||
|
||||
if (args.size() == 2) {
|
||||
defs::dacIndex dacIndex =
|
||||
((det->getDetectorType().squash() == defs::CHIPTESTBOARD ||
|
||||
det->getDetectorType().squash() ==
|
||||
defs::XILINX_CHIPTESTBOARD) &&
|
||||
!is_int(args[0]))
|
||||
? det->getDacIndex(args[0])
|
||||
: StringTo<defs::dacIndex>(args[0]);
|
||||
if (is_int(args[0]) &&
|
||||
det->getDetectorType().squash() != defs::CHIPTESTBOARD &&
|
||||
det->getDetectorType().squash() != defs::XILINX_CHIPTESTBOARD) {
|
||||
throw RuntimeError(
|
||||
"Dac indices can only be used for chip test board. Use "
|
||||
"daclist to get list of dac names for current detector.");
|
||||
}
|
||||
if (args[1] != "mv" && args[1] != "mV") {
|
||||
throw RuntimeError("Unknown argument " + args[1] +
|
||||
". Did you mean mV?");
|
||||
}
|
||||
auto arg1 = StringTo<bool>("1");
|
||||
auto t = det->getDAC(dacIndex, arg1, std::vector<int>{det_id});
|
||||
os << args[0] << ' ' << OutString(t) << " mV" << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
if (action == slsDetectorDefs::PUT_ACTION) {
|
||||
if (args.size() == 2) {
|
||||
defs::dacIndex dacIndex =
|
||||
((det->getDetectorType().squash() == defs::CHIPTESTBOARD ||
|
||||
det->getDetectorType().squash() ==
|
||||
defs::XILINX_CHIPTESTBOARD) &&
|
||||
!is_int(args[0]))
|
||||
? det->getDacIndex(args[0])
|
||||
: StringTo<defs::dacIndex>(args[0]);
|
||||
if (is_int(args[0]) &&
|
||||
det->getDetectorType().squash() != defs::CHIPTESTBOARD &&
|
||||
det->getDetectorType().squash() != defs::XILINX_CHIPTESTBOARD) {
|
||||
throw RuntimeError(
|
||||
"Dac indices can only be used for chip test board. Use "
|
||||
"daclist to get list of dac names for current detector.");
|
||||
}
|
||||
auto arg1 = StringTo<int>(args[1]);
|
||||
auto arg2 = StringTo<bool>("0");
|
||||
det->setDAC(dacIndex, arg1, arg2, std::vector<int>{det_id});
|
||||
os << args[0] << ' ' << args[1] << '\n';
|
||||
}
|
||||
|
||||
if (args.size() == 3) {
|
||||
defs::dacIndex dacIndex =
|
||||
((det->getDetectorType().squash() == defs::CHIPTESTBOARD ||
|
||||
det->getDetectorType().squash() ==
|
||||
defs::XILINX_CHIPTESTBOARD) &&
|
||||
!is_int(args[0]))
|
||||
? det->getDacIndex(args[0])
|
||||
: StringTo<defs::dacIndex>(args[0]);
|
||||
if (is_int(args[0]) &&
|
||||
det->getDetectorType().squash() != defs::CHIPTESTBOARD &&
|
||||
det->getDetectorType().squash() != defs::XILINX_CHIPTESTBOARD) {
|
||||
throw RuntimeError(
|
||||
"Dac indices can only be used for chip test board. Use "
|
||||
"daclist to get list of dac names for current detector.");
|
||||
}
|
||||
auto arg1 = StringTo<int>(args[1]);
|
||||
auto arg2 = StringTo<bool>("1");
|
||||
det->setDAC(dacIndex, arg1, arg2, std::vector<int>{det_id});
|
||||
os << args[0] << ' ' << args[1] << " mV" << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string Caller::dacindex(int action) {
|
||||
|
||||
std::ostringstream os;
|
||||
|
||||
@@ -415,6 +415,8 @@ class Caller {
|
||||
// applicable
|
||||
RegisterAddress getRegisterAddress(const std::string &saddr) const;
|
||||
BitAddress getBitAddress() const;
|
||||
defs::dacIndex parseDacIndex(int argIndex, bool isCtb);
|
||||
bool parseMV(int argIndex);
|
||||
|
||||
FunctionMap functions{
|
||||
{"list", &Caller::list},
|
||||
|
||||
@@ -1809,4 +1809,84 @@ BitAddress Caller::getBitAddress() const {
|
||||
throw RuntimeError("Invalid number of parameters for bit address.");
|
||||
}
|
||||
|
||||
std::string Caller::dac(int action) {
|
||||
std::ostringstream os;
|
||||
|
||||
if (action == defs::HELP_ACTION) {
|
||||
if (args.size() == 0)
|
||||
os << GetHelpDac("");
|
||||
else
|
||||
os << args[0] << GetHelpDac(args[0]) << '\n';
|
||||
return os.str();
|
||||
}
|
||||
|
||||
bool isCtb = false;
|
||||
auto detType = det->getDetectorType().squash(defs::GENERIC);
|
||||
if (detType == defs::CHIPTESTBOARD ||
|
||||
detType == defs::XILINX_CHIPTESTBOARD) {
|
||||
isCtb = true;
|
||||
}
|
||||
|
||||
if (action == defs::GET_ACTION) {
|
||||
auto index = parseDacIndex(0, isCtb);
|
||||
auto mV = parseMV(1);
|
||||
auto t = det->getDAC(index, mV, std::vector<int>{det_id});
|
||||
os << args[0] << ' ' << OutString(t) << (mV ? " mV" : "") << '\n';
|
||||
}
|
||||
|
||||
else if (action == defs::PUT_ACTION) {
|
||||
auto index = parseDacIndex(0, isCtb);
|
||||
if (args.size() < 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
auto val = StringTo<int>(args[1]);
|
||||
auto mV = parseMV(2);
|
||||
det->setDAC(index, val, mV, std::vector<int>{det_id});
|
||||
os << args[0] << ' ' << args[1] << (mV ? " mV" : "") << '\n';
|
||||
}
|
||||
|
||||
else {
|
||||
throw RuntimeError("Unknown action");
|
||||
}
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
||||
defs::dacIndex Caller::parseDacIndex(int argIndex, bool isCtb) {
|
||||
if (argIndex >= (int)args.size()) {
|
||||
throw RuntimeError("Invalid arguments. DAC index is required.");
|
||||
}
|
||||
auto arg = args[argIndex];
|
||||
|
||||
if (isCtb) {
|
||||
// dac index or power dacs
|
||||
if (is_int(arg) || arg == "v_a" || arg == "v_b" || arg == "v_c" ||
|
||||
arg == "v_d" || arg == "v_io" || arg == "v_chip") {
|
||||
return StringTo<defs::dacIndex>(arg);
|
||||
}
|
||||
// dac name for ctb gui
|
||||
return det->getDacIndex(arg);
|
||||
}
|
||||
|
||||
// not ctb
|
||||
if (is_int(arg)) {
|
||||
throw RuntimeError("DAC index is not supported for your detector. "
|
||||
"Please use dac name. Use daclist command to get "
|
||||
"the list of dac names for your detector.");
|
||||
}
|
||||
return StringTo<defs::dacIndex>(arg);
|
||||
}
|
||||
|
||||
bool Caller::parseMV(int argIndex) {
|
||||
if (argIndex < (int)args.size()) {
|
||||
auto arg = args[argIndex];
|
||||
if (arg != "mv" && arg != "mV") {
|
||||
throw RuntimeError("Unknown argument " + arg +
|
||||
". Did you mean mV?");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace sls
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace sls {
|
||||
|
||||
std::string GetHelpDac(std::string dac) {
|
||||
if (sls::is_int(dac)) {
|
||||
if (dac.empty() || sls::is_int(dac)) {
|
||||
return std::string("[dac name] [dac or mV value] [(optional unit) mV] "
|
||||
"\n\t[Ctb] Use dac index for dac name.");
|
||||
}
|
||||
@@ -280,24 +280,52 @@ std::string GetHelpDac(std::string dac) {
|
||||
return std::string(
|
||||
"[dac or mV value][(optional unit) mV] \n\t[Moench] Dac for 7");
|
||||
}
|
||||
if (dac == "vtgstv") {
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
if (dac == "vtgstv") { return std::string(""); }
|
||||
// clang-format on
|
||||
if (dac == "v_a") {
|
||||
return std::string(
|
||||
"[mV value] mV \n\t[Ctb][Xilinx Ctb] Dac for Power supply a. Can "
|
||||
"only be set in mV. Default to minimum values. To switch off must "
|
||||
"switch off power rails using 'power' command.\n\t[Ctb] Changes "
|
||||
"vchip (max of power supply voltages + 200mV).");
|
||||
}
|
||||
if (dac == "v_b") {
|
||||
return std::string(
|
||||
"[mV value] mV \n\t[Ctb][Xilinx Ctb] Dac for Power supply b. Can "
|
||||
"only be set in mV. Default to minimum values. To switch off must "
|
||||
"switch off power rails using 'power' command.\n\t[Ctb] Changes "
|
||||
"vchip (max of power supply voltages + 200mV).");
|
||||
}
|
||||
if (dac == "v_c") {
|
||||
return std::string(
|
||||
"[mV value] mV \n\t[Ctb][Xilinx Ctb] Dac for Power supply c. Can "
|
||||
"only be set in mV. Default to minimum values. To switch off must "
|
||||
"switch off power rails using 'power' command.\n\t[Ctb] Changes "
|
||||
"vchip (max of power supply voltages + 200mV).");
|
||||
}
|
||||
if (dac == "v_d") {
|
||||
return std::string(
|
||||
"[mV value] mV \n\t[Ctb][Xilinx Ctb] Dac for Power supply d. Can "
|
||||
"only be set in mV. Default to minimum values. To switch off must "
|
||||
"switch off power rails using 'power' command.\n\t[Ctb] Changes "
|
||||
"vchip (max of power supply voltages + 200mV).");
|
||||
}
|
||||
if (dac == "v_io") {
|
||||
return std::string(
|
||||
"[mV value] mV \n\t[Ctb][Xilinx Ctb] Dac for Power supply IO. Can "
|
||||
"only be set in mV. Default to minimum values. To switch off must "
|
||||
"switch off power rails using 'power' command.\n\t[Ctb] Changes "
|
||||
"vchip (max of power supply voltages + 200mV).");
|
||||
}
|
||||
if (dac == "v_chip") {
|
||||
return std::string("mV \n\t[Ctb] Dac for Vchip. Can only get. Default "
|
||||
"to minimum values. Vchip is set in the background "
|
||||
"when v_a, b, c, d or io are set.");
|
||||
}
|
||||
|
||||
throw sls::RuntimeError("Unknown dac command");
|
||||
}
|
||||
|
||||
std::string GetHelpDacWrapper(const std::string &cmd,
|
||||
const std::vector<std::string> &args) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (args.size() == 0) {
|
||||
os << GetHelpDac(std::to_string(0)) << '\n';
|
||||
} else {
|
||||
os << args[0] << ' ' << GetHelpDac(args[0]) << '\n';
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
} // namespace sls
|
||||
|
||||
@@ -7,7 +7,4 @@ namespace sls {
|
||||
|
||||
std::string GetHelpDac(std::string dac);
|
||||
|
||||
std::string GetHelpDacWrapper(const std::string &cmd,
|
||||
const std::vector<std::string> &args);
|
||||
|
||||
} // namespace sls
|
||||
|
||||
@@ -594,13 +594,15 @@ TEST_CASE("dac", "[.detectorintegration][.dacs]") {
|
||||
defs::V_POWER_A, defs::V_POWER_B, defs::V_POWER_C,
|
||||
defs::V_POWER_D, defs::V_POWER_IO};
|
||||
for (size_t iPower = 0; iPower < names.size(); ++iPower) {
|
||||
auto prev_val = det.getDAC(indices[iPower]);
|
||||
auto prev_val = det.getDAC(indices[iPower], true);
|
||||
|
||||
// this is the first command touching power dacs, should not be
|
||||
// -100
|
||||
if (det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||
if (det_type == defs::XILINX_CHIPTESTBOARD ||
|
||||
det_type == defs::CHIPTESTBOARD) {
|
||||
REQUIRE(prev_val.any(-100) == false);
|
||||
REQUIRE(prev_val.any(-1) == false);
|
||||
REQUIRE(prev_val.any(0) == false);
|
||||
}
|
||||
|
||||
REQUIRE_THROWS(
|
||||
@@ -613,6 +615,11 @@ TEST_CASE("dac", "[.detectorintegration][.dacs]") {
|
||||
caller.call("dac", {names[iPower], "0"}, -1, PUT));
|
||||
REQUIRE_THROWS(
|
||||
caller.call("dac", {names[iPower], "4096"}, -1, PUT));
|
||||
// not mV
|
||||
REQUIRE_THROWS(
|
||||
caller.call("dac", {names[iPower], "1200"}, -1, PUT));
|
||||
REQUIRE_THROWS(caller.call("dac", {names[iPower]}, -1, GET));
|
||||
|
||||
// min
|
||||
if (names[iPower] == "v_io")
|
||||
REQUIRE_THROWS(caller.call(
|
||||
@@ -634,33 +641,19 @@ TEST_CASE("dac", "[.detectorintegration][.dacs]") {
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"dac", {names[iPower], "2469", "mV"}, -1, PUT));
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("dac", {names[iPower], "800", "mV"}, -1, PUT,
|
||||
oss);
|
||||
REQUIRE(oss.str() == "dac " + names[iPower] + " 800 mV\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss1, oss2;
|
||||
caller.call("dac", {names[iPower], "1200", "mV"}, -1, PUT,
|
||||
oss1);
|
||||
REQUIRE(oss1.str() ==
|
||||
"dac " + names[iPower] + " 1200 mV\n");
|
||||
caller.call("dac", {names[iPower], "1200", "mV"}, -1, GET,
|
||||
oss2);
|
||||
caller.call("dac", {names[iPower], "mV"}, -1, GET, oss2);
|
||||
REQUIRE(oss2.str() ==
|
||||
"dac " + names[iPower] + " 1200 mV\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss1, oss2;
|
||||
caller.call("dac", {names[iPower], "1200"}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "dac " + names[iPower] + " 1200\n");
|
||||
caller.call("dac", {names[iPower], "1200"}, -1, GET, oss2);
|
||||
REQUIRE(oss2.str() == "dac " + names[iPower] + " 1200\n");
|
||||
}
|
||||
// Reset all dacs to previous value
|
||||
for (int imod = 0; imod != det.size(); ++imod) {
|
||||
det.setDAC(indices[iPower], prev_val[imod], false, {imod});
|
||||
det.setDAC(indices[iPower], prev_val[imod], true, {imod});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ void test_dac_caller(defs::dacIndex index, const std::string &dacname,
|
||||
std::vector<std::string> args = {dac, value};
|
||||
if (mV)
|
||||
args.push_back("mV");
|
||||
std::cout << "args:" << ToString(args) << std::endl;
|
||||
caller.call("dac", args, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == std::string("dac ") + dac + " " + value +
|
||||
(mV ? " mV\n" : "\n"));
|
||||
@@ -57,7 +58,7 @@ void test_dac_caller(defs::dacIndex index, const std::string &dacname,
|
||||
std::vector<std::string> args = {dac};
|
||||
if (mV)
|
||||
args.push_back("mV");
|
||||
caller.call(dacname, args, -1, GET, oss);
|
||||
caller.call("dac", args, -1, GET, oss);
|
||||
REQUIRE(oss.str() ==
|
||||
"dac " + dac + " " + value + (mV ? " mV\n" : "\n"));
|
||||
}
|
||||
|
||||
@@ -121,8 +121,7 @@ TEST_CASE("Convert BitAddress using classes", "[support]") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Output operator gives same result as string",
|
||||
"[support]") {
|
||||
TEST_CASE("Output operator gives same result as string", "[support]") {
|
||||
{
|
||||
RegisterAddress addr{0x3456af};
|
||||
std::ostringstream os;
|
||||
|
||||
Reference in New Issue
Block a user