Skip to content

Commit c9eaf73

Browse files
committed
gc_info: Added choice to either use local or remote nodemap of device
1 parent 3a9a3c6 commit c9eaf73

File tree

2 files changed

+140
-112
lines changed

2 files changed

+140
-112
lines changed

tools/gc_config.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ int main(int argc, char *argv[])
277277
std::cout << std::endl;
278278
}
279279
}
280-
catch (const std::exception &ex)
280+
catch (const std::exception &)
281281
{
282282
std::cout << "Ptp parameters are not available" << std::endl;
283283
std::cout << std::endl;

tools/gc_info.cc

Lines changed: 139 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -162,168 +162,195 @@ int main(int argc, char *argv[])
162162
// get parameters, if any
163163

164164
const char *xml=0;
165-
if (k+1 < argc && std::string(argv[k]) == "-o")
165+
bool local_nodemap=false;
166+
bool edit=false;
167+
168+
while (k+1 < argc && argv[k][0] == '-')
166169
{
167-
k++;
168-
xml=argv[k++];
170+
if (std::string(argv[k]) == "-o")
171+
{
172+
k++;
173+
xml=argv[k++];
169174

170-
if (std::string(xml) == ".")
175+
if (std::string(xml) == ".")
176+
{
177+
xml="";
178+
}
179+
}
180+
else if (std::string(argv[k]) == "-d")
171181
{
172-
xml="";
182+
k++;
183+
local_nodemap=true;
184+
}
185+
else if (std::string(argv[k]) == "-e")
186+
{
187+
k++;
188+
edit=true;
189+
}
190+
else
191+
{
192+
std::cerr << "Unknown parameter: " << argv[k] << std::endl;
193+
ret=1;
173194
}
174195
}
175196

176-
bool edit=false;
177-
if (k < argc && std::string(argv[k]) == "-e")
178-
{
179-
k++;
180-
edit=true;
181-
}
182-
183-
if (k < argc)
197+
if (ret == 0)
184198
{
185-
// separate optional node name from device id
186-
187-
std::string devid=argv[k++];
188-
std::string node="Root";
189-
int depth=1000;
190-
199+
if (k < argc)
191200
{
192-
size_t j=devid.find('?');
201+
// separate optional node name from device id
202+
203+
std::string devid=argv[k++];
204+
std::string node="Root";
205+
int depth=1000;
193206

194-
if (j != std::string::npos)
195207
{
196-
node=devid.substr(j+1);
197-
devid=devid.substr(0, j);
198-
depth=1;
208+
size_t j=devid.find('?');
199209

200-
if (node.size() == 0)
210+
if (j != std::string::npos)
201211
{
202-
node="Root";
212+
node=devid.substr(j+1);
213+
devid=devid.substr(0, j);
214+
depth=1;
215+
216+
if (node.size() == 0)
217+
{
218+
node="Root";
219+
}
203220
}
204221
}
205-
}
206-
207-
// find specific device accross all systems and interfaces
208222

209-
std::shared_ptr<rcg::Device> dev=rcg::getDevice(devid.c_str());
223+
// find specific device accross all systems and interfaces
210224

211-
if (dev)
212-
{
213-
// open device and optionally change some settings
225+
std::shared_ptr<rcg::Device> dev=rcg::getDevice(devid.c_str());
214226

215-
if (k < argc || edit)
216-
{
217-
dev->open(rcg::Device::CONTROL);
218-
}
219-
else
227+
if (dev)
220228
{
221-
dev->open(rcg::Device::READONLY);
222-
}
223-
224-
rcg::printNodemap(dev->getNodeMap(), "Root");
229+
// open device and optionally change some settings
225230

226-
std::cout << std::endl;
227-
std::cout << " ----------" << std::endl;
228-
std::cout << std::endl;
229-
230-
std::shared_ptr<GenApi::CNodeMapRef> nodemap=dev->getRemoteNodeMap(xml);
231+
if (k < argc || edit)
232+
{
233+
dev->open(rcg::Device::CONTROL);
234+
}
235+
else
236+
{
237+
dev->open(rcg::Device::READONLY);
238+
}
231239

232-
if (nodemap)
233-
{
234-
while (k < argc)
240+
std::shared_ptr<GenApi::CNodeMapRef> nodemap;
241+
if (local_nodemap)
242+
{
243+
nodemap=dev->getNodeMap();
244+
}
245+
else
235246
{
236-
std::string p=argv[k++];
247+
nodemap=dev->getRemoteNodeMap(xml);
248+
}
237249

238-
if (p.find('=') != std::string::npos)
250+
if (nodemap)
251+
{
252+
while (k < argc)
239253
{
240-
// split argument in key and value
254+
std::string p=argv[k++];
241255

242-
size_t j=p.find('=');
243-
std::string value=p.substr(j+1);
244-
std::string key=p.substr(0, j);
256+
if (p.find('=') != std::string::npos)
257+
{
258+
// split argument in key and value
245259

246-
// set key=value pair through GenICam
260+
size_t j=p.find('=');
261+
std::string value=p.substr(j+1);
262+
std::string key=p.substr(0, j);
247263

248-
rcg::setString(nodemap, key.c_str(), value.c_str(), true);
249-
}
250-
else
251-
{
252-
// call the command
253-
rcg::callCommand(nodemap, p.c_str(), true);
264+
// set key=value pair through GenICam
265+
266+
rcg::setString(nodemap, key.c_str(), value.c_str(), true);
267+
}
268+
else
269+
{
270+
// call the command
271+
rcg::callCommand(nodemap, p.c_str(), true);
272+
}
254273
}
255-
}
256274

257-
if (edit)
258-
{
259-
if (!rcg::editNodemap(nodemap, node.c_str()))
275+
if (edit)
260276
{
261-
std::cerr << "Unknown node: " << node << std::endl;
262-
ret=1;
277+
if (!rcg::editNodemap(nodemap, node.c_str()))
278+
{
279+
std::cerr << "Unknown node: " << node << std::endl;
280+
ret=1;
281+
}
263282
}
264-
}
265-
else if (depth > 1)
266-
{
267-
// report all features
268-
269-
std::cout << "Device: " << dev->getID() << std::endl;
270-
std::cout << "Vendor: " << dev->getVendor() << std::endl;
271-
std::cout << "Model: " << dev->getModel() << std::endl;
272-
std::cout << "TL type: " << dev->getTLType() << std::endl;
273-
std::cout << "Display name: " << dev->getDisplayName() << std::endl;
274-
std::cout << "User defined name: " << dev->getUserDefinedName() << std::endl;
275-
std::cout << "Serial number: " << dev->getSerialNumber() << std::endl;
276-
std::cout << "Version: " << dev->getVersion() << std::endl;
277-
std::cout << "TS Frequency: " << dev->getTimestampFrequency() << std::endl;
278-
std::cout << std::endl;
279-
280-
std::vector<std::shared_ptr<rcg::Stream> > stream=dev->getStreams();
281-
282-
std::cout << "Available streams:" << std::endl;
283-
for (size_t i=0; i<stream.size(); i++)
283+
else if (depth > 1)
284284
{
285-
std::cout << " Stream ID: " << stream[i]->getID() << std::endl;
285+
// report all features
286+
287+
std::cout << "Device: " << dev->getID() << std::endl;
288+
std::cout << "Vendor: " << dev->getVendor() << std::endl;
289+
std::cout << "Model: " << dev->getModel() << std::endl;
290+
std::cout << "TL type: " << dev->getTLType() << std::endl;
291+
std::cout << "Display name: " << dev->getDisplayName() << std::endl;
292+
std::cout << "User defined name: " << dev->getUserDefinedName() << std::endl;
293+
std::cout << "Serial number: " << dev->getSerialNumber() << std::endl;
294+
std::cout << "Version: " << dev->getVersion() << std::endl;
295+
std::cout << "TS Frequency: " << dev->getTimestampFrequency() << std::endl;
296+
std::cout << std::endl;
297+
298+
std::vector<std::shared_ptr<rcg::Stream> > stream=dev->getStreams();
299+
300+
std::cout << "Available streams:" << std::endl;
301+
for (size_t i=0; i<stream.size(); i++)
302+
{
303+
std::cout << " Stream ID: " << stream[i]->getID() << std::endl;
304+
}
305+
306+
std::cout << std::endl;
307+
308+
if (local_nodemap)
309+
{
310+
std::cout << "Local device nodemap:" << std::endl;
311+
}
312+
else
313+
{
314+
std::cout << "Remote device nodemap:" << std::endl;
315+
}
316+
317+
rcg::printNodemap(nodemap, node.c_str(), depth, true);
286318
}
319+
else
320+
{
321+
// report requested node only
287322

288-
std::cout << std::endl;
289-
290-
std::cout << "Available features:" << std::endl;
291-
rcg::printNodemap(nodemap, node.c_str(), depth, true);
323+
if (!rcg::printNodemap(nodemap, node.c_str(), depth, true))
324+
{
325+
std::cerr << "Unknown node: " << node << std::endl;
326+
ret=1;
327+
}
328+
}
292329
}
293330
else
294331
{
295-
// report requested node only
296-
297-
if (!rcg::printNodemap(nodemap, node.c_str(), depth, true))
298-
{
299-
std::cerr << "Unknown node: " << node << std::endl;
300-
ret=1;
301-
}
332+
std::cerr << "Nodemap not available!" << std::endl;
302333
}
334+
335+
dev->close();
303336
}
304337
else
305338
{
306-
std::cerr << "Nodemap not available!" << std::endl;
339+
std::cerr << "Device '" << devid << "' not found!" << std::endl;
340+
ret=1;
307341
}
308-
309-
dev->close();
310342
}
311343
else
312344
{
313-
std::cerr << "Device '" << devid << "' not found!" << std::endl;
345+
std::cerr << "Device name not given!" << std::endl;
314346
ret=1;
315347
}
316348
}
317-
else
318-
{
319-
std::cerr << "Device name not given!" << std::endl;
320-
ret=1;
321-
}
322349
}
323350
}
324351
else
325352
{
326-
std::cout << argv[0] << " -h | -L | -l | -s | ([-o <xml-output-file>|.] [-e] [<interface-id>:]<device-id>[?<node>] [<key>=<value>] ...)" << std::endl;
353+
std::cout << argv[0] << " -h | -L | -l | -s | ([-o <xml-output-file>|.] [-d] [-e] [<interface-id>:]<device-id>[?<node>] [<key>=<value>] ...)" << std::endl;
327354
std::cout << std::endl;
328355
std::cout << "Provides information about GenICam transport layers, interfaces and devices." << std::endl;
329356
std::cout << std::endl;
@@ -333,6 +360,7 @@ int main(int argc, char *argv[])
333360
std::cout << "-l List all available devices on all interfaces" << std::endl;
334361
std::cout << "-s List all available devices on all interfaces (short format)" << std::endl;
335362
std::cout << "-o Store XML description from specified device" << std::endl;
363+
std::cout << "-d Use local device nodemap, instead of remote nodemap" << std::endl;
336364
std::cout << "-e Open nodemap editor instead of printing nodemap" << std::endl;
337365
std::cout << std::endl;
338366
std::cout << "Parameters:" << std::endl;

0 commit comments

Comments
 (0)