Extended wxHMI test
authorEdouard Tisserant
Thu, 18 Jun 2015 15:22:43 +0200
changeset 1462 9ee3a2dea7e8
parent 1461 954d1f42d42d
child 1463 de311ffe3961
child 1465 9011e2ceea85
Extended wxHMI test
tests/wxGlade/HMIFrame@wxglade_hmi/py_ext.xml
tests/wxGlade/HMIFrame@wxglade_hmi/pyfile.xml
tests/wxHMI/HMI@wxglade_hmi/hmi.wxg
tests/wxHMI/HMI@wxglade_hmi/pyfile.xml
tests/wxHMI/plc.xml
--- a/tests/wxGlade/HMIFrame@wxglade_hmi/py_ext.xml	Thu Jun 18 11:36:35 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<Python xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="python_xsd.xsd">
-<![CDATA[]]>
-</Python>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/wxGlade/HMIFrame@wxglade_hmi/pyfile.xml	Thu Jun 18 15:22:43 2015 +0200
@@ -0,0 +1,19 @@
+<?xml version='1.0' encoding='utf-8'?>
+<PyFile xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+  <variables/>
+  <globals>
+    <xhtml:p><![CDATA[]]></xhtml:p>
+  </globals>
+  <init>
+    <xhtml:p><![CDATA[]]></xhtml:p>
+  </init>
+  <cleanup>
+    <xhtml:p><![CDATA[]]></xhtml:p>
+  </cleanup>
+  <start>
+    <xhtml:p><![CDATA[]]></xhtml:p>
+  </start>
+  <stop>
+    <xhtml:p><![CDATA[]]></xhtml:p>
+  </stop>
+</PyFile>
--- a/tests/wxHMI/HMI@wxglade_hmi/hmi.wxg	Thu Jun 18 11:36:35 2015 +0200
+++ b/tests/wxHMI/HMI@wxglade_hmi/hmi.wxg	Thu Jun 18 15:22:43 2015 +0200
@@ -1,72 +1,99 @@
-<?xml version="1.0"?>
-<!-- generated by wxGlade HG on Fri Aug 22 11:10:56 2014 -->
-
-<application path="" name="" class="" option="0" language="python" top_window="wxglade_hmi" encoding="UTF-8" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.8" is_template="0" indent_amount="4" indent_symbol="space" source_extension=".cpp" header_extension=".h">
-    <object class="Class_wxglade_hmi" name="wxglade_hmi" base="EditFrame">
-        <style>wxCAPTION|wxCLOSE_BOX|wxMINIMIZE_BOX|wxMAXIMIZE|wxMAXIMIZE_BOX|wxSYSTEM_MENU|wxRESIZE_BORDER|wxCLIP_CHILDREN</style>
-        <title>frame_1</title>
-        <object class="wxFlexGridSizer" name="grid_sizer_1" base="EditFlexGridSizer">
-            <hgap>0</hgap>
-            <growable_rows>0</growable_rows>
-            <rows>1</rows>
-            <growable_cols>0</growable_cols>
-            <cols>2</cols>
-            <vgap>0</vgap>
-            <object class="sizeritem">
-                <flag>wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
-                <border>0</border>
-                <option>1</option>
-                <object class="ThreeDee" name="window_1" base="CustomWidget">
-                    <arguments>
-                        <argument>$parent</argument>
-                        <argument>$id</argument>
-                    </arguments>
-                    <size>400,400</size>
-                </object>
-            </object>
-            <object class="sizeritem">
-                <flag>wxEXPAND</flag>
-                <border>0</border>
-                <option>1</option>
-                <object class="wxFlexGridSizer" name="sizer_1" base="EditFlexGridSizer">
-                    <hgap>0</hgap>
-                    <growable_rows>0</growable_rows>
-                    <rows>2</rows>
-                    <cols>1</cols>
-                    <vgap>0</vgap>
-                    <object class="sizeritem">
-                        <flag>wxEXPAND</flag>
-                        <border>0</border>
-                        <option>1</option>
-                        <object class="wxBoxSizer" name="sizer_2" base="EditBoxSizer">
-                            <orient>wxVERTICAL</orient>
-                            <object class="sizerslot" />
-                            <object class="sizerslot" />
-                            <object class="sizerslot" />
-                            <object class="sizerslot" />
-                        </object>
-                    </object>
-                    <object class="sizeritem">
-                        <flag>wxEXPAND</flag>
-                        <border>0</border>
-                        <option>1</option>
-                        <object class="wxGridSizer" name="sizer_3" base="EditGridSizer">
-                            <hgap>0</hgap>
-                            <rows>4</rows>
-                            <cols>2</cols>
-                            <vgap>0</vgap>
-                            <object class="sizerslot" />
-                            <object class="sizerslot" />
-                            <object class="sizerslot" />
-                            <object class="sizerslot" />
-                            <object class="sizerslot" />
-                            <object class="sizerslot" />
-                            <object class="sizerslot" />
-                            <object class="sizerslot" />
-                        </object>
-                    </object>
-                </object>
-            </object>
-        </object>
-    </object>
-</application>
+<?xml version="1.0"?>
+<!-- generated by wxGlade 0.6.8 on Thu Jun 18 15:19:02 2015 -->
+
+<application path="" name="" class="" option="0" language="python" top_window="wxglade_hmi" encoding="UTF-8" use_gettext="1" overwrite="0" use_new_namespace="1" for_version="2.8" is_template="0" indent_amount="4" indent_symbol="space" source_extension=".cpp" header_extension=".h">
+    <object class="Class_wxglade_hmi" name="wxglade_hmi" base="EditFrame">
+        <style>wxCAPTION|wxCLOSE_BOX|wxMINIMIZE_BOX|wxMAXIMIZE|wxMAXIMIZE_BOX|wxSYSTEM_MENU|wxRESIZE_BORDER|wxCLIP_CHILDREN</style>
+        <title>frame_1</title>
+        <object class="wxFlexGridSizer" name="grid_sizer_1" base="EditFlexGridSizer">
+            <hgap>0</hgap>
+            <growable_rows>0</growable_rows>
+            <rows>1</rows>
+            <growable_cols>0</growable_cols>
+            <cols>4</cols>
+            <vgap>0</vgap>
+            <object class="sizeritem">
+                <flag>wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
+                <border>0</border>
+                <option>1</option>
+                <object class="ThreeDee" name="window_1" base="CustomWidget">
+                    <extracode># WHERE IS THAT ?\nprint "hello"\n</extracode>
+                    <arguments>
+                        <argument>$parent</argument>
+                        <argument>$id</argument>
+                    </arguments>
+                    <size>400,400</size>
+                </object>
+            </object>
+            <object class="sizeritem">
+                <flag>wxEXPAND</flag>
+                <border>0</border>
+                <option>1</option>
+                <object class="wxFlexGridSizer" name="sizer_1" base="EditFlexGridSizer">
+                    <hgap>0</hgap>
+                    <growable_rows>0</growable_rows>
+                    <rows>2</rows>
+                    <cols>1</cols>
+                    <vgap>0</vgap>
+                    <object class="sizeritem">
+                        <flag>wxEXPAND</flag>
+                        <border>0</border>
+                        <option>1</option>
+                        <object class="wxBoxSizer" name="sizer_2" base="EditBoxSizer">
+                            <orient>wxVERTICAL</orient>
+                            <object class="sizerslot" />
+                            <object class="sizerslot" />
+                            <object class="sizerslot" />
+                            <object class="sizerslot" />
+                        </object>
+                    </object>
+                    <object class="sizeritem">
+                        <flag>wxEXPAND</flag>
+                        <border>0</border>
+                        <option>1</option>
+                        <object class="wxGridSizer" name="sizer_3" base="EditGridSizer">
+                            <hgap>0</hgap>
+                            <rows>4</rows>
+                            <cols>2</cols>
+                            <vgap>0</vgap>
+                            <object class="sizerslot" />
+                            <object class="sizerslot" />
+                            <object class="sizerslot" />
+                            <object class="sizerslot" />
+                            <object class="sizerslot" />
+                            <object class="sizerslot" />
+                            <object class="sizerslot" />
+                            <object class="sizerslot" />
+                        </object>
+                    </object>
+                </object>
+            </object>
+            <object class="sizeritem">
+                <border>0</border>
+                <option>0</option>
+                <object class="wxToggleButton" name="DrawTestBt" base="EditToggleButton">
+                    <label>Please Draw !</label>
+                    <events>
+                        <handler event="EVT_TOGGLEBUTTON">SetPLCGlobalVar</handler>
+                    </events>
+                    <extraproperties>
+                        <property name="Name">"DrawTest"</property>
+                    </extraproperties>
+                </object>
+            </object>
+            <object class="sizeritem">
+                <border>0</border>
+                <option>0</option>
+                <object class="wxToggleButton" name="DrawTestBt_copy" base="EditToggleButton">
+                    <label>Please Draw copy !</label>
+                    <events>
+                        <handler event="EVT_TOGGLEBUTTON">SetPLCGlobalVar</handler>
+                    </events>
+                    <extraproperties>
+                        <property name="Name">"DrawEscher"</property>
+                    </extraproperties>
+                </object>
+            </object>
+        </object>
+    </object>
+</application>
--- a/tests/wxHMI/HMI@wxglade_hmi/pyfile.xml	Thu Jun 18 11:36:35 2015 +0200
+++ b/tests/wxHMI/HMI@wxglade_hmi/pyfile.xml	Thu Jun 18 15:22:43 2015 +0200
@@ -72,16 +72,23 @@
     obj.Bind(wx.EVT_LEFT_UP, ButtonUp)
     return obj
 
