You are here

Notification

During DLL initialization you choose how the library will notify your application when GPIO-24 adapter sends events or responses. The following options are available: event object, callback function, window messages or thread messages.

Notification settings are passed to GPIO_Init() function as GPIO_NOTIFICATION structure:

typedef struct _GPIO_NOTIFICATION
{
        GPIO_NOTIFICATION_TYPE type;
        PGPIO_CALLBACK callback;
        DWORD thread;
        HWND wnd;
        UINT msg;
        HANDLE event;
} GPIO_NOTIFICATION, *PGPIO_NOTIFICATION;

Notification type is declared as enumeration:

typedef enum _GPIO_NOTIFICATION_TYPE
{
        ntEvent,
        ntCallback,
        ntWindowMessage,
        ntThreadMessage,
        ntNoNotification,
} GPIO_NOTIFICATION_TYPE;

After you have chosen the notification type, you have to fill the rest of the structure members as described below:

  • type=ntEvent – In this case the DLL uses an event object to notify the application when GPIO-24 adapter sends events or responses.

    Specify valid handle to the event object in event member of the GPIO_NOTIFICATION structure. As there is no possibility to pass parameters, handle to the device that generated the event is not sent. Specify HGPIO_ALL_DEVICES constant as the device handle when you call the GPIO_GetEvent() function.

    You can use tracer.exe application source code as an example of event object notification.

  • type=ntCallback – DLL calls the specified callback function to notify the application.

    Specify the address of a callback function in callback member of the GPIO_NOTIFICATION structure.

    The function should be declared as:

       void CALLBACK GPIO_Callback(HGPIO hDevice);
    

    The callback function receives handle to the device that has generated the event or HGPIO_DLL_NOTIFICATION constant for events generated internally by the DLL.

    [Warning] Warning

    The callback function is called in the context of the internal DLL thread. If you use resources which are also available for other threads, apply the appropriate synchronization.

  • type=ntWindowMessage – DLL sends a window message to notify the application.

    Specify valid window handle in wnd member of the GPIO_NOTIFICATION structure. Message ID should be chosen during the initialization and specified in msg member of the GPIO_NOTIFICATION structure.

    The device handle is sent in wParam of the window message. If an event is generated by the DLL, HGPIO_DLL_NOTIFICATION constant is sent instead of device handle.

  • type=ntThreadMessage – DLL sends a thread message to notify the application.

    Specify valid thread identifier in thread member of the GPIO_NOTIFICATION structure. Message ID should be chosen during the initialization and specified in msg member of the GPIO_NOTIFICATION structure.

    The device handle is sent in wParam of the window message. If an event is generated by the DLL, HGPIO_DLL_NOTIFICATION constant is sent instead of device handle.

  • type=ntNoNotification – DLL doesn’t notify the application when events arrive.

    In this case you can use synchronous communication routines or send asynchronous commands but the application will receive no notifications. You can still call the GPIO_GetEvent() function to check whether the new events have arrived and get event details.