| Customize Help

MIL hook-type functions in Python



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

MappHookFunction()

MIL_APP_HOOK_FUNCTION_PTR

MbufHookFunction()

MIL_BUF_HOOK_FUNCTION_PTR

MdigFocus()

MIL_FOCUS_HOOK_FUNCTION_PTR

MdigHookFunction(), MdigProcess()

MIL_DIG_HOOK_FUNCTION_PTR

MdispHookFunction()

MIL_DISP_HOOK_FUNCTION_PTR

MfuncAlloc()

MIL_FUNC_FUNCTION_PTR

MgraHookFunction()

MIL_GRA_HOOK_FUNCTION_PTR

MocrHookFunction()

MIL_OCR_HOOK_FUNCTION_PTR

MseqHookFunction()

MIL_SEQ_HOOK_FUNCTION_PTR

MsysHookFunction()

MIL_SYS_HOOK_FUNCTION_PTR

MthrAlloc()

MIL_THREAD_FUNCTION_PTR

MfpgaHookFunction()

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.

def ProcessingHook(HookType, HookId, HookDataPtr):

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.

ProcessingHookPtr = MIL.MIL_DIG_HOOK_FUNCTION_PTR(ProcessingHook)
MIL.MdigProcess(MilDigitizer, MilGrabBufferList, MilGrabBufferListSize, MIL.M_START, MIL.M_DEFAULT, ProcessingHookPtr, ctypes.POINTER(HookData))

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.