INotify Interface

<< Click to Display Table of Contents >>

Navigation:  CVB with GenICam > SDK > Supported Interfaces - GenICam Driver >

INotify Interface

 

INotify Interface description : callback functions for events

 

This 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. Refer also examples from Connection Monitoring chapter.

 

VC++ Example Code (CVB 2017 - 13.x.x):

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 (CVB 2017 - 13.x.x)

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.

}