.. _virtual_tank:

********************
Virtual Tank
********************

.. index:: devices; tanks; Virtual Tank

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

Fluid Dia tank element simulated by the Dia framework. It creates 
the same channels than the :ref:`Tank <tank>` device. As it is virtual, 
it doesn't need any other devices or channels to work.

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

A typical Virtual Tank configuration block looks like this::

    - name: tank_v0
      driver: devices.tanks.virtual_tank:VirtualTank
      settings:
          volume: 5000
          initial_level: 40
          initial_temperature: 15
          inflow_rate: 5
          outflow_rate: 10
          min_level_alarm: 10
          max_level_alarm: 90
          min_temperature_alarm: 6
          max_temperature_alarm: 18

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

volume (required)
    Total volume of the tank, in liters.

initial_level (optional)
    The initial level of the tank, (%).

initial_temperature (optional)
    The initial temperature of the tank, (C).

inflow_rate (optional)
    Flow rate of the input valve (liters/second).

outflow_rate (optional)
    Flow rate of the output valve (liters/second).

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.
