IecTaskCreate (FUN)¶
FUNCTION IecTaskCreate : RTS_IEC_HANDLE
Create a new IEC Task
IEC Tasks itself are used by the scheduler of the runtime. They don’t essentially need a corresponding OS task or timer. They might be handled by the scheduler in a completely different way. The system call for the task entry function has to be enabled. The return value of the task entry function is not evaluated.
Note
FUNCTION CheckEvent : BOOL
VAR_INPUT
END_VAR
(* This function checks wether the event is triggered *)
(* by returning TRUE: raising edge, status, etc. *)
FUNCTION IecTaskCyclic : BOOL
VAR_INPUT
    parameter : IEC_CYCLE_STRUCT;
END_VAR
VAR
    udiState : UDINT;
    hTask : RTS_IEC_HANDLE;
END_VAR
(* ----- mandatory cyclic task frame code begin ----- *)
udiState := parameter.pApplication^.udiState;
hTask := parameter.hTaskHandle;
IF udiState = AS_STOP THEN
    RETURN;
END_IF
IF parameter.pTaskInfo^.bWatchdog THEN
    IecTaskEnableWatchdog(hTask);
END_IF
(* ------ mandatory cyclic task frame code end ------ *)
- Error code:
- ERR_OK: The new task was successfully created. 
- ERR_FAILED: There was an error in a subsystem (e.g. the scheduler could not allocate his task handle). 
- ERR_PARAMETER: Invalid application- or task info pointer 
- ERR_OUT_OF_LIMITS: Maximum number of Tasks reached (target specific) 
- ERR_NOMEMORY: Unable to allocate the memory, that is necessary for the task description 
 
- InOut:
- Scope - Name - Type - Comment - Return - IecTaskCreate- RTS_IEC_HANDLE- Handle to newly created task - Input - pApp- POINTER TO APPLICATION - Pointer to application that contains the task - pTaskInfo- POINTER TO Task_Info2 - Pointer to task information - pResult- POINTER TO RTS_IEC_RESULT - Pointer to error code