Gw XML setup: Difference between revisions

From Phobos Wiki
Jump to navigation Jump to search
No edit summary
 
(94 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{| align="right"
| __TOC__
|}
== Element: Setup ==
== Element: Setup ==
The XML setup starts with the tag Setup. The entire setup is contained in this element.
The XML setup starts with the tag Setup. The entire setup is contained in this element.
<Setup />
 
<span style="color:#ff0000"><big>All '''id''' attributes must be unique!</big></span>


This element contains:
This element contains:
Line 8: Line 13:
*Attribute: '''device'''
*Attribute: '''device'''
**If more than one '''Device''' element available. This attribute specifies the '''id''' of the '''Device''' to use as current setup.
**If more than one '''Device''' element available. This attribute specifies the '''id''' of the '''Device''' to use as current setup.
<syntaxhighlight lang="xml">
<Setup device="Telem-Gw6-1">
<Device id="Telem-Gw6-1" />
<Device id="Gw1" />
<Device id="Gw2" />
</Setup>
</syntaxhighlight>


== Element: Device ==
== Element: Device ==
Line 19: Line 33:
*Attribute: '''id'''
*Attribute: '''id'''
** Used for element identification
** Used for element identification
Child elements of Device when used as GW device
<syntaxhighlight lang="xml">
<Device id="Telem-Gw6-1">
<Channel />
<Interfaces />
</Device>
</syntaxhighlight>
Child elements of Device when used as the device we're connecting to.
<syntaxhighlight lang="xml">
<Device id="DI-24T-1">
<Protocol />
<Objects />
</Device>
</syntaxhighlight>


== Element: Channel ==
== Element: Channel ==
This element contains:
This element contains:
*Element: '''[[Gw_XML_setup#Element:_Port | Port]]'''
*Element: '''[[Gw_XML_setup#Element:_Port | Port]]'''
**If more than one '''[[Gw_XML_setup#Element:_Port | Port]]''' is specified, they are for redundancy.
*Element: '''[[Gw_XML_setup#Element:_Device | Device]]'''
*Element: '''[[Gw_XML_setup#Element:_Device | Device]]'''
*Element: '''[[Gw_XML_setup#Element:_Objects | Objects]]'''
*Element: '''[[Gw_XML_setup#Element:_Objects | Objects]]'''
<syntaxhighlight lang="xml">
<Channel id="DI-24T-1">
<Port />
<Device />
<Objects />
</Channel>
</syntaxhighlight>
== Element: Protocol ==
== Element: Protocol ==
<syntaxhighlight lang="xml">
  <Protocol comment="protocol8" id="prot_8_0">
  <Protocol comment="protocol8" id="prot_8_0">
  <Address />
  <Address />
  <CommunicationDelay unit="millisecond">0</CommunicationDelay>
  <CommunicationDelay unit="millisecond">0</CommunicationDelay>
  <PollingTimeout unit="millisecond">500</PollingTimeout>
  <PollingTimeout unit="millisecond">500</PollingTimeout>
  <TimeSync enabled="false"/>
  <TimeSync />
  <RemoveCount>5</RemoveCount>
  <TimeoutRemoveCount>5</TimeoutRemoveCount>
  <RemoveTime unit="second">20</RemoveTime>
  <TimeoutRemoveTime unit="second">20</TimeoutRemoveTime>
  <ReplaceTime>false</ReplaceTime>
  <ReplaceTime>false</ReplaceTime>
<GeneralInterrogationForwarding>false</GeneralInterrogationForwarding>
  <Type SubVersion="0" isMaster="false">IEC101UnBalanced</Type>
  <Type SubVersion="0" isMaster="false">IEC101UnBalanced</Type>
  </Protocol>
  </Protocol>
</syntaxhighlight>
=== Element: TimeSync ===
Timesync interval and correction setup
<syntaxhighlight lang="xml">
<TimeSync isEnabled="true">
<Interval unit="second">30</Interval>
<Correction />
</TimeSync>
</syntaxhighlight>
==== Element: Correction ====
Possible timesync correction types:
*Absolute
**Timesync message shall always be modified by this amount.
*ConnectionSpeed
**Baudrate based(only when using serial port)
<syntaxhighlight lang="xml">
<Correction>
<Absolute enabled="true" unit="millisecond">0</Absolute>
<ConnectionSpeed enabled="true"/>
</Correction>
</syntaxhighlight>


=== Element: Address ===
== Element: Address ==
This element can refer to '''protocol''' address or some specific '''object''' address.
=== Address for protocol ===
This elements contents depend on the protocol selected
This elements contents depend on the protocol selected
==== Iec-10x ====
==== Iec-10x ====
<syntaxhighlight lang="xml">
  <Address>
  <Address>
  <LinkAddress>1</LinkAddress>
  <LinkAddress>1</LinkAddress>
Line 47: Line 117:
  <ObjectAddressLength>2</ObjectAddressLength>
  <ObjectAddressLength>2</ObjectAddressLength>
  </Address>
  </Address>
</syntaxhighlight>
==== MODBUS ====
==== MODBUS ====
Value: ''integer''
<syntaxhighlight lang="xml">
  <Address>2</Address>
  <Address>2</Address>
</syntaxhighlight>
==== IEC62056-21 ====
==== IEC62056-21 ====
  <Address>addr123</Address>
Value: ''string''
 
Can be empty if only one device on channel.
<syntaxhighlight lang="xml">
  <Address id="0.0.0">addr123</Address>
</syntaxhighlight>
 
If this Address element contains attribute '''id''', It shall be used for device verification.
 
=== Address of object ===
 
==== Iec-101/104 ====
Value: ''integer''
<syntaxhighlight lang="xml">
<Address index="0">10</Address>
</syntaxhighlight>
 
attribute index is unnecessary if value=='''0'''
 
 
==== Iec-103 ====
<syntaxhighlight lang="xml">
<Address fnCode="3" infoNr="6"/>
</syntaxhighlight>
 
==== SPA-Bus ====
 
Kas standardis on '''dataType''' või '''dataCode''' vastava välja nimetus?
 
Väärtuse '''1234''' oleks ka võibolla mõistlik attribuuti '''dataNumber''' tõsta
 
Kas DI'l index on kasutused?
 
===== DI =====
<syntaxhighlight lang="xml">
<Address index="3" onEvent="6" offEvent="6" channelNumber="6" dataType="I">1234</Address>
</syntaxhighlight>
 
Alternatiiv:
 
<syntaxhighlight lang="xml">
<Address onEvent="6" offEvent="6" channelNumber="6" dataCode="I" dataNumber="1234" />
</syntaxhighlight>
===== AI =====
<syntaxhighlight lang="xml">
<Address channelNumber="6" dataType="I">1234</Address>
</syntaxhighlight>
 
Alternatiiv:
 
<syntaxhighlight lang="xml">
<Address channelNumber="6" dataCode="I" dataNumber="1234" />
</syntaxhighlight>
 
===== CN =====
<syntaxhighlight lang="xml">
<Address channelNumber="6" dataType="I">1234</Address>
</syntaxhighlight>
 
Alternatiiv:
 
<syntaxhighlight lang="xml">
<Address channelNumber="6" dataCode="I" dataNumber="1234" />
</syntaxhighlight>
 
==== IEC61580/IEC62056-21 ====
Value: ''string''
<syntaxhighlight lang="xml">
<Address>5.3.5</Address>
</syntaxhighlight>
 
==== Other ====
Other protocols might have additional fields.
 
== Element: Port ==
== Element: Port ==
<syntaxhighlight lang="xml">
<Port>
        <Buffer id="inBuffer"/>
        <Buffer id="outBuffer"/>
        <IoBuffer in="inBuffer" out="outBuffer"/>
</Port>
</syntaxhighlight>
=== Port data forwarding ===
It is possible to send data from one port to another.
To do that, port1's input buffer is the same as port2's outputbuffer and vice versa.
<syntaxhighlight lang="xml">
<Port id="port1">
        <Buffer id="portBufferIn"/>
        <Buffer id="portBufferOut"/>
        <IoBuffer in="portBufferIn" out="portBufferOut"/>
</Port>
<Port id="port2">
        <IoBuffer in="portBufferOut" out="portBufferIn"/>
</Port>
</syntaxhighlight>
The same method allows creation of a local loopback.
<syntaxhighlight lang="xml">
<Port id="portLoopback">
        <Buffer id="portBuffer"/>
        <IoBuffer in="portBuffer" out="portBuffer"/>
</Port>
</syntaxhighlight>
=== Serial port ===
=== Serial port ===
<syntaxhighlight lang="xml">
  <Port class="SerialPortSetup">
  <Port class="SerialPortSetup">
  <BaudRate>9600</BaudRate>
  <BaudRate>9600</BaudRate>
Line 60: Line 238:
  <FlowControl>none</FlowControl>
  <FlowControl>none</FlowControl>
  </Port>
  </Port>
</syntaxhighlight>
=== TCP/IP server ===
=== TCP/IP server ===
<syntaxhighlight lang="xml">
  <Port class="TcpIpServerSetup">
  <Port class="TcpIpServerSetup">
  <PortNumber>80</PortNumber>
  <PortNumber>80</PortNumber>
Line 66: Line 246:
  <Interface>eth0</Interface>
  <Interface>eth0</Interface>
  </Port>
  </Port>
</syntaxhighlight>
==== Element: ClientIpMask ====
Defines who is allowed to connect with us.
More than one possible.
=== TCP/IP client ===
=== TCP/IP client ===
<syntaxhighlight lang="xml">
  <Port class="TcpIpClientSetup" name="16">
  <Port class="TcpIpClientSetup" name="16">
  <PortNumber>502</PortNumber>
  <PortNumber>502</PortNumber>
Line 72: Line 260:
  <Interface>eth0</Interface>
  <Interface>eth0</Interface>
  </Port>
  </Port>
</syntaxhighlight>
=== Virtual port ===
=== Virtual port ===
They are ports 3-5 on GW6.
They are ports 3-5 on GW6.
<syntaxhighlight lang="xml">
  <Port class="VirtualPortSetup">
  <Port class="VirtualPortSetup">
  <Port class="SerialPortSetup">
  <Port class="SerialPortSetup">
Line 83: Line 273:
  </Port>
  </Port>
  </Port>
  </Port>
</syntaxhighlight>
== Element: Objects ==
== Element: Objects ==
=== Element: Object ===
Depending on protocol the object belongs to (master/slave), has different child elements.
Possible child elements:
*'''[[Gw_XML_setup#Address_of_object |Address]]'''
*'''[[Gw_XML_setup#Element:_Buffer | Buffer]]'''
*'''[[Gw_XML_setup#Element:_Filter | Filter]]'''
*'''[[Gw_XML_setup#Element:_MxValue | MxValue]]'''
==== Attribute: type ====
Defines object type.
Possible values:
*DI
*AI
*CN
*DO
*AO
==== Element: MxValue ====
Defines the object for current/latest value.
Child elements define default value, flags and time tag.
<syntaxhighlight lang="xml">
<MxValue id="DI_6_value">
<Value>0</Value>
<BitMask>
<Bit>Invalid</Bit>
<Bit>NotTopical</Bit>
</BitMask>
</MxValue>
</syntaxhighlight>
==== Element: Filter ====
Defines what is going to happen to the incoming measured value.
Filters can be daisy chained. To achieve different outcomes.
When an event is received, it is sent to it's filter. After the filter does what it's supposed to do, it will pass the event to the '''Next''' Filter
<syntaxhighlight lang="xml">
<Filter class="Change">
<Filter class="Proxy" />
</Filter>
</syntaxhighlight>
===== AddToBuffer =====
AddToBuffer may have more than one '''Target'''.
'''Target''' is a Buffer object.
<syntaxhighlight lang="xml">
<Filter class="AddToBuffer">
<Target ref="DI_0_7_buf"/>
<Target ref="DI_1_7_buf"/>
<Target ref="DI_2_7_buf"/>
<Target ref="DI_3_7_buf"/>
<Target ref="DI_4_7_buf"/>
</Filter>
</syntaxhighlight>
===== Assert =====
Passes event to the next filter only if specified target('''[[Gw_XML_setup#Element:_MxValue |MxValue]]''') '''==''' false.
Possible use cases:
* Respond negatively to control commands
* Signal blocking
<syntaxhighlight lang="xml">
<Filter class="Assert">
<Ref>DI_7_value<Ref/>
</Filter>
</syntaxhighlight>
===== Change =====
Detects change in Digital measurments value and status bits.
===== Deadband =====
Used to detect change in analog and counter values
<syntaxhighlight lang="xml">
<Filter class="Deadband">
        <Type>X</Type>
        [...]
</Filter>
</syntaxhighlight>
* Type
** Default is Deadband1, if Deadband1 then element Type is unnecessary
====== Integral ======
New deadband type, not implemented.
====== Absolute ======
This deadband is used for counter values.
f = abs( new_value - current_value ) > Threshold
* Threshold
** Integer value
** If value=0; then no need for filter
<syntaxhighlight lang="xml">
<Filter class="Deadband">
<Type>Absolute</Type>
<Threshold>X</Threshold>
</Filter>
</syntaxhighlight>
====== Deadband1/Legacy ======
This is the legacy GW6 deadband mode
This deadband is used for analog values.
if( (new_value < Critical.min) || (new_value > Critical.max) )
{
    current_threshold = Threshold.db2
}
else
{
    current_threshold = Threshold.db1
}
if ( new_value.is_normalized )
    calculated_threshold = current_threshold / 100
else
    calculated_threshold = (Scale.max - Scale.min) * current_threshold / 100
f = abs( new_value - current_value ) > calculated_threshold
* If Threshold.db1=0 and Threshold.db2=0, do not add Deadband filter.
* Element Scale
** Unneccessary when Scale.min=0 and Scale.max=0
* If Critical.min=0 and Critical.max=0, following elements/attrbutes are not neccessary
** Element Critical
** Attribute "db2" of element "Threshold"
<big>Example 1</big>
Both '''DB1''' and '''DB2''' active
<syntaxhighlight lang="xml">
<Filter class="Deadband">
  <Scale min="1" max="4" />
  <Threshold db1="2" db2="2" />
  <Critical min="2" max="3" />
</Filter>
</syntaxhighlight>
<big>Example 2</big>
Works only on '''normalized''' values ( no element Scale )
'''DB2''' inactive
<syntaxhighlight lang="xml">
<Filter class="Deadband">
  <Threshold db1="2"/>
</Filter>
</syntaxhighlight>
<big>Example 3</big>
Works on '''normalized''' and '''floating point''' values
'''DB2''' inactive
<syntaxhighlight lang="xml">
<Filter class="Deadband">
  <Scale min="1" max="4" />
  <Threshold db1="2"/>
</Filter>
</syntaxhighlight>
===== Fallback =====
Falls back to specified value.
===== Normalize =====
This filter is used for converting floating point value to normalized value.
This filter works only on floating point values. Normalized values shall be passed on without change
<syntaxhighlight lang="xml">
<Filter class="Normalize">
<To>-1...1</To>
<Max>100</Max>
<Min>10</Min>
</Filter>
</syntaxhighlight>
Element '''To'''  has two possible value: '''-1...1''' or '''0...1''' and this selects the formula and overflow conditions being used.
====== Range -1...1 ======
normalized_value=float_value/Max
overflow is set when '''normalized_value < -1 && normalized_value > 1'''
No element '''Min''' for this range
====== Range 0...1 ======
normalized_value=(float_value-Min)/(Max-Min)
overflow is set when '''normalized_value < 0 && normalized_value > 1'''
===== Inversion =====
Inverts the passed digital value..
===== If-else =====
Input: digital value
This is not final!
<syntaxhighlight lang="xml">
<Filter class="IfElse">
<True>
    <Filter class="AddToBuffer">
      <Target ref="DO_device_output1_buf"/> 
    </Filter>
</True>
<False>
    <Filter class="AddToBuffer">
      <Target ref="DO_device_output2_buf"/> 
    </Filter>
</False>
</Filter>
</syntaxhighlight>
===== OutputController =====
This filter is used with Formulas when output controlling is needed.
* Count
** Default value if count not specified, '''1'''
** Number of output commands
** Integer: '''1...X''' ( X = uint32_t )
** String: '''inf''' ( infinity, if Count is not convertable to integer, then inifinity is used)
* Retry
** time to wait before retry/next command
** default value if not specified, 5 seconds
* FirstControl
** Defines if first control operation is allowed
<syntaxhighlight lang="xml">
<Filter class="OutputController">
  <Count>1</Count>
  <Retry unit="second">5</Retry>
  <FirstControl>1</FirstControl>
  <Filter class="Assert">
    <Ref>DO_device_status</Ref>
    <Filter class="AddToBuffer">
      <Target ref="DO_device_output1_buf"/> 
    </Filter>
  </Filter>
</Filter>
</syntaxhighlight>
===== Proxy =====
'''Proxy''' may have more than one next '''Filter'''.
<syntaxhighlight lang="xml">
<Filter class="Proxy">
<Filter class="AddToBuffer" />
<Filter class="AddToBuffer" />
<Filter class="Fallback" />
</Filter>
</syntaxhighlight>
===== Scale =====
This filter works only on normalized values. Non-normalized(floating point) values shall be passed on without change
scaled_value=normalized_value*(Max-Min)+Min
<syntaxhighlight lang="xml">
<Filter class="Scale">
<Max>100</Max>
<Min>10</Min>
</Filter>
</syntaxhighlight>
If element '''Min'''=0 then no need to define that element, value 0 is used as default for Min.
Element '''Max''' must always exist.
Element '''To''' is not used.
===== CsvLogger =====
??? kas teha filtrina või mõni muu lahendus?
===== UpdateValue =====
'''Target''' is a MxValue object.
<syntaxhighlight lang="xml">
<Filter class="UpdateValue">
<Target ref="DI_7_value"/>
</Filter>
</syntaxhighlight>
===== Square =====
===== SquareRoot =====
===== Sine =====
===== Cosine =====
===== Tangent =====
===== Cotangent =====
f = 1 / tan(x)
===== Secant =====
f = 1 / cos(x)
===== Cosecant =====
f = 1 / sin(x)
===== log =====
===== log10 =====
===== exp =====
==== Element: Buffer ====
Defines a buffer object, with depth.
<syntaxhighlight lang="xml">
<Buffer id="DI_8_0_buf">
<Depth>10</Depth>
</Buffer>
</syntaxhighlight>
=== Element: Formula ===
Possible child elements:
*'''[[Gw_XML_setup#Element:_Buffer | Buffer]]'''
*'''[[Gw_XML_setup#Element:_MxValue | MxValue]]'''
*'''[[Gw_XML_setup#Element:_Filter | Filter]]'''
*'''[[Gw_XML_setup#Element:_Expression | Expression]]'''
Attribute: type - This defines the result type of formula. Possible choices DI, AI, CN
==== Element: Expression ====
Element name '''Expression''' may be abbreviated as '''Exp'''
Element name '''Operation''' may be abbreviated as '''O'''
Elements '''a''' and '''b''' are current expressions inputs.
{| class="wikitable sortable"
|-
! Operation !! operand count !! example !! description
|-
| and || ∞, a<sub>1</sub> a<sub>2</sub> ... a<sub>n</sub> || a<sub>1</sub> &and; a<sub>2</sub> &and; a<sub>n</sub>
|-
| or || ∞, a<sub>1</sub> a<sub>2</sub> ... a<sub>n</sub> || a<sub>1</sub> &or; a<sub>2</sub> &or; a<sub>n</sub>
|-
| add || ∞, a<sub>1</sub> a<sub>2</sub> ... a<sub>n</sub> || a<sub>1</sub> + a<sub>2</sub> + a<sub>n</sub>
|-
| sub || ∞, a<sub>1</sub> a<sub>2</sub> ... a<sub>n</sub> || a<sub>1</sub> &minus; a<sub>2</sub> &minus; a<sub>n</sub>
|-
| not || 1, a || !a
|-
| sqr || 1, a || a²
|-
| sqrt || 1, a || &radic;a
|-
| sin || 1, a || sin(a)
|-
| cos || 1, a || cos(a)
|-
| tan || 1, a || tan(a)
|-
| arcsin || 1, a || arcsin(a)
|-
| arccos || 1, a || arccos(a)
|-
| arctan || 1, a || arctan(a)
|-
| sec || 1, a || 1 / cos(a)
|-
| cosec || 1, a || 1 / sin(a)
|-
| cotan || 1, a || 1 / tan(a)
|-
| log || 1, a || log<sub>e</sub>(a) || The natural logarithm is the base-e logarithm, the inverse of the natural exponential function (exp)
|-
| log10 || 1, a || log<sub>10</sub>(a) || Returns the common (base-10) logarithm of x
|-
| exp || 1, a || exp(a) || Returns the base-e exponential function of x, which is the '''e''' number raised to the power x.
|-
| mul || 2, a b || a*b
|-
| div || 2, a b || a/b
|-
| pow || 2, a b || a^b
|-
| xor || 2, a b || a&oplus;b
|-
| eq || 2, a b || a = b || Check equality
|-
| lt || 2, a b || a < b || Less than
|-
| gt || 2, a b || a > b || Greater than
|}
===== example 1: or =====
f = a<sub>1</sub> &or; a<sub>2</sub>
<syntaxhighlight lang="xml">
<Expression>
    <Operation>or<Operation/>
    <a>Buffer</a>
    <a>MxValue</a>
    <Filter />
</Expression>
</syntaxhighlight>
===== example 2: power =====
f = a^b
<syntaxhighlight lang="xml">
<Expression>
    <Operation>pow<Operation/>
    <a>Buffer</a>
    <b>Buffer</b>
    <Filter/>
</Expression>
</syntaxhighlight>
==== Formula example 1 ====
f = @1 or @2
<syntaxhighlight lang="xml">
<Formula type="DI" id="DI_f0" comment="Virtual1 OK">
      <MxValue id="DI_f0_value"/>
      <Buffer id="DI_f0_0_0_buf" /> <!-- @1 -->
      <Buffer id="DI_f0_0_1_buf" /> <!-- @2 -->
      <Expression>                  <!-- @1 or @2 -->
          <O>or<O/>
          <a>DI_f0_0_0_buf</a>
          <a>DI_f0_0_1_buf</a>
          <Filter ref="DI_f0_filter" />
      </Expression>
      <Filter id="DI_f0_filter" class="Change">  <!-- result filter -->
          <Filter class="UpdateValue">
              <Target ref="DI_f0_value"/>
              <Filter class="AddToBuffer" />
          </Filter>
      </Filter>
</Formula>
</syntaxhighlight>
'''DI_f0_0_0_buf''' and '''DI_f0_0_1_buf''' are inputs to formula.
==== Formula example 2 ====
f = (@1 + @2) / (@3 + @4)
<syntaxhighlight lang="xml">
<Formula type="DI" id="DI_f0" comment="formula example 2, f = (@1 + @2) / (@3 + @4)">
    <MxValue id="DI_f0_value"/>  <!-- This variable holds the latest value of formula -->
    <Buffer id="DI_f0_1_buf" />  <!-- @1 -->
    <Buffer id="DI_f0_2_buf" />  <!-- @2 -->
    <Buffer id="DI_f0_3_buf" />  <!-- @3 -->
    <Buffer id="DI_f0_4_buf" />  <!-- @4 -->
    <Buffer id="DI_f0_t1_buf" /> <!-- temporary result of @1 + @2 -->
    <Buffer id="DI_f0_t2_buf" /> <!-- temporary result of @2 + @3 -->
    <Expression>                <!-- @1 + @2 -->
        <O>add</O>
        <a>DI_f0_1_buf</a>      <!-- @1 -->
        <a>DI_f0_2_buf</a>      <!-- @2 -->
        <Filter class="AddToBuffer">
            <Target ref="DI_f0_t1_buf"/>
        </Filter>
    </Expression>
    <Expression>                <!-- @3 + @4 -->
        <O>add</O>
        <a>DI_f0_3_buf</a>      <!-- @3 -->
        <a>DI_f0_4_buf</a>      <!-- @4 -->
        <Filter class="AddToBuffer">
            <Target ref="DI_f0_t2_buf"/>
        </Filter>
    </Expression>
    <Expression>                <!-- f = (@1 + @2) / (@3 + @4) -->
        <O>div</O>
        <a>DI_f0_t1_buf</a>      <!-- @1 + @2 -->
        <a>DI_f0_t2_buf</a>      <!-- @3 + @4 -->
        <Filter ref="di_f0_filter" />
    </Expression>
    <Filter id="di_f0_filter" class="AddToBuffer"> <!-- result filter -->
        <Target ref="DI_SCADA_buf"/>
    </Filter>
</Formula>
</syntaxhighlight>
==== Formula example 3 ====
Comparison with constant
f = @1 &lt; 3,5
<syntaxhighlight lang="xml">
<Formula type="DI" id="DI_f0" comment="Formula example 3, constant, f = @1 < 3,5">
      <MxValue id="DI_f0_value"/>  <!-- latest value of formula -->
      <Buffer id="AI_f0_0_0_buf" /> <!-- @1 -->
      <Expression>                  <!-- @1 < 3,5 -->
          <O>lt<O/>
          <a>AI_f0_0_0_buf</a>
          <b><MxValue>3.5</MxValue></b>
          <Filter ref="DI_f0_filter" />
      </Expression>
      <Filter id="DI_f0_filter" class="Change">  <!-- result filter -->
          <Filter class="UpdateValue">
              <Target ref="DI_f0_value"/>
              <Filter class="AddToBuffer" />
          </Filter>
      </Filter>
</Formula>
</syntaxhighlight>
== Element: Interfaces ==
== Element: Interfaces ==
Network setup
Network setup


Has at least one '''Interface''' element.
Has at least one '''Interface''' element.
 
<syntaxhighlight lang="xml">
  <Interface name="eth0">
  <Interface name="eth0">
<IpAddress>192.168.0.111</IpAddress>
        <IpAddress>192.168.0.111</IpAddress>
<Netmask>255.255.255.0</Netmask>
        <Netmask>255.255.255.0</Netmask>
<Gateway>192.168.0.1</Gateway>
        <Gateway>192.168.0.1</Gateway>
  </Interface>
  </Interface>
</syntaxhighlight>
=== VLAN ===
Example with required elements.
<syntaxhighlight lang="xml">
<Vlan interface="eth0">
    <VlanId>10</VlanId>
    <VlanIngressQos>4</VlanIngressQos>
    <VlanEgressQos>4</VlanEgressQos>
    <IpIngressQos>0</IpIngressQos>
    <IpEgressQos>0</IpEgressQos>
</Vlan>
</syntaxhighlight>
Example with additional elements from '''Interface'''
<syntaxhighlight lang="xml">
<Vlan interface="eth0">
    <VlanId>131</VlanId>
    <VlanIngressQos>4</VlanIngressQos>
    <VlanEgressQos>4</VlanEgressQos>
    <IpIngressQos>0</IpIngressQos>
    <IpEgressQos>0</IpEgressQos>
    <IpAddress>172.18.0.11</IpAddress>
    <Netmask>255.255.255.0</Netmask>
    <Gateway>172.18.0.254</Gateway>
</Vlan>
</syntaxhighlight>

Latest revision as of 11:09, 31 August 2012

Element: Setup

The XML setup starts with the tag Setup. The entire setup is contained in this element.

All id attributes must be unique!

This element contains:

  • Element: Device
    • At least one element of this type.
  • Attribute: device
    • If more than one Device element available. This attribute specifies the id of the Device to use as current setup.


 <Setup device="Telem-Gw6-1">
 	<Device id="Telem-Gw6-1" />
 	<Device id="Gw1" />
 	<Device id="Gw2" />
 </Setup>

Element: Device

This element contains setup for a specific device. This might be Gw itself or some substation device or SCADA device.

This element contains:

Child elements of Device when used as GW device

 <Device id="Telem-Gw6-1">
 	<Channel />
 	<Interfaces />
 </Device>

Child elements of Device when used as the device we're connecting to.

 <Device id="DI-24T-1">
 	<Protocol />
 	<Objects />
 </Device>

Element: Channel

This element contains:

 <Channel id="DI-24T-1">
 	<Port />
 	<Device />
 	<Objects />
 </Channel>

Element: Protocol

 <Protocol comment="protocol8" id="prot_8_0">
 	<Address />
 	<CommunicationDelay unit="millisecond">0</CommunicationDelay>
 	<PollingTimeout unit="millisecond">500</PollingTimeout>
 	<TimeSync />
 	<TimeoutRemoveCount>5</TimeoutRemoveCount>
 	<TimeoutRemoveTime unit="second">20</TimeoutRemoveTime>
 	<ReplaceTime>false</ReplaceTime>
 	<GeneralInterrogationForwarding>false</GeneralInterrogationForwarding>
 	<Type SubVersion="0" isMaster="false">IEC101UnBalanced</Type>
 </Protocol>

Element: TimeSync

Timesync interval and correction setup

 <TimeSync isEnabled="true">
 	<Interval unit="second">30</Interval>
 	<Correction />
 </TimeSync>

Element: Correction

Possible timesync correction types:

  • Absolute
    • Timesync message shall always be modified by this amount.
  • ConnectionSpeed
    • Baudrate based(only when using serial port)
 <Correction>
 	<Absolute enabled="true" unit="millisecond">0</Absolute>
 	<ConnectionSpeed enabled="true"/>
 </Correction>

Element: Address

This element can refer to protocol address or some specific object address.

Address for protocol

This elements contents depend on the protocol selected

Iec-10x

 <Address>
 	<LinkAddress>1</LinkAddress>
 	<LinkAddressLength>1</LinkAddressLength>
 	<AsduAddress>1</AsduAddress>
 	<AsduAddressLength>2</AsduAddressLength>
 	<ObjectAddressLength>2</ObjectAddressLength>
 </Address>

MODBUS

Value: integer

 <Address>2</Address>

IEC62056-21

Value: string

Can be empty if only one device on channel.

 <Address id="0.0.0">addr123</Address>

If this Address element contains attribute id, It shall be used for device verification.

Address of object

Iec-101/104

Value: integer

 <Address index="0">10</Address>

attribute index is unnecessary if value==0


Iec-103

 <Address fnCode="3" infoNr="6"/>

SPA-Bus

Kas standardis on dataType või dataCode vastava välja nimetus?

Väärtuse 1234 oleks ka võibolla mõistlik attribuuti dataNumber tõsta

Kas DI'l index on kasutused?

DI
 <Address index="3" onEvent="6" offEvent="6" channelNumber="6" dataType="I">1234</Address>

Alternatiiv:

 <Address onEvent="6" offEvent="6" channelNumber="6" dataCode="I" dataNumber="1234" />
AI
 <Address channelNumber="6" dataType="I">1234</Address>

Alternatiiv:

 <Address channelNumber="6" dataCode="I" dataNumber="1234" />
CN
 <Address channelNumber="6" dataType="I">1234</Address>

Alternatiiv:

 <Address channelNumber="6" dataCode="I" dataNumber="1234" />

IEC61580/IEC62056-21

Value: string

 <Address>5.3.5</Address>

Other

Other protocols might have additional fields.

Element: Port

 <Port>
        <Buffer id="inBuffer"/>
        <Buffer id="outBuffer"/>
        <IoBuffer in="inBuffer" out="outBuffer"/>
 </Port>

Port data forwarding

It is possible to send data from one port to another.

To do that, port1's input buffer is the same as port2's outputbuffer and vice versa.

 <Port id="port1">
        <Buffer id="portBufferIn"/>
        <Buffer id="portBufferOut"/>
        <IoBuffer in="portBufferIn" out="portBufferOut"/>
 </Port>
 <Port id="port2">
        <IoBuffer in="portBufferOut" out="portBufferIn"/>
 </Port>

The same method allows creation of a local loopback.

 <Port id="portLoopback">
        <Buffer id="portBuffer"/>
        <IoBuffer in="portBuffer" out="portBuffer"/>
 </Port>

Serial port

 <Port class="SerialPortSetup">
 	<BaudRate>9600</BaudRate>
 	<DataBits>8</DataBits>
 	<StopBits>1</StopBits>
 	<Parity>none</Parity>
 	<FlowControl>none</FlowControl>
 </Port>

TCP/IP server

 <Port class="TcpIpServerSetup">
 	<PortNumber>80</PortNumber>
 	<ClientIpMask>0.0.0.0</ClientIpMask>
 	<Interface>eth0</Interface>
 </Port>

Element: ClientIpMask

Defines who is allowed to connect with us. More than one possible.

TCP/IP client

 <Port class="TcpIpClientSetup" name="16">
 	<PortNumber>502</PortNumber>
 	<IpAddress>10.0.0.89</IpAddress>
 	<Interface>eth0</Interface>
 </Port>

Virtual port

They are ports 3-5 on GW6.

 <Port class="VirtualPortSetup">
 	<Port class="SerialPortSetup">
 	      <BaudRate>9600</BaudRate>
 	      <DataBits>8</DataBits>
 	      <StopBits>1</StopBits>
 	      <Parity>none</Parity>
 	      <FlowControl>none</FlowControl>
 	</Port>
 </Port>

Element: Objects

Element: Object

Depending on protocol the object belongs to (master/slave), has different child elements.

Possible child elements:

Attribute: type

Defines object type.

Possible values:

  • DI
  • AI
  • CN
  • DO
  • AO


Element: MxValue

Defines the object for current/latest value.

Child elements define default value, flags and time tag.

 <MxValue id="DI_6_value">
 	<Value>0</Value>
 	<BitMask>
 		<Bit>Invalid</Bit>
 		<Bit>NotTopical</Bit>
 	</BitMask>
 </MxValue>

Element: Filter

Defines what is going to happen to the incoming measured value.

Filters can be daisy chained. To achieve different outcomes.

When an event is received, it is sent to it's filter. After the filter does what it's supposed to do, it will pass the event to the Next Filter

 <Filter class="Change">
 	<Filter class="Proxy" />
 </Filter>
AddToBuffer

AddToBuffer may have more than one Target.

Target is a Buffer object.

 <Filter class="AddToBuffer">
 	<Target ref="DI_0_7_buf"/>
 	<Target ref="DI_1_7_buf"/>
 	<Target ref="DI_2_7_buf"/>
 	<Target ref="DI_3_7_buf"/>
 	<Target ref="DI_4_7_buf"/>
 </Filter>
Assert

Passes event to the next filter only if specified target(MxValue) == false.

Possible use cases:

  • Respond negatively to control commands
  • Signal blocking


 <Filter class="Assert">
 	<Ref>DI_7_value<Ref/>
 </Filter>
Change

Detects change in Digital measurments value and status bits.

Deadband

Used to detect change in analog and counter values

 <Filter class="Deadband">
         <Type>X</Type>
         [...]
 </Filter>
  • Type
    • Default is Deadband1, if Deadband1 then element Type is unnecessary
Integral

New deadband type, not implemented.

Absolute

This deadband is used for counter values.

f = abs( new_value - current_value ) > Threshold
  • Threshold
    • Integer value
    • If value=0; then no need for filter
<Filter class="Deadband">
 <Type>Absolute</Type>
 <Threshold>X</Threshold>
</Filter>
Deadband1/Legacy

This is the legacy GW6 deadband mode This deadband is used for analog values.

if( (new_value < Critical.min) || (new_value > Critical.max) )
{
    current_threshold = Threshold.db2
}
else 
{
    current_threshold = Threshold.db1
}

if ( new_value.is_normalized )
    calculated_threshold = current_threshold / 100
else
    calculated_threshold = (Scale.max - Scale.min) * current_threshold / 100

f = abs( new_value - current_value ) > calculated_threshold
  • If Threshold.db1=0 and Threshold.db2=0, do not add Deadband filter.
  • Element Scale
    • Unneccessary when Scale.min=0 and Scale.max=0
  • If Critical.min=0 and Critical.max=0, following elements/attrbutes are not neccessary
    • Element Critical
    • Attribute "db2" of element "Threshold"

Example 1

Both DB1 and DB2 active

 <Filter class="Deadband">
  <Scale min="1" max="4" />
  <Threshold db1="2" db2="2" />
  <Critical min="2" max="3" />
 </Filter>

Example 2

Works only on normalized values ( no element Scale )

DB2 inactive

 <Filter class="Deadband">
  <Threshold db1="2"/>
 </Filter>

Example 3

Works on normalized and floating point values

DB2 inactive

 <Filter class="Deadband">
  <Scale min="1" max="4" />
  <Threshold db1="2"/>
 </Filter>
Fallback

Falls back to specified value.

Normalize

This filter is used for converting floating point value to normalized value.

This filter works only on floating point values. Normalized values shall be passed on without change

 <Filter class="Normalize">
 	<To>-1...1</To>
 	<Max>100</Max>
 	<Min>10</Min>
 </Filter>

Element To has two possible value: -1...1 or 0...1 and this selects the formula and overflow conditions being used.

Range -1...1
normalized_value=float_value/Max

overflow is set when normalized_value < -1 && normalized_value > 1

No element Min for this range

Range 0...1
normalized_value=(float_value-Min)/(Max-Min)

overflow is set when normalized_value < 0 && normalized_value > 1

Inversion

Inverts the passed digital value..

If-else

Input: digital value

This is not final!

<Filter class="IfElse">
<True>
    <Filter class="AddToBuffer">
      <Target ref="DO_device_output1_buf"/>  
    </Filter>
</True>
<False>
    <Filter class="AddToBuffer">
      <Target ref="DO_device_output2_buf"/>  
    </Filter>
</False>
</Filter>
OutputController

This filter is used with Formulas when output controlling is needed.

  • Count
    • Default value if count not specified, 1
    • Number of output commands
    • Integer: 1...X ( X = uint32_t )
    • String: inf ( infinity, if Count is not convertable to integer, then inifinity is used)
  • Retry
    • time to wait before retry/next command
    • default value if not specified, 5 seconds
  • FirstControl
    • Defines if first control operation is allowed
<Filter class="OutputController">
  <Count>1</Count>
  <Retry unit="second">5</Retry>
  <FirstControl>1</FirstControl>
  <Filter class="Assert">
    <Ref>DO_device_status</Ref>
    <Filter class="AddToBuffer">
      <Target ref="DO_device_output1_buf"/>  
    </Filter>
  </Filter>
</Filter>
Proxy

Proxy may have more than one next Filter.

 <Filter class="Proxy">
 	<Filter class="AddToBuffer" />
 	<Filter class="AddToBuffer" />
 	<Filter class="Fallback" />
 </Filter>
Scale

This filter works only on normalized values. Non-normalized(floating point) values shall be passed on without change

scaled_value=normalized_value*(Max-Min)+Min
 <Filter class="Scale">
 	<Max>100</Max>
 	<Min>10</Min>
 </Filter>

If element Min=0 then no need to define that element, value 0 is used as default for Min. Element Max must always exist. Element To is not used.

CsvLogger

??? kas teha filtrina või mõni muu lahendus?

UpdateValue

Target is a MxValue object.

 <Filter class="UpdateValue">
 	<Target ref="DI_7_value"/>
 </Filter>
Square
SquareRoot
Sine
Cosine
Tangent
Cotangent
f = 1 / tan(x)
Secant
f = 1 / cos(x)
Cosecant
f = 1 / sin(x)
log
log10
exp

Element: Buffer

Defines a buffer object, with depth.

 <Buffer id="DI_8_0_buf">
 	<Depth>10</Depth>
 </Buffer>

Element: Formula

Possible child elements:

Attribute: type - This defines the result type of formula. Possible choices DI, AI, CN

Element: Expression

Element name Expression may be abbreviated as Exp

Element name Operation may be abbreviated as O

Elements a and b are current expressions inputs.

Operation operand count example description
and ∞, a1 a2 ... an a1 ∧ a2 ∧ an
or ∞, a1 a2 ... an a1 ∨ a2 ∨ an
add ∞, a1 a2 ... an a1 + a2 + an
sub ∞, a1 a2 ... an a1 − a2 − an
not 1, a !a
sqr 1, a
sqrt 1, a √a
sin 1, a sin(a)
cos 1, a cos(a)
tan 1, a tan(a)
arcsin 1, a arcsin(a)
arccos 1, a arccos(a)
arctan 1, a arctan(a)
sec 1, a 1 / cos(a)
cosec 1, a 1 / sin(a)
cotan 1, a 1 / tan(a)
log 1, a loge(a) The natural logarithm is the base-e logarithm, the inverse of the natural exponential function (exp)
log10 1, a log10(a) Returns the common (base-10) logarithm of x
exp 1, a exp(a) Returns the base-e exponential function of x, which is the e number raised to the power x.
mul 2, a b a*b
div 2, a b a/b
pow 2, a b a^b
xor 2, a b a⊕b
eq 2, a b a = b Check equality
lt 2, a b a < b Less than
gt 2, a b a > b Greater than
example 1: or
f = a1 ∨ a2
<Expression>
    <Operation>or<Operation/>
    <a>Buffer</a>
    <a>MxValue</a>
    <Filter />
</Expression>
example 2: power
f = a^b
 <Expression>
    <Operation>pow<Operation/>
    <a>Buffer</a>
    <b>Buffer</b>
    <Filter/>
 </Expression>

Formula example 1

f = @1 or @2
 <Formula type="DI" id="DI_f0" comment="Virtual1 OK">
      <MxValue id="DI_f0_value"/>
      <Buffer id="DI_f0_0_0_buf" /> <!-- @1 -->
      <Buffer id="DI_f0_0_1_buf" /> <!-- @2 -->
      <Expression>                  <!-- @1 or @2 -->
          <O>or<O/>
          <a>DI_f0_0_0_buf</a>
          <a>DI_f0_0_1_buf</a>
          <Filter ref="DI_f0_filter" />
      </Expression>
      <Filter id="DI_f0_filter" class="Change">  <!-- result filter -->
          <Filter class="UpdateValue">
              <Target ref="DI_f0_value"/>
              <Filter class="AddToBuffer" />
          </Filter>
      </Filter>
 </Formula>

DI_f0_0_0_buf and DI_f0_0_1_buf are inputs to formula.


Formula example 2

f = (@1 + @2) / (@3 + @4)
 <Formula type="DI" id="DI_f0" comment="formula example 2, f = (@1 + @2) / (@3 + @4)">
    <MxValue id="DI_f0_value"/>  <!-- This variable holds the latest value of formula -->
    <Buffer id="DI_f0_1_buf" />  <!-- @1 -->
    <Buffer id="DI_f0_2_buf" />  <!-- @2 -->
    <Buffer id="DI_f0_3_buf" />  <!-- @3 -->
    <Buffer id="DI_f0_4_buf" />  <!-- @4 -->
    <Buffer id="DI_f0_t1_buf" /> <!-- temporary result of @1 + @2 -->
    <Buffer id="DI_f0_t2_buf" /> <!-- temporary result of @2 + @3 -->
    <Expression>                 <!-- @1 + @2 -->
        <O>add</O>
        <a>DI_f0_1_buf</a>       <!-- @1 -->
        <a>DI_f0_2_buf</a>       <!-- @2 -->
        <Filter class="AddToBuffer">
            <Target ref="DI_f0_t1_buf"/>
        </Filter>
    </Expression>
    <Expression>                 <!-- @3 + @4 -->
        <O>add</O>
        <a>DI_f0_3_buf</a>       <!-- @3 -->
        <a>DI_f0_4_buf</a>       <!-- @4 -->
        <Filter class="AddToBuffer">
            <Target ref="DI_f0_t2_buf"/>
        </Filter>
    </Expression>
    <Expression>                 <!-- f = (@1 + @2) / (@3 + @4) -->
        <O>div</O>
        <a>DI_f0_t1_buf</a>      <!-- @1 + @2 -->
        <a>DI_f0_t2_buf</a>      <!-- @3 + @4 -->
        <Filter ref="di_f0_filter" />
    </Expression>
    <Filter id="di_f0_filter" class="AddToBuffer"> <!-- result filter -->
        <Target ref="DI_SCADA_buf"/>
    </Filter>
 </Formula>

Formula example 3

Comparison with constant

f = @1 < 3,5
 <Formula type="DI" id="DI_f0" comment="Formula example 3, constant, f = @1 < 3,5">
      <MxValue id="DI_f0_value"/>   <!-- latest value of formula -->
      <Buffer id="AI_f0_0_0_buf" /> <!-- @1 -->
      <Expression>                  <!-- @1 < 3,5 -->
          <O>lt<O/>
          <a>AI_f0_0_0_buf</a>
          <b><MxValue>3.5</MxValue></b>
          <Filter ref="DI_f0_filter" />
      </Expression>
      <Filter id="DI_f0_filter" class="Change">  <!-- result filter -->
          <Filter class="UpdateValue">
              <Target ref="DI_f0_value"/>
              <Filter class="AddToBuffer" />
          </Filter>
      </Filter>
 </Formula>

Element: Interfaces

Network setup

Has at least one Interface element.

 <Interface name="eth0">
        <IpAddress>192.168.0.111</IpAddress>
        <Netmask>255.255.255.0</Netmask>
        <Gateway>192.168.0.1</Gateway>
 </Interface>

VLAN

Example with required elements.

 <Vlan interface="eth0">
     <VlanId>10</VlanId>
     <VlanIngressQos>4</VlanIngressQos>
     <VlanEgressQos>4</VlanEgressQos>
     <IpIngressQos>0</IpIngressQos>
     <IpEgressQos>0</IpEgressQos>
 </Vlan>

Example with additional elements from Interface

 <Vlan interface="eth0">
     <VlanId>131</VlanId>
     <VlanIngressQos>4</VlanIngressQos>
     <VlanEgressQos>4</VlanEgressQos>
     <IpIngressQos>0</IpIngressQos>
     <IpEgressQos>0</IpEgressQos>
     <IpAddress>172.18.0.11</IpAddress>
     <Netmask>255.255.255.0</Netmask>
     <Gateway>172.18.0.254</Gateway>
 </Vlan>