SysLibCallback libraryPermalink

This library provides the functions SysCallbackRegister and SysCallbackUnregister, which serve to activate defined callback functions for runtime events.

Both functions are of type BOOL and return TRUE as soon as the required callback function successfully has been registered resp. de-registered.

The execution is synchronous.

Prototype of the callback function

The prototype of the callback function must look as follows:

FUNCTION Callback : DWORD

VAR_INPUT

 dwEvent:DWORD; // Event

 dwFilter:DWORD; // Filter

 dwOwner:DWORD; // Source

END_VAR

For RISC and Motorola 68K target systems the name of the callback function must start with "callback"!

The library functions SysCallbackRegister and SysCallbackUnregister each use the following parameters when calling the callback function which should be registered or de-registered.

Input variable

Data type

Description

iPOUIndex

INT

POU Index of the callback function which should be (de)registered. The index must be accquired before with the aid of the operator INDEXOF(<function name>).

Event

RTS_EVENT

The runtime event, for which the callback function is called, is defined by a value of the enumeration RTS_EVENT, which also is contained in the library.

The enumeration RTS_EVENT is defined as follows:

TYPE RTS_EVENT :

(

EVENT_ALL,

(* General events *)

EVENT_START,

EVENT_STOP,

EVENT_BEFORE_RESET,

EVENT_AFTER_RESET,

EVENT_SHUTDOWN,

(* Exceptions generated by run time *)

EVENT_EXCPT_CYCLETIME_OVERFLOW, (* Cycle time overflow *)

EVENT_EXCPT_WATCHDOG, (* Software watchdog OF IEC-task expired *)

EVENT_EXCPT_HARDWARE_WATCHDOG, (* Hardware watchdog expired. Global software error *)

EVENT_EXCPT_FIELDBUS, (* Fieldbus error occurred *)

EVENT_EXCPT_IOUPDATE, (* IO-update error *)

(* Exceptions generated BY system *)

EVENT_EXCPT_ILLEGAL_INSTRUCTION, (* Illegal instruction *)

EVENT_EXCPT_ACCESS_VIOLATION, (* Access violation *)

EVENT_EXCPT_PRIV_INSTRUCTION, (* Privileged instruction *)

EVENT_EXCPT_IN_PAGE_ERROR, (* Page error *)

EVENT_EXCPT_STACK_OVERFLOW, (* Stack overflow *)

EVENT_EXCPT_MISALIGNMENT, (* Datatype misalignment *)

EVENT_EXCPT_ARRAYBOUNDS, (* ARRAY bounds exceeded *)

EVENT_EXCPT_DIVIDEBYZERO, (* Division BY zero *)

EVENT_EXCPT_OVERFLOW, (* Overflow *)

EVENT_EXCPT_NONCONTINUABLE, (* Non continuable *)

EVENT_EXCPT_NO_FPU_AVAILABLE, (* FPU: No FPU available *)

EVENT_EXCPT_FPU_ERROR, (* FPU: Unspecified error *)

EVENT_EXCPT_FPU_DENORMAL_OPERAND, (* FPU: Denormal operand *)

EVENT_EXCPT_FPU_DIVIDEBYZERO, (* FPU: Division BY zero *)

EVENT_EXCPT_FPU_INVALID_OPERATION, (* FPU: Invalid operation *)

EVENT_EXCPT_FPU_OVERFLOW, (* FPU: Overflow *)

EVENT_EXCPT_FPU_STACK_CHECK, (* FPU: Stack check *)

(* IO events *)

EVENT_AFTER_READING_INPUTS,

EVENT_BEFORE_WRITING_OUTPUTS,

(* Miscellaneous events *)

EVENT_TIMER, (* Schedule tick (timer interrupt) *)

EVENT_DEBUG_LOOP, (* Debug loop at breakpoint *)

(* Online services *)

EVENT_ONLINE_SERVICES_BEGIN := 500,

EVENT_LOGIN,

EVENT_CUSTOM_SERVICES,

(* Interrupts *)

EVENT_INT_0:=1000,

EVENT_INT_1,

EVENT_INT_2,

EVENT_INT_3,

EVENT_INT_4,

EVENT_INT_5,

EVENT_INT_6,

EVENT_INT_7,

EVENT_INT_8,

EVENT_INT_9,

EVENT_INT_10,

EVENT_INT_11,

EVENT_INT_12,

EVENT_INT_13,

EVENT_INT_14,

EVENT_INT_15,

EVENT_INT_255:=1255,

EVENT_MAX

);

END_TYPE