Newer
Older
ibsystem / ibmanager / logic / LuaDeviceMonitor.xml
<?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">

  <!--

    ======================
    Description
    ======================

    Logika monitoruje stan urządzeń podłączonych do ibvunit na podstawie parametru tslc (czas od ostatniej prawidłowej komunikacji z urządzeniem).

    Należy zbudować listę sterowników z wszystkimi zmiennymi z listy.

    ======================
    Parameters
    ======================

    SubLogic supports following variables:

    counter.no                              - ilość monitorowanych urządzeń

    counter.err.state                       - stan błędu urządzeń:
                                              0 - wszystkie odpowiadają, lub czas do wywołania błędu jeszcze nie upłynął;
                                              1 - urządzenie nie odpowiada
                                              2 - zdublowana nazwa urządzenia

    counter.err.srt                         - string zawierający nazwy wszystkich sterowników z błędem

    setting.err.time                        - [s] po tym czasie, jeżeli nie zostanie nawiązana prawidłowa komunikacja z urządzeniem tzn:
                                                  wartość counter.tslc < setting.tslc.limit i wartość counter.tslc <> -1
                                                  zostanie zarejestrowany błąd urządzenia

    setting.tslc.timeout                    - [s] wartość limitu tslc. Jeżeli wartość counter.tslc jest większa niż setting.tslc.timeout to
                                                  fakt ten traktowany jest jako błąd komunikacji ze sterownikiem

    counter.tslc                            - lista - [s] tslc sterownika (-1 oznacza, że sterownik nigdy nie odpowiedział)

    counter.err.downcounter                 - lista - [s] licznik powiązany z setting.err.timer. Jeżeli dojdzie do 0 to zostanie wywołany błąd counter.err.state

    counter.err.state                       - lista - czy urządzenie jest w stanie błędu

    setting.id                              - lista - identyfikator sterownika zgodny z ibvunit (np. rs.0.id.1)

    setting.err.enabled                     - lista - czy błąd komunikacji ma być monitorowany

    ======================
    mandatory variables
    ======================

    Logic expects following mandatory variables:

    reload.trigger                          - causes reloading lua script

    memcnt                                  - current amount of memory used by lua in bytes

    Logic expects following kv settings:

    LuaScriptPath                           - path to the lua script - must be absolute

    ======================
    ChangeLog
    ======================

    2022-08-02 ver 1.0.0

    # First release

   -->

  <!-- Type and Version must be the same as Logic::TYPE and Logic::VERSION in Logic.cpp -->
  <Logic Type="Lua" SubType="DeviceMonitor" Version="1.0.10.1421" SubVersion="1.0.0.0">

    <Declaration>

      <GlobalDeclSection>

      </GlobalDeclSection>

      <InstanceDeclSection>

        <!-- mandatory variables -->

        <Var Name="reload.trigger" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Direction="Input" Min="0" Max="1"
          Default="0" IsStorable="false"/>

        <Var Name="memcnt" Type="T_LONGLONG"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="false"
          Direction="Output" Min="0"
          Default="0" IsStorable="false"/>

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

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

        <Var Name="counter.err.comm.str" Type="T_STRING"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="false"
          Direction="Output" 
          Default="" IsStorable="false"/>

        <Var Name="setting.err.time" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Direction="Input" Default="10"
          IsStorable="true"/>

        <Var Name="setting.tslc.timeout" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Direction="Input" Default="10" Min="1"
          IsStorable="true"/>

        <VarList Name="setting.id" Type="T_STRING"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Direction="Input"  GroupName="devices"
          Default="" IsStorable="false"/>

        <VarList Name="setting.err.enabled" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Direction="Input"  GroupName="devices"
          Min="0" Max="1" Default="1" IsStorable="true"/>

        <VarList Name="counter.tslc" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Direction="Input"  GroupName="devices"
          Min="-1" Default="-1" IsStorable="false"/>

        <VarList Name="counter.err.downcounter" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Direction="Output"  GroupName="devices"
          Default="0" Min="0" IsStorable="false"/>

        <VarList Name="counter.err.state" Type="T_INT"
          CanLocalRead="true" CanLocalWrite="true"
          CanExternRead="true" CanExternWrite="true"
          Direction="Output"  GroupName="devices"
          Min="0" Default="0" IsStorable="false"/>

        <Settings>
          <KVSettings>
            <!-- pointing source list - mandatory setting-->
            <KVSetting Key="LuaScriptPath" Value="logic/scripts/DeviceMonitor.lua"/>
          </KVSettings>
        </Settings>

    </InstanceDeclSection>

    </Declaration>

    <Initialization>

      <GlobalInitSection>
      </GlobalInitSection>

      <Instances>

        <Instance Name="dev">

          <InstanceInitSection>

            <VarAssign Name="counter.err.comm.str"         Value=""  DstVar="Notifier.dev.controllers.str.content2"/>

            <VarListItem ListName="setting.id"                      Postfix="0"                        Value="rs.0.id.1"/>
            <VarListItem ListName="setting.err.enabled"             Postfix="0"                        Value="1"/>
            <VarListItem ListName="counter.tslc"                    Postfix="0"                        Value="-1"/>
            <VarListItem ListName="counter.err.downcounter"         Postfix="0"                        Value="0"/>
            <VarListItem ListName="counter.err.state"               Postfix="0"                        Value="0"/>

            <VarListItem ListName="setting.id"                      Postfix="1"                        Value="rs.0.id.10"/>
            <VarListItem ListName="setting.err.enabled"             Postfix="1"                        Value="1"/>
            <VarListItem ListName="counter.tslc"                    Postfix="1"                        Value="-1"/>
            <VarListItem ListName="counter.err.downcounter"         Postfix="1"                        Value="0"/>
            <VarListItem ListName="counter.err.state"               Postfix="1"                        Value="0"/>

            <VarListItem ListName="setting.id"                      Postfix="2"                        Value="rs.0.id.11"/>
            <VarListItem ListName="setting.err.enabled"             Postfix="2"                        Value="1"/>
            <VarListItem ListName="counter.tslc"                    Postfix="2"                        Value="-1"/>
            <VarListItem ListName="counter.err.downcounter"         Postfix="2"                        Value="0"/>
            <VarListItem ListName="counter.err.state"               Postfix="2"                        Value="0"/>

            <VarListItem ListName="setting.id"                      Postfix="3"                        Value="rs.0.id.12"/>
            <VarListItem ListName="setting.err.enabled"             Postfix="3"                        Value="1"/>
            <VarListItem ListName="counter.tslc"                    Postfix="3"                        Value="-1"/>
            <VarListItem ListName="counter.err.downcounter"         Postfix="3"                        Value="0"/>
            <VarListItem ListName="counter.err.state"               Postfix="3"                        Value="0"/>

            <VarListItem ListName="setting.id"                      Postfix="4"                        Value="rs.0.id.13"/>
            <VarListItem ListName="setting.err.enabled"             Postfix="4"                        Value="1"/>
            <VarListItem ListName="counter.tslc"                    Postfix="4"                        Value="-1"/>
            <VarListItem ListName="counter.err.downcounter"         Postfix="4"                        Value="0"/>
            <VarListItem ListName="counter.err.state"               Postfix="4"                        Value="0"/>

          </InstanceInitSection>

        </Instance>

      </Instances>

    </Initialization>

  </Logic>

</Config>