From c981105b7e507589c3aaa0012f439a937521d131 Mon Sep 17 00:00:00 2001 From: Brayan Almonte Date: Thu, 28 Mar 2024 16:45:12 -0400 Subject: [PATCH] feat(hardware): add new hepa uv current field to HepaUVStateResponse (#14710) --- .../firmware_bindings/messages/payloads.py | 1 + .../hardware_control/hepa_uv_settings.py | 2 ++ .../hardware_control/test_hepauv_settings.py | 21 ++++++++++++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/hardware/opentrons_hardware/firmware_bindings/messages/payloads.py b/hardware/opentrons_hardware/firmware_bindings/messages/payloads.py index 64a57cae11a..f4bca8cb881 100644 --- a/hardware/opentrons_hardware/firmware_bindings/messages/payloads.py +++ b/hardware/opentrons_hardware/firmware_bindings/messages/payloads.py @@ -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) diff --git a/hardware/opentrons_hardware/hardware_control/hepa_uv_settings.py b/hardware/opentrons_hardware/hardware_control/hepa_uv_settings.py index 8c7b69f4909..0716a4f4c90 100644 --- a/hardware/opentrons_hardware/hardware_control/hepa_uv_settings.py +++ b/hardware/opentrons_hardware/hardware_control/hepa_uv_settings.py @@ -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( @@ -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: diff --git a/hardware/tests/opentrons_hardware/hardware_control/test_hepauv_settings.py b/hardware/tests/opentrons_hardware/hardware_control/test_hepauv_settings.py index 260a7d965ea..2401aee34b4 100644 --- a/hardware/tests/opentrons_hardware/hardware_control/test_hepauv_settings.py +++ b/hardware/tests/opentrons_hardware/hardware_control/test_hepauv_settings.py @@ -1,4 +1,5 @@ """Tests for hepa/uv settings.""" + from opentrons_hardware.firmware_bindings.messages.messages import MessageDefinition import pytest from mock import AsyncMock @@ -24,6 +25,7 @@ ) from opentrons_hardware.firmware_bindings.utils import ( UInt8Field, + UInt16Field, UInt32Field, ) from tests.conftest import CanLoopback @@ -46,7 +48,10 @@ 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( @@ -54,6 +59,7 @@ def create_hepa_uv_state_response( uv_light_on=UInt8Field(light_on), uv_duration_s=UInt32Field(duration), remaining_time_s=UInt32Field(remaining_time), + uv_current_ma=UInt16Field(uv_current), ) ) @@ -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( @@ -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 )