LOGGER
Logger
Data Logging using ESP8266
|
Go to the source code of this file.
Classes | |
struct | LogElement_t |
Structure that gets logged. More... | |
Macros | |
#define | MAX_SENSORS 30 |
< version of this include file More... | |
Functions | |
void | dataservicesInit () |
Initialize the data services, call once at system startup. | |
void | dataservicesLoop () |
void | dataservicesLogElement (LogElement_t &element, time_t sampleTime, uint32_t msSinceBoot) |
bool | dataservicesReadElement (time_t sampleTime, LogElement_t *pElement, time_t *pTimeError) |
void | dataservicesInitialize () |
void | dataservicesDumpElement (Print *pPrinter, uint8_t indent, LogElement_t &element, FormatType_t formatType, bool reportDelta, SensorDatatypeID_t datatype=SDallTypes) |
void | dataservicesDumpElementIDvalue (Print *pPrinter, uint8_t indent, LogElement_t &element, FormatType_t formatType, SensorDatatypeID_t datatype=SDallTypes) |
void | dataservicesDump (Print *pPrinter, bool formatForWeb) |
void | dataservicesDumpTemporaries (uint8_t maxElements) |
void | dataservicesDumpDatabase (time_t timeToStart, uint8_t maxElements) |
void | dataservicesDumpNthElement (Print *pPrinter, uint32_t index) |
void | dataservicesDumpElementAtUnixTime (Print *pPrinter, uint8_t indent, time_t elementTime, FormatType_t formatType) |
void | dataservicesReadConfiguration () |
Read the configuration information from the flash storage. | |
void | dataservicesDumpConfiguration () |
Dump the configuration information. | |
time_t | dataservicesFirstLegalTime () |
time_t | dataservicesLatestLegalTime () |
Variables | |
uint32_t | secondsBetweenSamples |
Data logging and reporting service routines.
This module is responsible for storing and retrieving data. It also is responsible for time keeping on the elements that are stored. The LogElement_t structure is the primitive element that is logged. It comprises one sample of the datums logged for this device. The Sensor class is responsible for how the data is stored in the data block of the LogElement_t structure. (Pin values of the processor are logged in a regular data cell.)
The dataStorage is divided between inputs that come from multiple devices. There are access functions to read and/or set the data storage elements. The configuration of the data storage depends on what devices are attached to the LOGGER. See the Sensor class for a description of what devices are attached.
The data storage model can support appending to a file or simply writing to a NAND flash. There is a tacit assumption that Data stored in flash parts starts as all ones and gets written to zeros. When the data of an element is not valid all of the bits will be on.
There may be intervals when samples have not been taken. The most recent sample taken is copied to each element and samplesSinceValid keeps track of how far it is (in sample intervals not seconds) to get to the most recent sample.
There are 32 bits of overhead. With 30 16 bit samples per element this gives a block size of 64 bytes. On a 32Gigabyte card at one sample per second you get 16 years of data, (less a bit for file system overhead). At one sample every 5 seconds you get 81 years of data.
#define MAX_SENSORS 30 |
< version of this include file
Maximum number of unique sensors that can be stored in the database.
void dataservicesDump | ( | Print * | pPrinter, |
bool | formatForWeb | ||
) |
Report the state of the the dataservices module. When formatting for the web emit fields as rows of a table.
pPrinter | where to print it |
formatForWeb | true to emit web formatting |
void dataservicesDumpDatabase | ( | time_t | timeToStart, |
uint8_t | maxElements | ||
) |
Report the database elements. When a time before the first element in the database is presented start with the first element in the database.
timeToStart | time of first element to dump |
maxElements | maximum number of elements to print |
void dataservicesDumpElement | ( | Print * | pPrinter, |
uint8_t | indent, | ||
LogElement_t & | element, | ||
FormatType_t | formatType, | ||
bool | reportDelta, | ||
SensorDatatypeID_t | datatype = SDallTypes |
||
) |
Convert the value of an element to a string. When formatted for the web the output expects to be emitted in a cell of a table. The
and are not included in the output.
pPrinter | where to print the element |
indent | number of spaces to indent each new line |
element | the element to dump |
formatType | output format type |
reportDelta | true to report time since the sample was taken |
datatype | which members of the element to dump |
void dataservicesDumpElementAtUnixTime | ( | Print * | pPrinter, |
uint8_t | indent, | ||
time_t | elementTime, | ||
FormatType_t | formatType | ||
) |
Convert the value of an element to a string. Emit the time information and the associated value.
pPrinter | where to print the element |
indent | number of spaces to indent each new line |
elementTime | the element to dump |
formatType | output format type |
void dataservicesDumpElementIDvalue | ( | Print * | pPrinter, |
uint8_t | indent, | ||
LogElement_t & | element, | ||
FormatType_t | formatType, | ||
SensorDatatypeID_t | datatype = SDallTypes |
||
) |
Convert the value of an element to a string. Limit what is output for each sensor to the ID and value of that sensor. When formatted for the web the output expects to be emitted in a cell of a table. The
and are not included in the output.
pPrinter | where to print the element |
indent | number of spaces to indent each new line |
element | the element to dump |
formatType | output format type |
datatype | which members of the element to dump |
void dataservicesDumpNthElement | ( | Print * | pPrinter, |
uint32_t | index | ||
) |
Report the Nth database element
pPrinter | where to print to |
index | element to report |
void dataservicesDumpTemporaries | ( | uint8_t | maxElements | ) |
Report the temporary elements
maxElements | maximum number of elements to print |
time_t dataservicesFirstLegalTime | ( | ) |
Get the first legal time in the database
void dataservicesInitialize | ( | ) |
Flush all configuration and logged data. Reset the configuration to the default and start the log.
time_t dataservicesLatestLegalTime | ( | ) |
Get the most recent legal time in the database
void dataservicesLogElement | ( | LogElement_t & | element, |
time_t | sampleTime, | ||
uint32_t | msSinceBoot | ||
) |
Log a set of values. The log is done at the current time.
element | the element to log |
sampleTime | time the sample was taken (0 if unix time is not valid) |
msSinceBoot | ms since boot of when the sample was taken |
void dataservicesLoop | ( | ) |
Perform periodic tasks managing data services. Call frequently as the system runs. Does not block.
bool dataservicesReadElement | ( | time_t | sampleTime, |
LogElement_t * | pElement, | ||
time_t * | pTimeError | ||
) |
Get the value logged at a particular time. Elements for times in the future do not exist. A request for an element prior to the beginning of the entire log will report as not existing.
sampleTime | UNIX time to retrieve from the log |
pElement | pointer to where to store the element |
pTimeError | point to where to store how different the actual sample time is from the requested time |
uint32_t secondsBetweenSamples |
Time between samples stored in the database. As read from the configuration data at the beginning of the database.