Skip to content

Commit

Permalink
feat(hardware): add new hepa uv current field to HepaUVStateResponse (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vegano1 authored Mar 28, 2024
1 parent a019b41 commit c981105
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ class GetHepaUVStatePayloadResponse(EmptyPayload):
uv_duration_s: utils.UInt32Field
uv_light_on: utils.UInt8Field
remaining_time_s: utils.UInt32Field
uv_current_ma: utils.UInt16Field


@dataclass(eq=False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class HepaUVState:
uv_light_on: bool
uv_duration_s: int
remaining_time_s: int
uv_current_ma: int


async def set_hepa_fan_state(
Expand Down Expand Up @@ -132,6 +133,7 @@ def _listener(message: MessageDefinition, arb_id: ArbitrationId) -> None:
uv_light_on=bool(message.payload.uv_light_on.value),
uv_duration_s=int(message.payload.uv_duration_s.value),
remaining_time_s=int(message.payload.remaining_time_s.value),
uv_current_ma=int(message.payload.uv_current_ma.value),
)

def _filter(arb_id: ArbitrationId) -> bool:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for hepa/uv settings."""

from opentrons_hardware.firmware_bindings.messages.messages import MessageDefinition
import pytest
from mock import AsyncMock
Expand All @@ -24,6 +25,7 @@
)
from opentrons_hardware.firmware_bindings.utils import (
UInt8Field,
UInt16Field,
UInt32Field,
)
from tests.conftest import CanLoopback
Expand All @@ -46,14 +48,18 @@ def create_hepa_fan_state_response(fan_on: bool, duty_cycle: int) -> MessageDefi


def create_hepa_uv_state_response(
light_on: bool, duration: int, remaining_time: int
light_on: bool,
duration: int,
remaining_time: int,
uv_current: int,
) -> MessageDefinition:
"""Create a GetHepaUVStateResponse."""
return md.GetHepaUVStateResponse(
payload=GetHepaUVStatePayloadResponse(
uv_light_on=UInt8Field(light_on),
uv_duration_s=UInt32Field(duration),
remaining_time_s=UInt32Field(remaining_time),
uv_current_ma=UInt16Field(uv_current),
)
)

Expand Down Expand Up @@ -149,10 +155,14 @@ def responder(
@pytest.mark.parametrize(
"response",
[
(NodeId.host, create_hepa_uv_state_response(True, 900, 300), NodeId.hepa_uv),
(NodeId.host, create_hepa_uv_state_response(True, 0, 0), NodeId.hepa_uv),
(NodeId.host, create_hepa_uv_state_response(False, 0, 0), NodeId.hepa_uv),
(NodeId.host, create_hepa_uv_state_response(False, 900, 0), NodeId.hepa_uv),
(
NodeId.host,
create_hepa_uv_state_response(True, 900, 300, 3300),
NodeId.hepa_uv,
),
(NodeId.host, create_hepa_uv_state_response(True, 0, 0, 33000), NodeId.hepa_uv),
(NodeId.host, create_hepa_uv_state_response(False, 0, 0, 0), NodeId.hepa_uv),
(NodeId.host, create_hepa_uv_state_response(False, 900, 0, 0), NodeId.hepa_uv),
],
)
async def test_get_hepa_uv_state(
Expand Down Expand Up @@ -186,6 +196,7 @@ def responder(
bool(payload.uv_light_on.value),
int(payload.uv_duration_s.value),
int(payload.remaining_time_s.value),
int(payload.uv_current_ma.value),
)
== res
)

0 comments on commit c981105

Please sign in to comment.