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/config.h>
00040
00041 #include <iostream>
00042
00043 int main(int argc, char *argv[])
00044 {
00045 try
00046 {
00047 if (argc > 1)
00048 {
00049
00050
00051 if (std::string(argv[1]) == "-l")
00052 {
00053 std::cout << "Available GigE Vision devices:" << std::endl;
00054
00055 std::vector<std::shared_ptr<rcg::System> > system=rcg::System::getSystems();
00056
00057 for (size_t i=0; i<system.size(); i++)
00058 {
00059 system[i]->open();
00060
00061 std::vector<std::shared_ptr<rcg::Interface> > interf=system[i]->getInterfaces();
00062
00063 for (size_t k=0; k<interf.size(); k++)
00064 {
00065 interf[k]->open();
00066
00067 std::vector<std::shared_ptr<rcg::Device> > device=interf[k]->getDevices();
00068
00069 for (size_t j=0; j<device.size(); j++)
00070 {
00071 if (device[j]->getTLType() == "GEV")
00072 {
00073 std::cout << " " << interf[k]->getID() << ":" << device[j]->getID() << " (";
00074
00075 std::string uname=device[j]->getDisplayName();
00076
00077 if (uname.size() > 0)
00078 {
00079 std::cout << uname << ", ";
00080 }
00081
00082 std::cout << device[j]->getSerialNumber() << ")" << std::endl;
00083 }
00084 }
00085
00086 interf[k]->close();
00087 }
00088
00089 system[i]->close();
00090 }
00091 }
00092 else
00093 {
00094
00095
00096 int i=1;
00097 std::shared_ptr<rcg::Device> dev=rcg::getDevice(argv[i++]);
00098
00099 if (dev != 0)
00100 {
00101 if (i < argc)
00102 {
00103 dev->open(rcg::Device::CONTROL);
00104 }
00105 else
00106 {
00107 dev->open(rcg::Device::READONLY);
00108 }
00109
00110
00111
00112 std::shared_ptr<GenApi::CNodeMapRef> nodemap=dev->getRemoteNodeMap();
00113
00114 while (i < argc)
00115 {
00116 std::string p=argv[i++];
00117
00118 if (p[0] == '-' && i < argc)
00119 {
00120 if (p == "-n")
00121 {
00122 rcg::setString(nodemap, "DeviceUserID", argv[i++], true);
00123 }
00124 else if (p == "-d")
00125 {
00126 rcg::setString(nodemap, "GevCurrentIPConfigurationDHCP", argv[i++], true);
00127 }
00128 else if (p == "-p")
00129 {
00130 rcg::setString(nodemap, "GevCurrentIPConfigurationPersistentIP", argv[i++], true);
00131 }
00132 else if (p == "-t")
00133 {
00134 rcg::setString(nodemap, "GevIEEE1588", argv[i++], true);
00135 }
00136 else if (p == "-i")
00137 {
00138 rcg::setIPV4Address(nodemap, "GevPersistentIPAddress", argv[i++], true);
00139 }
00140 else if (p == "-s")
00141 {
00142 rcg::setIPV4Address(nodemap, "GevPersistentSubnetMask", argv[i++], true);
00143 }
00144 else if (p == "-g")
00145 {
00146 rcg::setIPV4Address(nodemap, "GevPersistentDefaultGateway", argv[i++], true);
00147 }
00148 else
00149 {
00150 std::cerr << "Unknown parameter: " << p << std::endl;
00151 exit(1);
00152 }
00153 }
00154 else if (p.find('=') != std::string::npos)
00155 {
00156
00157
00158 size_t k=p.find('=');
00159 std::string value=p.substr(k+1);
00160 std::string key=p.substr(0, k);
00161
00162
00163
00164 rcg::setString(nodemap, key.c_str(), value.c_str(), true);
00165 }
00166 else
00167 {
00168 std::cerr << "Missing '=': " << p << std::endl;
00169 exit(1);
00170 }
00171 }
00172
00173
00174
00175 std::cout << "ID: " << dev->getParent()->getID() << ":"
00176 << dev->getID() << std::endl;
00177 std::cout << "Serial number: " << rcg::getString(nodemap, "DeviceID") << std::endl;
00178 std::cout << "User defined ID: " << rcg::getString(nodemap, "DeviceUserID") << std::endl;
00179 std::cout << "MAC Address: " << rcg::getString(nodemap, "GevMACAddress") << std::endl;
00180 std::cout << std::endl;
00181
00182 std::cout << "Current IP: " << rcg::getString(nodemap, "GevCurrentIPAddress") << std::endl;
00183 std::cout << "Current subnet mask: " << rcg::getString(nodemap, "GevCurrentSubnetMask") << std::endl;
00184 std::cout << "Current gateway: " << rcg::getString(nodemap, "GevCurrentDefaultGateway") << std::endl;
00185 std::cout << std::endl;
00186
00187 std::cout << "Persistent IP on/off: " << rcg::getString(nodemap, "GevCurrentIPConfigurationPersistentIP") << std::endl;
00188 std::cout << " Persistent IP: " << rcg::getString(nodemap, "GevPersistentIPAddress") << std::endl;
00189 std::cout << " Persistent subnet mask: " << rcg::getString(nodemap, "GevPersistentSubnetMask") << std::endl;
00190 std::cout << " Persistent gateway: " << rcg::getString(nodemap, "GevPersistentDefaultGateway") << std::endl;
00191 std::cout << "DHCP on/off: " << rcg::getString(nodemap, "GevCurrentIPConfigurationDHCP") << std::endl;
00192 std::cout << "Link local on/off: " << rcg::getString(nodemap, "GevCurrentIPConfigurationLLA") << std::endl;
00193 std::cout << std::endl;
00194
00195 std::cout << "PTP: " << rcg::getString(nodemap, "GevIEEE1588") << std::endl;
00196 std::cout << "PTP status: " << rcg::getString(nodemap, "GevIEEE1588Status") << std::endl;
00197
00198 dev->close();
00199 }
00200 else
00201 {
00202 std::cerr << "Cannot find device: " << argv[1] << std::endl;
00203 }
00204 }
00205 }
00206 else
00207 {
00208 std::cout << argv[0] << " -l|([interface-id>:]<device-id> <options>)" << std::endl;
00209 std::cout << std::endl;
00210 std::cout << "Configuration of a device via GenICam" << std::endl;
00211 std::cout << std::endl;
00212 std::cout << "-n <id>: Set user defined id" << std::endl;
00213 std::cout << "-d 1|0: Switch DHCP on or off" << std::endl;
00214 std::cout << "-p 1|0: Switch persistent IP on or off" << std::endl;
00215 std::cout << "-t 1|0: Switch precision time protocol (ptp) on or off" << std::endl;
00216 std::cout << "-i <ip>: Set persistent IP address" << std::endl;
00217 std::cout << "-s <ip>: Set subnet mask for persistent IP address" << std::endl;
00218 std::cout << "-g <ip>: Set default gateway for persistent IP address" << std::endl;
00219 std::cout << std::endl;
00220 std::cout << "<key>=<value>: Set GenICam key to given value." << std::endl;
00221 }
00222 }
00223 catch (const std::exception &ex)
00224 {
00225 std::cerr << ex.what() << std::endl;
00226 }
00227
00228 rcg::System::clearSystems();
00229
00230 return 0;
00231 }