BaslerUniversalInstantCamera.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. //-----------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2010-2021 Basler AG
  4. // http://www.baslerweb.com
  5. // Author: Andreas Gau
  6. //-----------------------------------------------------------------------------
  7. /*!
  8. \file
  9. \brief pylon universal instant camera class.
  10. */
  11. #ifndef INCLUDED_BASLERUNIVERSALINSTANTCAMERA_H
  12. #define INCLUDED_BASLERUNIVERSALINSTANTCAMERA_H
  13. #pragma once
  14. #include <pylon/_BaslerUniversalCameraParams.h>
  15. #include <pylon/_BaslerUniversalStreamParams.h>
  16. #include <pylon/_BaslerUniversalEventParams.h>
  17. #include <pylon/_BaslerUniversalTLParams.h>
  18. #include <pylon/BaslerUniversalConfigurationEventHandler.h>
  19. #include <pylon/BaslerUniversalImageEventHandler.h>
  20. #include <pylon/BaslerUniversalCameraEventHandler.h>
  21. #include <pylon/BaslerUniversalGrabResultPtr.h>
  22. #include <pylon/private/DeviceSpecificInstantCamera.h>
  23. #include <pylon/gige/PylonGigEDevice.h>
  24. #include <pylon/DeviceClass.h>
  25. #include <pylon/NodeMapProxy.h>
  26. #include <Base/GCException.h>
  27. namespace Pylon
  28. {
  29. /** \addtogroup Pylon_InstantCameraApiUniversal
  30. * @{
  31. */
  32. class CBaslerUniversalInstantCamera;
  33. /// Lists all the types used by the universal instant camera class.
  34. struct CBaslerUniversalInstantCameraTraits
  35. {
  36. /// The type of the final camera class.
  37. typedef CBaslerUniversalInstantCamera InstantCamera_t;
  38. /// \copybrief Basler_UniversalCameraParams::CUniversalCameraParams_Params
  39. typedef Basler_UniversalCameraParams::CUniversalCameraParams_Params CameraParams_t;
  40. /// \copybrief Pylon::IPylonDevice
  41. typedef IPylonDevice IPylonDevice_t;
  42. /// \copybrief Pylon::CDeviceInfo
  43. typedef Pylon::CDeviceInfo DeviceInfo_t;
  44. /// \copybrief Basler_UniversalTLParams::CUniversalTLParams_Params
  45. typedef CNodeMapProxyT<Basler_UniversalTLParams::CUniversalTLParams_Params> TlParams_t;
  46. /// The parameters of the universal stream grabber.
  47. typedef CNodeMapProxyT<Basler_UniversalStreamParams::CUniversalStreamParams_Params> StreamGrabberParams_t;
  48. /// The parameters of the universal event grabber.
  49. typedef CNodeMapProxyT<Basler_UniversalEventParams::CUniversalEventParams_Params> EventGrabberParams_t;
  50. /// The universal configuration event handler class.
  51. typedef CBaslerUniversalConfigurationEventHandler ConfigurationEventHandler_t;
  52. /// The universal image event handler class.
  53. typedef CBaslerUniversalImageEventHandler ImageEventHandler_t;
  54. /// The universal camera event handler class.
  55. typedef CBaslerUniversalCameraEventHandler CameraEventHandler_t;
  56. /// The universal grab result data.
  57. typedef CBaslerUniversalGrabResultData GrabResultData_t;
  58. /// The universal grab result smart pointer.
  59. typedef CBaslerUniversalGrabResultPtr GrabResultPtr_t;
  60. //! Can be used to check whether the DeviceClass() can be used for enumeration.
  61. static bool HasSpecificDeviceClass()
  62. {
  63. return false;
  64. }
  65. //! The name of this device class. Use this one for enumeration.
  66. static String_t DeviceClass()
  67. {
  68. throw LOGICAL_ERROR_EXCEPTION( "The CBaslerUniversalInstantCamera has no specific device class. The method DeviceClass() cannot be used." );
  69. }
  70. };
  71. /*!
  72. \class CBaslerUniversalInstantCamera
  73. \brief Extends the CInstantCamera by universal parameter interface classes combining all interface types.
  74. */
  75. class CBaslerUniversalInstantCamera : public CDeviceSpecificInstantCameraT<CBaslerUniversalInstantCameraTraits>
  76. {
  77. public:
  78. /*!
  79. \copybrief CInstantCamera::CInstantCamera()
  80. \copydetails CInstantCamera::CInstantCamera
  81. */
  82. CBaslerUniversalInstantCamera()
  83. {
  84. }
  85. /*!
  86. \copybrief CInstantCamera::CInstantCamera( IPylonDevice* , ECleanup )
  87. \copydetails CInstantCamera::CInstantCamera( IPylonDevice* , ECleanup )
  88. */
  89. CBaslerUniversalInstantCamera( IPylonDevice* pDevice, ECleanup cleanupProcedure = Cleanup_Delete )
  90. : CDeviceSpecificInstantCameraT<CBaslerUniversalInstantCameraTraits>( pDevice, cleanupProcedure )
  91. {
  92. }
  93. /*!
  94. \copybrief CInstantCamera::~CInstantCamera
  95. \copydetails CInstantCamera::~CInstantCamera
  96. */
  97. ~CBaslerUniversalInstantCamera()
  98. {
  99. Attach( NULL );
  100. InternalShutdownEventHandlers();
  101. }
  102. /*!
  103. \brief Enables/disables use of persistent IP address and DHCP usage of the attached %Pylon Device.
  104. See Pylon::IPylonGigEDevice::ChangeIpConfiguration()
  105. \pre
  106. <ul>
  107. <li> A %Pylon Device is attached.
  108. <li> The %Pylon Device is open.
  109. </ul>
  110. \error
  111. The Instant Camera object is still valid after error.
  112. \threading
  113. This method is synchronized using the lock provided by GetLock().
  114. */
  115. void ChangeIpConfiguration( bool EnablePersistentIp, bool EnableDhcp )
  116. {
  117. AutoLock lock( CInstantCamera::GetLock() );
  118. GetGigEDevice()->ChangeIpConfiguration( EnablePersistentIp, EnableDhcp );
  119. }
  120. /*!
  121. \brief Reads the persistent IP address from the attached %Pylon Device.
  122. See Pylon::IPylonGigEDevice::GetPersistentIpAddress()
  123. \pre
  124. <ul>
  125. <li> A %Pylon Device is attached.
  126. <li> The %Pylon Device is open.
  127. </ul>
  128. \error
  129. The Instant Camera object is still valid after error.
  130. \threading
  131. This method is synchronized using the lock provided by GetLock().
  132. */
  133. void GetPersistentIpAddress( String_t& IpAddress, String_t& SubnetMask, String_t& DefaultGateway )
  134. {
  135. AutoLock lock( CInstantCamera::GetLock() );
  136. GetGigEDevice()->GetPersistentIpAddress( IpAddress, SubnetMask, DefaultGateway );
  137. }
  138. /*!
  139. \brief Writes a persistent IP address to the attached %Pylon Device.
  140. See Pylon::IPylonGigEDevice::SetPersistentIpAddress()
  141. \pre
  142. <ul>
  143. <li> A %Pylon Device is attached.
  144. <li> The %Pylon Device is open.
  145. </ul>
  146. \error
  147. The Instant Camera object is still valid after error.
  148. \threading
  149. This method is synchronized using the lock provided by GetLock().
  150. */
  151. void SetPersistentIpAddress( const String_t& IpAddress,
  152. const String_t& SubnetMask,
  153. const String_t& DefaultGateway )
  154. {
  155. AutoLock lock( CInstantCamera::GetLock() );
  156. GetGigEDevice()->SetPersistentIpAddress( IpAddress, SubnetMask, DefaultGateway );
  157. }
  158. protected:
  159. //Get the pointer for the Universal device.
  160. virtual IPylonGigEDevice* GetGigEDevice()
  161. {
  162. IPylonDevice* pDevice = CInstantCamera::GetDevice();
  163. IPylonGigEDevice* pGigEDevice = dynamic_cast<IPylonGigEDevice*>(pDevice);
  164. // Check whether device type matches camera type.
  165. if (!pGigEDevice)
  166. {
  167. throw LOGICAL_ERROR_EXCEPTION( "The attached pylon device type must be a GigE device." );
  168. }
  169. return pGigEDevice;
  170. }
  171. //Create device grab result data. Is subject to change without notice.
  172. virtual CGrabResultData* CreateDeviceSpecificGrabResultData()
  173. {
  174. return new GrabResultData_t();
  175. }
  176. };
  177. /**
  178. * @}
  179. */
  180. } // namespace Pylon
  181. #endif /* INCLUDED_BASLERUNIVERSALINSTANTCAMERA_H */