runtime/PLCObject.py
branchsvghmi
changeset 3282 725d3e9ac913
parent 2732 a3f0e4148714
child 3395 93ad018fb602
equal deleted inserted replaced
3281:1fc4274de64e 3282:725d3e9ac913
   111                 "r").read().strip() + lib_ext
   111                 "r").read().strip() + lib_ext
   112             self.PLCStatus = PlcStatus.Stopped
   112             self.PLCStatus = PlcStatus.Stopped
   113             if autostart:
   113             if autostart:
   114                 if self.LoadPLC():
   114                 if self.LoadPLC():
   115                     self.StartPLC()
   115                     self.StartPLC()
   116                     return
   116                 else:
       
   117                     self._fail(_("Problem autostarting PLC : can't load PLC"))
       
   118                 return
   117         except Exception:
   119         except Exception:
   118             self.PLCStatus = PlcStatus.Empty
   120             self.PLCStatus = PlcStatus.Empty
   119             self.CurrentPLCFilename = None
   121             self.CurrentPLCFilename = None
   120 
   122 
   121         self.StatusChange()
   123         self.StatusChange()
   267 
   269 
   268     @RunInMain
   270     @RunInMain
   269     def LoadPLC(self):
   271     def LoadPLC(self):
   270         res = self._LoadPLC()
   272         res = self._LoadPLC()
   271         if res:
   273         if res:
   272             self.PythonRuntimeInit()
   274             try:
       
   275                 self.PythonRuntimeInit()
       
   276             except Exception:
       
   277                 self._loading_error = traceback.format_exc()
       
   278                 PLCprint(self._loading_error)
       
   279                 return False
   273         else:
   280         else:
   274             self._FreePLC()
   281             self._FreePLC()
   275 
   282 
   276         return res
   283         return res
   277 
   284 
   678                 PLCprint(traceback.format_exc())
   685                 PLCprint(traceback.format_exc())
   679                 return False
   686                 return False
   680 
   687 
   681             if self.LoadPLC():
   688             if self.LoadPLC():
   682                 self.PLCStatus = PlcStatus.Stopped
   689                 self.PLCStatus = PlcStatus.Stopped
       
   690                 self.StatusChange()
   683             else:
   691             else:
   684                 self.PLCStatus = PlcStatus.Broken
   692                 self._fail(_("Problem installing new PLC : can't load PLC"))
   685             self.StatusChange()
       
   686 
   693 
   687             return self.PLCStatus == PlcStatus.Stopped
   694             return self.PLCStatus == PlcStatus.Stopped
   688         return False
   695         return False
   689 
   696 
   690     def MatchMD5(self, MD5):
   697     def MatchMD5(self, MD5):