Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cbiering committed Feb 6, 2025
1 parent 413c61c commit efd9f5b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions nova/core/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Device,
IODevice,
AbstractRobot,
ValueType,
)
from nova.core.io import IOAccess

Expand Down Expand Up @@ -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)
6 changes: 3 additions & 3 deletions nova/core/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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(
Expand Down

0 comments on commit efd9f5b

Please sign in to comment.