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  if (node->GetPrincipalInterfaceType() == GenApi::intfIEnumeration)
559  {
560  GenApi::IEnumeration *p=dynamic_cast<GenApi::IEnumeration *>(node);
561  ret=p->GetCurrentEntry(false, igncache)->GetValue();
562 
563  if (vmin != 0) *vmin=ret;
564  if (vmax != 0) *vmax=ret;
565  }
566  else
567  {
568  GenApi::IInteger *val=dynamic_cast<GenApi::IInteger *>(node);
569 
570  if (val != 0)
571  {
572  ret=val->GetValue(false, igncache);
573 
574  if (vmin != 0) *vmin=val->GetMin();
575  if (vmax != 0) *vmax=val->GetMax();
576  }
577  else if (exception)
578  {
579  throw std::invalid_argument(std::string("Feature not integer: ")+name);
580  }
581  }
582  }
583  else if (exception)
584  {
585  throw std::invalid_argument(std::string("Feature not readable: ")+name);
586  }
587  }
588  else if (exception)
589  {
590  throw std::invalid_argument(std::string("Feature not found: ")+name);
591  }
592  }
593  catch (const GENICAM_NAMESPACE::GenericException &ex)
594  {
595  if (exception)
596  {
597  throw std::invalid_argument(ex.what());
598  }
599  }
600 
601  return ret;
602 }
603 
604 double getFloat(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
605  double *vmin, double *vmax, bool exception, bool igncache)
606 {
607  double ret=0;
608 
609  if (vmin != 0) *vmin=0;
610  if (vmax != 0) *vmax=0;
611 
612  try
613  {
614  GenApi::INode *node=nodemap->_GetNode(name);
615 
616  if (node != 0)
617  {
618  if (GenApi::IsReadable(node))
619  {
620  GenApi::IFloat *val=dynamic_cast<GenApi::IFloat *>(node);
621 
622  if (val != 0)
623  {
624  ret=val->GetValue(false, igncache);
625 
626  if (vmin != 0) *vmin=val->GetMin();
627  if (vmax != 0) *vmax=val->GetMax();
628  }
629  else if (exception)
630  {
631  throw std::invalid_argument(std::string("Feature not float: ")+name);
632  }
633  }
634  else if (exception)
635  {
636  throw std::invalid_argument(std::string("Feature not readable: ")+name);
637  }
638  }
639  else if (exception)
640  {
641  throw std::invalid_argument(std::string("Feature not found: ")+name);
642  }
643  }
644  catch (const GENICAM_NAMESPACE::GenericException &ex)
645  {
646  if (exception)
647  {
648  throw std::invalid_argument(ex.what());
649  }
650  }
651 
652  return ret;
653 }
654 
655 std::string getEnum(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
656  bool exception)
657 {
658  std::string ret;
659 
660  try
661  {
662  GenApi::INode *node=nodemap->_GetNode(name);
663 
664  if (node != 0)
665  {
666  if (GenApi::IsReadable(node))
667  {
668  GenApi::IEnumeration *val=dynamic_cast<GenApi::IEnumeration *>(node);
669 
670  if (val != 0)
671  {
672  GenApi::IEnumEntry *entry=val->GetCurrentEntry();
673 
674  if (entry != 0)
675  {
676  ret=entry->GetSymbolic();
677  }
678  else if (exception)
679  {
680  throw std::invalid_argument(std::string("Current value is not defined: ")+name);
681  }
682  }
683  else if (exception)
684  {
685  throw std::invalid_argument(std::string("Feature not enumeration: ")+name);
686  }
687  }
688  else if (exception)
689  {
690  throw std::invalid_argument(std::string("Feature not readable: ")+name);
691  }
692  }
693  else if (exception)
694  {
695  throw std::invalid_argument(std::string("Feature not found: ")+name);
696  }
697  }
698  catch (const GENICAM_NAMESPACE::GenericException &ex)
699  {
700  if (exception)
701  {
702  throw std::invalid_argument(ex.what());
703  }
704  }
705 
706  return ret;
707 }
708 
709 std::string getEnum(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
710  std::vector<std::string> &list, bool exception)
711 {
712  std::string ret;
713 
714  list.clear();
715 
716  try
717  {
718  GenApi::INode *node=nodemap->_GetNode(name);
719 
720  if (node != 0)
721  {
722  if (GenApi::IsReadable(node))
723  {
724  GenApi::IEnumeration *val=dynamic_cast<GenApi::IEnumeration *>(node);
725 
726  if (val != 0)
727  {
728  GenApi::StringList_t entries;
729  val->GetSymbolics(entries);
730 
731  for (size_t i=0; i<entries.size(); i++)
732  {
733  list.push_back(std::string(entries[i]));
734  }
735 
736  GenApi::IEnumEntry *entry=val->GetCurrentEntry();
737 
738  if (entry != 0)
739  {
740  ret=entry->GetSymbolic();
741  }
742  else if (exception)
743  {
744  throw std::invalid_argument(std::string("Current value is not defined: ")+name);
745  }
746  }
747  else if (exception)
748  {
749  throw std::invalid_argument(std::string("Feature not enumeration: ")+name);
750  }
751  }
752  else if (exception)
753  {
754  throw std::invalid_argument(std::string("Feature not readable: ")+name);
755  }
756  }
757  else if (exception)
758  {
759  throw std::invalid_argument(std::string("Feature not found: ")+name);
760  }
761  }
762  catch (const GENICAM_NAMESPACE::GenericException &ex)
763  {
764  if (exception)
765  {
766  throw std::invalid_argument(ex.what());
767  }
768  }
769 
770  return ret;
771 }
772 
773 std::string getString(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
774  bool exception, bool igncache)
775 {
776  std::ostringstream out;
777 
778  try
779  {
780  GenApi::INode *node=nodemap->_GetNode(name);
781 
782  if (node != 0)
783  {
784  if (GenApi::IsReadable(node))
785  {
786  switch (node->GetPrincipalInterfaceType())
787  {
789  {
790  GenApi::IBoolean *p=dynamic_cast<GenApi::IBoolean *>(node);
791  out << p->GetValue(false, igncache);
792  }
793  break;
794 
796  {
797  GenApi::IInteger *p=dynamic_cast<GenApi::IInteger *>(node);
798  int64_t value=p->GetValue(false, igncache);
799 
800  switch (p->GetRepresentation())
801  {
802  case GenApi::HexNumber:
803  out << std::hex << value;
804  break;
805 
806  case GenApi::IPV4Address:
807  out << ((value>>24)&0xff) << '.' << ((value>>16)&0xff) << '.'
808  << ((value>>8)&0xff) << '.' << (value&0xff);
809  break;
810 
811  case GenApi::MACAddress:
812  out << std::hex << std::setfill('0');
813  out << std::setw(2) << ((value>>40)&0xff) << ':'
814  << std::setw(2) << ((value>>32)&0xff) << ':'
815  << std::setw(2) << ((value>>24)&0xff) << ':'
816  << std::setw(2) << ((value>>16)&0xff) << ':'
817  << std::setw(2) << ((value>>8)&0xff) << ':'
818  << std::setw(2) << (value&0xff);
819  break;
820 
821  default:
822  out << value;
823  break;
824  }
825  }
826  break;
827 
828  case GenApi::intfIFloat:
829  {
830  GenApi::IFloat *p=dynamic_cast<GenApi::IFloat *>(node);
831  out << p->GetValue(false, igncache);
832  }
833  break;
834 
836  {
837  GenApi::IEnumeration *p=dynamic_cast<GenApi::IEnumeration *>(node);
838  out << p->GetCurrentEntry()->GetSymbolic();
839  }
840  break;
841 
842  case GenApi::intfIString:
843  {
844  GenApi::IString *p=dynamic_cast<GenApi::IString *>(node);
845  out << p->GetValue(false, igncache);
846  }
847  break;
848 
849  default:
850  if (exception)
851  {
852  throw std::invalid_argument(std::string("Feature of unknown datatype: ")+name);
853  }
854  break;
855  }
856  }
857  else if (exception)
858  {
859  throw std::invalid_argument(std::string("Feature not readable: ")+name);
860  }
861  }
862  else if (exception)
863  {
864  throw std::invalid_argument(std::string("Feature not found: ")+name);
865  }
866  }
867  catch (const GENICAM_NAMESPACE::GenericException &ex)
868  {
869  if (exception)
870  {
871  throw std::invalid_argument(ex.what());
872  }
873  }
874 
875  return out.str();
876 }
877 
878 void checkFeature(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap, const char *name,
879  const char *value, bool igncache)
880 {
881  std::string cvalue=getString(nodemap, name, true, igncache);
882 
883  if (cvalue != "" && cvalue != value)
884  {
885  std::ostringstream out;
886  out << name << " == " << value << " expected: " << cvalue;
887  throw std::invalid_argument(out.str());
888  }
889 }
890 
891 std::shared_ptr<GenApi::CChunkAdapter> getChunkAdapter(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap,
892  const std::string &tltype)
893 {
894  std::shared_ptr<GenApi::CChunkAdapter> chunkadapter;
895 
896  if (setBoolean(nodemap, "ChunkModeActive", true))
897  {
898  if (tltype == "GEV")
899  {
900  chunkadapter=std::shared_ptr<GenApi::CChunkAdapter>(new GenApi::CChunkAdapterGEV(nodemap->_Ptr));
901  }
902  else if (tltype == "U3V")
903  {
904  chunkadapter=std::shared_ptr<GenApi::CChunkAdapter>(new GenApi::CChunkAdapterU3V(nodemap->_Ptr));
905  }
906  else
907  {
908  chunkadapter=std::shared_ptr<GenApi::CChunkAdapter>(new GenApi::CChunkAdapterGeneric(nodemap->_Ptr));
909  }
910  }
911 
912  return chunkadapter;
913 }
914 
915 std::string getComponetOfPart(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap,
916  const Buffer *buffer, uint32_t ipart)
917 {
918  std::string component;
919 
920  try
921  {
922  // get chunk component selector and proprietary chunk part index parmeters
923 
924  GenApi::IEnumeration *sel=dynamic_cast<GenApi::IEnumeration *>(nodemap->_GetNode("ChunkComponentSelector"));
925  GenApi::IInteger *part=dynamic_cast<GenApi::IInteger *>(nodemap->_GetNode("ChunkPartIndex"));
926 
927  if (sel != 0 && part != 0)
928  {
929  if (GenApi::IsReadable(sel) && GenApi::IsWritable(sel) && GenApi::IsReadable(part))
930  {
931  // go through all available enumerations
932 
933  GenApi::NodeList_t list;
934  sel->GetEntries(list);
935 
936  for (size_t i=0; i<list.size() && component.size() == 0; i++)
937  {
938  GenApi::IEnumEntry *entry=dynamic_cast<GenApi::IEnumEntry *>(list[i]);
939 
940  if (entry != 0 && GenApi::IsReadable(entry))
941  {
942  sel->SetIntValue(entry->GetValue());
943 
944  int64_t val=part->GetValue();
945  if (val == ipart)
946  {
947  component=dynamic_cast<GenApi::IEnumEntry *>(list[i])->GetSymbolic();
948  }
949  }
950  }
951  }
952  }
953  }
954  catch (const std::exception &)
955  { /* ignore errors */ }
957  { /* ignore errors */ }
958 
959  // try guessing component name from pixel format
960 
961  if (component.size() == 0 && buffer->getImagePresent(ipart))
962  {
963  switch (buffer->getPixelFormat(ipart))
964  {
965  case Mono8:
966  case YCbCr411_8:
967  if (buffer->getWidth(ipart) >= buffer->getHeight(ipart))
968  {
969  component="Intensity";
970  }
971  else
972  {
973  component="IntensityCombined";
974  }
975  break;
976 
977  case Coord3D_C16:
978  component="Disparity";
979  break;
980 
981  case Confidence8:
982  component="Confidence";
983  break;
984 
985  case Error8:
986  component="Error";
987  break;
988 
989  default:
990  break;
991  }
992  }
993 
994  return component;
995 }
996 
997 }
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
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IBoolean
Interface for Boolean properties.
Definition: IBoolean.h:61
Definition: PFNC.h:272
GENICAM_INTERFACE IInteger
Interface for integer properties.
Definition: IFloat.h:114
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)
NOTE: This function is deprecated.
Definition: config.cc:891
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()
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:333
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
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT ICommand
Interface for command like properties.
Definition: ICommand.h:59
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:118
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:878
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:655
uint64_t getPixelFormat(std::uint32_t part) const
Returns the pixel format of the specified part as defined in the PFNC.
Definition: buffer.cc:480
#define Error8
Definition: pixel_formats.h:46
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IEnumeration
Interface for enumeration properties.
Definition: IEnumeration.h:60
std::string getComponetOfPart(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const Buffer *buffer, uint32_t ipart)
Definition: config.cc:915
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:604
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
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IString
Interface for string properties.
Definition: IString.h:61
Definition: buffer.cc:47
bool getImagePresent(std::uint32_t part) const
Returns if a 2D, 3D or confidence image is present in the specified part.
Definition: buffer.cc:433
bool IsWritable(EAccessMode AccessMode)
Tests if writable.
Definition: INode.h:196
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IFloat
Interface for float properties.
Definition: IFloat.h:60
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_INTERFACE INode
Interface common to all nodes.
Definition: ICategory.h:51
GenICam&#39;s exception class.
Definition: GCException.h:63
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:351
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IEnumEntry
Interface of single enum value.
Definition: IEnumEntry.h:60
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:773
Connects a chunked U3V buffer to a node map.
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 Wed Mar 17 2021 02:48:40