-def UpdatePositions(self, event):
-
-    # TODO : uncomment
+def UpdPos(self):
     positions = [getattr(PLCGlobals,axname+"axisPos") for axname in AxisList]
 
     self.window_1.UpdatePositions(positions)
 
-    event.Skip()
+Class_wxglade_hmi.UpdPos = UpdPos
 
-Class_wxglade_hmi.UpdatePositions = UpdatePositions
+
+#def UpdatePositions(self, event):
+#
+#    positions = [getattr(PLCGlobals,axname+"axisPos") for axname in AxisList]
+#
+#    self.window_1.UpdatePositions(positions)
+#
+#    event.Skip()
+
+#Class_wxglade_hmi.UpdatePositions = UpdatePositions
 
 initorig = Class_wxglade_hmi.__init__
 def Init(self,*args,**kargs):
@@ -96,26 +103,16 @@
         lambda axis:( MakeButtonFunc(self, sizer, axis+"axisMinus"), 
                         MakeButtonFunc(self, sizer, axis+"axisPlus")),
         AxisList)
-    self.timer = wx.Timer(self, -1)
-    self.Bind(wx.EVT_TIMER, self.UpdatePositions, self.timer)
+    # self.timer = wx.Timer(self, -1)
+    # self.Bind(wx.EVT_TIMER, self.UpdatePositions, self.timer)
     self.ShowFullScreen(True,wx.FULLSCREEN_ALL)
