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:
|
||||
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))
|
||||
|
||||
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user