added patfname command to save the file the last pttern was loaded from (#770)

* added patfname command to save the file the last pttern was loaded from
This commit is contained in:
2023-06-22 09:08:48 +02:00
committed by GitHub
parent e18c191247
commit 58cdb5bd20
19 changed files with 120 additions and 28 deletions

View File

@ -1224,6 +1224,7 @@ class CmdProxy {
/* Pattern */
{"pattern", &CmdProxy::Pattern},
{"patfname", &CmdProxy::patfname},
{"savepattern", &CmdProxy::savepattern},
{"defaultpattern", &CmdProxy::defaultpattern},
{"patioctrl", &CmdProxy::patioctrl},
@ -1721,7 +1722,8 @@ class CmdProxy {
"[voltagename1 voltagename2 .. voltagename4] \n\t\t[ChipTestBoard] Set "
"the list of voltage names for this board.");
CTB_SINGLE_DACNAME(voltagename, getVoltageName, setVoltageName, defs::V_POWER_A,
CTB_SINGLE_DACNAME(voltagename, getVoltageName, setVoltageName,
defs::V_POWER_A,
"[0-4][name] \n\t\t[ChipTestBoard] Set "
"the voltage at the given position to the given name.");
@ -1734,7 +1736,8 @@ class CmdProxy {
"[slowadcname1 slowadcname2 .. slowadcname7] \n\t\t[ChipTestBoard] Set "
"the list of slowadc names for this board.");
CTB_SINGLE_DACNAME(slowadcname, getSlowAdcName, setSlowAdcName, defs::SLOW_ADC0,
CTB_SINGLE_DACNAME(slowadcname, getSlowAdcName, setSlowAdcName,
defs::SLOW_ADC0,
"[0-7][name] \n\t\t[ChipTestBoard] Set "
"the slowadc at the given position to the given name.");
@ -2473,6 +2476,11 @@ class CmdProxy {
/* Pattern */
GET_COMMAND(patfname, getPatterFileName,
"\n\t[Ctb][Mythen3] Gets the pattern file name including "
"path of the last pattern uploaded. Returns an empty if "
"nothing was uploaded or via a server default file");
EXECUTE_SET_COMMAND_NOID_1ARG(
savepattern, savePattern,
"[fname]\n\t[Ctb][Mythen3] Saves pattern to file (ascii). "

View File

@ -2335,7 +2335,7 @@ defs::dacIndex Detector::getVoltageIndex(const std::string &name) const {
}
void Detector::setVoltageName(const defs::dacIndex index,
const std::string &name) {
const std::string &name) {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named powers only for CTB");
pimpl->setCtbVoltageName(index, name);
@ -2370,7 +2370,7 @@ defs::dacIndex Detector::getSlowAdcIndex(const std::string &name) const {
}
void Detector::setSlowAdcName(const defs::dacIndex index,
const std::string &name) {
const std::string &name) {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named SlowAdcs only for CTB");
pimpl->setCtbSlowAdcName(index, name);
@ -2384,16 +2384,20 @@ std::string Detector::getSlowAdcName(const defs::dacIndex i) const {
// Pattern
Result<std::string> Detector::getPatterFileName(Positions pos) const {
return pimpl->Parallel(&Module::getPatterFileName, pos);
}
void Detector::setPattern(const std::string &fname, Positions pos) {
Pattern pat;
pat.load(fname);
pat.validate();
setPattern(pat, pos);
pimpl->Parallel(&Module::setPattern, pos, pat, fname);
}
void Detector::setPattern(const Pattern &pat, Positions pos) {
pat.validate();
pimpl->Parallel(&Module::setPattern, pos, pat);
pimpl->Parallel(&Module::setPattern, pos, pat, "");
}
void Detector::savePattern(const std::string &fname) {

View File

@ -2051,7 +2051,7 @@ std::string DetectorImpl::getCtbVoltageName(const defs::dacIndex i) const {
}
void DetectorImpl::setCtbVoltageName(const defs::dacIndex index,
const std::string &name) {
const std::string &name) {
ctb_shm()->setVoltageName(static_cast<int>(index - defs::V_POWER_A), name);
}
@ -2068,7 +2068,7 @@ std::string DetectorImpl::getCtbSlowAdcName(const defs::dacIndex i) const {
}
void DetectorImpl::setCtbSlowAdcName(const defs::dacIndex index,
const std::string &name) {
const std::string &name) {
ctb_shm()->setSlowAdcName(static_cast<int>(index - defs::SLOW_ADC0), name);
}

View File

@ -2478,9 +2478,23 @@ void Module::setLEDEnable(bool enable) {
}
// Pattern
std::string Module::getPatterFileName() const {
char retval[MAX_STR_LENGTH]{};
sendToDetector(F_GET_PATTERN_FILE_NAME, nullptr, retval);
return retval;
}
void Module::setPattern(const Pattern &pat) {
sendToDetector(F_SET_PATTERN, pat.data(), pat.size(), nullptr, 0);
void Module::setPattern(const Pattern &pat, const std::string &fname) {
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_SET_PATTERN);
client.Send(pat.data(), pat.size());
char args[MAX_STR_LENGTH]{};
strcpy_safe(args, fname.c_str());
client.Send(args);
if (client.Receive<int>() == FAIL) {
throw DetectorError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
}
Pattern Module::getPattern() {

View File

@ -525,7 +525,8 @@ class Module : public virtual slsDetectorDefs {
* Pattern *
* *
* ************************************************/
void setPattern(const Pattern &pat);
std::string getPatterFileName() const;
void setPattern(const Pattern &pat, const std::string &fname);
Pattern getPattern();
void loadDefaultPattern();
uint64_t getPatternIOControl() const;