fix: separate BECDevice and BECDeviceBase
This commit is contained in:
parent
82cfefb3b9
commit
2f2cef10f7
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user