3.7.0 3.6.0 3.5.0 3.4.0 3.3.0 3.2.2 3.2.1 3.2.0 Korean English Chinese Czech Dutch French German Hungarian Italian Japanese Polish Portuguese Spanish
3.7.0 3.6.0 3.5.0 3.4.0 3.3.0 3.2.2 3.2.1 3.2.0 Korean English Chinese Czech Dutch French German Hungarian Italian Japanese Polish Portuguese Spanish

thread_run()

정의

thread_run(th_func_name, loop=False)

기능

Thread를 생성하여 수행하며 Thread가 수행할 기능은 th_func_name에 지정된 함수에 따라 결정됩니다.

알아두기

Thread 명령어를 사용할 때, 제약 조건은 아래와 같습니다.

  • Thread는 최대 4개까지만 사용 가능합니다.

  • Thread 내에서 로봇을 움직이는 하기 모션 명령어는 사용할 수 없습니다.

    • movej, amovej, movejx, amovejx, movel, amovel, movec, amovec, movesj, amovesj,

    • movesx, amovesx, moveb, amoveb, move_spiral, amove_spiral,

    • move_periodic, amove_periodic

  • thread_run 시 loop=Ture 하고, 해당 쓰레드 함수 내에서 무한루프로 블록되어 있는 경우에는 쓰레드 명령들이 정상 동작하지 않습니다. (단, TP를 통한 STOP시, 해당 쓰레드는 정상적으로 종료됩니다.)

인수

인수명

자료형

기본값

설명

th_func_name

callable

-

Thread가 수행할 function name

loop

bool

False

Thread의 반복 수행 여부

  • True : th_func_name이 반복적 호출
    (interval 0.01second)

  • False : th_func_name이 1회 호출

리턴

설명

int

등록된 thread ID

음수값

실패

예외

예외

설명

DR_Error (DR_ERROR_TYPE)

인수들의 데이터형 오류 시

DR_Error (DR_ERROR_VALUE)

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

DR_Error (DR_ERROR_RUNTIME)

C Extension 모듈 에러 발생 시

DR_Error (DR_ERROR_STOP)

프로그램 강제 종료 시

예제

Python
#----- 쓰레드 -------------------------------------- 
def fn_th_func():
  if check_motion()==0: # 수행 중인 모션이 없는 경우
    set_digital_output(1, OFF)
  else:
    set_digital_output(1, ON)

#----- 메인 루틴 ----------------------------------
th_id = thread_run(fn_th_func, loop=True) #쓰레드 Run

while 1: 
  # do something…
  wait(0.1)

Keyword

thread / thread_