Skip to content

Commit 29d7d79

Browse files
committed
feat(hardware): added safety relay active state to HepaUVState and safety_relay_inactive error (#15311)
1 parent 1ea906e commit 29d7d79

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

hardware/opentrons_hardware/firmware_bindings/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
by default. Please do not unconditionally import things outside the python standard
55
library.
66
"""
7+
78
from enum import Enum, unique
89
from typing import Union, Dict, List
910

@@ -294,6 +295,7 @@ class ErrorCode(int, Enum):
294295
door_open = 0x0E
295296
reed_open = 0x0F
296297
motor_driver_error_detected = 0x10
298+
safety_relay_inactive = 0x11
297299

298300

299301
@unique

hardware/opentrons_hardware/firmware_bindings/messages/payloads.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Payloads of can bus messages."""
2+
23
# TODO (amit, 2022-01-26): Figure out why using annotations import ruins
34
# dataclass fields interpretation.
45
# from __future__ import annotations
@@ -684,6 +685,7 @@ class GetHepaUVStatePayloadResponse(EmptyPayload):
684685
uv_light_on: utils.UInt8Field
685686
remaining_time_s: utils.UInt32Field
686687
uv_current_ma: utils.UInt16Field
688+
safety_relay_active: utils.UInt8Field
687689

688690

689691
@dataclass(eq=False)

hardware/opentrons_hardware/hardware_control/hepa_uv_settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Utilities for controlling the hepa/uv extension module."""
2+
23
import logging
34
import asyncio
45
from typing import Optional
@@ -46,6 +47,7 @@ class HepaUVState:
4647
uv_duration_s: int
4748
remaining_time_s: int
4849
uv_current_ma: int
50+
safety_relay_active: bool
4951

5052

5153
async def set_hepa_fan_state(
@@ -136,6 +138,7 @@ def _listener(message: MessageDefinition, arb_id: ArbitrationId) -> None:
136138
uv_duration_s=int(message.payload.uv_duration_s.value),
137139
remaining_time_s=int(message.payload.remaining_time_s.value),
138140
uv_current_ma=int(message.payload.uv_current_ma.value),
141+
safety_relay_active=bool(message.payload.safety_relay_active.value),
139142
)
140143

141144
def _filter(arb_id: ArbitrationId) -> bool:

hardware/tests/opentrons_hardware/hardware_control/test_hepauv_settings.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def create_hepa_uv_state_response(
5555
duration: int,
5656
remaining_time: int,
5757
uv_current: int,
58+
safety_relay_active: bool,
5859
) -> MessageDefinition:
5960
"""Create a GetHepaUVStateResponse."""
6061
return md.GetHepaUVStateResponse(
@@ -63,6 +64,7 @@ def create_hepa_uv_state_response(
6364
uv_duration_s=UInt32Field(duration),
6465
remaining_time_s=UInt32Field(remaining_time),
6566
uv_current_ma=UInt16Field(uv_current),
67+
safety_relay_active=UInt8Field(safety_relay_active),
6668
)
6769
)
6870

@@ -162,12 +164,29 @@ def responder(
162164
[
163165
(
164166
NodeId.host,
165-
create_hepa_uv_state_response(True, 900, 300, 3300),
167+
create_hepa_uv_state_response(True, 900, 300, 3300, True),
168+
NodeId.hepa_uv,
169+
),
170+
(
171+
NodeId.host,
172+
create_hepa_uv_state_response(True, 0, 0, 33000, True),
173+
NodeId.hepa_uv,
174+
),
175+
(
176+
NodeId.host,
177+
create_hepa_uv_state_response(True, 0, 0, 33000, False),
178+
NodeId.hepa_uv,
179+
),
180+
(
181+
NodeId.host,
182+
create_hepa_uv_state_response(False, 0, 0, 0, True),
183+
NodeId.hepa_uv,
184+
),
185+
(
186+
NodeId.host,
187+
create_hepa_uv_state_response(False, 900, 0, 0, False),
166188
NodeId.hepa_uv,
167189
),
168-
(NodeId.host, create_hepa_uv_state_response(True, 0, 0, 33000), NodeId.hepa_uv),
169-
(NodeId.host, create_hepa_uv_state_response(False, 0, 0, 0), NodeId.hepa_uv),
170-
(NodeId.host, create_hepa_uv_state_response(False, 900, 0, 0), NodeId.hepa_uv),
171190
],
172191
)
173192
async def test_get_hepa_uv_state(
@@ -202,6 +221,7 @@ def responder(
202221
int(payload.uv_duration_s.value),
203222
int(payload.remaining_time_s.value),
204223
int(payload.uv_current_ma.value),
224+
bool(payload.safety_relay_active.value),
205225
)
206226
== res
207227
)

0 commit comments

Comments
 (0)