mirror of
https://github.com/bec-project/ophyd_devices.git
synced 2025-06-06 03:40:41 +02:00
fix(sim): fixed device for testing a describe failure
This commit is contained in:
parent
58f89e5298
commit
905535b049
@ -175,11 +175,23 @@ class SimPositionerWithCommFailure(SimPositioner):
|
|||||||
|
|
||||||
|
|
||||||
class SimPositionerWithDescribeFailure(SimPositioner):
|
class SimPositionerWithDescribeFailure(SimPositioner):
|
||||||
_fail = True
|
"""
|
||||||
|
Simulated positioner that raises a RuntimeError if the 'e2e_test_<name>_fail' endpoint is set to 1 using
|
||||||
|
a DeviceStatusMessage. This is used to test the behavior of the device when the describe method fails.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, *args, device_manager=None, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.device_manager = device_manager
|
||||||
|
|
||||||
|
def _get_fail_state(self):
|
||||||
|
msg = self.device_manager.connector.get(f"e2e_test_{self.name}_fail")
|
||||||
|
if not msg:
|
||||||
|
return 0
|
||||||
|
return msg.status
|
||||||
|
|
||||||
def describe(self):
|
def describe(self):
|
||||||
SimPositionerWithDescribeFailure._fail = not SimPositionerWithDescribeFailure._fail
|
if self._get_fail_state() == 1:
|
||||||
if SimPositionerWithDescribeFailure._fail:
|
|
||||||
raise RuntimeError("Communication failure")
|
raise RuntimeError("Communication failure")
|
||||||
return super().describe()
|
return super().describe()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user