PylonGigEDeviceProxy.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. //-----------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2007-2021 Basler AG
  4. // http://www.baslerweb.com
  5. //-----------------------------------------------------------------------------
  6. /*!
  7. \file
  8. \brief Low Level API: Pylon generic GigEVision device interface declaration
  9. */
  10. #ifndef __PYLON_PYLONGIGEDEVICEPROXY__H__
  11. #define __PYLON_PYLONGIGEDEVICEPROXY__H__
  12. #if _MSC_VER > 1000
  13. #pragma once
  14. #endif //_MSC_VER > 1000
  15. #include <pylon/Platform.h>
  16. #ifdef _MSC_VER
  17. # pragma pack(push, PYLON_PACKING)
  18. #endif /* _MSC_VER */
  19. #include "PylonGigEDevice.h"
  20. #include "../PylonDeviceProxy.h"
  21. namespace Pylon
  22. {
  23. //**************************************************************************************************
  24. /// Low Level API: The camera class for GigE Vision camera devices
  25. /**
  26. \ingroup Pylon_LowLevelApi
  27. Extends the Pylon::CPylonDeviceProxyT class by GigE Vision specific functionality.
  28. \tparam TCameraParams The camera specific parameter class (auto generated from camera xml file)
  29. */
  30. //**************************************************************************************************
  31. template<class TCameraParams>
  32. class CPylonGigEDeviceProxyT : public CPylonDeviceProxyT<TCameraParams>
  33. {
  34. public:
  35. //! \name Construction
  36. // \{
  37. /** \brief \copybrief Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT()
  38. \copydetails Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT()
  39. */
  40. CPylonGigEDeviceProxyT();
  41. /** \brief \copybrief Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT(IPylonDevice*,bool)
  42. \copydetails Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT(IPylonDevice*,bool)
  43. */
  44. CPylonGigEDeviceProxyT( IPylonDevice*, bool takeOwnership = true );
  45. //! Destructor
  46. virtual ~CPylonGigEDeviceProxyT();
  47. //\}
  48. private:
  49. //! \name Assignment and copying is not supported
  50. // \{
  51. CPylonGigEDeviceProxyT( const CPylonGigEDeviceProxyT& );
  52. CPylonGigEDeviceProxyT& operator=( const CPylonGigEDeviceProxyT& );
  53. // \}
  54. public:
  55. //! \name Some smart pointer functionality
  56. // \{
  57. /** \brief \copybrief Pylon::CPylonDeviceProxyT::Attach()
  58. \copydetails Pylon::CPylonDeviceProxyT::Attach()
  59. */
  60. virtual void Attach( IPylonDevice*, bool takeOwnership = true );
  61. /** \brief \copybrief Pylon::CPylonDeviceProxyT::IsAttached()
  62. \copydetails Pylon::CPylonDeviceProxyT::IsAttached()
  63. */
  64. virtual bool IsAttached() const;
  65. // \}
  66. public:
  67. //! \name Implementation of the IPylonGigEDevice interface.
  68. //! See Pylon::IPylonGigEDevice for more details.
  69. // \{
  70. /** \brief \copybrief Pylon::IPylonGigEDevice::ChangeIpConfiguration()
  71. \copydetails Pylon::IPylonGigEDevice::ChangeIpConfiguration()
  72. */
  73. void ChangeIpConfiguration( bool EnablePersistentIp, bool EnableDhcp )
  74. {
  75. CheckGigEDevicePtr();
  76. m_pGigEDevice->ChangeIpConfiguration( EnablePersistentIp, EnableDhcp );
  77. }
  78. /** \brief \copybrief Pylon::IPylonGigEDevice::GetPersistentIpAddress()
  79. \copydetails Pylon::IPylonGigEDevice::GetPersistentIpAddress()
  80. */
  81. void GetPersistentIpAddress( String_t& IpAddress, String_t& SubnetMask, String_t& DefaultGateway )
  82. {
  83. CheckGigEDevicePtr();
  84. m_pGigEDevice->GetPersistentIpAddress( IpAddress, SubnetMask, DefaultGateway );
  85. }
  86. /** \brief \copybrief Pylon::IPylonGigEDevice::SetPersistentIpAddress()
  87. \copydetails Pylon::IPylonGigEDevice::SetPersistentIpAddress()
  88. */
  89. void SetPersistentIpAddress( const String_t& IpAddress,
  90. const String_t& SubnetMask,
  91. const String_t& DefaultGateway )
  92. {
  93. CheckGigEDevicePtr();
  94. m_pGigEDevice->SetPersistentIpAddress( IpAddress, SubnetMask, DefaultGateway );
  95. }
  96. // \}
  97. protected:
  98. void CheckGigEDevicePtr() const
  99. {
  100. if (NULL == m_pGigEDevice)
  101. {
  102. throw LOGICAL_ERROR_EXCEPTION( "The camera class is not attached to an IPylonGigEDevice" );
  103. }
  104. }
  105. IPylonGigEDevice* m_pGigEDevice;
  106. };
  107. //**************************************************************************************************
  108. // CPylonGigEDeviceProxyT implementation
  109. //**************************************************************************************************
  110. template<class TCameraParams>
  111. inline CPylonGigEDeviceProxyT<TCameraParams>::CPylonGigEDeviceProxyT()
  112. : CPylonDeviceProxyT<TCameraParams>()
  113. , m_pGigEDevice( NULL )
  114. {
  115. }
  116. template<class TCameraParams>
  117. inline CPylonGigEDeviceProxyT<TCameraParams>::CPylonGigEDeviceProxyT( IPylonDevice* pDevice, bool takeOwnership )
  118. : CPylonDeviceProxyT<TCameraParams>()
  119. , m_pGigEDevice( NULL )
  120. {
  121. Attach( pDevice, takeOwnership );
  122. }
  123. template<class TCameraParams>
  124. inline CPylonGigEDeviceProxyT<TCameraParams>::~CPylonGigEDeviceProxyT()
  125. {
  126. }
  127. template<class TCameraParams>
  128. inline void CPylonGigEDeviceProxyT<TCameraParams>::Attach( IPylonDevice* pDevice, bool takeOwnership )
  129. {
  130. IPylonGigEDevice* pGigEDevice = dynamic_cast<IPylonGigEDevice*>(pDevice);
  131. if (!pGigEDevice)
  132. {
  133. throw LOGICAL_ERROR_EXCEPTION( "The attached Pylon Device is not of type IPylonGigEDevice!" );
  134. }
  135. CPylonDeviceProxyT<TCameraParams>::Attach( pDevice, takeOwnership );
  136. m_pGigEDevice = pGigEDevice;
  137. }
  138. template<class TCameraParams>
  139. inline bool CPylonGigEDeviceProxyT<TCameraParams>::IsAttached() const
  140. {
  141. return NULL != m_pGigEDevice;
  142. }
  143. } // namespace Pylon
  144. #ifdef _MSC_VER
  145. # pragma pack(pop)
  146. #endif /* _MSC_VER */
  147. #endif