<?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">

  <!--
    this logic watches only one variable, of which name (key) is declared in KVSetting section
    in KVSetting is also mandatory item - "mode" - which determines work mode of notifier

    logic expects following mandatory variables:

    setting.delay          - delay, expressed in second, from an event occurring to raise alert.
                             remaining time is placed in counter.delay.downtime

    counter.delay.downtime - downcounts time to raise alert

    name                   - helper string variable used to display any text.

    is.active              - tells if alert is active

   -->



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

    <Declaration>

      <GlobalDeclSection>

      </GlobalDeclSection>

      <InstanceDeclSection>

        <!-- mandatory parameters -->

        <Var Name="setting.delay" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="false"
          Min="0" Default="30" Direction="Input" IsStorable="true"/>

        <Var Name="counter.delay.downtime" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="false"
          Min="0" Default="0" Direction="Output" IsStorable="false"/>

        <Var Name="name" Type="T_STRING"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Direction="Input" IsStorable="true"/>

        <Var Name="is.active" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="false"
          Min="0" Max="1" Default="0" Direction="Output" IsStorable="false"/>

        <Alert Id="notifier_alert" Text="notification related with parameter {0}">
          <VarParam Id="0" VarName="name" Presentation="String"/>
        </Alert>

        <!-- parameters related with given instance. can be remote, import etc
             below lists are used in presented examples-->

        <VarList Name="params" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Direction="Input" IsStorable="false"/>

        <VarList Name="values" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Direction="Input" IsStorable="false"/>

        <VarList Name="str" Type="T_STRING"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Direction="Input" IsStorable="false"/>


        <Settings>

          <KVSettings>

            <!-- mandatory item - observed variable name (key). This variable can be in list-->
            <!-- <KVSetting Key="srcVarName" Value="remote.src"/> -->

            <!--
                 mandatory item - notifier work mode. One of:

                 * "NotChangedNotify"
                 * "HasValueNotify"
                 * "HasNotValueNotify"
                 * "GreaterThanOrEqualsNotify"
                 * "LessThanOrEqualsNotify"
            -->
            <!-- <KVSetting Key="mode" Value="NotChangedNotify"/> -->

            <!-- ************************ parameters required by "NotChangedNotify" mode ************************ -->

            <!--
                 if value of variable "srcVarName"
                 was not changed since setting.delay seconds, then notification is issued as alert.
            -->


            <!-- ************************ parameters required by "HasValueNotify" mode ************************ -->

            <!-- name of variable list, that keep values, that are compared with srcVarName variable. When srcVarName has value
                 that equals one ov values in this list, then notification is issued as alert. Type of this variable list must
                 be the same as variable placed in srcVarName
             -->
            <!-- <KVSetting Key="valuesVarListName" Value="values"/> -->

            <!-- ************************ parameters required by "HasNotValueNotify" mode ************************ -->

            <!-- name of variable list, that keep values, that are compared with srcVarName variable. When srcVarName has not value
                 that equals one of values in this list, then notification is issued as alert. Type of this variable list must
                 be the same as variable placed in srcVarName. use above
             -->
            <!-- <KVSetting Key="valuesVarListName" Value="values"/> -->

            <!-- ************************ parameters required by "GreaterThanOrEqualsNotify" and "LessThanOrEqualsNotify" modes ************************ -->

            <!-- variable that is compared with srcVarName and alert is raised, when srcVarName is greater than or equals ("GreaterThanOrEqualsNotify" mode)
                 or less than or equals ("LessThanOrEqualsNotify") than this variable. this variable can be placed in list (in below example, variable is in list
                 values with cmp postfix). type of both srcVarName and cmpVarName must be a number-->

            <!-- <KVSetting Key="cmpVarName" Value="values.cmp"/> -->

          </KVSettings>
        </Settings>

      </InstanceDeclSection>

    </Declaration>

    <Initialization>

      <GlobalInitSection>

      </GlobalInitSection>

      <Instances>

        <Instance Name="dev.controllers">
          <InstanceInitSection>
            <!-- lista z wartosciami z logik -->
            <VarListItem       ListName="values" Postfix="input"         Value="0" SrcVar="Lua.DeviceMonitor.dev.counter.err.comm.state"/>

            <!-- lista z wyrazeniami do zbudowania komunikatu -->
            <VarListItem       ListName="str"    Postfix="title"         Value="Ostrzezenie"/>
            <VarListItem       ListName="str"    Postfix="content1"      Value="nie odpowiada: "/>
            <VarListItem       ListName="str"    Postfix="content2"      Value="" Src="Lua.DeviceMonitor.dev.counter.err.comm.str"/>

            <!-- wartosc opoznienia dla komunikatu -->
            <VarAssign         Name="setting.delay" Value="600"/>

            <!-- tresc komunikatu -->
            <Alert Id="notifier_alert" Text="{0}: {1} {2}">
              <VarListItemParam Id="0" VarListName="str"       ItemPostfix="title" Presentation="String"/>
              <VarListItemParam Id="1" VarListName="str"       ItemPostfix="content1" Presentation="String"/>
              <VarListItemParam Id="2" VarListName="str"       ItemPostfix="content2" Presentation="String"/>
            </Alert>

            <!-- wartosc parametrow dla komunikatu -->
            <VarListItem       ListName="params" Postfix="0"     Value="0"/>

            <!-- konfiguracja komunikatu -->
            <Settings>
              <KVSettings>
                <KVSetting Key="mode" Value="HasNotValueNotify"/>
                <KVSetting Key="srcVarName" Value="values.input"/>
                <KVSetting Key="valuesVarListName" Value="params"/>
              </KVSettings>
            </Settings>
          </InstanceInitSection>
        </Instance>

      </Instances>

    </Initialization>

  </Logic>

</Config>
