better reset stats handling

This commit is contained in:
2019-07-10 12:21:48 +02:00
parent edeb4ea0f0
commit 3c6c420178
2 changed files with 6 additions and 8 deletions

View File

@ -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:
if not isinstance(r, AbstractModbusDatapoint):
raise ValueError('Entry in register list {0!s} is not derived from class AbstractModbusDatapoint'.format(r))
else:
if reset:
r.errorCount = 0
r.processCount = 0
r.enqueued = False
print("Datapoint loaded: {0!s}".format(r))

View File

@ -21,8 +21,7 @@ if __name__ == "__main__":
datapoints = None
with open(config.registerFile, 'rb') as f:
datapoints = pickle.load(f)
RegisterDatapoint.checkRegisterList(datapoints)
RegisterDatapoint.resetStatsRegisterList(datapoints)
RegisterDatapoint.checkRegisterList(datapoints, reset=True)
cp = CommunicationProcessor.CommunicationProcessor(config, queue, pubQueue)
cp.start()