Skip to content

Commit

Permalink
Add OneOfEverythingDevices to configuration using context manager
Browse files Browse the repository at this point in the history
  • Loading branch information
jsouter committed Jan 9, 2025
1 parent d59c035 commit 840dd23
Showing 1 changed file with 36 additions and 37 deletions.
73 changes: 36 additions & 37 deletions src/ophyd_async/testing/_one_of_everything.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
soft_signal_r_and_setter,
soft_signal_rw,
)
from ophyd_async.core import StandardReadableFormat as Format
from ophyd_async.core._device import DeviceVector


Expand Down Expand Up @@ -63,44 +64,42 @@ def float_array_signal(
class OneOfEverythingDevice(StandardReadable):
# make a detector to test assert_configuration
def __init__(self, name=""):
self.int = soft_signal_rw(int, 1)
self.float = soft_signal_rw(float, 1.234)
self.str = soft_signal_rw(str, "test_string")
self.bool = soft_signal_rw(bool, True)
self.enum = soft_signal_rw(ExampleEnum, ExampleEnum.B)
self.int8a = int_array_signal(np.int8)
self.uint8a = int_array_signal(np.uint8)
self.int16a = int_array_signal(np.int16)
self.uint16a = int_array_signal(np.uint16)
self.int32a = int_array_signal(np.int32)
self.uint32a = int_array_signal(np.uint32)
self.int64a = int_array_signal(np.int64)
self.uint64a = int_array_signal(np.uint64)
self.float32a = float_array_signal(np.float32)
self.float64a = float_array_signal(np.float64)
self.stra = soft_signal_rw(
Sequence[str],
["one", "two", "three"],
)
self.enuma = soft_signal_rw(
Sequence[ExampleEnum],
[ExampleEnum.A, ExampleEnum.C],
)
self.table = soft_signal_rw(
ExampleTable,
ExampleTable(
bool=np.array([False, False, True, True], np.bool_),
int=np.array([1, 8, -9, 32], np.int32),
float=np.array([1.8, 8.2, -6, 32.9887], np.float64),
str=["Hello", "World", "Foo", "Bar"],
enum=[ExampleEnum.A, ExampleEnum.B, ExampleEnum.A, ExampleEnum.C],
),
)
self.ndarray = soft_signal_rw(np.ndarray, np.array(([1, 2, 3], [4, 5, 6])))
# add all signals to configuration
self._read_config_funcs = tuple( # type: ignore
sig.read for sig in self.__dict__.values() if isinstance(sig, SignalR)
)
with self.add_children_as_readables(Format.CONFIG_SIGNAL):
self.int = soft_signal_rw(int, 1)
self.float = soft_signal_rw(float, 1.234)
self.str = soft_signal_rw(str, "test_string")
self.bool = soft_signal_rw(bool, True)
self.enum = soft_signal_rw(ExampleEnum, ExampleEnum.B)
self.int8a = int_array_signal(np.int8)
self.uint8a = int_array_signal(np.uint8)
self.int16a = int_array_signal(np.int16)
self.uint16a = int_array_signal(np.uint16)
self.int32a = int_array_signal(np.int32)
self.uint32a = int_array_signal(np.uint32)
self.int64a = int_array_signal(np.int64)
self.uint64a = int_array_signal(np.uint64)
self.float32a = float_array_signal(np.float32)
self.float64a = float_array_signal(np.float64)
self.stra = soft_signal_rw(
Sequence[str],
["one", "two", "three"],
)
self.enuma = soft_signal_rw(
Sequence[ExampleEnum],
[ExampleEnum.A, ExampleEnum.C],
)
self.table = soft_signal_rw(
ExampleTable,
ExampleTable(
bool=np.array([False, False, True, True], np.bool_),
int=np.array([1, 8, -9, 32], np.int32),
float=np.array([1.8, 8.2, -6, 32.9887], np.float64),
str=["Hello", "World", "Foo", "Bar"],
enum=[ExampleEnum.A, ExampleEnum.B, ExampleEnum.A, ExampleEnum.C],
),
)
self.ndarray = soft_signal_rw(np.ndarray, np.array(([1, 2, 3], [4, 5, 6])))
super().__init__(name)


Expand Down

0 comments on commit 840dd23

Please sign in to comment.