fix
This commit is contained in:
parent
4575bea50e
commit
a37f4945d8
@ -1,30 +1,22 @@
|
||||
|
||||
def dummyPublisher(processImage):
|
||||
while True:
|
||||
discreteInputChangeset = []
|
||||
analogInputChangeset = []
|
||||
|
||||
with processImage:
|
||||
processImage.wait()
|
||||
|
||||
discreteInputChangeset = processImage.getChangedDiscreteInputs()
|
||||
analogInputChangeset = processImage.getChangedAnalogsInputs()
|
||||
|
||||
if discreteInputChangeset != []:
|
||||
print("Discrete: {}".format(discreteInputChangeset))
|
||||
if analogInputChangeset != []:
|
||||
print("Analog: {}".format(analogInputChangeset))
|
||||
for discreteInputChangeItem in discreteInputChangeset:
|
||||
print("Discrete input {} changed from {} to {}"
|
||||
.format(discreteInputChangeItem[0],
|
||||
discreteInputChangeItem[1][1],
|
||||
discreteInputChangeItem[1][0]))
|
||||
|
||||
# for discreteInputChangeItem in discreteInputChangeset:
|
||||
# print("Discrete input {} changed from {} to {}"
|
||||
# .format(discreteInputChangeItem[0]),
|
||||
# discreteInputChangeItem[1][1],
|
||||
# discreteInputChangeItem[1][0])
|
||||
#
|
||||
# for analogInputChangeItem in analogInputChangeset:
|
||||
# print("Analog input {} changed from {} to {}"
|
||||
# .format(analogInputChangeItem[0]),
|
||||
# analogInputChangeItem[1][1],
|
||||
# analogInputChangeItem[1][0])
|
||||
for analogInputChangeItem in analogInputChangeset:
|
||||
print("Analog input {} changed from {} to {}"
|
||||
.format(analogInputChangeItem[0],
|
||||
analogInputChangeItem[1][1],
|
||||
analogInputChangeItem[1][0]))
|
||||
|
||||
|
||||
|
@ -54,7 +54,7 @@ def modbusHandler(processImage):
|
||||
processImage.setDiscreteInputs(discreteInputs)
|
||||
if processImage.hasPendingInputChanges():
|
||||
processImage.notify()
|
||||
if processImage.hasPendingOutputChanges:
|
||||
if processImage.hasPendingOutputChanges():
|
||||
coils = processImage.getCoils()
|
||||
|
||||
if coils:
|
||||
|
@ -2,7 +2,7 @@ from threading import Condition
|
||||
|
||||
|
||||
def zippingFilter(a, b):
|
||||
return [ x for x in enumerate(zip(a, b)) if x[1][0] == x[1][1] ]
|
||||
return [ x for x in enumerate(zip(a, b)) if x[1][0] != x[1][1] ]
|
||||
|
||||
class NotInitializedException(Exception): pass
|
||||
|
||||
@ -40,12 +40,8 @@ class ProcessImage(Condition):
|
||||
def getChangedDiscreteInputs(self):
|
||||
if not self.initialized:
|
||||
raise NotInitializedException
|
||||
print("D1: {}".format(self.discreteInputs))
|
||||
print("D2: {}".format(self.shadowDiscreteInputs))
|
||||
changedDiscreteInputs = zippingFilter(self.discreteInputs, self.shadowDiscreteInputs)
|
||||
print("D3: {}".format(changedDiscreteInputs))
|
||||
self.shadowDiscreteInputs = self.discreteInputs
|
||||
print("D4: {}".format(self.shadowDiscreteInputs))
|
||||
return changedDiscreteInputs
|
||||
|
||||
def getDiscreteInputs(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user