SfncVersion.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //-----------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2009-2021 Basler AG
  4. // http://www.baslerweb.com
  5. // Author: Andreas Gau
  6. //-----------------------------------------------------------------------------
  7. /*!
  8. \file
  9. \brief Contains the support for SFNC version handling.
  10. */
  11. #ifndef INCLUDED_SFNCVERSION_H_3193628
  12. #define INCLUDED_SFNCVERSION_H_3193628
  13. #include <pylon/Platform.h>
  14. #include <pylon/PylonVersionInfo.h>
  15. #ifdef PYLON_LINUX_BUILD
  16. # undef GCC_VERSION
  17. # define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
  18. # undef GCC_DIAGNOSTIC_AWARE
  19. # define GCC_DIAGNOSTIC_AWARE (GCC_VERSION >= 40200)
  20. # undef GCC_DIAGNOSTIC_PUSH_POP_AWARE
  21. # define GCC_DIAGNOSTIC_PUSH_POP_AWARE (GCC_VERSION >= 40600)
  22. #else
  23. # undef GCC_DIAGNOSTIC_AWARE
  24. # define GCC_DIAGNOSTIC_AWARE 0
  25. #endif
  26. #if defined (PYLON_OSX_BUILD)
  27. # pragma clang diagnostic push
  28. # pragma clang diagnostic ignored "-Wunused-variable"
  29. # pragma clang diagnostic ignored "-Wunknown-pragmas"
  30. #endif
  31. #if GCC_DIAGNOSTIC_AWARE
  32. # if GCC_DIAGNOSTIC_PUSH_POP_AWARE
  33. # pragma GCC diagnostic push
  34. # endif
  35. # pragma GCC diagnostic ignored "-Wunknown-pragmas"
  36. # pragma GCC diagnostic ignored "-Wpragmas" // gcc < 4.6 doesn't know the following pragma
  37. # pragma GCC diagnostic ignored "-Wunused-but-set-variable"
  38. #endif
  39. #include <GenApi/GenApi.h>
  40. #if GCC_DIAGNOSTIC_AWARE
  41. # if GCC_DIAGNOSTIC_PUSH_POP_AWARE
  42. # pragma GCC diagnostic pop
  43. # else
  44. # pragma GCC diagnostic warning "-Wunknown-pragmas"
  45. # pragma GCC diagnostic warning "-Wunused-but-set-variable"
  46. # pragma GCC diagnostic warning "-Wpragmas" // gcc < 4.6 doesn't know the pragma
  47. # endif
  48. #endif
  49. #include <GenApi/Pointer.h>
  50. #include <GenApi/INodeMap.h>
  51. #if defined (PYLON_OSX_BUILD)
  52. # pragma clang diagnostic pop
  53. #endif
  54. namespace Pylon
  55. {
  56. /** \addtogroup Pylon_InstantCameraApiGeneric
  57. * @{
  58. */
  59. /// Constant for undefined SFNC version.
  60. static const VersionInfo Sfnc_VersionUndefined( 0, 0, 0 );
  61. /// Constant for SFNC version 1.2.1.
  62. static const VersionInfo Sfnc_1_2_1( 1, 2, 1 );
  63. /// Constant for SFNC version 1.3.0.
  64. static const VersionInfo Sfnc_1_3_0( 1, 3, 0 );
  65. /// Constant for SFNC version 1.4.0.
  66. static const VersionInfo Sfnc_1_4_0( 1, 4, 0 );
  67. /// Constant for SFNC version 1.5.0.
  68. static const VersionInfo Sfnc_1_5_0( 1, 5, 0 );
  69. /// Constant for SFNC version 1.5.1.
  70. static const VersionInfo Sfnc_1_5_1( 1, 5, 1 );
  71. /// Constant for SFNC version 2.0.0. This version or a later version is used by USB camera devices.
  72. static const VersionInfo Sfnc_2_0_0( 2, 0, 0 );
  73. /// Constant for SFNC version 2.1.0
  74. static const VersionInfo Sfnc_2_1_0( 2, 1, 0 );
  75. /// Constant for SFNC version 2.2.0
  76. static const VersionInfo Sfnc_2_2_0( 2, 2, 0 );
  77. /// Constant for SFNC version 2.3.0
  78. static const VersionInfo Sfnc_2_3_0( 2, 3, 0 );
  79. /// Constant for SFNC version 2.4.0
  80. static const VersionInfo Sfnc_2_4_0( 2, 4, 0 );
  81. /// Constant for SFNC version 2.5.0
  82. static const VersionInfo Sfnc_2_5_0( 2, 5, 0 );
  83. /**
  84. * @}
  85. */
  86. /// Helper function for getting the SFNC version from the camera device node map.
  87. inline VersionInfo GetSfncVersion( GenApi::INodeMap* pNodeMap )
  88. {
  89. // If pNodeMap is a valid node map.
  90. if (pNodeMap)
  91. {
  92. // Check to see whether node for major version exists.
  93. GenApi::CIntegerPtr major = pNodeMap->GetNode( "DeviceSFNCVersionMajor" );
  94. if (major)
  95. {
  96. // Get further version Info.
  97. GenApi::CIntegerPtr minor = pNodeMap->GetNode( "DeviceSFNCVersionMinor" );
  98. GenApi::CIntegerPtr subminor = pNodeMap->GetNode( "DeviceSFNCVersionSubMinor" );
  99. if (!IsReadable( major ) || !IsReadable( minor ) || !IsReadable( subminor ))
  100. {
  101. throw RUNTIME_EXCEPTION( "Failed to read SFNC version from camera device node map." );
  102. }
  103. VersionInfo v( static_cast<unsigned int>(major->GetValue()),
  104. static_cast<unsigned int>(minor->GetValue()),
  105. static_cast<unsigned int>(subminor->GetValue()) );
  106. return v;
  107. }
  108. }
  109. return Sfnc_VersionUndefined;
  110. }
  111. }
  112. #endif /* INCLUDED_SFNCVERSION_H_3193628 */