GenApi 3.5.1
EventAdapterGEV.h
1//-----------------------------------------------------------------------------
2// (c) 2006 by Basler Vision Technologies
3// Author: Fritz Dierks
4//
5// License: This file is published under the license of the EMVA GenICam Standard Group.
6// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
7// If for some reason you are missing this file please contact the EMVA or visit the website
8// (http://www.genicam.org) for a full copy.
9//
10// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
11// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
12// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
13// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
14// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
15// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
17// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
18// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
19// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20// POSSIBILITY OF SUCH DAMAGE.
21//
22//-----------------------------------------------------------------------------
28#ifndef GENAPI_EVENTADAPTERGEV_H
29#define GENAPI_EVENTADAPTERGEV_H
30
31#include <GenApi/EventAdapter.h>
32
33namespace GENAPI_NAMESPACE
34{
35
36 /* ------------------------------------------- */
37 // Declaration of GigE Vision Event message structures
38
39 // some useful macros
40 #if defined( _MSC_VER )
41 #define PACK_STRUCT
42 #elif defined (__GNUC__)
43 // While gcc-4 understands #pragma pack,
44 // gcc-3 does not
45 #define PACK_STRUCT __attribute__((packed))
46 #else
47 # error Unknown platform
48 #endif
49
50 // make sure everything is properly packed
51#pragma pack(push, 1)
52
53
55 typedef struct PACK_STRUCT GVCP_REQUEST_HEADER
56 {
57 uint8_t Magic;
58 uint8_t Flags;
59 uint16_t Command;
60 uint16_t Length;
61 uint16_t ReqId;
63
65 typedef struct PACK_STRUCT GVCP_EVENT_ITEM_BASIC
66 {
67 uint16_t ReservedOrEventSize;
68 uint16_t EventId;
70
72 typedef struct PACK_STRUCT GVCP_EVENT_ITEM
73 {
74 uint16_t ReservedOrEventSize;
75 uint16_t EventId;
76 uint16_t StreamChannelId;
77 uint16_t BlockId;
78 uint32_t TimestampHigh;
79 uint32_t TimestampLow;
81
83 typedef struct PACK_STRUCT GVCP_EVENT_REQUEST
84 {
86 GVCP_EVENT_ITEM Items[ 1 ];
88
90 typedef struct PACK_STRUCT GVCP_EVENTDATA_REQUEST
91 {
93 GVCP_EVENT_ITEM Event;
94 uint32_t Data[ 1 ];
96
98 typedef struct PACK_STRUCT GVCP_EVENT_ITEM_EXTENDED_ID
99 {
100 uint16_t ReservedOrEventSize;
101 uint16_t EventId;
102 uint16_t StreamChannelId;
103 uint16_t BlockId;
104 uint32_t BlockId64High;
105 uint32_t BlockId64Low;
106 uint32_t TimestampHigh;
107 uint32_t TimestampLow;
109
116
118 typedef struct PACK_STRUCT GVCP_EVENTDATA_REQUEST_EXTENDED_ID
119 {
120 GVCP_REQUEST_HEADER Header;
122 uint32_t Data[ 1 ];
124
125 const uint8_t COMMAND_MAGIC = 0x42;
126
127 typedef enum GVCP_MESSAGE_TAGS
128 {
129 TAG_EVENT_CMD = 0xc0,
130 TAG_EVENTDATA_CMD = 0xc2
131 } GVCP_MESSAGE_TAGS;
132 // restore the previous packing
133#pragma pack(pop)
134 /* ------------------------------------------- */
135
136
138 class GENAPI_DECL CEventAdapterGEV : public CEventAdapter
139 {
140 public:
142 CEventAdapterGEV(INodeMap* pNodeMap = NULL);
143
146
147 virtual void DeliverMessage( const uint8_t msg[], uint32_t numBytes );
148
151
154
157
160
161 private:
162 void DeliverEventItem(const GVCP_EVENT_ITEM_BASIC *pItem, unsigned int length);
163
164 /*
165 The code for handling event messages and attaching event items to the EventPort
166 is the same for events with and without extended ID.
167 Only the datatype differs, so we keep the implementation in these templates
168 */
169 template<typename EVT_REQ_TYPE> void DeliverEventMessageImpl(const EVT_REQ_TYPE *pEvent);
170 template<typename EVT_REQ_TYPE> void DeliverEventDataMessageImpl(const EVT_REQ_TYPE *pEvent);
171 void AttachItemToPorts(const uint8_t *pItem, uint16_t event_id, unsigned int length);
172
173 };
174}
175
176#endif // GENAPI_EVENTADAPTERGEV_H
Declaration of the CEventAdapter class.
Connects a GigE Event to a node map.
Definition EventAdapterGEV.h:139
void DeliverEventMessage(const GVCP_EVENT_REQUEST *pEvent)
Delivers the Events listed in the Event packet (Extended ID flag not set)
virtual ~CEventAdapterGEV()
Destructor.
void DeliverEventMessage(const GVCP_EVENTDATA_REQUEST *pEventData)
Delivers the Event + Data listed in the EventData packet (Extended ID flag not set)
void DeliverEventMessage(const GVCP_EVENT_REQUEST_EXTENDED_ID *pEvent)
Delivers the Events listed in the Event packet (Extended ID flag set)
void DeliverEventMessage(const GVCP_EVENTDATA_REQUEST_EXTENDED_ID *pEventData)
Delivers the Event + Data listed in the EventData packet (Extended ID flag set)
CEventAdapterGEV(INodeMap *pNodeMap=NULL)
Constructor.
Delivers Events to ports.
Definition EventAdapter.h:46
Layout of a GVCP event data request packet (Extended ID flag set)
Definition EventAdapterGEV.h:119
Layout of a GVCP event data request packet (Extended ID flag not set)
Definition EventAdapterGEV.h:91
layout of a GVCP event item (common to all types)
Definition EventAdapterGEV.h:66
layout of a GVCP event item (Extended ID flag set)
Definition EventAdapterGEV.h:99
layout of a GVCP event item (Extended ID flag not set)
Definition EventAdapterGEV.h:73
Layout of a GVCP event request packet (Extended ID flag set)
Definition EventAdapterGEV.h:112
Layout of a GVCP event request packet (Extended ID flag not set)
Definition EventAdapterGEV.h:84
header of a GVCP request packet
Definition EventAdapterGEV.h:56