Skip to content

Commit

Permalink
Added meter registers
Browse files Browse the repository at this point in the history
  • Loading branch information
mmitic committed May 29, 2020
1 parent 4f8850e commit 7f098e0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 2 additions & 0 deletions src/modbussim/modbussim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7f098e0

Please sign in to comment.