Program Control
Start Task
Start a new task
Serial tasks are executed in queue, with maximum one serial task running at a time. Subsequent tasks wait for previous tasks to complete, fail or terminate before running.
Parallel tasks execute immediately, with multiple parallel tasks running simultaneously with independent environment variables.
WARNING
- When the started scene contains motion related interfaces, must start as serial task (
is_parallel
isfalse
) - In serial tasks, must start as parallel task (
is_parallel
istrue
), otherwise will block
task_id = lebai:start_task(scene, params, dir, is_parallel, loop_to)
- Parameters
scene
Scene IDparams
Parameters to pass. String array. Optional, default emptydir
Workspace name. Optional, default root directoryis_parallel
Whether to execute in parallel. Optional, default serialloop_to
Number of repetitions. Optional, default 1 time, 0 means infinite
- Returns
task_id
Task ID
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "start_task", "params": [{"name": "", "params": [""], "dir": "", "is_parallel": false, "loop_to": 1}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {"id": 1}, "id": 1 }
Get All Task IDs
tasks = lebai:get_task_list()
- Returns
tasks
IDs of all uncompleted tasks
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "load_task_list", "params": [{}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {"ids": []}, "id": 1 }
Get Serial Task ID
task = lebai:get_main_task_id()
- Returns
task
ID of serial task
Wait for Task Completion
stdout = lebai:wait_task(task_id)
- Parameters
task_id
task_id returned by start_task. Optional, default serial task
- Returns
stdout
All print output of the task
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "wait_task", "params": [{"id": 1}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {"done": true, "stdout": ""}, "id": 1 }
Get Task State
state = lebai:get_task_state(task_id)
- Parameters
task_id
Task ID. Optional, default serial task
- Returns
state
Task state: "NONE" no task; "WAIT" queuing; "RUNNING" running; "PAUSE" paused; "SUCCESS" completed successfully; "INTERRUPTING" stopping; "INTERRUPT" stopped; "FAIL" failed
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "load_task", "params": [{"id": 1}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {"state": ""}, "id": 1 }
Stop Task
lebai:cancel_task(task_id)
Stop specified task. When stopping serial task, will automatically call stop_move to stop motion
- Parameters
task_id
Task ID. Optional, default serial task
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "cancel_task", "params": [{"id": 1}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {}, "id": 1 }
Pause Task
lebai:pause_task(task_id)
Pause specified task. When pausing serial task, will automatically call pause_move to pause motion
- Parameters
task_id
Task ID. Optional, default serial task
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "pause_task", "params": [{"id": 1}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {}, "id": 1 }
Resume Task
lebai:resume_task(task_id)
Resume specified task. When resuming serial task, will automatically call resume_move to resume motion
- Parameters
task_id
Task ID. Optional, default serial task
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "resume_task", "params": [{"id": 1}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {}, "id": 1 }