reset default dacs

This commit is contained in:
2021-07-29 16:34:38 +02:00
parent e28d19f5be
commit 9c03e83ef1
17 changed files with 131 additions and 39 deletions

View File

@ -427,8 +427,10 @@ class Detector {
void setDefaultDac(defs::dacIndex index, int defaultValue,
defs::detectorSettings sett, Positions pos = {});
/** [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Mythen3] */
void setDefaultDacs(Positions pos = {});
/** [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Mythen3]
reset to defaults, hardReset will reset to hardcoded defaults on on-board
server */
void resetToDefaultDacs(const bool hardReset, Positions pos = {});
Result<int> getDAC(defs::dacIndex index, bool mV = false,
Positions pos = {}) const;

View File

@ -1095,6 +1095,37 @@ std::string CmdProxy::DacValues(int action) {
return os.str();
}
std::string CmdProxy::ResetDacs(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[(optional) hard] "
"\n\t[Eiger][Jungfrau][Gotthard][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."
<< '\n';
} else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get");
} else if (action == defs::PUT_ACTION) {
bool hardReset = false;
if (args.size() == 1) {
if (args[0] != "hard") {
throw sls::RuntimeError("Unknown argument " + args[0] +
". Did you mean hard?");
}
hardReset = true;
} else if (args.size() > 1) {
WrongNumberOfParameters(1);
}
det->resetToDefaultDacs(hardReset, std::vector<int>{det_id});
os << "successful\n";
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::DefaultDac(int action) {
std::ostringstream os;
os << cmd << ' ';
@ -1111,10 +1142,12 @@ std::string CmdProxy::DefaultDac(int action) {
if (args.size() == 2) {
auto t = det->getDefaultDac(
StringTo<defs::dacIndex>(args[0]),
sls::StringTo<slsDetectorDefs::detectorSettings>(args[1]));
sls::StringTo<slsDetectorDefs::detectorSettings>(args[1]),
std::vector<int>{det_id});
os << args[0] << ' ' << args[1] << ' ' << OutString(t) << '\n';
} else {
auto t = det->getDefaultDac(StringTo<defs::dacIndex>(args[0]));
auto t = det->getDefaultDac(StringTo<defs::dacIndex>(args[0]),
std::vector<int>{det_id});
os << args[0] << ' ' << OutString(t) << '\n';
}
} else if (action == defs::PUT_ACTION) {
@ -1125,7 +1158,8 @@ std::string CmdProxy::DefaultDac(int action) {
if (args.size() == 3) {
det->setDefaultDac(
StringTo<defs::dacIndex>(args[0]), StringTo<int>(args[1]),
sls::StringTo<slsDetectorDefs::detectorSettings>(args[2]));
sls::StringTo<slsDetectorDefs::detectorSettings>(args[2]),
std::vector<int>{det_id});
os << args[0] << ' ' << args[2] << ' ' << args[1] << '\n';
} else {
det->setDefaultDac(StringTo<defs::dacIndex>(args[0]),

View File

@ -671,6 +671,8 @@ class CmdProxy {
{"vipre_cds", "dac"},
{"ibias_sfp", "dac"},
{"defaultdacs", "resetdacs"},
/* acquisition */
{"busy", "clearbusy"},
{"receiver", "rx_status"},
@ -816,7 +818,7 @@ class CmdProxy {
{"dac", &CmdProxy::Dac},
{"daclist", &CmdProxy::daclist},
{"dacvalues", &CmdProxy::DacValues},
{"defaultdacs", &CmdProxy::defaultdacs},
{"resetdacs", &CmdProxy::ResetDacs},
{"defaultdac", &CmdProxy::DefaultDac},
/* on chip dacs */
@ -1095,6 +1097,7 @@ class CmdProxy {
/* dacs */
std::string Dac(int action);
std::string DacValues(int action);
std::string ResetDacs(int action);
std::string DefaultDac(int action);
/* acquisition */
std::string ReceiverStatus(int action);
@ -1383,10 +1386,6 @@ class CmdProxy {
daclist, getDacList,
"\n\tGets the list of commands for every dac for this detector.");
EXECUTE_SET_COMMAND(defaultdacs, setDefaultDacs,
"\n\t[Eiger][Jungfrau][Gotthard][Moench][Gotthard2]["
"Mythen3]Sets default dacs on to the detector.");
/* on chip dacs */
INTEGER_USER_IND_COMMAND(
vchip_comp_fe, getOnChipDAC, setOnChipDAC, StringTo<int>,

View File

@ -657,8 +657,8 @@ void Detector::setDefaultDac_(defs::dacIndex index, int defaultValue,
pimpl->Parallel(&Module::setDefaultDac, pos, index, defaultValue, sett);
}
void Detector::setDefaultDacs(Positions pos) {
pimpl->Parallel(&Module::setDefaultDacs, pos);
void Detector::resetToDefaultDacs(const bool hardReset, Positions pos) {
pimpl->Parallel(&Module::resetToDefaultDacs, hardReset, pos);
}
Result<int> Detector::getDAC(defs::dacIndex index, bool mV,

View File

@ -629,7 +629,10 @@ void Module::setDefaultDac(slsDetectorDefs::dacIndex index, int defaultValue,
return sendToDetector(F_SET_DEFAULT_DAC, args, nullptr);
}
void Module::setDefaultDacs() { sendToDetector(F_SET_DEFAULT_DACS); }
void Module::resetToDefaultDacs(const bool hardReset) {
sendToDetector(F_RESET_TO_DEFAULT_DACS, static_cast<int>(hardReset),
nullptr);
}
void Module::setDAC(int val, dacIndex index, bool mV) {
int args[]{static_cast<int>(index), static_cast<int>(mV), val};

View File

@ -152,7 +152,7 @@ class Module : public virtual slsDetectorDefs {
slsDetectorDefs::detectorSettings sett);
void setDefaultDac(slsDetectorDefs::dacIndex index, int defaultValue,
defs::detectorSettings sett);
void setDefaultDacs();
void resetToDefaultDacs(const bool hardReset);
int getDAC(dacIndex index, bool mV) const;
void setDAC(int val, dacIndex index, bool mV);
bool getPowerChip() const;

View File

@ -1466,16 +1466,17 @@ TEST_CASE("defaultdac", "[.cmd]") {
}
}
TEST_CASE("defaultdacs", "[.cmd]") {
TEST_CASE("resetdacs", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type != defs::CHIPTESTBOARD) {
REQUIRE_THROWS(proxy.Call("defaultdacs", {}, -1, GET));
REQUIRE_NOTHROW(proxy.Call("defaultdacs", {}, -1, PUT));
REQUIRE_THROWS(proxy.Call("resetdacs", {}, -1, GET));
REQUIRE_NOTHROW(proxy.Call("resetdacs", {}, -1, PUT));
REQUIRE_NOTHROW(proxy.Call("resetdacs", {"hard"}, -1, PUT));
} else {
REQUIRE_THROWS(proxy.Call("defaultdacs", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("defaultdacs", {}, -1, PUT));
REQUIRE_THROWS(proxy.Call("resetdacs", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("resetdacs", {}, -1, PUT));
}
}