fix: fix inheritance for SimMonitor
This commit is contained in:
parent
3f2c6dc4ef
commit
f56961ba8c
@ -21,7 +21,7 @@ from ophyd_devices.utils.errors import DeviceStopError
|
||||
logger = bec_logger.logger
|
||||
|
||||
|
||||
class SimMonitor(Device):
|
||||
class SimMonitor(ReadOnlySignal):
|
||||
"""
|
||||
A simulated device mimic any 1D Axis (position, temperature, beam).
|
||||
|
||||
@ -46,10 +46,10 @@ class SimMonitor(Device):
|
||||
sim_cls = SimulatedDataMonitor
|
||||
BIT_DEPTH = np.uint32
|
||||
|
||||
readback = Cpt(ReadOnlySignal, value=BIT_DEPTH(0), kind=Kind.hinted, compute_readback=True)
|
||||
|
||||
SUB_READBACK = "readback"
|
||||
_default_sub = SUB_READBACK
|
||||
# TODO: to be removed once changes in BEC are merged
|
||||
readback = Cpt(ReadOnlySignal, value=BIT_DEPTH(0), kind=Kind.hinted, compute_readback=True)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@ -58,7 +58,7 @@ class SimMonitor(Device):
|
||||
precision: int = 3,
|
||||
sim_init: dict = None,
|
||||
parent=None,
|
||||
kind=None,
|
||||
kind: Kind = None,
|
||||
device_manager=None,
|
||||
**kwargs,
|
||||
):
|
||||
@ -68,9 +68,14 @@ class SimMonitor(Device):
|
||||
self.sim = self.sim_cls(parent=self, **kwargs)
|
||||
self._registered_proxies = {}
|
||||
|
||||
super().__init__(name=name, parent=parent, kind=kind, **kwargs)
|
||||
self.sim.sim_state[self.name] = self.sim.sim_state.pop(self.readback.name, None)
|
||||
self.readback.name = self.name
|
||||
super().__init__(
|
||||
name=name,
|
||||
parent=self,
|
||||
kind=kind,
|
||||
value=self.BIT_DEPTH(0),
|
||||
compute_readback=True,
|
||||
**kwargs,
|
||||
)
|
||||
if self.sim_init:
|
||||
self.sim.set_init(self.sim_init)
|
||||
|
||||
|
@ -155,8 +155,7 @@ def test_signal__init__(signal):
|
||||
def test_monitor__init__(monitor):
|
||||
"""Test the __init__ method of SimMonitor."""
|
||||
assert isinstance(monitor, SimMonitor)
|
||||
assert isinstance(monitor, BECDeviceProtocol)
|
||||
assert isinstance(monitor, BECScanProtocol)
|
||||
assert isinstance(monitor, BECSignalProtocol)
|
||||
|
||||
|
||||
def test_camera__init__(camera):
|
||||
@ -193,7 +192,7 @@ def test_init_async_monitor(async_monitor):
|
||||
def test_monitor_readback(monitor, center):
|
||||
"""Test the readback method of SimMonitor."""
|
||||
motor_pos = 0
|
||||
monitor.device_manager.add_device("samx", value=motor_pos)
|
||||
monitor.device_manager.add_device(name="samx", value=motor_pos)
|
||||
for model_name in monitor.sim.get_models():
|
||||
monitor.sim.select_model(model_name)
|
||||
monitor.sim.params["noise_multipler"] = 10
|
||||
|
Loading…
x
Reference in New Issue
Block a user