senml

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2018 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

senml

Travis-CI GoDoc GoReportCard

go get github.com/objenious/senml

Status: alpha - breaking changes might happen

This package implements the SenML format (Sensor Measurement Lists, formerly known as Sensor Markup Language), as defined in https://tools.ietf.org/html/draft-ietf-core-senml-16

This package is used in production on the Objenious LoRaWAN platform, and is maintained.

TODO

  • CBOR Representation
  • EXI Representation
  • Fragment Identification

Contribution guidelines

Contributions are welcome, as long as :

  • unit tests & comments are included,
  • no external package is added to the top-level package (but allowed in sub-packages).

Licence

MIT - See LICENSE

Documentation

Overview

Package senml implements the Sensor Measurement Lists format, as defined by https://tools.ietf.org/html/draft-ietf-core-senml-16.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pack

type Pack []Record

Pack defines a SenML pack (a list of Records).

func (Pack) Equals

func (p Pack) Equals(p2 Pack) bool

Equals checks if 2 packs are equal.

func (Pack) Len

func (p Pack) Len() int

Len implements sort.Interface.

func (Pack) Less

func (p Pack) Less(i, j int) bool

Less implements sort.Interface.

func (Pack) MarshalXML

func (p Pack) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements xml.Marshaler. It encodes the SenML Pack to XML.

func (Pack) Normalize

func (p Pack) Normalize() Pack

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) Swap

func (p Pack) Swap(i, j int)

Swap implements sort.Interface.

func (*Pack) UnmarshalXML

func (p *Pack) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

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:"sum,attr,omitempty"`
}

Record is a SenML Record.

func (*Record) Equals

func (r *Record) Equals(r2 *Record) bool

Equals checks if two records are equal

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"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL