773 self.iec2c_path = os.path.join(base_folder, "matiec", "iec2c"+exe_ext) |
773 self.iec2c_path = os.path.join(base_folder, "matiec", "iec2c"+exe_ext) |
774 self.ieclib_path = os.path.join(base_folder, "matiec", "lib") |
774 self.ieclib_path = os.path.join(base_folder, "matiec", "lib") |
775 |
775 |
776 # Setup debug information |
776 # Setup debug information |
777 self.IECdebug_datas = {} |
777 self.IECdebug_datas = {} |
|
778 self.IECdebug_display_lock = Semaphore(1) |
778 self.IECdebug_lock = Lock() |
779 self.IECdebug_lock = Lock() |
779 |
780 |
780 self.DebugTimer=None |
781 self.DebugTimer=None |
781 self.ResetIECProgramsAndVariables() |
782 self.ResetIECProgramsAndVariables() |
782 |
783 |
1770 # This will block thread if more than one call is waiting |
1771 # This will block thread if more than one call is waiting |
1771 |
1772 |
1772 def GetTicktime(self): |
1773 def GetTicktime(self): |
1773 return self._Ticktime |
1774 return self._Ticktime |
1774 |
1775 |
|
1776 def DebugDispatch(self, TracedDebugVars, debug_tick): |
|
1777 for IECPath,value in TracedDebugVars: |
|
1778 if value is not None: |
|
1779 self.CallWeakcallables(IECPath, "NewValue", debug_tick, value) |
|
1780 self.CallWeakcallables("__tick__", "NewDataAvailable") |
|
1781 self.IECdebug_display_lock.release() |
|
1782 |
1775 def DebugThreadProc(self): |
1783 def DebugThreadProc(self): |
1776 """ |
1784 """ |
1777 This thread waid PLC debug data, and dispatch them to subscribers |
1785 This thread waid PLC debug data, and dispatch them to subscribers |
1778 """ |
1786 """ |
1779 self.debug_break = False |
1787 self.debug_break = False |
1787 if len(debug_vars) == len(self.TracedIECPath): |
1795 if len(debug_vars) == len(self.TracedIECPath): |
1788 if debug_getvar_retry > DEBUG_RETRIES_WARN: |
1796 if debug_getvar_retry > DEBUG_RETRIES_WARN: |
1789 wx.CallAfter(self.logger.write, |
1797 wx.CallAfter(self.logger.write, |
1790 _("... debugger recovered\n")) |
1798 _("... debugger recovered\n")) |
1791 debug_getvar_retry = 0 |
1799 debug_getvar_retry = 0 |
1792 for IECPath,value in zip(self.TracedIECPath, debug_vars): |
1800 if self.IECdebug_display_lock.acquire(False): |
1793 if value is not None: |
1801 wx.CallAfter(self.DebugDispatch, zip(self.TracedIECPath, debug_vars), debug_tick) |
1794 self.CallWeakcallables(IECPath, "NewValue", debug_tick, value) |
|
1795 self.CallWeakcallables("__tick__", "NewDataAvailable") |
|
1796 self.IECdebug_lock.release() |
1802 self.IECdebug_lock.release() |
1797 if debug_getvar_retry == DEBUG_RETRIES_WARN: |
1803 if debug_getvar_retry == DEBUG_RETRIES_WARN: |
1798 wx.CallAfter(self.logger.write, |
1804 wx.CallAfter(self.logger.write, |
1799 _("Waiting debugger to recover...\n")) |
1805 _("Waiting debugger to recover...\n")) |
1800 if debug_getvar_retry == DEBUG_RETRIES_REREGISTER: |
1806 if debug_getvar_retry == DEBUG_RETRIES_REREGISTER: |