1690 """ |
1690 """ |
1691 This thread waid PLC debug data, and dispatch them to subscribers |
1691 This thread waid PLC debug data, and dispatch them to subscribers |
1692 """ |
1692 """ |
1693 # This lock is used to avoid flooding wx event stack calling callafter |
1693 # This lock is used to avoid flooding wx event stack calling callafter |
1694 self.debug_break = False |
1694 self.debug_break = False |
|
1695 debug_getvar_retry = 0 |
1695 while (not self.debug_break) and (self._connector is not None): |
1696 while (not self.debug_break) and (self._connector is not None): |
1696 plc_status, debug_tick, debug_vars = self._connector.GetTraceVariables() |
1697 plc_status, debug_tick, debug_vars = self._connector.GetTraceVariables() |
1697 #print debug_tick, debug_vars |
1698 #print debug_tick, debug_vars |
1698 self.IECdebug_lock.acquire() |
1699 self.IECdebug_lock.acquire() |
1699 if debug_vars is not None: |
1700 if debug_vars is not None: |
|
1701 debug_getvar_retry = 0 |
1700 if len(debug_vars) == len(self.TracedIECPath): |
1702 if len(debug_vars) == len(self.TracedIECPath): |
1701 for IECPath,value in zip(self.TracedIECPath, debug_vars): |
1703 for IECPath,value in zip(self.TracedIECPath, debug_vars): |
1702 if value is not None: |
1704 if value is not None: |
1703 self.CallWeakcallables(IECPath, "NewValue", debug_tick, value) |
1705 self.CallWeakcallables(IECPath, "NewValue", debug_tick, value) |
1704 self.CallWeakcallables("__tick__", "NewDataAvailable") |
1706 self.CallWeakcallables("__tick__", "NewDataAvailable") |
1705 else : |
1707 else : |
1706 wx.CallAfter(self.logger.write_warning, |
1708 wx.CallAfter(self.logger.write_warning, |
1707 _("Debug data do not match requested variable count %d != %d\n")%(len(debug_vars), len(self.TracedIECPath))) |
1709 _("Debug data do not match requested variable count %d != %d\n")%(len(debug_vars), len(self.TracedIECPath))) |
1708 else: |
1710 else: |
1709 if plc_status == "Started": |
1711 if plc_status == "Started": |
|
1712 # Just in case, re-register debug registry to PLC |
|
1713 if debug_getvar_retry == 0: |
|
1714 wx.CallAfter(self.RegisterDebugVarToConnector) |
|
1715 wx.CallAfter(self.logger.write_warning, |
|
1716 _("Waiting debugger to recover...\n")) |
|
1717 debug_getvar_retry += 1 |
1710 # Be patient, tollerate PLC to come up before debugging |
1718 # Be patient, tollerate PLC to come up before debugging |
1711 time.sleep(0.1) |
1719 time.sleep(0.1) |
1712 else: |
1720 else: |
1713 wx.CallAfter(self.logger.write, _("Debugger disabled\n")) |
1721 wx.CallAfter(self.logger.write, _("Debugger disabled\n")) |
1714 self.debug_break = True |
1722 self.debug_break = True |