Notifications
As we've just seen, when an event occurs, a dedicated counter is incremented. Coaxlink
can also notify the application of this event by having
Euresys::EGrabber
execute a user-defined callback function. But first, it is required
to enable notifications of one or more events:
grabber.setString<DeviceModule>("EventSelector", "CameraTriggerRisingEdge");
grabber.setInteger<DeviceModule>("EventNotification", true);
grabber.setString<DeviceModule>("EventSelector", "CameraTriggerFallingEdge");
grabber.setInteger<DeviceModule>("EventNotification", true);
...
or:
grabber.setInteger<DeviceModule>("EventNotification[CameraTriggerRisingEdge]", true);
grabber.setInteger<DeviceModule>("EventNotification[CameraTriggerFallingEdge]", true);
...
Using a configuration script, it is easy to enable notifications for all events:
function enableAllEvents(p) { // 1
var events = p.$ee('EventSelector'); // 2
for (var e of events) {
p.set('EventNotification[' + e + ']', true); // 3
}
}
var grabber = grabbers[0];
enableAllEvents(grabber.InterfacePort); // 4
enableAllEvents(grabber.DevicePort); // 5
enableAllEvents(grabber.StreamPort); // 6
- Define a helper function named
enableAllEvents
and taking as argument a module (or port)p
. - Use the
$ee
function to retrieve the list of valuesEventSelector
can take. This is the list of events generated by modulep
. (ee
stands for enum entry.) - For each event, enable notifications. (The
+
operator concatenates strings, so ife
is'LIN1'
, the expression'EventNotification[' + e + ']'
evaluates to'EventNotification[LIN1]'
.) - Call the
enableAllEvents
function defined in step 1 for the interface module. This will enable notifications for all events in the I/O toolbox and CoaXPress interface categories. - Likewise, enable notifications for all events coming from the device module (CIC events).
- Finally, enable notifications for all data stream events.