INotify Interface

<< Click to Display Table of Contents >>

Navigation:  Image Manager > CVB Technology > Acquisition device drivers and CVB Programming Interfaces >

INotify Interface

 

INotify Interface description : callback functions for events

 

The INotify interface allows to register callback functions for events like disconnect/reconnect or events generated by the device.

In case such an event carries additional data, it is passed to the callback function.

 

VC++ Example Code:

void CVCSizeableDisplayDlg::OnImageUpdatedCvgrabberctrl()

{

  // update attached OCXs

  m_Img = reinterpret_cast<IMG>(m_cvGrabber.GetImage());

  m_cvImg.SetImage(m_cvGrabber.GetImage());

  m_cvDisp.SetImage(m_cvGrabber.GetImage());

 

  if (CanNotify(m_Img))

  {

    cvbint64_t info = FALSE;

    cvbres_t result = NOGetStatus(m_Img, CVNO_EID_DEVICE_DISCONNECTED, CVNO_INFO_IS_AVAILABLE, info);

    if (result < 0 || !info)

    {

      m_cvDisp.SetStatusUserText("No MetaData available");

    }

    else

    {

      // we do not need to unregister the callback:

      intptr_t disconnectedEventCookie = -1;

      result = NORegister(m_Img, CVNO_EID_DEVICE_DISCONNECTED, &CVCSizeableDisplayDlg::DeviceDisconnected, this, disconnectedEventCookie);

      if (result < 0)

        m_cvDisp.SetStatusUserText("Error registering DisconnectedEvent!");

    }

  }

}

 

// Event that gets called when a camera was disconnected.

// EventID  - The event ID.

// Buf      - The buffer.

// Size     - Size of Buffer in bytes.

// DataType - Defines the datatype for the INotify data. See CVNotifyDatatypes for possible types.

// UserData - User provided pointer to private data which gets passed to the event callback function.

 

void __stdcall CVCSizeableDisplayDlg::DeviceDisconnected(CVNotifyEvent_t EventIDvoid *Bufsize_t Size, CVNotifyDatatype_t DataTypevoid *UserData)

{

  CVCSizeableDisplayDlg* dlg = reinterpret_cast<CVCSizeableDisplayDlg*>(UserData);

  dlg->m_cvDisp.SetStatusUserText("Device disconnected!");

}

 

 

C# Example Code:

private void cvGrabber_ImageUpdated(object sender, System.EventArgs e)

{

  // image handling

  cvDisplay.Image = cvImage.Image;

 

  // check if INotify is supported.

  if (Driver.INotify.CanNotify(cvImage.Image))

  {

    // check if DeviceDisconnected is supported.

    long info;

    Driver.INotify.NOGetStatus(cvDisplay.Image, Driver.INotify.CVNotifyEventID.DEVICE_DISCONNECTED, Driver.INotify.CVNotifyInfoCmd.IS_AVAILABLE, out info);

 

    // if DeviceDisconnected is supported.

    IntPtr cookie;

    if (info)

      // register event.

      Driver.INotify.NORegister(cvDisplay.Image, Driver.INotify.CVNotifyEventID.DEVICE_DISCONNECTED, DeviceDisconnectedEvent, Handle, out cookie);

 

    else

      MessageBox.Show("Driver does not support DeviceDisonnected!");

  }

 

  else

    Debug.WriteLine("Driver does not support INotify!");

}

 

// Event that gets called when a camera was disconnected.

// eventID  - The event ID.

// buffer   - The buffer.

// Size     - Size of Buffer in bytes.

// DataType - Defines the datatype for the INotify data. See CVNotifyDatatypes for possible types.

// UserData - User provided pointer to private data which gets passed to the event callback function.

public void DeviceDisconnectedEvent(Cvb.Driver.INotify.CVNotifyEventID eventID, IntPtr buffer, int Size, 

 Cvb.Driver.INotify.CVNotifyDataType DataType, IntPtr UserData)

{

  // user output:

  MessageBox.Show("Device disconnected!");

 

  // error handling.

}

 

Connection Monitoring using the INotify interface

Within our GenICam architecture it is possible to be informed if a device disconnects or reconnects.

This is called Connection Monitoring and  is supported with GigE Vision.

 

This feature can be useful if a device temporarily loose its power and the connection needs to be re-established.

The Connection Monitoring is realized over the INotify interface with its DEVICE_DISCONNECTED and DEVICE_RECONNECT event.

For details refer INotify interface description.

 

Important Notes:

•When the camera is reconnected the driver has to be reloaded.

•Configure the devices with a persistent IP address and do not use DHCP to be able to get reconnected events.

•Do not disconnect the camera inside the callback thread.