From 81bca16f67a6a1df4a14463e1d2d573b72e1bbae Mon Sep 17 00:00:00 2001 From: gac-x01da Date: Tue, 18 Mar 2025 16:20:18 +0100 Subject: [PATCH] refactor: moved nidaq to subfolder --- debye_bec/devices/nidaq/__init__.py | 0 debye_bec/devices/{ => nidaq}/nidaq.py | 50 +++----------------------- debye_bec/devices/nidaq/nidaq_enums.py | 45 +++++++++++++++++++++++ 3 files changed, 49 insertions(+), 46 deletions(-) create mode 100644 debye_bec/devices/nidaq/__init__.py rename debye_bec/devices/{ => nidaq}/nidaq.py (92%) create mode 100644 debye_bec/devices/nidaq/nidaq_enums.py diff --git a/debye_bec/devices/nidaq/__init__.py b/debye_bec/devices/nidaq/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/debye_bec/devices/nidaq.py b/debye_bec/devices/nidaq/nidaq.py similarity index 92% rename from debye_bec/devices/nidaq.py rename to debye_bec/devices/nidaq/nidaq.py index 758550f..0e84f3a 100644 --- a/debye_bec/devices/nidaq.py +++ b/debye_bec/devices/nidaq/nidaq.py @@ -1,4 +1,4 @@ -import enum + from typing import Literal @@ -7,55 +7,13 @@ from ophyd import Device, Kind, DeviceStatus, Component as Cpt from ophyd import EpicsSignal, EpicsSignalRO from ophyd_devices.sim.sim_signals import SetableSignal from bec_lib.logger import bec_logger +from debye_bec.devices.nidaq.nidaq_enums import NIDAQCompression, ScanType, NidaqState, ScanRates, ReadoutRange, EncoderTypes logger = bec_logger.logger class NidaqError(Exception): """ Nidaq specific error""" -class NIDAQCompression(str, enum.Enum): - """ Options for Compression""" - OFF = 0 - ON = 1 - -class ScanType(int, enum.Enum): - """ Triggering options of the backend""" - TRIGGERED = 0 - CONTINUOUS = 1 - -class NidaqState(int, enum.Enum): - """ Possible States of the NIDAQ backend""" - DISABLED = 0 - STANDBY = 1 - STAGE = 2 - KICKOFF = 3 - ACQUIRE = 4 - UNSTAGE = 5 - -class ScanRates(int, enum.Enum): - """ Sampling Rate options for the backend, in kHZ and MHz""" - HUNDRED_KHZ = 0 - FIVE_HUNDRED_KHZ = 1 - ONE_MHZ = 2 - TWO_MHZ = 3 - FOUR_MHZ = 4 - FIVE_MHZ = 5 - TEN_MHZ = 6 - FOURTEEN_THREE_MHZ = 7 - -class ReadoutRange(int, enum.Enum): - """ReadoutRange in +-V""" - ONE_V = 0 - TWO_V = 1 - FIVE_V = 2 - TEN_V = 3 - -class EncoderTypes(int, enum.Enum): - """ Encoder Types""" - X_1 = 0 - X_2 = 1 - X_4 = 2 - class NIDAQCustomMixin(CustomDetectorMixin): """ NIDAQ Custom Mixin class to implement the device and beamline-specific actions to the psidetectorbase class via custom_prepare methods""" @@ -146,7 +104,7 @@ class NIDAQCustomMixin(CustomDetectorMixin): logger.info(f"Device {self.parent.name} was unstaged: {NidaqState(self.parent.state.get())}") -class NIDAQ(PSIDetectorBase): +class Nidaq(PSIDetectorBase): """ NIDAQ ophyd wrapper around the NIDAQ backend currently running at x01da-cons-05 Args: @@ -159,7 +117,7 @@ class NIDAQ(PSIDetectorBase): USER_ACCESS = ['set_config'] - encoder_angle = Cpt(SetableSignal,value=0, kind=Kind.normal) + enc = Cpt(SetableSignal,value=0, kind=Kind.normal) signal_1 = Cpt(SetableSignal,value=0, kind=Kind.normal) signal_2 = Cpt(SetableSignal,value=0, kind=Kind.normal) signal_3 = Cpt(SetableSignal,value=0, kind=Kind.normal) diff --git a/debye_bec/devices/nidaq/nidaq_enums.py b/debye_bec/devices/nidaq/nidaq_enums.py new file mode 100644 index 0000000..728f7eb --- /dev/null +++ b/debye_bec/devices/nidaq/nidaq_enums.py @@ -0,0 +1,45 @@ +import enum + + +class NIDAQCompression(str, enum.Enum): + """ Options for Compression""" + OFF = 0 + ON = 1 + +class ScanType(int, enum.Enum): + """ Triggering options of the backend""" + TRIGGERED = 0 + CONTINUOUS = 1 + +class NidaqState(int, enum.Enum): + """ Possible States of the NIDAQ backend""" + DISABLED = 0 + STANDBY = 1 + STAGE = 2 + KICKOFF = 3 + ACQUIRE = 4 + UNSTAGE = 5 + +class ScanRates(int, enum.Enum): + """ Sampling Rate options for the backend, in kHZ and MHz""" + HUNDRED_KHZ = 0 + FIVE_HUNDRED_KHZ = 1 + ONE_MHZ = 2 + TWO_MHZ = 3 + FOUR_MHZ = 4 + FIVE_MHZ = 5 + TEN_MHZ = 6 + FOURTEEN_THREE_MHZ = 7 + +class ReadoutRange(int, enum.Enum): + """ReadoutRange in +-V""" + ONE_V = 0 + TWO_V = 1 + FIVE_V = 2 + TEN_V = 3 + +class EncoderTypes(int, enum.Enum): + """ Encoder Types""" + X_1 = 0 + X_2 = 1 + X_4 = 2