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

@ -156,4 +156,28 @@ def test_period(virtual_jf_detectors):
d.period = t
assert d.period == 10e-6
def test_gainmode(virtual_jf_detectors):
d = ExperimentalDetector()
assert d.gainMode == gainMode.NORMAL_GAIN_MODE
gain_list = [
gainMode.NORMAL_GAIN_MODE,
gainMode.FORCE_SWITCH_G1,
gainMode.FORCE_SWITCH_G2,
]
# Set all viable gain for Jungfrau to make sure nothing is crashing
for gain in gain_list:
d.gainMode = gain
assert d.gainMode == gain
d.setGainMode(gainMode.FORCE_SWITCH_G1, [1])
assert d.gainMode == [
gainMode.NORMAL_GAIN_MODE,
gainMode.FORCE_SWITCH_G1,
gainMode.FORCE_SWITCH_G2,
]
d.gainMode = gainMode.FORCE_SWITCH_G1
assert d.gainMode == gainMode.FORCE_SWITCH_G1

View File

@ -2165,6 +2165,26 @@ class Detector(CppDetectorApi):
def selinterface(self, i):
ut.set_using_dict(self.selectUDPInterface, i)
@property
def gainmodelist(self):
"""List of gainmode implemented for this detector."""
return self.getGainModeList()
@property
def gainmode(self):
"""
[Jungfrau] Detector gain mode. Enum: gainMode
Note
-----
[Jungfrau] NORMAL_GAIN_MODE, FORCE_SWITCH_G1, FORCE_SWITCH_G2
"""
return element_if_equal(self.getGainMode())
@gainmode.setter
def gainmode(self, value):
self.setGainMode(value)
"""
---------------------------<<<Gotthard2 specific>>>---------------------------
"""

View File

@ -1002,6 +1002,17 @@ void init_det(py::module &m) {
(void (Detector::*)(sls::ns, sls::Positions)) &
Detector::setStorageCellDelay,
py::arg(), py::arg() = Positions{})
.def("getGainModeList",
(std::vector<defs::gainMode>(Detector::*)() const) &
Detector::getGainModeList)
.def("getGainMode",
(Result<defs::gainMode>(Detector::*)(sls::Positions) const) &
Detector::getGainMode,
py::arg() = Positions{})
.def("setGainMode",
(void (Detector::*)(defs::gainMode, sls::Positions)) &
Detector::setGainMode,
py::arg(), py::arg() = Positions{})
.def("getROI",
(Result<defs::ROI>(Detector::*)(sls::Positions) const) &
Detector::getROI,

View File

@ -305,4 +305,10 @@ void init_enums(py::module &m) {
.value("DEFAULT_ALGORITHM",
slsDetectorDefs::vetoAlgorithm::DEFAULT_ALGORITHM)
.export_values();
py::enum_<slsDetectorDefs::gainMode>(Defs, "gainMode")
.value("NORMAL_GAIN_MODE", slsDetectorDefs::gainMode::NORMAL_GAIN_MODE)
.value("FORCE_SWITCH_G1", slsDetectorDefs::gainMode::FORCE_SWITCH_G1)
.value("FORCE_SWITCH_G2", slsDetectorDefs::gainMode::FORCE_SWITCH_G2)
.export_values();
}