View on GitHub

senml-python-library

senml_pack Module

senml_pack.SenmlPack Objects

represents a senml pack object. This can contain multiple records but also other (child) pack objects. When the pack object only contains records, it represents the data of a device. If the pack object has child pack objects, then it represents a gateway

enter

__enter__(self)

for supporting the ‘with’ statement

returns: self

exit

__exit__(self, exc_type, exc_val, exc_tb)

when destroyed in a ‘with’ statement, make certain that the item is removed from the parent list.

returns: None

init

__init__(self, name, callback=None)

initialize the object

parameters:

iter

__iter__(self)

add

adds the item to the list of records

parameters:

returns: None

base_sum

the base sum of the pack.

returns: a number

base_time

Get the base time assigned to this pack object. While rendering, this value will be subtracted from the value of the records.

returns: unix time stamp representing the base time

base_value

the base value of the pack. The value of the records will be subtracted by this value during rendering. While parsing, this value is added to the value of the records.

returns: a number

clear

clear(self)

clear the list of the pack

returns: None

do_actuate

do_actuate(self, raw, naming_map, device=None)

called while parsing incoming data for a record that is not yet part of this pack object. adds a new record and raises the actuate callback of the pack with the newly created record as argument

parameters:

returns: None

from_cbor

from_cbor(self, data)

parse a cbor data byte array to a senml pack structure.

parameters:

returns: None

from_json

from_json(self, data)

parse a json string and convert it to a senml pack structure

parameters:

returns: None, will call the appropriate callback functions.

remove

remove(self, item)

removes the item from the pack

parameters:

returns: None

to_cbor

to_cbor(self)

render the content of this object to a cbor byte array

returns: a byte array

to_json

to_json(self)

render the content of this object to a string.

returns: a string representing the senml pack object

senml_pack.SenmlPackIterator Objects

an iterator to walk over all records in a pack

init

__init__(self, list)

iter

__iter__(self)

next

__next__(self)