plugger.py
changeset 16 b2c02ca6271e
parent 15 7a473efc4530
child 17 ee8cb104dbe0
equal deleted inserted replaced
15:7a473efc4530 16:b2c02ca6271e
    91         """
    91         """
    92         Generate C code
    92         Generate C code
    93         @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5)
    93         @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5)
    94         @param locations: List of complete variables locations \
    94         @param locations: List of complete variables locations \
    95             [(IEC_loc, IEC_Direction IEC_Type, Name)]\
    95             [(IEC_loc, IEC_Direction IEC_Type, Name)]\
    96             ex: [((0,0,4,5),'I','X','__IX_0_0_4_5'),...]
    96             ex: [((0,0,4,5),'I','STRING','__IX_0_0_4_5'),...]
    97         """
    97         """
    98         return [],""
    98         return [],""
    99     
    99     
   100     def _Generate_C(self, buildpath, current_location, locations):
   100     def _Generate_C(self, buildpath, current_location, locations):
   101         # Generate plugins [(Cfiles, CFLAGS)], LDFLAGS
   101         # Generate plugins [(Cfiles, CFLAGS)], LDFLAGS
   102         PlugCFilesAndCFLAGS, PlugLDFLAGS = self._Generate_C(buildpath, current_location, locations)
   102         PlugCFilesAndCFLAGS, PlugLDFLAGS = self.PlugGenerate_C(buildpath, current_location, locations)
   103         # recurse through all childs, and stack their results
   103         # recurse through all childs, and stack their results
   104         for PlugChild in self.IterChilds():
   104         for PlugChild in self.IterChilds():
       
   105             # Compute chile IEC location
       
   106             new_location = current_location + (self.BaseParams.getIEC_Channel())
   105             # Get childs [(Cfiles, CFLAGS)], LDFLAGS
   107             # Get childs [(Cfiles, CFLAGS)], LDFLAGS
   106             CFilesAndCFLAGS, LDFLAGS = \
   108             CFilesAndCFLAGS, LDFLAGS = \
   107                 PlugChild._Generate_C(
   109                 PlugChild._Generate_C(
   108                     #keep the same path
   110                     #keep the same path
   109                     buildpath,
   111                     buildpath,
   110                     # but update location (add curent IEC channel at the end)
   112                     # but update location (add curent IEC channel at the end)
   111                     current_location + (self.BaseParams.getIEC_Channel()),
   113                     new_location,
   112                     # filter locations that start with current IEC location
   114                     # filter locations that start with current IEC location
   113                     [ (l,d,t,n) for l,d,t,n in locations if l[0:len(current_location)] == current_location ])
   115                     [ (l,d,t,n) for l,d,t,n in locations if l[0:len(new_location)] == new_location ])
   114             # stack the result
   116             # stack the result
   115             PlugCFilesAndCFLAGS += CFilesAndCFLAGS
   117             PlugCFilesAndCFLAGS += CFilesAndCFLAGS
   116             PlugLDFLAGS += LDFLAGS
   118             PlugLDFLAGS += LDFLAGS
   117         
   119         
   118         return PlugCFilesAndCFLAGS,PlugLDFLAGS
   120         return PlugCFilesAndCFLAGS,PlugLDFLAGS
   288                 try:
   290                 try:
   289                     self.PlugAddChild(*PlugDir.split[NameTypeSeparator])
   291                     self.PlugAddChild(*PlugDir.split[NameTypeSeparator])
   290                 except Exception, e:
   292                 except Exception, e:
   291                     print e
   293                     print e
   292 
   294 
   293 
       
   294 class PluginsRoot(PlugTemplate):
   295 class PluginsRoot(PlugTemplate):
   295 
   296 
   296     # For root object, available Childs Types are modules of the plugin packages.
   297     # For root object, available Childs Types are modules of the plugin packages.
   297     PlugChildsTypes = [(name,lambda : getattr(__import__("plugins." + name), name).RootClass) for name in plugins.__all__]
   298     PlugChildsTypes = [(name,lambda : getattr(__import__("plugins." + name), name).RootClass) for name in plugins.__all__]
   298 
   299 
   372     def PlugPath(self,PlugName=None):
   373     def PlugPath(self,PlugName=None):
   373         return self.ProjectPath
   374         return self.ProjectPath
   374         
   375         
   375     def PluginXmlFilePath(self, PlugName=None):
   376     def PluginXmlFilePath(self, PlugName=None):
   376         return os.path.join(self.PlugPath(PlugName), "beremiz.xml")
   377         return os.path.join(self.PlugPath(PlugName), "beremiz.xml")
   377         
   378     
   378     
   379