In MIL, there are functions (for example, MappHookFunction()) that take a callback function (hook-handler function) and set it up as the event handler for a specific type of event (hooks it to the event). When the event then happens, the callback function is executed. The MIL functions capable of hooking a callback function to an event are referred to as hook-type functions. Hook-type functions take as input a reference to the callback function and the name of the event that should invoke the execution of the callback function. The reference to the callback function must be of a specific callback type. The following table lists the MIL hook-type functions and their associated callback function type.
MIL hook-type function |
Callback type |
MIL_APP_HOOK_FUNCTION_PTR |
|
MIL_BUF_HOOK_FUNCTION_PTR |
|
MIL_FOCUS_HOOK_FUNCTION_PTR |
|
MIL_DIG_HOOK_FUNCTION_PTR |
|
MIL_DISP_HOOK_FUNCTION_PTR |
|
MIL_FUNC_FUNCTION_PTR |
|
MIL_GRA_HOOK_FUNCTION_PTR |
|
MIL_OCR_HOOK_FUNCTION_PTR |
|
MIL_SEQ_HOOK_FUNCTION_PTR |
|
MIL_SYS_HOOK_FUNCTION_PTR |
|
MIL_THREAD_FUNCTION_PTR |
|
MIL_FPGA_HOOK_FUNCTION_PTR |
When creating a hook-handler function, the function must have the required number of parameters of the right data type. For more information on the requirements of the hook-handler function, refer to the description of the corresponding hook-type function.
An example of the declaration for a user-defined callback function defined in Python is shown below.
Where for this example, ProcessingHook is the callback function, HookType is the type of event that will invoke the call, HookId is the identifier of the event, and HookDataPtr is a pointer to the user data that should be passed to the callback function when it is invoked.
In the above statements, the ProcessingHook function which was defined above, is referenced by ProcessingHookPtr as a callback of type MIL_DIG_HOOK_FUNCTION_PTR. This function reference is then passed to the MdigProcess() function as a parameter.