fixed plc_python.c to assure data coherancy from the PLC point of view. Also fix non work multiple python_eval FB instance case.
authoretisserant
Wed, 24 Dec 2008 00:02:12 +0100
changeset 282 2221e99d2f8f
parent 281 3f0fc8de99b0
child 283 d0e6fc0701fb
fixed plc_python.c to assure data coherancy from the PLC point of view. Also fix non work multiple python_eval FB instance case.
pous.xml
tests/python/plc.xml
--- a/pous.xml	Tue Dec 23 23:56:29 2008 +0100
+++ b/pous.xml	Wed Dec 24 00:02:12 2008 +0100
@@ -8,7 +8,7 @@
               productVersion="0.0"
               creationDateTime="2008-12-14T16:53:26"/>
   <contentHeader name="Beremiz non-standard POUs library"
-                 modificationDateTime="2008-12-18T18:41:34">
+                 modificationDateTime="2008-12-23T22:35:46">
     <coordinateInfo>
       <fbd>
         <scaling x="0" y="0"/>
@@ -61,11 +61,21 @@
                 <string/>
               </type>
             </variable>
+            <variable name="PREBUFFER">
+              <type>
+                <string/>
+              </type>
+            </variable>
             <variable name="TRIGM1">
               <type>
                 <BOOL/>
               </type>
             </variable>
+            <variable name="TRIGGED">
+              <type>
+                <BOOL/>
+              </type>
+            </variable>
           </localVars>
         </interface>
         <body>
--- a/tests/python/plc.xml	Tue Dec 23 23:56:29 2008 +0100
+++ b/tests/python/plc.xml	Wed Dec 24 00:02:12 2008 +0100
@@ -8,7 +8,7 @@
               productVersion="0.0"
               creationDateTime="2008-12-14T16:21:19"/>
   <contentHeader name="Beremiz Python Support Tests"
-                 modificationDateTime="2008-12-22T23:58:02">
+                 modificationDateTime="2008-12-24T00:54:43">
     <coordinateInfo>
       <pageSize x="1024" y="1024"/>
       <fbd>
@@ -32,63 +32,54 @@
               <type>
                 <string/>
               </type>
-              <initialValue>
-                <simpleValue value="time.sleep(1)"/>
-              </initialValue>
             </variable>
             <variable name="pytest_var2">
               <type>
                 <BOOL/>
               </type>
             </variable>
-            <variable name="pytest_var3">
-              <type>
-                <string/>
-              </type>
-            </variable>
-            <variable name="pytest_var4">
-              <type>
-                <BOOL/>
-              </type>
-            </variable>
             <variable name="py1">
               <type>
                 <derived name="python_eval"/>
               </type>
             </variable>
+            <variable name="Block1">
+              <type>
+                <derived name="python_eval"/>
+              </type>
+            </variable>
+            <variable name="Block2">
+              <type>
+                <derived name="python_eval"/>
+              </type>
+            </variable>
+            <variable name="Block3">
+              <type>
+                <derived name="python_eval"/>
+              </type>
+            </variable>
           </localVars>
         </interface>
         <body>
           <FBD>
-            <outVariable localId="2" height="30" width="120">
-              <position x="760" y="150"/>
-              <connectionPointIn>
-                <relPosition x="0" y="15"/>
-                <connection refLocalId="5" formalParameter="RESULT">
-                  <position x="760" y="165"/>
-                  <position x="515" y="165"/>
-                </connection>
-              </connectionPointIn>
-              <expression>pytest_var3</expression>
-            </outVariable>
-            <inVariable localId="4" height="30" width="120">
-              <position x="35" y="150"/>
-              <connectionPointOut>
-                <relPosition x="120" y="15"/>
-              </connectionPointOut>
-              <expression>pytest_var1</expression>
+            <inVariable localId="4" height="30" width="160">
+              <position x="295" y="235"/>
+              <connectionPointOut>
+                <relPosition x="160" y="15"/>
+              </connectionPointOut>
+              <expression>'time.sleep(1)'</expression>
             </inVariable>
             <block localId="5" width="125" height="80" typeName="python_eval" instanceName="py1">
