SVGHMI: Fix HMI_REAL support, and add a HMI_REAL use case in tests/svghmi. svghmi
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Thu, 22 Oct 2020 22:44:29 +0200
branchsvghmi
changeset 3068 81758c94f3df
parent 3067 2263f2ecf9bb
child 3069 a9b03c2634c5
SVGHMI: Fix HMI_REAL support, and add a HMI_REAL use case in tests/svghmi.
svghmi/gen_index_xhtml.xslt
svghmi/svghmi.js
svghmi/svghmi.py
tests/svghmi/plc.xml
tests/svghmi/svghmi_0@svghmi/svghmi.svg
--- a/svghmi/gen_index_xhtml.xslt	Tue Oct 20 00:24:49 2020 +0200
+++ b/svghmi/gen_index_xhtml.xslt	Thu Oct 22 22:44:29 2020 +0200
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
-<xsl:stylesheet xmlns:ns="beremiz" xmlns:definitions="definitions" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:func="http://exslt.org/functions" xmlns:epilogue="epilogue" xmlns:preamble="preamble" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:svg="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:str="http://exslt.org/strings" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:exsl="http://exslt.org/common" xmlns:declarations="declarations" xmlns:debug="debug" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions" extension-element-prefixes="ns func exsl regexp str dyn" version="1.0">
-  <xsl:output method="xml" cdata-section-elements="xhtml:script"/>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:str="http://exslt.org/strings" xmlns:func="http://exslt.org/functions" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:debug="debug" xmlns:preamble="preamble" xmlns:declarations="declarations" xmlns:definitions="definitions" xmlns:epilogue="epilogue" xmlns:ns="beremiz" version="1.0" extension-element-prefixes="ns func exsl regexp str dyn" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions">
+  <xsl:output cdata-section-elements="xhtml:script" method="xml"/>
   <xsl:variable name="svg" select="/svg:svg"/>
   <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
   <xsl:variable name="hmitree" select="ns:GetHMITree()"/>
@@ -5940,7 +5940,7 @@
     <xsl:comment>
       <xsl:apply-templates select="document('')/*/debug:*"/>
     </xsl:comment>
-    <html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
+    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
       <head/>
       <body style="margin:0;overflow:hidden;">
         <xsl:copy-of select="$result_svg"/>
@@ -6059,6 +6059,8 @@
 </xsl:text>
           <xsl:text>    NODE: (dv,offset) =&gt; [dv.getInt8(offset, true), 1],
 </xsl:text>
