4#include <condition_variable>
6#include <cvb/device_factory.hpp>
7#include <cvb/global.hpp>
8#include <cvb/driver/composite_stream.hpp>
9#include <cvb/genapi/node_map_enumerator.hpp>
10#include <cvb/async/async.hpp>
11#include <cvb/async/stream_handler_base.hpp>
14static const constexpr int NUM_ELEMENTS_TO_ACQUIRE = 10;
30 return std::make_unique<CustomStreamHandler>(streams, PrivateTag{});
41 return observer_.wait_until(lock, absTime);
51 waitResultList.reserve(streams.size());
52 for (
auto n = 0; n < streams.size(); ++n)
53 waitResultList.emplace_back(streams[n]->WaitFor(TIMEOUT));
63 std::cout <<
"round: #" << numDeliverables_ <<
"\n";
66 for (
auto m = 0; m < waitResultList.size(); ++m)
69 auto waitStatus = std::get<Cvb::WaitStatus>(waitResultList[m]);
78 std::cout << WAIT_ERROR_STATES[waitStatus];
83 std::cout <<
"; no deliverable is available.\n";
90 auto composite = std::get<Cvb::CompositePtr>(waitResultList[m]);
93 const auto numItems = composite->ItemCount();
94 std::cout <<
"number of items: " << numItems <<
"\n";
95 for (
auto n = 0; n < numItems; ++n)
97 auto item = composite->ItemAt(n);
99 if (Cvb::holds_alternative<Cvb::ImagePtr>(item))
101 else if (Cvb::holds_alternative<Cvb::PlanePtr>(item))
103 else if (Cvb::holds_alternative<Cvb::PlaneEnumeratorPtr>(item))
104 item_type =
"plane enumerator";
105 else if (Cvb::holds_alternative<Cvb::BufferPtr>(item))
106 item_type =
"buffer";
107 else if (Cvb::holds_alternative<Cvb::PFNCBufferPtr>(item))
108 item_type =
"pfnc buffer";
109 std::cout <<
"composite item #" << n <<
": " << item_type <<
"\n";
115 if (numDeliverables_ == NUM_ELEMENTS_TO_ACQUIRE)
116 observer_.notify_all();
121 int numDeliverables_;
133 for (
const auto &info : infoList)
134 if (info.AccessToken().find(
"MockTL") != Cvb::String::npos)
135 accessToken = info.AccessToken();
137 if (accessToken.empty())
143 Cvb::DeviceFactory::Open<Cvb::GenICamDevice>(infoList.front().AccessToken(), Cvb::AcquisitionStack::GenTL);
152 streams.reserve(device->StreamCount());
153 for (
auto n = 0; n < device->StreamCount(); ++n)
155 auto handler = CustomStreamHandler::Create(streams);
169 handler->TryFinish();
Stream handler for synchronous streams.
Definition: decl_stream_handler_base.hpp:93
virtual void HandleAsyncWaitResult(const std::vector< WaitResult< typename Internal::DeliverableTraits< STREAMTYPE >::type > > &waitResultVector)
Asynchronously called for all acquired images.
Definition: detail_stream_handler_base.hpp:151
static std::unique_ptr< StreamHandlerBase > Create(const StreamVectorType &streamVector)
Create a stream handler object.
Definition: decl_stream_handler_base.hpp:130
virtual void HandleAsyncStream(const StreamVectorType &streamVector)
Asynchronously called for all registered streams.
Definition: detail_stream_handler_base.hpp:131
static std::vector< DiscoveryInformation > Discover()
Discovers available devices (not vins) with a default time span of 300ms.
Definition: decl_device_factory.hpp:221
Streams composites.
Definition: composite_stream.hpp:21
StreamHandlerBase< CompositeStream > CompositeStreamHandler
Shorthand notation of the composite stream handler.
Definition: async.hpp:31
Root namespace for the Image Manager interface.
Definition: c_barcode.h:15
@ Abort
The acquisition has been stopped asynchronously, there is no image buffer.
@ Ok
Everything is fine, a new image arrived.
@ Timeout
A timeout occurred, no image buffer has been returned.