Common Vision Blox 15.0
Loading...
Searching...
No Matches
Image Manager/Cvb++/CppConnectionState

This example program is located in your CVB installation under %CVB%Tutorial/Image Manager/Cvb++/CppConnectionState.

main.cpp:

// The CppConnectionState example shows the state of device connection. The console output gives a
// message when device is disconnected.
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
#include <cvb/device_factory.hpp>
#include <iostream>
#include <stdio.h>
int main() {
try {
// open a device
auto infoList =
Cvb::DeviceFactory::Discover(Cvb::DiscoverFlags::IgnoreVins);
if (infoList.empty()) {
std::cout << "no device discovered" << std::endl;
return (0);
}
infoList[0].AccessToken(), Cvb::AcquisitionStack::GenTL);
auto cookie = device->RegisterConnectionStateChangedEvent(
[]() { std::cout << "device was disconnected" << std::endl; });
char endKey;
std::cout << "you can disconnect the device and get a confirmation message "
"or ending the program by pressing a key."
<< std::endl;
std::cin >> endKey;
} catch (const std::exception &error) {
std::cout << error.what() << std::endl;
}
return (0);
}
static std::vector< DiscoveryInformation > Discover()
static std::shared_ptr< T > Open(const String &provider, AcquisitionStack acquisitionStack=AcquisitionStack::PreferVin)