diff --git a/README.md b/README.md index e83617c..6bf7b33 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # ModbusSim -Fork of Modbus RTU/TCP simulator with a REST api attached with additional read registers (instantaneous_registers, tariff_data_registers, current_data_registers, prev1_data_registers). For now, this additional registers can be imported only by using '/dump' endpoint. +Fork of Modbus RTU/TCP simulator with a REST api attached with additional read registers (instantaneous_registers, meter_registers, tariff_data_registers, current_data_registers, prev1_data_registers). For now, this additional registers can be imported only by using '/dump' endpoint. Looked for a long time for a modbus RTU simulator that could do single server multi-slave simulations and couldn't find anything quite suitable. Something that could be used to rapidly stand-up and teardown various multi-slave setups programatically in modern distributed REST API based systems. Most tools seemed to be written for non-software developers and mostly for windows users. diff --git a/src/modbussim/modbussim.py b/src/modbussim/modbussim.py index dbe8efe..40c08d8 100644 --- a/src/modbussim/modbussim.py +++ b/src/modbussim/modbussim.py @@ -82,6 +82,7 @@ def get_log_buffer(self, prefix, buff): class ModbusSim(Simulator): INSTANTANEOUS_REGISTERS_START_ADDRESS = 0 + METER_REGISTERS_START_ADDRESS = 1026 TARIFF_REGISTERS_START_ADDRESS = 2048 CURRENT_REGISTERS_START_ADDRESS = 16384 PREV1_REGISTERS_START_ADDRESS = 16896 @@ -181,6 +182,7 @@ def load_slave_dump(self, dump): self.load_register(dump, 'input_register_count', 'input_registers', 4, self.HOLDING_REGISTERS_START_ADDRESS, registersDict) self.load_register(dump, 'holding_register_count', 'holding_registers', 3, self.INPUT_REGISTERS_START_ADDRESS, registersDict) self.load_register(dump, 'instantaneous_register_count', 'instantaneous_registers', 3, self.INSTANTANEOUS_REGISTERS_START_ADDRESS, registersDict) + self.load_register(dump, 'meter_register_count', 'meter_registers', 3, self.METER_REGISTERS_START_ADDRESS, registersDict) self.load_register(dump, 'tariff_data_register_count', 'tariff_data_registers', 3, self.TARIFF_REGISTERS_START_ADDRESS, registersDict) self.load_register(dump, 'current_data_register_count', 'current_data_registers', 3, self.CURRENT_REGISTERS_START_ADDRESS, registersDict) self.load_register(dump, 'prev1_data_register_count', 'prev1_data_registers', 3, self.PREV1_REGISTERS_START_ADDRESS, registersDict) diff --git a/src/server.py b/src/server.py index 304592a..2c9b4a0 100644 --- a/src/server.py +++ b/src/server.py @@ -247,6 +247,14 @@ def load_dump(): type: array description: "Array of Instantaneous Register Values" example: [ 1, 2, 3 ] + meter_register_count: + type: integer + description: "Metric Value" + example: 9999 + meter_registers: + type: array + description: "Array of Meter Register Values" + example: [ 1, 2, 3 ] tariff_data_register_count: type: integer description: "Metric Value"