EventAdapterU3V.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //-----------------------------------------------------------------------------
  2. // (c) 2013 by Groget
  3. // Project: GenApi
  4. // Author: Jan Becvar
  5. // $Header$
  6. //
  7. // License: This file is published under the license of the EMVA GenICam Standard Group.
  8. // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
  9. // If for some reason you are missing this file please contact the EMVA or visit the website
  10. // (http://www.genicam.org) for a full copy.
  11. //
  12. // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
  13. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  14. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  15. // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
  16. // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  17. // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  18. // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  19. // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  20. // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  21. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  22. // POSSIBILITY OF SUCH DAMAGE.
  23. //-----------------------------------------------------------------------------
  24. /**
  25. \file
  26. \brief Declaration of the CEventAdapterU3V class.
  27. */
  28. #ifndef GENAPI_EVENTADAPTERU3V_H
  29. #define GENAPI_EVENTADAPTERU3V_H
  30. #include <GenApi/EventAdapter.h>
  31. namespace GENAPI_NAMESPACE
  32. {
  33. /* ------------------------------------------- */
  34. // Declaration of USB3 Vision / GenCP Event message structures
  35. // some useful macros
  36. #if defined( _MSC_VER )
  37. #define PACK_STRUCT
  38. #elif defined (__GNUC__)
  39. // While gcc-4 understands #pragma pack,
  40. // gcc-3 does not
  41. #define PACK_STRUCT __attribute__((packed))
  42. #else
  43. # error Unknown platform
  44. #endif
  45. // make sure everything is properly packed
  46. #pragma pack(push, 1)
  47. //! U3V/GenCP command header
  48. typedef struct PACK_STRUCT U3V_COMMAND_HEADER
  49. {
  50. uint32_t Prefix;
  51. // CCD
  52. uint16_t Flags;
  53. uint16_t CommandId;
  54. uint16_t Length;
  55. uint16_t ReqId;
  56. } U3V_COMMAND_HEADER;
  57. //! U3V/GenCP EVENT_CMD specific command data
  58. typedef struct PACK_STRUCT U3V_EVENT_DATA
  59. {
  60. // SCD
  61. uint16_t Reserved;
  62. uint16_t EventId;
  63. uint64_t Timestamp;
  64. // Deliberately not mentioning the (optional?) variable sized data
  65. } U3V_EVENT_DATA;
  66. //! Entire event data message (without the variable-sized data field)
  67. typedef struct PACK_STRUCT U3V_EVENT_MESSAGE
  68. {
  69. U3V_COMMAND_HEADER CommandHeader;
  70. U3V_EVENT_DATA EventData;
  71. } U3V_EVENT_MESSAGE;
  72. const uint32_t U3V_EVENT_PREFIX = 0x45563355;
  73. const uint16_t GENCP_EVENT_CMD_ID = 0x0C00;
  74. const size_t GENCP_COMMAND_HEADER_SIZE = sizeof (U3V_COMMAND_HEADER);
  75. const size_t GENCP_EVENT_BASIC_SIZE = sizeof (U3V_EVENT_MESSAGE);
  76. // restore the previous packing
  77. #pragma pack(pop)
  78. /* ------------------------------------------- */
  79. //! Connects a U3V Event to a node map
  80. class GENAPI_DECL CEventAdapterU3V : public CEventAdapter
  81. {
  82. public:
  83. //! Constructor
  84. CEventAdapterU3V(INodeMap* pNodeMap = NULL);
  85. //! Destructor
  86. virtual ~CEventAdapterU3V();
  87. virtual void DeliverMessage( const uint8_t msg[], uint32_t numBytes );
  88. //! Delivers the Event + Data listed in the packet
  89. void DeliverEventMessage(const U3V_EVENT_MESSAGE *pEventMessage);
  90. };
  91. }
  92. #endif // GENAPI_EVENTADAPTERU3V_H