AsyncAdd (FUN)ΒΆ
FUNCTION AsyncAdd : RTS_IEC_HANDLE
Function to start a new asynchronous job.
Note
On shutdown or reset, or before download, call AsyncRemoveAll() to remove all registered asynchronous jobs.
During exit of an application (Application reset or delete), an asynchronous job is executed synchronously!
- InOut:
Scope
Name
Type
Comment
Return
AsyncAddRTS_IEC_HANDLEHandle to the job object
Input
pfJobFuncPOINTER TO BYTE
Function pointer to be called asyncrononous. Use ADR to retrieve the function pointer.
pParamPOINTER TO BYTE
Parameter to be passed to pfJobFunc
pInstancePOINTER TO BYTE
In case of ulIecFunc is ASYNC_IS_IEC, and if pfJobFunc is a method of a FB, pass here the instance pointer of the FB In other cases, set to 0
pulStatePOINTER TO UDINT
Pointer to job state, filled by CmpAsyncMgr. Check this state cyclically.
ulIecFuncUDINTIndicates if pfJobFunc is written in IEC or C: ASYNC_IS_IEC or ASYNC_ISNOT_IEC
ulTypeUDINTType of an async job: ASYNCJOB_TASK, ASYNCJOB_EVENT or ASYNCJOB_HOOK
ulTimeoutUDINTTimout for the operation in milliseconds. Can be 0, then infinite.
pAsyncJobParamPOINTER TO ASYNCJOB_PARAM
Pointer to structure ASYNCJOB_PARAM. Specify task by name with member TaskParam.pszTaskname. A new task will be created on first call. For other jobs, this same task can be re-used by setting the same name. Specify task priority with member TaskParam.ulTaskPriority.
pResultPOINTER TO RTS_IEC_RESULT
- Pointer to the runtime system error code (see CmpErrors2 Interface Library):
ERR_PARAMETER: invalid parameter
Result of CmpMemPool
ERR_NOTIMPLEMENTED: ulType ASYNCJOB_EVENT and SysEvent handling fails
ERR_NOT_SUPPORTED: ulType ASYNCJOB_TASK and SysTask handling fails