read separate battery firmware version

This commit is contained in:
Yinyin Liu 2024-07-02 13:26:03 +02:00
parent 02037ab765
commit 93c062ec90
3 changed files with 10 additions and 10 deletions

View File

@ -243,7 +243,7 @@ def time_since_toc_in_time_format(status):
# Format the string to show days.hours:minutes:seconds
return f"{days}.{hours:02}:{minutes:02}:{seconds:02}"
def create_csv_signals(firmware_version):
def create_csv_signals():
read_voltage = c.read_float(register=999, scale_factor=0.01, offset=0, places=2)
read_current = c.read_float(register=1000, scale_factor=0.01, offset=-10000, places=2)
read_limb_bitmap = c.read_bitmap(1059)
@ -319,7 +319,7 @@ def create_csv_signals(firmware_version):
return soc_ah(status)
return [
CsvSignal('/Battery/Devices/FwVersion', firmware_version),
CsvSignal('/Battery/Devices/FwVersion', lambda bs: bs.battery.firmware_version),
CsvSignal('/Battery/Devices/Dc/Power', read_power, 'W'),
CsvSignal('/Battery/Devices/Dc/Voltage', read_voltage, 'V'),
CsvSignal('/Battery/Devices/Soc', c.read_float(register=1053, scale_factor=0.1, offset=0, places=1), '%'),
@ -353,8 +353,8 @@ def create_csv_signals(firmware_version):
CsvSignal('/Battery/Devices/MaxDischargePower', calc_max_discharge_power),
]
def init_signals(hardware_version, firmware_version, n_batteries):
# type: (str,str,int) -> Iterable[Signal]
def init_signals(n_batteries):
# type: (int) -> Iterable[Signal]
"""
A Signal holds all information necessary for the handling of a
certain datum (e.g. voltage) published by the battery.
@ -459,9 +459,9 @@ def init_signals(hardware_version, firmware_version, n_batteries):
Signal('/ProductName', c.first, product_name),
Signal('/ProductId', c.first, cfg.PRODUCT_ID, product_id_hex),
Signal('/Connected', c.first, 1),
Signal('/FirmwareVersion', c.return_in_list, firmware_version),
Signal('/HardwareVersion', c.first, cfg.HARDWARE_VERSION, hardware_version),
Signal('/BmsVersion', c.first, lambda s: s.battery.bms_version),
Signal('/FirmwareVersion', c.return_in_list, lambda bs: bs.battery.firmware_version),
Signal('/HardwareVersion', c.return_in_list, lambda bs: bs.battery.hardware_version),
Signal('/BmsVersion', c.return_in_list, lambda s: s.battery.bms_version),
# Warnings
Signal('/WarningFlags/TaM1', c.return_in_list, c.read_bool(register=1005, bit=1)),
Signal('/WarningFlags/TbM1', c.return_in_list, c.read_bool(register=1005, bit=4)),

View File

@ -514,7 +514,7 @@ def create_update_task(modbus, service, batteries):
_socket = init_udp_socket()
_signals = signals.init_battery_signals()
csv_signals = signals.create_csv_signals(first(batteries).firmware_version)
csv_signals = signals.create_csv_signals()
node_numbers = [battery.slave_address for battery in batteries]
warnings_signals, alarm_signals = signals.read_warning_and_alarm_flags()
current_warnings = {}

View File

@ -227,7 +227,7 @@ def init_battery_signals():
BatterySignal('/BmsVersion', comma_separated, lambda bs: bs.battery.bms_version)
]
def create_csv_signals(firmware_version):
def create_csv_signals():
total_current = read_float(register=1062, scale_factor=0.01, offset=-10000)
def read_total_current(status):
@ -294,7 +294,7 @@ def create_csv_signals(firmware_version):
return "{}.{:02}:{:02}:{:02}".format(days, hours, minutes, seconds)
return [
CsvSignal('/Battery/Devices/FwVersion', firmware_version),
CsvSignal('/Battery/Devices/FwVersion', lambda bs: bs.battery.firmware_version),
CsvSignal('/Battery/Devices/Dc/Power', read_power, 'W'),
CsvSignal('/Battery/Devices/Dc/Voltage', read_voltage(), 'V'),
CsvSignal('/Battery/Devices/Soc', read_float(register=1053, scale_factor=0.1, offset=0), '%'),