-    wx.CallAfter(self.timer.Start,200)
+    # wx.CallAfter(self.timer.Start,200)
     
 Class_wxglade_hmi.__init__ = Init
 
-def GUIMessage(message):
-    try:
-       wxglade_hmi.window_1.Message = message
-    except:
-       # sometime get some wxpydeadobject
-       pass
-
-def SetNegLimits(*args):
-    wxglade_hmi.window_1.NegLimits = args
-
-def SetDisk(*args):
-    wxglade_hmi.window_1.Disk = args
-    GUIMessage("DiskOK")
+def SetPLCGlobalVar(self, evt):
+    tglbtname = evt.GetEventObject().GetName()
+    setattr(PLCGlobals, tglbtname, evt.GetEventObject().GetValue())
 
 ]]></xhtml:p>
   </globals>
--- a/tests/wxHMI/plc.xml	Thu Jun 18 11:36:35 2015 +0200
+++ b/tests/wxHMI/plc.xml	Thu Jun 18 15:22:43 2015 +0200
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='utf-8'?>
 <project xmlns="http://www.plcopen.org/xml/tc6_0201" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation="http://www.plcopen.org/xml/tc6_0201">
   <fileHeader companyName="Unknown" productName="Unnamed" productVersion="1" creationDateTime="2012-09-12T23:30:19"/>
-  <contentHeader name="Unnamed" modificationDateTime="2015-06-18T11:28:47">
+  <contentHeader name="Unnamed" modificationDateTime="2015-06-18T15:22:07">
     <coordinateInfo>
       <pageSize x="1050" y="1485"/>
       <fbd>
