LOGGER
Logger
Data Logging using ESP8266
|
#include <arduino.h>
#include "sensorlibrary.h"
#include "dataservices.h"
#include "pincounter.h"
#include "processorsensors.h"
#include "services.h"
Classes | |
class | Sensor |
Macros | |
#define | sensorlibraryEdit 1 |
version of this module | |
Typedefs | |
typedef class Sensor | Sensor_t |
Functions | |
EXTERNDEF void | sensorlibraryInit () |
< version of this module More... | |
EXTERNDEF String | sensorlibraryInterfaceGetName (SensorInterfaceID_t interface) |
EXTERNDEF String | sensorlibrarySensorTypeGetName (SensorTypeID_t sensorType) |
EXTERNDEF void | sensorlibraryDumpSensorName (Print *pPrinter, uint8_t sensorID, FormatType_t formatType) |
EXTERNDEF void | sensorlibraryDumpSensorUniqueID (Print *pPrinter, uint8_t sensorID, FormatType_t formatType) |
EXTERNDEF void | sensorlibraryDumpSensorValue (Print *pPrinter, uint8_t indent, uint32_t value, uint8_t sensorID, FormatType_t formatType) |
EXTERNDEF void | sensorlibraryDumpSensors (Print *pPrinter, FormatType_t formatType) |
EXTERNDEF void | sensorlibraryReadSensors (LogElement_t &element) |
EXTERNDEF void | sensorlibraryDumpElement (Print *pPrinter, uint8_t indent, LogElement_t &element, FormatType_t formatType, SensorDatatypeID_t datatype) |
EXTERNDEF void | sensorlibraryDumpElementIDvalue (Print *pPrinter, uint8_t indent, LogElement_t &element, FormatType_t formatType, SensorDatatypeID_t datatype) |
EXTERNDEF int8_t | sensorlibraryCreateSensor (uint8_t *uniqueID, String name, uint8_t bitsOfData, bool isSigned, SensorInterfaceID_t interface, SensorTypeID_t sensorType, SensorDatatypeID_t datatype, uint8_t decimalPlaces, uint8_t sensorSpecific, pSENSOR_READ_CALLBACK pReader) |
EXTERNDEF void | sensorlibraryDisableSensor (uint8_t sensorID) |
EXTERNDEF uint32_t | sensorlibraryExtractPulseCount (uint8_t index, LogElement_t &element, uint32_t defaultCount) |
EXTERNDEF void | sensorlibraryDumpSampleList (Print *pPrinter, LogElement_t &element, SensorDatatypeID_t datatype) |
EXTERNDEF void | sensorlibrarySetPulsesSinceBoot (LogElement_t &element) |
EXTERNDEF void | sensorlibraryDumpAddColumns (Print *pPrinter, GraphType_t graphType, SensorDatatypeID_t datatype) |
EXTERNDEF String | sensorlibraryGetSensorName (uint8_t sensorID) |
EXTERNDEF void | sensorlibraryDumpSensorById (uint8_t sensorID, Print *pPrinter, FormatType_t formatType) |
EXTERNDEF uint8_t | sensorlibraryGetI2Caddress (uint8_t sensorID) |
EXTERNDEF uint8_t | sensorlibraryGetSensorSpecificData (uint8_t sensorID) |
Variables | |
EXTERNVAR const char *const | datatypeNames [] |
Manage a library of sensors and the instances of those sensors that are observed.
Description of all sensors that have been found.
The unique ID for onewire sensors is the serial number of the device.
EXTERNDEF int8_t sensorlibraryCreateSensor | ( | uint8_t * | uniqueID, |
String | name, | ||
uint8_t | bitsOfData, | ||
bool | isSigned, | ||
SensorInterfaceID_t | interface, | ||
SensorTypeID_t | sensorType, | ||
SensorDatatypeID_t | datatype, | ||
uint8_t | decimalPlaces, | ||
uint8_t | sensorSpecific, | ||
pSENSOR_READ_CALLBACK | pReader | ||
) |
Establish a new sensor in the library.
uniqueID | unique among sensors of the same type |
name | string to emit for people |
bitsOfData | bits in one sample |
isSigned | data is a signed value |
interface | how the sensor is connected |
sensorType | what kind of device provides the sensing |
datatype | type of information that is stored |
decimalPlaces | places for display as a fixed point number |
sensorSpecific | info about this sensor |
pReader | callback to read the sensor |
EXTERNDEF void sensorlibraryDisableSensor | ( | uint8_t | sensorID | ) |
Once a sensor is created it can be turned off. This disables printout of the sensor and is typically used to decomission a sensor that is not available because the hardware is being used for another purpose
EXTERNDEF void sensorlibraryDumpAddColumns | ( | Print * | pPrinter, |
GraphType_t | graphType, | ||
SensorDatatypeID_t | datatype | ||
) |
Dump the addColumn lines for a graph. Lines appropriate to sensors that are intervals can be emitted or lines that are appropriate to sensors that are samples.
??? future enhancements may add other graph types which will need updates to the types of graphs that can be output.
The lines have the form:
data.addColumn('number', 'ADC 0');
pPrinter | where to send the ouput |
graphType | what kind of graph is being emitted |
datatype | type of data elements to put in the list |
EXTERNDEF void sensorlibraryDumpElement | ( | Print * | pPrinter, |
uint8_t | indent, | ||
LogElement_t & | element, | ||
FormatType_t | formatType = FormatForConsole , |
||
SensorDatatypeID_t | datatype = SDallTypes |
||
) |
Print the contents of an element reporting the value logged in the element by the sensorlibraryReadSensors call.
pPrinter | where to sent the output |
indent | indentation for each new line |
element | block of data to work on |
formatType | type of output to do |
datatype | limit output to this datatype |
EXTERNDEF void sensorlibraryDumpElementIDvalue | ( | Print * | pPrinter, |
uint8_t | indent, | ||
LogElement_t & | element, | ||
FormatType_t | formatType = FormatForConsole , |
||
SensorDatatypeID_t | datatype = SDallTypes |
||
) |
Print the contents of an element reporting the value logged in the element by the sensorlibraryReadSensors call. Limit the ouptut of each sensor to the ID and value of that sensor.
pPrinter | where to sent the output |
indent | indentation for each new line |
element | block of data to work on |
formatType | type of output to do |
datatype | limit output to this datatype |
EXTERNDEF void sensorlibraryDumpSampleList | ( | Print * | pPrinter, |
LogElement_t & | element, | ||
SensorDatatypeID_t | datatype = SDallTypes |
||
) |
Print a comma seperated list of sample values. Skip over the pulse counts and pin arrays
pPrinter | where to send the output |
element | element to dump samples from |
datatype | type of data elements to put in the list |
EXTERNDEF void sensorlibraryDumpSensorById | ( | uint8_t | index, |
Print * | pPrinter, | ||
FormatType_t | formatType | ||
) |
Dump a sensor given the ID returned by sensorlibraryCreateSensor.
index | Sensor ID |
pPrinter | where to send the ouput |
formatType | how to format the output |
EXTERNDEF void sensorlibraryDumpSensorName | ( | Print * | pPrinter, |
uint8_t | sensorID, | ||
FormatType_t | formatType = FormatForConsole |
||
) |
Dump the name of a sensor based on the ID index of the sensor determined when the sensor was created with sensorlibraryCreateSensor.
pPrinter | where to sent the output |
sensorID | ID returned by sensorlibraryCreateSensor |
formatType | how to format the output |
EXTERNDEF void sensorlibraryDumpSensors | ( | Print * | pPrinter = &Serial , |
FormatType_t | formatType = FormatForConsole |
||
) |
Dump a list of sensors
pPrinter | printer to use for output |
formatType | type of ouput to emit |
EXTERNDEF void sensorlibraryDumpSensorUniqueID | ( | Print * | pPrinter, |
uint8_t | sensorID, | ||
FormatType_t | formatType = FormatForConsole |
||
) |
Dump the unique ID of a sensor based on the ID index of the sensor determined when the sensor was created with sensorlibraryCreateSensor.
pPrinter | where to sent the output |
sensorID | ID returned by sensorlibraryCreateSensor |
formatType | how to format the output |
EXTERNDEF void sensorlibraryDumpSensorValue | ( | Print * | pPrinter, |
uint8_t | indent, | ||
uint32_t | value, | ||
uint8_t | sensorID, | ||
FormatType_t | formatType = FormatForConsole |
||
) |
Dump the value of a sensor based on the unique ID of the sensor determined when the sensor was created with sensorlibraryCreateSensor.
pPrinter | where to sent the output |
indent | indentation for each new line |
value | value to dump |
sensorID | ID returned by sensorlibraryCreateSensor |
formatType | format of output |
EXTERNDEF uint32_t sensorlibraryExtractPulseCount | ( | uint8_t | index, |
LogElement_t & | element, | ||
uint32_t | defaultCount | ||
) |
Given an element extract the Nth pulse count cell.
index | which pulse count to extract |
element | element to fetch it from |
defaultCount | value to store in element if value found is invalid |
EXTERNDEF uint8_t sensorlibraryGetI2Caddress | ( | uint8_t | sensorID | ) |
Look up the I2C address for a sensor. The I2C address is stored in the last byte of the uniqueID for TCA9535 device pins.
sensorID | index into 'sensors' table |
EXTERNDEF String sensorlibraryGetSensorName | ( | uint8_t | index | ) |
Fetch a pointer to the name of a sensor given the ID returned by sensorlibraryCreateSensor.
index | Sensor ID |
EXTERNDEF uint8_t sensorlibraryGetSensorSpecificData | ( | uint8_t | sensorID | ) |
Look up the sensor specific data for a sensor.
sensorID | index into 'sensors' table |
EXTERNDEF void sensorlibraryInit | ( | ) |
< version of this module
Initialize the onewire services, call once at system startup.
EXTERNDEF String sensorlibraryInterfaceGetName | ( | SensorInterfaceID_t | interface | ) |
Get the name of a sensor interface
interface | the interface ID |
EXTERNDEF void sensorlibraryReadSensors | ( | LogElement_t & | element | ) |
Read each sensor in the library and place it into the element that gets logged.
element | block of data to write data to |
EXTERNDEF String sensorlibrarySensorTypeGetName | ( | SensorTypeID_t | sensorType | ) |
Get the name of a sensor type
sensorType | the sensor type ID |
EXTERNDEF void sensorlibrarySetPulsesSinceBoot | ( | LogElement_t & | element | ) |
For all sensors that are pulse counters read the value from the element and tell the pulse counter module the initial value. This should be called with the latest element from the database at system startup to update the pulse counters with the pulses to date.
element | element to take initial pulses from |
Update the pulse counter module
EXTERNVAR const char* const datatypeNames[] |
This array is indexed by a SensorDatatypeID_t to get the ASCIZ name of that type.