--- a/tests/projects/iec61131_lang_test/plc.xml Sat Nov 23 01:09:55 2024 +0100
+++ b/tests/projects/iec61131_lang_test/plc.xml Wed Nov 27 16:05:26 2024 +0100
@@ -1,7 +1,7 @@
<?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="2023-03-11T14:33:27"/>
- <contentHeader name="Unnamed" modificationDateTime="2023-03-27T09:12:21">
+ <contentHeader name="Unnamed" modificationDateTime="2024-11-27T15:23:14">
<coordinateInfo>
<fbd>
<scaling x="8" y="8"/>
@@ -17,6 +17,138 @@
<types>
<dataTypes/>
<pous>
+ <pou name="FLOW_CONTROL_TEST" pouType="functionBlock">
+ <interface>
+ <outputVars>
+ <variable name="RESULT">
+ <type>
+ <string/>
+ </type>
+ </variable>
+ </outputVars>
+ <localVars>
+ <variable name="WORDS">
+ <type>
+ <array>
+ <dimension lower="1" upper="10"/>
+ <baseType>
+ <INT/>
+ </baseType>
+ </array>
+ </type>
+ <initialValue>
+ <arrayValue>
+ <value>
+ <simpleValue value="0"/>
+ </value>
+ <value>
+ <simpleValue value="0"/>
+ </value>
+ <value>
+ <simpleValue value="0"/>
+ </value>
+ <value>
+ <simpleValue value="0"/>
+ </value>
+ <value>
+ <simpleValue value="0"/>
+ </value>
+ <value>
+ <simpleValue value="0"/>
+ </value>
+ <value>
+ <simpleValue value="0"/>
+ </value>
+ <value>
+ <simpleValue value="0"/>
+ </value>
+ <value>
+ <simpleValue value="0"/>
+ </value>
+ <value>
+ <simpleValue value="0"/>
+ </value>
+ </arrayValue>
+ </initialValue>
+ </variable>
+ <variable name="J">
+ <type>
+ <BOOL/>
+ </type>
+ </variable>
+ <variable name="I">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </localVars>
+ </interface>
+ <body>
+ <ST>
+ <xhtml:p><![CDATA[(* FOR loop test s *)
+
+RESULT := 'Single iteration FOR loop';
+
+J := FALSE;
+FOR I:= 1 TO 1 DO
+ J := TRUE;
+END_FOR;
+
+IF NOT J THEN RETURN; END_IF;
+
+
+RESULT := 'By 2 FOR loop';
+
+J := TRUE;
+FOR I:= 2 TO 10 BY 2 DO
+ WORDS[I] := I;
+END_FOR;
+
+J := J AND WORDS[1] = 0;
+J := J AND WORDS[2] = 2;
+J := J AND WORDS[3] = 0;
+J := J AND WORDS[4] = 4;
+J := J AND WORDS[5] = 0;
+J := J AND WORDS[6] = 6;
+J := J AND WORDS[7] = 0;
+J := J AND WORDS[8] = 8;
+J := J AND WORDS[9] = 0;
+J := J AND WORDS[10] = 10;
+
+IF NOT J THEN RETURN; END_IF;
+
+RESULT := 'By 2 FOR loop with CONTINUE';
+
+J := TRUE;
+FOR I:= 1 TO 10 BY 2 DO
+ IF I = 5 THEN
+ CONTINUE;
+ END_IF;
+ WORDS[I] := I;
+END_FOR;
+
+J := J AND WORDS[1] = 1;
+J := J AND WORDS[2] = 2;
+J := J AND WORDS[3] = 3;
+J := J AND WORDS[4] = 4;
+J := J AND WORDS[5] = 0;
+J := J AND WORDS[6] = 6;
+J := J AND WORDS[7] = 7;
+J := J AND WORDS[8] = 8;
+J := J AND WORDS[9] = 9;
+J := J AND WORDS[10] = 10;
+
+IF NOT J THEN RETURN; END_IF;
+
+(* TODO: CONTINUE EXIT WHILE REPEAT *)
+
+
+RESULT := 'OK';
+
+]]></xhtml:p>
+ </ST>
+ </body>
+ </pou>
<pou name="CONVERSION_TEST" pouType="functionBlock">
<interface>
<outputVars>
@@ -1065,6 +1197,26 @@
<derived name="LOGGER"/>
</type>
</variable>
+ <variable name="FLOW_CONTROL_TEST0">
+ <type>
+ <derived name="FLOW_CONTROL_TEST"/>
+ </type>
+ </variable>
+ <variable name="R_TRIG1">
+ <type>
+ <derived name="R_TRIG"/>
+ </type>
+ </variable>
+ <variable name="LOGGER3">
+ <type>
+ <derived name="LOGGER"/>
+ </type>
+ </variable>
+ <variable name="SR2">
+ <type>
+ <derived name="SR"/>
+ </type>
+ </variable>
</localVars>
</interface>
<body>
@@ -1445,7 +1597,7 @@
</variable>
</outputVariables>
</block>
- <block localId="21" typeName="AND" executionOrderId="0" height="64" width="64">
+ <block localId="21" typeName="AND" executionOrderId="0" height="80" width="64">
<position x="1296" y="496"/>
<inputVariables>
<variable formalParameter="IN1">
@@ -1461,15 +1613,26 @@
</variable>
<variable formalParameter="IN2">
<connectionPointIn>
- <relPosition x="0" y="56"/>
+ <relPosition x="0" y="48"/>
<connection refLocalId="20" formalParameter="Q1">
- <position x="1296" y="552"/>
- <position x="1232" y="552"/>
+ <position x="1296" y="544"/>
+ <position x="1232" y="544"/>
<position x="1232" y="600"/>
<position x="1168" y="600"/>
</connection>
</connectionPointIn>
</variable>
+ <variable formalParameter="IN3">
+ <connectionPointIn>
+ <relPosition x="0" y="72"/>
+ <connection refLocalId="37" formalParameter="Q1">
+ <position x="1296" y="568"/>
+ <position x="1280" y="568"/>
+ <position x="1280" y="920"/>
+ <position x="1264" y="920"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
</inputVariables>
<inOutVariables/>
<outputVariables>
@@ -1640,6 +1803,259 @@
- time is emulated]]></xhtml:p>
</content>
</comment>
+ <block localId="30" typeName="FLOW_CONTROL_TEST" instanceName="FLOW_CONTROL_TEST0" executionOrderId="0" height="72" width="152">
+ <position x="392" y="928"/>
+ <inputVariables>
+ <variable formalParameter="EN">
+ <connectionPointIn>
+ <relPosition x="0" y="32"/>
+ <connection refLocalId="31" formalParameter="Q">
+ <position x="392" y="960"/>
+ <position x="336" y="960"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="ENO">
+ <connectionPointOut>
+ <relPosition x="152" y="32"/>
+ </connectionPointOut>
+ </variable>
+ <variable formalParameter="RESULT">
+ <connectionPointOut>
+ <relPosition x="152" y="56"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <block localId="31" typeName="R_TRIG" instanceName="R_TRIG1" executionOrderId="0" height="48" width="64">
+ <position x="272" y="928"/>
+ <inputVariables>
+ <variable formalParameter="CLK">
+ <connectionPointIn>
+ <relPosition x="0" y="32"/>
+ <connection refLocalId="32">
+ <position x="272" y="960"/>
+ <position x="240" y="960"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="Q">
+ <connectionPointOut>
+ <relPosition x="64" y="32"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="32" executionOrderId="0" height="32" width="48" negated="false">
+ <position x="192" y="944"/>
+ <connectionPointOut>
+ <relPosition x="48" y="16"/>
+ </connectionPointOut>
+ <expression>TRUE</expression>
+ </inVariable>
+ <block localId="33" typeName="LOGGER" instanceName="LOGGER3" executionOrderId="0" height="112" width="64">
+ <position x="920" y="952"/>
+ <inputVariables>
+ <variable formalParameter="TRIG">
+ <connectionPointIn>
+ <relPosition x="0" y="32"/>
+ <connection refLocalId="30" formalParameter="ENO">
+ <position x="920" y="984"/>
+ <position x="832" y="984"/>
+ <position x="832" y="960"/>
+ <position x="544" y="960"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="MSG">
+ <connectionPointIn>
+ <relPosition x="0" y="64"/>
+ <connection refLocalId="34" formalParameter="OUT">
+ <position x="920" y="1016"/>
+ <position x="808" y="1016"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="LEVEL">
+ <connectionPointIn>
+ <relPosition x="0" y="96"/>
+ <connection refLocalId="36">
+ <position x="920" y="1048"/>
+ <position x="888" y="1048"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables/>
+ </block>
+ <block localId="34" typeName="CONCAT" executionOrderId="0" height="64" width="64">
+ <position x="744" y="984"/>
+ <inputVariables>
+ <variable formalParameter="IN1">
+ <connectionPointIn>
+ <relPosition x="0" y="32"/>
+ <connection refLocalId="35">
+ <position x="744" y="1016"/>
+ <position x="712" y="1016"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN2">
+ <connectionPointIn>
+ <relPosition x="0" y="56"/>
+ <connection refLocalId="30" formalParameter="RESULT">
+ <position x="744" y="1040"/>
+ <position x="554" y="1040"/>
+ <position x="554" y="984"/>
+ <position x="544" y="984"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="64" y="32"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="35" executionOrderId="0" height="32" width="144" negated="false">
+ <position x="584" y="1000"/>
+ <connectionPointOut>
+ <relPosition x="144" y="16"/>
+ </connectionPointOut>
+ <expression>'FLOW CONTROL: '</expression>
+ </inVariable>
+ <inVariable localId="36" executionOrderId="0" height="32" width="56" negated="false">
+ <position x="832" y="1032"/>
+ <connectionPointOut>
+ <relPosition x="56" y="16"/>
+ </connectionPointOut>
+ <expression>DEBUG</expression>
+ </inVariable>
+ <block localId="37" typeName="SR" instanceName="SR2" executionOrderId="0" height="64" width="48">
+ <position x="1216" y="888"/>
+ <inputVariables>
+ <variable formalParameter="S1">
+ <connectionPointIn>
+ <relPosition x="0" y="32"/>
+ <connection refLocalId="38" formalParameter="OUT">
+ <position x="1216" y="920"/>
+ <position x="1176" y="920"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="R">
+ <connectionPointIn>
+ <relPosition x="0" y="56"/>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="Q1">
+ <connectionPointOut>
+ <relPosition x="48" y="32"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <block localId="38" typeName="AND" executionOrderId="0" height="64" width="64">
+ <position x="1112" y="888"/>
+ <inputVariables>
+ <variable formalParameter="IN1">
+ <connectionPointIn>
+ <relPosition x="0" y="32"/>
+ <connection refLocalId="30" formalParameter="ENO">
+ <position x="1112" y="920"/>
+ <position x="832" y="920"/>
+ <position x="832" y="960"/>
+ <position x="544" y="960"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN2">
+ <connectionPointIn>
+ <relPosition x="0" y="56"/>
+ <connection refLocalId="39" formalParameter="OUT">
+ <position x="1112" y="944"/>
+ <position x="1086" y="944"/>
+ <position x="1086" y="1072"/>
+ <position x="1072" y="1072"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="64" y="32"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <block localId="39" typeName="EQ" executionOrderId="0" height="64" width="64">
+ <position x="1008" y="1040"/>
+ <inputVariables>
+ <variable formalParameter="IN1">
+ <connectionPointIn>
+ <relPosition x="0" y="32"/>
+ <connection refLocalId="30" formalParameter="RESULT">
+ <position x="1008" y="1072"/>
+ <position x="554" y="1072"/>
+ <position x="554" y="984"/>
+ <position x="544" y="984"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN2">
+ <connectionPointIn>
+ <relPosition x="0" y="56"/>
+ <connection refLocalId="40">
+ <position x="1008" y="1096"/>
+ <position x="960" y="1096"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="64" y="32"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="40" executionOrderId="0" height="32" width="48" negated="false">
+ <position x="912" y="1080"/>
+ <connectionPointOut>
+ <relPosition x="48" y="16"/>
+ </connectionPointOut>
+ <expression>'OK'</expression>
+ </inVariable>
+ <comment localId="41" height="40" width="248">
+ <position x="160" y="864"/>
+ <content>
+ <xhtml:p><![CDATA[Execute only on first cycle]]></xhtml:p>
+ </content>
+ </comment>
+ <comment localId="42" height="40" width="248">
+ <position x="648" y="864"/>
+ <content>
+ <xhtml:p><![CDATA[Log when just executed]]></xhtml:p>
+ </content>
+ </comment>
</FBD>
</body>
</pou>