tests/BACnet/plc.xml
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Tue, 25 Sep 2018 19:00:03 +0300
changeset 2343 33071a451021
parent 2254 3145dcffc6ed
child 2346 ac16bad593cf
permissions -rw-r--r--
Don't need to call extra _init_

_init_ is already called for value in infos["elmt_type"]["initial"]().
Additional _init_() creates second set of child element and that
creates unusable xml project.
This regression cause by not well tested commit "Proper fix for error
'object has no attribute 'getSlave' in EtherCAT extension" (96ca6b056c55595f71bfaca9f54b9e8646460c23)
<?xml version='1.0' encoding='utf-8'?>
<project xmlns:ns1="http://www.plcopen.org/xml/tc6_0201" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.plcopen.org/xml/tc6_0201">
  <fileHeader companyName="Unknown" productName="Unnamed" productVersion="1" creationDateTime="2018-07-28T02:24:08"/>
  <contentHeader name="BACnet" modificationDateTime="2018-07-29T01:54:59">
    <coordinateInfo>
      <fbd>
        <scaling x="0" y="0"/>
      </fbd>
      <ld>
        <scaling x="0" y="0"/>
      </ld>
      <sfc>
        <scaling x="0" y="0"/>
      </sfc>
    </coordinateInfo>
  </contentHeader>
  <types>
    <dataTypes/>
    <pous>
      <pou name="program0" pouType="program">
        <interface>
          <localVars>
            <variable name="EnergyCounter" address="%MD0.2.0">
              <type>
                <REAL/>
              </type>
            </variable>
            <variable name="Temperature" address="%ID0.0.0">
              <type>
                <REAL/>
              </type>
            </variable>
            <variable name="Humidity" address="%ID0.0.1">
              <type>
                <REAL/>
              </type>
            </variable>
          </localVars>
          <localVars>
            <variable name="TempSimulation">
              <type>
                <derived name="Simulator"/>
              </type>
            </variable>
            <variable name="HumiditySimulation">
              <type>
                <derived name="Simulator"/>
              </type>
            </variable>
          </localVars>
          <localVars>
            <variable name="TemperatureSetPoint" address="%QD0.1.0">
              <type>
                <REAL/>
              </type>
            </variable>
            <variable name="ControlDisable" address="%QX0.4.2">
              <type>
                <BOOL/>
              </type>
            </variable>
            <variable name="Heater" address="%IX0.3.0">
              <type>
                <BOOL/>
              </type>
            </variable>
            <variable name="Cooler" address="%IX0.3.1">
              <type>
                <BOOL/>
              </type>
            </variable>
          </localVars>
        </interface>
        <body>
          <FBD>
            <inVariable localId="1" executionOrderId="0" height="30" width="105" negated="false">
              <position x="299" y="521"/>
              <connectionPointOut>
                <relPosition x="105" y="15"/>
              </connectionPointOut>
              <expression>EnergyCounter</expression>
            </inVariable>
            <outVariable localId="2" executionOrderId="0" height="30" width="105" negated="false">
              <position x="654" y="521"/>
              <connectionPointIn>
                <relPosition x="0" y="15"/>
                <connection refLocalId="3" formalParameter="OUT">
                  <position x="654" y="536"/>
                  <position x="533" y="536"/>
                </connection>
              </connectionPointIn>
              <expression>EnergyCounter</expression>
            </outVariable>
            <block localId="3" typeName="ADD" executionOrderId="0" height="60" width="67">
              <position x="466" y="506"/>
              <inputVariables>
                <variable formalParameter="IN1">
                  <connectionPointIn>
                    <relPosition x="0" y="30"/>
                    <connection refLocalId="1">
                      <position x="466" y="536"/>
                      <position x="404" y="536"/>
                    </connection>
                  </connectionPointIn>
                </variable>
                <variable formalParameter="IN2">
                  <connectionPointIn>
                    <relPosition x="0" y="50"/>
                    <connection refLocalId="4">
                      <position x="466" y="556"/>
                      <position x="436" y="556"/>
                      <position x="436" y="585"/>
                      <position x="401" y="585"/>
                    </connection>
                  </connectionPointIn>
                </variable>
              </inputVariables>
              <inOutVariables/>
              <outputVariables>
                <variable formalParameter="OUT">
                  <connectionPointOut>
                    <relPosition x="67" y="30"/>
                  </connectionPointOut>
                </variable>
              </outputVariables>
            </block>
            <inVariable localId="4" executionOrderId="0" height="30" width="105" negated="false">
              <position x="296" y="570"/>
              <connectionPointOut>
                <relPosition x="105" y="15"/>
              </connectionPointOut>
              <expression>0.00131</expression>
            </inVariable>
            <comment localId="5" height="67" width="229">
              <position x="27" y="525"/>
              <content>
                <xhtml:p><![CDATA[Always consume some energy]]></xhtml:p>
              </content>
            </comment>
            <block localId="6" typeName="Simulator" instanceName="TempSimulation" executionOrderId="0" height="115" width="134">
              <position x="188" y="661"/>
              <inputVariables>
                <variable formalParameter="MinVal">
                  <connectionPointIn>
                    <relPosition x="0" y="35"/>
                    <connection refLocalId="8">
                      <position x="188" y="696"/>
                      <position x="138" y="696"/>
                    </connection>
                  </connectionPointIn>
                </variable>
                <variable formalParameter="MaxVal">
                  <connectionPointIn>
                    <relPosition x="0" y="66"/>
                    <connection refLocalId="9">
                      <position x="188" y="727"/>
                      <position x="138" y="727"/>
                    </connection>
                  </connectionPointIn>
                </variable>
                <variable formalParameter="PeriodSeconds">
                  <connectionPointIn>
                    <relPosition x="0" y="97"/>
                    <connection refLocalId="10">
                      <position x="188" y="758"/>
                      <position x="138" y="758"/>
                    </connection>
                  </connectionPointIn>
                </variable>
              </inputVariables>
              <inOutVariables/>
              <outputVariables>
                <variable formalParameter="Out">
                  <connectionPointOut>
                    <relPosition x="134" y="35"/>
                  </connectionPointOut>
                </variable>
              </outputVariables>
            </block>
            <outVariable localId="7" executionOrderId="0" height="30" width="92" negated="false">
              <position x="421" y="681"/>
              <connectionPointIn>
                <relPosition x="0" y="15"/>
                <connection refLocalId="6" formalParameter="Out">
                  <position x="421" y="696"/>
                  <position x="322" y="696"/>
                </connection>
              </connectionPointIn>
              <expression>Temperature</expression>
            </outVariable>
            <inVariable localId="8" executionOrderId="0" height="30" width="105" negated="false">
              <position x="33" y="681"/>
              <connectionPointOut>
                <relPosition x="105" y="15"/>
              </connectionPointOut>
              <expression>18.0</expression>
            </inVariable>
            <inVariable localId="9" executionOrderId="0" height="30" width="105" negated="false">
              <position x="33" y="712"/>
              <connectionPointOut>
                <relPosition x="105" y="15"/>
              </connectionPointOut>
              <expression>30.0</expression>
            </inVariable>
            <inVariable localId="10" executionOrderId="0" height="30" width="105" negated="false">
              <position x="33" y="743"/>
              <connectionPointOut>
                <relPosition x="105" y="15"/>
              </connectionPointOut>
              <expression>120</expression>
            </inVariable>
            <block localId="11" typeName="Simulator" instanceName="HumiditySimulation" executionOrderId="0" height="115" width="134">
              <position x="185" y="803"/>
              <inputVariables>
                <variable formalParameter="MinVal">
                  <connectionPointIn>
                    <relPosition x="0" y="35"/>
                    <connection refLocalId="13">
                      <position x="185" y="838"/>
                      <position x="135" y="838"/>
                    </connection>
                  </connectionPointIn>
                </variable>
                <variable formalParameter="MaxVal">
                  <connectionPointIn>
                    <relPosition x="0" y="66"/>
                    <connection refLocalId="14">
                      <position x="185" y="869"/>
                      <position x="135" y="869"/>
                    </connection>
                  </connectionPointIn>
                </variable>
                <variable formalParameter="PeriodSeconds">
                  <connectionPointIn>
                    <relPosition x="0" y="97"/>
                    <connection refLocalId="15">
                      <position x="185" y="900"/>
                      <position x="135" y="900"/>
                    </connection>
                  </connectionPointIn>
                </variable>
              </inputVariables>
              <inOutVariables/>
              <outputVariables>
                <variable formalParameter="Out">
                  <connectionPointOut>
                    <relPosition x="134" y="35"/>
                  </connectionPointOut>
                </variable>
              </outputVariables>
            </block>
            <outVariable localId="12" executionOrderId="0" height="30" width="92" negated="false">
              <position x="418" y="823"/>
              <connectionPointIn>
                <relPosition x="0" y="15"/>
                <connection refLocalId="11" formalParameter="Out">
                  <position x="418" y="838"/>
                  <position x="319" y="838"/>
                </connection>
              </connectionPointIn>
              <expression>Humidity</expression>
            </outVariable>
            <inVariable localId="13" executionOrderId="0" height="30" width="105" negated="false">
              <position x="30" y="823"/>
              <connectionPointOut>
                <relPosition x="105" y="15"/>
              </connectionPointOut>
              <expression>55.0</expression>
            </inVariable>
            <inVariable localId="14" executionOrderId="0" height="30" width="105" negated="false">
              <position x="30" y="854"/>
              <connectionPointOut>
                <relPosition x="105" y="15"/>
              </connectionPointOut>
              <expression>78.0</expression>
            </inVariable>
            <inVariable localId="15" executionOrderId="0" height="30" width="105" negated="false">
              <position x="30" y="885"/>
              <connectionPointOut>
                <relPosition x="105" y="15"/>
              </connectionPointOut>
              <expression>58</expression>
            </inVariable>
            <block localId="16" typeName="GT" executionOrderId="0" height="60" width="67">
              <position x="231" y="1103"/>
              <inputVariables>
                <variable formalParameter="IN1">
                  <connectionPointIn>
                    <relPosition x="0" y="30"/>
                    <connection refLocalId="18">
                      <position x="231" y="1133"/>
                      <position x="132" y="1133"/>
                    </connection>
                  </connectionPointIn>
                </variable>
                <variable formalParameter="IN2">
                  <connectionPointIn>
                    <relPosition x="0" y="50"/>
                    <connection refLocalId="22">
                      <position x="231" y="1153"/>
                      <position x="208" y="1153"/>
                      <position x="208" y="1169"/>
                      <position x="185" y="1169"/>
                    </connection>
                  </connectionPointIn>
                </variable>
              </inputVariables>
              <inOutVariables/>
              <outputVariables>
                <variable formalParameter="OUT">
                  <connectionPointOut>
                    <relPosition x="67" y="30"/>
                  </connectionPointOut>
                </variable>
              </outputVariables>
            </block>
            <inVariable localId="18" executionOrderId="0" height="30" width="92" negated="false">
              <position x="40" y="1118"/>
              <connectionPointOut>
                <relPosition x="92" y="15"/>
              </connectionPointOut>
              <expression>Temperature</expression>
            </inVariable>
            <block localId="19" typeName="AND" executionOrderId="0" height="60" width="67">
              <position x="347" y="1059"/>
              <inputVariables>
                <variable formalParameter="IN1" negated="true">
                  <connectionPointIn>
                    <relPosition x="0" y="30"/>
                    <connection refLocalId="20">
                      <position x="347" y="1089"/>
                      <position x="263" y="1089"/>
                      <position x="263" y="1074"/>
                      <position x="145" y="1074"/>
                    </connection>
                  </connectionPointIn>
                </variable>
                <variable formalParameter="IN2">
                  <connectionPointIn>
                    <relPosition x="0" y="50"/>
                    <connection refLocalId="16" formalParameter="OUT">
                      <position x="347" y="1109"/>
                      <position x="337" y="1109"/>
                      <position x="337" y="1133"/>
                      <position x="298" y="1133"/>
                    </connection>
                  </connectionPointIn>
                </variable>
              </inputVariables>
              <inOutVariables/>
              <outputVariables>
                <variable formalParameter="OUT">
                  <connectionPointOut>
                    <relPosition x="67" y="30"/>
                  </connectionPointOut>
                </variable>
              </outputVariables>
            </block>
            <inVariable localId="20" executionOrderId="0" height="30" width="104" negated="false">
              <position x="41" y="1059"/>
              <connectionPointOut>
                <relPosition x="104" y="15"/>
              </connectionPointOut>
              <expression>ControlDisable</expression>
            </inVariable>
            <outVariable localId="21" executionOrderId="0" height="30" width="92" negated="false">
              <position x="468" y="1074"/>
              <connectionPointIn>
                <relPosition x="0" y="15"/>
                <connection refLocalId="19" formalParameter="OUT">
                  <position x="468" y="1089"/>
                  <position x="414" y="1089"/>
                </connection>
              </connectionPointIn>
              <expression>Cooler</expression>
            </outVariable>
            <inVariable localId="22" executionOrderId="0" height="30" width="146" negated="false">
              <position x="39" y="1154"/>
              <connectionPointOut>
                <relPosition x="146" y="15"/>
              </connectionPointOut>
              <expression>TemperatureSetPoint</expression>
            </inVariable>
            <block localId="17" typeName="LT" executionOrderId="0" height="60" width="67">
              <position x="228" y="1278"/>
              <inputVariables>
                <variable formalParameter="IN1">
                  <connectionPointIn>
                    <relPosition x="0" y="30"/>
                    <connection refLocalId="23">
                      <position x="228" y="1308"/>
                      <position x="129" y="1308"/>
                    </connection>
                  </connectionPointIn>
                </variable>
                <variable formalParameter="IN2">
                  <connectionPointIn>
                    <relPosition x="0" y="50"/>
                    <connection refLocalId="27">
                      <position x="228" y="1328"/>
                      <position x="205" y="1328"/>
                      <position x="205" y="1344"/>
                      <position x="182" y="1344"/>
                    </connection>
                  </connectionPointIn>
                </variable>
              </inputVariables>
              <inOutVariables/>
              <outputVariables>
                <variable formalParameter="OUT">
                  <connectionPointOut>
                    <relPosition x="67" y="30"/>
                  </connectionPointOut>
                </variable>
              </outputVariables>
            </block>
            <inVariable localId="23" executionOrderId="0" height="30" width="92" negated="false">
              <position x="37" y="1293"/>
              <connectionPointOut>
                <relPosition x="92" y="15"/>
              </connectionPointOut>
              <expression>Temperature</expression>
            </inVariable>
            <block localId="24" typeName="AND" executionOrderId="0" height="60" width="67">
              <position x="344" y="1234"/>
              <inputVariables>
                <variable formalParameter="IN1" negated="true">
                  <connectionPointIn>
                    <relPosition x="0" y="30"/>
                    <connection refLocalId="25">
                      <position x="344" y="1264"/>
                      <position x="260" y="1264"/>
                      <position x="260" y="1249"/>
                      <position x="142" y="1249"/>
                    </connection>
                  </connectionPointIn>
                </variable>
                <variable formalParameter="IN2">
                  <connectionPointIn>
                    <relPosition x="0" y="50"/>
                    <connection refLocalId="17" formalParameter="OUT">
                      <position x="344" y="1284"/>
                      <position x="334" y="1284"/>
                      <position x="334" y="1308"/>
                      <position x="295" y="1308"/>
                    </connection>
                  </connectionPointIn>
                </variable>
              </inputVariables>
              <inOutVariables/>
              <outputVariables>
                <variable formalParameter="OUT">
                  <connectionPointOut>
                    <relPosition x="67" y="30"/>
                  </connectionPointOut>
                </variable>
              </outputVariables>
            </block>
            <inVariable localId="25" executionOrderId="0" height="30" width="104" negated="false">
              <position x="38" y="1234"/>
              <connectionPointOut>
                <relPosition x="104" y="15"/>
              </connectionPointOut>
              <expression>ControlDisable</expression>
            </inVariable>
            <outVariable localId="26" executionOrderId="0" height="30" width="92" negated="false">
              <position x="465" y="1249"/>
              <connectionPointIn>
                <relPosition x="0" y="15"/>
                <connection refLocalId="24" formalParameter="OUT">
                  <position x="465" y="1264"/>
                  <position x="411" y="1264"/>
                </connection>
              </connectionPointIn>
              <expression>Heater</expression>
            </outVariable>
            <inVariable localId="27" executionOrderId="0" height="30" width="146" negated="false">
              <position x="36" y="1329"/>
              <connectionPointOut>
                <relPosition x="146" y="15"/>
              </connectionPointOut>
              <expression>TemperatureSetPoint</expression>
            </inVariable>
            <comment localId="28" height="67" width="229">
              <position x="343" y="734"/>
              <content>
                <xhtml:p><![CDATA[Simple sensor simulation]]></xhtml:p>
              </content>
            </comment>
            <comment localId="29" height="67" width="229">
              <position x="37" y="978"/>
              <content>
                <xhtml:p><![CDATA[Climate control]]></xhtml:p>
              </content>
            </comment>
            <comment localId="30" height="464" width="773">
              <position x="14" y="16"/>
              <content>
                <xhtml:p><![CDATA[This examples shows how to work with BACnet extension.

Extensions requires native BACnet stack to be installed nearby Beremiz.
Following directory structure is expected:
<Parent directory>
  "beremiz"
  "BACnet"

If library is installed elsewhere, then place corresponding paths
in CFLAGS/LDFLAGS in project settings.

For GNU/Linux to install BACnet library in parent directory run following commands:
$ svn checkout https://svn.code.sf.net/p/bacnet/code/trunk/bacnet-stack/ BACnet
$ cd BACnet
$ make

After that BACnet extension is ready to be used in Beremiz projects.
BACnet stack implementation contains a lot of test tools. They could be useful during 
debugging and BACnet investigation. See "BACnet/bin/readme.txt" for more information about them.]]></xhtml:p>
              </content>
            </comment>
          </FBD>
        </body>
      </pou>
      <pou name="Simulator" pouType="functionBlock">
        <interface>
          <outputVars>
            <variable name="Out">
              <type>
                <REAL/>
              </type>
            </variable>
          </outputVars>
          <inputVars>
            <variable name="MinVal">
              <type>
                <REAL/>
              </type>
            </variable>
            <variable name="MaxVal">
              <type>
                <REAL/>
              </type>
            </variable>
            <variable name="PeriodSeconds">
              <type>
                <INT/>
              </type>
            </variable>
          </inputVars>
          <localVars>
            <variable name="TON0">
              <type>
                <derived name="TON"/>
              </type>
            </variable>
            <variable name="seconds">
              <type>
                <INT/>
              </type>
            </variable>
            <variable name="BaseVal">
              <type>
                <REAL/>
              </type>
            </variable>
            <variable name="VarVal">
              <type>
                <REAL/>
              </type>
            </variable>
          </localVars>
        </interface>
        <body>
          <ST>
            <xhtml:p><![CDATA[(* pseudo-random variations *)
TON0(IN := TRUE, PT := T#3120s);
IF TON0.Q THEN
  TON0(IN := FALSE);
END_IF;
seconds := TIME_TO_INT(TON0.ET);

BaseVal := (MaxVal + MinVal)/2.0;
VarVal  := (MaxVal-MinVal)*INT_TO_REAL((seconds MOD PeriodSeconds) - (PeriodSeconds/2))/INT_TO_REAL(PeriodSeconds);

Out :=  BaseVal + VarVal;]]></xhtml:p>
          </ST>
        </body>
      </pou>
    </pous>
  </types>
  <instances>
    <configurations>
      <configuration name="config">
        <resource name="resource1">
          <task name="task0" priority="0" interval="T#20ms">
            <pouInstance name="instance0" typeName="program0"/>
          </task>
        </resource>
      </configuration>
    </configurations>
  </instances>
</project>