| Customize Help
| Save Settings

MsysHookFunction



Function Map
Synopsis
Hook a function to a system event.
Syntax
void MsysHookFunction(
MIL_ID SysId, //in
MIL_INT HookType, //in
MIL_SYS_HOOK_FUNCTION_PTR HookHandlerPtr, //in
void *UserDataPtr //in-out
)
Description

This function allows you to attach or detach a user-defined function to a specified system event. Once a hook-handler function is defined and hooked to an event, it is automatically called when the event occurs.

You can hook more than one function to an event by making separate calls to MsysHookFunction() for each function that you want to hook. MIL automatically chains and keeps an internal list of all these hooked functions. When a function is hooked, this new function is added to the end of the list. When the event happens, all user-defined functions in the list will be executed in the same order that they were hooked to the event. You can also remove any function from the list; in this case, MIL preserves the order of the remaining functions in the list.

You can obtain more information about the event from within the hook handler function using MsysGetHookInfo().

Note that functions hooked to an event execute on a distinct thread. This permits the functions to run concurrently from the operation that fired the event and from functions hooked to other events. Although there is a small queue to permit a certain amount of overlap, hooked functions should not take longer to execute than the period in which two of their associated events can occur. You cannot determine the instance of the event that fired the function.

Note that this function reference has not been updated for a MIL system added during a MIL update. Refer to the MIL system's release note to see which MIL system’s documentation you should use in its place and any possible differences.
Parameters
This function is not supported on the selected boards.
This function reference has not been updated for the selected MIL system. To show the content of this page, choose a second MIL system; refer to the MIL system's release note to see which MIL system’s documentation to choose and any possible differences.
Parameters
SysId

Specifies the identifier of the system on which to hook a function.

function map For specifying the system identifier
Click to summarizeValue Description MIL system-specific
tooltip (‡)
Click to summarize M_DEFAULT_HOST

Specifies the default Host system of the current MIL application.

a c
M10
g h o t
U28
u
U36
v
Click to summarize MIL system identifier

Specifies a valid system identifier, previously allocated using MsysAlloc().

a c
M10
g h j l m o p r
U27
t
U28
u
U36
v w
U53
z aa
HookType

Specifies the system event to which to hook the function. This parameter can be set to one of the following values.

function map For specifying the system event to hook
Click to summarizeValue Description MIL system-specific
tooltip (‡)
Click to summarize M_CAMERA_PRESENT +

Hooks the function to the presence of the camera.

(summarize)
c
M10
o u
U36
MIL system specific

Note that this hook requires the use of the mtxgigeservice process. If the service is not started, a MIL error will be generated when calling this value.

c
M10
Click to summarize M_FEATURE_CHANGE +

Hooks the function to the event that occurs when the value of a GenICam feature changes.

To enable an event to occur when the value of a specific feature changes, use MsysControlFeature() with M_FEATURE_CHANGE_HOOK set to M_ENABLE. Repeat for each feature for which you want to enable a feature change event. To enable an event to occur when the value of any feature changes, use M_FEATURE_CHANGE + M_ALL.

This setting is only available for hooking to an image buffer.

Within the hook function, use MsysGetHookInfo() with M_GC_FEATURE_CHANGE_NAME to retrieve the name of the feature that caused the event.

(summarize)
v
Click to summarize M_IO_CHANGE +

Hooks the function to the event that occurs when an I/O signal changes in accordance with its specified interrupt mode, set using MsysControl() with M_IO_INTERRUPT_ACTIVATION. Within the scope of the hook-handler function, it is prudent to verify that the appropriate I/O signal triggered the hook-handler function, using MsysGetHookInfo() with M_IO_INTERRUPT_SOURCE.

If more than one input signal triggers an interrupt at the same time, the hook-handler function (or chain of hook-handler functions) is called for each input signal that generated an interrupt. As a result, any and all user-specified function(s) hooked using this hook type will be executed for each interrupt.

(summarize)
a g h t
U28
w
U53
z
MIL system specific
[This is only applicable to Matrox 4Sight-X, Matrox 4Sight GP/GPm, and Matrox Supersight platforms]

The system must be a Host system allocated on the Matrox 4Sight GPm or Matrox Supersight platform.

a w
U53
z
Click to summarize M_TIMER_END +

Hooks the function to the event that occurs when the specified timer completes.

[Matrox 4Sight GP/GPm]

On a Matrox 4Sight GPm platform, this value is only available if MIL 10 update 51 (or later) is installed. It is not available on a Matrox 4Sight GP.

(summarize)
a t
U28
w
U53
z
MIL system specific

You must specify a combination value from the following table:
t
U28
Click to summarize M_TIMER_START +

Hooks the function to the event that occurs when the specified timer starts its active period (after the timer delay).

[Matrox 4Sight GP/GPm]

On a Matrox 4Sight GPm platform, this value is only available if MIL 10 update 51 (or later) is installed. It is not available on a Matrox 4Sight GP.

(summarize)
a t
U28
w
U53
z
MIL system specific

