plugger.py
changeset 250 01963beca027
parent 248 444d4db3faea
child 253 b1a9d37bb84c
equal deleted inserted replaced
249:a770187273e9 250:01963beca027
   190             XMLFile.close()
   190             XMLFile.close()
   191         
   191         
   192         # Call the plugin specific OnPlugSave method
   192         # Call the plugin specific OnPlugSave method
   193         result = self.OnPlugSave()
   193         result = self.OnPlugSave()
   194         if not result:
   194         if not result:
   195             return "Error while saving \"%s\""%self.PlugPath()
   195             return "Error while saving \"%s\"\n"%self.PlugPath()
   196 
   196 
   197         # mark plugin as saved
   197         # mark plugin as saved
   198         self.ChangesToSave = False        
   198         self.ChangesToSave = False        
   199         # go through all childs and do the same
   199         # go through all childs and do the same
   200         for PlugChild in self.IterChilds():
   200         for PlugChild in self.IterChilds():
   270         return ""
   270         return ""
   271 
   271 
   272     def IterChilds(self):
   272     def IterChilds(self):
   273         for PlugType, PluggedChilds in self.PluggedChilds.items():
   273         for PlugType, PluggedChilds in self.PluggedChilds.items():
   274             for PlugInstance in PluggedChilds:
   274             for PlugInstance in PluggedChilds:
   275                    yield PlugInstance
   275                 yield PlugInstance
   276     
   276     
   277     def IECSortedChilds(self):
   277     def IECSortedChilds(self):
   278         # reorder childs by IEC_channels
   278         # reorder childs by IEC_channels
   279         ordered = [(chld.BaseParams.getIEC_Channel(),chld) for chld in self.IterChilds()]
   279         ordered = [(chld.BaseParams.getIEC_Channel(),chld) for chld in self.IterChilds()]
   280         if ordered:
   280         if ordered:
   787     def SaveProject(self):
   787     def SaveProject(self):
   788         if not self.SaveXMLFile():
   788         if not self.SaveXMLFile():
   789             self.SaveXMLFile(os.path.join(self.ProjectPath, 'plc.xml'))
   789             self.SaveXMLFile(os.path.join(self.ProjectPath, 'plc.xml'))
   790         if self.PLCEditor:
   790         if self.PLCEditor:
   791             self.PLCEditor.RefreshTitle()
   791             self.PLCEditor.RefreshTitle()
   792         self.PlugRequestSave()
   792         result = self.PlugRequestSave()
       
   793         if result:
       
   794             self.logger.write_error(result)
   793     
   795     
   794     # Update PLCOpenEditor Plugin Block types from loaded plugins
   796     # Update PLCOpenEditor Plugin Block types from loaded plugins
   795     def RefreshPluginsBlockLists(self):
   797     def RefreshPluginsBlockLists(self):
   796         if getattr(self, "PluggedChilds", None) is not None:
   798         if getattr(self, "PluggedChilds", None) is not None:
   797             self.ClearPluginTypes()
   799             self.ClearPluginTypes()