From 2f2cef10f7fb77e502cbf274a6b350f2feb0ad22 Mon Sep 17 00:00:00 2001 From: appel_c Date: Wed, 21 Feb 2024 10:10:46 +0100 Subject: [PATCH] fix: separate BECDevice and BECDeviceBase --- ophyd_devices/utils/bec_device_base.py | 53 ++++++++++++++++++++++- ophyd_devices/utils/static_device_test.py | 4 +- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/ophyd_devices/utils/bec_device_base.py b/ophyd_devices/utils/bec_device_base.py index 3597ebf..c1eda27 100644 --- a/ophyd_devices/utils/bec_device_base.py +++ b/ophyd_devices/utils/bec_device_base.py @@ -2,8 +2,8 @@ from typing import Protocol, runtime_checkable @runtime_checkable -class BECDeviceBase(Protocol): - """Base class for BEC devices with zero functionality.""" +class BECDevice(Protocol): + """Protocol for BEC devices with zero functionality.""" name: str _destroyed: bool @@ -67,3 +67,52 @@ class BECDeviceBase(Protocol): def destroy(self) -> None: """Destroy method""" + + +class BECDeviceBase: + """Base class for BEC devices with minimum functionality. + + Device will be initiated and connected,e.g. obj.connected will be True. + + """ + + def __init__(self, name: str): + self.name = name + self._connected = True + self._destroyed = False + + @property + def hints(self) -> dict: + """hints property""" + return {} + + @property + def connected(self) -> bool: + """connected property""" + return self._connected + + @connected.setter + def connected(self, value: bool): + """connected setter""" + self._connected = value + + def describe(self) -> dict: + """describe method""" + return {} + + def describe_configuration(self) -> dict: + """describe_configuration method""" + return {} + + def read(self) -> dict: + """read method""" + return {} + + def read_configuration(self) -> dict: + """read_configuration method""" + return {} + + def destroy(self) -> None: + """destroy method""" + self._destroyed = True + self.connected = False diff --git a/ophyd_devices/utils/static_device_test.py b/ophyd_devices/utils/static_device_test.py index a0914bc..ece936d 100644 --- a/ophyd_devices/utils/static_device_test.py +++ b/ophyd_devices/utils/static_device_test.py @@ -7,7 +7,7 @@ import ophyd import yaml from bec_lib.scibec_validator import SciBecValidator -from ophyd_devices.utils.bec_device_base import BECDeviceBase +from ophyd_devices.utils.bec_device_base import BECDevice try: from bec_plugins import devices as plugin_devices @@ -178,7 +178,7 @@ class StaticDeviceTest: Returns: """ - assert isinstance(obj, BECDeviceBase) + assert isinstance(obj, BECDevice) assert isinstance(obj.name, str) assert isinstance(obj.read(), dict) assert isinstance(obj.read_configuration(), dict)