3.1.4. waf_tools.battery_cell_config_validate

Validate battery cell configuration files.

This module validates the battery_cell_cfg.json configuration file used by the foxBMS build system. It parses the JSON structure into typed dataclasses representing the battery cell’s electrical and thermal operating limits and ensures all required defines are present and have the declared type.

The following configuration sections are validated:
  • Temperature limits (charge/discharge) - MSL, RSL, MOL thresholds in deci-degrees Celsius.

  • Voltage limits - Maximum, nominal, and minimum cell voltages in mV.

  • Current limits (charge/discharge) - MSL, RSL, MOL thresholds in mA.

  • Capacity - Cell capacity (mAh) and energy (Wh).

  • Lookup tables - File references for SOC and SOE estimation tables.

The validation is performed during the waf build phase. Any raised error is reported by waf_tools.config_codegen_task.CreateCfgFile, which then fails the task and thereby the build.

3.1.4.1. Usage

The validator is typically passed as a callback to the codegen_config feature in a waf build script:

bld(
    features="codegen_config",
    json=bld.srcnode.find_node("conf/bms/battery_cell_cfg.json"),
    validator=battery_cell_config_validate.validate_battery_cell_configuration,
    target=f"{cp}battery_cell_cfg",
)

It can also be called directly:

cfg = validate_battery_cell_configuration(bld, battery_cell_json_node)

3.1.4.2. Dependencies

Functions

parse_battery_cell_config(cfg)

Parse a raw JSON dictionary into a validated battery cell configuration.

validate_battery_cell_configuration(bld, ...)

Validate the battery cell configuration JSON file.

Classes

BatteryCellConfiguration(...)

Complete validated battery cell configuration.

CellCapacity(capacity_mah, energy_wh)

Battery cell capacity and energy rating.

CellCurrentLimits(max_msl_ma, max_rsl_ma, ...)

Operating current limits for a battery cell in one direction.

CellLookupTables(soc_lookup_table, ...)

File references for SOC and SOE lookup tables.

CellTemperatureLimits(max_msl_ddegc, ...)

Operating temperature limits for a battery cell.

CellVoltageLimits(max_msl_mv, max_rsl_mv, ...)

Operating voltage limits for a battery cell.

Exceptions

InvalidBatteryCellConfigurationError

Raised for an invalid battery cell configuration.