Tezzeret  1
Tezzeret
GmAppEvent.hpp
1 #ifndef GM_APP_EVENT_SENSOR_HPP_
2 #define GM_APP_EVENT_SENSOR_HPP_
3 
4 #include <geotypes.hpp>
5 #include <GmMeta.hpp>
6 
7 #include "GmBufferedSensor.hpp"
8 #include <GmRingBuffer.hpp>
9 #include <GmManagedRingBuffer.hpp>
10 #include <GmChildRingBuffer.hpp>
11 
12 #ifndef GMMFAMDATA_HPP_
13 #include <GmMfamData.hpp>
14 #endif
15 
16 
17 //#define COUNT_APP_EVENT_BUFFERS 20
18 // Date size should align to 32-bit boundary.
19 #define MAX_APP_EVENT_DATA_SIZE 64
20 
21 // Error codes.
22 // As with all sensors, the base success code is
23 // GM_SENSOR_OK, defined in the base CSensor header.
24 #define GM_APP_EVENT_FAILED_INIT 1
25 #define GM_APP_EVENT_FAILED 2
26 
27 // =========================================================== //
28 // Event types.
29 // =========================================================== //
30 
31 
32 namespace Geometrics
33 {
34  PACKED_PRAGMA
35  typedef struct PACKED_SPEC _AppEvent
36  {
37  _AppEvent (UInt32 uiEventCode,
38  UInt32 uiEventInfo,
39  UInt32 uiDataLength,
40  const char *caData);
41  _AppEvent () {};
42  UInt32 m_uiEventCode; // Offset 0, size 4
43  UInt32 m_uiEventInfo; // Offset 4, size 4
44  UInt32 m_uiDataLength; // Offset 8, size 4
45  char m_caData[MAX_APP_EVENT_DATA_SIZE]; // Offset 12, size 64, total size 76
46  } GmAppEvent ALIGN_4_SPEC ;
47 
48  PACKED_PRAGMA
49  typedef struct PACKED_SPEC _IndexedAppEvent
50  {
51  public:
52  _IndexedAppEvent (uint64_t uiIndex,
53  UInt32 uiEventCode,
54  UInt32 uiEventInfo,
55  UInt32 uiDataLength,
56  const char *caData);
57  _IndexedAppEvent () {};
58  GmAppEvent m_eEvent; // Offset 0, size 76
59  uint64_t m_uiIndex; // Offset 76, size 8, total record size 84
60  } IndexedAppEvent ALIGN_4_SPEC ;
61 
62  PACKED_PRAGMA
63  typedef struct PACKED_SPEC _TypedAppEvent
64  {
65  public:
66  int m_iRecordType; // Offset 0 - always GM_EVENT_FORMAT_BINARY_STORED
67  int m_iRecordSize; // Offset 4 - size of this structure.
68  IndexedAppEvent m_event; // Offset 8, size 84, total size 92.
69  } TypedAppEvent ALIGN_4_SPEC ;
70 
71  PACKED_PRAGMA
72  typedef struct PACKED_SPEC _DatasetAppEvent
73  {
74  public:
75  _DatasetAppEvent (int iDataset,
76  uint64_t uiIndex,
77  UInt32 uiEventCode,
78  UInt32 uiEventInfo,
79  UInt32 uiDataLength,
80  char *caData);
81  _DatasetAppEvent () {};
82  int mDataset;
83  IndexedAppEvent m_event; // Offset 4, size 84, total size 88.
84  } DatasetAppEvent ALIGN_4_SPEC;
85 
86 
87  #if defined(acs) || defined (linux)
88 
89  /**************************************************************************/
90  /* The default for GmAppEventSource is that all data is contained in the */
91  /* event structure, i.e. no pointers to allocations. */
92  /* If new application event types allocation information, then either */
93  /* this class becomes aware of it, or callers don't call DeleteNext */
94  /* and manage the memory carefully. */
95  /**************************************************************************/
97  {
98  public:
99  GmAppEventSource (UInt8 iSubjectId,
101  int Initialize ();
102  void ReadDataInternal ();
103 
104  int AddEvent (UInt32 uiEventCode,
105  UInt32 uiEventInfo,
106  UInt32 uiDataLength,
107  const char *caData);
108  int WriteToStorage (UInt32 ui32Topic,
109  char *pData,
110  UInt32 iSize,
111  GmStorage *psStorage,
112  UInt32 ui32FormatId);
113 
114  };
115  #endif
116 }
117 
118 #endif
Definition: GmAppEvent.hpp:97
int WriteToStorage(UInt32 ui32Topic, char *pData, UInt32 iSize, GmStorage *psStorage, UInt32 ui32FormatId)
Definition: GmAppEvent.cpp:107
The class from which event sources and sensors that post events to the application's main event queue...
Definition: GmBufferedSensor.hpp:18
Definition: GmStorage.hpp:81
GmApp/GmLoggingApp.hpp>
Definition: Analogs.hpp:47
Definition: GmAppEvent.hpp:36
Definition: GmAppEvent.hpp:73
Definition: GmAppEvent.hpp:50
Definition: GmAppEvent.hpp:64