plugger.py
changeset 465 67d32a91d70b
parent 464 46dd4358e8a8
child 466 11263fd24566
equal deleted inserted replaced
464:46dd4358e8a8 465:67d32a91d70b
  1600 
  1600 
  1601             if Idxs:
  1601             if Idxs:
  1602                 Idxs.sort()
  1602                 Idxs.sort()
  1603                 self.TracedIECPath = zip(*Idxs)[2]
  1603                 self.TracedIECPath = zip(*Idxs)[2]
  1604                 self._connector.SetTraceVariablesList(zip(*zip(*Idxs)[0:2]))
  1604                 self._connector.SetTraceVariablesList(zip(*zip(*Idxs)[0:2]))
       
  1605             else:
       
  1606                 self.TracedIECPath = []
       
  1607                 self._connector.SetTraceVariablesList([])
  1605             self.IECdebug_lock.release()
  1608             self.IECdebug_lock.release()
  1606             
  1609             
  1607             #for IEC_path, IECdebug_data in self.IECdebug_datas.iteritems():
  1610             #for IEC_path, IECdebug_data in self.IECdebug_datas.iteritems():
  1608             #    print IEC_path, IECdebug_data[0].keys()
  1611             #    print IEC_path, IECdebug_data[0].keys()
  1609 
  1612 
  1725         self.DebugThread.join(timeout=1)
  1728         self.DebugThread.join(timeout=1)
  1726         if self.DebugThread.isAlive():
  1729         if self.DebugThread.isAlive():
  1727             self.logger.write_warning(_("Debug Thread couldn't be killed"))
  1730             self.logger.write_warning(_("Debug Thread couldn't be killed"))
  1728         self.DebugThread = None
  1731         self.DebugThread = None
  1729 
  1732 
       
  1733     def _connect_debug(self): 
       
  1734         if self.AppFrame:
       
  1735             self.AppFrame.ResetGraphicViewers()
       
  1736         self.RegisterDebugVarToConnector()
       
  1737         self.DebugThread = Thread(target=self.DebugThreadProc)
       
  1738         self.DebugThread.start()
       
  1739     
  1730     def _Run(self):
  1740     def _Run(self):
  1731         """
  1741         """
  1732         Start PLC
  1742         Start PLC
  1733         """
  1743         """
  1734         if self.GetIECProgramsAndVariables():
  1744         if self.GetIECProgramsAndVariables():
  1735             self._connector.StartPLC()
  1745             self._connector.StartPLC()
  1736             self.logger.write(_("Starting PLC\n"))
  1746             self.logger.write(_("Starting PLC\n"))
  1737             if self.AppFrame:
  1747             self._connect_debug()
  1738                 self.AppFrame.ResetGraphicViewers()
       
  1739             self.RegisterDebugVarToConnector()
       
  1740             self.DebugThread = Thread(target=self.DebugThreadProc)
       
  1741             self.DebugThread.start()
       
  1742         else:
  1748         else:
  1743             self.logger.write_error(_("Couldn't start PLC !\n"))
  1749             self.logger.write_error(_("Couldn't start PLC !\n"))
  1744         self.UpdateMethodsFromPLCStatus()
  1750         self.UpdateMethodsFromPLCStatus()
  1745 
  1751 
  1746 
  1752 
  1828                 status = ""
  1834                 status = ""
  1829             self.logger.write(_("PLC is %s\n")%status)
  1835             self.logger.write(_("PLC is %s\n")%status)
  1830             
  1836             
  1831             # Start the status Timer
  1837             # Start the status Timer
  1832             self.StatusTimer.Start(milliseconds=500, oneShot=False)
  1838             self.StatusTimer.Start(milliseconds=500, oneShot=False)
       
  1839             
       
  1840             if self.previous_plcstate=="Started":
       
  1841                 if self.DebugAvailable() and self.GetIECProgramsAndVariables():
       
  1842                     self.logger.write(_("Debug connect matching running PLC\n"))
       
  1843                     self._connect_debug()
       
  1844                 else:
       
  1845                     self.logger.write_warning(_("Debug do not match PLC - stop/transfert/start to re-enable\n"))
  1833 
  1846 
  1834     def CompareLocalAndRemotePLC(self):
  1847     def CompareLocalAndRemotePLC(self):
  1835         if self._connector is None:
  1848         if self._connector is None:
  1836             return
  1849             return
  1837         # We are now connected. Update button status
  1850         # We are now connected. Update button status
  1844                 self.EnableMethod("_Transfer", True)
  1857                 self.EnableMethod("_Transfer", True)
  1845             else:
  1858             else:
  1846                 self.logger.write(
  1859                 self.logger.write(
  1847                    _("Latest build matches target, no transfer needed.\n"))
  1860                    _("Latest build matches target, no transfer needed.\n"))
  1848                 self.EnableMethod("_Transfer", True)
  1861                 self.EnableMethod("_Transfer", True)
       
  1862                 # warns controller that program match
       
  1863                 self.ProgramTransferred()
  1849                 #self.EnableMethod("_Transfer", False)
  1864                 #self.EnableMethod("_Transfer", False)
  1850         else:
  1865         else:
  1851             self.logger.write_warning(
  1866             self.logger.write_warning(
  1852                 _("Cannot compare latest build to target. Please build.\n"))
  1867                 _("Cannot compare latest build to target. Please build.\n"))
  1853             self.EnableMethod("_Transfer", False)
  1868             self.EnableMethod("_Transfer", False)