ConfigTreeNode.py
changeset 728 e0424e96e3fd
parent 725 31dade089db5
child 734 5c42cafaee15
equal deleted inserted replaced
727:3edd2f19bce2 728:e0424e96e3fd
    59         self._AddParamsMembers()
    59         self._AddParamsMembers()
    60         self.Children = {}
    60         self.Children = {}
    61         self._View = None
    61         self._View = None
    62         # copy ConfNodeMethods so that it can be later customized
    62         # copy ConfNodeMethods so that it can be later customized
    63         self.ConfNodeMethods = [dic.copy() for dic in self.ConfNodeMethods]
    63         self.ConfNodeMethods = [dic.copy() for dic in self.ConfNodeMethods]
    64         self.LoadSTLibrary()
       
    65         
    64         
    66     def ConfNodeBaseXmlFilePath(self, CTNName=None):
    65     def ConfNodeBaseXmlFilePath(self, CTNName=None):
    67         return os.path.join(self.CTNPath(CTNName), "baseconfnode.xml")
    66         return os.path.join(self.CTNPath(CTNName), "baseconfnode.xml")
    68     
    67     
    69     def ConfNodeXmlFilePath(self, CTNName=None):
    68     def ConfNodeXmlFilePath(self, CTNName=None):
    70         return os.path.join(self.CTNPath(CTNName), "confnode.xml")
    69         return os.path.join(self.CTNPath(CTNName), "confnode.xml")
    71 
       
    72     def ConfNodeLibraryFilePath(self):
       
    73         return os.path.join(self.ConfNodePath(), "pous.xml")
       
    74 
    70 
    75     def ConfNodePath(self):
    71     def ConfNodePath(self):
    76         return os.path.join(self.CTNParent.ConfNodePath(), self.CTNType)
    72         return os.path.join(self.CTNParent.ConfNodePath(), self.CTNType)
    77 
    73 
    78     def CTNPath(self,CTNName=None):
    74     def CTNPath(self,CTNName=None):
   250             LDFLAGS += _LDFLAGS
   246             LDFLAGS += _LDFLAGS
   251             extra_files += _extra_files
   247             extra_files += _extra_files
   252         
   248         
   253         return LocationCFilesAndCFLAGS, LDFLAGS, extra_files
   249         return LocationCFilesAndCFLAGS, LDFLAGS, extra_files
   254 
   250 
   255     def ConfNodeTypesFactory(self):
       
   256         if self.LibraryControler is not None:
       
   257             return [{"name" : self.CTNType, "types": self.LibraryControler.Project}]
       
   258         return []
       
   259 
       
   260     def ParentsTypesFactory(self):
       
   261         return self.CTNParent.ParentsTypesFactory() + self.ConfNodeTypesFactory()
       
   262 
       
   263     def ConfNodesTypesFactory(self):
       
   264         list = self.ConfNodeTypesFactory()
       
   265         for CTNChild in self.IterChildren():
       
   266             list += CTNChild.ConfNodesTypesFactory()
       
   267         return list
       
   268 
       
   269     def STLibraryFactory(self):
       
   270         if self.LibraryControler is not None:
       
   271             program, errors, warnings = self.LibraryControler.GenerateProgram()
       
   272             return program + "\n"
       
   273         return ""
       
   274 
       
   275     def ConfNodesSTLibraryFactory(self):
       
   276         program = self.STLibraryFactory()
       
   277         for CTNChild in self.IECSortedChildren():
       
   278             program += CTNChild.ConfNodesSTLibraryFactory()
       
   279         return program
       
   280         
       
   281     def IterChildren(self):
   251     def IterChildren(self):
   282         for CTNType, Children in self.Children.items():
   252         for CTNType, Children in self.Children.items():
   283             for CTNInstance in Children:
   253             for CTNInstance in Children:
   284                 yield CTNInstance
   254                 yield CTNInstance
   285     
   255     
   561     def ClearChildren(self):
   531     def ClearChildren(self):
   562         for child in self.IterChildren():
   532         for child in self.IterChildren():
   563             child.ClearChildren()
   533             child.ClearChildren()
   564         self.Children = {}
   534         self.Children = {}
   565     
   535     
   566     def LoadSTLibrary(self):
       
   567         # Get library blocks if plcopen library exist
       
   568         library_path = self.ConfNodeLibraryFilePath()
       
   569         if os.path.isfile(library_path):
       
   570             self.LibraryControler = PLCControler()
       
   571             self.LibraryControler.OpenXMLFile(library_path)
       
   572             self.LibraryControler.ClearConfNodeTypes()
       
   573             self.LibraryControler.AddConfNodeTypesList(self.ParentsTypesFactory())
       
   574 
       
   575     def LoadXMLParams(self, CTNName = None):
   536     def LoadXMLParams(self, CTNName = None):
   576         methode_name = os.path.join(self.CTNPath(CTNName), "methods.py")
   537         methode_name = os.path.join(self.CTNPath(CTNName), "methods.py")
   577         if os.path.isfile(methode_name):
   538         if os.path.isfile(methode_name):
   578             execfile(methode_name)
   539             execfile(methode_name)
   579         
   540