QPx_AcqSetNotificationHandler
QPx_AcqSetNotificationHandler(handlerMethod):error | |||
---|---|---|---|
![]() |
handlerMethod | Text | Notification handler method name |
![]() |
error | Longint | Error result |
Specify the device notification handler
Parameter handlerMethod is the name of the method that will receive device notifications. If the specified method does not exist, an error is returned. To remove an already installed notification handler method, set handlerMethod to an empty string.
NOTE Not all acquisition protocol devices provide connection/disconnection events. The protocols and devices that can currently send notifications are:
- PTP devices.
- USB-based video cameras on Windows.
The device notification handler
The device notification handler is a 4D method that receives notification events when a device is connected or disconnected. This method must comply with the following calling interface:
Syntax of the device notification handler method | |||
---|---|---|---|
![]() |
$1 - eventKindParam | Longint | The kind of the event |
![]() |
$2 - acqProtocolParam | Longint | The acquisition protocol identifier |
![]() |
$3 - deviceNameParam | Text | The name of the device |
![]() |
$0 - errorCode | Longint | Error code |
Parameter eventKindParam receives the kind of the event. This is one of the following constants:
qpx_AcqDeviceConnected | 0x1001 | A device has been connected |
qpx_AcqDeviceDisconnected | 0x1002 | A device has been disconnected |
Parameter acqProtocolParam receives the ID of the acquisition protocol to which the device belongs.
Parameter deviceNameParam receives the name of the device.
The notification handler returns <span class="qdoc-param">errorCode</span>, indicating to QPix if the handler executed successfully, if an error has occured, or if the notification handler was not interested in handling the event.
- If event was handled successfully, the handler must return qpx_noErr (zero).
- If there was an error handling the event, a suitable error code must be returned (non zero).
- If the handler did not handle the event, it must return error qpx_eventNotHandledErr.
Even though errorCode is not currently used by QPix, it is important to follow these rules in order to allow for future expansion and compatibility.
Important note: The notification handler method should do as little as possible and not access the 4D database engine, because it is called in a local plug-in process ($QPixAcqGlobalHandler). To do any kind of database access or GUI operations like running dialogs, start a new 4D process or send a message to an existing one using your favorite interprocess communication mechanism.
Related commands
QPx_AcqGetNotificationHandler | Get the device notification handler |