@@ -64,11 +64,18 @@
               </type>
             </variable>
           </localVars>
+          <externalVars>
+            <variable name="ZaxisPos">
+              <type>
+                <INT/>
+              </type>
+            </variable>
+          </externalVars>
         </interface>
         <body>
           <FBD>
             <inVariable localId="286" executionOrderId="0" height="25" width="65" negated="false">
-              <position x="170" y="155"/>
+              <position x="230" y="205"/>
               <connectionPointOut>
                 <relPosition x="65" y="10"/>
               </connectionPointOut>
@@ -83,8 +90,8 @@
                     <connection refLocalId="286">
                       <position x="395" y="220"/>
                       <position x="315" y="220"/>
-                      <position x="315" y="165"/>
-                      <position x="235" y="165"/>
+                      <position x="315" y="215"/>
+                      <position x="295" y="215"/>
                     </connection>
                   </connectionPointIn>
                 </variable>
@@ -93,9 +100,9 @@
                     <relPosition x="0" y="55"/>
                     <connection refLocalId="288">
                       <position x="395" y="245"/>
-                      <position x="315" y="245"/>
-                      <position x="315" y="265"/>
-                      <position x="235" y="265"/>
+                      <position x="320" y="245"/>
+                      <position x="320" y="260"/>
+                      <position x="310" y="260"/>
                     </connection>
                   </connectionPointIn>
                 </variable>
@@ -110,7 +117,7 @@
               </outputVariables>
             </block>
             <inVariable localId="288" executionOrderId="0" height="25" width="70" negated="false">
-              <position x="165" y="255"/>
+              <position x="240" y="250"/>
               <connectionPointOut>
                 <relPosition x="70" y="10"/>
               </connectionPointOut>
@@ -129,6 +136,124 @@
               </connectionPointIn>
               <expression>power</expression>
             </outVariable>
+            <inVariable localId="290" executionOrderId="0" height="25" width="60" negated="false">
+              <position x="75" y="55"/>
+              <connectionPointOut>
+                <relPosition x="60" y="10"/>
+              </connectionPointOut>
+              <expression>DrawTest</expression>
+            </inVariable>
+            <block localId="292" typeName="ADD" executionOrderId="0" height="65" width="60">
+              <position x="350" y="50"/>
+              <inputVariables>
+                <variable formalParameter="IN1">
+                  <connectionPointIn>
+                    <relPosition x="0" y="30"/>
+                    <connection refLocalId="291">
+                      <position x="350" y="80"/>
+                      <position x="340" y="80"/>
+                      <position x="340" y="25"/>
+                      <position x="530" y="25"/>
+                      <position x="530" y="45"/>
+                      <position x="520" y="45"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+                <variable formalParameter="IN2">
+                  <connectionPointIn>
+                    <relPosition x="0" y="55"/>
+                    <connection refLocalId="293" formalParameter="OUT">
+                      <position x="350" y="105"/>
+                      <position x="287" y="105"/>
+                      <position x="287" y="65"/>
+                      <position x="225" y="65"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+              </inputVariables>
+              <inOutVariables/>
+              <outputVariables>
+                <variable formalParameter="OUT">
+                  <connectionPointOut>
+                    <relPosition x="60" y="30"/>
+                  </connectionPointOut>
+                </variable>
+              </outputVariables>
+            </block>
+            <inOutVariable localId="291" executionOrderId="0" height="25" width="55" negatedOut="false" negatedIn="false">
+              <position x="465" y="35"/>
+              <connectionPointIn>
+                <relPosition x="0" y="10"/>
+                <connection refLocalId="292" formalParameter="OUT">
+                  <position x="465" y="45"/>
+                  <position x="437" y="45"/>
+                  <position x="437" y="80"/>
+                  <position x="410" y="80"/>
+                </connection>
+              </connectionPointIn>
+              <connectionPointOut>
+                <relPosition x="55" y="10"/>
+              </connectionPointOut>
+              <expression>ZaxisPos</expression>
+            </inOutVariable>
+            <block localId="293" typeName="SEL" executionOrderId="0" height="85" width="60">
+              <position x="165" y="35"/>
+              <inputVariables>
+                <variable formalParameter="G">
+                  <connectionPointIn>
+                    <relPosition x="0" y="30"/>
+                    <connection refLocalId="290">
+                      <position x="165" y="65"/>
+                      <position x="135" y="65"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+                <variable formalParameter="IN0">
+                  <connectionPointIn>
+                    <relPosition x="0" y="50"/>
+                    <connection refLocalId="295">
+                      <position x="165" y="85"/>
+                      <position x="135" y="85"/>
+                      <position x="135" y="90"/>
+                      <position x="105" y="90"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+                <variable formalParameter="IN1">
+                  <connectionPointIn>
+                    <relPosition x="0" y="70"/>
+                    <connection refLocalId="294">
+                      <position x="165" y="105"/>
+                      <position x="135" y="105"/>
+                      <position x="135" y="115"/>
+                      <position x="105" y="115"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+              </inputVariables>
+              <inOutVariables/>
+              <outputVariables>
+                <variable formalParameter="OUT">
+                  <connectionPointOut>
+                    <relPosition x="60" y="30"/>
+                  </connectionPointOut>
+                </variable>
+              </outputVariables>
+            </block>
+            <inVariable localId="294" executionOrderId="0" height="25" width="20" negated="false">
+              <position x="85" y="105"/>
+              <connectionPointOut>
+                <relPosition x="20" y="10"/>
+              </connectionPointOut>
+              <expression>1</expression>
+            </inVariable>
+            <inVariable localId="295" executionOrderId="0" height="25" width="20" negated="false">
+              <position x="85" y="80"/>
+              <connectionPointOut>
+                <relPosition x="20" y="10"/>
+              </connectionPointOut>
+              <expression>0</expression>
+            </inVariable>
           </FBD>
         </body>
         <documentation>
