habitat.sensor_manager: Sensor function management

habitat.sensors: the sensor-function manager

The sensor function manager provides a collection of sensor functions, which are used by parser modules to turn extracted fields into useful data.

Sensor functions are grouped into “libraries”, which are python modules. When loaded, these modules are assigned a shorthand. For example, functions in habitat.sensors.stdtelem are available simply as stdtelem.func. The shorthand assigned is specified in the config document.

These all libraries listed in the Sensor Manager’s configuration are loaded upon initialisation.

Sensor Functions

The sensor_manager provides the base library built in; it includes

  • ascii_int
  • ascii_float
  • string

Other libraries are available with habitat. See sensors

A sensor function takes two arguments, config and data. It can return a string, list, dict, int, float, or any other python object that can be stored in a couchdb database.

config is a dict of options. It is passed to the function from SensorManager.parse()

data is the string to parse.

class habitat.sensor_manager.SensorManager(program)[source]

The main Sensor Manager class

program: a habitat.main.Program object

All modules listed in the config document for the sensor manager will be loaded using load().

load(module, shorthand)[source]

loads module as a library and assigns it to shorthand

parse(name, config, data)[source]

parses the data provided

name: The sensor function to use.

config: The config dict to provide to the sensor function

data: The data to parse.

Table Of Contents

Previous topic

habitat.parser: interpretation of incoming strings

Next topic

habitat.sensors: Sensor function libraries

This Page