mirror of
https://github.com/bec-project/ophyd_devices.git
synced 2025-06-02 18:10:40 +02:00
refactor: made BECDeviceBase a protocol
This commit is contained in:
parent
406f27c27e
commit
84fed4ee82
@ -1,15 +1,16 @@
|
|||||||
class BECDeviceBase:
|
from typing import Protocol, runtime_checkable
|
||||||
|
|
||||||
|
|
||||||
|
@runtime_checkable
|
||||||
|
class BECDeviceBase(Protocol):
|
||||||
"""Base class for BEC devices with zero functionality."""
|
"""Base class for BEC devices with zero functionality."""
|
||||||
|
|
||||||
def __init__(self, name: str, *args, **kwargs):
|
name: str
|
||||||
self.name = name
|
_destroyed: bool
|
||||||
self._connected = True
|
|
||||||
self._destroyed = False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hints(self):
|
def hints(self) -> dict:
|
||||||
"""hints property"""
|
"""hints property"""
|
||||||
return {}
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def connected(self) -> bool:
|
def connected(self) -> bool:
|
||||||
@ -19,12 +20,10 @@ class BECDeviceBase:
|
|||||||
Returns:
|
Returns:
|
||||||
bool: True if connected, False otherwise
|
bool: True if connected, False otherwise
|
||||||
"""
|
"""
|
||||||
return self._connected
|
|
||||||
|
|
||||||
@connected.setter
|
@connected.setter
|
||||||
def connected(self, value: bool):
|
def connected(self, value: bool):
|
||||||
"""connected setter"""
|
"""connected setter"""
|
||||||
self._connected = value
|
|
||||||
|
|
||||||
def describe(self) -> dict:
|
def describe(self) -> dict:
|
||||||
"""describe method
|
"""describe method
|
||||||
@ -35,7 +34,6 @@ class BECDeviceBase:
|
|||||||
Returns:
|
Returns:
|
||||||
dict: Dictionary with dictionaries with signal descriptions ('source', 'dtype', 'shape')
|
dict: Dictionary with dictionaries with signal descriptions ('source', 'dtype', 'shape')
|
||||||
"""
|
"""
|
||||||
return {}
|
|
||||||
|
|
||||||
def describe_configuration(self) -> dict:
|
def describe_configuration(self) -> dict:
|
||||||
"""describe method
|
"""describe method
|
||||||
@ -46,7 +44,6 @@ class BECDeviceBase:
|
|||||||
Returns:
|
Returns:
|
||||||
dict: Dictionary with dictionaries with signal descriptions ('source', 'dtype', 'shape')
|
dict: Dictionary with dictionaries with signal descriptions ('source', 'dtype', 'shape')
|
||||||
"""
|
"""
|
||||||
return {}
|
|
||||||
|
|
||||||
def read_configuration(self) -> dict:
|
def read_configuration(self) -> dict:
|
||||||
"""read_configuration method
|
"""read_configuration method
|
||||||
@ -57,7 +54,6 @@ class BECDeviceBase:
|
|||||||
dict: Dictionary with nested dictionary of signals with kind.config:
|
dict: Dictionary with nested dictionary of signals with kind.config:
|
||||||
{'signal_name' : {'value' : .., "timestamp" : ..}, ...}
|
{'signal_name' : {'value' : .., "timestamp" : ..}, ...}
|
||||||
"""
|
"""
|
||||||
return {}
|
|
||||||
|
|
||||||
def read(self) -> dict:
|
def read(self) -> dict:
|
||||||
"""read method
|
"""read method
|
||||||
@ -68,8 +64,6 @@ class BECDeviceBase:
|
|||||||
dict: Dictionary with nested dictionary of signals with kind.normal or kind.hinted:
|
dict: Dictionary with nested dictionary of signals with kind.normal or kind.hinted:
|
||||||
{'signal_name' : {'value' : .., "timestamp" : ..}, ...}
|
{'signal_name' : {'value' : .., "timestamp" : ..}, ...}
|
||||||
"""
|
"""
|
||||||
return {}
|
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self) -> None:
|
||||||
"""Destroy method"""
|
"""Destroy method"""
|
||||||
self._destroyed = True
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user