LOGGER
Logger
Data Logging using ESP8266
|
#include <arduino.h>
#include <Time.h>
#include "dataservices.h"
#include "consoleio.h"
#include "flashservices.h"
#include "huzzahpins.h"
#include "sensorlibrary.h"
#include "services.h"
#include "sleepservices.h"
#include "timeservices.h"
#include "webservices.h"
Classes | |
struct | ConfigurationInfo_t |
Configuration information stored at the beginning of the database. More... | |
Macros | |
#define | dataservicesEdit 1 |
version of this module | |
#define | DATABASE_MAJOR_VERSION 1 |
Major version of the database. | |
#define | DATABASE_MINOR_VERSION 1 |
Minor version of the database. | |
Functions | |
EXTERNDEF void | dataservicesInit () |
Initialize the data services, call once at system startup. | |
EXTERNDEF void | dataservicesLogElement (LogElement_t &element, time_t sampleTime, uint32_t msSinceBoot) |
EXTERNDEF bool | dataservicesReadElement (time_t sampleTime, LogElement_t *pElement, time_t *pTimeError) |
EXTERNDEF void | dataservicesDumpElement (Print *pPrint, uint8_t indent, LogElement_t &element, FormatType_t formatType, bool reportDelta, SensorDatatypeID_t datatype) |
EXTERNDEF void | dataservicesDump (Print *pPrinter, bool formatForWeb) |
EXTERNDEF void | dataservicesDumpTemporaries (uint8_t maxElements) |
EXTERNDEF void | dataservicesDumpDatabase (time_t timeToStart, uint8_t maxElements) |
EXTERNDEF void | dataservicesDumpNthElement (Print *pPrinter, uint32_t index) |
EXTERNDEF void | dataservicesDumpElementAtUnixTime (Print *pPrinter, uint8_t indent, time_t elementTime, FormatType_t formatType) |
EXTERNDEF void | dataservicesReadConfiguration () |
Read the configuration information from the flash storage. | |
EXTERNDEF void | dataservicesInitialize () |
EXTERNDEF void | dataservicesDumpConfiguration () |
Dump the configuration information. | |
EXTERNDEF void | dataservicesLoop () |
EXTERNDEF time_t | dataservicesFirstLegalTime () |
time_t | dataservicesLatestLegalTime () |
Variables | |
EXTERNVAR uint32_t | secondsBetweenSamples |
Data logging and reporting services.
EXTERNDEF 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 |
EXTERNDEF 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 |
EXTERNDEF 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 |
EXTERNDEF 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 |
EXTERNDEF void dataservicesDumpNthElement | ( | Print * | pPrinter, |
uint32_t | index | ||
) |
Report the Nth database element
pPrinter | where to print to |
index | element to report |
EXTERNDEF void dataservicesDumpTemporaries | ( | uint8_t | maxElements | ) |
Report the temporary elements
maxElements | maximum number of elements to print |
EXTERNDEF time_t dataservicesFirstLegalTime | ( | ) |
Get the first legal time in the database
EXTERNDEF 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
EXTERNDEF 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 |
EXTERNDEF void dataservicesLoop | ( | ) |
Perform periodic tasks managing data services. Call frequently as the system runs. Does not block.
EXTERNDEF 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 |
EXTERNVAR uint32_t secondsBetweenSamples |
Time between samples stored in the database. As read from the configuration data at the beginning of the database.