-              <position x="390" y="100"/>
+              <position x="650" y="185"/>
               <inputVariables>
                 <variable formalParameter="TRIG">
                   <connectionPointIn>
                     <relPosition x="0" y="35"/>
                     <connection refLocalId="7" formalParameter="OUT">
-                      <position x="390" y="135"/>
-                      <position x="190" y="135"/>
-                      <position x="190" y="55"/>
-                      <position x="130" y="55"/>
+                      <position x="650" y="220"/>
+                      <position x="285" y="220"/>
+                      <position x="285" y="260"/>
+                      <position x="250" y="260"/>
                     </connection>
                   </connectionPointIn>
                 </variable>
@@ -96,8 +87,8 @@
                   <connectionPointIn>
                     <relPosition x="0" y="65"/>
                     <connection refLocalId="4">
-                      <position x="390" y="165"/>
-                      <position x="155" y="165"/>
+                      <position x="650" y="250"/>
+                      <position x="455" y="250"/>
                     </connection>
                   </connectionPointIn>
                 </variable>
@@ -116,30 +107,15 @@
                 </variable>
               </outputVariables>
             </block>
-            <outVariable localId="6" height="30" width="120">
-              <position x="760" y="120"/>
-              <connectionPointIn>
-                <relPosition x="0" y="15"/>
-                <connection refLocalId="5" formalParameter="ACK">
-                  <position x="760" y="135"/>
-                  <position x="515" y="135"/>
-                </connection>
-              </connectionPointIn>
-              <expression>pytest_var4</expression>
-            </outVariable>
             <block localId="7" width="70" height="45" typeName="NOT">
-              <position x="60" y="25"/>
+              <position x="180" y="230"/>
               <inputVariables>
                 <variable formalParameter="IN">
                   <connectionPointIn>
                     <relPosition x="0" y="30"/>
                     <connection refLocalId="3">
-                      <position x="60" y="55"/>
-                      <position x="45" y="55"/>
-                      <position x="45" y="85"/>
-                      <position x="165" y="85"/>
-                      <position x="165" y="120"/>
-                      <position x="155" y="120"/>
+                      <position x="180" y="260"/>
+                      <position x="155" y="260"/>
                     </connection>
                   </connectionPointIn>
                 </variable>
@@ -154,16 +130,16 @@
               </outputVariables>
             </block>
             <inOutVariable localId="3" height="30" width="120">
-              <position x="35" y="105"/>
+              <position x="35" y="245"/>
               <connectionPointIn>
                 <relPosition x="0" y="15"/>
                 <connection refLocalId="7" formalParameter="OUT">
-                  <position x="35" y="120"/>
-                  <position x="25" y="120"/>
-                  <position x="25" y="15"/>
-                  <position x="210" y="15"/>
-                  <position x="210" y="55"/>
-                  <position x="130" y="55"/>
+                  <position x="35" y="260"/>
+                  <position x="25" y="260"/>
+                  <position x="25" y="220"/>
+                  <position x="270" y="220"/>
+                  <position x="270" y="260"/>
+                  <position x="250" y="260"/>
                 </connection>
               </connectionPointIn>
               <connectionPointOut>
@@ -171,6 +147,147 @@
               </connectionPointOut>
               <expression>pytest_var2</expression>
             </inOutVariable>
