hitl_tester.test_cases.bms.test_chamber_reading

Test Thermal chamber calibration
GitHub Issue(s) turnaroundfactor/HITL#347
Description Assist in thermal chamber calibration.

Used in these test plans:

  • chamber_loop ⠀⠀⠀(bms/chamber_loop.plan)

Example Command (warning: test plan may run other test cases):

  • ./hitl_tester.py chamber_loop -DCHAMBER_UNITS=C -DSAMPLE_RATE=2 -DSET_POINT=None
 1"""
 2| Test                 | Thermal chamber calibration            |
 3| :------------------- | :------------------------------------- |
 4| GitHub Issue(s)      | turnaroundfactor/HITL#347       |
 5| Description          | Assist in thermal chamber calibration. |
 6"""
 7
 8from __future__ import annotations
 9
10import time
11
12import pytest
13
14from hitl_tester.modules.bms.bms_hw import BMSHardware
15from hitl_tester.modules.logger import logger
16
17CHAMBER_UNITS = "C"
18"""The temperature unit for the thermal chamber readings and set point. Valid values are "C" and "F"."""
19SAMPLE_RATE = 2
20"""How often (in seconds) to measure temperature."""
21SET_POINT: float | None = None
22"""The set point temperature. Only set when this property is given a value."""
23
24_bms = BMSHardware(pytest.flags)  # type: ignore[arg-type]
25_bms.init()
26
27
28def test_thermal_chamber_readings():
29    """
30    | Description          | Output thermal chamber temperatures in a loop |
31    | :------------------- | :-------------------------------------------- |
32    | GitHub Issue         | turnaroundfactor/HITL#347              |
33    """
34    _bms.thermal_chamber.internal_units = CHAMBER_UNITS
35    _bms.thermal_chamber.display_units = CHAMBER_UNITS
36
37    if isinstance(SET_POINT, (int, float)):
38        _bms.thermal_chamber.set_point_temperature = SET_POINT
39
40    while True:
41        logger.write_info_to_report(f"Chamber temperature: {_bms.thermal_chamber.air_temperature}°{CHAMBER_UNITS}")
42        time.sleep(SAMPLE_RATE)
CHAMBER_UNITS = 'C'

The temperature unit for the thermal chamber readings and set point. Valid values are "C" and "F".

SAMPLE_RATE = 2

How often (in seconds) to measure temperature.

SET_POINT: float | None = None

The set point temperature. Only set when this property is given a value.

def test_thermal_chamber_readings():
29def test_thermal_chamber_readings():
30    """
31    | Description          | Output thermal chamber temperatures in a loop |
32    | :------------------- | :-------------------------------------------- |
33    | GitHub Issue         | turnaroundfactor/HITL#347              |
34    """
35    _bms.thermal_chamber.internal_units = CHAMBER_UNITS
36    _bms.thermal_chamber.display_units = CHAMBER_UNITS
37
38    if isinstance(SET_POINT, (int, float)):
39        _bms.thermal_chamber.set_point_temperature = SET_POINT
40
41    while True:
42        logger.write_info_to_report(f"Chamber temperature: {_bms.thermal_chamber.air_temperature}°{CHAMBER_UNITS}")
43        time.sleep(SAMPLE_RATE)
Description Output thermal chamber temperatures in a loop
GitHub Issue turnaroundfactor/HITL#347