Open Core Interface - MLPI
MLPI-MotionLogicProgrammingInterface(mlpiCore)  1.26.2
Control Task Viewer
Collaboration diagram for Control Task Viewer:

Functions

MLPIRESULT mlpiTaskViewerStart (const MLPIHANDLE connection)
 
MLPIRESULT mlpiTaskViewerStop (const MLPIHANDLE connection)
 
MLPIRESULT mlpiTaskViewerAddItem (const MLPIHANDLE connection, const UCHAR *data, const ULONG numElements)
 
MLPIRESULT mlpiTaskViewerTaskStart (const MLPIHANDLE connection)
 
MLPIRESULT mlpiTaskViewerTaskStop (const MLPIHANDLE connection)
 
MLPIRESULT mlpiTaskViewerGetState (const MLPIHANDLE connection, MlpiTaskViewerState *state)
 

Detailed Description

The task viewer resp. "Task Execution Viewer" is part of the development environment IndraWorks and shows a restricted chronological sequence of task processing on the control. The functions of these library part can be used to control and interact with the task viewer functionality in the control.

TaskViewerTaskOverview.png
Task viewer - overview.


Note
All recorded tasks must be present at time of call of function mlpiTaskViewerStop otherwise the task viewer functionality is not able to determine the name and the priority of a missing task.
The task viewer functionality is not able to recognize any changes of priority of a task. The task viewer functionality determine the priority of a task once at call of function mlpiTaskViewerStop. For deeply debug inspection please use the "System Viewer" of your WindRiver Workbench OEM.

Function Documentation

MLPIRESULT mlpiTaskViewerStart ( const MLPIHANDLE  connection)

This function starts a task viewer session, all task information is stored in a ring buffer as long as the recording is running. You have to use IndraWorks to upload and view the session in a graphical window. Please have a look within the IndraWorks help system to find more information about the task viewer.

Parameters
[in]connectionHandle for multiple connections.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // start task viewer session
2 MLPIRESULT result = mlpiTaskViewerStart(connection);
3 if (MLPI_FAILED(result)) {
4  printf("\ncall of MLPI function failed with 0x%08x!", (unsigned)result);
5  return result;
6 }
7 
8 // run task viewer for some time
9 Sleep(1000);
10 
11 // stop task viewer session
12 result = mlpiTaskViewerStop(connection);
13 if (MLPI_FAILED(result)) {
14  printf("\ncall of MLPI function failed with 0x%08x!", (unsigned)result);
15  return result;
16 }
17 
18 // now use IndraWorks for visualization of session data...
MLPIRESULT mlpiTaskViewerStop ( const MLPIHANDLE  connection)

This function stops a task viewer session.

Parameters
[in]connectionHandle for multiple connections.
Returns
Return value indicating success (>=0) or error (<0).
Example:
See mlpiTaskViewerStart
MLPIRESULT mlpiTaskViewerAddItem ( const MLPIHANDLE  connection,
const UCHAR data,
const ULONG  numElements 
)

This function adds a user event into the task viewer session. Use this function to mark special events in the task viewer. This function is very useful for debugging timing problems.

Parameters
[in]connectionHandle for multiple connections.
[in]dataSome user data that will be shown in the task viewer together with this event.
[in]numElementsNumber of bytes given by data.
Returns
Return value indicating success (>=0) or error (<0).
Example
1 // Add item to task viewer and attach some user data. Task viewer has to be started for this
2 // example to work. After stopping, you should find the item visualized in the task viewer.
3 UCHAR data[] = {0xDE, 0xAD, 0xBE, 0xAF};
4 MLPIRESULT result = mlpiTaskViewerAddItem(connection, data, sizeof(data));
5 if (MLPI_FAILED(result)) {
6  printf("\ncall of MLPI function failed with 0x%08x!", (unsigned)result);
7  return result;
8 }
MLPIRESULT mlpiTaskViewerTaskStart ( const MLPIHANDLE  connection)

This function sets a START event into a task viewer session.

Note
For a valid task viewer session, the START event and the STOP event must be set in an alternating manner.
Parameters
[in]connectionHandle for multiple connections.
Returns
Return value indicating success (>=0) or error (<0).
Example:
Create a background task and run it endlessly. In the background task, check every 20 milliseconds the displayed diagnosis. Visualize the needed runtime of the background task in the task viewer.
1 {
2  ..
3  taskSpawn("BackgroundDiagnosis", 200, VX_FP_TASK, 0x200000, (FUNCPTR)&taskBackgroundDiagnosis, connection, 0, 0, 0, 0, 0, 0, 0, 0, 0);
4 }
1 extern "C" int taskBackgroundDiagnosis(MLPIHANDLE connection)
2 {
3  MLPIRESULT result = MLPI_S_OK;
4  MlpiDiagnosis diagnosis;
5  memset(&diagnosis, 0, sizeof(diagnosis));
6 
7  do {
8  // set STOP event into task viewer session
9  mlpiTaskViewerTaskStop(connection);
10 
11  // sleep
12  taskDelay(20);
13 
14  // set START event into task viewer session
15  mlpiTaskViewerTaskStart(connection);
16 
17  // Get displayed diagnosis
18  result = mlpiSystemGetDisplayedDiagnosis(connection, &diagnosis);
19  if(MLPI_SUCCEEDED(result)) {
20  // do something with diagnosis
21  ;
22  }
23  else {
24  // error handling
25  ;
26  break;
27  }
28  }while(TRUE);
29 
30  return result;
31 }
TaskViewerTaskStartStopEvent.png
Task viewer session.

MLPIRESULT mlpiTaskViewerTaskStop ( const MLPIHANDLE  connection)

This function sets a STOP event into a task viewer session.

Note
For a valid task viewer session the START event and the STOP event must be set alternating.
Parameters
[in]connectionHandle for multiple connections.
Returns
Return value indicating success (>=0) or error (<0).
Example:
See mlpiTaskViewerTaskStart
MLPIRESULT mlpiTaskViewerGetState ( const MLPIHANDLE  connection,
MlpiTaskViewerState state 
)

This function gets the current state if the task viewer.

Parameters
[in]connectionHandle for multiple connections.
[in]stateState of the task viewer.
Returns
Return value indicating success (>=0) or error (<0).
Example:
MlpiTaskViewerState state; MLPIRESULT result = mlpiTaskViewerGetState(_hControl, &state); if (MLPI_FAILED(result)) { printf("\ncall of MLPI function failed with 0x%08x!", (unsigned)result); return result; }