CVB++ 14.1
Cvb/CppConnectionState
1// ---------------------------------------------------------------------------
4// ---------------------------------------------------------------------------
5
6#include <iostream>
7#include <stdio.h>
8#include <iostream>
9#include <cvb/device_factory.hpp>
10
11
12int main(int argc, char* argv[])
13{
14 try
15 {
16 // open a device
17 auto infoList = Cvb::DeviceFactory::Discover(Cvb::DiscoverFlags::IgnoreVins);
18 if (infoList.empty())
19 {
20 std::cout << "no device discovered"<<std::endl;
21 return(0);
22 }
23 auto device = Cvb::DeviceFactory::Open<Cvb::GenICamDevice>(infoList[0].AccessToken(), Cvb::AcquisitionStack::GenTL);
24 auto cookie = device->RegisterConnectionStateChangedEvent([]() {
25 std::cout << "device was disconnected" << std::endl;
26 });
27 char endKey;
28 std::cout << "you can disconnect the device and get a confirmation message or ending the program by pressing a key."<<std::endl;
29 std::cin >> endKey;
30 }
31 catch (const std::exception& error)
32 {
33 std::cout << error.what() << std::endl;
34 }
35 return(0);
36}
static std::vector< DiscoveryInformation > Discover()
Discovers available devices (not vins) with a default time span of 300ms.
Definition: decl_device_factory.hpp:221