plugger.py
changeset 483 bc26c42d2eec
parent 481 28d47c1df46f
child 486 2e0fe44044b3
equal deleted inserted replaced
482:7c83eb6a55bd 483:bc26c42d2eec
   679 from PLCOpenEditor import PLCOpenEditor, ProjectDialog
   679 from PLCOpenEditor import PLCOpenEditor, ProjectDialog
   680 from TextViewer import TextViewer
   680 from TextViewer import TextViewer
   681 from plcopen.structures import IEC_KEYWORDS, TypeHierarchy_list
   681 from plcopen.structures import IEC_KEYWORDS, TypeHierarchy_list
   682 
   682 
   683 # Construct debugger natively supported types
   683 # Construct debugger natively supported types
   684 DebugTypes = [t for t in zip(*TypeHierarchy_list)[0] if not t.startswith("ANY")] + \
   684 DebugTypes = [t for t in zip(*TypeHierarchy_list)[0] if not t.startswith("ANY")]
   685     ["STEP","TRANSITION","ACTION"]
       
   686 DebugTypesSize =  {"BOOL" :       1,
   685 DebugTypesSize =  {"BOOL" :       1,
   687                    "STEP" :       1,
       
   688                    "TRANSITION" : 1,
       
   689                    "ACTION" :     1,
       
   690                    "SINT" :       1,
   686                    "SINT" :       1,
   691                    "USINT" :      1,
   687                    "USINT" :      1,
   692                    "BYTE" :       1,
   688                    "BYTE" :       1,
   693                    "STRING" :     128,
   689                    "STRING" :     128,
   694                    "INT" :        2,
   690                    "INT" :        2,
  1710             #data_log.append((debug_tick, value))
  1706             #data_log.append((debug_tick, value))
  1711             for weakcallable,(args,kwargs) in WeakCallableDict.iteritems():
  1707             for weakcallable,(args,kwargs) in WeakCallableDict.iteritems():
  1712                 #print weakcallable, value, args, kwargs
  1708                 #print weakcallable, value, args, kwargs
  1713                 function = getattr(weakcallable, function_name, None)
  1709                 function = getattr(weakcallable, function_name, None)
  1714                 if function is not None:
  1710                 if function is not None:
  1715                     if status == "Forced":
  1711                     if status == "Forced" and cargs[1] == fvalue:
  1716                         function(*(cargs + (True,) + args), **kwargs)
  1712                         function(*(cargs + (True,) + args), **kwargs)
  1717                     else:
  1713                     else:
  1718                         function(*(cargs + args), **kwargs)
  1714                         function(*(cargs + args), **kwargs)
  1719                 # This will block thread if more than one call is waiting
  1715                 # This will block thread if more than one call is waiting
  1720 
  1716 
  1801        
  1797        
  1802     def _Stop(self):
  1798     def _Stop(self):
  1803         """
  1799         """
  1804         Stop PLC
  1800         Stop PLC
  1805         """
  1801         """
       
  1802         if self._connector is not None and not self._connector.StopPLC():
       
  1803             self.logger.write_error(_("Couldn't stop PLC !\n"))
       
  1804 
  1806         if self.DebugThread is not None:
  1805         if self.DebugThread is not None:
  1807             self.logger.write(_("Stopping debug\n"))
  1806             self.logger.write(_("Stopping debug\n"))
  1808             self.KillDebugThread()
  1807             self.KillDebugThread()
  1809         
  1808         
  1810         if self._connector is not None and not self._connector.StopPLC():
       
  1811             self.logger.write_error(_("Couldn't stop PLC !\n"))
       
  1812         self.UpdateMethodsFromPLCStatus()
  1809         self.UpdateMethodsFromPLCStatus()
  1813 
  1810 
  1814     def _Connect(self):
  1811     def _Connect(self):
  1815         # don't accept re-connetion is already connected
  1812         # don't accept re-connetion is already connected
  1816         if self._connector is not None:
  1813         if self._connector is not None: