EventPort.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. //-----------------------------------------------------------------------------
  2. // (c) 2006 by Basler Vision Technologies
  3. // Section: Vision Components
  4. // Project: GenApi
  5. // Author: Fritz Dierks
  6. // $Header$
  7. //
  8. // License: This file is published under the license of the EMVA GenICam Standard Group.
  9. // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
  10. // If for some reason you are missing this file please contact the EMVA or visit the website
  11. // (http://www.genicam.org) for a full copy.
  12. //
  13. // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
  14. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  15. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
  17. // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  18. // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  20. // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  21. // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  22. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  23. // POSSIBILITY OF SUCH DAMAGE.
  24. //-----------------------------------------------------------------------------
  25. /**
  26. \file
  27. \brief Declaration of the CEventPort class.
  28. \ingroup GenApi_PublicUtilities
  29. */
  30. #ifndef GENAPI_EVENTPORT_H
  31. #define GENAPI_EVENTPORT_H
  32. #include <GenApi/Pointer.h>
  33. #include <GenApi/IPortConstruct.h>
  34. #include <GenApi/INodeMap.h>
  35. namespace GENAPI_NAMESPACE
  36. {
  37. /**
  38. \brief Port attachable to an event
  39. \ingroup GenApi_PublicUtilities
  40. */
  41. class GENAPI_DECL CEventPort : public IPortConstruct
  42. {
  43. public:
  44. //! Constructor; can attach to a node
  45. CEventPort(INode* pNode = NULL);
  46. //! Destructor; detaches from the port
  47. ~CEventPort();
  48. //-------------------------------------------------------------
  49. // IPortConstruct implementation
  50. //-------------------------------------------------------------
  51. //! Get the access mode of the node
  52. virtual EAccessMode GetAccessMode() const;
  53. //! Get the type of the main interface of a node
  54. virtual EInterfaceType GetPrincipalInterfaceType() const;
  55. //! Reads a chunk of bytes from the port
  56. virtual void Read(void *pBuffer, int64_t Address, int64_t Length);
  57. //! Writes a chunk of bytes to the port
  58. virtual void Write(const void *pBuffer, int64_t Address, int64_t Length);
  59. //! Called from the port node to give the chunk port a pointer to itself
  60. virtual void SetPortImpl(GENAPI_NAMESPACE::IPort* pPort);
  61. //! Determines if the port adapter must perform an endianess swap
  62. virtual EYesNo GetSwapEndianess();
  63. //---------------------------------------------------------------
  64. // Implementation
  65. //---------------------------------------------------------------
  66. // Invalidates the chunk port node
  67. void InvalidateNode();
  68. //-------------------------------------------------------------
  69. // Initializing
  70. //-------------------------------------------------------------
  71. //! Attaches to the Node
  72. bool AttachNode(GENAPI_NAMESPACE::INode* pNode);
  73. //! Detaches from the Node
  74. void DetachNode();
  75. //! Gets the EventID length
  76. int GetEventIDLength();
  77. //! Checks if a EventID matches
  78. bool CheckEventID(uint8_t* pEventIDBuffer, int EventIDLength) const;
  79. //! Checks if a EventID matches, version using uint64_t ID representation
  80. bool CheckEventID(uint64_t EventID) const;
  81. //! Attaches the an Event to the EventPort
  82. void AttachEvent(uint8_t *pBaseAddress, int64_t Length);
  83. //! Detaches the Event from the EventPort
  84. void DetachEvent();
  85. protected:
  86. CLock& GetLock() const;
  87. private:
  88. void ResetEventDataBuffer();
  89. //-------------------------------------------------------------
  90. // Member variables
  91. //-------------------------------------------------------------
  92. //! Pointer to the begin of the buffer
  93. uint8_t *m_pEventData;
  94. //! Length of the data
  95. int64_t m_EventDataLength;
  96. //! Space allocated for the data
  97. int64_t m_EventDataAlloc;
  98. #ifdef _MSC_VER
  99. # pragma warning( push )
  100. # pragma warning( disable: 4251 )
  101. #endif
  102. //! Pointer to the node holding a reference to this implementation
  103. CNodePtr m_ptrNode;
  104. #ifdef _MSC_VER
  105. # pragma warning( pop )
  106. #endif
  107. //! Binary version of the EventID
  108. uint8_t *m_pEventIDBuffer;
  109. //! Length of the EventID buffer
  110. int m_EventIDLength;
  111. //! indicates if the object is attached to a port node or another node type
  112. bool m_IsAttachedToPortNode;
  113. //! Event ID stored as a number (for more straightforward access)
  114. uint64_t m_EventIDNumber;
  115. //! indicates if the m_EventIDNumber is valid (could be invalid eg. if the ID does not fit in 64-bit range)
  116. bool m_EventIDNumberValid;
  117. };
  118. }
  119. #endif // GENAPI_EVENTPORT_H