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