@@ -171,6 +296,13 @@
               </type>
             </variable>
           </externalVars>
+          <localVars>
+            <variable name="python_poll0">
+              <type>
+                <derived name="python_poll"/>
+              </type>
+            </variable>
+          </localVars>
         </interface>
         <body>
           <FBD>
@@ -321,6 +453,56 @@
               </connectionPointOut>
               <expression>power</expression>
             </inVariable>
+            <block localId="220" typeName="python_poll" instanceName="python_poll0" executionOrderId="0" height="65" width="85">
+              <position x="640" y="370"/>
+              <inputVariables>
+                <variable formalParameter="TRIG">
+                  <connectionPointIn>
+                    <relPosition x="0" y="30"/>
+                    <connection refLocalId="221">
+                      <position x="640" y="400"/>
+                      <position x="595" y="400"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+                <variable formalParameter="CODE">
+                  <connectionPointIn>
+                    <relPosition x="0" y="55"/>
+                    <connection refLocalId="222">
+                      <position x="640" y="425"/>
+                      <position x="590" y="425"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+              </inputVariables>
+              <inOutVariables/>
+              <outputVariables>
+                <variable formalParameter="ACK">
+                  <connectionPointOut>
+                    <relPosition x="85" y="30"/>
+                  </connectionPointOut>
+                </variable>
+                <variable formalParameter="RESULT">
+                  <connectionPointOut>
+                    <relPosition x="85" y="55"/>
+                  </connectionPointOut>
+                </variable>
+              </outputVariables>
+            </block>
+            <inVariable localId="221" executionOrderId="0" height="25" width="75" negated="false">
+              <position x="520" y="390"/>
+              <connectionPointOut>
+                <relPosition x="75" y="10"/>
+              </connectionPointOut>
+              <expression>BOOL#TRUE</expression>
+            </inVariable>
+            <inVariable localId="222" executionOrderId="0" height="25" width="135" negated="false">
+              <position x="455" y="415"/>
+              <connectionPointOut>
+                <relPosition x="135" y="10"/>
+              </connectionPointOut>
+              <expression>'wxglade_hmi.UpdPos()'</expression>
+            </inVariable>
           </FBD>
         </body>
         <documentation>
@@ -382,7 +564,7 @@
           <task name="ControlTask" priority="0" interval="T#2ms">
             <pouInstance name="MainInstance" typeName="main"/>
           </task>
-          <task name="GUIupdate" priority="0" interval="T#40ms">
+          <task name="GUIupdate" priority="0" interval="T#200ms">
             <pouInstance name="PosReader" typeName="ReadGUIdata"/>
           </task>
           <globalVars>