LRAUV  revA
LinearApproxLogWriter.h
Go to the documentation of this file.
1 
10 #ifndef LINEARAPPROXLOGWRITER_H_
11 #define LINEARAPPROXLOGWRITER_H_
12 
13 #include "logger/EventEntry.h"
14 #include "logger/Logger.h"
16 #include "utils/FlexArray.h"
17 
18 class DataEntry;
19 class DataValue;
20 class ElementURI;
21 class LogEntry;
22 class SyslogEntry;
23 
42 {
43 public:
44 
45  LinearApproxLogWriter( LogWriter& outputTo, const Str& varName, DataValue* approxErrorValue,
46  bool makeDirEntries, Logger& logger );
47 
48  virtual ~LinearApproxLogWriter();
49 
51  virtual unsigned int write( const LogEntry *entry, const Unit* unit = NULL );
52 
53  virtual unsigned int writeHeader();
54 
56  virtual void endCycle()
57  {
59  }
60 
62  virtual void config( Logger& logger )
63  {
64  outputTo_.config( logger );
65  }
66 
67  virtual unsigned int writeFooter();
68 
69  virtual void setParameter( DataValue* approxError, Logger& logger );
70 
71  virtual unsigned int flush();
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  LinearApproxLogWriter( const LinearApproxLogWriter& old ); // disallow copy constructor
77 
78  friend class Supervisor;
79 
80  class VarData
81  {
82  public:
83  VarData( const DataEntry* startEntry, float approxError );
84  ~VarData();
85 
87  {
88  return dataEntry_;
89  }
90 
91  float getDeltaT( const Timestamp timestamp );
92 
93  void advance();
94 
95  // Returns whether due to deliver next output
96  bool checkNextEntry( const DataEntry* nextEntry );
97 
98  bool isReady()
99  {
100  return ready_;
101  }
102 
103  bool wasNaN()
104  {
105  return wasNaN_;
106  }
107 
109  {
110  return approxError_;
111  }
112 
113  void setApproxError( float approxError )
114  {
115  approxError_ = approxError;
116  }
117 
118  bool flushed()
119  {
120  return startTime_ == endTime_ && endTime_ == nextTime_;
121  }
122 
123  private:
124  // Note that the copy constructor below is private and not given a body.
125  // Any attempt to call it will return a compiler error.
126  VarData( const VarData& old ); // disallow copy constructor
127 
130  const Unit& unit_;
134  double startValue_;
135  double endValue_;
136  double nextValue_;
140  bool ready_;
141  bool wasNaN_;
142  };
143 
144  unsigned int sendOutput( DataEntry* dataEntry );
145 
146  const Str varName_;
148 
150 
153 
154 };
155 
156 #endif /*LINEARAPPROXLOGWRITER_H_*/
Client-side interface for injecting log data into the log queue.
Definition: Logger.h:30
EventEntry cycleStartEntry_
Definition: LinearApproxLogWriter.h:151
Contains the DecimationLogWriter class definition.
DataEntry * dataEntry_
Definition: LinearApproxLogWriter.h:128
LinearApproxLogWriter::VarData * varData_
Definition: LinearApproxLogWriter.h:149
Base class for a generalized set of "log data destinations," including to files (text or binary)...
Definition: LogWriter.h:25
bool wasNaN()
Definition: LinearApproxLogWriter.h:103
const Unit & unit_
Definition: LinearApproxLogWriter.h:130
double endValue_
Definition: LinearApproxLogWriter.h:135
unsigned int sendOutput(DataEntry *dataEntry)
Definition: LinearApproxLogWriter.cpp:98
virtual void endCycle()
Do what needs to be done at the end of the cycle.
Definition: LogWriter.h:70
DataValue * approxErrorValue_
Definition: LinearApproxLogWriter.h:147
virtual void config(Logger &logger)
Configure from a config file.
Definition: LinearApproxLogWriter.h:62
bool ready_
Definition: LinearApproxLogWriter.h:140
void advance()
Definition: LinearApproxLogWriter.cpp:184
Timestamp startTime_
Definition: LinearApproxLogWriter.h:137
A DataValue is an abstract base class for a data value and associated engineering units of the value...
Definition: DataValue.h:35
virtual void config(Logger &logger)
Configure from a config file.
Definition: LogWriter.h:79
Base class for a generalized set of "log data destinations," including to files (text or binary)...
Definition: DecimationLogWriter.h:22
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.
float maxLowerSlope_
Definition: LinearApproxLogWriter.h:133
virtual void setParameter(DataValue *approxError, Logger &logger)
Definition: LinearApproxLogWriter.cpp:111
LogWriter & outputTo_
Stores an LogWriter.
Definition: DecimationLogWriter.h:71
float approxError_
Definition: LinearApproxLogWriter.h:131
Code unit that represents an atomic unit of data destined for writing in the log file.
Definition: DataEntry.h:43
virtual unsigned int writeHeader()
Write the log header, if any.
Definition: LinearApproxLogWriter.cpp:56
virtual ~LinearApproxLogWriter()
Definition: LinearApproxLogWriter.cpp:41
VarData(const DataEntry *startEntry, float approxError)
Definition: LinearApproxLogWriter.cpp:151
float getApproxError()
Definition: LinearApproxLogWriter.h:108
bool isReady()
Definition: LinearApproxLogWriter.h:98
double startValue_
Definition: LinearApproxLogWriter.h:134
Replacement for standard template class string.
Definition: Str.h:12
~VarData()
Definition: LinearApproxLogWriter.cpp:171
virtual void endCycle()
Do what needs to be done at the end of the cycle.
Definition: LinearApproxLogWriter.h:56
bool flushed()
Definition: LinearApproxLogWriter.h:118
const Str varName_
Definition: LinearApproxLogWriter.h:146
Definition: LinearApproxLogWriter.h:80
Code unit that represents an event to be stored in the log file.
Definition: EventEntry.h:53
float minUpperSlope_
Definition: LinearApproxLogWriter.h:132
bool checkNextEntry(const DataEntry *nextEntry)
Definition: LinearApproxLogWriter.cpp:197
float getDeltaT(const Timestamp timestamp)
Definition: LinearApproxLogWriter.cpp:179
Contains the Logger class definition.
Timestamp lastTime_
Definition: LinearApproxLogWriter.h:152
bool wasNaN_
Definition: LinearApproxLogWriter.h:141
void setApproxError(float approxError)
Definition: LinearApproxLogWriter.h:113
virtual unsigned int flush()
Definition: LinearApproxLogWriter.cpp:138
Code unit that represents a unique name for a DataElement.
Definition: ElementURI.h:27
double nextValue_
Definition: LinearApproxLogWriter.h:136
DataEntry * getDataEntry()
Definition: LinearApproxLogWriter.h:86
The supervisor is the "main" component in the vehicle software.
Definition: Supervisor.h:65
LinearApproxLogWriter(LogWriter &outputTo, const Str &varName, DataValue *approxErrorValue, bool makeDirEntries, Logger &logger)
Definition: LinearApproxLogWriter.cpp:26
Timestamp endTime_
Definition: LinearApproxLogWriter.h:138
Code that represents an engineering unit.
Definition: Unit.h:24
virtual unsigned int write(const LogEntry *entry, const Unit *unit=NULL)
Write an entry to the text log.
Definition: LinearApproxLogWriter.cpp:61
Defines a LogWriter that can perform lossy decimation on a stream of DataEntries, by outputting value...
Definition: LinearApproxLogWriter.h:41
virtual unsigned int writeFooter()
Write the log footer, if any.
Definition: LinearApproxLogWriter.cpp:106
Represents absolute times.
Definition: Timestamp.h:31
Contains the EventEntry class definition.
Timestamp nextTime_
Definition: LinearApproxLogWriter.h:139
DataValue * dataValue_
Definition: LinearApproxLogWriter.h:129