ProjectController.py
changeset 1072 83b0815b8812
parent 1064 44318b45aab9
child 1080 5ec20f56b1d2
equal deleted inserted replaced
1071:5e740fe71fbe 1072:83b0815b8812
   801         """
   801         """
   802         # filter location that are related to code that will be called
   802         # filter location that are related to code that will be called
   803         # in retreive, publish, init, cleanup
   803         # in retreive, publish, init, cleanup
   804         locstrs = map(lambda x:"_".join(map(str,x)),
   804         locstrs = map(lambda x:"_".join(map(str,x)),
   805            [loc for loc,Cfiles,DoCalls in self.LocationCFilesAndCFLAGS if loc and DoCalls])
   805            [loc for loc,Cfiles,DoCalls in self.LocationCFilesAndCFLAGS if loc and DoCalls])
   806 
   806         
   807         # Generate main, based on template
   807         # Generate main, based on template
   808         if not self.BeremizRoot.getDisable_Extensions():
   808         if not self.BeremizRoot.getDisable_Extensions():
   809             plc_main_code = targets.GetCode("plc_main_head") % {
   809             plc_main_code = targets.GetCode("plc_main_head") % {
   810                 "calls_prototypes":"\n".join([(
   810                 "calls_prototypes":"\n".join([(
   811                       "int __init_%(s)s(int argc,char **argv);\n"+
   811                       "int __init_%(s)s(int argc,char **argv);\n"+
   812                       "void __cleanup_%(s)s(void);\n"+
   812                       "void __cleanup_%(s)s(void);\n"+
   813                       "void __retrieve_%(s)s(void);\n"+
   813                       "void __retrieve_%(s)s(void);\n"+
   814                       "void __publish_%(s)s(void);")%{'s':locstr} for locstr in locstrs]),
   814                       "void __publish_%(s)s(void);")%{'s':locstr} for locstr in locstrs]),
   815                 "retrieve_calls":"\n    ".join([
   815                 "retrieve_calls":"\n    ".join([
   816                       "__retrieve_%s();"%locstrs[i-1] for i in xrange(len(locstrs), 0, -1)]),
   816                       "__retrieve_%s();"%locstr for locstr in locstrs]),
   817                 "publish_calls":"\n    ".join([ #Call publish in reverse order
   817                 "publish_calls":"\n    ".join([ #Call publish in reverse order
   818                       "__publish_%s();"%locstr for locstr in locstrs]),
   818                       "__publish_%s();"%locstrs[i-1] for i in xrange(len(locstrs), 0, -1)]),
   819                 "init_calls":"\n    ".join([
   819                 "init_calls":"\n    ".join([
   820                       "init_level=%d; "%(i+1)+
   820                       "init_level=%d; "%(i+1)+
   821                       "if((res = __init_%s(argc,argv))){"%locstr +
   821                       "if((res = __init_%s(argc,argv))){"%locstr +
   822                       #"printf(\"%s\"); "%locstr + #for debug
   822                       #"printf(\"%s\"); "%locstr + #for debug
   823                       "return res;}" for i,locstr in enumerate(locstrs)]),
   823                       "return res;}" for i,locstr in enumerate(locstrs)]),