plugger.py
changeset 669 472469f4d5ad
parent 661 5d3da49e8029
child 670 fb03cb6da95c
equal deleted inserted replaced
668:048f5a923c86 669:472469f4d5ad
   301             LDFLAGS += _LDFLAGS
   301             LDFLAGS += _LDFLAGS
   302             extra_files += _extra_files
   302             extra_files += _extra_files
   303         
   303         
   304         return LocationCFilesAndCFLAGS, LDFLAGS, extra_files
   304         return LocationCFilesAndCFLAGS, LDFLAGS, extra_files
   305 
   305 
   306     def BlockTypesFactory(self):
   306     def PluginTypesFactory(self):
   307         if self.LibraryControler is not None:
   307         if self.LibraryControler is not None:
   308             return [{"name" : _("%s POUs") % self.PlugType, "list": self.LibraryControler.Project.GetCustomBlockTypes()}]
   308             return [{"name" : self.PlugType, "types": self.LibraryControler.Project}]
   309         return []
   309         return []
   310 
   310 
   311     def ParentsBlockTypesFactory(self):
   311     def ParentsTypesFactory(self):
   312         return self.PlugParent.ParentsBlockTypesFactory() + self.BlockTypesFactory()
   312         return self.PlugParent.ParentsTypesFactory() + self.PluginTypesFactory()
   313 
   313 
   314     def PluginsBlockTypesFactory(self):
   314     def PluginsTypesFactory(self):
   315         list = self.BlockTypesFactory()
   315         list = self.PluginTypesFactory()
   316         for PlugChild in self.IterChilds():
   316         for PlugChild in self.IterChilds():
   317             list += PlugChild.PluginsBlockTypesFactory()
   317             list += PlugChild.PluginsTypesFactory()
   318         return list
   318         return list
   319 
   319 
   320     def STLibraryFactory(self):
   320     def STLibraryFactory(self):
   321         if self.LibraryControler is not None:
   321         if self.LibraryControler is not None:
   322             program, errors, warnings = self.LibraryControler.GenerateProgram()
   322             program, errors, warnings = self.LibraryControler.GenerateProgram()
   623         library_path = self.PluginLibraryFilePath()
   623         library_path = self.PluginLibraryFilePath()
   624         if os.path.isfile(library_path):
   624         if os.path.isfile(library_path):
   625             self.LibraryControler = PLCControler()
   625             self.LibraryControler = PLCControler()
   626             self.LibraryControler.OpenXMLFile(library_path)
   626             self.LibraryControler.OpenXMLFile(library_path)
   627             self.LibraryControler.ClearPluginTypes()
   627             self.LibraryControler.ClearPluginTypes()
   628             self.LibraryControler.AddPluginBlockList(self.ParentsBlockTypesFactory())
   628             self.LibraryControler.AddPluginTypesList(self.ParentsTypesFactory())
   629 
   629 
   630     def LoadXMLParams(self, PlugName = None):
   630     def LoadXMLParams(self, PlugName = None):
   631         methode_name = os.path.join(self.PlugPath(PlugName), "methods.py")
   631         methode_name = os.path.join(self.PlugPath(PlugName), "methods.py")
   632         if os.path.isfile(methode_name):
   632         if os.path.isfile(methode_name):
   633             execfile(methode_name)
   633             execfile(methode_name)
  1015     
  1015     
  1016     # Update PLCOpenEditor Plugin Block types from loaded plugins
  1016     # Update PLCOpenEditor Plugin Block types from loaded plugins
  1017     def RefreshPluginsBlockLists(self):
  1017     def RefreshPluginsBlockLists(self):
  1018         if getattr(self, "PluggedChilds", None) is not None:
  1018         if getattr(self, "PluggedChilds", None) is not None:
  1019             self.ClearPluginTypes()
  1019             self.ClearPluginTypes()
  1020             self.AddPluginBlockList(self.PluginsBlockTypesFactory())
  1020             self.AddPluginTypesList(self.PluginsTypesFactory())
  1021         if self.AppFrame is not None:
  1021         if self.AppFrame is not None:
  1022             self.AppFrame.RefreshLibraryTree()
  1022             self.AppFrame.RefreshLibraryTree()
  1023             self.AppFrame.RefreshEditor()
  1023             self.AppFrame.RefreshEditor()
  1024     
  1024     
  1025     # Update a PLCOpenEditor Pou variable location
  1025     # Update a PLCOpenEditor Pou variable location
  1054         return self.ProjectPath
  1054         return self.ProjectPath
  1055     
  1055     
  1056     def PluginXmlFilePath(self, PlugName=None):
  1056     def PluginXmlFilePath(self, PlugName=None):
  1057         return os.path.join(self.PlugPath(PlugName), "beremiz.xml")
  1057         return os.path.join(self.PlugPath(PlugName), "beremiz.xml")
  1058 
  1058 
  1059     def ParentsBlockTypesFactory(self):
  1059     def ParentsTypesFactory(self):
  1060         return self.BlockTypesFactory()
  1060         return self.PluginTypesFactory()
  1061 
  1061 
  1062     def _setBuildPath(self, buildpath):
  1062     def _setBuildPath(self, buildpath):
  1063         if CheckPathPerm(buildpath):
  1063         if CheckPathPerm(buildpath):
  1064             self.BuildPath = buildpath
  1064             self.BuildPath = buildpath
  1065         else:
  1065         else: