54 text = "/* Code generated by Beremiz c_ext confnode */\n\n" |
51 text = "/* Code generated by Beremiz c_ext confnode */\n\n" |
55 text += "#include <stdio.h>\n\n" |
52 text += "#include <stdio.h>\n\n" |
56 |
53 |
57 # Adding includes |
54 # Adding includes |
58 text += "/* User includes */\n" |
55 text += "/* User includes */\n" |
59 text += self.CodeFile.includes.gettext().strip() |
56 text += self.CodeFile.includes.getanyText().strip() |
60 text += "\n" |
57 text += "\n" |
61 |
58 |
62 text += '#include "iec_types_all.h"\n\n' |
59 text += '#include "iec_types_all.h"\n\n' |
63 |
60 |
64 # Adding variables |
61 # Adding variables |
74 text += "#define %(name)s %(global)s.value\n" % var_infos |
71 text += "#define %(name)s %(global)s.value\n" % var_infos |
75 text += "\n" |
72 text += "\n" |
76 |
73 |
77 # Adding user global variables and routines |
74 # Adding user global variables and routines |
78 text += "/* User internal user variables and routines */\n" |
75 text += "/* User internal user variables and routines */\n" |
79 text += self.CodeFile.globals.gettext().strip() |
76 text += self.CodeFile.globals.getanyText().strip() |
80 text += "\n" |
77 text += "\n" |
81 |
78 |
82 # Adding Beremiz confnode functions |
79 # Adding Beremiz confnode functions |
83 text += "/* Beremiz confnode functions */\n" |
80 text += "/* Beremiz confnode functions */\n" |
84 text += "int __init_%s(int argc,char **argv)\n{\n"%location_str |
81 text += "int __init_%s(int argc,char **argv)\n{\n"%location_str |
85 text += self.CodeFile.initFunction.gettext().strip() |
82 text += self.CodeFile.initFunction.getanyText().strip() |
86 text += " return 0;\n}\n\n" |
83 text += " return 0;\n}\n\n" |
87 |
84 |
88 text += "void __cleanup_%s(void)\n{\n"%location_str |
85 text += "void __cleanup_%s(void)\n{\n"%location_str |
89 text += self.CodeFile.cleanUpFunction.gettext().strip() |
86 text += self.CodeFile.cleanUpFunction.getanyText().strip() |
90 text += "\n}\n\n" |
87 text += "\n}\n\n" |
91 |
88 |
92 text += "void __retrieve_%s(void)\n{\n"%location_str |
89 text += "void __retrieve_%s(void)\n{\n"%location_str |
93 text += self.CodeFile.retrieveFunction.gettext().strip() |
90 text += self.CodeFile.retrieveFunction.getanyText().strip() |
94 text += "\n}\n\n" |
91 text += "\n}\n\n" |
95 |
92 |
96 text += "void __publish_%s(void)\n{\n"%location_str |
93 text += "void __publish_%s(void)\n{\n"%location_str |
97 text += self.CodeFile.publishFunction.gettext().strip() |
94 text += self.CodeFile.publishFunction.getanyText().strip() |
98 text += "\n}\n\n" |
95 text += "\n}\n\n" |
99 |
96 |
100 Gen_Cfile_path = os.path.join(buildpath, "CFile_%s.c"%location_str) |
97 Gen_Cfile_path = os.path.join(buildpath, "CFile_%s.c"%location_str) |
101 cfile = open(Gen_Cfile_path,'w') |
98 cfile = open(Gen_Cfile_path,'w') |
102 cfile.write(text) |
99 cfile.write(text) |