Documentation
¶
Overview ¶
Package senml implements the Sensor Measurement Lists format, as defined by https://tools.ietf.org/html/draft-ietf-core-senml-16.
Index ¶
- Variables
- func Bool(b bool) *bool
- func Float(f float64) *float64
- func GoTime(f float64) time.Time
- func Time(t time.Time) float64
- type Pack
- func (p Pack) Equals(p2 Pack) bool
- func (p Pack) Len() int
- func (p Pack) Less(i, j int) bool
- func (p Pack) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (p Pack) Normalize() Pack
- func (p Pack) NormalizeAt(t time.Time) Pack
- func (p Pack) Swap(i, j int)
- func (p *Pack) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- type Record
- type Unit
Constants ¶
This section is empty.
Variables ¶
var ( True = Bool(true) False = Bool(false) )
Functions ¶
func Bool ¶ added in v0.0.3
Bool returns a pointer to a bool value, to be used for Record.BoolValue.
func Float ¶ added in v0.0.3
Float returns a pointer to a float64 value, to be used for Record.Value and Record.Sum.
Types ¶
type Pack ¶
type Pack []Record
Pack defines a SenML pack (a list of Records).
func (Pack) MarshalXML ¶
MarshalXML implements xml.Marshaler. It encodes the SenML Pack to XML.
func (Pack) Normalize ¶
Normalize resolves the SenML Records, as explained in https://tools.ietf.org/html/draft-ietf-core-senml-16#section-4.6. All base items are removed, and records are sorted in chronological order.
func (Pack) NormalizeAt ¶ added in v0.0.3
NormalizeAt resolves the SenML Records, and replaces all relative times by absolute times, based on the t reference time.
func (*Pack) UnmarshalXML ¶
UnmarshalXML implements xml.Unmarshaler. It decodes a XML encoded SenML Pack.
type Record ¶
type Record struct {
BaseName string `json:"bn,omitempty" xml:"bn,attr,omitempty"`
BaseTime float64 `json:"bt,omitempty" xml:"bt,attr,omitempty"`
BaseUnit Unit `json:"bu,omitempty" xml:"bu,attr,omitempty"`
BaseValue *float64 `json:"bv,omitempty" xml:"bv,attr,omitempty"`
BaseSum *float64 `json:"bs,omitempty" xml:"bs,attr,omitempty"`
Version int `json:"bver,omitempty" xml:"bver,attr,omitempty"`
Name string `json:"n,omitempty" xml:"n,attr,omitempty"`
Unit Unit `json:"u,omitempty" xml:"u,attr,omitempty"`
Time float64 `json:"t,omitempty" xml:"t,attr,omitempty"`
UpdateTime float64 `json:"ut,omitempty" xml:"ut,attr,omitempty"`
Value *float64 `json:"v,omitempty" xml:"v,attr,omitempty"`
StringValue string `json:"vs,omitempty" xml:"vs,attr,omitempty"`
DataValue []byte `json:"vd,omitempty" xml:"vd,attr,omitempty"`
BoolValue *bool `json:"vb,omitempty" xml:"vb,attr,omitempty"`
Sum *float64 `json:"s,omitempty" xml:"s,attr,omitempty"`
}
Record is a SenML Record.
type Unit ¶
type Unit string
Unit is the unit for a measurement value.
const ( Meter Unit = "m" Kilogram Unit = "kg" Second Unit = "s" Ampere Unit = "A" Kelvin Unit = "K" Candela Unit = "cd" Mole Unit = "mol" Hertz Unit = "Hz" Radian Unit = "rad" Steradian Unit = "sr" Newton Unit = "N" Pascal Unit = "Pa" Joule Unit = "J" Watt Unit = "W" Coulomb Unit = "C" Volt Unit = "V" Farad Unit = "F" Ohm Unit = "Ohm" Siemens Unit = "S" Weber Unit = "Wb" Tesla Unit = "T" Henry Unit = "H" // degrees Celsius Celsius Unit = "Cel" Lumen Unit = "lm" Lux Unit = "lux" Becquerel Unit = "Bq" Gray Unit = "Gy" Sievert Unit = "Sv" Katal Unit = "kat" // square meter (area) SquareMeter Unit = "m2" // cubic meter (volume) CubicMeter Unit = "m3" // liter (volume) Liter Unit = "l" // meter per second (velocity) MeterPerSecond Unit = "m/s" // meter per square second (acceleration) MeterPerSquareSecond Unit = "m/s2" // cubic meter per second (flow rate) CubicMeterPerSecond Unit = "m3/s" // liter per second (flow rate) LiterPerSecond Unit = "l/s" // watt per square meter (irradiance) WattPerSquareMeter Unit = "W/m2" // candela per square meter (luminance) CandelaPerSquareMeter Unit = "cd/m2" // bit (information content) Bit Unit = "bit" // bit per second (data rate) BitPerSecond Unit = "bit/s" // degrees latitude DegreesLatitude Unit = "lat" // degrees longitude DegreesLongitude Unit = "lon" // pH value (acidity; logarithmic quantity) PH Unit = "pH" // decibel (logarithmic quantity) Decibel Unit = "dB" // decibel relative to 1 W (power level) Decibel1W Unit = "dBW" // bel (sound pressure level; logarithmic quantity) Bel Unit = "Bspl" // 1 (counter value) Count Unit = "count" // 1 (Ratio e.g., value of a switch) Switch Unit = "/" // percentage Percentage Unit = "%" // percentage (Relative Humidity) RelativeHumidity Unit = "%RH" // percentage (remaining battery energy level) EnergyLevel Unit = "%EL" // seconds (remaining battery energy level) EnergyRemaining Unit = "EL" // 1 per second (event rate) EventRate Unit = "1/s" // 1 per minute (Heart rate in beats per minute) BeatsPerMinute Unit = "beat/min" // 1 (Cumulative number of heart beats) Beats Unit = "beats" // siemens per meter (conductivity) SiemensPerMeter Unit = "S/m" )