<?xml version="1.0" encoding="UTF-8"?>
<Config Version="1.3"
        xmlns="http://www.insbud.net/ibmanager/logicCfg"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.insbud.net/ibmanager/logicCfg logicCfg.xsd">

  <!--

  logic handles following instance variables:

    input.t.value          - input temperature value
    input.t.err            - input temperature status
    output.t.value         - it is output variable of current logic, but it is input variables for logics, that
                             utilizes this value. It is temperature expressed in tenthes of celsius degrees.
    output.t.err           - output of current logic, but input for logics, that utilizes this value. It is
                             error code related with above temperature. Look at the supported temperature errors below.
    setting.t.calib.value  - this value is added (if negative then subtracted) to/from input.t.value.
    setting.t.manual.value - manually forced value, this value is copied to output.t.value when variable
                             setting.t.value.mode has value 1. Look at the supported temperature errors below.
    setting.t.manual.err   - manually forced temperature error code, this value is copied to input.t.logic.err when variable
                             setting.t.err.mode has value 1.
    setting.t.value.mode   - mode of determining output.t.value. Can have following values:
                             0 - output.t.value = input.t.value + setting.t.calib.value.
                             1 - output.t.value = setting.t.manual.value.
    setting.t.err.mode     - mode of determining output.t.err. Can have following values:
                             0 - output.t.err = output.t.err.
                             1 - output.t.err = setting.t.manual.err.
    setting.t.smooth       - 0..1. it is only included when setting.t.value.mode equals 0.
                             0 - output.t.value = input.t.value + setting.t.calib.value - immediately
                             1 - output.t.value tends to (input.t.value + setting.t.calib.value)
                             default each (smooth.period) 5 seconds by (smooth.delta) 5[*C/10]. smooth.period and smooth.delta can
                             override in KVSettings

  logic expects optional KVSettings:

   "smooth.period"         - look at "setting.t.smooth" variable description
   "smooth.delta"          - look at "setting.t.smooth" variable description

   supported temperature error values:
   0 - no error
   1 - sensor circuit is open
   2 - sensor circuit is closed
   3 - temperature suspiciously too high
   4 - temperature suspiciously too low
   5 - internal device error - probably unexpected
   6 - 1WIRE related code - bus is not yet ready
   7 - 1WIRE related code - sensor not exists
   8 - current logic special code - temperature was not read from remote device
   -->



  <!-- Type and Version must be the same as Logic::TYPE and Logic::VERSION in Logic.cpp -->
  <Logic Type="MapperTemp" Version="0.3.13.1413">

    <Declaration>

      <GlobalDeclSection>

      </GlobalDeclSection>

      <InstanceDeclSection>

        <Var Name="output.t.value" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="false"
          Direction="Output" Default="0" IsStorable="false"/>

        <Var Name="output.t.err" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="false"
          Direction="Output" Default="0" IsStorable="false"/>

        <Var Name="input.t.value" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Direction="Input" Default="0" IsStorable="false"/>

        <Var Name="input.t.err" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Direction="Input" Default="0" IsStorable="false"/>

        <Var Name="setting.t.calib.value" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Direction="Input" Default="0" IsStorable="true"/>

        <Var Name="setting.t.manual.value" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Direction="Input" Default="0" IsStorable="true"/>

        <Var Name="setting.t.manual.err" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Min="0" Max="8" Default="0" Direction="Input"
          IsStorable="true"/>

        <Var Name="setting.t.value.mode" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Min="0" Max="1" Default="0" Direction="Input"
          IsStorable="true"/>

        <Var Name="setting.t.err.mode" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Min="0" Max="1" Default="0" Direction="Input"
          IsStorable="true"/>

        <Var Name="setting.t.smooth" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Min="0" Max="1" Default="0" Direction="Input"
          IsStorable="true"/>

        <Settings>
          <KVSettings>
            <KVSetting Key="smooth.period" Value="2"/>
            <KVSetting Key="smooth.delta" Value="1"/>
          </KVSettings>
        </Settings>

      </InstanceDeclSection>

    </Declaration>

    <Initialization>

      <GlobalInitSection>

      </GlobalInitSection>
      <Instances>

        <!-- temperatura powietrza zewnętrznego -->
        <Instance Name="outdoor">
        <InstanceInitSection>
            <VarAssign Name="input.t.value"    Value="0"      SrcVar="rs.0.id.10.input.temperature"/>
            <VarAssign Name="input.t.err"      Value="0"      SrcVar="Lua.DeviceMonitor.dev.counter.err.state.1"/>
            <VarAssign Name="setting.t.smooth" Value="1"/>
            <Settings>
            <KVSettings>
                <KVSetting Key="smooth.period" Value="10"/>
                <KVSetting Key="smooth.delta"  Value="2"/>
            </KVSettings>
            </Settings>
        </InstanceInitSection>
        </Instance>

        <!-- temperatura złoża GWC 1 -->
        <Instance Name="ghe.1.inner">
        <InstanceInitSection>
            <VarAssign Name="input.t.value"    Value="0"      SrcVar="rs.0.id.11.input.temperature"/>
            <VarAssign Name="input.t.err"      Value="0"      SrcVar="Lua.DeviceMonitor.dev.counter.err.state.2"/>
            <VarAssign Name="setting.t.smooth" Value="1"/>
            <Settings>
            <KVSettings>
                <KVSetting Key="smooth.period" Value="10"/>
                <KVSetting Key="smooth.delta"  Value="2"/>
            </KVSettings>
            </Settings>
        </InstanceInitSection>
        </Instance>

        <!-- temperatura powietrza nawiewanego GWC 1 -->
        <Instance Name="ghe.1.vent.supply">
        <InstanceInitSection>
            <VarAssign Name="input.t.value"    Value="0"      SrcVar="rs.0.id.12.input.temperature"/>
            <VarAssign Name="input.t.err"      Value="0"      SrcVar="Lua.DeviceMonitor.dev.counter.err.state.3"/>
            <VarAssign Name="setting.t.smooth" Value="1"/>
            <Settings>
            <KVSettings>
                <KVSetting Key="smooth.period" Value="10"/>
                <KVSetting Key="smooth.delta"  Value="2"/>
            </KVSettings>
            </Settings>
        </InstanceInitSection>
        </Instance>

        <!-- temperatura wody zraszającej -->
        <Instance Name="water">
        <InstanceInitSection>
            <VarAssign Name="input.t.value"    Value="0"      SrcVar="rs.0.id.13.input.temperature"/>
            <VarAssign Name="input.t.err"      Value="0"      SrcVar="Lua.DeviceMonitor.dev.counter.err.state.4"/>
            <VarAssign Name="setting.t.smooth" Value="1"/>
            <Settings>
            <KVSettings>
                <KVSetting Key="smooth.period" Value="10"/>
                <KVSetting Key="smooth.delta"  Value="2"/>
            </KVSettings>
            </Settings>
        </InstanceInitSection>
        </Instance>

      </Instances>
    </Initialization>

  </Logic>

</Config>
