80 current_location = self.GetCurrentLocation() |
80 current_location = self.GetCurrentLocation() |
81 # define a unique name for the generated C file |
81 # define a unique name for the generated C file |
82 prefix = "_".join(map(lambda x:str(x), current_location)) |
82 prefix = "_".join(map(lambda x:str(x), current_location)) |
83 Gen_OD_path = os.path.join(buildpath, "OD_%s.c"%prefix ) |
83 Gen_OD_path = os.path.join(buildpath, "OD_%s.c"%prefix ) |
84 # Create a new copy of the model with DCF loaded with PDO mappings for desired location |
84 # Create a new copy of the model with DCF loaded with PDO mappings for desired location |
85 master = config_utils.GenerateConciseDCF(locations, current_location, self, self.CanFestivalNode.getSync_TPDOs()) |
85 master = config_utils.GenerateConciseDCF(locations, current_location, self, self.CanFestivalNode.getSync_TPDOs(),"OD_%s"%prefix) |
86 master.SetNodeName("OD_%s"%prefix) |
|
87 res = gen_cfile.GenerateFile(Gen_OD_path, master) |
86 res = gen_cfile.GenerateFile(Gen_OD_path, master) |
88 if res : |
87 if res : |
89 raise Exception, res |
88 raise Exception, res |
90 |
89 |
91 return [(Gen_OD_path,canfestival_config.getCFLAGS(CanFestivalPath))],"",False |
90 return [(Gen_OD_path,canfestival_config.getCFLAGS(CanFestivalPath))],"",False |
109 "candriver" : self.CanFestivalInstance.getCAN_Driver(), |
108 "candriver" : self.CanFestivalInstance.getCAN_Driver(), |
110 "nodes_includes" : "", |
109 "nodes_includes" : "", |
111 "board_decls" : "", |
110 "board_decls" : "", |
112 "nodes_init" : "", |
111 "nodes_init" : "", |
113 "nodes_open" : "", |
112 "nodes_open" : "", |
114 "nodes_close" : ""} |
113 "nodes_close" : "", |
|
114 "nodes_send_sync" : "", |
|
115 "nodes_proceed_sync" : ""} |
115 for child in self.IECSortedChilds(): |
116 for child in self.IECSortedChilds(): |
116 childlocstr = "_".join(map(str,child.GetCurrentLocation())) |
117 childlocstr = "_".join(map(str,child.GetCurrentLocation())) |
117 nodename = "OD_%s" % childlocstr |
118 nodename = "OD_%s" % childlocstr |
118 |
119 |
119 format_dict["nodes_includes"] += '#include "%s.h"\n'%(nodename) |
120 format_dict["nodes_includes"] += '#include "%s.h"\n'%(nodename) |
120 format_dict["board_decls"] += 'BOARD_DECL(%s, "%s", "%s")\n'%( |
121 format_dict["board_decls"] += 'BOARD_DECL(%s, "%s", "%s")\n'%( |
121 nodename, |
122 nodename, |
122 child.CanFestivalNode.getCAN_Device(), |
123 child.CanFestivalNode.getCAN_Device(), |
123 child.CanFestivalNode.getCAN_Baudrate()) |
124 child.CanFestivalNode.getCAN_Baudrate()) |
124 format_dict["nodes_init"] += 'NODE_INIT(%s, %s)\n'%( |
125 format_dict["nodes_init"] += 'NODE_INIT(%s, %s)\n '%( |
125 nodename, |
126 nodename, |
126 child.CanFestivalNode.getNodeId()) |
127 child.CanFestivalNode.getNodeId()) |
127 format_dict["nodes_open"] += 'NODE_OPEN(%s)\n'%(nodename) |
128 format_dict["nodes_open"] += 'NODE_OPEN(%s)\n '%(nodename) |
128 format_dict["nodes_close"] += 'NODE_CLOSE(%s)\n'%(nodename) |
129 format_dict["nodes_close"] += 'NODE_CLOSE(%s)\n '%(nodename) |
|
130 format_dict["nodes_send_sync"] += 'NODE_SEND_SYNC(%s)\n '%(nodename) |
|
131 format_dict["nodes_proceed_sync"] += 'NODE_PROCEED_SYNC(%s)\n '%(nodename) |
129 filename = os.path.join(os.path.split(__file__)[0],"cf_runtime.c") |
132 filename = os.path.join(os.path.split(__file__)[0],"cf_runtime.c") |
130 cf_main = open(filename).read() % format_dict |
133 cf_main = open(filename).read() % format_dict |
131 cf_main_path = os.path.join(buildpath, "CF_%(locstr)s.c"%format_dict) |
134 cf_main_path = os.path.join(buildpath, "CF_%(locstr)s.c"%format_dict) |
132 f = open(cf_main_path,'w') |
135 f = open(cf_main_path,'w') |
133 f.write(cf_main) |
136 f.write(cf_main) |