coil event processed immediately
This commit is contained in:
parent
882571425b
commit
5f3d50090a
@ -72,7 +72,10 @@ def modbusHandler(config, processImage):
|
|||||||
logger.error("Exception in inner modbus handler loop: {}".format(e))
|
logger.error("Exception in inner modbus handler loop: {}".format(e))
|
||||||
client.close()
|
client.close()
|
||||||
finally:
|
finally:
|
||||||
sleep(modbusRefreshPeriod)
|
#sleep(modbusRefreshPeriod)
|
||||||
|
if (processImage.coilEvent.wait(timeout=modbusRefreshPeriod)):
|
||||||
|
processImage.coilEvent.clear()
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Exception in modbus handler: {}".format(e))
|
logger.error("Exception in modbus handler: {}".format(e))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from threading import Condition
|
from threading import Condition, Event
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
def zippingFilter(a, b):
|
def zippingFilter(a, b):
|
||||||
@ -9,6 +9,7 @@ class NotInitializedException(Exception): pass
|
|||||||
class ProcessImage(Condition):
|
class ProcessImage(Condition):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
self.coilEvent = Event()
|
||||||
self.initialized = False
|
self.initialized = False
|
||||||
|
|
||||||
def init(self, numCoils, numDiscreteInputs, numAnalogInputs):
|
def init(self, numCoils, numDiscreteInputs, numAnalogInputs):
|
||||||
@ -61,6 +62,7 @@ class ProcessImage(Condition):
|
|||||||
if not self.initialized:
|
if not self.initialized:
|
||||||
raise NotInitializedException
|
raise NotInitializedException
|
||||||
self.coils[coilNum] = value
|
self.coils[coilNum] = value
|
||||||
|
self.coilEvent.set()
|
||||||
|
|
||||||
# def getChangedCoils(self):
|
# def getChangedCoils(self):
|
||||||
# if not self.initialized:
|
# if not self.initialized:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user