read coils 5
This commit is contained in:
@@ -39,17 +39,17 @@ class ModbusHandler(threading.Thread):
|
|||||||
|
|
||||||
self.processImage.init(digitalOutputBits, digitalInputBits, analogInputBits)
|
self.processImage.init(digitalOutputBits, digitalInputBits, analogInputBits)
|
||||||
|
|
||||||
reg = client.read_coils(0, digitalOutputBits)
|
|
||||||
if isinstance(reg, ModbusIOException):
|
|
||||||
raise Exception(reg)
|
|
||||||
with self.processImage:
|
|
||||||
self.processImage.setCoils(reg.bits)
|
|
||||||
|
|
||||||
while not self.killBill:
|
while not self.killBill:
|
||||||
try:
|
try:
|
||||||
if not client.is_socket_open():
|
if not client.is_socket_open():
|
||||||
client.connect()
|
client.connect()
|
||||||
|
|
||||||
|
reg = client.read_coils(0, digitalOutputBits)
|
||||||
|
if isinstance(reg, ModbusIOException):
|
||||||
|
raise Exception(reg)
|
||||||
|
readCoils = reg.bits
|
||||||
|
|
||||||
reg = client.read_input_registers(0, analogInputBits // 8)
|
reg = client.read_input_registers(0, analogInputBits // 8)
|
||||||
if isinstance(reg, ModbusIOException):
|
if isinstance(reg, ModbusIOException):
|
||||||
raise Exception(reg)
|
raise Exception(reg)
|
||||||
@@ -64,6 +64,7 @@ class ModbusHandler(threading.Thread):
|
|||||||
with self.processImage:
|
with self.processImage:
|
||||||
self.processImage.setAnalogsInputs(analogInputs)
|
self.processImage.setAnalogsInputs(analogInputs)
|
||||||
self.processImage.setDiscreteInputs(discreteInputs)
|
self.processImage.setDiscreteInputs(discreteInputs)
|
||||||
|
self.processImage.setCoils(readCoils)
|
||||||
if self.processImage.hasPendingInputChanges():
|
if self.processImage.hasPendingInputChanges():
|
||||||
self.processImage.notify()
|
self.processImage.notify()
|
||||||
if self.processImage.hasPendingOutputChanges():
|
if self.processImage.hasPendingOutputChanges():
|
||||||
|
|||||||
Reference in New Issue
Block a user