Skip to main content
Skip table of contents

wait_modbus_input(iobus, val, timeout=None)

기능

Modbus Slave 장치에서 지정한 신호값이 val(ON or OFF)이 될 때까지 대기합니다. 대기 시간은 timeout 설정으로 변경할 수 있으며, 지정된 시간이 지나면 대기 상태가 종료됨과 동시에 결과를 리턴합니다. , timeout을 설정하지 않으면 무한 대기합니다.

인수

인수명자료형기본값설명

iobus

string

-

modbus 이름 (TP에서 설정)

value


int

-

Modbus digital I/O 인 경우

  • ON : 1
  • OFF : 0
Modbus analog I/O 인 경우 value

timeout

float

-

대기 시간 [sec]

설정하지 않으면 무한 대기

알아두기

다중신호로 등록된 경우 신호이름에 인덱스[n]를 붙여 사용가능합니다.


리턴

설명

0

성공

-1

실패 (time-out)

예외

예외설명

DR_Error (DR_ERROR_TYPE)

인수들의 데이터형 오류 시

DR_Error (DR_ERROR_VALUE)

인수의 값이 유효하지 않을 시

DR_Error (DR_ERROR_RUNTIME)

C Extension 모듈 에러 발생 시

DR_Error (DR_ERROR_STOP)

프로그램 강제 종료 시

예제

PY
wait_modbus_input("CIN0", ON)  #"CIN0" 신호가 ON될 때까지 무한 대기 
wait_modbus_input("CIN0", OFF)  #"CIN0" 신호가 OFF될 때까지 무한 대기

res = wait_modbus_input("CIN0", ON, 3) #"CIN0" 신호가 ON될 때까지 3초간 대기
    #3초 안에 1번 신호가 ON 되면, res = 0
    #3초 안에 1번 신호가 ON 되지 않았으면 res = -1

#다중신호 신호이름: “multi”(cnt=2)가 등록되어 있는 경우
#“multi[0]”, “multi[1]” 사용가능
wait_modbus_input(“multi [1]”, ON)
wait_modbus_input(“multi [0]”, OFF)
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.