Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(hardware): added safety relay active state to HepaUVState and safety_relay_inactive error #15311

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions hardware/opentrons_hardware/firmware_bindings/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
by default. Please do not unconditionally import things outside the python standard
library.
"""

from enum import Enum, unique
from typing import Union, Dict, List

Expand Down Expand Up @@ -294,6 +295,7 @@ class ErrorCode(int, Enum):
door_open = 0x0E
reed_open = 0x0F
motor_driver_error_detected = 0x10
safety_relay_inactive = 0x11


@unique
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Payloads of can bus messages."""

# TODO (amit, 2022-01-26): Figure out why using annotations import ruins
# dataclass fields interpretation.
# from __future__ import annotations
Expand Down Expand Up @@ -684,6 +685,7 @@ class GetHepaUVStatePayloadResponse(EmptyPayload):
uv_light_on: utils.UInt8Field
remaining_time_s: utils.UInt32Field
uv_current_ma: utils.UInt16Field
safety_relay_active: utils.UInt8Field


@dataclass(eq=False)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities for controlling the hepa/uv extension module."""

import logging
import asyncio
from typing import Optional
Expand Down Expand Up @@ -46,6 +47,7 @@ class HepaUVState:
uv_duration_s: int
remaining_time_s: int
uv_current_ma: int
safety_relay_active: bool


async def set_hepa_fan_state(
Expand Down Expand Up @@ -136,6 +138,7 @@ def _listener(message: MessageDefinition, arb_id: ArbitrationId) -> None:
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),
safety_relay_active=bool(message.payload.safety_relay_active.value),
)

def _filter(arb_id: ArbitrationId) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def create_hepa_uv_state_response(
duration: int,
remaining_time: int,
uv_current: int,
safety_relay_active: bool,
) -> MessageDefinition:
"""Create a GetHepaUVStateResponse."""
return md.GetHepaUVStateResponse(
Expand All @@ -63,6 +64,7 @@ def create_hepa_uv_state_response(
uv_duration_s=UInt32Field(duration),
remaining_time_s=UInt32Field(remaining_time),
uv_current_ma=UInt16Field(uv_current),
safety_relay_active=UInt8Field(safety_relay_active),
)
)

Expand Down Expand Up @@ -162,12 +164,29 @@ def responder(
[
(
NodeId.host,
create_hepa_uv_state_response(True, 900, 300, 3300),
create_hepa_uv_state_response(True, 900, 300, 3300, True),
NodeId.hepa_uv,
),
(
NodeId.host,
create_hepa_uv_state_response(True, 0, 0, 33000, True),
NodeId.hepa_uv,
),
(
NodeId.host,
create_hepa_uv_state_response(True, 0, 0, 33000, False),
NodeId.hepa_uv,
),
(
NodeId.host,
create_hepa_uv_state_response(False, 0, 0, 0, True),
NodeId.hepa_uv,
),
(
NodeId.host,
create_hepa_uv_state_response(False, 900, 0, 0, False),
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 @@ -202,6 +221,7 @@ def responder(
int(payload.uv_duration_s.value),
int(payload.remaining_time_s.value),
int(payload.uv_current_ma.value),
bool(payload.safety_relay_active.value),
)
== res
)
Loading