heros.datasource.types
======================

.. py:module:: heros.datasource.types


Classes
-------

.. autoapisummary::

   heros.datasource.types.DatasourceReturnValue
   heros.datasource.types.DatasourceReturnSet


Functions
---------

.. autoapisummary::

   heros.datasource.types.ensure_string


Module Contents
---------------

.. py:function:: ensure_string(x)

.. py:class:: 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: :py:obj:`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 :class:`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.


   .. py:property:: id


   .. py:property:: raw_value


   .. py:property:: raw_unit


   .. py:property:: value

      (float) value in specified units.


   .. py:property:: unit

      SI Unit of the current tuple.


   .. py:property:: time


   .. py:property:: inbound

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


   .. py:method:: __str__()

      Return str(self).



   .. py:method:: __repr__()

      Return repr(self).



.. py:class:: DatasourceReturnSet

   Bases: :py:obj:`tuple`


   Collection of multiple :class:`DatasourceReturnValue`.


   .. py:method:: from_data(data)
      :staticmethod:


      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)



