Skip to content

Commit

Permalink
change the timeout_s config setting to uv_duration_s so its clear it …
Browse files Browse the repository at this point in the history
…means how long to turn the uv light on for.
  • Loading branch information
vegano1 committed Feb 16, 2024
1 parent b2a37de commit 7109242
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 27 deletions.
4 changes: 2 additions & 2 deletions api/src/opentrons/hardware_control/backends/flex_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ async def set_hepa_fan_state(self, fan_on: bool, duty_cycle: int) -> bool:
async def get_hepa_fan_state(self) -> Optional[HepaFanState]:
...

async def set_hepa_uv_state(self, light_on: bool, timeout_s: int) -> bool:
"""Sets the state and timeout in seconds of the Hepa/UV module."""
async def set_hepa_uv_state(self, light_on: bool, uv_duration_s: int) -> bool:
"""Sets the state and duration (seconds) of the UV light for the Hepa/UV module."""
...

async def get_hepa_uv_state(self) -> Optional[HepaUVState]:
Expand Down
6 changes: 3 additions & 3 deletions api/src/opentrons/hardware_control/backends/ot3controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1591,15 +1591,15 @@ async def get_hepa_fan_state(self) -> Optional[HepaFanState]:
else None
)

async def set_hepa_uv_state(self, light_on: bool, timeout_s: int) -> bool:
return await set_hepa_uv_state_fw(self._messenger, light_on, timeout_s)
async def set_hepa_uv_state(self, light_on: bool, uv_duration_s: int) -> bool:
return await set_hepa_uv_state_fw(self._messenger, light_on, uv_duration_s)

