etherlab/pous.xml
changeset 2086 8e4992e0f147
child 2090 52b398c75ba9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/etherlab/pous.xml	Thu Oct 25 19:55:02 2012 +0200
@@ -0,0 +1,276 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.plcopen.org/xml/tc6.xsd"
+         xsi:schemaLocation="http://www.plcopen.org/xml/tc6.xsd"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns:xhtml="http://www.w3.org/1999/xhtml">
+  <fileHeader companyName="EtherlabMaster"
+              productName="EtherlabMaster"
+              productVersion="1"
+              creationDateTime="2012-10-22T12:12:45"/>
+  <contentHeader name="EtherlabMaster SDO Blocks"
+                 modificationDateTime="2012-10-25T19:53:33">
+    <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="EtherLabSDOUpload" pouType="functionBlock">
+        <interface>
+          <inputVars>
+            <variable name="EXECUTE">
+              <type>
+                <BOOL/>
+              </type>
+            </variable>
+            <variable name="POS">
+              <type>
+                <INT/>
+              </type>
+            </variable>
+            <variable name="INDEX">
+              <type>
+                <UINT/>
+              </type>
+            </variable>
+            <variable name="SUBINDEX">
+              <type>
+                <USINT/>
+              </type>
+            </variable>
+            <variable name="VARTYPE">
+              <type>
+                <string/>
+              </type>
+            </variable>
+          </inputVars>
+          <outputVars>
+            <variable name="ACK">
+              <type>
+                <BOOL/>
+              </type>
+            </variable>
+            <variable name="VALID">
+              <type>
+                <BOOL/>
+              </type>
+            </variable>
+            <variable name="VALUE">
+              <type>
+                <string/>
+              </type>
+            </variable>
+          </outputVars>
+          <localVars>
+            <variable name="PY0">
+              <type>
+                <derived name="python_eval"/>
+              </type>
+            </variable>
+            <variable name="PY1">
+              <type>
+                <derived name="python_eval"/>
+              </type>
+            </variable>
+            <variable name="EXECUTE0">
+              <type>
+                <BOOL/>
+              </type>
+            </variable>
+            <variable name="STATE">
+              <type>
+                <INT/>
+              </type>
+              <initialValue>
+                <simpleValue value="0"/>
+              </initialValue>
+            </variable>
+          </localVars>
+        </interface>
+        <body>
+          <ST>
+<![CDATA[{extern int AcquireSDOLock();}
+{extern int HasAnswer();}
+{extern void ReleaseSDOLock();}
+CASE STATE OF
+  0:
+    IF EXECUTE AND NOT EXECUTE0 THEN
+      STATE := 1;
+      ACK := 0;
+      VALID := 0;
+      VALUE := 'None';
+    END_IF;
+  1:
+    {if (AcquireSDOLock()) __SET_VAR(data__->,STATE, 2)}
+  2:
+    IF PY0.ACK THEN
+      STATE := 3;
+    END_IF;
+  3:
+    {if (HasAnswer()) __SET_VAR(data__->,STATE, 4)}
+  4:
+    IF PY1.ACK THEN
+      ACK := 1;
+      VALUE := PY1.RESULT;
+      VALID := NE(VALUE, 'None');
+      STATE := 0;
+      {ReleaseSDOLock();}
+    END_IF;
+ELSE
+  STATE := 0;
+END_CASE;
+
+EXECUTE0 := EXECUTE;
+PY0(TRIG := STATE = 2, 
+    CODE := CONCAT('EthercatSDOUpload(',
+                   INT_TO_STRING(POS),
+                   ',',
+                   UINT_TO_STRING(INDEX),
+                   ',',
+                   USINT_TO_STRING(SUBINDEX),
+                   ',"',
+                   VARTYPE,
+                   '")'));
+PY1(TRIG := STATE = 4, 
+    CODE := 'GetResult()');
+]]>
+          </ST>
+        </body>
+      </pou>
+      <pou name="EtherLabSDODownload" pouType="functionBlock">
+        <interface>
+          <inputVars>
+            <variable name="EXECUTE">
+              <type>
+                <BOOL/>
+              </type>
+            </variable>
+            <variable name="POS">
+              <type>
+                <INT/>
+              </type>
+            </variable>
+            <variable name="INDEX">
+              <type>
+                <UINT/>
+              </type>
+            </variable>
+            <variable name="SUBINDEX">
+              <type>
+                <USINT/>
+              </type>
+            </variable>
+            <variable name="VARTYPE">
+              <type>
+                <string/>
+              </type>
+            </variable>
+            <variable name="VALUE">
+              <type>
+                <string/>
+              </type>
+            </variable>
+          </inputVars>
+          <outputVars>
+            <variable name="ACK">
+              <type>
+                <BOOL/>
+              </type>
+            </variable>
+            <variable name="ERROR">
+              <type>
+                <BOOL/>
+              </type>
+            </variable>
+          </outputVars>
+          <localVars>
+            <variable name="PY0">
+              <type>
+                <derived name="python_eval"/>
+              </type>
+            </variable>
+            <variable name="PY1">
+              <type>
+                <derived name="python_eval"/>
+              </type>
+            </variable>
+            <variable name="EXECUTE0">
+              <type>
+                <BOOL/>
+              </type>
+            </variable>
+            <variable name="STATE">
+              <type>
+                <INT/>
+              </type>
+              <initialValue>
+                <simpleValue value="0"/>
+              </initialValue>
+            </variable>
+          </localVars>
+        </interface>
+        <body>
+          <ST>
+<![CDATA[{extern int AcquireSDOLock();}
+{extern int HasAnswer();}
+{extern void ReleaseSDOLock();}
+CASE STATE OF
+  0:
+    IF EXECUTE AND NOT EXECUTE0 THEN
+      STATE := 1;
+      ACK := 0;
+      ERROR := 0;
+    END_IF;
+  1:
+    {if (AcquireSDOLock()) __SET_VAR(data__->,STATE, 2)}
+  2:
+    IF PY0.ACK THEN
+      STATE := 3;
+    END_IF;
+  3:
+    {if (HasAnswer()) __SET_VAR(data__->,STATE, 4)}
+  4:
+    IF PY1.ACK THEN
+      ACK := 1;
+      VALUE := PY1.RESULT;
+      ERROR := EQ(PY1.RESULT, 'False');
+      STATE := 0;
+      {ReleaseSDOLock();}
+    END_IF;
+ELSE
+  STATE := 0;
+END_CASE;
+EXECUTE0 := EXECUTE;
+PY0(TRIG := STATE = 2, 
+    CODE := CONCAT('EthercatSDODownload(',
+                   INT_TO_STRING(POS),
+                   ',',
+                   UINT_TO_STRING(INDEX),
+                   ',',
+                   USINT_TO_STRING(SUBINDEX),
+                   ',"',
+                   VARTYPE,
+                   '",',
+                   VALUE,
+                   ')'));
+PY1(TRIG := STATE = 4, 
+    CODE := 'GetResult()');
+]]>
+          </ST>
+        </body>
+      </pou>
+    </pous>
+  </types>
+  <instances>
+    <configurations/>
+  </instances>
+</project>