heros.datasource.types

Classes

DatasourceReturnValue

A structure to store data returned from a single entity in a datasource.

DatasourceReturnSet

Collection of multiple DatasourceReturnValue.

Functions

Module Contents

heros.datasource.types.ensure_string(x)
class heros.datasource.types.DatasourceReturnValue(id: str = None, time: float = None, value: float = None, unit: str = None, raw_value: float = None, raw_unit: str = None, inbound: int = -1, calibrated: bool = False, **kwargs)

Bases: dict

A structure to store data returned from a single entity in a datasource. A datasource can return multiple entities at once. In this case many DatasourceReturnValues are stored in a DatasourceReturnSet.

Default return values from datasource. They can be converted using a calibration.
param raw_value:

(float)

param raw_unit:

(str[10])

param time:

(int) creation time of the rawValue.

property id
property raw_value
property raw_unit
property value

(float) value in specified units.

property unit

SI Unit of the current tuple.

property time
property inbound

Boundary level (int) -1=unbound, 0=ok, 1=warn,error, fault

__str__()

Return str(self).

__repr__()

Return repr(self).

class heros.datasource.types.DatasourceReturnSet

Bases: tuple

Collection of multiple DatasourceReturnValue.

static from_data(data)
We try to build a DatasourceReturnSet by guessing the data format from the following options:
  • [FLOAT, FLOAT, ..] -> A list of raw_values

  • [(FLOAT, STR), (FLOAT, STR), ..] -> a list of (raw_value, raw_unit) tuples

  • {STR: FLOAT, STR: FLOAT, ..} -> a dict with id: raw_value

  • {STR: (FLOAT, STR), STR: (FLOAT, STR), …} a dict with id: (raw_value, raw_unit)

  • FLOAT -> raw_value

  • (FLOAT, STR) -> (raw_value, raw_unit)