From 865f2a859435b4134587e6b3591043b552a1d471 Mon Sep 17 00:00:00 2001 From: Brayan Almonte Date: Thu, 8 Feb 2024 17:18:19 -0500 Subject: [PATCH] feat(hardware): add CAN messages to control the Hepa/UV filter. (#14452) --- .../firmware_bindings/constants.py | 7 ++ .../messages/message_definitions.py | 70 +++++++++++++++++++ .../firmware_bindings/messages/messages.py | 6 ++ .../firmware_bindings/messages/payloads.py | 35 +++++++++- 4 files changed, 117 insertions(+), 1 deletion(-) diff --git a/hardware/opentrons_hardware/firmware_bindings/constants.py b/hardware/opentrons_hardware/firmware_bindings/constants.py index 61387ea798dc..6d173e6effcf 100644 --- a/hardware/opentrons_hardware/firmware_bindings/constants.py +++ b/hardware/opentrons_hardware/firmware_bindings/constants.py @@ -250,6 +250,13 @@ class MessageId(int, Enum): peripheral_status_response = 0x8D baseline_sensor_response = 0x8E + set_hepa_fan_state_request = 0x90 + get_hepa_fan_state_request = 0x91 + get_hepa_fan_state_response = 0x92 + set_hepa_uv_state_request = 0x93 + get_hepa_uv_state_request = 0x94 + get_hepa_uv_state_response = 0x95 + @unique class ErrorSeverity(int, Enum): diff --git a/hardware/opentrons_hardware/firmware_bindings/messages/message_definitions.py b/hardware/opentrons_hardware/firmware_bindings/messages/message_definitions.py index 9af027707456..49698329264b 100644 --- a/hardware/opentrons_hardware/firmware_bindings/messages/message_definitions.py +++ b/hardware/opentrons_hardware/firmware_bindings/messages/message_definitions.py @@ -907,3 +907,73 @@ class HepaUVInfoResponse(BaseMessage): # noqa: D101 payloads.HepaUVInfoResponsePayload ] = payloads.HepaUVInfoResponsePayload message_id: Literal[MessageId.hepauv_info_response] = MessageId.hepauv_info_response + + +@dataclass +class SetHepaFanStateRequest(BaseMessage): + """Request to set the state and duty cycle of the hepa fan.""" + + payload: payloads.SetHepaFanStateRequestPayload + payload_type: Type[ + payloads.SetHepaFanStateRequestPayload + ] = payloads.SetHepaFanStateRequestPayload + message_id: Literal[ + MessageId.set_hepa_fan_state_request + ] = MessageId.set_hepa_fan_state_request + + +@dataclass +class GetHepaFanStateRequest(EmptyPayloadMessage): + """Request the Hepa/UV to send the state and duty cycle of the fan.""" + + message_id: Literal[ + MessageId.get_hepa_fan_state_request + ] = MessageId.get_hepa_fan_state_request + + +@dataclass +class GetHepaFanStateResponse(BaseMessage): + """Hepa/UV response with the state and duty cycle of the fan.""" + + payload: payloads.GetHepaFanStatePayloadResponse + payload_type: Type[ + payloads.GetHepaFanStatePayloadResponse + ] = payloads.GetHepaFanStatePayloadResponse + message_id: Literal[ + MessageId.get_hepa_fan_state_response + ] = MessageId.get_hepa_fan_state_response + + +@dataclass +class SetHepaUVStateRequest(BaseMessage): + """Sets the state and timeout in seconds the UV light should stay on.""" + + payload: payloads.SetHepaUVStateRequestPayload + payload_type: Type[ + payloads.SetHepaUVStateRequestPayload + ] = payloads.SetHepaUVStateRequestPayload + message_id: Literal[ + MessageId.set_hepa_uv_state_request + ] = MessageId.set_hepa_uv_state_request + + +@dataclass +class GetHepaUVStateRequest(EmptyPayloadMessage): + """Request the Hepa/UV send the state and timeout in seconds for the UV light.""" + + message_id: Literal[ + MessageId.get_hepa_uv_state_request + ] = MessageId.get_hepa_uv_state_request + + +@dataclass +class GetHepaUVStateResponse(BaseMessage): + """Response from the Hepa/UV state and timeout in seconds for the UV light.""" + + payload: payloads.GetHepaUVStatePayloadResponse + payload_type: Type[ + payloads.GetHepaUVStatePayloadResponse + ] = payloads.GetHepaUVStatePayloadResponse + message_id: Literal[ + MessageId.get_hepa_uv_state_response + ] = MessageId.get_hepa_uv_state_response diff --git a/hardware/opentrons_hardware/firmware_bindings/messages/messages.py b/hardware/opentrons_hardware/firmware_bindings/messages/messages.py index b1563f5ecf4e..930c82bab793 100644 --- a/hardware/opentrons_hardware/firmware_bindings/messages/messages.py +++ b/hardware/opentrons_hardware/firmware_bindings/messages/messages.py @@ -100,6 +100,12 @@ defs.SetGripperJawHoldoffRequest, defs.GripperJawHoldoffRequest, defs.GripperJawHoldoffResponse, + defs.SetHepaFanStateRequest, + defs.GetHepaFanStateRequest, + defs.GetHepaFanStateResponse, + defs.SetHepaUVStateRequest, + defs.GetHepaUVStateRequest, + defs.GetHepaUVStateResponse, ] diff --git a/hardware/opentrons_hardware/firmware_bindings/messages/payloads.py b/hardware/opentrons_hardware/firmware_bindings/messages/payloads.py index 650c5d1e30c0..c2efd8ac4162 100644 --- a/hardware/opentrons_hardware/firmware_bindings/messages/payloads.py +++ b/hardware/opentrons_hardware/firmware_bindings/messages/payloads.py @@ -631,7 +631,40 @@ def build(cls, data: bytes) -> "GetMotorUsageResponsePayload": @dataclass(eq=False) class HepaUVInfoResponsePayload(EmptyPayload): - """A response carrying data about an attached gripper.""" + """A response carrying data about an attached hepa uv.""" model: utils.UInt16Field serial: SerialDataCodeField + + +@dataclass(eq=False) +class SetHepaFanStateRequestPayload(EmptyPayload): + """A request to set the state and pwm of a the hepa fan.""" + + duty_cycle: utils.UInt32Field + fan_on: utils.Int8Field + + +@dataclass(eq=False) +class GetHepaFanStatePayloadResponse(EmptyPayload): + """A response with the state and pwm of the fan.""" + + duty_cycle: utils.UInt32Field + fan_on: utils.UInt8Field + + +@dataclass(eq=False) +class SetHepaUVStateRequestPayload(EmptyPayload): + """A request to set the state and timeout in seconds of the hepa uv light.""" + + timeout_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.""" + + timeout_s: utils.UInt32Field + uv_light_on: utils.UInt8Field + remaining_time_s: utils.UInt32Field