better reset stats handling
This commit is contained in:
@ -170,17 +170,16 @@ class DiscreteInputDatapoint(ReadOnlyDatapoint):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def resetStatsRegisterList(registers):
|
|
||||||
for r in registers:
|
|
||||||
r.errorCount = 0
|
|
||||||
r.processCount = 0
|
|
||||||
r.enqueued = False
|
|
||||||
|
|
||||||
def checkRegisterList(registers):
|
def checkRegisterList(registers, reset=False):
|
||||||
for r in registers:
|
for r in registers:
|
||||||
if not isinstance(r, AbstractModbusDatapoint):
|
if not isinstance(r, AbstractModbusDatapoint):
|
||||||
raise ValueError('Entry in register list {0!s} is not derived from class AbstractModbusDatapoint'.format(r))
|
raise ValueError('Entry in register list {0!s} is not derived from class AbstractModbusDatapoint'.format(r))
|
||||||
else:
|
else:
|
||||||
|
if reset:
|
||||||
|
r.errorCount = 0
|
||||||
|
r.processCount = 0
|
||||||
|
r.enqueued = False
|
||||||
print("Datapoint loaded: {0!s}".format(r))
|
print("Datapoint loaded: {0!s}".format(r))
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,8 +21,7 @@ if __name__ == "__main__":
|
|||||||
datapoints = None
|
datapoints = None
|
||||||
with open(config.registerFile, 'rb') as f:
|
with open(config.registerFile, 'rb') as f:
|
||||||
datapoints = pickle.load(f)
|
datapoints = pickle.load(f)
|
||||||
RegisterDatapoint.checkRegisterList(datapoints)
|
RegisterDatapoint.checkRegisterList(datapoints, reset=True)
|
||||||
RegisterDatapoint.resetStatsRegisterList(datapoints)
|
|
||||||
|
|
||||||
cp = CommunicationProcessor.CommunicationProcessor(config, queue, pubQueue)
|
cp = CommunicationProcessor.CommunicationProcessor(config, queue, pubQueue)
|
||||||
cp.start()
|
cp.start()
|
||||||
|
Reference in New Issue
Block a user