diff --git a/nova/core/controller.py b/nova/core/controller.py index 5f84f99..f25317f 100644 --- a/nova/core/controller.py +++ b/nova/core/controller.py @@ -11,6 +11,7 @@ Device, IODevice, AbstractRobot, + ValueType, ) from nova.core.io import IOAccess @@ -91,3 +92,9 @@ def get_robots(self) -> dict[str, AbstractRobot]: motion_group_id: self.motion_group(int(motion_group_id.split("@")[0])) for motion_group_id in self._activated_motion_group_ids } + + async def read(self, key: str) -> ValueType: + return await self._io_access.read(key) + + async def write(self, key: str, value: ValueType) -> None: + return await self._io_access.write(key, value) diff --git a/nova/core/io.py b/nova/core/io.py index c3ad121..f6f4259 100644 --- a/nova/core/io.py +++ b/nova/core/io.py @@ -80,9 +80,9 @@ async def read(self, key: str) -> bool | int | float: if io_value.boolean_value is not None: return io_value.boolean_value if io_value.integer_value is not None: - return io_value.integer_value + return int(io_value.integer_value) if io_value.floating_value is not None: - return io_value.floating_value + return float(io_value.floating_value) raise ValueError(f"IO value for {key} is of an unexpected type.") async def write(self, key: str, value: ValueType): @@ -101,7 +101,7 @@ async def write(self, key: str, value: ValueType): raise ValueError( f"Integer value can only be set at an IO_VALUE_ANALOG_INTEGER IO and not to {io_value_type}" ) - io_value = models.IOValue(io=key, integer_value=value) # TODO: handle mask + io_value = models.IOValue(io=key, integer_value=str(value)) # TODO: handle mask elif isinstance(value, float): if io_value_type is not IOValueType.IO_VALUE_ANALOG_FLOATING: raise ValueError(