fix in converter and json handling

This commit is contained in:
Wolfgang Hottgenroth 2019-07-17 15:06:28 +01:00
parent 264d1cab14
commit ac47ff0ebe
3 changed files with 9 additions and 8 deletions

View File

@ -13,6 +13,6 @@ Converters = {
}, },
"uint32": { "uint32": {
"in": lambda x : unpack('L', pack('HH', *x))[0], "in": lambda x : unpack('L', pack('HH', *x))[0],
"out": lambda x : unpack('HH', pack('L', x)) "out": lambda x : unpack('HH', pack('L', int(x)))
} }
} }

View File

@ -10,7 +10,7 @@ class DatapointException(Exception): pass
class AbstractModbusDatapoint(object): class AbstractModbusDatapoint(object):
def __init__(self, label=None, unit=None, address=None, count=None, scanRate=None, converter=None): def __init__(self, label=None, unit=None, address=None, count=None, scanRate=None, converter=None):
self.argList = ['label', 'unit', 'address', 'count', 'scanRate'] self.argList = ['label', 'unit', 'address', 'count', 'scanRate', 'converter']
self.label = label self.label = label
self.unit = unit self.unit = unit
self.address = address self.address = address
@ -167,6 +167,7 @@ class DiscreteInputDatapoint(ReadOnlyDatapoint):
def __init__(self, label=None, unit=None, address=None, count=None, scanRate=None, updateOnly=None, def __init__(self, label=None, unit=None, address=None, count=None, scanRate=None, updateOnly=None,
publishTopic=None, converter=None, bitCount=8): publishTopic=None, converter=None, bitCount=8):
super().__init__(label, unit, address, count, scanRate, updateOnly, publishTopic, converter) super().__init__(label, unit, address, count, scanRate, updateOnly, publishTopic, converter)
self.argList = self.argList + ['bitCount']
self.type = 'discrete input' self.type = 'discrete input'
self.bitCount = bitCount self.bitCount = bitCount

View File

@ -6,7 +6,7 @@
"label": "Temperature", "label": "Temperature",
"converter": "dht20TOFloat", "converter": "dht20TOFloat",
"publishTopic": "Pub/Temperature", "publishTopic": "Pub/Temperature",
"scanRate": 1.0, "scanRate": 10.0,
"unit": 5, "unit": 5,
"updateOnly": false "updateOnly": false
}, },
@ -45,7 +45,7 @@
"label": "Counter1", "label": "Counter1",
"converter": "uint32", "converter": "uint32",
"publishTopic": "Pub/Counter1", "publishTopic": "Pub/Counter1",
"scanRate": null, "scanRate": 1.0,
"subscribeTopic": "Sub/Counter1", "subscribeTopic": "Sub/Counter1",
"unit": 4 "unit": 4
}, },
@ -56,8 +56,8 @@
"address": 40012, "address": 40012,
"count": 2, "count": 2,
"feedbackTopic": "FB/Counter2", "feedbackTopic": "FB/Counter2",
"label": "Counter2",
"converter": "uint32", "converter": "uint32",
"label": "Counter2",
"publishTopic": "Pub/Counter2", "publishTopic": "Pub/Counter2",
"scanRate": null, "scanRate": null,
"subscribeTopic": "Pub/Counter2", "subscribeTopic": "Pub/Counter2",
@ -70,8 +70,8 @@
"address": 40014, "address": 40014,
"count": 2, "count": 2,
"feedbackTopic": "FB/Counter3", "feedbackTopic": "FB/Counter3",
"label": "Counter3",
"converter": "uint32", "converter": "uint32",
"label": "Counter3",
"publishTopic": "Pub/Counter3", "publishTopic": "Pub/Counter3",
"scanRate": null, "scanRate": null,
"subscribeTopic": "FB/Counter3", "subscribeTopic": "FB/Counter3",
@ -84,13 +84,13 @@
"address": 40016, "address": 40016,
"count": 2, "count": 2,
"feedbackTopic": "FB/Counter4", "feedbackTopic": "FB/Counter4",
"label": "Counter4",
"converter": "uint32", "converter": "uint32",
"label": "Counter4",
"publishTopic": "Pub/Counter4", "publishTopic": "Pub/Counter4",
"scanRate": 1.0, "scanRate": 1.0,
"subscribeTopic": "Sub/Counter4", "subscribeTopic": "Sub/Counter4",
"unit": 4 "unit": 4
}, },
"type": "HoldingRegisterDatapoint" "type": "HoldingRegisterDatapoint"
}, }
] ]