LRAUV  revA
EventEntry.h
Go to the documentation of this file.
1 
10 #ifndef EVENTENTRY_H_
11 #define EVENTENTRY_H_
12 
13 #include "LogEntry.h"
14 
15 #include "component/FailureMode.h"
16 
17 class Component;
18 class DataElement;
19 class RingBufferVoid;
20 
53 class EventEntry : public LogEntry
54 {
55 public:
56 
58  typedef enum
59  {
61  SET_DATA_ACCURACY = 1 << 2,
62  SET_DATA_STATE = 2 << 2,
63  COMPONENT_ACTION = 3 << 2,
64  } EventType;
65  static const int EVENT_TYPE_MASK = 3 << 2;
66 
67  typedef enum
68  {
78 
80  typedef enum
81  {
84  COMPONENT_FAIL = 2 << 2,
86  static const int COMPONENT_ACTION_MASK = 3 << 2;
87 
89  EventEntry( Component* actor,
90  DataElement* dataElement,
91  const EventType eventType );
92 
94  EventEntry( Component* actor,
95  DataElement* dataElement,
96  const DataStateChange dataStateChange );
97 
99  EventEntry( Component* actor,
100  const bool loaded );
101 
103  EventEntry( Component* actor,
104  const int loop );
105 
107  EventEntry( Component* actor,
108  const FailureMode::FailType failure,
109  const int failCount );
110 
112  virtual ~EventEntry();
113 
115  void* operator new( size_t size );
116 
118  void operator delete( void* p );
119 
120  const void setAccuracy( const double& accuracy )
121  {
122  accuracy_ = accuracy;
123  }
124 
125  const double& getAccuracy( void ) const
126  {
127  return accuracy_;
128  }
129 
135  static EventEntry* Read( Timestamp& timeBase, Timespan& timeAdjust, InStream &inStream, unsigned short firstWord, Logger& logger );
136 
142  virtual unsigned int write( Timestamp& timeBase, OutStream& logStream ) const;
143 
144  virtual Str toString( const Unit* unit = NULL ) const;
145 
147  static const char* EventTypeToString( EventType theAction );
148 
150  static const char* StateChangeToString( DataStateChange dataStateChange );
151 
152  unsigned short getActorCode() const
153  {
154  return actorCode_;
155  }
156 
158  {
159  return componentAction_;
160  }
161 
162  unsigned short getDataElementCode( void ) const
163  {
164  return dataElementCode_;
165  }
166 
167  EventType getEventType( void ) const
168  {
169  return eventType_;
170  }
171 
173  {
174  return dataStateChange_;
175  }
176 
177  void setDataStateChange( const DataStateChange dataStateChange )
178  {
179  dataStateChange_ = dataStateChange;
180  }
181 
182  int getRunLoop() const
183  {
184  return runLoop_;
185  }
186 
187  bool getLoaded() const
188  {
189  return loaded_;
190  }
191 
193  {
194  return failureMode_;
195  }
196 
197  int getFailCount() const
198  {
199  return failCount_;
200  }
201 
202 protected:
203 
205  EventEntry( const Timestamp& timestamp,
206  const unsigned short actorCode, // Arg1
207  const unsigned short dataElementCode, // Arg2
208  const EventType action, // Arg3
209  const double& accuracy = 0.0 ); // Arg5
210 
212  EventEntry( const Timestamp& timestamp,
213  const unsigned short actorCode, // Arg1
214  const unsigned short dataElementCode, // Arg2
215  const DataStateChange dataStateChange, // Arg4
216  const double& accuracy = 0.0 ); // Arg5
217 
219  EventEntry( const Timestamp& timestamp,
220  const unsigned short actorCode, // Arg1
221  const bool loaded ); // Arg2
222 
224  EventEntry( const Timestamp& timestamp,
225  const unsigned short actorCode, // Arg1
226  const int loop ); // Arg2
227 
229  EventEntry( const Timestamp& timestamp,
230  const unsigned short actorCode, // Arg1
231  const FailureMode::FailType failure, // Arg2
232  const int failCount ); // Arg5
233 
235  unsigned short actorCode_;
236 
238  union
239  {
240  unsigned short dataElementCode_;
241  bool loaded_;
242  int runLoop_;
244  };
245 
248 
250  union
251  {
254  };
255 
257  union
258  {
259  double accuracy_;
261  };
262 
263  virtual const Str makeComponentActionString() const;
264 
265  virtual const Str makeDataValueString() const;
266 
269 
272  {
273  public:
275  };
276 
279 
280 };
281 
282 #endif /*EVENTENTRY_H_*/
Client-side interface for injecting log data into the log queue.
Definition: Logger.h:30
int failCount_
Definition: EventEntry.h:260
static const int COMPONENT_ACTION_MASK
Definition: EventEntry.h:86
unsigned short dataElementCode_
Definition: EventEntry.h:240
FailureMode::FailType getFailureMode() const
Definition: EventEntry.h:192
Definition: EventEntry.h:74
virtual ~EventEntry()
Destructor.
Definition: EventEntry.cpp:84
int getRunLoop() const
Definition: EventEntry.h:182
static const int EVENT_TYPE_MASK
Definition: EventEntry.h:65
virtual const Str makeDataValueString() const
Definition: EventEntry.cpp:363
virtual const Str makeComponentActionString() const
Definition: EventEntry.cpp:348
static const char * StateChangeToString(DataStateChange dataStateChange)
Convert actions to Strs.
Definition: EventEntry.cpp:394
Definition: EventEntry.h:82
EventType
Type of data event.
Definition: EventEntry.h:58
Timespan class, represents a delta of time.
Definition: Timestamp.h:248
Change of Data Accuracy.
Definition: EventEntry.h:62
unsigned short actorCode_
Arg1.
Definition: EventEntry.h:235
int getFailCount() const
Definition: EventEntry.h:197
static RingBufferVoid * MallocRing_
Declared as a pointer to avoid including RingBuffer.h header here.
Definition: EventEntry.h:268
This is a very abstract class that can be implemented by classes that want to receive stream input...
Definition: InStream.h:29
Definition: EventEntry.h:76
One "entry" in a LogQueue.
Definition: LogEntry.h:33
static EventEntry::StaticDestructor StaticDestructor_
Static instance of StaticDestructor.
Definition: EventEntry.h:278
FailType
Components can fail in a variety of ways.
Definition: FailureMode.h:19
Contains the LogEntry class definition.
Start of a cycle.
Definition: EventEntry.h:61
Definition: EventEntry.h:60
DataStateChange dataStateChange_
Definition: EventEntry.h:252
bool loaded_
Definition: EventEntry.h:241
FailureMode::FailType failureMode_
Definition: EventEntry.h:243
EventType getEventType(void) const
Definition: EventEntry.h:167
EventEntry(Component *actor, DataElement *dataElement, const EventType eventType)
EventType Constructor.
Definition: EventEntry.cpp:27
Followed by boolean true or false to indicate load/unload.
Definition: EventEntry.h:83
virtual unsigned int write(Timestamp &timeBase, OutStream &logStream) const
Send payload to a stream.
Definition: EventEntry.cpp:234
Replacement for standard template class string.
Definition: Str.h:12
~StaticDestructor()
Definition: EventEntry.cpp:20
virtual Str toString(const Unit *unit=NULL) const
Convert payload to Str.
Definition: EventEntry.cpp:300
Abstract Base class for software components.
Definition: Component.h:53
static EventEntry * Read(Timestamp &timeBase, Timespan &timeAdjust, InStream &inStream, unsigned short firstWord, Logger &logger)
Read new EventEntry from a stream.
Definition: EventEntry.cpp:116
Code unit that represents an event to be stored in the log file.
Definition: EventEntry.h:53
const double & getAccuracy(void) const
Definition: EventEntry.h:125
EventType eventType_
Arg3.
Definition: EventEntry.h:247
unsigned short getActorCode() const
Definition: EventEntry.h:152
ComponentAction getComponentAction(void) const
Definition: EventEntry.h:157
Followed by 0=done, positive=loop#, negative=preempted in loop#.
Definition: EventEntry.h:84
Definition: EventEntry.h:69
Definition: EventEntry.h:71
Indicate change to/from best, failed, orphaned, etc.
Definition: EventEntry.h:63
Definition: EventEntry.h:72
bool getLoaded() const
Definition: EventEntry.h:187
const void setAccuracy(const double &accuracy)
Definition: EventEntry.h:120
Contains the FailureMode class definition.
Indicate change to the "best" of associated universal.
Definition: EventEntry.h:75
This is a very abstract class that can be implemented by classes that want to send stream output...
Definition: OutStream.h:41
static const char * EventTypeToString(EventType theAction)
Convert actions to Strs.
Definition: EventEntry.cpp:377
DataStateChange getDataStateChange(void) const
Definition: EventEntry.h:172
Definition: EventEntry.h:73
Thread-safe ring buffer for storing void pointers.
Definition: RingBuffer.h:36
void setDataStateChange(const DataStateChange dataStateChange)
Definition: EventEntry.h:177
unsigned short getDataElementCode(void) const
Definition: EventEntry.h:162
DataStateChange
Definition: EventEntry.h:67
Makes sure that mallocRing_s is deleted on shutdown.
Definition: EventEntry.h:271
Code that represents an engineering unit.
Definition: Unit.h:24
double accuracy_
Definition: EventEntry.h:259
int runLoop_
Definition: EventEntry.h:242
Represents absolute times.
Definition: Timestamp.h:31
ComponentAction componentAction_
Definition: EventEntry.h:253
Abstact base class for one "element" of the Slate.
Definition: DataElement.h:37
ComponentAction
Type of component event.
Definition: EventEntry.h:80