Bug that fixed Windows in Debug mode fixed
authorgreg
Wed, 10 Jun 2009 13:58:52 +0200
changeset 372 8cab11dd2325
parent 371 a69a5a72daa1
child 373 db5f282946b0
Bug that fixed Windows in Debug mode fixed
PLCOpenEditor.py
Viewer.py
graphics/GraphicCommons.py
--- a/PLCOpenEditor.py	Wed Jun 10 13:18:42 2009 +0200
+++ b/PLCOpenEditor.py	Wed Jun 10 13:58:52 2009 +0200
@@ -4558,8 +4558,8 @@
     def SetValue(self, value):
         if self.Value != value:
             self.Value = value
-            self.Parent.NewDataAvailable()
-    
+            self.Parent.HasNewData = True
+            
     def GetValue(self):
         return self.Value
 
@@ -4791,6 +4791,7 @@
         self._init_ctrls(parent)
         DebugViewer.__init__(self, controler, True)
         self.Controler = controler
+        self.HasNewData = False
         
         self.Table = DebugVariableTable(self, [], ["Variable", "Value"])
         self.VariablesGrid.SetTable(self.Table)
@@ -4805,7 +4806,10 @@
         self.Table.ResetView(self.VariablesGrid)
     
     def RefreshNewData(self):
-        self.RefreshGrid()
+        if self.HasNewData:
+            self.HasNewData = False
+            self.RefreshGrid()
+        DebugViewer.RefreshNewData(self)
     
     def RefreshGrid(self):
         self.Freeze()
--- a/Viewer.py	Wed Jun 10 13:18:42 2009 +0200
+++ b/Viewer.py	Wed Jun 10 13:58:52 2009 +0200
@@ -660,13 +660,13 @@
         if self.NewDataRefreshRect is not None:
             refresh_rect, self.NewDataRefreshRect = self.NewDataRefreshRect, None
             self.RefreshRect(self.GetScrolledRect(refresh_rect), False)
-        DebugViewer.RefreshNewData(self)
-
+        
     def ResetBuffer(self):
         pass
 
     # Refresh Viewer elements
     def RefreshView(self):
+        self.Inhibit(True)
         self.current_id = 0
         # Start by reseting Viewer
         self.Flush()
@@ -713,7 +713,8 @@
                 iec_path = self.GetElementIECPath(block)
                 if iec_path is not None:
                     self.AddDataConsumer(iec_path.upper(), block)
-        
+
+        self.Inhibit(False)
         self.RefreshVisibleElements()
         self.ShowErrors()
         self.Refresh(False)
@@ -2899,6 +2900,8 @@
         dc = self.GetLogicalDC(True)
         self.DoDrawing(dc)
         wx.BufferedPaintDC(self, dc.GetAsBitmap())
+        if self.Debug:
+            DebugViewer.RefreshNewData(self)
         event.Skip()
 
 
--- a/graphics/GraphicCommons.py	Wed Jun 10 13:18:42 2009 +0200
+++ b/graphics/GraphicCommons.py	Wed Jun 10 13:58:52 2009 +0200
@@ -201,7 +201,7 @@
     
     def Inhibit(self, inhibit):
         self.Inhibited = inhibit
-        if inhibit and self.LastValue is not None:
+        if not inhibit and self.LastValue is not None:
             self.SetValue(self.LastValue)
             self.LastValue = None
         
@@ -225,17 +225,18 @@
     def __init__(self, producer, debug, register_tick=True):
         self.DataProducer = producer
         self.Debug = debug
+        self.Inhibited = False
         
         self.DataConsumers = {}
         
         self.LastRefreshTime = gettime()
         
+        self.RefreshTimer = wx.Timer(self, -1)
+        self.Bind(wx.EVT_TIMER, self.OnRefreshTimer, self.RefreshTimer)
+        
         if register_tick and debug:
             self.DataProducer.SubscribeDebugIECVariable("__tick__", self)
         
-        self.RefreshTimer = wx.Timer(self, -1)
-        self.Bind(wx.EVT_TIMER, self.OnRefreshTimer, self.RefreshTimer)
-    
     def __del__(self):
         if self.Debug:
             self.DataProducer.UnsubscribeDebugIECVariable("__tick__", self)
@@ -243,6 +244,7 @@
         self.RefreshTimer.Stop()
         
     def Inhibit(self, inhibit):
+        self.Inhibited = inhibit
         for consumer, iec_path in self.DataConsumers.iteritems():
             consumer.Inhibit(inhibit)
     
@@ -267,12 +269,14 @@
         event.Skip()
     
     def NewDataAvailable(self):
-        self.Inhibit(True)
-        current_time = gettime()
-        if current_time - self.LastRefreshTime > REFRESH_PERIOD:
-            self.LastRefreshTime = current_time
-            wx.CallAfter(self.RefreshViewOnNewData)
-
+        self.RefreshTimer.Stop()
+        if not self.Inhibited:
+            current_time = gettime()
+            if current_time - self.LastRefreshTime > REFRESH_PERIOD:
+                self.LastRefreshTime = current_time
+                self.Inhibit(True)
+                wx.CallAfter(self.RefreshViewOnNewData)
+            
     def RefreshViewOnNewData(self):
         if self:
             self.RefreshNewData()