config.cc
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 #include "config.h"
37 #include "buffer.h"
38 
39 #include <stdexcept>
40 #include <iomanip>
41 
42 #include "Base/GCException.h"
43 
44 #include <GenApi/ChunkAdapterGEV.h>
45 #include <GenApi/ChunkAdapterU3V.h>
47 
49 
50 namespace rcg
51 {
52 
53 bool callCommand(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
54  bool exception)
55 {
56  bool ret=false;
57 
58  try
59  {
60  GenApi::INode *node=nodemap->_GetNode(name);
61 
62  if (node != 0)
63  {
64  if (GenApi::IsWritable(node))
65  {
66  GenApi::ICommand *val=dynamic_cast<GenApi::ICommand *>(node);
67 
68  if (val != 0)
69  {
70  val->Execute();
71  ret=true;
72  }
73  else if (exception)
74  {
75  throw std::invalid_argument(std::string("Feature not a command: ")+name);
76  }
77  }
78  else if (exception)
79  {
80  throw std::invalid_argument(std::string("Feature not writable: ")+name);
81  }
82  }
83  else if (exception)
84  {
85  throw std::invalid_argument(std::string("Feature not found: ")+name);
86  }
87  }
88  catch (const GENICAM_NAMESPACE::GenericException &ex)
89  {
90  if (exception)
91  {
92  throw std::invalid_argument(ex.what());
93  }
94  }
95 
96  return ret;
97 }
98 
99 bool setBoolean(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
100  bool value, bool exception)
101 {
102  bool ret=false;
103 
104  try
105  {
106  GenApi::INode *node=nodemap->_GetNode(name);
107 
108  if (node != 0)
109  {
110  if (GenApi::IsWritable(node))
111  {
112  GenApi::IBoolean *val=dynamic_cast<GenApi::IBoolean *>(node);
113 
114  if (val != 0)
115  {
116  val->SetValue(value);
117  ret=true;
118  }
119  else if (exception)
120  {
121  throw std::invalid_argument(std::string("Feature not boolean: ")+name);
122  }
123  }
124  else if (exception)
125  {
126  throw std::invalid_argument(std::string("Feature not writable: ")+name);
127  }
128  }
129  else if (exception)
130  {
131  throw std::invalid_argument(std::string("Feature not found: ")+name);
132  }
133  }
134  catch (const GENICAM_NAMESPACE::GenericException &ex)
135  {
136  if (exception)
137  {
138  throw std::invalid_argument(ex.what());
139  }
140  }
141 
142  return ret;
143 }
144 
145 bool setInteger(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
146  int64_t value, bool exception)
147 {
148  bool ret=false;
149 
150  try
151  {
152  GenApi::INode *node=nodemap->_GetNode(name);
153 
154  if (node != 0)
155  {
156  if (GenApi::IsWritable(node))
157  {
158  GenApi::IInteger *val=dynamic_cast<GenApi::IInteger *>(node);
159 
160  if (val != 0)
161  {
162  val->SetValue(value);
163  ret=true;
164  }
165  else if (exception)
166  {
167  throw std::invalid_argument(std::string("Feature not integer: ")+name);
168  }
169  }
170  else if (exception)
171  {
172  throw std::invalid_argument(std::string("Feature not writable: ")+name);
173  }
174  }
175  else if (exception)
176  {
177  throw std::invalid_argument(std::string("Feature not found: ")+name);
178  }
179  }
180  catch (const GENICAM_NAMESPACE::GenericException &ex)
181  {
182  if (exception)
183  {
184  throw std::invalid_argument(ex.what());
185  }
186  }
187 
188  return ret;
189 }
190 
191 bool setIPV4Address(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
192  const char *value, bool exception)
193 {
194  bool ret=false;
195 
196  try
197  {
198  GenApi::INode *node=nodemap->_GetNode(name);
199 
200  if (node != 0)
201  {
202  if (GenApi::IsWritable(node))
203  {
204  GenApi::IInteger *val=dynamic_cast<GenApi::IInteger *>(node);
205 
206  if (val != 0)
207  {
208  int64_t ip=0;
209 
210  std::stringstream in(value);
211  std::string elem;
212 
213  for (int i=0; i<4; i++)
214  {
215  getline(in, elem, '.');
216  ip=(ip<<8)|(stoi(elem)&0xff);
217  }
218 
219  val->SetValue(ip);
220  ret=true;
221  }
222  else if (exception)
223  {
224  throw std::invalid_argument(std::string("Feature not integer: ")+name);
225  }
226  }
227  else if (exception)
228  {
229  throw std::invalid_argument(std::string("Feature not writable: ")+name);
230  }
231  }
232  else if (exception)
233  {
234  throw std::invalid_argument(std::string("Feature not found: ")+name);
235  }
236  }
237  catch (const GENICAM_NAMESPACE::GenericException &ex)
238  {
239  if (exception)
240  {
241  throw std::invalid_argument(ex.what());
242  }
243  }
244 
245  return ret;
246 }
247 
248 bool setFloat(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
249  double value, bool exception)
250 {
251  bool ret=false;
252 
253  try
254  {
255  GenApi::INode *node=nodemap->_GetNode(name);
256 
257  if (node != 0)
258  {
259  if (GenApi::IsWritable(node))
260  {
261  GenApi::IFloat *val=dynamic_cast<GenApi::IFloat *>(node);
262 
263  if (val != 0)
264  {
265  val->SetValue(value);
266  ret=true;
267  }
268  else if (exception)
269  {
270  throw std::invalid_argument(std::string("Feature not float: ")+name);
271  }
272  }
273  else if (exception)
274  {
275  throw std::invalid_argument(std::string("Feature not writable: ")+name);
276  }
277  }
278  else if (exception)
279  {
280  throw std::invalid_argument(std::string("Feature not found: ")+name);
281  }
282  }
283  catch (const GENICAM_NAMESPACE::GenericException &ex)
284  {
285  if (exception)
286  {
287  throw std::invalid_argument(ex.what());
288  }
289  }
290 
291  return ret;
292 }
293 
294 bool setEnum(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
295  const char *value, bool exception)
296 {
297  bool ret=false;
298 
299  try
300  {
301  GenApi::INode *node=nodemap->_GetNode(name);
302 
303  if (node != 0)
304  {
305  if (GenApi::IsWritable(node))
306  {
307  GenApi::IEnumeration *val=dynamic_cast<GenApi::IEnumeration *>(node);
308 
309  if (val != 0)
310  {
311  GenApi::IEnumEntry *entry=val->GetEntryByName(value);
312 
313  if (entry != 0)
314  {
315  val->SetIntValue(entry->GetValue());
316 
317  return true;
318  }
319  else if (exception)
320  {
321  throw std::invalid_argument(std::string("Enumeration '")+name+
322  "' does not contain: "+value);
323  }
324  }
325  else if (exception)
326  {
327  throw std::invalid_argument(std::string("Feature not enumeration: ")+name);
328  }
329  }
330  else if (exception)
331  {
332  throw std::invalid_argument(std::string("Feature not writable: ")+name);
333  }
334  }
335  else if (exception)
336  {
337  throw std::invalid_argument(std::string("Feature not found: ")+name);
338  }
339  }
340  catch (const GENICAM_NAMESPACE::GenericException &ex)
341  {
342  if (exception)
343  {
344  throw std::invalid_argument(ex.what());
345  }
346  }
347 
348  return ret;
349 }
350 
351 bool setString(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
352  const char *value, bool exception)
353 {
354  bool ret=false;
355 
356  try
357  {
358  GenApi::INode *node=nodemap->_GetNode(name);
359 
360  if (node != 0)
361  {
362  if (GenApi::IsWritable(node))
363  {
364  switch (node->GetPrincipalInterfaceType())
365  {
367  {
368  GenApi::IBoolean *p=dynamic_cast<GenApi::IBoolean *>(node);
369 
370  std::string v=std::string(value);
371  if (v == "true" || v == "True" || v == "TRUE")
372  {
373  p->SetValue(1);
374  }
375  else if (v == "false" || v == "False" || v == "FALSE")
376  {
377  p->SetValue(0);
378  }
379  else
380  {
381  p->SetValue(std::stoi(v));
382  }
383  }
384  break;
385 
387  {
388  GenApi::IInteger *p=dynamic_cast<GenApi::IInteger *>(node);
389 
390  switch (p->GetRepresentation())
391  {
392  case GenApi::HexNumber:
393  p->SetValue(std::stoll(std::string(value), 0, 16));
394  break;
395 
396  case GenApi::IPV4Address:
397  {
398  int64_t ip=0;
399 
400  std::stringstream in(value);
401  std::string elem;
402 
403  for (int i=0; i<4; i++)
404  {
405  getline(in, elem, '.');
406  ip=(ip<<8)|(stoi(elem)&0xff);
407  }
408 
409  p->SetValue(ip);
410  }
411  break;
412 
413  case GenApi::MACAddress:
414  {
415  int64_t mac=0;
416 
417  std::stringstream in(value);
418  std::string elem;
419 
420  for (int i=0; i<4; i++)
421  {
422  getline(in, elem, ':');
423  mac=(mac<<8)|(stoi(elem, 0, 16)&0xff);
424  }
425 
426  p->SetValue(mac);
427  }
428  break;
429 
430  default:
431  p->SetValue(std::stoll(std::string(value)));
432  break;
433  }
434  }
435  break;
436 
437  case GenApi::intfIFloat:
438  {
439  GenApi::IFloat *p=dynamic_cast<GenApi::IFloat *>(node);
440  p->SetValue(std::stof(std::string(value)));
441  }
442  break;
443 
445  {
446  GenApi::IEnumeration *p=dynamic_cast<GenApi::IEnumeration *>(node);
447  GenApi::IEnumEntry *entry=p->GetEntryByName(value);
448 
449  if (entry != 0)
450  {
451  p->SetIntValue(entry->GetValue());
452  }
453  else if (exception)
454  {
455  throw std::invalid_argument(std::string("Enumeration '")+name+
456  "' does not contain: "+value);
457  }
458  }
459  break;
460 
461  case GenApi::intfIString:
462  {
463  GenApi::IString *p=dynamic_cast<GenApi::IString *>(node);
464  p->SetValue(value);
465  }
466  break;
467 
468  default:
469  if (exception)
470  {
471  throw std::invalid_argument(std::string("Feature of unknown datatype: ")+name);
472  }
473  break;
474  }
475  }
476  else if (exception)
477  {
478  throw std::invalid_argument(std::string("Feature not writable: ")+name);
479  }
480  }
481  else if (exception)
482  {
483  throw std::invalid_argument(std::string("Feature not found: ")+name);
484  }
485  }
486  catch (const GENICAM_NAMESPACE::GenericException &ex)
487  {
488  if (exception)
489  {
490  throw std::invalid_argument(ex.what());
491  }
492  }
493 
494  return ret;
495 }
496 
497 bool getBoolean(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
498  bool exception, bool igncache)
499 {
500  bool ret=false;
501 
502  try
503  {
504  GenApi::INode *node=nodemap->_GetNode(name);
505 
506  if (node != 0)
507  {
508  if (GenApi::IsReadable(node))
509  {
510  GenApi::IBoolean *val=dynamic_cast<GenApi::IBoolean *>(node);
511 
512  if (val != 0)
513  {
514  ret=val->GetValue(false, igncache);
515  }
516  else if (exception)
517  {
518  throw std::invalid_argument(std::string("Feature not boolean: ")+name);
519  }
520  }
521  else if (exception)
522  {
523  throw std::invalid_argument(std::string("Feature not readable: ")+name);
524  }
525  }
526  else if (exception)
527  {
528  throw std::invalid_argument(std::string("Feature not found: ")+name);
529  }
530  }
531  catch (const GENICAM_NAMESPACE::GenericException &ex)
532  {
533  if (exception)
534  {
535  throw std::invalid_argument(ex.what());
536  }
537  }
538 
539  return ret;
540 }
541 
542 int64_t getInteger(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
543  int64_t *vmin, int64_t *vmax, bool exception, bool igncache)
544 {
545  int64_t ret=0;
546 
547  if (vmin != 0) *vmin=0;
548  if (vmax != 0) *vmax=0;
549 
550  try
551  {
552  GenApi::INode *node=nodemap->_GetNode(name);
553 
554  if (node != 0)
555  {
556  if (GenApi::IsReadable(node))
557  {
558  GenApi::IInteger *val=dynamic_cast<GenApi::IInteger *>(node);
559 
560  if (val != 0)
561  {
562  ret=val->GetValue(false, igncache);
563 
564  if (vmin != 0) *vmin=val->GetMin();
565  if (vmax != 0) *vmax=val->GetMax();
566  }
567  else if (exception)
568  {
569  throw std::invalid_argument(std::string("Feature not integer: ")+name);
570  }
571  }
572  else if (exception)
573  {
574  throw std::invalid_argument(std::string("Feature not readable: ")+name);
575  }
576  }
577  else if (exception)
578  {
579  throw std::invalid_argument(std::string("Feature not found: ")+name);
580  }
581  }
582  catch (const GENICAM_NAMESPACE::GenericException &ex)
583  {
584  if (exception)
585  {
586  throw std::invalid_argument(ex.what());
587  }
588  }
589 
590  return ret;
591 }
592 
593 double getFloat(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
594  double *vmin, double *vmax, bool exception, bool igncache)
595 {
596  double ret=0;
597 
598  if (vmin != 0) *vmin=0;
599  if (vmax != 0) *vmax=0;
600 
601  try
602  {
603  GenApi::INode *node=nodemap->_GetNode(name);
604 
605  if (node != 0)
606  {
607  if (GenApi::IsReadable(node))
608  {
609  GenApi::IFloat *val=dynamic_cast<GenApi::IFloat *>(node);
610 
611  if (val != 0)
612  {
613  ret=val->GetValue(false, igncache);
614 
615  if (vmin != 0) *vmin=val->GetMin();
616  if (vmax != 0) *vmax=val->GetMax();
617  }
618  else if (exception)
619  {
620  throw std::invalid_argument(std::string("Feature not float: ")+name);
621  }
622  }
623  else if (exception)
624  {
625  throw std::invalid_argument(std::string("Feature not readable: ")+name);
626  }
627  }
628  else if (exception)
629  {
630  throw std::invalid_argument(std::string("Feature not found: ")+name);
631  }
632  }
633  catch (const GENICAM_NAMESPACE::GenericException &ex)
634  {
635  if (exception)
636  {
637  throw std::invalid_argument(ex.what());
638  }
639  }
640 
641  return ret;
642 }
643 
644 std::string getEnum(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
645  bool exception)
646 {
647  std::string ret;
648 
649  try
650  {
651  GenApi::INode *node=nodemap->_GetNode(name);
652 
653  if (node != 0)
654  {
655  if (GenApi::IsReadable(node))
656  {
657  GenApi::IEnumeration *val=dynamic_cast<GenApi::IEnumeration *>(node);
658 
659  if (val != 0)
660  {
661  GenApi::IEnumEntry *entry=val->GetCurrentEntry();
662 
663  if (entry != 0)
664  {
665  ret=entry->GetSymbolic();
666  }
667  else if (exception)
668  {
669  throw std::invalid_argument(std::string("Current value is not defined: ")+name);
670  }
671  }
672  else if (exception)
673  {
674  throw std::invalid_argument(std::string("Feature not enumeration: ")+name);
675  }
676  }
677  else if (exception)
678  {
679  throw std::invalid_argument(std::string("Feature not readable: ")+name);
680  }
681  }
682  else if (exception)
683  {
684  throw std::invalid_argument(std::string("Feature not found: ")+name);
685  }
686  }
687  catch (const GENICAM_NAMESPACE::GenericException &ex)
688  {
689  if (exception)
690  {
691  throw std::invalid_argument(ex.what());
692  }
693  }
694 
695  return ret;
696 }
697 
698 std::string getEnum(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
699  std::vector<std::string> &list, bool exception)
700 {
701  std::string ret;
702 
703  list.clear();
704 
705  try
706  {
707  GenApi::INode *node=nodemap->_GetNode(name);
708 
709  if (node != 0)
710  {
711  if (GenApi::IsReadable(node))
712  {
713  GenApi::IEnumeration *val=dynamic_cast<GenApi::IEnumeration *>(node);
714 
715  if (val != 0)
716  {
717  ret=val->GetCurrentEntry()->GetSymbolic();
718 
719  GenApi::StringList_t entry;
720  val->GetSymbolics(entry);
721 
722  for (size_t i=0; i<entry.size(); i++)
723  {
724  list.push_back(std::string(entry[i]));
725  }
726  }
727  else if (exception)
728  {
729  throw std::invalid_argument(std::string("Feature not enumeration: ")+name);
730  }
731  }
732  else if (exception)
733  {
734  throw std::invalid_argument(std::string("Feature not readable: ")+name);
735  }
736  }
737  else if (exception)
738  {
739  throw std::invalid_argument(std::string("Feature not found: ")+name);
740  }
741  }
742  catch (const GENICAM_NAMESPACE::GenericException &ex)
743  {
744  if (exception)
745  {
746  throw std::invalid_argument(ex.what());
747  }
748  }
749 
750  return ret;
751 }
752 
753 std::string getString(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
754  bool exception, bool igncache)
755 {
756  std::ostringstream out;
757 
758  try
759  {
760  GenApi::INode *node=nodemap->_GetNode(name);
761 
762  if (node != 0)
763  {
764  if (GenApi::IsReadable(node))
765  {
766  switch (node->GetPrincipalInterfaceType())
767  {
769  {
770  GenApi::IBoolean *p=dynamic_cast<GenApi::IBoolean *>(node);
771  out << p->GetValue(false, igncache);
772  }
773  break;
774 
776  {
777  GenApi::IInteger *p=dynamic_cast<GenApi::IInteger *>(node);
778  int64_t value=p->GetValue(false, igncache);
779 
780  switch (p->GetRepresentation())
781  {
782  case GenApi::HexNumber:
783  out << std::hex << value;
784  break;
785 
786  case GenApi::IPV4Address:
787  out << ((value>>24)&0xff) << '.' << ((value>>16)&0xff) << '.'
788  << ((value>>8)&0xff) << '.' << (value&0xff);
789  break;
790 
791  case GenApi::MACAddress:
792  out << std::hex << std::setfill('0');
793  out << std::setw(2) << ((value>>40)&0xff) << ':'
794  << std::setw(2) << ((value>>32)&0xff) << ':'
795  << std::setw(2) << ((value>>24)&0xff) << ':'
796  << std::setw(2) << ((value>>16)&0xff) << ':'
797  << std::setw(2) << ((value>>8)&0xff) << ':'
798  << std::setw(2) << (value&0xff);
799  break;
800 
801  default:
802  out << value;
803  break;
804  }
805  }
806  break;
807 
808  case GenApi::intfIFloat:
809  {
810  GenApi::IFloat *p=dynamic_cast<GenApi::IFloat *>(node);
811  out << p->GetValue(false, igncache);
812  }
813  break;
814 
816  {
817  GenApi::IEnumeration *p=dynamic_cast<GenApi::IEnumeration *>(node);
818  out << p->GetCurrentEntry()->GetSymbolic();
819  }
820  break;
821 
822  case GenApi::intfIString:
823  {
824  GenApi::IString *p=dynamic_cast<GenApi::IString *>(node);
825  out << p->GetValue(false, igncache);
826  }
827  break;
828 
829  default:
830  if (exception)
831  {
832  throw std::invalid_argument(std::string("Feature of unknown datatype: ")+name);
833  }
834  break;
835  }
836  }
837  else if (exception)
838  {
839  throw std::invalid_argument(std::string("Feature not readable: ")+name);
840  }
841  }
842  else if (exception)
843  {
844  throw std::invalid_argument(std::string("Feature not found: ")+name);
845  }
846  }
847  catch (const GENICAM_NAMESPACE::GenericException &ex)
848  {
849  if (exception)
850  {
851  throw std::invalid_argument(ex.what());
852  }
853  }
854 
855  return out.str();
856 }
857 
858 void checkFeature(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
859  const char *value, bool igncache)
860 {
861  std::string cvalue=rcg::getString(nodemap, name, true, igncache);
862 
863  if (cvalue != "" && cvalue != value)
864  {
865  std::ostringstream out;
866  out << name << " == " << value << " expected: " << cvalue;
867  throw std::invalid_argument(out.str());
868  }
869 }
870 
871 std::shared_ptr<GenApi::CChunkAdapter> getChunkAdapter(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap,
872  const std::string &tltype)
873 {
874  std::shared_ptr<GenApi::CChunkAdapter> chunkadapter;
875 
876  if (setBoolean(nodemap, "ChunkModeActive", true))
877  {
878  if (tltype == "GEV")
879  {
880  chunkadapter=std::shared_ptr<GenApi::CChunkAdapter>(new GenApi::CChunkAdapterGEV(nodemap->_Ptr));
881  }
882  else if (tltype == "U3V")
883  {
884  chunkadapter=std::shared_ptr<GenApi::CChunkAdapter>(new GenApi::CChunkAdapterU3V(nodemap->_Ptr));
885  }
886  else
887  {
888  chunkadapter=std::shared_ptr<GenApi::CChunkAdapter>(new GenApi::CChunkAdapterGeneric(nodemap->_Ptr));
889  }
890  }
891 
892  return chunkadapter;
893 }
894 
895 std::string getComponetOfPart(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap,
896  const rcg::Buffer *buffer, uint32_t ipart)
897 {
898  std::string component;
899 
900  try
901  {
902  // get chunk component selector and proprietary chunk part index parmeters
903 
904  GenApi::IEnumeration *sel=dynamic_cast<GenApi::IEnumeration *>(nodemap->_GetNode("ChunkComponentSelector"));
905  GenApi::IInteger *part=dynamic_cast<GenApi::IInteger *>(nodemap->_GetNode("ChunkPartIndex"));
906 
907  if (sel != 0 && part != 0)
908  {
909  if (GenApi::IsReadable(sel) && GenApi::IsWritable(sel) && GenApi::IsReadable(part))
910  {
911  // go through all available enumerations
912 
913  GenApi::NodeList_t list;
914  sel->GetEntries(list);
915 
916  for (size_t i=0; i<list.size() && component.size() == 0; i++)
917  {
918  GenApi::IEnumEntry *entry=dynamic_cast<GenApi::IEnumEntry *>(list[i]);
919 
920  if (entry != 0 && GenApi::IsReadable(entry))
921  {
922  sel->SetIntValue(entry->GetValue());
923 
924  int64_t val=part->GetValue();
925  if (val == ipart)
926  {
927  component=dynamic_cast<GenApi::IEnumEntry *>(list[i])->GetSymbolic();
928  }
929  }
930  }
931  }
932  }
933  }
934  catch (const std::exception &)
935  { /* ignore errors */ }
937  { /* ignore errors */ }
938 
939  // try guessing component name from pixel format
940 
941  if (component.size() == 0 && buffer->getImagePresent(ipart))
942  {
943  switch (buffer->getPixelFormat(ipart))
944  {
945  case Mono8:
946  case YCbCr411_8:
947  if (buffer->getWidth(ipart) >= buffer->getHeight(ipart))
948  {
949  component="Intensity";
950  }
951  else
952  {
953  component="IntensityCombined";
954  }
955  break;
956 
957  case Coord3D_C16:
958  component="Disparity";
959  break;
960 
961  case Confidence8:
962  component="Confidence";
963  break;
964 
965  case Error8:
966  component="Error";
967  break;
968 
969  default:
970  break;
971  }
972  }
973 
974  return component;
975 }
976 
977 }
bool getBoolean(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool exception, bool igncache)
Get the value of a boolean feature of the given nodemap.
Definition: config.cc:497
bool setIPV4Address(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, const char *value, bool exception)
Set the value of an integer feature of the given nodemap from an IP address.
Definition: config.cc:191
Hex number in an edit control.
Definition: Types.h:95
Connects a chunked DCAM buffer to a node map.
IFloat interface.
Definition: Types.h:196
interface GENAPI_DECL_ABSTRACT IBoolean
Interface for Boolean properties.
Definition: IBoolean.h:61
Definition: PFNC.h:272
std::istream & getline(std::istream &is, GENICAM_NAMESPACE::gcstring &str)
STL getline.
Definition: GCString.h:188
std::shared_ptr< GenApi::CChunkAdapter > getChunkAdapter(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const std::string &tltype)
Sets ChunkModeActive to 1, creates a chunk adapter for the specified transport layer and attaches it ...
Definition: config.cc:871
Declaration of the CChunkAdapterGeneric class.
__int64 int64_t
Definition: config-win32.h:21
int64_t getInteger(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, int64_t *vmin, int64_t *vmax, bool exception, bool igncache)
Get the value of an integer feature of the given nodemap.
Definition: config.cc:542
std::string str()
interface GENAPI_DECL_ABSTRACT IEnumeration
Interface for enumeration properties.
Definition: IEnumeration.h:60
bool setFloat(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, double value, bool exception)
Set the value of a float feature of the given nodemap.
Definition: config.cc:248
virtual GENICAM_NAMESPACE::gcstring GetSymbolic() const =0
Get symbolic enum value.
bool IsReadable(EAccessMode AccessMode)
Tests if readable.
Definition: INode.h:178
size_t getWidth(std::uint32_t part) const
Returns the width of the image in pixel.
Definition: buffer.cc:271
bool setEnum(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, const char *value, bool exception)
Set the value of an enumeration of the given nodemap.
Definition: config.cc:294
interface GENAPI_DECL_ABSTRACT IInteger
Interface for integer properties.
Definition: IInteger.h:61
interface GENAPI_DECL_ABSTRACT IFloat
Interface for float properties.
Definition: IFloat.h:60
interface GENAPI_DECL_ABSTRACT IEnumEntry
Interface of single enum value.
Definition: IEnumEntry.h:60
IString interface.
Definition: Types.h:197
IBoolean interface.
Definition: Types.h:194
The buffer class encapsulates a Genicam buffer that is provided by a stream.
Definition: buffer.h:115
Declaration of the CChunkAdapterGEV class.
node_vector NodeList_t
a list of node references
Definition: INode.h:55
void checkFeature(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, const char *value, bool igncache)
Checks the value of given feature and throws an exception in case of a mismatch.
Definition: config.cc:858
std::string getEnum(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool exception)
Get the value of an enumeration of the given nodemap.
Definition: config.cc:644
uint64_t getPixelFormat(std::uint32_t part) const
Returns the pixel format of the specified part as defined in the PFNC.
Definition: buffer.cc:388
#define Error8
Definition: pixel_formats.h:46
interface GENAPI_DECL_ABSTRACT ICommand
Interface for command like properties.
Definition: ICommand.h:59
bool setString(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, const char *value, bool exception)
Set the value of a feature of the given nodemap.
Definition: config.cc:351
bool setBoolean(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool value, bool exception)
Set the value of a boolean feature of the given nodemap.
Definition: config.cc:99
double getFloat(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, double *vmin, double *vmax, bool exception, bool igncache)
Get the value of a double feature of the given nodemap.
Definition: config.cc:593
bool callCommand(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool exception)
Calls the given command.
Definition: config.cc:53
Connects a generic chunked buffer to a node map.
IEnumeration interface.
Definition: Types.h:200
Definition: buffer.cc:42
interface GENAPI_DECL_ABSTRACT IString
Interface for string properties.
Definition: IString.h:61
bool getImagePresent(std::uint32_t part) const
Returns if a 2D, 3D or confidence image is present in the specified part.
Definition: buffer.cc:346
bool IsWritable(EAccessMode AccessMode)
Tests if writable.
Definition: INode.h:196
bool setInteger(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, int64_t value, bool exception)
Set the value of an integer feature of the given nodemap.
Definition: config.cc:145
GenICam&#39;s exception class.
Definition: GCException.h:62
interface GENAPI_DECL_ABSTRACT INode
Interface common to all nodes.
Definition: INode.h:60
GENICAM_NAMESPACE::gcstring_vector StringList_t
A list of strings.
Definition: Types.h:150
IInteger interface.
Definition: Types.h:193
size_t getHeight(std::uint32_t part) const
Returns the height of the image in pixel.
Definition: buffer.cc:284
std::string getString(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool exception, bool igncache)
Get the value of a feature of the given nodemap.
Definition: config.cc:753
Connects a chunked U3V buffer to a node map.
std::string getComponetOfPart(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const rcg::Buffer *buffer, uint32_t ipart)
Definition: config.cc:895
Declaration of the CChunkAdapterU3V class.
virtual const char * what() const
Get error description (overwrite from std:exception)


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Thu Jun 6 2019 19:10:53