2. Dev/add jf pedestal feature (#807)

This commit is contained in:
2023-09-29 11:25:58 +02:00
committed by GitHub
parent 72bec5d62e
commit d003a6d8e0
27 changed files with 751 additions and 109 deletions

View File

@ -2105,6 +2105,55 @@ std::string CmdProxy::TemperatureEvent(int action) {
return os.str();
}
std::string CmdProxy::PedestalMode(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << " [frames<uint8_t>] [loops<uint16_t>]\n\t\t[Jungfrau] "
"Enable pedestal mode. \n\t\tThe number of frames or triggers is "
"overwritten by: \n\t\t(#pedestal_frames x #pedestal_loops x 2). "
"\n\t\tIn auto timing mode or in trigger mode with #frames > 1, "
"\n\t\t#frames is overwritten and #triggers = 1, \n\t\telse "
"#triggers is overwritten and #frames = 1. \n\t\tOne cannot set "
"#frames, #triggers or timing mode in pedestal mode (exception "
"thrown).\n\n";
os << cmd
<< " [0]\n\t\t[Jungfrau] Disable pedestal "
"mode.\n\t\tDisabling pedestal mode will set back the normal "
"mode values of #frames and #triggers."
<< '\n';
} else if (action == defs::GET_ACTION) {
if (args.size() != 0) {
WrongNumberOfParameters(0);
}
auto t = det->getPedestalMode(std::vector<int>{det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
// disable
if (args.size() == 1) {
if (args[0] != "0") {
throw RuntimeError(
"Unknown argument " + args[0] +
". Did you mean '0' to disable pedestal mode?");
}
det->setPedestalMode(defs::pedestalParameters());
}
// enable
else if (args.size() == 2) {
uint8_t frames = StringTo<uint8_t>(args[0]);
uint16_t loops = StringTo<uint16_t>(args[1]);
det->setPedestalMode(defs::pedestalParameters(frames, loops));
} else {
throw RuntimeError(
"Invalid number of parareters for this command.");
}
os << ToString(args) << '\n';
} else {
throw RuntimeError("Unknown action");
}
return os.str();
}
/* Gotthard Specific */
std::string CmdProxy::ROI(int action) {

View File

@ -1187,6 +1187,7 @@ class CmdProxy {
{"storagecell_delay", &CmdProxy::storagecell_delay},
{"gainmode", &CmdProxy::gainmode},
{"filtercells", &CmdProxy::filtercells},
{"pedestalmode", &CmdProxy::PedestalMode},
/* Gotthard Specific */
{"roi", &CmdProxy::ROI},
@ -1399,6 +1400,7 @@ class CmdProxy {
std::string DataStream(int action);
/* Jungfrau Specific */
std::string TemperatureEvent(int action);
std::string PedestalMode(int action);
/* Gotthard Specific */
std::string ROI(int action);
/* Gotthard2 Specific */

View File

@ -1760,6 +1760,16 @@ void Detector::setNumberOfFilterCells(int cell, Positions pos) {
pimpl->Parallel(&Module::setNumberOfFilterCells, pos, cell);
}
Result<defs::pedestalParameters>
Detector::getPedestalMode(Positions pos) const {
return pimpl->Parallel(&Module::getPedestalMode, pos);
}
void Detector::setPedestalMode(const defs::pedestalParameters par,
Positions pos) {
pimpl->Parallel(&Module::setPedestalMode, pos, par);
}
// Gotthard Specific
Result<defs::ROI> Detector::getROI(Positions pos) const {

View File

@ -1940,6 +1940,20 @@ void Module::setNumberOfFilterCells(int value) {
sendToDetector(F_SET_NUM_FILTER_CELLS, value, nullptr);
}
defs::pedestalParameters Module::getPedestalMode() const {
return sendToDetector<defs::pedestalParameters>(F_GET_PEDESTAL_MODE);
}
void Module::setPedestalMode(const defs::pedestalParameters par) {
sendToDetector(F_SET_PEDESTAL_MODE, par, nullptr);
if (shm()->useReceiverFlag) {
auto value = getNumberOfFrames();
sendToReceiver(F_RECEIVER_SET_NUM_FRAMES, value, nullptr);
value = getNumberOfTriggers();
sendToReceiver(F_SET_RECEIVER_NUM_TRIGGERS, value, nullptr);
}
}
// Gotthard Specific
slsDetectorDefs::ROI Module::getROI() const {

View File

@ -419,6 +419,8 @@ class Module : public virtual slsDetectorDefs {
void setGainMode(const gainMode mode);
int getNumberOfFilterCells() const;
void setNumberOfFilterCells(int value);
defs::pedestalParameters getPedestalMode() const;
void setPedestalMode(defs::pedestalParameters par);
/**************************************************
* *