Camera Connect Disconnect 3rd generation CVBV++ in GenTL (no VIN) GIGE

I am using in C++ CVB++ with GenTL (no vin used) with cvb 14.0.2 win64.
When I was using VIN, I was using “PCRegisterCallBack” API.
But without VIN and just GenTL, I don’t know what is the best way to do it.
I saw “RegisterConnectionStateChangedEvent”, but the callback has no parameter to inform which object it is (which camera) if I have several cams. This was possible with “PCRegisterCallBack” (.vin) with the “private” member.
Is the only way to be notified is to use “RegisterConnectionStateChangedEvent”?

Best regards,

1 Like

Hi @Mikael
since the RegisterConnectionStateChangedEvent is called on a specific Device object, you know exactely, which device is affected :nerd:


I don’t understand.
If I have a class “ClassCam” that has the static method “static void RegisterConnectionStateChangedEvent(void)”.
If I have multpile instaces of “ClassCam”, one instance per camera. Each instance registers RegisterConnectionStateChangedEvent. How can I know excactly which device has received the event (static method)?

I have no knowledge of your ClassCam class, but the Device class from CVB :cvb: (of which you should ultimately have one or more objects) has a non static RegisterConnectionStateChangedEvent function.
Your goal should be to register one listener for each CVB :cvb: device.


device1->RegisterConnectionStateChangedEvent([]() {
    // Handle device 1 disconnect

device2->RegisterConnectionStateChangedEvent([]() {
    // Handle device 2 disconnect

Ok thanks.
To my mind, there is a disavantage of this method: you must write all callback for a predefined number of camera. This is not dynamic. But I can make a mistake! Maybe there is a dynamic solution.

It would have been easier that CVB would have provided an interface that user implements and the ConnectionStateEvent would arrive directly in the concerned object. Or another solution: a callback with an argument void* (more C style) that contains the pointer of the objet given by the user.

Something like this?

void GenericHandleCameraDisconnect(Cvb::DevicePtr device)
    // Handle stuff

for (auto& dev : myDevices)
    dev->RegisterConnectionStateChangedEvent([dev]() {

Ok, this seems very good! I didn’t know this use of lambas.
Thanks !

1 Like