This commit is contained in:
2021-08-10 17:26:26 +02:00
parent c716a87935
commit fce35e35a1
17 changed files with 486 additions and 78 deletions

View File

@ -959,6 +959,69 @@ std::string CmdProxy::ExternalSignal(int action) {
return os.str();
}
std::string CmdProxy::CurrentSource(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[0|1]\n\t[Gotthard2] Enable or disable current source. Default "
"is disabled.\n[0|1] [fix|nofix] [select source] "
"[normal|low]\n\t[Jungfrau] Disable or enable current source "
"with some parameters. The select source is 0-63 for chipv1.0 "
"and a 64 bit mask for chipv1.1. To disable, one needs only one "
"argument '0'."
<< '\n';
} else if (action == defs::GET_ACTION) {
if (args.size() != 0) {
WrongNumberOfParameters(0);
}
auto t = det->getCurrentSource(std::vector<int>{det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() == 1) {
det->setCurrentsource(
defs::currentSrcParameters(StringTo<bool>(args[0])));
} else if (args.size() >= 3) {
// scan fix
bool fix = false;
if (args[1] == "fix") {
fix = true;
} else if (args[1] == "nofix") {
fix = false;
} else {
throw sls::RuntimeError("Invalid argument: " + args[1] +
". Did you mean fix or nofix?");
}
if (args.size() == 3) {
det->setCurrentsource(defs::currentSrcParameters(
StringTo<bool>(args[0]), fix, StringTo<int64_t>(args[2])));
} else if (args.size() == 4) {
bool normalCurrent = false;
if (args[3] == "normal") {
normalCurrent = true;
} else if (args[3] == "low") {
normalCurrent = false;
} else {
throw sls::RuntimeError("Invalid argument: " + args[3] +
". Did you mean normal or low?");
}
det->setCurrentsource(defs::currentSrcParameters(
StringTo<bool>(args[0]), fix, StringTo<int64_t>(args[2]),
normalCurrent));
} else {
throw sls::RuntimeError(
"Invalid number of parareters for this command.");
}
} else {
throw sls::RuntimeError(
"Invalid number of parareters for this command.");
}
os << ToString(args) << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
/** temperature */
std::string CmdProxy::TemperatureValues(int action) {
std::ostringstream os;

View File

@ -803,6 +803,7 @@ class CmdProxy {
{"extsig", &CmdProxy::ExternalSignal},
{"parallel", &CmdProxy::parallel},
{"filterresistor", &CmdProxy::filterresistor},
{"currentsource", &CmdProxy::CurrentSource},
/** temperature */
{"templist", &CmdProxy::templist},
@ -951,7 +952,6 @@ class CmdProxy {
{"vetofile", &CmdProxy::VetoFile},
{"burstmode", &CmdProxy::BurstMode},
{"cdsgain", &CmdProxy::cdsgain},
{"currentsource", &CmdProxy::currentsource},
{"timingsource", &CmdProxy::timingsource},
{"veto", &CmdProxy::veto},
{"vetostream", &CmdProxy::VetoStreaming},
@ -1097,6 +1097,7 @@ class CmdProxy {
std::string MaxClockPhaseShift(int action);
std::string ClockDivider(int action);
std::string ExternalSignal(int action);
std::string CurrentSource(int action);
/** temperature */
std::string TemperatureValues(int action);
/* dacs */
@ -1921,11 +1922,6 @@ class CmdProxy {
"[0, 1]\n\t[Gotthard2] Enable or disable CDS gain. Default "
"is disabled.");
INTEGER_COMMAND_VEC_ID(
currentsource, getCurrentSource, setCurrentSource, StringTo<int>,
"[0, 1]\n\t[Gotthard2] Enable or disable current source. "
"Default is disabled.");
INTEGER_COMMAND_VEC_ID(
timingsource, getTimingSource, setTimingSource,
sls::StringTo<slsDetectorDefs::timingSourceType>,

View File

@ -707,6 +707,14 @@ void Detector::setFilterResistor(int value, Positions pos) {
pimpl->Parallel(&Module::setFilterResistor, pos, value);
}
Result<defs::currentSrcParameters>
Detector::getCurrentSource(Positions pos) const {
return pimpl->Parallel(&Module::getCurrentSource, pos);
}
void Detector::setCurrentSource(defs::currentSrcParameters par, Positions pos) {
pimpl->Parallel(&Module::setCurrentSource, pos, par);
}
// Acquisition
void Detector::acquire() { pimpl->acquire(); }
@ -1620,14 +1628,6 @@ void Detector::setCDSGain(bool value, Positions pos) {
pimpl->Parallel(&Module::setCDSGain, pos, value);
}
Result<bool> Detector::getCurrentSource(Positions pos) const {
return pimpl->Parallel(&Module::getCurrentSource, pos);
}
void Detector::setCurrentSource(bool value, Positions pos) {
pimpl->Parallel(&Module::setCurrentSource, pos, value);
}
Result<defs::timingSourceType> Detector::getTimingSource(Positions pos) const {
return pimpl->Parallel(&Module::getTimingSource, pos);
}

View File

@ -712,6 +712,14 @@ void Module::setFilterResistor(int value) {
sendToDetector(F_SET_FILTER_RESISTOR, value, nullptr);
}
defs::currentSrcParameters Module::getCurrentSource() const {
return sendToDetector<defs::currentSrcParameters>(F_GET_CURRENT_SOURCE);
}
void Module::setCurrentSource(defs::currentSrcParameters par) {
sendToDetector(F_SET_CURRENT_SOURCE, par, nullptr);
}
// Acquisition
void Module::startReceiver() {
@ -1914,14 +1922,6 @@ void Module::setCDSGain(bool value) {
sendToDetector(F_SET_CDS_GAIN, static_cast<int>(value), nullptr);
}
bool Module::getCurrentSource() const {
return sendToDetector<int>(F_GET_CURRENT_SOURCE);
}
void Module::setCurrentSource(bool value) {
sendToDetector(F_SET_CURRENT_SOURCE, static_cast<int>(value), nullptr);
}
slsDetectorDefs::timingSourceType Module::getTimingSource() const {
return sendToDetector<timingSourceType>(F_GET_TIMING_SOURCE);
}

View File

@ -172,7 +172,8 @@ class Module : public virtual slsDetectorDefs {
void setParallelMode(const bool enable);
int getFilterResistor() const;
void setFilterResistor(int value);
defs::currentSrcParameters getCurrentSource() const;
void setCurrentSource(defs::currentSrcParameters par);
/**************************************************
* *
* Acquisition *
@ -412,8 +413,6 @@ class Module : public virtual slsDetectorDefs {
void setBurstMode(burstMode value);
bool getCDSGain() const;
void setCDSGain(bool value);
bool getCurrentSource() const;
void setCurrentSource(bool value);
slsDetectorDefs::timingSourceType getTimingSource() const;
void setTimingSource(slsDetectorDefs::timingSourceType value);
bool getVeto() const;