mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
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:
@ -1803,6 +1803,10 @@ class Detector {
|
||||
* Pattern *
|
||||
* *
|
||||
* ************************************************/
|
||||
/** [CTB][Mythen3] Gets the pattern file name including path of the last
|
||||
* pattern uploaded. \n Returns an empty if nothing was uploaded or via a
|
||||
* server default file*/
|
||||
Result<std::string> getPatterFileName(Positions pos = {}) const;
|
||||
|
||||
/** [CTB][Mythen3] Loads ASCII pattern file directly to server
|
||||
* (instead of executing line by line)*/
|
||||
|
@ -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). "
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
|
@ -309,15 +309,15 @@ TEST_CASE("voltagename", "[.cmd]") {
|
||||
REQUIRE_THROWS(proxy.Call("voltagename", {"5", "bname"}, -1, PUT));
|
||||
{
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(proxy.Call("voltagename", {str_voltage_index, "bname"},
|
||||
-1, PUT, oss));
|
||||
REQUIRE_NOTHROW(proxy.Call(
|
||||
"voltagename", {str_voltage_index, "bname"}, -1, PUT, oss));
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(
|
||||
proxy.Call("voltagename", {str_voltage_index}, -1, GET, oss));
|
||||
REQUIRE(oss.str() ==
|
||||
std::string("voltagename ") + str_voltage_index + " bname\n");
|
||||
REQUIRE(oss.str() == std::string("voltagename ") +
|
||||
str_voltage_index + " bname\n");
|
||||
}
|
||||
det.setVoltageName(ind, prev);
|
||||
|
||||
@ -401,15 +401,15 @@ TEST_CASE("slowadcname", "[.cmd]") {
|
||||
REQUIRE_THROWS(proxy.Call("slowadcname", {"8", "bname"}, -1, PUT));
|
||||
{
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(proxy.Call("slowadcname", {str_slowadc_index, "bname"},
|
||||
-1, PUT, oss));
|
||||
REQUIRE_NOTHROW(proxy.Call(
|
||||
"slowadcname", {str_slowadc_index, "bname"}, -1, PUT, oss));
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(
|
||||
proxy.Call("slowadcname", {str_slowadc_index}, -1, GET, oss));
|
||||
REQUIRE(oss.str() ==
|
||||
std::string("slowadcname ") + str_slowadc_index + " bname\n");
|
||||
REQUIRE(oss.str() == std::string("slowadcname ") +
|
||||
str_slowadc_index + " bname\n");
|
||||
}
|
||||
det.setSlowAdcName(ind, prev);
|
||||
|
||||
|
@ -19,6 +19,18 @@ using test::PUT;
|
||||
|
||||
/* Pattern */
|
||||
|
||||
TEST_CASE("patfname", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MYTHEN3) {
|
||||
REQUIRE_THROWS(proxy.Call("patfname", {}, -1, PUT));
|
||||
REQUIRE_NOTHROW(proxy.Call("patfname", {}, -1, GET));
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("patfname", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("pattern", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
|
Reference in New Issue
Block a user