You must specify a combination value from the following table:
t
U28
Click to summarize M_UART_DATA_RECEIVED +

Hooks the function to the event that occurs when the specified UART receives data. Use MsysInquire() with M_UART_PRESENT to return the number of UARTs available.

Note that this value can be used in combination; see below.

(summarize)
g j l m p r
U27
aa
Click to summarize M_WATCHDOG_WARNING +

Hooks the function to the event that occurs when the Watchdog warning timer is not reset before the specified interval expires. From within your hook-handler function, you should reset the Watchdog's main timer. If it is not reset, the Host computer will reboot.

(summarize)
g h
Combination values for M_FEATURE_CHANGE.

You can add one of the following values to the above-mentioned value to specify the GenTL configuration file (XML file) associated with the feature.

function map For specifying to hook on a specific feature change event associated with a GenTL configuration file
Click to summarizeCombination value Description MIL system-specific
tooltip (‡)
Click to summarize

Specifies that the hook will occur on a feature change event for a feature associated with a specific instance of the GenTL interface configuration file (XML file).

(summarize)
v
Parameters

Specifies the index of the GenTL interface configuration file.

v
0 <= Value <=M_GENTL_INTERFACE_COUNT

Specifies the index.

v
Click to summarize M_ALL

Specifies that the hook will occur on all feature change events.

v
Click to summarize M_GENTL_SYSTEM

Specifies that the hook will occur on a feature change event of a feature associated with the GenTL system configuration file (XML file).

v
Combination value for M_UART_DATA_RECEIVED.

You can add the following value to the above-mentioned value to set the UART upon which the system event occurs.

function map For specifying the UART upon which the system event occurs
Click to summarizeCombination value Description MIL system-specific
tooltip (‡)
Click to summarize

Specifies the UART upon which the system event occurs.

Use MsysInquire() with M_UART_PRESENT to determine the number of UARTS on the system.

(summarize)
g j l m p r
U27
aa
Parameters

Specifies a device (UART) on which the system event occurs.

g j l m p r
U27
aa
M_DEVn

Specifies the device upon which the system event occurs, where n can be from 0 and 15.

g j l m p r
U27
aa
MIL system specific

There is 1 UART available on Matrox Morphis.

g

There are 4 UARTs available on Matrox Solios eA/XA Quad, 2 on Matrox Solios eA/XA Dual, and 1 on Matrox Solios eA/XA Single.

l

There are 2 UARTs available on Matrox Solios eCL/XCL dual-Base/single-Medium operating in dual-Base mode, and 1 is available on Matrox Solios eCL/XCL-B, eCL/XCL-F, and eCL/XCL dual-Base/single-Medium operating in single-Medium mode.

j m p r
U27
aa

There are 2 UARTS available on Matrox Radient eCL-DB and eCL-DF, 3 on Matrox Radient eCL-QB, and 1 on Matrox Radient eCL-SF. Note that, using the CLProtocol will occupy one COM port per allocated digitizer.

j p r
U27
aa
Combination value for M_TIMER_END; M_TIMER_START.

You must add the following value to the above-mentioned values to specify the timer to which to hook the function.

function map For specifying the timer to which to hook the function
Click to summarizeCombination value Description MIL system-specific
tooltip (‡)
Click to summarize M_TIMERn

Specifies the timer to hook.

t
U28
Combination value for the values listed in For specifying the system event to hook.

You can add the following value to the above-mentioned values to specify that the function should be unhooked.

function map For specifying that the function should be unhooked
Click to summarizeCombination value Description MIL system-specific
tooltip (‡)
Click to summarize M_UNHOOK

Unhooks a hooked function.

a c
M10
g h j l m o p r
U27
t
U28
u
U36
v w
U53
z aa
HookHandlerPtr

Specifies the address of the function that should be called when the specified event occurs. The hook-handler function must be declared as follows:

MIL_INT MFTYPE HookHandler(
MIL_INT HookType,
MIL_ID EventId,
void *UserDataPtr
)

Parameters
HookType

Type of system event hooked.

EventId

Event identifier to pass to MsysGetHookInfo() when inquiring about the hooked event.

UserDataPtr

Specifies the user data pointer passed to MsysHookFunction().

Upon successful completion, the hook-handler function should return M_NULL. Note, MIL_SYS_HOOK_FUNCTION_PTR and MFTYPE are reserved MIL predefined types for functions and data pointers.

UserDataPtr

Specifies the address of the user data that you want to make available to the hook-handler function. This address is passed to the hook-handler function, through its UserDataPtr parameter, when the specified event occurs. Set this parameter to M_NULL if not used.

Compilation information
Header Include mil.h.
Library Use mil.lib.
DLL Requires mil.dll.
DEFAULT HOST CAMERA PRESENT FEATURE CHANGE IO CHANGE TIMER END TIMER START UART DATA RECEIVED WATCHDOG WARNING GENTL INTERFACE COUNT ALL GENTL SYSTEM DEVn TIMERn UNHOOK M_DEVn M_TIMERn