+          <xsl:text>    REAL: (dv,offset) =&gt; [dv.getFloat32(offset, true), 4],
+</xsl:text>
           <xsl:text>    STRING: (dv, offset) =&gt; {
 </xsl:text>
           <xsl:text>        size = dv.getInt8(offset);
--- a/svghmi/svghmi.js	Tue Oct 20 00:24:49 2020 +0200
+++ b/svghmi/svghmi.js	Thu Oct 22 22:44:29 2020 +0200
@@ -39,6 +39,7 @@
     INT: (dv,offset) => [dv.getInt16(offset, true), 2],
     BOOL: (dv,offset) => [dv.getInt8(offset, true), 1],
     NODE: (dv,offset) => [dv.getInt8(offset, true), 1],
+    REAL: (dv,offset) => [dv.getFloat32(offset, true), 4],
     STRING: (dv, offset) => {
         size = dv.getInt8(offset);
         return [
--- a/svghmi/svghmi.py	Tue Oct 20 00:24:49 2020 +0200
+++ b/svghmi/svghmi.py	Thu Oct 22 22:44:29 2020 +0200
@@ -35,7 +35,8 @@
     "HMI_NODE":{},
     "HMI_STRING":{},
     "HMI_INT":{},
-    "HMI_BOOL":{}
+    "HMI_BOOL":{},
+    "HMI_REAL":{}
 }
 
 HMI_TYPES = HMI_TYPES_DESC.keys()
--- a/tests/svghmi/plc.xml	Tue Oct 20 00:24:49 2020 +0200
+++ b/tests/svghmi/plc.xml	Thu Oct 22 22:44:29 2020 +0200
@@ -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="2019-08-06T14:23:42"/>
-  <contentHeader name="Unnamed" modificationDateTime="2020-08-03T17:17:02">
+  <contentHeader name="Unnamed" modificationDateTime="2020-10-22T08:43:10">
     <coordinateInfo>
       <fbd>
         <scaling x="5" y="5"/>
@@ -279,6 +279,11 @@
                 <simpleValue value="blup"/>
               </initialValue>
             </variable>
+            <variable name="floating">
+              <type>
+                <derived name="HMI_REAL"/>
+              </type>
+            </variable>
           </localVars>
         </interface>
         <body>
@@ -659,6 +664,90 @@
               </connectionPointOut>
               <expression>0</expression>
             </inVariable>
+            <outVariable localId="23" executionOrderId="0" height="25" width="75" negated="false">
+              <position x="935" y="120"/>
+              <connectionPointIn>
+                <relPosition x="0" y="10"/>
+                <connection refLocalId="25" formalParameter="OUT">
+                  <position x="935" y="130"/>
+                  <position x="922" y="130"/>
+                  <position x="922" y="110"/>
+                  <position x="910" y="110"/>
+                </connection>
+              </connectionPointIn>
+              <expression>floating</expression>
+            </outVariable>
+            <inVariable localId="24" executionOrderId="0" height="30" width="60" negated="false">
+              <position x="615" y="65"/>
+              <connectionPointOut>
+                <relPosition x="60" y="15"/>
+              </connectionPointOut>
+              <expression>Sloth</expression>
+            </inVariable>
+            <block localId="25" typeName="DIV" executionOrderId="0" height="60" width="65">
+              <position x="845" y="80"/>
+              <inputVariables>
+                <variable formalParameter="IN1">
+                  <connectionPointIn>
+                    <relPosition x="0" y="30"/>
+                    <connection refLocalId="27" formalParameter="OUT">
+                      <position x="845" y="110"/>
+                      <position x="822" y="110"/>
+                      <position x="822" y="80"/>
+                      <position x="800" y="80"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+                <variable formalParameter="IN2">
+                  <connectionPointIn>
+                    <relPosition x="0" y="50"/>
+                    <connection refLocalId="26">
+                      <position x="845" y="130"/>
+                      <position x="810" y="130"/>
+                      <position x="810" y="135"/>
+                      <position x="800" y="135"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+              </inputVariables>
+              <inOutVariables/>
+              <outputVariables>
+                <variable formalParameter="OUT">
+                  <connectionPointOut>
+                    <relPosition x="65" y="30"/>
+                  </connectionPointOut>
+                </variable>
+              </outputVariables>
+            </block>
+            <inVariable localId="26" executionOrderId="0" height="30" width="90" negated="false">
+              <position x="710" y="120"/>
+              <connectionPointOut>
+                <relPosition x="90" y="15"/>
+              </connectionPointOut>
+              <expression>REAL#100.0</expression>
+            </inVariable>
+            <block localId="27" typeName="INT_TO_REAL" executionOrderId="0" height="40" width="100">
+              <position x="700" y="50"/>
+              <inputVariables>
+                <variable formalParameter="IN">
+                  <connectionPointIn>
+                    <relPosition x="0" y="30"/>
+                    <connection refLocalId="24">
+                      <position x="700" y="80"/>
+                      <position x="675" y="80"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+              </inputVariables>
+              <inOutVariables/>
+              <outputVariables>
+                <variable formalParameter="OUT">
+                  <connectionPointOut>
+                    <relPosition x="100" y="30"/>
+                  </connectionPointOut>
+                </variable>
+              </outputVariables>
+            </block>
           </FBD>
         </body>
       </pou>
--- a/tests/svghmi/svghmi_0@svghmi/svghmi.svg	Tue Oct 20 00:24:49 2020 +0200
+++ b/tests/svghmi/svghmi_0@svghmi/svghmi.svg	Thu Oct 22 22:44:29 2020 +0200
@@ -16,7 +16,7 @@
    version="1.1"
    id="hmi0"
    sodipodi:docname="svghmi.svg"
-   inkscape:version="0.92.5 (0.92.5+68)">
+   inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)">
   <metadata
      id="metadata4542">
     <rdf:RDF>
@@ -200,13 +200,13 @@
      inkscape:current-layer="hmi0"
      showgrid="false"
      units="px"
-     inkscape:zoom="2.1826317"
-     inkscape:cx="-408.38959"
-     inkscape:cy="176.28106"
-     inkscape:window-width="1863"
-     inkscape:window-height="1176"
-     inkscape:window-x="57"
-     inkscape:window-y="24"
+     inkscape:zoom="0.38583842"
+     inkscape:cx="-56.535477"
+     inkscape:cy="77.476632"
+     inkscape:window-width="1920"
+     inkscape:window-height="1043"
+     inkscape:window-x="0"
+     inkscape:window-y="0"
      inkscape:window-maximized="1"
      showguides="true"
      inkscape:guide-bbox="true" />
@@ -6088,4 +6088,16 @@
            style="text-align:center;text-anchor:middle;fill:#ff6600;stroke-width:0.99999994px">Alarms</tspan></text>
     </g>
   </g>
+  <text
+     xml:space="preserve"
+     style="font-style:normal;font-weight:normal;font-size:45.74443054px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.28590268px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+     x="668.18188"
+     y="242.50345"
+     id="text889"
+     inkscape:label="HMI:Display@/PUMP0/FLOATING"><tspan
+       sodipodi:role="line"
+       id="tspan887"
+       x="668.18188"
+       y="242.50345"
+       style="fill:#ffffff;fill-opacity:1;stroke-width:0.28590268px">8888</tspan></text>
 </svg>