LRAUV  revA
LinearApproximationLogWriter.h
Go to the documentation of this file.
1 
10 #ifndef LINEARAPPROXIMATIONLOGWRITER_H_
11 #define LINEARAPPROXIMATIONLOGWRITER_H_
12 
13 #include "logger/TableLogWriter.h"
14 
15 #include "logger/EventEntry.h"
16 #include "logger/Logger.h"
17 #include "utils/FlexArray.h"
18 
19 class DataAccess;
20 class DataEntry;
21 class DataValue;
22 class ElementURI;
23 class LogEntry;
24 
43 {
44 public:
45 
46  LinearApproximationLogWriter( LogWriter* outputTo, int varCount, char** varList, char** unitList, float* approxErrors, bool sendAtStartCycle, bool makeDirEntries = false );
47 
49 
50  virtual unsigned int writeHeader();
51 
53  virtual void endCycle()
54  {
56  }
57 
59  virtual void config( Logger& logger )
60  {
61  outputTo_->config( logger );
62  }
63 
64  virtual unsigned int writeFooter();
65 
66  void resetDirectoryEntries();
67 
68  unsigned int forceWrite( DataEntry* dataEntry );
69 
70  unsigned int forceWriteRow();
71 
72 
73 private:
74  // Note that the copy constructor below is private and not given a body.
75  // Any attempt to call it will return a compiler error.
76  LinearApproximationLogWriter( const LinearApproximationLogWriter& old ); // disallow copy constructor
77 
78  friend class Supervisor;
79 
80  // An instance of VarData is created for each variable being filtered.
81  class VarData
82  {
83  public:
84  VarData( const DataEntry* startEntry, float approxError );
85  ~VarData();
86 
88  {
89  return dataEntry_;
90  }
91 
92  float getDeltaT( const Timestamp timestamp );
93 
94  void advance();
95 
96  // Returns whether due to deliver next output
97  bool checkNextEntry( const DataEntry* nextEntry );
98 
99  bool isReady()
100  {
101  return ready_;
102  }
103 
104  bool wasNaN()
105  {
106  return wasNaN_;
107  }
108 
109  private:
110  // Note that the copy constructor below is private and not given a body.
111  // Any attempt to call it will return a compiler error.
112  VarData( const VarData& old ); // disallow copy constructor
113 
116  const Unit& unit_;
120  double startValue_;
121  double endValue_;
122  double nextValue_;
126  bool ready_;
127  bool wasNaN_;
128  };
129 
130 
131  void preInitialize();
132 
133  virtual unsigned int writeToColumn( const DataEntry *dataEntry, const int column );
134  virtual unsigned int writeRow();
135  virtual unsigned int writeSyslog( const SyslogEntry* syslogEntry );
136 
137  unsigned int sendOutput( DataEntry* dataEntry, int varIndex );
138 
142 
144 
151 
152 };
153 
154 #endif /*LINEARAPPROXIMATIONLOGWRITER_H_*/
Client-side interface for injecting log data into the log queue.
Definition: Logger.h:30
bool wasNaN_
Definition: LinearApproximationLogWriter.h:127
DataAccess ** dataAccesses_
Definition: LinearApproximationLogWriter.h:147
DataValue * dataValue_
Definition: LinearApproximationLogWriter.h:115
void preInitialize()
Definition: LinearApproximationLogWriter.cpp:43
virtual unsigned int writeRow()
Definition: LinearApproximationLogWriter.cpp:118
Serializable representation of DataAccessor object.
Definition: DataAccess.h:30
Timestamp nextTime_
Definition: LinearApproximationLogWriter.h:125
~VarData()
Definition: LinearApproximationLogWriter.cpp:320
bool ready_
Definition: LinearApproximationLogWriter.h:126
Definition: LinearApproximationLogWriter.h:81
Base class for a generalized set of "log data destinations," including to files (text or binary)...
Definition: LogWriter.h:25
bool * dataAccessHidden_
Definition: LinearApproximationLogWriter.h:148
FlexArray< int * > forceWrites_
Definition: LinearApproximationLogWriter.h:146
EventEntry cycleStartEntry_
Definition: LinearApproximationLogWriter.h:150
virtual void endCycle()
Do what needs to be done at the end of the cycle.
Definition: LinearApproximationLogWriter.h:53
float maxLowerSlope_
Definition: LinearApproximationLogWriter.h:119
float getDeltaT(const Timestamp timestamp)
Definition: LinearApproximationLogWriter.cpp:328
Defines a LogWriter that can perform lossy decimation on a stream of DataEntries, by outputting value...
Definition: LinearApproximationLogWriter.h:42
virtual void endCycle()
Do what needs to be done at the end of the cycle.
Definition: LogWriter.h:70
virtual unsigned int writeToColumn(const DataEntry *dataEntry, const int column)
Definition: LinearApproximationLogWriter.cpp:84
void advance()
Definition: LinearApproximationLogWriter.cpp:333
float minUpperSlope_
Definition: LinearApproximationLogWriter.h:118
LinearApproximationLogWriter(LogWriter *outputTo, int varCount, char **varList, char **unitList, float *approxErrors, bool sendAtStartCycle, bool makeDirEntries=false)
Definition: LinearApproximationLogWriter.cpp:27
DataEntry * getDataEntry()
Definition: LinearApproximationLogWriter.h:87
virtual unsigned int writeSyslog(const SyslogEntry *syslogEntry)
Definition: LinearApproximationLogWriter.cpp:134
A DataValue is an abstract base class for a data value and associated engineering units of the value...
Definition: DataValue.h:35
Timestamp startTime_
Definition: LinearApproximationLogWriter.h:123
virtual unsigned int writeHeader()
Write the log header, if any.
Definition: LinearApproximationLogWriter.cpp:79
double nextValue_
Definition: LinearApproximationLogWriter.h:122
virtual void config(Logger &logger)
Configure from a config file.
Definition: LogWriter.h:79
float * approxErrors_
Definition: LinearApproximationLogWriter.h:139
virtual void config(Logger &logger)
Configure from a config file.
Definition: LinearApproximationLogWriter.h:59
One "entry" in a LogQueue.
Definition: LogEntry.h:33
LogEntry with information specific to "Syslog"-like text logs.
Definition: SyslogEntry.h:54
Contains the FlexArrayBase and FlexArray class declarations.
double startValue_
Definition: LinearApproximationLogWriter.h:120
Timestamp endTime_
Definition: LinearApproximationLogWriter.h:124
unsigned int forceWriteRow()
Definition: LinearApproximationLogWriter.cpp:262
VarData(const DataEntry *startEntry, float approxError)
Definition: LinearApproximationLogWriter.cpp:300
LinearApproximationLogWriter::VarData ** varData_
Definition: LinearApproximationLogWriter.h:143
const Unit & unit_
Definition: LinearApproximationLogWriter.h:116
Code unit that represents an atomic unit of data destined for writing in the log file.
Definition: DataEntry.h:43
bool sendAtStartCycle_
Definition: LinearApproximationLogWriter.h:140
bool checkNextEntry(const DataEntry *nextEntry)
Definition: LinearApproximationLogWriter.cpp:346
DataEntry * dataEntry_
Definition: LinearApproximationLogWriter.h:114
FlexArray< int * > nameWrites_
Definition: LinearApproximationLogWriter.h:145
Defines a LogWriter that generates a text table of values.
Definition: TableLogWriter.h:31
double endValue_
Definition: LinearApproximationLogWriter.h:121
Code unit that represents an event to be stored in the log file.
Definition: EventEntry.h:53
float approxError_
Definition: LinearApproximationLogWriter.h:117
virtual ~LinearApproximationLogWriter()
Definition: LinearApproximationLogWriter.cpp:53
Contains the Logger class definition.
unsigned int sendOutput(DataEntry *dataEntry, int varIndex)
Definition: LinearApproximationLogWriter.cpp:190
bool wasNaN()
Definition: LinearApproximationLogWriter.h:104
bool makeDirEntries_
Definition: LinearApproximationLogWriter.h:141
virtual unsigned int writeFooter()
Write the log footer, if any.
Definition: LinearApproximationLogWriter.cpp:257
void resetDirectoryEntries()
Definition: LinearApproximationLogWriter.cpp:280
unsigned int forceWrite(DataEntry *dataEntry)
Definition: LinearApproximationLogWriter.cpp:154
Code unit that represents a unique name for a DataElement.
Definition: ElementURI.h:27
LogWriter * outputTo_
Definition: TableLogWriter.h:74
The supervisor is the "main" component in the vehicle software.
Definition: Supervisor.h:65
bool isReady()
Definition: LinearApproximationLogWriter.h:99
Code that represents an engineering unit.
Definition: Unit.h:24
bool recentOutput_
Definition: LinearApproximationLogWriter.h:149
Represents absolute times.
Definition: Timestamp.h:31
Contains the EventEntry class definition.
Contains the TableLogWriter class definition.