161 typeinfos = GetValidTypeInfos(typename) |
161 typeinfos = GetValidTypeInfos(typename) |
162 texts["subIndexType"] = typeinfos[0] |
162 texts["subIndexType"] = typeinfos[0] |
163 texts["suffixe"] = typeinfos[1] |
163 texts["suffixe"] = typeinfos[1] |
164 if typeinfos[2] == "visible_string": |
164 if typeinfos[2] == "visible_string": |
165 texts["value"] = "\"%s\""%values |
165 texts["value"] = "\"%s\""%values |
|
166 texts["comment"] = "" |
|
167 elif typeinfos[2] == "domain": |
|
168 texts["value"] = "\"%s\""%''.join(["\\x%2.2x"%ord(char) for char in value]) |
166 texts["comment"] = "" |
169 texts["comment"] = "" |
167 else: |
170 else: |
168 texts["value"] = "0x%X"%values |
171 texts["value"] = "0x%X"%values |
169 texts["comment"] = "\t/* %s */"%str(values) |
172 texts["comment"] = "\t/* %s */"%str(values) |
170 if index in variablelist: |
173 if index in variablelist: |
204 if subIndex > 0: |
207 if subIndex > 0: |
205 if subIndex == len(values)-1: |
208 if subIndex == len(values)-1: |
206 sep = "" |
209 sep = "" |
207 if typeinfos[2] == "visible_string": |
210 if typeinfos[2] == "visible_string": |
208 value = "\"%s\""%value |
211 value = "\"%s\""%value |
209 else: |
212 elif typeinfos[2] == "domain": |
|
213 value = "\"%s\""%''.join(["\\x%2.2x"%ord(char) for char in value]) |
|
214 else: |
210 comment = "\t/* %s */"%str(value) |
215 comment = "\t/* %s */"%str(value) |
211 value = "0x%X"%value |
216 value = "0x%X"%value |
212 mappedVariableContent += " %s%s%s\n"%(value, sep, comment) |
217 mappedVariableContent += " %s%s%s\n"%(value, sep, comment) |
213 mappedVariableContent += " };\n" |
218 mappedVariableContent += " };\n" |
214 else: |
219 else: |
241 texts["subIndexType"] = typeinfos[0] |
246 texts["subIndexType"] = typeinfos[0] |
242 texts["suffixe"] = typeinfos[1] |
247 texts["suffixe"] = typeinfos[1] |
243 if typeinfos[2] == "visible_string": |
248 if typeinfos[2] == "visible_string": |
244 texts["value"] = "\"%s\""%value |
249 texts["value"] = "\"%s\""%value |
245 texts["comment"] = "" |
250 texts["comment"] = "" |
246 else: |
251 elif typeinfos[2] == "domain": |
|
252 texts["value"] = "\"%s\""%''.join(["\\x%2.2x"%ord(char) for char in value]) |
|
253 texts["comment"] = "" |
|
254 else: |
247 texts["value"] = "0x%X"%value |
255 texts["value"] = "0x%X"%value |
248 texts["comment"] = "\t/* %s */"%str(value) |
256 texts["comment"] = "\t/* %s */"%str(value) |
249 texts["name"] = FormatName(subentry_infos["name"]) |
257 texts["name"] = FormatName(subentry_infos["name"]) |
250 if index in variablelist: |
258 if index in variablelist: |
251 strDeclareHeader += "extern %(subIndexType)s %(parent)s_%(name)s%(suffixe)s;\t\t/* Mapped at index 0x%(index)04X, subindex 0x%(subIndex)02X */\n"%texts |
259 strDeclareHeader += "extern %(subIndexType)s %(parent)s_%(name)s%(suffixe)s;\t\t/* Mapped at index 0x%(index)04X, subindex 0x%(subIndex)02X */\n"%texts |
461 |
469 |
462 #------------------------------------------------------------------------------- |
470 #------------------------------------------------------------------------------- |
463 # Write Header File Content |
471 # Write Header File Content |
464 #------------------------------------------------------------------------------- |
472 #------------------------------------------------------------------------------- |
465 |
473 |
|
474 texts["file_include_name"] = headerfilepath.replace(".", "_").upper() |
466 HeaderFileContent = generated_tag + """ |
475 HeaderFileContent = generated_tag + """ |
|
476 #ifdef %(file_include_name)s |
|
477 #define %(file_include_name)s |
|
478 |
467 #include "data.h" |
479 #include "data.h" |
468 |
480 |
469 /* Prototypes of function provided by object dictionnary */ |
481 /* Prototypes of function provided by object dictionnary */ |
470 UNS32 %(NodeName)s_valueRangeTest (UNS8 typeValue, void * value); |
482 UNS32 %(NodeName)s_valueRangeTest (UNS8 typeValue, void * value); |
471 const indextable * %(NodeName)s_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks); |
483 const indextable * %(NodeName)s_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks); |
472 |
484 |
473 /* Master node data struct */ |
485 /* Master node data struct */ |
474 extern CO_Data %(NodeName)s_Data; |
486 extern CO_Data %(NodeName)s_Data; |
475 |
|
476 """%texts |
487 """%texts |
477 HeaderFileContent += strDeclareHeader |
488 HeaderFileContent += strDeclareHeader |
|
489 |
|
490 HeaderFileContent += "\n#endif // %(file_include_name)s\n"%texts |
478 |
491 |
479 return fileContent,HeaderFileContent |
492 return fileContent,HeaderFileContent |
480 |
493 |
481 #------------------------------------------------------------------------------- |
494 #------------------------------------------------------------------------------- |
482 # Main Function |
495 # Main Function |