Add BACnet example
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Sun, 29 Jul 2018 02:00:03 +0300
changeset 2254 3145dcffc6ed
parent 2253 b0418bb13527
child 2255 f6a0508fa473
Add BACnet example
tests/BACnet/bacnet_0@bacnet/bacnet_slave
tests/BACnet/bacnet_0@bacnet/baseconfnode.xml
tests/BACnet/bacnet_0@bacnet/confnode.xml
tests/BACnet/beremiz.xml
tests/BACnet/plc.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/BACnet/bacnet_0@bacnet/bacnet_slave	Sun Jul 29 02:00:03 2018 +0300
@@ -0,0 +1,202 @@
+(dp0
+S'BV_Obj'
+p1
+(lp2
+sS'AV_Obj'
+p3
+(lp4
+(dp5
+S'loc'
+p6
+S'MD0_2'
+p7
+sS'Description'
+p8
+S''
+p9
+sS'Unit ID'
+p10
+I19
+sS'Object Identifier'
+p11
+I0
+sS'Ctype'
+p12
+S'float'
+p13
+sS'BACnetObjTypeID'
+p14
+I2
+sS'Settable'
+p15
+S'Y'
+p16
+sS'Engineering Units'
+p17
+V(Energy) kilowatt-hours (19)
+p18
+sS'Object Name'
+p19
+VEnergyCounter
+p20
+sasS'AO_Obj'
+p21
+(lp22
+(dp23
+g6
+S'QD0_1'
+p24
+sg8
+V
+p25
+sS'Unit ID'
+p26
+I62
+sS'Object Identifier'
+p27
+V0
+p28
+sg12
+g13
+sg14
+I1
+sg15
+g16
+sS'Object Name'
+p29
+VTemperatureSetPoint
+p30
+sS'Engineering Units'
+p31
+V(Temperature) degrees-celsius (62)
+p32
+sasS'MSI_Obj'
+p33
+(lp34
+sS'BO_Obj'
+p35
+(lp36
+(dp37
+g6
+S'QX0_4'
+p38
+sg8
+g9
+sS'Object Identifier'
+p39
+I2
+sg12
+S'uint8_t'
+p40
+sg14
+I4
+sg15
+g16
+sS'Object Name'
+p41
+VBlockClimateControl
+p42
+sasS'MSO_Obj'
+p43
+(lp44
+sS'EDEfile_parm'
+p45
+(dp46
+S'next_EDE_file_version'
+p47
+I1
+ssS'BI_Obj'
+p48
+(lp49
+(dp50
+g6
+S'IX0_3'
+p51
+sg8
+g9
+sS'Object Identifier'
+p52
+I0
+sg12
+g40
+sg14
+I3
+sg15
+S'N'
+p53
+sS'Object Name'
+p54
+VHeater
+p55
+sa(dp56
+g6
+g51
+sg8
+g9
+sg52
+I1
+sg12
+g40
+sg14
+I3
+sg15
+g53
+sg54
+VCooler
+p57
+sasS'AI_Obj'
+p58
+(lp59
+(dp60
+g6
+S'ID0_0'
+p61
+sg8
+VCurrent termperature in Beremiz lab
+p62
+sS'Unit ID'
+p63
+I62
+sS'Object Identifier'
+p64
+I0
+sg12
+g13
+sg14
+I0
+sg15
+g53
+sS'Engineering Units'
+p65
+V(Temperature) degrees-celsius (62)
+p66
+sS'Object Name'
+p67
+VTemperature
+p68
+sa(dp69
+g6
+g61
+sg8
+VCurrent humidity in Beremiz lab
+p70
+sg63
+I29
+sg64
+I1
+sg12
+g13
+sg14
+I0
+sg15
+g53
+sg67
+VHumidity
+p71
+sg65
+V(Humidity) percent-relative-humidity (29)
+p72
+sasS'MSV_Obj'
+p73
+(lp74
+s.
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/BACnet/bacnet_0@bacnet/baseconfnode.xml	Sun Jul 29 02:00:03 2018 +0300
@@ -0,0 +1,2 @@
+<?xml version='1.0' encoding='utf-8'?>
+<BaseParams xmlns:xsd="http://www.w3.org/2001/XMLSchema" IEC_Channel="0" Name="bacnet_0"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/BACnet/bacnet_0@bacnet/confnode.xml	Sun Jul 29 02:00:03 2018 +0300
@@ -0,0 +1,2 @@
+<?xml version='1.0' encoding='utf-8'?>
+<BACnetServerNode xmlns:xsd="http://www.w3.org/2001/XMLSchema" UDP_Port_Number="47808" BACnet_Device_ID="3" BACnet_Communication_Control_Password=" " BACnet_Device_Location="Beremiz lab" Network_Interface="virbr0"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/BACnet/beremiz.xml	Sun Jul 29 02:00:03 2018 +0300
@@ -0,0 +1,4 @@
+<?xml version='1.0' encoding='utf-8'?>
+<BeremizRoot xmlns:xsd="http://www.w3.org/2001/XMLSchema" URI_location="LOCAL://">
+  <TargetType/>
+</BeremizRoot>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/BACnet/plc.xml	Sun Jul 29 02:00:03 2018 +0300
@@ -0,0 +1,601 @@
+<?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>