mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
defaultdac upto detector side, settings is undefined when none given
This commit is contained in:
parent
18bbfcaa5b
commit
de7f4489af
@ -412,6 +412,21 @@ class Detector {
|
||||
/** gets list of dac enums for this detector */
|
||||
std::vector<defs::dacIndex> getDacList() const;
|
||||
|
||||
/** [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Mythen3] */
|
||||
Result<int> getDefaultDac(defs::dacIndex index, Positions pos = {});
|
||||
|
||||
/** [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Mythen3] */
|
||||
void setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||
Positions pos = {});
|
||||
|
||||
/** [Jungfrau][Mythen3] */
|
||||
Result<int> getDefaultDac(defs::dacIndex index, defs::detectorSettings sett,
|
||||
Positions pos = {});
|
||||
|
||||
/** [Jungfrau][Mythen3] */
|
||||
void setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||
defs::detectorSettings sett, Positions pos = {});
|
||||
|
||||
/** [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Mythen3] */
|
||||
void setDefaultDacs(Positions pos = {});
|
||||
|
||||
@ -1779,6 +1794,10 @@ class Detector {
|
||||
void updateRxRateCorrections();
|
||||
void setNumberofUDPInterfaces_(int n, Positions pos);
|
||||
Result<int> getNumberofUDPInterfaces_(Positions pos) const;
|
||||
Result<int> getDefaultDac_(defs::dacIndex index,
|
||||
defs::detectorSettings sett, Positions pos = {});
|
||||
void setDefaultDac_(defs::dacIndex index, int defaultValue,
|
||||
defs::detectorSettings sett, Positions pos = {});
|
||||
};
|
||||
|
||||
} // namespace sls
|
||||
|
@ -1095,6 +1095,47 @@ std::string CmdProxy::DacValues(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::DefaultDac(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[dac name][value][(optional)setting]\n\tSets the default for "
|
||||
"that dac to this value.\n\t[Jungfrau][Mythen3] When settings is "
|
||||
"provided, it sets the default value only for that setting"
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() < 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
// optional settings
|
||||
if (args.size() == 2) {
|
||||
auto t = det->getDefaultDac(
|
||||
StringTo<defs::dacIndex>(args[0]),
|
||||
sls::StringTo<slsDetectorDefs::detectorSettings>(args[1]));
|
||||
os << ToString(args) << ' ' << OutString(t) << '\n';
|
||||
} else {
|
||||
auto t = det->getDefaultDac(StringTo<defs::dacIndex>(args[0]));
|
||||
os << args[0] << ' ' << OutString(t) << '\n';
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() < 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
// optional settings
|
||||
if (args.size() == 3) {
|
||||
det->setDefaultDac(
|
||||
StringTo<defs::dacIndex>(args[0]), StringTo<int>(args[1]),
|
||||
sls::StringTo<slsDetectorDefs::detectorSettings>(args[2]));
|
||||
} else {
|
||||
det->setDefaultDac(StringTo<defs::dacIndex>(args[0]),
|
||||
StringTo<int>(args[1]));
|
||||
}
|
||||
os << ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
/* acquisition */
|
||||
|
||||
std::string CmdProxy::ReceiverStatus(int action) {
|
||||
|
@ -817,6 +817,7 @@ class CmdProxy {
|
||||
{"daclist", &CmdProxy::daclist},
|
||||
{"dacvalues", &CmdProxy::DacValues},
|
||||
{"defaultdacs", &CmdProxy::defaultdacs},
|
||||
{"defaultdac", &CmdProxy::DefaultDac},
|
||||
|
||||
/* on chip dacs */
|
||||
{"vchip_comp_fe", &CmdProxy::vchip_comp_fe},
|
||||
@ -1094,6 +1095,7 @@ class CmdProxy {
|
||||
/* dacs */
|
||||
std::string Dac(int action);
|
||||
std::string DacValues(int action);
|
||||
std::string DefaultDac(int action);
|
||||
/* acquisition */
|
||||
std::string ReceiverStatus(int action);
|
||||
std::string DetectorStatus(int action);
|
||||
|
@ -620,6 +620,43 @@ std::vector<defs::dacIndex> Detector::getDacList() const {
|
||||
return retval;
|
||||
}
|
||||
|
||||
Result<int> Detector::getDefaultDac(defs::dacIndex index, Positions pos) {
|
||||
return getDefaultDac_(index, defs::UNDEFINED, pos);
|
||||
}
|
||||
|
||||
void Detector::setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||
Positions pos) {
|
||||
setDefaultDac_(index, defaultValue, defs::UNDEFINED, pos);
|
||||
}
|
||||
|
||||
Result<int> Detector::getDefaultDac(defs::dacIndex index,
|
||||
defs::detectorSettings sett,
|
||||
Positions pos) {
|
||||
if (sett == defs::UNDEFINED) {
|
||||
throw RuntimeError("Invalid settings given for default dac");
|
||||
}
|
||||
return getDefaultDac_(index, sett, pos);
|
||||
}
|
||||
|
||||
void Detector::setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||
defs::detectorSettings sett, Positions pos) {
|
||||
if (sett == defs::UNDEFINED) {
|
||||
throw RuntimeError("Invalid settings given for default dac");
|
||||
}
|
||||
setDefaultDac_(index, defaultValue, sett, pos);
|
||||
}
|
||||
|
||||
Result<int> Detector::getDefaultDac_(defs::dacIndex index,
|
||||
defs::detectorSettings sett,
|
||||
Positions pos) {
|
||||
return pimpl->Parallel(&Module::getDefaultDac, pos, index, sett);
|
||||
}
|
||||
|
||||
void Detector::setDefaultDac_(defs::dacIndex index, int defaultValue,
|
||||
defs::detectorSettings sett, Positions pos) {
|
||||
pimpl->Parallel(&Module::setDefaultDac, pos, index, defaultValue, sett);
|
||||
}
|
||||
|
||||
void Detector::setDefaultDacs(Positions pos) {
|
||||
pimpl->Parallel(&Module::setDefaultDacs, pos);
|
||||
}
|
||||
|
@ -618,6 +618,16 @@ int Module::getDAC(dacIndex index, bool mV) const {
|
||||
int args[]{static_cast<int>(index), static_cast<int>(mV), GET_FLAG};
|
||||
return sendToDetector<int>(F_SET_DAC, args);
|
||||
}
|
||||
int Module::getDefaultDac(slsDetectorDefs::dacIndex index,
|
||||
slsDetectorDefs::detectorSettings sett) {
|
||||
int args[]{static_cast<int>(index), static_cast<int>(sett)};
|
||||
return sendToDetector<int>(F_GET_DEFAULT_DAC, args);
|
||||
}
|
||||
void Module::setDefaultDac(slsDetectorDefs::dacIndex index, int defaultValue,
|
||||
defs::detectorSettings sett) {
|
||||
int args[]{static_cast<int>(index), static_cast<int>(sett), defaultValue};
|
||||
return sendToDetector(F_SET_DEFAULT_DAC, args, nullptr);
|
||||
}
|
||||
|
||||
void Module::setDefaultDacs() { sendToDetector(F_SET_DEFAULT_DACS); }
|
||||
|
||||
|
@ -148,7 +148,10 @@ class Module : public virtual slsDetectorDefs {
|
||||
int getMaxClockPhaseShift(int clkIndex) const;
|
||||
int getClockFrequency(int clkIndex) const;
|
||||
void setClockFrequency(int clkIndex, int value);
|
||||
/** [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Mythen3] */
|
||||
int getDefaultDac(slsDetectorDefs::dacIndex index,
|
||||
slsDetectorDefs::detectorSettings sett);
|
||||
void setDefaultDac(slsDetectorDefs::dacIndex index, int defaultValue,
|
||||
defs::detectorSettings sett);
|
||||
void setDefaultDacs();
|
||||
int getDAC(dacIndex index, bool mV) const;
|
||||
void setDAC(int val, dacIndex index, bool mV);
|
||||
|
@ -1407,6 +1407,58 @@ TEST_CASE("dacvalues", "[.cmd]") {
|
||||
REQUIRE_THROWS(proxy.Call("dacvalues", {}, -1, PUT));
|
||||
}
|
||||
|
||||
TEST_CASE("defaultdac", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
REQUIRE_THROWS(proxy.Call("defaultdac", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("defaultdac", {"blabla"}, -1, PUT));
|
||||
auto daclist = det.getDacList();
|
||||
for (auto it : daclist) {
|
||||
auto dacname = sls::ToString(it);
|
||||
auto prev_val = det.getDefaultDac(it);
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("defaultdac", {dacname, "1000"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == std::string("defaultdac [") + dacname +
|
||||
std::string(", 1000]\n"));
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("defaultdac", {dacname}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == std::string("defaultdac ") + dacname +
|
||||
std::string(" 1000\n"));
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setDefaultDac(it, prev_val[i], {i});
|
||||
}
|
||||
}
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type != defs::JUNGFRAU) {
|
||||
std::vector<defs::dacIndex> daclist = {defs::VB_COMP, defs::VREF_DS,
|
||||
defs::VREF_COMP};
|
||||
for (auto it : daclist) {
|
||||
auto dacname = sls::ToString(it);
|
||||
auto prev_val = det.getDefaultDac(it, defs::DYNAMICGAIN);
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("defaultdac", {dacname, "1000", "dynamicgain"}, -1,
|
||||
PUT, oss);
|
||||
REQUIRE(oss.str() == std::string("defaultdac [") + dacname +
|
||||
std::string(", dynamicgain, 1000]\n"));
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("defaultdac", {dacname}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == std::string("defaultdac [") + dacname +
|
||||
std::string(", dynamicgain] 1000\n"));
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setDefaultDac(it, prev_val[i], defs::DYNAMICGAIN, {i});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("defaultdacs", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
|
@ -231,6 +231,8 @@ enum detFuncs {
|
||||
F_GET_VETO_ALGORITHM,
|
||||
F_SET_VETO_ALGORITHM,
|
||||
F_GET_CHIP_VERSION,
|
||||
F_GET_DEFAULT_DAC,
|
||||
F_SET_DEFAULT_DAC,
|
||||
|
||||
NUM_DET_FUNCTIONS,
|
||||
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
||||
@ -568,6 +570,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_GET_VETO_ALGORITHM: return "F_GET_VETO_ALGORITHM";
|
||||
case F_SET_VETO_ALGORITHM: return "F_SET_VETO_ALGORITHM";
|
||||
case F_GET_CHIP_VERSION: return "F_GET_CHIP_VERSION";
|
||||
case F_GET_DEFAULT_DAC: return "F_GET_DEFAULT_DAC";
|
||||
case F_SET_DEFAULT_DAC: return "F_SET_DEFAULT_DAC";
|
||||
|
||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||
|
Loading…
x
Reference in New Issue
Block a user