All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
device.h
Go to the documentation of this file.
1 /*
2  * This file is part of the rc_genicam_api package.
3  *
4  * Copyright (c) 2017 Roboception GmbH
5  * All rights reserved
6  *
7  * Author: Heiko Hirschmueller
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * 3. Neither the name of the copyright holder nor the names of its contributors
20  * may be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef RC_GENICAM_API_DEVICE
37 #define RC_GENICAM_API_DEVICE
38 
39 #include "interface.h"
40 
41 #include <mutex>
42 
44 
45 namespace rcg
46 {
47 
48 class Stream;
49 
56 class Device : public std::enable_shared_from_this<Device>
57 {
58  public:
59 
61 
67  Device(const std::shared_ptr<Interface> &parent,
68  const std::shared_ptr<const GenTLWrapper> &gentl, const char *id);
69  ~Device();
70 
77  std::shared_ptr<Interface> getParent() const;
78 
85  const std::string &getID() const;
86 
95  void open(ACCESS access);
96 
102  void close();
103 
109  void enableModuleEvents();
110 
119 
133  int64_t getModuleEvent(int64_t timeout=-1);
134 
140 
150  std::vector<std::shared_ptr<Stream> > getStreams();
151 
162  std::string getVendor();
163 
174  std::string getModel();
175 
186  std::string getTLType();
187 
198  std::string getDisplayName();
199 
210  std::string getAccessStatus();
211 
222  std::string getUserDefinedName();
223 
234  std::string getSerialNumber();
235 
246  std::string getVersion();
247 
258  uint64_t getTimestampFrequency();
259 
272  std::shared_ptr<GenApi::CNodeMapRef> getNodeMap(const char *xml=0);
273 
286  std::shared_ptr<GenApi::CNodeMapRef> getRemoteNodeMap(const char *xml=0);
287 
295  std::shared_ptr<CPort> getRemotePort();
296 
303  void *getHandle() const;
304 
305  private:
306 
307  Device(class Device &); // forbidden
308  Device &operator=(const Device &); // forbidden
309 
310  std::shared_ptr<Interface> parent;
311  std::shared_ptr<const GenTLWrapper> gentl;
312  std::string id;
313 
314  std::mutex mtx;
315 
316  int n_open;
317  void *dev;
318  void *rp;
319  void *event;
320  std::vector<uint8_t> event_buffer;
321  std::vector<uint8_t> event_value;
322 
323  std::shared_ptr<CPort> cport, rport;
324  std::shared_ptr<GenApi::CNodeMapRef> nodemap, rnodemap;
325  std::shared_ptr<GenApi::CEventAdapterGeneric> eventadapter;
326 
327  std::vector<std::weak_ptr<Stream> > slist;
328 };
329 
339 std::vector<std::shared_ptr<Device> > getDevices(uint64_t timeout);
340 std::vector<std::shared_ptr<Device> > getDevices();
341 
354 std::shared_ptr<Device> getDevice(const char *devid, uint64_t timeout);
355 std::shared_ptr<Device> getDevice(const char *devid);
356 
357 }
358 
359 #endif
rcg::Device::getRemoteNodeMap
std::shared_ptr< GenApi::CNodeMapRef > getRemoteNodeMap(const char *xml=0)
Returns the node map of the remote device.
Definition: device.cc:652
rcg::Device::close
void close()
Closes the device.
Definition: device.cc:142
rcg::Device::open
void open(ACCESS access)
Opens the device for working with it.
Definition: device.cc:87
rcg::Device::getParent
std::shared_ptr< Interface > getParent() const
Returns the pointer to the parent interface object.
Definition: device.cc:77
rcg::Device::~Device
~Device()
Definition: device.cc:62
rcg::Device::rnodemap
std::shared_ptr< GenApi::CNodeMapRef > rnodemap
Definition: device.h:324
rcg::Device::getUserDefinedName
std::string getUserDefinedName()
Returns the user defined name of the device.
Definition: device.cc:566
rcg::Device::getNodeMap
std::shared_ptr< GenApi::CNodeMapRef > getNodeMap(const char *xml=0)
Returns the node map of this object.
Definition: device.cc:639
rcg::Device::getModel
std::string getModel()
Returns the model of the device.
Definition: device.cc:477
rcg::Device::id
std::string id
Definition: device.h:312
rcg::getDevice
std::shared_ptr< Device > getDevice(const char *id, uint64_t timeout)
Searches across all transport layers and interfaces for a device.
Definition: device.cc:726
rcg::Device::cport
std::shared_ptr< CPort > cport
Definition: device.h:323
rcg
Definition: buffer.cc:47
rcg::Device::rport
std::shared_ptr< CPort > rport
Definition: device.h:323
rcg::Device::EXCLUSIVE
@ EXCLUSIVE
Definition: device.h:60
rcg::Device::getID
const std::string & getID() const
Get the internal ID of this device.
Definition: device.cc:82
rcg::Device::getSerialNumber
std::string getSerialNumber()
Returns the serial number of the device.
Definition: device.cc:607
rcg::Device::getVersion
std::string getVersion()
Returns the version of the device.
Definition: device.cc:613
rcg::Device::getModuleEvent
int64_t getModuleEvent(int64_t timeout=-1)
Gets the next module event for the device and attaches it to the local device nodemap.
Definition: device.cc:243
rcg::Device::getAvailableModuleEvents
int getAvailableModuleEvents()
Returns the number of module events that are currently in the queue.
Definition: device.cc:188
rcg::Device::event_value
std::vector< uint8_t > event_value
Definition: device.h:321
rcg::Device
The device class encapsulates a Genicam device.
Definition: device.h:56
rcg::Device::dev
void * dev
Definition: device.h:317
rcg::Device::getHandle
void * getHandle() const
Get internal interface handle.
Definition: device.cc:684
interface.h
rcg::Device::rp
void * rp
Definition: device.h:318
rcg::Device::operator=
Device & operator=(const Device &)
rcg::Device::CONTROL
@ CONTROL
Definition: device.h:60
rcg::Device::eventadapter
std::shared_ptr< GenApi::CEventAdapterGeneric > eventadapter
Definition: device.h:325
EventAdapterGeneric.h
Declaration of the CEventAdapterGEV class.
rcg::Device::event_buffer
std::vector< uint8_t > event_buffer
Definition: device.h:320
rcg::Device::slist
std::vector< std::weak_ptr< Stream > > slist
Definition: device.h:327
rcg::getDevices
std::vector< std::shared_ptr< Device > > getDevices(uint64_t timeout)
Returns a list of all devices that are available across all transport layers and interfaces.
Definition: device.cc:689
rcg::Device::parent
std::shared_ptr< Interface > parent
Definition: device.h:310
rcg::Device::ACCESS
ACCESS
Definition: device.h:60
rcg::Device::enableModuleEvents
void enableModuleEvents()
Enable module events for the local device.
Definition: device.cc:175
rcg::Device::getTLType
std::string getTLType()
Returns the transport layer type of the device.
Definition: device.cc:483
int64_t
__int64 int64_t
Definition: config-win32.h:21
rcg::Device::nodemap
std::shared_ptr< GenApi::CNodeMapRef > nodemap
Definition: device.h:324
rcg::Device::Device
Device(const std::shared_ptr< Interface > &parent, const std::shared_ptr< const GenTLWrapper > &gentl, const char *id)
Constructs a device class.
Definition: device.cc:49
rcg::Device::mtx
std::mutex mtx
Definition: device.h:314
rcg::Device::getTimestampFrequency
uint64_t getTimestampFrequency()
Returns the timestamp frequency of the device.
Definition: device.cc:619
rcg::Device::n_open
int n_open
Definition: device.h:316
rcg::Device::event
void * event
Definition: device.h:319
rcg::Device::getAccessStatus
std::string getAccessStatus()
Returns the access status of the device.
Definition: device.cc:506
rcg::Device::getVendor
std::string getVendor()
Returns the vendor of the device.
Definition: device.cc:471
rcg::Device::getStreams
std::vector< std::shared_ptr< Stream > > getStreams()
Returns the currently available streams of this device.
Definition: device.cc:406
rcg::Device::getRemotePort
std::shared_ptr< CPort > getRemotePort()
Returns the remote port that is used by the remote node map to read and write registers.
Definition: device.cc:668
rcg::Device::abortWaitingForModuleEvents
void abortWaitingForModuleEvents()
Aborts waiting for module events.
Definition: device.cc:378
rcg::Device::getDisplayName
std::string getDisplayName()
Returns the display name of the device.
Definition: device.cc:489
rcg::Device::gentl
std::shared_ptr< const GenTLWrapper > gentl
Definition: device.h:311
rcg::Device::READONLY
@ READONLY
Definition: device.h:60


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Wed Dec 4 2024 03:10:11