Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <rc_genicam_api/system.h>
00037 #include <rc_genicam_api/interface.h>
00038 #include <rc_genicam_api/device.h>
00039 #include <rc_genicam_api/stream.h>
00040
00041 #include <iostream>
00042
00043 namespace
00044 {
00045
00053 const char *getAccessMode(const GenApi::INode *node)
00054 {
00055 switch (node->GetAccessMode())
00056 {
00057 case GenApi::NI:
00058 return "(NI)";
00059
00060 case GenApi::NA:
00061 return "(NA)";
00062
00063 case GenApi::WO:
00064 return "(WO)";
00065
00066 case GenApi::RO:
00067 return "(RO)";
00068
00069 case GenApi::RW:
00070 return "(RW)";
00071
00072 case GenApi::_UndefinedAccesMode:
00073 return "(undefined access mode)";
00074
00075 case GenApi::_CycleDetectAccesMode:
00076 return "(cycle detection)";
00077
00078 default:
00079 return "(unknown)";
00080 }
00081 }
00082
00092 std::string formatValue(GenApi::IInteger *node, int64_t value)
00093 {
00094 std::ostringstream out;
00095
00096 switch (node->GetRepresentation())
00097 {
00098 case GenApi::HexNumber:
00099 out << "0x" << std::hex << value;
00100 break;
00101
00102 case GenApi::IPV4Address:
00103 out << ((value>>24)&0xff) << '.' << ((value>>16)&0xff) << '.'
00104 << ((value>>8)&0xff) << '.' << (value&0xff);
00105 break;
00106
00107 case GenApi::MACAddress:
00108 out << std::hex << ((value>>32)&0xff) << ':' << ((value>>30)&0xff) << ':'
00109 << ((value>>24)&0xff) << ':' << ((value>>16)&0xff) << ':'
00110 << ((value>>8)&0xff) << ':' << (value&0xff);
00111 break;
00112
00113 default:
00114 out << value;
00115 break;
00116 }
00117
00118 return out.str();
00119 }
00120
00128 void printNode(const std::string &prefix, GenApi::INode *node)
00129 {
00130 if (node != 0)
00131 {
00132 switch (node->GetPrincipalInterfaceType())
00133 {
00134 case GenApi::intfIValue:
00135 std::cout << prefix << "Value: " << node->GetName() << " " << getAccessMode(node)
00136 << std::endl;
00137 break;
00138
00139 case GenApi::intfIBase:
00140 std::cout << prefix << "Base: " << node->GetName() << " " << getAccessMode(node)
00141 << std::endl;
00142 break;
00143
00144 case GenApi::intfIInteger:
00145 {
00146 std::cout << prefix << "Integer: " << node->GetName() << " "
00147 << getAccessMode(node) << " ";
00148
00149 GenApi::IInteger *p=dynamic_cast<GenApi::IInteger *>(node);
00150
00151 if (GenApi::IsReadable(p))
00152 {
00153 std::cout << "[" << formatValue(p, p->GetMin()) << ", "
00154 << formatValue(p, p->GetMax()) << "]: ";
00155 std::cout << formatValue(p, p->GetValue()) << " " << p->GetUnit();
00156 }
00157
00158 std::cout << std::endl;
00159 }
00160 break;
00161
00162 case GenApi::intfIBoolean:
00163 {
00164 std::cout << prefix << "Boolean: " << node->GetName() << " " << getAccessMode(node)
00165 << ": ";
00166
00167 GenApi::IBoolean *p=dynamic_cast<GenApi::IBoolean *>(node);
00168
00169 if (GenApi::IsReadable(p))
00170 {
00171 std::cout << p->GetValue();
00172 }
00173
00174 std::cout << std::endl;
00175 }
00176 break;
00177
00178 case GenApi::intfICommand:
00179 std::cout << prefix << "Command: " << node->GetName() << " " << getAccessMode(node)
00180 << std::endl;
00181 break;
00182
00183 case GenApi::intfIFloat:
00184 {
00185 std::cout << prefix << "Float: " << node->GetName() << " " << getAccessMode(node)
00186 << " ";
00187
00188 GenApi::IFloat *p=dynamic_cast<GenApi::IFloat *>(node);
00189
00190 if (GenApi::IsReadable(p))
00191 {
00192 std::cout << "[" << p->GetMin() << ", "
00193 << p->GetMax() << "]: "
00194 << p->GetValue() << " " << p->GetUnit();
00195 }
00196
00197 std::cout << std::endl;
00198 }
00199 break;
00200
00201 case GenApi::intfIString:
00202 {
00203 std::cout << prefix << "String: " << node->GetName() << " " << getAccessMode(node)
00204 << ": ";
00205
00206 GenApi::IString *p=dynamic_cast<GenApi::IString *>(node);
00207
00208 if (GenApi::IsReadable(p))
00209 {
00210 std::cout << p->GetValue();
00211 }
00212
00213 std::cout << std::endl;
00214 }
00215 break;
00216
00217 case GenApi::intfIRegister:
00218 std::cout << prefix << "Register: " << node->GetName() << " " << getAccessMode(node)
00219 << std::endl;
00220 break;
00221
00222 case GenApi::intfICategory:
00223 {
00224 std::cout << prefix << "Category: " << node->GetName() << " "
00225 << getAccessMode(node) << std::endl;
00226
00227 GenApi::ICategory *root=dynamic_cast<GenApi::ICategory *>(node);
00228
00229 if (root != 0)
00230 {
00231 GenApi::FeatureList_t feature;
00232 root->GetFeatures(feature);
00233
00234 for (size_t i=0; i<feature.size(); i++)
00235 {
00236 printNode(prefix+" ", feature[i]->GetNode());
00237 }
00238 }
00239 }
00240 break;
00241
00242 case GenApi::intfIEnumeration:
00243 {
00244 std::cout << prefix << "Enumeration: " << node->GetName() << " " << getAccessMode(node)
00245 << ' ';
00246
00247 GenApi::IEnumeration *p=dynamic_cast<GenApi::IEnumeration *>(node);
00248
00249 if (GenApi::IsReadable(p))
00250 {
00251 std::cout << '[';
00252
00253 GenApi::StringList_t list;
00254 p->GetSymbolics(list);
00255
00256 for (size_t i=0; i<list.size(); i++)
00257 {
00258 if (i > 0)
00259 {
00260 std::cout << ' ';
00261 }
00262
00263 std::cout << list[i];
00264 }
00265
00266 std::cout << "]: " << p->GetCurrentEntry()->GetSymbolic();
00267 }
00268
00269 std::cout << std::endl;
00270 }
00271 break;
00272
00273 case GenApi::intfIEnumEntry:
00274 std::cout << prefix << "EnumEntry: " << node->GetName() << " " << getAccessMode(node)
00275 << std::endl;
00276 break;
00277
00278 case GenApi::intfIPort:
00279 std::cout << prefix << "Port: " << node->GetName() << " " << getAccessMode(node)
00280 << std::endl;
00281 break;
00282
00283 }
00284 }
00285 }
00286
00287 }
00288
00289 int main(int argc, char *argv[])
00290 {
00291 try
00292 {
00293 if (argc == 2 || argc == 3)
00294 {
00295 if (std::string(argv[1]) == "-l")
00296 {
00297
00298
00299 std::vector<std::shared_ptr<rcg::System> > system=rcg::System::getSystems();
00300
00301 for (size_t i=0; i<system.size(); i++)
00302 {
00303 system[i]->open();
00304
00305 std::cout << "Transport Layer " << system[i]->getID() << std::endl;
00306 std::cout << "Vendor: " << system[i]->getVendor() << std::endl;
00307 std::cout << "Model: " << system[i]->getModel() << std::endl;
00308 std::cout << "Vendor version: " << system[i]->getVersion() << std::endl;
00309 std::cout << "TL type: " << system[i]->getTLType() << std::endl;
00310 std::cout << "Pathname: " << system[i]->getPathname() << std::endl;
00311 std::cout << "GenTL version " << system[i]->getMajorVersion() << "."
00312 << system[i]->getMinorVersion() << std::endl;
00313 std::cout << std::endl;
00314
00315 std::vector<std::shared_ptr<rcg::Interface> > interf=system[i]->getInterfaces();
00316
00317 for (size_t k=0; k<interf.size(); k++)
00318 {
00319 interf[k]->open();
00320
00321 std::cout << " Interface " << interf[k]->getID() << std::endl;
00322 std::cout << " Display name: " << interf[k]->getDisplayName() << std::endl;
00323 std::cout << " TL type: " << interf[k]->getTLType() << std::endl;
00324 std::cout << std::endl;
00325
00326 std::vector<std::shared_ptr<rcg::Device> > device=interf[k]->getDevices();
00327
00328 for (size_t j=0; j<device.size(); j++)
00329 {
00330 std::cout << " Device " << device[j]->getID() << std::endl;
00331 std::cout << " Vendor: " << device[j]->getVendor() << std::endl;
00332 std::cout << " Model: " << device[j]->getModel() << std::endl;
00333 std::cout << " TL type: " << device[j]->getTLType() << std::endl;
00334 std::cout << " Display name: " << device[j]->getDisplayName() << std::endl;
00335 std::cout << " Access status: " << device[j]->getAccessStatus() << std::endl;
00336 std::cout << " Serial number: " << device[j]->getSerialNumber() << std::endl;
00337 std::cout << " Version: " << device[j]->getVersion() << std::endl;
00338 std::cout << " TS Frequency: " << device[j]->getTimestampFrequency() << std::endl;
00339 std::cout << std::endl;
00340 }
00341
00342 interf[k]->close();
00343 }
00344
00345 system[i]->close();
00346 }
00347 }
00348 else
00349 {
00350
00351
00352
00353 std::shared_ptr<rcg::Device> dev=rcg::getDevice(argv[1]);
00354
00355 const char *xml=0;
00356 if (argc == 3)
00357 {
00358 xml=argv[2];
00359 }
00360
00361 if (dev)
00362 {
00363 dev->open(rcg::Device::READONLY);
00364
00365 std::cout << "Device: " << dev->getID() << std::endl;
00366 std::cout << "Vendor: " << dev->getVendor() << std::endl;
00367 std::cout << "Model: " << dev->getModel() << std::endl;
00368 std::cout << "TL type: " << dev->getTLType() << std::endl;
00369 std::cout << "Display name: " << dev->getDisplayName() << std::endl;
00370 std::cout << "User name: " << dev->getUserDefinedName() << std::endl;
00371 std::cout << "Serial number: " << dev->getSerialNumber() << std::endl;
00372 std::cout << "Version: " << dev->getVersion() << std::endl;
00373 std::cout << "TS Frequency: " << dev->getTimestampFrequency() << std::endl;
00374 std::cout << std::endl;
00375
00376 std::vector<std::shared_ptr<rcg::Stream> > stream=dev->getStreams();
00377
00378 std::cout << "Available streams:" << std::endl;
00379 for (size_t i=0; i<stream.size(); i++)
00380 {
00381 std::cout << " Stream ID: " << stream[i]->getID() << std::endl;
00382 }
00383
00384 std::cout << std::endl;
00385 std::cout << "Available features:" << std::endl;
00386 std::shared_ptr<GenApi::CNodeMapRef> nodemap=dev->getRemoteNodeMap(xml);
00387 printNode(std::string(" "), nodemap->_GetNode("Root"));
00388
00389 dev->close();
00390 }
00391 else
00392 {
00393 std::cerr << "Device '" << argv[1] << "' not found!" << std::endl;
00394 }
00395 }
00396 }
00397 else
00398 {
00399 std::cout << argv[0] << " -l | ([interface-id>:]<device-id> [<name_for_xml_file>])" << std::endl;
00400 std::cout << std::endl;
00401 std::cout << "Lists all reachable devices or all GenICam parameters of the specified device" << std::endl;
00402 }
00403 }
00404 catch (const std::exception &ex)
00405 {
00406 std::cerr << ex.what() << std::endl;
00407 }
00408
00409 rcg::System::clearSystems();
00410
00411 return 0;
00412 }