LogBuffer class
This class buffers logged timestamps and variable values for transmission. The log is divided into a number of records. Each record stores the timestamp of the record as a uint32_t, then the value of each variable as a float at that time.
- Reference
- Detailed Descriptions
Constructors, destructors, conversion operators
- LogBuffer()
- Constructs a new empty buffer which stores no variables or values.
- ~LogBuffer() virtual
- Destroys the buffer.
Public functions
- void setNumVariables(uint8_t numVariables_)
- Sets the number of variables the buffer will store in each record. Clears the buffer as a side effect.
- uint8_t getNumVariables(void) -> uint8_t
- Gets the number of variables that will be stored in each record.
- void clear(void)
- Clears all records from the log.
- int getNumRecords(void) -> int
- Gets the number of records currently in the log.
- uint8_t getPercentFull(void) -> uint8_t
- Computes the percentage full of the buffer.
- int addRecord(uint32_t timestamp) -> int
- Adds a new record with the given timestamp.
- void setRecordValue(int record, uint8_t variable, float value)
- Sets the value of a particular variable in a particular record.
- uint32_t getRecordTimestamp(int record) -> uint32_t
- Gets the timestamp of a particular record.
- float getRecordValue(int record, uint8_t variable) -> float
- Gets the value of a particular variable in a particular record.
Protected variables
- uint8_t dataBuffer
- Buffer which stores the log data.
- uint16_t dataBufferTail
- Index of buffer head.
- uint16_t dataBufferHead
- Index of buffer tail.
- bool _bufferOverflow
- The buffer overflow status.
- int numRecords
- Number of records currently in the buffer.
- size_t recordSize
- Size in bytes of each record in the buffer.
- uint8_t numVariables
- Number of variables stored in each record in the buffer.
Function documentation
void LogBuffer:: setNumVariables(uint8_t numVariables_)
Sets the number of variables the buffer will store in each record. Clears the buffer as a side effect.
Parameters | |
---|---|
numVariables_ | The number of variables to store. |
uint8_t LogBuffer:: getNumVariables(void)
Gets the number of variables that will be stored in each record.
Returns | uint8_t The variable count. |
---|
int LogBuffer:: getNumRecords(void)
Gets the number of records currently in the log.
Returns | int The number of records. |
---|
uint8_t LogBuffer:: getPercentFull(void)
Computes the percentage full of the buffer.
Returns | uint8_t The current percent full. |
---|
int LogBuffer:: addRecord(uint32_t timestamp)
Adds a new record with the given timestamp.
Parameters | |
---|---|
timestamp | The timestamp |
Returns | int Index of the new record, or -1 if there was no space. |
void LogBuffer:: setRecordValue(int record,
uint8_t variable,
float value)
Sets the value of a particular variable in a particular record.
Parameters | |
---|---|
record | The record |
variable | The variable |
value | The value |
uint32_t LogBuffer:: getRecordTimestamp(int record)
Gets the timestamp of a particular record.
Parameters | |
---|---|
record | The record |
Returns | uint32_t The record's timestamp. |
float LogBuffer:: getRecordValue(int record,
uint8_t variable)
Gets the value of a particular variable in a particular record.
Parameters | |
---|---|
record | The record |
variable | The variable |
Returns | float The variable's value. |