Open Core Interface - MLPI
MLPI-MotionLogicProgrammingInterface(mlpi4LabVIEW)  1.26.2
Control Task Execution
Collaboration diagram for Control Task Execution:

Functions

MLPIRESULT mlpiTaskExecuteFile (const MLPIHANDLE connection, const WCHAR16 *path, const WCHAR16 *envArguments, const WCHAR16 *arguments, MLPITASKHANDLE *handle)
 
MLPIRESULT mlpiTaskExecuteGetStatus (const MLPIHANDLE connection, const MLPITASKHANDLE handle, MlpiProcessState *state)
 
MLPIRESULT mlpiTaskExecuteGetActive (const MLPIHANDLE connection, MLPITASKHANDLE *handles, const ULONG numElements, ULONG *numElementsRet)
 
MLPIRESULT mlpiTaskExecuteKill (const MLPIHANDLE connection, const MLPITASKHANDLE handle)
 
MLPIRESULT mlpiTaskExecuteGetName (const MLPIHANDLE connection, const MLPITASKHANDLE handle, WCHAR16 *name, const ULONG numElements)
 

Detailed Description

The following functions are used for controlling execution of user tasks.

Function Documentation

MLPIRESULT mlpiTaskExecuteFile ( const MLPIHANDLE  connection,
const WCHAR16 path,
const WCHAR16 envArguments,
const WCHAR16 arguments,
MLPITASKHANDLE handle 
)

This function executes a file.

Parameters
[in]connectionHandle for multiple connections.
[in]pathPath of file to be executed.
[in]envArgumentsArguments for execution environment.
[in]argumentsArguments for execution.
[out]handlePointer to value where execution handle will be stored.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 MLPIRESULT result;
2 MLPITASKHANDLE handle;
3 // start execution of file /ata0b/test.lua without argument for Lua-VM and without arguments for file
4 result = mlpiTaskExecuteFile(connection, L"/ata0b/test.lua", L"", L"", &handle);
5 if (MLPI_FAILED(result))
6 {
7  printf("unable to start execution of file with error code: %08X", result);
8  return;
9 }
MLPIRESULT mlpiTaskExecuteGetStatus ( const MLPIHANDLE  connection,
const MLPITASKHANDLE  handle,
MlpiProcessState state 
)

This function gets the status of an executed file.

Parameters
[in]connectionHandle for multiple connections.
[in]handleHandle of the execution
[out]stateStatus of the executed file
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 MLPIRESULT result;
2 MLPITASKHANDLE handle;
3 // start execution of file /ata0b/test.lua without argument for Lua-VM and without arguments for file
4 result = mlpiTaskExecuteFile(connection, L"/ata0b/test.lua", L"", L"", &handle);
5 if (MLPI_FAILED(result))
6 {
7  printf("unable to start execution of file with error code: %08X", result);
8  return;
9 }
10 
11 MlpiProcessState state;
12 result = mlpiTaskExecuteGetStatus(connection, handle, &state);
13 if (MLPI_FAILED(result))
14 {
15  printf("unable to get state of file execution with error code: %08X", result);
16  return;
17 }
MLPIRESULT mlpiTaskExecuteGetActive ( const MLPIHANDLE  connection,
MLPITASKHANDLE handles,
const ULONG  numElements,
ULONG numElementsRet 
)

This function gets handles for all executed files.

Parameters
[in]connectionHandle for multiple connections.
[in]handlesPointer to an array of handles where handles of executions will be stored
[in]numElementsNumber of handle elements available in 'handles' for reading.
[out]numElementsRetNumber of elements used.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 MLPIRESULT result;
2 MLPITASKHANDLE handles[100];
3 ULONG numElementsRet = 0;
4 result = mlpiTaskExecuteGetActive(connection, handles, 100, &numElementsRet);
5 if (MLPI_FAILED(result))
6 {
7  printf("unable to get all active file executions with error code: %08X", result);
8  return;
9 }
10 for(ULONG index = 0; index < numElementsRet; index++)
11 {
12  printf("\nhandle of file %u is %016LX", index, handles[index]);
13 }
MLPIRESULT mlpiTaskExecuteKill ( const MLPIHANDLE  connection,
const MLPITASKHANDLE  handle 
)

This function stops execution of file.

Parameters
[in]connectionHandle for multiple connections.
[in]handleHandle of the execution
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 MLPIRESULT result;
2 MLPITASKHANDLE handle;
3 // start execution of file /ata0b/test.lua without argument for Lua-VM and without arguments for file
4 result = mlpiTaskExecuteFile(connection, L"/ata0b/test.lua", L"", L"", &handle);
5 if (MLPI_FAILED(result))
6 {
7  printf("unable to start execution of file with error code: %08X", result);
8  return;
9 }
10 
11 result = mlpiTaskExecuteKill(connection, handle);
12 if (MLPI_FAILED(result))
13 {
14  printf("unable to kill file execution with error code: %08X", result);
15  return;
16 }
MLPIRESULT mlpiTaskExecuteGetName ( const MLPIHANDLE  connection,
const MLPITASKHANDLE  handle,
WCHAR16 name,
const ULONG  numElements 
)

This function gets the name of an executed file.

Parameters
[in]connectionHandle for multiple connections.
[in]handleHandle of the execution
[out]nameName of the executed file
[in]numElementsNumber of handle elements available in 'name' for reading.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 MLPIRESULT result;
2 MLPITASKHANDLE handle;
3 // start execution of file /ata0b/test.lua without argument for Lua-VM and without arguments for file
4 result = mlpiTaskExecuteFile(connection, L"/ata0b/test.lua", L"", L"", &handle);
5 if (MLPI_FAILED(result))
6 {
7  printf("unable to start execution of file with error code: %08X", result);
8  return;
9 }
10 
11 WCHAR16 name[256];
12 result = mlpiTaskExecuteGetName(connection, handle, name, 256);
13 if (MLPI_FAILED(result))
14 {
15  printf("unable to get name of file execution with error code: %08X", result);
16  return;
17 }