improvement: Automatically build polling commands basing on the fields
This commit is contained in:
1 parent
0e5c1a0b44
commit
a1e9c180b3
10 files changed
+69
-113
No files matched your search
@@ -34,6 +34,7 @@ class EP500P(ProtocolV1Device):
|
||||
self.struct.add_decimal_field("pack_voltage", 98, 2) # Full pack voltage
|
||||
self.struct.add_uint_field("pack_battery_percent", 99)
|
||||
self.struct.add_decimal_array_field("cell_voltages", 105, 16, 2) # internal
|
||||
self.struct.add_version_field("pack_bms_version", 201)
|
||||
|
||||
# Controls
|
||||
self.struct.add_enum_field("ups_mode", 3001, UpsMode)
|
||||
@@ -49,17 +50,9 @@ class EP500P(ProtocolV1Device):
|
||||
|
||||
@property
|
||||
def polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return super().polling_commands + [
|
||||
ReadHoldingRegisters(70, 11),
|
||||
ReadHoldingRegisters(86, 3),
|
||||
ReadHoldingRegisters(92, 1),
|
||||
ReadHoldingRegisters(3001, 1),
|
||||
ReadHoldingRegisters(3004, 2),
|
||||
ReadHoldingRegisters(3011, 1),
|
||||
ReadHoldingRegisters(3013, 1),
|
||||
ReadHoldingRegisters(3015, 2),
|
||||
ReadHoldingRegisters(3061, 1),
|
||||
]
|
||||
return self.struct.get_read_holding_registers(
|
||||
filter=lambda address: address <= 90 or address >= 256 # pack_polling_commands
|
||||
)
|
||||
|
||||
@property
|
||||
def writable_ranges(self) -> List[range]:
|
||||
@@ -71,8 +64,6 @@ class EP500P(ProtocolV1Device):
|
||||
@property
|
||||
def pack_polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return [
|
||||
ReadHoldingRegisters(91, 2),
|
||||
ReadHoldingRegisters(96, 1),
|
||||
ReadHoldingRegisters(98, 2),
|
||||
ReadHoldingRegisters(105, 16),
|
||||
ReadHoldingRegisters(91, 37),
|
||||
ReadHoldingRegisters(201, 2),
|
||||
]
|
||||
Reference in new issue
Block a user