async def get_hepa_uv_state(self) -> Optional[HepaUVState]:
res = await get_hepa_uv_state_fw(self._messenger)
return (
HepaUVState(
light_on=res.uv_light_on,
config_timeout=res.timeout_s,
uv_duration_s=res.uv_duration_s,
remaining_time_s=res.remaining_time_s,
)
if res
Expand Down
6 changes: 3 additions & 3 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2698,10 +2698,10 @@ async def get_hepa_fan_state(self) -> Optional[HepaFanState]:
return await self._backend.get_hepa_fan_state()

async def set_hepa_uv_state(
self, turn_on: bool = False, timeout_s: int = 900
self, turn_on: bool = False, uv_duration_s: int = 900
) -> bool:
"""Sets the state and timeout in seconds of the Hepa/UV module."""
return await self._backend.set_hepa_uv_state(turn_on, timeout_s)
"""Sets the state and duration (seconds) of the UV light for the Hepa/UV module."""
return await self._backend.set_hepa_uv_state(turn_on, uv_duration_s)

async def get_hepa_uv_state(self) -> Optional[HepaUVState]:
return await self._backend.get_hepa_uv_state()
2 changes: 1 addition & 1 deletion api/src/opentrons/hardware_control/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ class HepaFanState:
@dataclass
class HepaUVState:
light_on: bool
config_timeout: int
uv_duration_s: int
remaining_time_s: int


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,16 +655,16 @@ class GetHepaFanStatePayloadResponse(EmptyPayload):

@dataclass(eq=False)
class SetHepaUVStateRequestPayload(EmptyPayload):
"""A request to set the state and timeout in seconds of the hepa uv light."""
"""A request to set the state and duration in seconds of the hepa uv light."""

timeout_s: utils.UInt32Field
uv_duration_s: utils.UInt32Field
uv_light_on: utils.UInt8Field


@dataclass(eq=False)
class GetHepaUVStatePayloadResponse(EmptyPayload):
"""A response with the state and timeout in seconds of the hepa uv light."""
"""A response with the state and duration in seconds of the hepa uv light."""

timeout_s: utils.UInt32Field
uv_duration_s: utils.UInt32Field
uv_light_on: utils.UInt8Field
remaining_time_s: utils.UInt32Field
11 changes: 6 additions & 5 deletions hardware/opentrons_hardware/hardware_control/hepa_uv_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class HepaUVState:
"""Hepa UV Light Config."""

uv_light_on: bool
timeout_s: int
uv_duration_s: int
remaining_time_s: int


Expand Down Expand Up @@ -100,14 +100,15 @@ def _filter(arb_id: ArbitrationId) -> bool:
async def set_hepa_uv_state(
can_messenger: CanMessenger,
uv_light_on: bool,
timeout_s: int,
uv_duration_s: int,
) -> bool:
"""Set the Hepa UV state and timeout in seconds."""
"""Sets the Hepa UV light state and duration in seconds."""
error = await can_messenger.ensure_send(
node_id=NodeId.hepa_uv,
message=SetHepaUVStateRequest(
payload=payloads.SetHepaUVStateRequestPayload(
timeout_s=UInt32Field(timeout_s), uv_light_on=UInt8Field(uv_light_on)
uv_duration_s=UInt32Field(uv_duration_s),
uv_light_on=UInt8Field(uv_light_on),
),
),
expected_nodes=[NodeId.hepa_uv],
Expand All @@ -129,7 +130,7 @@ def _listener(message: MessageDefinition, arb_id: ArbitrationId) -> None:
event.set()
uv_state = HepaUVState(
uv_light_on=bool(message.payload.uv_light_on.value),
timeout_s=int(message.payload.timeout_s.value),
uv_duration_s=int(message.payload.uv_duration_s.value),
remaining_time_s=int(message.payload.remaining_time_s.value),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ def create_hepa_fan_state_response(fan_on: bool, duty_cycle: int) -> MessageDefi


def create_hepa_uv_state_response(
light_on: bool, config_timeout: int, remaining_time: int
light_on: bool, duration: int, remaining_time: int
) -> MessageDefinition:
"""Create a GetHepaUVStateResponse."""
return md.GetHepaUVStateResponse(
payload=GetHepaUVStatePayloadResponse(
uv_light_on=UInt8Field(light_on),
timeout_s=UInt32Field(config_timeout),
uv_duration_s=UInt32Field(duration),
remaining_time_s=UInt32Field(remaining_time),
)
)
Expand Down Expand Up @@ -81,21 +81,21 @@ async def test_set_hepa_fan_state(


@pytest.mark.parametrize(
("light_on", "timeout"), [[True, 0], [True, 900], [False, 3600], [False, 7200]]
("light_on", "duration"), [[True, 0], [True, 900], [False, 3600], [False, 7200]]
)
async def test_set_hepa_uv_state(
mock_can_messenger: AsyncMock,
light_on: bool,
timeout: int,
duration: int,
) -> None:
"""We should set the uv light state and timeout for the hepa/uv node."""
await set_hepa_uv_state(mock_can_messenger, light_on, timeout)
"""We should set the uv light state and duration for the hepa/uv node."""
await set_hepa_uv_state(mock_can_messenger, light_on, duration)
mock_can_messenger.ensure_send.assert_any_call(
node_id=NodeId.hepa_uv,
message=md.SetHepaUVStateRequest(
payload=SetHepaUVStateRequestPayload(
uv_light_on=UInt8Field(light_on),
timeout_s=UInt32Field(timeout),
uv_duration_s=UInt32Field(duration),
)
),
expected_nodes=[NodeId.hepa_uv],
Expand Down Expand Up @@ -160,7 +160,7 @@ async def test_get_hepa_uv_state(
message_send_loopback: CanLoopback,
response: Tuple[NodeId, MessageDefinition, NodeId],
) -> None:
"""We should get the uv light state and timeout for the hepa/uv node."""
"""We should get the uv light state and duration for the hepa/uv node."""

def responder(
node_id: NodeId, message: MessageDefinition
Expand All @@ -184,7 +184,7 @@ def responder(
assert (
HepaUVState(
bool(payload.uv_light_on.value),
int(payload.timeout_s.value),
int(payload.uv_duration_s.value),
int(payload.remaining_time_s.value),
)
== res
Expand Down

0 comments on commit 7109242

Please sign in to comment.