Connection monitoring in cvb.net

Hi all,

I am relatively new to cvb so apologies if i’m asking an obvious question!

I’ve been moving our image-capturing code (C#) from the standard cvb library to using the cvb.NET library. This has been generally successful and capturing/saving images and configuring cameras works great. However, I can’t figure out how to do connection monitoring in cvb.net???

I’ve seen this link already:
CVB User Guide for the GenICam Driver (commonvisionblox.com)

However, this doesn’t seem to be compatible with the cvb.net approach to connecting devices. I’ve seen the Device.ConnectionState property and the Device.ConnectionStateChanged event, but neither of these seem to work as expected.

I wrote a small test harness that manually monitored the Device.ConnetionState property of my camera as I disconnected and reconnected it and the ConnectionState was Connected throughout.

I tried subscribing to the ConnectionStateChanged event but my handler was never triggered.

I’m sure there must be something I’m missing, but I can’t see what. Any help would be greatly appreciated.

Thanks,

Rob

Hi Rob,

this is a good question, indeed. We simplified the connection monitoring interface quite a bit. You can use the Device.ConnectionState property and Device.ConnectionStateChanged event. Under the hood this still uses INotify, but makes handling this much more convenient.

Simply register to the Device.ConnectionStateChanged event. On the event data you have the .OldState and .NewState properties for you to evaluate the nature of the change.

2 Likes

Hi parsd,

Thank you for taking the time to answer my query.

The way you describe it what I attempted and thought would work, but I’ve noticed that the Device.ConnectionState property isn’t changing and Device.ConnectionStateChanged event isn’t being fired when I disconnect or reconnect my camera.

Do you have any idea why this might be?? Is there any further under-the-hood code I need? Or do I need to configure a node on the device somehow??

Thanks,

Rob

ps. for reference here is the code I am using:

bool success = DeviceFactory.TryOpenPort(driverString, channelNumber, out camera);
if (success) camera.ConnectionStateChanged += HandleConnectionStateChanged;
.
.
.
private void HandleConnectionStateChanged(object sender, ConnectionStateChangeEventArgs e)
{
      logManager.Write($"Camera connection status has changed from {e.OldState} to {e.NewState}");
}

What kind of underlying technology do you use?

Not all Vins/transport layers support connection monitoring. You can check that by reading out the .ConnectionState property on the device: if that is ConnectionState.NotSupported the underlying technology doesn’t support it. If that states ConnectionState.Connected, then it still might be that the underlying transport layer does not communicate the connection change.