54 def PlugGenerate_C(self, buildpath, current_location, locations, logger): |
54 def PlugGenerate_C(self, buildpath, current_location, locations, logger): |
55 """ |
55 """ |
56 Generate C code |
56 Generate C code |
57 @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5) |
57 @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5) |
58 @param locations: List of complete variables locations \ |
58 @param locations: List of complete variables locations \ |
59 [(IEC_loc, IEC_Direction IEC_Type, Name)]\ |
59 [{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...) |
60 ex: [((0,0,4,5),'I','X','__IX_0_0_4_5'),...] |
60 "NAME" : name of the variable (generally "__IW0_1_2" style) |
|
61 "DIR" : direction "Q","I" or "M" |
|
62 "SIZE" : size "X", "B", "W", "D", "L" |
|
63 "LOC" : tuple of interger for IEC location (0,1,2,...) |
|
64 }, ...] |
|
65 @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
61 """ |
66 """ |
|
67 # define a unique name for the generated C file |
62 prefix = "_".join(map(lambda x:str(x), current_location)) |
68 prefix = "_".join(map(lambda x:str(x), current_location)) |
63 Gen_OD_path = os.path.join(buildpath, prefix + "_OD.c" ) |
69 Gen_OD_path = os.path.join(buildpath, prefix + "_OD.c" ) |
|
70 # Create a new copy of the model with DCF loaded with PDO mappings for desired location |
64 master = config_utils.GenerateConciseDCF(locations, current_location, self) |
71 master = config_utils.GenerateConciseDCF(locations, current_location, self) |
65 res = gen_cfile.GenerateFile(Gen_OD_path, master) |
72 res = gen_cfile.GenerateFile(Gen_OD_path, master) |
66 if res : |
73 if res : |
67 raise Exception, res |
74 raise Exception, res |
68 |
75 |
80 """ |
87 """ |
81 |
88 |
82 PlugChildsTypes = [("CanOpenNode",_NodeListPlug)] |
89 PlugChildsTypes = [("CanOpenNode",_NodeListPlug)] |
83 |
90 |
84 def PlugGenerate_C(self, buildpath, current_location, locations): |
91 def PlugGenerate_C(self, buildpath, current_location, locations): |
85 """ |
|
86 Generate C code |
|
87 @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5) |
|
88 @param locations: List of complete variables locations \ |
|
89 [(IEC_loc, IEC_Direction IEC_Type, Name)]\ |
|
90 ex: [((0,0,4,5),'I','X','__IX_0_0_4_5'),...] |
|
91 """ |
|
92 prefix = "_".join(map(lambda x:str(x), current_location)) |
|
93 Gen_OD_path = os.path.join(buildpath, prefix + "_OD.c" ) |
|
94 master = config_utils.GenerateConciseDCF(locations, self) |
|
95 res = gen_cfile.GenerateFile(Gen_OD_path, master) |
|
96 if not res: |
|
97 s = str(self.BaseParams.BusId)+"_IN(){}\n" |
|
98 s += "CanOpen(str(\""+self.CanFestivalNode.CAN_Device+"\")" |
|
99 f = file(filepath, 'a') |
|
100 f.write(s) |
|
101 else: |
|
102 pass # error |
|
103 |
|
104 return [],"" |
92 return [],"" |
105 |
93 |
106 |
94 |