wait_modbus_input(iobus, val, timeout=None)
Features
This function waits until the specified signal value of the Modbus digital I/O becomes val (ON or OFF). The waiting time can be changed with a timeout setting. The waiting time ends, and the result is returned if the waiting time has passed. This function waits indefinitely if the timeout is not set.
Parameters
Parameter Name | Data Type | Default Value | Description |
iobus | string | - | Modbus name (set in the TP) |
value | int | - | Modbus digital I/O
|
Value for Modbus analog I/O | |||
timeout | float | - | Waiting time (sec) This function waits indefinitely if the timeout is not set. |
Note
When registered as a multiple signal, it is available by adding address value index to signal name.
Return
Value | Description |
---|---|
0 | Success |
-1 | Failed (time-out) |
Exception
Exception | Description |
---|---|
DR_Error (DR_ERROR_TYPE) | Parameter data type error occurred |
DR_Error (DR_ERROR_VALUE) | Parameter value is invalid |
DR_Error (DR_ERROR_RUNTIME) | C extension module error occurred |
DR_Error (DR_ERROR_STOP) | Program terminated forcefully |
Example
wait_modbus_input("CIN0", ON) # Indefinite wait until the "CIN0" signal becomes ON
wait_modbus_input("CIN0", OFF) # Indefinite wait until the "CIN0" signal becomes OFF
res = wait_modbus_input("CIN0", ON, 3) # Wait for up to 3 seconds until the "CIN0" signal becomes ON
# res = 0 if the "CIN0" signal becomes ON within 3 seconds.
# res = -1 if the "CIN0" signal does not become ON within 3 seconds.
#Modbus multiple signal is registered as “multi”(start address=10, cnt=2).
#“multi_10” & “multi_11” abailable
wait_modbus_input("multi_10")
wait_modbus_input("multi_11")