driver.hpp
1 #pragma once
2 
3 #include <codecvt>
4 #include <locale>
5 #include <vector>
6 #include <type_traits>
7 #include <tuple>
8 
9 #include "../global.hpp"
10 #include "../string.hpp"
11 #include "../genapi/genapi.hpp"
12 
13 namespace Cvb
14 {
15 
16 CVB_BEGIN_INLINE_NS
17 
19 
23 namespace Driver
24 {
25 
26 class FlowSetPool;
29 
30 class DeviceControl;
33 
34 class RingBuffer;
37 
38 class DigitalIO;
41 
42 class SoftwareTrigger;
45 
46 class NotifyObservable;
49 
50 class ImageRect;
53 
54 class DeviceImage;
57 
58 class VinDevice;
61 
62 class VideoDevice;
65 
66 class EmuDevice;
69 
70 class NonStreamingDevice;
73 
74 class GenICamDevice;
77 
78 class RingBufferImage;
81 
82 class StreamImage;
85 
86 class MultiPartImage;
89 
90 class BufferImage;
93 
94 class Stream;
97 
98 class IndexedStream;
101 
102 class StreamBase;
105 
106 class CompositeStreamBase;
109 
110 class ImageStream;
113 
114 class CompositeStream;
117 
118 class PointCloudStream;
121 
122 class VideoImage;
125 
126 class EmuImage;
129 
130 class VinImage;
133 
134 class FlowSetPool;
137 
138 enum class StreamType
139 {
140  Legacy,
141  Composite,
142  Image,
143  PointCloud
144 };
145 
147 
148 struct Flow
149 {
151  size_t Size;
152 
154  void* Buffer;
155 
157  Flow(size_t size = 0, void* buffer = nullptr)
158  : Size(size)
159  , Buffer(buffer)
160  {
161  }
162 };
163 
164 namespace Private
165 {
166 
167 template <class T>
168 inline StreamType StreamTypeFor() noexcept
169 {
173  std::is_same<T, class Stream>::value, "unsupported stream type");
174  return StreamType::Legacy;
175 }
176 
177 template <>
178 inline StreamType StreamTypeFor<class Stream>() noexcept
179 {
180  return StreamType::Legacy;
181 }
182 
183 template <>
184 inline StreamType StreamTypeFor<CompositeStream>() noexcept
185 {
186  return StreamType::Composite;
187 }
188 
189 template <>
190 inline StreamType StreamTypeFor<ImageStream>() noexcept
191 {
192  return StreamType::Image;
193 }
194 
195 template <>
196 inline StreamType StreamTypeFor<PointCloudStream>() noexcept
197 {
198  return StreamType::PointCloud;
199 }
200 
201 }
202 
205 {
211  InterfaceSubNetList = CExports::DO_DISCOVER_INFO_INTERFACE_NET_LIST,
213  InterfaceMac = CExports::DO_DISCOVER_INFO_INTERFACE_NET_MAC,
219  InterfaceTLType = CExports::DO_DISCOVER_INFO_INTERFACE_TLTYPE,
221  InterfaceDisplayName = CExports::DO_DISCOVER_INFO_INTERFACE_DISPLAYNAME,
227  InterfaceDriverType = CExports::DO_DISCOVER_INFO_INTERFACE_DRIVERTYPE,
229  InterfaceId = CExports::DO_DISCOVER_INFO_INTERFACE_ID,
235  DeviceTransportLayerType = CExports::DO_DISCOVER_INFO_DEVICE_TLTYPE,
237  DeviceUsername = CExports::DO_DISCOVER_INFO_DEVICE_USERNAME,
239  DeviceSerialNumber = CExports::DO_DISCOVER_INFO_DEVICE_SERIALNUMBER,
241  DeviceMac = CExports::DO_DISCOVER_INFO_DEVICE_NET_MAC,
243  DeviceIP = CExports::DO_DISCOVER_INFO_DEVICE_NET_IP,
245  DeviceSubnetMask = CExports::DO_DISCOVER_INFO_DEVICE_NET_SUBNETMASK,
247  DeviceUsbVendorId = CExports::DO_DISCOVER_INFO_DEVICE_USB_VID,
249  DeviceUsbProductId = CExports::DO_DISCOVER_INFO_DEVICE_USB_PID,
251  DeviceVendor = CExports::DO_DISCOVER_INFO_DEVICE_VENDOR,
253  DeviceModel = CExports::DO_DISCOVER_INFO_DEVICE_MODEL,
255  DeviceId = CExports::DO_DISCOVER_INFO_DEVICE_ID,
261  DeviceAccessStatus = CExports::DO_DISCOVER_INFO_DEVICE_ACCESS_STATUS,
263  TransportLayerId = CExports::DO_DISCOVER_INFO_TRANSPORTLAYER_ID,
265  TransportLayerPath = CExports::DO_DISCOVER_INFO_TRANSPORTLAYER_PATH,
267  TransportLayerVendor = CExports::DO_DISCOVER_INFO_TRANSPORTLAYER_VENDOR,
269  UsbPortPath = CExports::DO_DISCOVER_INFO_DEVICE_USB_PORT_PATH
270 };
271 
273 enum class AcquisitionStack
274 {
276  Vin,
280  PreferVin,
282  GenTL,
287 };
288 
290 
294 {
296  FindAll = 0,
302  IncludeEmpty = 1,
304  IncludeInaccessible = 1 << 12,
306  UpToLevelSystem = 1 << 1,
308  UpToLevelVin = 2 << 1,
310  UpToLevelTL = 3 << 1,
312  UpToLevelInterface = 4 << 1,
314  UpToLevelDevice = 5 << 1,
316  UpToLevelStream = 6 << 1,
318  IgnoreVins = 1 << 8,
320  IgnoreTLs = 1 << 9,
322  IgnoreGevSD = 1 << 10,
324  IgnoreGevFD = 1 << 11
325 };
326 
327 inline DiscoverFlags operator|(DiscoverFlags a, DiscoverFlags b)
328 {
329  return static_cast<DiscoverFlags>(static_cast<std::uint64_t>(a) | static_cast<std::uint64_t>(b));
330 }
331 
333 enum class ModuleLayer
334 {
336  Unknown = CExports::DO_AT_LEVEL_UNKNOWN,
338  System = CExports::DO_AT_LEVEL_SYSTEM,
340  Vin = CExports::DO_AT_LEVEL_VIN,
342  TransportLayerSystem = CExports::DO_AT_LEVEL_TLSYSTEM,
344  TransportLayerInterface = CExports::DO_AT_LEVEL_TLIFACE,
346  TransportLayerDevice = CExports::DO_AT_LEVEL_TLDEVICE,
348  TransportLayerStream = CExports::DO_AT_LEVEL_TLSTREAM
349 };
350 
352 enum class NotifyDataType
353 {
355  Void = CExports::CVNO_DATA_VOID,
357  Int64 = CExports::CVNO_DATA_INTEGER64,
359  Float64 = CExports::CVNO_DATA_FLOAT64,
361  String = CExports::CVNO_DATA_STRING,
363  Binary = CExports::CVNO_DATA_BINARY,
365  Boolean = CExports::CVNO_DATA_BOOL8,
366 };
367 
369 enum class DeviceState
370 {
372  DeviceDisconnected = 2,
374  DeviceReconnect = 3,
378  NewMetaData = 5
379 };
380 
382 
384 template <class T> struct WaitResult
385 {
390 };
391 
394 {
400  Auto = CExports::RINGBUFFER_LOCKMODE_AUTO,
406  Off = CExports::RINGBUFFER_LOCKMODE_OFF,
412  On = CExports::RINGBUFFER_LOCKMODE_ON
413 };
414 
416 enum class PlaybackMode
417 {
419  FrameByFrame,
426  Stream
427 };
428 
431 {
433  Grabber,
435  Grab2,
437  GenTL
438 };
439 
441 
446 enum class StreamInfo
447 {
456  IsCameraDetected = CExports::GRAB_INFO_CAMERA_DETECTED,
458  NumBuffersAcquired = CExports::GRAB_INFO_NUMBER_IMAGES_AQCUIRED,
465  NumBuffersDelivered = CExports::G2INFO_NumBuffersDelivered,
470  NumBuffersLost = CExports::G2INFO_NumBuffersLost,
472  NumBuffersLostTransfer = CExports::GRAB_INFO_NUMBER_IMAGES_LOST,
474  NumBuffersLostLocked = CExports::GRAB_INFO_NUMBER_IMAGES_LOST_LOCKED,
476  NumBuffersLocked = CExports::GRAB_INFO_NUMBER_IMAGES_LOCKED,
478  NumBuffersPending = CExports::GRAB_INFO_NUMBER_IMAGES_PENDIG,
487  NumBuffersCorruptOnArrival = CExports::G2INFO_NumBuffersCorrupt,
495  NumBuffersCorruptOnDelivery = CExports::G2INFO_NumBuffersCorruptOnDelivery,
497  NumTriggersLost = CExports::GRAB_INFO_NUMBER_TRIGGERS_LOST,
504  NumBuffersAnnounced = CExports::G2INFO_NumBuffersAnnounced,
509  NumBuffersQueued = CExports::G2INFO_NumBuffersQueued,
511  NumBuffersBeingFilled = CExports::G2INFO_NumBuffersInIncompleteList,
513  NumPacketsReceived = CExports::G2INFO_NumPacketsReceived,
515  NumResends = CExports::G2INFO_NumResends
516 };
517 
520 {
522  Get = CExports::DC_GET,
524  Set = CExports::DC_SET,
526  GetMinimum = CExports::DC_GETMIN,
528  GetMaxiumum = CExports::DC_GETMAX,
530  Verify = CExports::DC_VERIFY
531 
532 };
533 
536 {
538  Started,
540  Stopping,
542  AbortingStop,
544  Stopped
545 };
546 
547 
548 namespace NodeMapID
549 {
551  static const Cvb::String Device = Cvb::String(CVB_LIT("Device"));
553  static const Cvb::String Factory = Cvb::String(CVB_LIT("TLFactory"));
555  static const Cvb::String System = Cvb::String(CVB_LIT("TLSystem"));
557  static const Cvb::String Interface = Cvb::String(CVB_LIT("TLInterface"));
559  static const Cvb::String TLDevice = Cvb::String(CVB_LIT("TLDevice"));
561  static const Cvb::String DataStream = Cvb::String(CVB_LIT("TLDatastream"));
563  static const Cvb::String VinDevice = Cvb::String(CVB_LIT("VinDevice"));
565  static const Cvb::String VinBuffer = Cvb::String(CVB_LIT("VinBuffer"));
566 }
567 
569 template<class T>
571 
572 }
573 
580 
591 using Driver::ImageStream;
601 using Driver::Stream;
602 using Driver::StreamPtr;
605 
606 using Driver::StreamType;
610 using Driver::DeviceState;
614 using Driver::EmuImagePtr;
615 using Driver::ModuleLayer;
619 using Driver::StreamInfo;
621 using Driver::VinImage;
622 using Driver::VinImagePtr;
623 using Driver::WaitResult;
625 using Driver::FlowSetPool;
627 using Driver::Flow;
628 
629 namespace NodeMapID = Driver::NodeMapID;
630 
631 CVB_END_INLINE_NS
632 
633 }
Gets the maximal supported value for the parameter.
Limit discovery depth to interface library level.
ModuleLayer
Level of an access token entry.
Definition: driver.hpp:333
Unique identifier of the GenTL Producer.
STL class.
std::shared_ptr< EmuDevice > EmuDevicePtr
Convenience shared pointer for EmuDevice.
Definition: driver.hpp:68
WaitStatus
Status after waiting for an image to be returned.
Definition: global.hpp:350
size_t Size
Flow size in bytes.
Definition: driver.hpp:151
Ethernet device only : Subnet mask.
Streams images.
Definition: image_stream.hpp:18
Device only : User configured name.
Streams composites.
Definition: composite_stream.hpp:19
Ignore socket driver for GEVTL GenTL Producer.
Buffer class implementing a buffer.
Definition: buffer.hpp:12
Limit discovery depth to system level(factory).
Ring buffer / queue based acquisition.
Limit discovery depth to vin-driver level.
std::tuple< std::shared_ptr< T >, WaitStatus, NodeMapEnumerator > WaitResultTuple
Tuple holding multiple return values after waiting for a specific payload data.
Definition: driver.hpp:570
std::shared_ptr< CompositeStreamBase > CompositeStreamBasePtr
Convenience shared pointer for CompositeStreamBase.
Definition: driver.hpp:108
Everything is fine, a new image arrived.
A device representing a video interface driver (vin).
Definition: decl_vin_device.hpp:35
Ignore GenTL producers in discovery.
Limit discovery depth to stream level.
Streams point clouds.
Definition: point_cloud_stream.hpp:18
Default flags to find all devices and vin-drivers.
FlowSetPool class to set external buffers as set of flows.
Definition: flow_set_pool.hpp:43
AcquisitionState
Specifies current state of the acquisition engine.
Definition: driver.hpp:535
Represents one acquisition stream of a device.
Definition: decl_stream.hpp:36
std::shared_ptr< IndexedStream > IndexedStreamPtr
Convenience shared pointer for IndexedStream.
Definition: driver.hpp:100
Base class of all composite based streams.
Definition: decl_composite_stream_base.hpp:30
Ethernet device only : IP address.
The Stream::Wait() method always returns the next image in the video stream.
std::shared_ptr< PointCloudStream > PointCloudStreamPtr
Convenience shared pointer for PointCloudStream.
Definition: driver.hpp:120
MultiPart image class.
Definition: multi_part_image.hpp:20
AcquisitionStack
Defines the acquisition stack when opening the device.
Definition: driver.hpp:273
std::shared_ptr< DigitalIO > DigitalIOPtr
Convenience shared pointer for DigitalIO.
Definition: driver.hpp:40
NotifyDataType
Data type delivered by the event.
Definition: driver.hpp:352
Count that only contains lost images due to ring buffer overflow.
Implementation of the device control interface.
Definition: decl_device_control.hpp:97
RingBufferLockMode
Lock mode options for the ring buffer.
Definition: driver.hpp:393
Use Vin acquisition stack or fail.
std::shared_ptr< EmuImage > EmuImagePtr
Convenience shared pointer for EmuImage.
Definition: driver.hpp:128
Gets how many trigger signals where ignored by the device due to e.g. over-triggering.
Base class of all stream related images.
Definition: stream_image.hpp:31
Single notify event observable.
Definition: decl_notify_observable.hpp:97
STL class.
Root namespace for the Image Manager interface.
Definition: version.hpp:11
Device was disconnected (communication lost).
std::shared_ptr< VideoDevice > VideoDevicePtr
Convenience shared pointer for VideoDevice.
Definition: driver.hpp:64
The Common Vision Blox image.
Definition: decl_image.hpp:44
std::shared_ptr< DeviceControl > DeviceControlPtr
Convenience shared pointer for DeviceControl.
Definition: driver.hpp:32
Interface only: GenTL identifier of the interface.
Lazy enumeration of node maps.
Definition: node_map_enumerator.hpp:30
WaitStatus Status
The status.
Definition: driver.hpp:387
std::shared_ptr< ImageRect > ImageRectPtr
Convenience shared pointer for SoftwareTrigger.
Definition: driver.hpp:52
Get information from the device.
Number of images currently in locked state.
Ethernet device only : MAC address.
std::shared_ptr< NonStreamingDevice > NonStreamingDevicePtr
Convenience shared pointer for NonStreamingDevice.
Definition: driver.hpp:72
Ignore vin-drivers in discovery.
Ignore filter driver for GEVTL GenTL Producer.
A device representing a GenICam compliant device.
Definition: decl_genicam_device.hpp:18
Limit discovery depth to transport library level.
std::shared_ptr< VideoImage > VideoImagePtr
Convenience shared pointer for VideoImage.
Definition: driver.hpp:124
PlaybackMode
Defines how frames are acquired by this video device.
Definition: driver.hpp:416
Number of images acquired, but not retrieved via the stream's wait method.
A point cloud object.
Definition: decl_point_cloud.hpp:48
std::shared_ptr< ImageStream > ImageStreamPtr
Convenience shared pointer for ImageStream.
Definition: driver.hpp:112
A stream with a finite number of images, which can also be accessed via an index.
Definition: decl_indexed_stream.hpp:24
Ethernet interface only: MAC address.
std::shared_ptr< BufferImage > BufferImagePtr
Convenience shared pointer for BufferImage.
Definition: driver.hpp:92
StreamInfo
Queryable stream information.
Definition: driver.hpp:446
Stream image that is returned, when the ring buffer interface is available on a device.
Definition: decl_ring_buffer_image.hpp:27
Invalid or not filled yet.
std::shared_ptr< VinDevice > VinDevicePtr
Convenience shared pointer for VinDevice.
Definition: driver.hpp:60
AcquisitionInterface
Known acquisition CVB interfaces.
Definition: driver.hpp:430
std::shared_ptr< FlowSetPool > FlowSetPoolPtr
Convenience shared pointer for FlowSetPool.
Definition: driver.hpp:28
Device width, height, plane number and/or data type changed.
std::shared_ptr< T > Image
The returned image by wait if applicable cast to the provided type.
Definition: driver.hpp:389
File path of the CTI file(GenTL Producer library).
DiscoverFlags
Flags controlling the discovery process.
Definition: driver.hpp:293
std::shared_ptr< RingBuffer > RingBufferPtr
Convenience shared pointer for RingBuffer.
Definition: driver.hpp:36
The engine is in the process of stopping.
std::shared_ptr< StreamImage > StreamImagePtr
Convenience shared pointer for StreamImage.
Definition: driver.hpp:84
A combined result returned after waiting for a image.
Definition: driver.hpp:384
Implementation of the software trigger.
Definition: decl_software_trigger.hpp:15
Number of buffer currently being filled by the acquisition engine.
std::shared_ptr< MultiPartImage > MultiPartImagePtr
Convenience shared pointer for StreamImage.
Definition: driver.hpp:88
Set information in the device.
std::shared_ptr< SoftwareTrigger > SoftwareTriggerPtr
Convenience shared pointer for SoftwareTrigger.
Definition: driver.hpp:44
USB device only: USB vendor identifier.
std::shared_ptr< NotifyObservable > NotifyObservablePtr
Convenience shared pointer for NotifyObservable.
Definition: driver.hpp:48
Device was reconnected (communication regained).
The engine is aborting an ongoing stop.
Use GenTL acquisition stack or fail.
std::shared_ptr< Stream > StreamPtr
Convenience shared pointer for Stream.
Definition: driver.hpp:96
For packet based protocols this contains the actual number of packets received (parts of a whole imag...
Device only : GenTL identifier of the interface.
std::shared_ptr< StreamBase > StreamBasePtr
Convenience shared pointer for StreamBase.
Definition: driver.hpp:104
Basic grabber interface for single image acquisition.
DeviceControlOperation
Operation on driver specific parameter.
Definition: driver.hpp:519
Normally inaccessible devices are filtered out : this flag includes them.
Base class of all streams.
Definition: stream_base.hpp:18
A device representing a video stream from the hard disk.
Definition: decl_video_device.hpp:30
Special device image.
Definition: decl_device_image.hpp:24
Flow(size_t size=0, void *buffer=nullptr)
Constructor.
Definition: driver.hpp:157
Limit discovery depth to device level.
std::shared_ptr< DeviceImage > DeviceImagePtr
Convenience shared pointer for DeviceImage.
Definition: driver.hpp:56
std::shared_ptr< GenICamDevice > GenICamDevicePtr
Convenience shared pointer for GenICamDevice.
Definition: driver.hpp:76
DeviceState
States the device can be in.
Definition: driver.hpp:369
std::shared_ptr< CompositeStream > CompositeStreamPtr
Convenience shared pointer for CompositeStream.
Definition: driver.hpp:116
DiscoveryProperties
Properties which can be queried from a DiscoveryInformation entry.
Definition: driver.hpp:204
Count that only contains lost images during transfer.
void * Buffer
The buffer.
Definition: driver.hpp:154
Ring buffer operations on a device.
Definition: decl_ring_buffer.hpp:20
Interface only: Human readable name of the interface.
Component class is a container for CVB objects.
Definition: decl_composite.hpp:44
Image rectangle operations on a device.
Definition: decl_image_rect.hpp:17
std::shared_ptr< VinImage > VinImagePtr
Convenience shared pointer for VinImage.
Definition: driver.hpp:132
Struct handling the size and buffer of a flow.
Definition: driver.hpp:148
The number of images buffers acquired since start of the last acquisition start.
A device representing an image stream based on single image files.
Definition: decl_emu_device.hpp:32
Number of resend requests sent since start of the last acquisition.
Discovery system module (root).
Gets the minimal supported value for the parameter.
Digital I/O operations on a device.
Definition: decl_digital_io.hpp:23
Verify the given value for the parameter.
std::shared_ptr< RingBufferImage > RingBufferImagePtr
Convenience shared pointer for RingBufferImage.
Definition: driver.hpp:80
USB device only : USB product identifier.
Generic CVB physical device.
Definition: decl_device.hpp:38