Commit 4cf72f2e authored by Jerome Carnis's avatar Jerome Carnis 🦊
Browse files

deviceEigerP11.py: change constants to private, add docstring

parent 2ff29c4a
Pipeline #28534 passed with stages
in 11 minutes and 43 seconds
......@@ -33,10 +33,10 @@ from kamzik3.macro.step import Step, StepDeviceMethod
from kamzik3.snippets.snippetsDecorators import expose_method
FRAMES_PER_FILE_SCAN = 1000
FRAMES_PER_FILE_LIVE = 1000000
_FRAMES_PER_FILE_SCAN = 1000
_FRAMES_PER_FILE_LIVE = 1_000_000
# any large number is ok, images are not saved in the live-view mode
MAX_ACQUISITION_RATE = units.Quantity(100, "Hz")
_MAX_ACQUISITION_RATE = units.Quantity(100, "Hz")
# according to Jan Meyer, 10ms is the lowest frame time
......@@ -48,7 +48,12 @@ class InterfaceStatus(IntEnum):
class TriggerMode(IntEnum):
"""The trigger modes can be found in Eiger2 documentation (v1.5.0)."""
"""
The trigger modes can be found in Eiger2 documentation (v1.5.0).
Note that this mapping is valid only at P11, which uses a custom Tango device server
instead of what FS-EC provides.
"""
EXTE = 0
EXTS = 1
......@@ -171,12 +176,12 @@ class DeviceTangoEigerDetector(DeviceTango):
)
converted_exposure = self.detector.to_device_unit("FrameTime", Exposure)
min_frame_time = (1 / MAX_ACQUISITION_RATE).to(
min_frame_time = (1 / _MAX_ACQUISITION_RATE).to(
self.get_value("FrameTime", key=UNIT)
)
if converted_exposure < min_frame_time:
self.logger.error(
f"Can't acquire data faster than {MAX_ACQUISITION_RATE}, "
f"Can't acquire data faster than {_MAX_ACQUISITION_RATE}, "
"defaulting to it"
)
frame_time = min_frame_time.m
......@@ -209,7 +214,7 @@ class DeviceTangoEigerDetector(DeviceTango):
["FileWriter", "Mode", VALUE], InterfaceStatus.DISABLED.value
)
self.set_attribute(
["FileWriter", "NimagesPerFile", VALUE], FRAMES_PER_FILE_LIVE
["FileWriter", "NimagesPerFile", VALUE], _FRAMES_PER_FILE_LIVE
)
if self.eiger_stream is not None:
self.logger.info("EigerStream disabled")
......@@ -218,12 +223,12 @@ class DeviceTangoEigerDetector(DeviceTango):
)
converted_exposure = self.detector.to_device_unit("FrameTime", Exposure)
min_frame_time = (1 / MAX_ACQUISITION_RATE).to(
min_frame_time = (1 / _MAX_ACQUISITION_RATE).to(
self.get_value("FrameTime", key=UNIT)
)
if converted_exposure < min_frame_time:
self.logger.error(
f"Can't acquire data faster than {MAX_ACQUISITION_RATE}, "
f"Can't acquire data faster than {_MAX_ACQUISITION_RATE}, "
"defaulting to it"
)
frame_time = min_frame_time.m
......@@ -233,11 +238,11 @@ class DeviceTangoEigerDetector(DeviceTango):
self.set_attribute(["FrameTime", VALUE], frame_time)
self.set_attribute(["CountTime", VALUE], float(converted_exposure.m))
self.set_attribute(["Ntrigger", VALUE], 1)
self.set_attribute(["Nimages", VALUE], FRAMES_PER_FILE_LIVE)
self.set_attribute(["Nimages", VALUE], _FRAMES_PER_FILE_LIVE)
self.Arm()
self.Trigger()
self.set_value(
ATTR_FRAME_COUNT, self.get_value(ATTR_FRAME_COUNT) + FRAMES_PER_FILE_LIVE
ATTR_FRAME_COUNT, self.get_value(ATTR_FRAME_COUNT) + _FRAMES_PER_FILE_LIVE
)
@expose_method()
......@@ -389,7 +394,7 @@ class EigerSwScanner(DeviceScanner):
scanner_input: StepDeviceMethod,
scanner_attributes: Dict[str, Any],
parent_macro: Macro,
):
) -> StepDeviceMethod:
if kamzik3.session is None:
raise DeviceError(
"kamzik session is None, can't get the device MacroServer"
......@@ -430,12 +435,12 @@ class EigerSwScanner(DeviceScanner):
converted_exposure = units.Quantity(params["Exposure"]).to(
self.detector.get_value("FrameTime", key=UNIT)
)
min_frame_time = (1 / MAX_ACQUISITION_RATE).to(
min_frame_time = (1 / _MAX_ACQUISITION_RATE).to(
self.get_value("FrameTime", key=UNIT)
)
if converted_exposure < min_frame_time:
self.logger.error(
f"Can't acquire data faster than {MAX_ACQUISITION_RATE}, "
f"Can't acquire data faster than {_MAX_ACQUISITION_RATE}, "
"defaulting to it"
)
frame_time = min_frame_time.m
......@@ -461,7 +466,7 @@ class EigerSwScanner(DeviceScanner):
)
self.detector.set_attribute(["FileWriter", "NamePattern", VALUE], path)
self.detector.set_attribute(
["FileWriter", "NimagesPerFile", VALUE], FRAMES_PER_FILE_SCAN
["FileWriter", "NimagesPerFile", VALUE], _FRAMES_PER_FILE_SCAN
)
self.detector.Arm()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment