jungfrau: gainmode

This commit is contained in:
2021-08-02 12:44:57 +02:00
parent 526aa3273e
commit 9ed3a294ce
20 changed files with 298 additions and 16 deletions

View File

@ -1164,6 +1164,17 @@ class Detector {
* Only applicable for chipv1.0.
*/
void setStorageCellDelay(ns value, Positions pos = {});
/** list of possible gainmode */
std::vector<defs::gainMode> getGainModeList() const;
/** [Jungfrau]*/
Result<defs::gainMode> getGainMode(Positions pos = {}) const;
/** [Jungfrau] Options: NORMAL_GAIN_MODE, FORCE_SWITCH_G1, FORCE_SWITCH_G2\n
*/
void setGainMode(const defs::gainMode mode, Positions pos = {});
///@{
/** @name Gotthard Specific */

View File

@ -717,8 +717,6 @@ class CmdProxy {
{"resmat", "partialreset"},
/* Jungfrau Specific */
{"mode", "mode"},
/* Gotthard Specific */
/* Gotthard2 Specific */
/* Mythen3 Specific */
@ -931,6 +929,7 @@ class CmdProxy {
{"storagecells", &CmdProxy::storagecells},
{"storagecell_start", &CmdProxy::storagecell_start},
{"storagecell_delay", &CmdProxy::storagecell_delay},
{"gainmode", &CmdProxy::gainmode},
/* Gotthard Specific */
{"roi", &CmdProxy::ROI},
@ -1866,6 +1865,11 @@ class CmdProxy {
"Additional time delay between 2 consecutive exposures in burst mode "
"(resolution of 25ns). Only applicable for chipv1.0. For advanced users only.");
INTEGER_COMMAND_VEC_ID(
gainmode, getGainMode, setGainMode,
sls::StringTo<slsDetectorDefs::gainMode>,
"[forceswitchg1, forceswitchg2]\n\t[Jungfrau] Gain mode.");
/* Gotthard Specific */
TIME_GET_COMMAND(exptimel, getExptimeLeft,
"[(optional unit) ns|us|ms|s]\n\t[Gotthard] Exposure time "

View File

@ -1483,6 +1483,26 @@ void Detector::setStorageCellDelay(ns value, Positions pos) {
pimpl->Parallel(&Module::setStorageCellDelay, pos, value.count());
}
std::vector<defs::gainMode> Detector::getGainModeList() const {
switch (getDetectorType().squash()) {
case defs::JUNGFRAU:
return std::vector<defs::gainMode>{defs::NORMAL_GAIN_MODE,
defs::FORCE_SWITCH_G1,
defs::FORCE_SWITCH_G2};
break;
default:
throw RuntimeError("Gain mode is not implemented for this detector.");
}
}
Result<defs::gainMode> Detector::getGainMode(Positions pos) const {
return pimpl->Parallel(&Module::getGainMode, pos);
}
void Detector::setGainMode(const defs::gainMode mode, Positions pos) {
pimpl->Parallel(&Module::setGainMode, pos, mode);
}
// Gotthard Specific
Result<defs::ROI> Detector::getROI(Positions pos) const {

View File

@ -1601,6 +1601,14 @@ void Module::setStorageCellDelay(int64_t value) {
sendToDetector(F_SET_STORAGE_CELL_DELAY, value, nullptr);
}
slsDetectorDefs::gainMode Module::getGainMode() const {
return sendToDetector<gainMode>(F_GET_GAIN_MODE);
}
void Module::setGainMode(const slsDetectorDefs::gainMode mode) {
sendToDetector(F_SET_GAIN_MODE, mode, nullptr);
}
// Gotthard Specific
slsDetectorDefs::ROI Module::getROI() const {

View File

@ -369,6 +369,8 @@ class Module : public virtual slsDetectorDefs {
void setStorageCellStart(int pos);
int64_t getStorageCellDelay() const;
void setStorageCellDelay(int64_t value);
gainMode getGainMode() const;
void setGainMode(const gainMode mode);
/**************************************************
* *

View File

@ -408,4 +408,38 @@ TEST_CASE("storagecell_delay", "[.cmd]") {
REQUIRE_THROWS(proxy.Call("storagecell_delay", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("storagecell_delay", {"0"}, -1, PUT));
}
}
}
TEST_CASE("gainmode", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU) {
auto prev_val = det.getGainMode();
{
std::ostringstream oss;
proxy.Call("gainmode", {"forceswitchg1"}, -1, PUT, oss);
REQUIRE(oss.str() == "gainmode forceswitchg1\n");
}
{
std::ostringstream oss;
proxy.Call("gainmode", {}, -1, GET, oss);
REQUIRE(oss.str() == "gainmode forceswitchg1\n");
}
{
std::ostringstream oss;
proxy.Call("gainmode", {"forceswitchg2"}, -1, PUT, oss);
REQUIRE(oss.str() == "gainmode forceswitchg2\n");
}
{
std::ostringstream oss;
proxy.Call("gainmode", {"normal"}, -1, PUT, oss);
REQUIRE(oss.str() == "gainmode normal\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setGainMode(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("gainmode", {}, -1, GET));
}
}