3.1.6. waf_tools.battery_system_config_validate

Validate battery system configuration files.

This module validates the battery_system_cfg.json configuration file used by the foxBMS build system. It parses the JSON structure into typed dataclasses representing the battery system’s topology, timing, current thresholds, operational flags, and hardware configuration.

The following configuration sections are validated:
  • Topology - Number of strings, modules, cell blocks, parallel cells, temperature sensors, and contactors.

  • Timeouts - Response timeouts for current, coulomb counting, and energy counting measurements in ms.

  • Currents - Maximum string current, rest current, no-current threshold, and contactor break current in mA.

  • Flags - Boolean operational switches (e.g. interlock feedback, CAN timing checks, balancing defaults, fuse placement checks).

  • Fuse - Trigger duration and maximum voltage drop configuration.

  • Relaxation - Relaxation period configuration.

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.6.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_system_cfg.json"),
    validator=battery_system_config_validate.validate_battery_system_configuration,
    target=f"{cp}battery_system_cfg",
)

It can also be called directly:

cfg = validate_battery_system_configuration(bld, battery_system_json_node)

3.1.6.2. Dependencies

Functions

parse_battery_system_config(cfg)

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

validate_battery_system_configuration(bld, ...)

Validate the battery system configuration JSON file.

Classes

BatterySystemConfiguration(topology, ...)

Complete validated battery system configuration.

SystemCurrents(maximum_string_current_ma, ...)

Battery system current thresholds.

SystemFlags(positive_discharge_current, ...)

Battery system boolean operational flags.

SystemFuse(...)

Battery system fuse configuration.

SystemRelaxation(relaxation_period_10ms)

Battery system relaxation configuration.

SystemTimeouts(...)

Battery system timeout configuration.

SystemTopology(nr_of_strings, ...)

Battery system topology configuration.

Exceptions

InvalidBatterySystemConfigurationError

Raised for an invalid battery system configuration.