Definition
thread_state(th_id)
Features
This function checks the status of a thread.
Parameters
|
Parameter Name |
Data Type |
Default Value |
Description |
|---|---|---|---|
|
th_id |
int |
- |
Thread ID to check the status |
Return
|
Value |
Description |
|---|---|
|
1 |
RUN (TH_STATE_RUN) |
|
2 |
PAUSE (TH_STATE_PAUSE) |
|
3 |
STOP (TH_STATE_STOP) |
Exception
|
Exception |
Description |
|---|---|
|
DR_Error (DR_ERROR_TYPE) |
Parameter data type error occurred |
|
DR_Error (DR_ERROR_VALUE) |
Parameter value is invalid |
Example
Python
def fn_th_func():
if check_motion()==0: # No motion in action
set_digital_output(1, OFF)
else:
set_digital_output(1, ON)
th_id = thread_run(fn_th_func, loop=True)
state1 = thread_state(th_id)
thread_pause(th_id)
state2 = thread_state(th_id)