+            <block localId="8" width="125" height="80" typeName="python_eval" instanceName="Block1">
+              <position x="650" y="295"/>
+              <inputVariables>
+                <variable formalParameter="TRIG">
+                  <connectionPointIn>
+                    <relPosition x="0" y="35"/>
+                    <connection refLocalId="7" formalParameter="OUT">
+                      <position x="650" y="330"/>
+                      <position x="285" y="330"/>
+                      <position x="285" y="260"/>
+                      <position x="250" y="260"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+                <variable formalParameter="CODE">
+                  <connectionPointIn>
+                    <relPosition x="0" y="65"/>
+                    <connection refLocalId="9">
+                      <position x="650" y="360"/>
+                      <position x="585" y="360"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+              </inputVariables>
+              <inOutVariables/>
+              <outputVariables>
+                <variable formalParameter="ACK">
+                  <connectionPointOut>
+                    <relPosition x="125" y="35"/>
+                  </connectionPointOut>
+                </variable>
+                <variable formalParameter="RESULT">
+                  <connectionPointOut>
+                    <relPosition x="125" y="65"/>
+                  </connectionPointOut>
+                </variable>
+              </outputVariables>
+            </block>
+            <inVariable localId="9" height="30" width="290">
+              <position x="295" y="345"/>
+              <connectionPointOut>
+                <relPosition x="290" y="15"/>
+              </connectionPointOut>
+              <expression>'sys.stdout.write("1234\n")'</expression>
+            </inVariable>
+            <inVariable localId="11" height="30" width="290">
+              <position x="290" y="465"/>
+              <connectionPointOut>
+                <relPosition x="290" y="15"/>
+              </connectionPointOut>
+              <expression>'sys.stdout.write("5678\n")'</expression>
+            </inVariable>
+            <block localId="12" width="125" height="80" typeName="python_eval" instanceName="Block2">
+              <position x="650" y="417"/>
+              <inputVariables>
+                <variable formalParameter="TRIG">
+                  <connectionPointIn>
+                    <relPosition x="0" y="33"/>
+                    <connection refLocalId="7" formalParameter="OUT">
+                      <position x="650" y="450"/>
+                      <position x="285" y="450"/>
+                      <position x="285" y="260"/>
+                      <position x="250" y="260"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+                <variable formalParameter="CODE">
+                  <connectionPointIn>
+                    <relPosition x="0" y="63"/>
+                    <connection refLocalId="11">
+                      <position x="650" y="480"/>
+                      <position x="580" y="480"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+              </inputVariables>
+              <inOutVariables/>
+              <outputVariables>
+                <variable formalParameter="ACK">
+                  <connectionPointOut>
+                    <relPosition x="125" y="33"/>
+                  </connectionPointOut>
+                </variable>
+                <variable formalParameter="RESULT">
+                  <connectionPointOut>
+                    <relPosition x="125" y="63"/>
+                  </connectionPointOut>
+                </variable>
+              </outputVariables>
+            </block>
+            <inVariable localId="14" height="30" width="290">
+              <position x="290" y="590"/>
+              <connectionPointOut>
+                <relPosition x="290" y="15"/>
+              </connectionPointOut>
+              <expression>'sys.stdout.write("90AB\n")'</expression>
+            </inVariable>
+            <block localId="15" width="125" height="80" typeName="python_eval" instanceName="Block3">
+              <position x="650" y="542"/>
+              <inputVariables>
+                <variable formalParameter="TRIG">
+                  <connectionPointIn>
+                    <relPosition x="0" y="33"/>
+                    <connection refLocalId="7" formalParameter="OUT">
+                      <position x="650" y="575"/>
+                      <position x="285" y="575"/>
+                      <position x="285" y="260"/>
+                      <position x="250" y="260"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+                <variable formalParameter="CODE">
+                  <connectionPointIn>
+                    <relPosition x="0" y="63"/>
+                    <connection refLocalId="14">
+                      <position x="650" y="605"/>
+                      <position x="580" y="605"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+              </inputVariables>
+              <inOutVariables/>
+              <outputVariables>
+                <variable formalParameter="ACK">
+                  <connectionPointOut>
+                    <relPosition x="125" y="33"/>
+                  </connectionPointOut>
+                </variable>
+                <variable formalParameter="RESULT">
+                  <connectionPointOut>
+                    <relPosition x="125" y="63"/>
+                  </connectionPointOut>
+                </variable>
+              </outputVariables>
+            </block>
+            <comment localId="16" height="90" width="680">
+              <position x="50" y="25"/>
+              <content>
+<![CDATA[This example test that, despite of 2T period clock stimulating TRIG pin of pyth_eval blocks, blocks keep executing one after the other, in respect of execution order.]]>
+              </content>
+            </comment>
           </FBD>
         </body>
       </pou>