Fix bug with refresh PLC status tool bar
authorLaurent Bessard
Wed, 30 Jan 2013 19:03:25 +0100
changeset 918 aa136ef12506
parent 917 401e44bae7c0
child 919 4a36e38e51d3
Fix bug with refresh PLC status tool bar
Beremiz.py
ProjectController.py
tests/python/plc.xml
--- a/Beremiz.py	Wed Jan 30 18:54:12 2013 +1100
+++ b/Beremiz.py	Wed Jan 30 19:03:25 2013 +0100
@@ -774,8 +774,6 @@
             getattr(self.CTR, method)()
             # Re-enable button 
             event.GetEventObject().Enable()
-            # Trigger refresh on Idle
-            wx.CallAfter(self.RefreshStatusToolBar)
         return OnMenu
     
     def GetConfigEntry(self, entry_name, default):
--- a/ProjectController.py	Wed Jan 30 18:54:12 2013 +1100
+++ b/ProjectController.py	Wed Jan 30 19:03:25 2013 +0100
@@ -1123,19 +1123,16 @@
                    }.get(status,[]):
                 self.ShowMethod(*args)
             self.previous_plcstate = status
-            return True
-        return False
+            {"Broken": self.logger.write_error,
+             None: lambda x: None}.get(
+                status, self.logger.write)(_("PLC is %s\n")%_(status))
+            if self.AppFrame is not None:
+                self.AppFrame.RefreshStatusToolBar()
     
     def PullPLCStatusProc(self, event):
         if self._connector is None:
             self.StatusTimer.Stop()
-        if self.UpdateMethodsFromPLCStatus():
-            
-            status = _(self.previous_plcstate)
-            {"Broken": self.logger.write_error,
-             None: lambda x: None}.get(
-                self.previous_plcstate, self.logger.write)(_("PLC is %s\n")%status)
-            self.AppFrame.RefreshStatusToolBar()
+        self.UpdateMethodsFromPLCStatus()
         
     def RegisterDebugVarToConnector(self):
         self.DebugTimer=None
--- a/tests/python/plc.xml	Wed Jan 30 18:54:12 2013 +1100
+++ b/tests/python/plc.xml	Wed Jan 30 19:03:25 2013 +0100
@@ -8,7 +8,7 @@
               productVersion="0.0"
               creationDateTime="2008-12-14T16:21:19"/>
   <contentHeader name="Beremiz Python Support Tests"
-                 modificationDateTime="2012-11-15T18:38:58">
+                 modificationDateTime="2013-01-11T14:08:25">
     <coordinateInfo>
       <pageSize x="1024" y="1024"/>
       <fbd>
@@ -155,6 +155,9 @@
               <type>
                 <string/>
               </type>
+              <initialValue>
+                <simpleValue value="test"/>
+              </initialValue>
             </variable>
             <variable name="Test_Bool">
               <type>
@@ -1064,6 +1067,30 @@
           </ST>
         </body>
       </pou>
+      <pou name="norm" pouType="function">
+        <interface>
+          <returnType>
+            <REAL/>
+          </returnType>
+          <inputVars>
+            <variable name="IN1">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+            <variable name="IN2">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+          </inputVars>
+        </interface>
+        <body>
+          <ST>
+<![CDATA[NORM := SQRT(IN1 * IN1 + IN2 * IN2);]]>
+          </ST>
+        </body>
+      </pou>
     </pous>
   </types>
   <instances>
@@ -1071,6 +1098,13 @@
       <configuration name="conf_pytest">
         <resource name="res_pytest">
           <task name="pytest_task" interval="T#1ms" priority="0"/>
+          <globalVars>
+            <variable name="TOTO">
+              <type>
+                <INT/>
+              </type>
+            </variable>
+          </globalVars>
           <pouInstance name="pytest_instance" typeName="main_pytest"/>
         </resource>
         <globalVars>