|
KPN Things Device SDK
|
#include <senml_record.h>
Public Member Functions | |
| SenMLRecord () | |
| SenMLRecord (const char *name) | |
| SenMLRecord (ThingsMLMeasurementIndex index) | |
| SenMLRecord (const char *name, SenMLUnit unit) | |
| double | getTime () |
| bool | setTime (double value, bool absolute=true) |
| void | setTimeDirect (double value) |
| const char * | getName () |
| ThingsMLMeasurementIndex | getIndex () |
| void | setName (const char *name) |
| double | getUpdateTime () |
| bool | setUpdateTime (double value, bool absolute=true) |
| SenMLUnit | getUnit () |
| void | setUnit (SenMLUnit value) |
| virtual int | fieldsToJson () |
| virtual int | fieldsToCbor () |
Public Member Functions inherited from SenMLBase | |
| SenMLBase () | |
| ~SenMLBase () | |
| SenMLBase * | getNext () |
| SenMLBase * | getRoot () |
| virtual void | adjustToBaseTime (double prev, double time) |
| virtual int | fieldsToJson ()=0 |
| virtual int | fieldsToCbor ()=0 |
Protected Member Functions | |
| virtual int | contentToJson () |
| virtual int | contentToCbor () |
| virtual void | adjustToBaseTime (double prev, double time) |
| virtual void | actuate (const void *value, int dataLength, SenMLDataType dataType) |
| int | getFieldLength () |
Protected Member Functions inherited from SenMLBase | |
| virtual int | contentToJson ()=0 |
| void | setNext (SenMLBase *value) |
| void | setPrev (SenMLBase *value) |
| SenMLBase * | getPrev () |
| virtual bool | isPack () |
| virtual int | contentToCbor ()=0 |
| virtual int | getArrayLength () |
| virtual int | getFieldLength ()=0 |
Friends | |
| class | SenMLCborParser |
| class | SenMLJsonListener |
SenMLRecord represents a single measurement. Besides the value, it also stores the name, optional unit, timestamp and update time.
This is the base class for all record types, you can not work directly with this class. Instead, use one of it's derivatives such as SenMLBinaryRecord, SenMLBoolRecord, SenMLFloatRecord, SenMLIntRecord or SenMLStringRecord. Alternatively, you can create your own records by inheriting from this class, or SenMLRecordTemplate, a convenience template which allows you to create records for different data types.
Although a record object can be used by itself, usually record objects are added to SenMLPack objects.
|
inline |
create a SenMLRecord object.
|
inline |
create a SenMLRecord object.
| name | the identifier for this record. This is a free-form string, but a set of predefined names, supported by the KPN network can be found in senml_enums.h |
|
inline |
|
inline |
create a SenMLRecord object.
| name | the string that will be prepended to all records in this pack. Is used to represent the name of the device. |
| unit | the unit that should be included in the output. See the SenMLUnit enum for supported unit types. |
|
protectedvirtual |
Reimplemented in SenMLBinaryActuator, SenMLBoolActuator, SenMLDoubleActuator, SenMLFloatActuator, SenMLHalfFloatActuator, SenMLIntActuator, and SenMLStringActuator.
|
protectedvirtual |
Reimplemented from SenMLBase.
|
protectedvirtual |
Implements SenMLBase.
|
protectedvirtual |
Implements SenMLBase.
|
virtual |
renders all the fields to cbor format. renders all the fields of the object without the length info at the beginning note: this is public so that custom implementations for the record object can use other objects internally and render to json using this function (ex: coordinatesRecord using 3 floatRecrods for lat, lon & alt.
Implements SenMLBase.
Reimplemented in SenMLBinaryRecord, SenMLBoolRecord, SenMLDoubleRecord, SenMLFloatRecord, SenMLHalfFloatRecord, SenMLIntRecord, and SenMLStringRecord.
|
virtual |
renders all the fields to json, without the starting and ending brackets. Inheriters can extend this function if they want to add extra fields to the json output note: this is public so that custom implementations for the record object can use other objects internally and render to json using this function (ex: coordinatesRecord using 3 floatRecrods for lat, lon & alt.
Implements SenMLBase.
Reimplemented in SenMLBinaryRecord, SenMLBoolRecord, SenMLDoubleRecord, SenMLFloatRecord, SenMLHalfFloatRecord, SenMLIntRecord, and SenMLStringRecord.
|
protectedvirtual |
Implements SenMLBase.
|
inline |
|
inline |
Get the name of the record.
|
inline |
returns the time assigned to this record. NaN represents 'no time assigned'. See base fields for more info on the time value.
|
inline |
Get the enum that identifies the unit name assigned to the record. The value SENML_UNIT_NONE means that no unit will be generated in the output. Senml defines a fixed set of supported unit names.
|
inline |
Get the expected timestamp at which this record will be updated again. NaN represents 'no time assigned'.
|
inline |
Assign an identifier to the record. This is a free-form string, but a set of predefined names, supported by the KPN network can be found in senml_enums.h
| name | a string that represents the identifier for the record. A copy of the value is made. |
| bool SenMLRecord::setTime | ( | double | value, |
| bool | absolute = true |
||
| ) |
set the time, expressed as a unix epoch time, absolute or relative to the base time of the parent SenMLPack object.. when absolute is true (default behaviour), the time value will be made relative to the base time of the pack object, if it has a base time. See base fields for more info on the time value. Possible reasons for failure:
| value | the unix epoch time value to assign to the record |
| absolute | When true (default), the value will be interpreted as an absolute time stamp. If there is a parent SenMLPack, the value will be made relative to the pack's base time, if there is any. When false, no conversion is done, but a parent SenMLPack has to be present. |
|
inline |
set the time, expressed as a unix epoch time. This assigns the value directly without taking the parent senml pack into consideration. Use this only when you are calculating the values in a way that is not compatible with the functionality of setTime(); See base fields for more info on the time value.
| value | the unix epoch time value to assign to the record |
|
inline |
Assigns a unit value to the record. The value SENML_UNIT_NONE means that no unit will be generated in the output. Senml defines a fixed set of supported unit names.
| value | a SenMLUnit enum value representing the unit name. |
| bool SenMLRecord::setUpdateTime | ( | double | value, |
| bool | absolute = true |
||
| ) |
Assign a timestamp to the record at which it is expected to update the value. See base fields for more info on the time
Note: previously update time was interpreted as being relative, however this is not in line with the spec. the optional paramter absolute will now be ignored and true will always be returned.
| value | the unix epoch update time value to assign to the record |
| absolute | ignored. previously updatetime was interpreted as being relative to basetime, this is not in line with the spec however. |
|
friend |
|
friend |