Commit 71af3313 authored by Jerome Carnis's avatar Jerome Carnis 🦊
Browse files

deviceEigerP11.py: use an enum for the Eiger interface status

parent d158b8df
Pipeline #28410 failed with stages
in 5 minutes and 4 seconds
......@@ -30,6 +30,13 @@ from kamzik3.macro.scan import Scan
from kamzik3.snippets.snippetsDecorators import expose_method
class InterfaceStatus(IntEnum):
"""Status of the Eiger interface (filewriter, eigerstream, monitor)."""
ENABLED = 0
DISABLED = 1
class TriggerMode(IntEnum):
"""The trigger modes can be found in Eiger documentation."""
......@@ -84,9 +91,10 @@ class DeviceTangoEigerDetector(DeviceTango):
"""
if (
self.file_writer is not None
and self.file_writer.get_value("Mode") == "0"
and self.file_writer.get_value("Mode") == str(InterfaceStatus.ENABLED.value)
and self.eiger_stream is not None
and self.eiger_stream.get_value("Mode") == "0"
and self.eiger_stream.get_value("Mode")
== str(InterfaceStatus.ENABLED.value)
):
raise DeviceError(
"Enable either the File Writer or the Streaming Interface, not both"
......@@ -125,12 +133,16 @@ class DeviceTangoEigerDetector(DeviceTango):
self.get_value(saving_directory),
f"{prefix}_{self.device_id}_{now.strftime('%Y-%m-%d_%H:%M:%S')}",
)
self.set_attribute(["FileWriter", "Mode", VALUE], 0)
self.set_attribute(
["FileWriter", "Mode", VALUE], InterfaceStatus.ENABLED.value
)
self.set_attribute(["FileWriter", "NamePattern", VALUE], path)
self.set_attribute(["FileWriter", "NimagesPerFile", VALUE], nb_frames)
else: # use the Stream subsystem
path = '{"series_name": "' + prefix + '"}'
self.set_attribute(["EigerStream", "Mode", VALUE], 0)
self.set_attribute(
["EigerStream", "Mode", VALUE], InterfaceStatus.ENABLED.value
)
self.set_attribute(["EigerStream", "HeaderAppendix", VALUE], path)
self.set_attribute(["EigerStream", "ImageAppendix", VALUE], path)
......@@ -168,11 +180,15 @@ class DeviceTangoEigerDetector(DeviceTango):
self.set_attribute(["TriggerMode", VALUE], TriggerMode.INTS.value)
if self.file_writer is not None:
self.logger.info("FileWriter disabled")
self.set_attribute(["FileWriter", "Mode", VALUE], 1)
self.set_attribute(
["FileWriter", "Mode", VALUE], InterfaceStatus.DISABLED.value
)
self.set_attribute(["FileWriter", "NimagesPerFile", VALUE], frames_per_file)
if self.eiger_stream is not None:
self.logger.info("EigerStream disabled")
self.set_attribute(["EigerStream", "Mode", VALUE], 1)
self.set_attribute(
["EigerStream", "Mode", VALUE], InterfaceStatus.DISABLED.value
)
exposure = float(self.to_device_unit("FrameTime", Exposure).m)
# According to Jan Meyer 10ms is the lowest frame time
frame_time = 10e-3 if exposure < 10e-3 else exposure
......@@ -356,7 +372,9 @@ class EigerScanner(DeviceScanner):
path = os.path.join(
self.detector.get_value("scanDir"), scan_dir_name, f"{scan_dir_name}"
)
self.detector.set_attribute(["FileWriter", "Mode", VALUE], 0)
self.detector.set_attribute(
["FileWriter", "Mode", VALUE], InterfaceStatus.ENABLED.value
)
self.detector.set_attribute(["FileWriter", "NamePattern", VALUE], path)
self.detector.set_attribute(["FileWriter", "NimagesPerFile", VALUE], 1000)
......
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