97 return os.path.join(self.CTNPath(CTNName), "confnode.xml") |
97 return os.path.join(self.CTNPath(CTNName), "confnode.xml") |
98 |
98 |
99 def ConfNodePath(self): |
99 def ConfNodePath(self): |
100 return os.path.join(self.CTNParent.ConfNodePath(), self.CTNType) |
100 return os.path.join(self.CTNParent.ConfNodePath(), self.CTNType) |
101 |
101 |
102 def CTNPath(self,CTNName=None,project_path=None): |
102 def CTNPath(self, CTNName=None, project_path=None): |
103 if not CTNName: |
103 if not CTNName: |
104 CTNName = self.CTNName() |
104 CTNName = self.CTNName() |
105 if not project_path: |
105 if not project_path: |
106 project_path = self.CTNParent.CTNPath() |
106 project_path = self.CTNParent.CTNPath() |
107 return os.path.join(project_path, |
107 return os.path.join(project_path, |
193 # Create it |
193 # Create it |
194 os.mkdir(ctnpath) |
194 os.mkdir(ctnpath) |
195 |
195 |
196 # generate XML for base XML parameters controller of the confnode |
196 # generate XML for base XML parameters controller of the confnode |
197 if self.MandatoryParams: |
197 if self.MandatoryParams: |
198 BaseXMLFile = open(self.ConfNodeBaseXmlFilePath(),'w') |
198 BaseXMLFile = open(self.ConfNodeBaseXmlFilePath(), 'w') |
199 BaseXMLFile.write(etree.tostring( |
199 BaseXMLFile.write(etree.tostring( |
200 self.MandatoryParams[1], |
200 self.MandatoryParams[1], |
201 pretty_print=True, |
201 pretty_print=True, |
202 xml_declaration=True, |
202 xml_declaration=True, |
203 encoding='utf-8')) |
203 encoding='utf-8')) |
204 BaseXMLFile.close() |
204 BaseXMLFile.close() |
205 |
205 |
206 # generate XML for XML parameters controller of the confnode |
206 # generate XML for XML parameters controller of the confnode |
207 if self.CTNParams: |
207 if self.CTNParams: |
208 XMLFile = open(self.ConfNodeXmlFilePath(),'w') |
208 XMLFile = open(self.ConfNodeXmlFilePath(), 'w') |
209 XMLFile.write(etree.tostring( |
209 XMLFile.write(etree.tostring( |
210 self.CTNParams[1], |
210 self.CTNParams[1], |
211 pretty_print=True, |
211 pretty_print=True, |
212 xml_declaration=True, |
212 xml_declaration=True, |
213 encoding='utf-8')) |
213 encoding='utf-8')) |
256 "SIZE" : size "X", "B", "W", "D", "L" |
256 "SIZE" : size "X", "B", "W", "D", "L" |
257 "LOC" : tuple of interger for IEC location (0,1,2,...) |
257 "LOC" : tuple of interger for IEC location (0,1,2,...) |
258 }, ...] |
258 }, ...] |
259 @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
259 @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
260 """ |
260 """ |
261 self.GetCTRoot().logger.write_warning(".".join(map(lambda x:str(x), self.GetCurrentLocation())) + " -> Nothing to do\n") |
261 self.GetCTRoot().logger.write_warning(".".join(map(lambda x: str(x), self.GetCurrentLocation())) + " -> Nothing to do\n") |
262 return [],"",False |
262 return [], "", False |
263 |
263 |
264 def _Generate_C(self, buildpath, locations): |
264 def _Generate_C(self, buildpath, locations): |
265 # Generate confnodes [(Cfiles, CFLAGS)], LDFLAGS, DoCalls, extra_files |
265 # Generate confnodes [(Cfiles, CFLAGS)], LDFLAGS, DoCalls, extra_files |
266 # extra_files = [(fname,fobject), ...] |
266 # extra_files = [(fname,fobject), ...] |
267 gen_result = self.CTNGenerate_C(buildpath, locations) |
267 gen_result = self.CTNGenerate_C(buildpath, locations) |
307 for CTNInstance in Children: |
307 for CTNInstance in Children: |
308 yield CTNInstance |
308 yield CTNInstance |
309 |
309 |
310 def IECSortedChildren(self): |
310 def IECSortedChildren(self): |
311 # reorder children by IEC_channels |
311 # reorder children by IEC_channels |
312 ordered = [(chld.BaseParams.getIEC_Channel(),chld) for chld in self.IterChildren()] |
312 ordered = [(chld.BaseParams.getIEC_Channel(), chld) for chld in self.IterChildren()] |
313 if ordered: |
313 if ordered: |
314 ordered.sort() |
314 ordered.sort() |
315 return zip(*ordered)[1] |
315 return zip(*ordered)[1] |
316 else: |
316 else: |
317 return [] |
317 return [] |
522 @param CTNName: string for the name of the confnode instance |
522 @param CTNName: string for the name of the confnode instance |
523 """ |
523 """ |
524 # reorganize self.CTNChildrenTypes tuples from (name, CTNClass, Help) |
524 # reorganize self.CTNChildrenTypes tuples from (name, CTNClass, Help) |
525 # to ( name, (CTNClass, Help)), an make a dict |
525 # to ( name, (CTNClass, Help)), an make a dict |
526 transpose = zip(*self.CTNChildrenTypes) |
526 transpose = zip(*self.CTNChildrenTypes) |
527 CTNChildrenTypes = dict(zip(transpose[0],zip(transpose[1],transpose[2]))) |
527 CTNChildrenTypes = dict(zip(transpose[0], zip(transpose[1], transpose[2]))) |
528 # Check that adding this confnode is allowed |
528 # Check that adding this confnode is allowed |
529 try: |
529 try: |
530 CTNClass, CTNHelp = CTNChildrenTypes[CTNType] |
530 CTNClass, CTNHelp = CTNChildrenTypes[CTNType] |
531 except KeyError: |
531 except KeyError: |
532 raise Exception, _("Cannot create child {a1} of type {a2} ").format(a1 = CTNName, a2 = CTNType) |
532 raise Exception, _("Cannot create child {a1} of type {a2} ").format(a1 = CTNName, a2 = CTNType) |