00001 /* 00002 * This file is part of the rc_genicam_api package. 00003 * 00004 * Copyright (c) 2017 Roboception GmbH 00005 * All rights reserved 00006 * 00007 * Author: Heiko Hirschmueller 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions are met: 00011 * 00012 * 1. Redistributions of source code must retain the above copyright notice, 00013 * this list of conditions and the following disclaimer. 00014 * 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 00019 * 3. Neither the name of the copyright holder nor the names of its contributors 00020 * may be used to endorse or promote products derived from this software without 00021 * specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00024 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00025 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00026 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00027 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00028 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00029 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00030 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00031 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00032 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00033 * POSSIBILITY OF SUCH DAMAGE. 00034 */ 00035 00036 #ifndef RC_GENICAM_API_DEVICE 00037 #define RC_GENICAM_API_DEVICE 00038 00039 #include "interface.h" 00040 00041 #include <mutex> 00042 00043 namespace rcg 00044 { 00045 00046 class Stream; 00047 00054 class Device : public std::enable_shared_from_this<Device> 00055 { 00056 public: 00057 00058 enum ACCESS {READONLY, CONTROL, EXCLUSIVE}; 00059 00065 Device(const std::shared_ptr<Interface> &parent, 00066 const std::shared_ptr<const GenTLWrapper> &gentl, const char *id); 00067 ~Device(); 00068 00075 std::shared_ptr<Interface> getParent() const; 00076 00083 const std::string &getID() const; 00084 00091 void open(ACCESS access); 00092 00098 void close(); 00099 00109 std::vector<std::shared_ptr<Stream> > getStreams(); 00110 00121 std::string getVendor(); 00122 00133 std::string getModel(); 00134 00145 std::string getTLType(); 00146 00157 std::string getDisplayName(); 00158 00169 std::string getAccessStatus(); 00170 00181 std::string getUserDefinedName(); 00182 00193 std::string getSerialNumber(); 00194 00205 std::string getVersion(); 00206 00217 uint64_t getTimestampFrequency(); 00218 00228 std::shared_ptr<GenApi::CNodeMapRef> getNodeMap(); 00229 00241 std::shared_ptr<GenApi::CNodeMapRef> getRemoteNodeMap(const char *xml=0); 00242 00249 void *getHandle() const; 00250 00251 private: 00252 00253 Device(class Device &); // forbidden 00254 Device &operator=(const Device &); // forbidden 00255 00256 std::shared_ptr<Interface> parent; 00257 std::shared_ptr<const GenTLWrapper> gentl; 00258 std::string id; 00259 00260 std::mutex mtx; 00261 00262 int n_open; 00263 void *dev; 00264 void *rp; 00265 00266 std::shared_ptr<CPort> cport, rport; 00267 std::shared_ptr<GenApi::CNodeMapRef> nodemap, rnodemap; 00268 00269 std::vector<std::weak_ptr<Stream> > slist; 00270 }; 00271 00279 std::vector<std::shared_ptr<Device> > getDevices(); 00280 00291 std::shared_ptr<Device> getDevice(const char *devid); 00292 00293 } 00294 00295 #endif