plugger.py
changeset 672 f97f207d027b
parent 670 fb03cb6da95c
child 673 2e1a2ea6242f
--- a/plugger.py	Wed Jan 25 01:23:44 2012 +0100
+++ b/plugger.py	Mon Jan 30 02:19:03 2012 +0100
@@ -775,6 +775,7 @@
         
         # Setup debug information
         self.IECdebug_datas = {}
+        self.IECdebug_display_lock = Semaphore(1) 
         self.IECdebug_lock = Lock()
 
         self.DebugTimer=None
@@ -1772,6 +1773,13 @@
     def GetTicktime(self):
         return self._Ticktime
 
+    def DebugDispatch(self, TracedDebugVars, debug_tick):
+        for IECPath,value in TracedDebugVars:
+            if value is not None:
+                self.CallWeakcallables(IECPath, "NewValue", debug_tick, value)
+        self.CallWeakcallables("__tick__", "NewDataAvailable")
+        self.IECdebug_display_lock.release()
+
     def DebugThreadProc(self):
         """
         This thread waid PLC debug data, and dispatch them to subscribers
@@ -1789,10 +1797,8 @@
                         wx.CallAfter(self.logger.write, 
                                  _("... debugger recovered\n"))
                     debug_getvar_retry = 0
-                    for IECPath,value in zip(self.TracedIECPath, debug_vars):
-                        if value is not None:
-                            self.CallWeakcallables(IECPath, "NewValue", debug_tick, value)
-                    self.CallWeakcallables("__tick__", "NewDataAvailable")
+                    if self.IECdebug_display_lock.acquire(False):
+                        wx.CallAfter(self.DebugDispatch, zip(self.TracedIECPath, debug_vars), debug_tick)
                 self.IECdebug_lock.release()
                 if debug_getvar_retry == DEBUG_RETRIES_WARN:
                     wx.CallAfter(self.logger.write,