.. _tank:

********************
Tank
********************

.. index:: devices; tanks; Tank

Overview
====================

Fluid Dia tank element which represents a physical one. Needs a Massa 
M3 sensor as part of the element and 2 Dia channels to control the input 
and output valves.

Configuration
====================

A typical Tank configuration block looks like this::

    - name: tank0
      driver: devices.tanks.tank:Tank
      settings:
          tank_sensor_device: <instance name>
          input_valve_channel: xbib0.led1
          output_valve_channel: xbib0.led2
          tank_height: 3.5
          min_level_alarm: 10
          max_level_alarm: 90
          min_temperature_alarm: 6
          max_temperature_alarm: 18

Settings
--------------------

tank_sensor_device (required)
    Must be set to the name of a Massa M3 instance.

input_valve_channel (required)
    Name of the Dia channel to be interpreted as Input Valve status.

output_valve_channel (required)
    Name of the Dia channel to be interpreted as Output Valve status.

tank_height (required)
    Tank height (in meters).

max_level_alarm (optional)
    Insert the minimum value of the tank level (%) to trigger a high 
    level alarm. Leave it in blank to disable the high level alarm.

min_level_alarm (optional)
    Insert the maximum value of the tank level (%) to trigger a low 
    level alarm. Leave it in blank to disable the low level alarm.

max_temperature_alarm (optional)
    Insert the minimum value of the temperature (C) to trigger a high 
    temperature alarm. Leave it in blank to disable the high temperature 
    alarm.

min_temperature_alarm (optional)
    Insert the maximum value of the temperature (C) to trigger a low 
    temperature alarm. Leave it in blank to disable the low temperature 
    alarm.

Channels
====================

level (Get, type: integer, unit: %)
    Current level percent of the tank.

temperature (Get, type: float, unit: C)
    Current temperature value of the tank.

valve_in (Get/Set, type: Boolean)
    Status of the input valve, change the channel to switch the valve 
    status.

valve_out (Get/Set, type: Boolean)
    Status of the output valve, change the channel to switch the valve 
    status.

level_alarm (Get, type: string)
    Displays the latest level alarm with the following format:

    ``date@@message``

temperature_alarm (Get, type: string)
    Displays the latest temperature alarm with the following format:

    ``date@@message``

virtual (Get, type: bool)
    Indicates whether the tank device is virtual or physical.
