MIL_ID DigId, | //in |
MIL_INT HookType, | //in |
MIL_DIG_HOOK_FUNCTION_PTR HookHandlerPtr, | //in |
void *UserDataPtr | //in |
This function allows you to attach or detach a user-defined function to a specified digitizer 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 MdigHookFunction() 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 MdigGetHookInfo().
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.
Note that the following hook types are only available if they are supported by the camera. Refer to your camera's documentation for more details.
Specifies the digitizer event to which to hook the function. This parameter can be set to one of the following values:
For specifying the digitizer event to
which to hook the function
|
|||||||||||||||||||||||||||||||||||||||
Value |
Description
|
MIL system-specific tooltip (†) |
|||||||||||||||||||||||||||||||||||||
M_CAMERA_LOCK + |
Hooks the function to the event that occurs when the camera is locked. (more details...) |
† | h | l | n | ||||||||||||||||||||||||||||||||||
M_CAMERA_PRESENT + |
Hooks the function to the presence of the camera. (more details...) |
† | c | e | g | h | i | j | l | n | o | p | r | s | |||||||||||||||||||||||||
MIL system specific | |||||||||||||||||||||||||||||||||||||||
This event occurs when the camera is physically unplugged from your IEEE 1394 IIDC-compatible board. |
† | e | |||||||||||||||||||||||||||||||||||||
M_FIELD_START + |
Hooks the function to the event that occurs at the start of each field of the incoming signal. (more details...) |
† | g | h | l | n | |||||||||||||||||||||||||||||||||
M_FIELD_START_EVEN + |
Hooks the function to the event that occurs at the start of the incoming signal's even fields. (more details...) |
† | g | h | l | n | |||||||||||||||||||||||||||||||||
M_FIELD_START_ODD + |
Hooks the function to the event that occurs at the start of the incoming signal's odd fields. (more details...) |
† | g | h | l | n | |||||||||||||||||||||||||||||||||
M_FRAME_START + |
Hooks the function to the event that occurs at the start of each frame of the incoming signal. (more details...) |
† | g | h | j | l | m | n | p | r | |||||||||||||||||||||||||||||
M_GC_EVENT + |
Hooks the function to the message sent from your GenICam SFNC-compliant camera at the time of the specified event. (more details...) |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_GRAB_END + |
Hooks the function to the event that occurs at the end of each grab. (more details...) |
† | a | b | c | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | |||||||||||||||||||
M_GRAB_FIELD_END + |
Hooks the function to event that occurs at the end of grabbed fields. (more details...) |
† | b | g | h | l | |||||||||||||||||||||||||||||||||
M_GRAB_FIELD_END_EVEN + |
Hooks the function to the event that occurs at the end of grabbed even fields. (more details...) |
† | b | g | h | l | |||||||||||||||||||||||||||||||||
M_GRAB_FIELD_END_ODD + |
Hooks the function to the event that occurs at the end of grabbed odd fields. (more details...) |
† | b | g | h | l | |||||||||||||||||||||||||||||||||
M_GRAB_FRAME_END + |
Hooks the function to the event that occurs at the end of grabbed frames. (more details...) |
† | a | b | c | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | |||||||||||||||||||
M_GRAB_FRAME_START + |
Hooks the function to the event that occurs at the start of grabbed frames. |
† | a | b | c | e | f | g | h | j | k | l | m | n | o | p | q | r | s | ||||||||||||||||||||
M_GRAB_LINE_END + n + |
Hooks the function to the event that occurs when the data of the specified line (row) is in the buffer and ready to be processed, where n is the specified line. (more details...) |
† | j | k | l | m | p | q | r | ||||||||||||||||||||||||||||||
M_GRAB_LINE + n + |
Hooks the function to the event that occurs when the specified line (row) is reached, where n is the specified line. (more details...) |
† | j | k | l | m | p | q | r | ||||||||||||||||||||||||||||||
M_GRAB_START + |
Hooks the function to the event that occurs at the start of each grab. (more details...) |
† | a | b | c | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | |||||||||||||||||||
M_IO_CHANGE + |
Hooks the function to the event that occurs when an I/O signal changes in accordance with its specified interrupt activation mode, set using MdigControl() with M_IO_INTERRUPT_ACTIVATION. (more details...) |
† | c | j | k | l | m | o | p | q | r | s | |||||||||||||||||||||||||||
M_ROTARY_ENCODER + |
Hooks the function to the event that occurs when the rotary decoder's counter reaches its trigger position (specified using MdigControl() with M_ROTARY_ENCODER_POSITION_TRIGGER). |
† | j | k | m | p | q | r | |||||||||||||||||||||||||||||||
M_TIMER_END + |
Hooks the function to the event that occurs when the active period of the specified timer ends (specified using MdigControl() with M_TIMER_DURATION). (more details...) |
† | j | k | l | m | p | q | r | ||||||||||||||||||||||||||||||
M_TIMER_START + |
Hooks the function to the event that occurs when the specified timer is triggered. (more details...) |
† | j | k | l | m | p | q | r |
You can add the following value to the above-mentioned values to specify to unhook a hooked function.
For unhooking a hooked
function
|
|||||||||||||||||||||||||||||||||||||||
Combination value | Description
|
MIL system-specific tooltip (†) |
|||||||||||||||||||||||||||||||||||||
M_UNHOOK |
Unhooks a hooked function. |
† | a | b | c | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s |
You must add one of the following values to the above-mentioned value to specify the type and number of the I/O signal to hook the function.
For specifying the type and number of the
I/O signal to hook the function
|
|||||||||||||||||||||||||||||||||||||||
Combination value |
Description
|
MIL system-specific tooltip (†) |
|||||||||||||||||||||||||||||||||||||
M_AUX_IOn |
Specifies to affect auxiliary signal n, where n is the signal number. (more details...) |
† | c | j | k | l | m | o | p | q | r | s | |||||||||||||||||||||||||||
MIL system specific | |||||||||||||||||||||||||||||||||||||||
With a GenICam SFNC-compliant camera, n is a number from 0 to 31. |
† | c | o | s | |||||||||||||||||||||||||||||||||||
M_TL_TRIGGER |
Specifies to affect the transport layer trigger signal. (more details...) |
† | k | q |
You can add one of the following values to the above-mentioned value to set the type of GenICam camera event.
The following events occur on the camera, as opposed to your frame grabber or the Host.
Your camera informs the Host (your computer) of these events by sending specific messages on the dedicated message channel. When dealing with the messages sent from your camera, the order of the messages can be specific to your camera's manufacturer. Typically, however, they follow the GenICam SFNC. Check your camera's documentation for potential discrepancies.
Note that, if you don't add a combination constant to M_GC_EVENT, the function is hooked to any GenICam event that has been enabled using MdigControlFeature(). In addition, the message channel must be supported by your camera and the specified event must also be supported by your camera.
When dealing specifically with acquisition-related events on the camera, typically the events occur in the following sequence, which starts when your grab command sets up the camera to start the acquisition of images. You can hook a function to the start and end of each of the following events: expose the sensor (CCD or CMOS) of the camera, perform the sensor readout and save the frame to an internal buffer, and then transfer the frame from your camera to your computer.
For error handling of acquisition-related events on the camera, hook a function on the acquisition error event (using M_ACQUISITION_ERROR).
For GenICam camera events
|
|||||||||||||||||||||||||||||||||||||||
Combination value | Description
|
MIL system-specific tooltip (†) |
|||||||||||||||||||||||||||||||||||||
M_ACQUISITION_END |
Hooks the function to the event that occurs when acquisition ends on your camera. (more details...) |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_ACQUISITION_ERROR |
Hooks the function to the event that occurs if an error is generated at some point while the camera exposes an image, stores it in an internal buffer, and transfers it from the camera to your computer. |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_ACQUISITION_START |
Hooks the function to the event that occurs when acquisition begins on your camera. (more details...) |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_ACQUISITION_TRANSFER_END |
Hooks the function to the event that occurs after transferring the image from your camera to your computer. (more details...) |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_ACQUISITION_TRANSFER_START |
Hooks the function to the event that occurs before transferring the image from your camera to your computer. (more details...) |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_ACQUISITION_TRIGGER |
Hooks the function to the event that occurs when acquisition is triggered on the camera. (more details...) |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_COUNTER_END + |
Hooks the function to the event that occurs when the specified camera counter stops. (more details...) |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_COUNTER_START + |
Hooks the function to the event that occurs when the specified camera counter starts. (more details...) |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_EXPOSURE_END |
Hooks the function to the event that occurs at the end of each exposure period of your camera. |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_EXPOSURE_START |
Hooks the function to the event that occurs at the start of each exposure period of your camera. |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_FRAME_END |
Hooks the function to the event that occurs when the frame ends on your camera. (more details...) |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_FRAME_START |
Hooks the function to the event that occurs when the frame begins on your camera. (more details...) |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_FRAME_TRANSFER_END |
Hooks the function to the event that occurs after transferring the frame from your camera to your computer. (more details...) |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_FRAME_TRANSFER_START |
Hooks the function to the event that occurs before transferring the frame from your camera to your computer. (more details...) |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_FRAME_TRIGGER |
Hooks the function to the event that occurs for each image when the acquisition of each image is triggered on the camera. |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_LINE_ANY_EDGE + |
Hooks the function to the event that occurs when the specified I/O signal changes on the camera. (more details...) |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_LINE_FALLING_EDGE + |
Hooks the function to the event that occurs on the falling edge of the specified I/O signal on the camera. (more details...) |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_LINE_RISING_EDGE + |
Hooks the function to the event that occurs on the rising edge of the specified I/O signal on the camera. (more details...) |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_TIMER_END + |
Hooks the function to the event that occurs when the specified timer ends. (more details...) |
† | c | o | s | ||||||||||||||||||||||||||||||||||
M_TIMER_START + |
Hooks the function to the event that occurs when the specified timer is triggered. (more details...) |
† | c | o | s |
You must add the following value to the above-mentioned values to specify the GenICam SFNC-specific counter, or I/O signal to which to hook the function.
For specifying the GenICam SFNC-specific
counter or I/O signal to which to hook the function
|
|||||||||||||||||||||||||||||||||||||||
Combination value | Description
|
MIL system-specific tooltip (†) |
|||||||||||||||||||||||||||||||||||||
Value >= 0 |
Specifies to hook to counter n or I/O signal n. (more details...) |
† | c | o | s |
You must add the following value to the above-mentioned values to specify the timer to which to hook the function.
For specifying the timer to which to hook
the function
|
|||||||||||||||||||||||||||||||||||||||
Combination value |
Description
|
MIL system-specific tooltip (†) |
|||||||||||||||||||||||||||||||||||||
M_TIMERn |
Specifies the timer to hook. (more details...) |
† | c | j | k | l | m | o | p | q | r | s | |||||||||||||||||||||||||||
MIL system specific | |||||||||||||||||||||||||||||||||||||||
With a GenICam SFNC-compliant camera, n can be a value from 0 to 8. |
† | c | o | s | |||||||||||||||||||||||||||||||||||
In this case, n can be a value from 1 to 4. |
† | j | k | m | p | q | r | ||||||||||||||||||||||||||||||||
With Matrox Solios eA/XA, n can be a value from 1 to 2. |
† | l |
You can add the following value to the above-mentioned value to specify the rotary decoder to which to hook the function.
For specifying the rotary decoder to
which to hook the function
|
|||||||||||||||||||||||||||||||||||||||
Combination value | Description
|
MIL system-specific tooltip (†) |
|||||||||||||||||||||||||||||||||||||
M_ROTARY_ENCODERn |
Specifies to hook to rotary decoder n, where n is a number between 1 and 4. (more details...) |
† | k | q |
Specifies the address of the function that should be called when the specified event occurs.
The hook-handler function, pointed to by HookHandlerPtr, must be declared as follows:
Type of event hooked.
Event identifier. You can pass the identifier to MdigGetHookInfo() to inquire about the hooked event.
User data pointer.
Upon successful completion, the hook-handler function should return M_NULL. Note, MFTYPE and MIL_DIG_HOOK_FUNCTION_PTR are reserved MIL predefined types for functions and data pointers.
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.
Header | Include mil.h. |
Library | Use mil.lib. |
DLL | Requires mil.dll. |