hitl_tester.test_cases.bms.smart_charger

Test Smart Charger
GitHub Issue(s) turnaroundfactor/HITL#314
Description Tests that our BB2590 works on a smart charger

Used in these test plans:

  • smart_charger_a ⠀⠀⠀(bms/smart_charger_a.plan)
  • smart_charger_b ⠀⠀⠀(bms/smart_charger_b.plan)

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

  • ./hitl_tester.py smart_charger_a -DSAMPLE_TIME=10
 1"""
 2| Test                 | Smart Charger                                                       |
 3| :------------------- | :------------------------------------------------------------------ |
 4| GitHub Issue(s)      | turnaroundfactor/HITL#314                                    |
 5| Description          | Tests that our BB2590 works on a smart charger                      |
 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
16from hitl_tester.modules.bms.plateset import Plateset
17
18SAMPLE_TIME = 10
19
20_bms = BMSHardware(pytest.flags)  # type: ignore[arg-type]
21_bms.init()
22_plateset = Plateset()
23
24
25@pytest.mark.sim_cells
26def test_smart_charger():
27    """
28    | Requirement          | Smart Charger                                                              |
29    | :------------------- | :------------------------------------------------------------------------- |
30    | GitHub Issue(s)      | turnaroundfactor/HITL#314                                           |
31    | Instructions         | 1. Enable CE                                                          </br>\
32                             2. Monitor cell sims and serial                                            |
33    | Pass / Fail Criteria | Manually confirm we can charge                                             |
34    """
35
36    _plateset.charger_switch = True
37    logger.write_info_to_report("Charge relay enabled")
38
39    # Begin recording
40    logger.write_info_to_report("Starting monitor...")
41    start = time.perf_counter()
42    while True:
43        elapsed_time = time.perf_counter() - start
44        _bms.csv.cycle_smbus.record(elapsed_time, suppress_smbus=True)
45        voltages = [f"{cell.measured_volts:.2f}V" for cell in _bms.cells.values()]
46        logger.write_info_to_report(f"Elapsed Time: {elapsed_time}, Cell Voltages: {', '.join(voltages)}, ")
47        time.sleep(SAMPLE_TIME)
SAMPLE_TIME = 10
@pytest.mark.sim_cells
def test_smart_charger():
26@pytest.mark.sim_cells
27def test_smart_charger():
28    """
29    | Requirement          | Smart Charger                                                              |
30    | :------------------- | :------------------------------------------------------------------------- |
31    | GitHub Issue(s)      | turnaroundfactor/HITL#314                                           |
32    | Instructions         | 1. Enable CE                                                          </br>\
33                             2. Monitor cell sims and serial                                            |
34    | Pass / Fail Criteria | Manually confirm we can charge                                             |
35    """
36
37    _plateset.charger_switch = True
38    logger.write_info_to_report("Charge relay enabled")
39
40    # Begin recording
41    logger.write_info_to_report("Starting monitor...")
42    start = time.perf_counter()
43    while True:
44        elapsed_time = time.perf_counter() - start
45        _bms.csv.cycle_smbus.record(elapsed_time, suppress_smbus=True)
46        voltages = [f"{cell.measured_volts:.2f}V" for cell in _bms.cells.values()]
47        logger.write_info_to_report(f"Elapsed Time: {elapsed_time}, Cell Voltages: {', '.join(voltages)}, ")
48        time.sleep(SAMPLE_TIME)
Requirement Smart Charger
GitHub Issue(s) turnaroundfactor/HITL#314
Instructions 1. Enable CE
2. Monitor cell sims and serial
Pass / Fail Criteria Manually confirm we can charge