140 strIndex += "\n/* index 0x%(index)04X : Mapped variable %(EntryName)s */\n"%texts |
140 strIndex += "\n/* index 0x%(index)04X : Mapped variable %(EntryName)s */\n"%texts |
141 else: |
141 else: |
142 strIndex += "\n/* index 0x%(index)04X : %(EntryName)s. */\n"%texts |
142 strIndex += "\n/* index 0x%(index)04X : %(EntryName)s. */\n"%texts |
143 if type(values) == ListType: |
143 if type(values) == ListType: |
144 texts["value"] = values[0] |
144 texts["value"] = values[0] |
145 strIndex += " UNS8 %(NodeName)s_highestSubIndex_obj%(index)04X = %(value)d; // number of subindex - 1\n"%texts |
145 strIndex += " UNS8 %(NodeName)s_highestSubIndex_obj%(index)04X = %(value)d; /* number of subindex - 1*/\n"%texts |
146 |
146 |
147 # Entry type is VAR |
147 # Entry type is VAR |
148 if type(values) != ListType: |
148 if type(values) != ListType: |
149 subentry_infos = Manager.GetSubentryInfos(index, 0) |
149 subentry_infos = Manager.GetSubentryInfos(index, 0) |
150 typename = Manager.GetTypeName(subentry_infos["type"]) |
150 typename = Manager.GetTypeName(subentry_infos["type"]) |
158 if typeinfos[2] == "visible_string": |
158 if typeinfos[2] == "visible_string": |
159 texts["value"] = "\"%s\""%values |
159 texts["value"] = "\"%s\""%values |
160 texts["comment"] = "" |
160 texts["comment"] = "" |
161 else: |
161 else: |
162 texts["value"] = "0x%X"%values |
162 texts["value"] = "0x%X"%values |
163 texts["comment"] = "\t// %s"%str(values) |
163 texts["comment"] = "\t/* %s */"%str(values) |
164 if index in variablelist: |
164 if index in variablelist: |
165 texts["name"] = FormatName(subentry_infos["name"]) |
165 texts["name"] = FormatName(subentry_infos["name"]) |
166 strDeclareHeader += "extern %(subIndexType)s %(name)s%(suffixe)s;\t\t// Mapped at index 0x%(index)04X, subindex 0x00\n"%texts |
166 strDeclareHeader += "extern %(subIndexType)s %(name)s%(suffixe)s;\t\t/* Mapped at index 0x%(index)04X, subindex 0x00*/\n"%texts |
167 if callbacks: |
167 if callbacks: |
168 strDeclareHeader += "extern ODCallback_t %(name)s_callbacks[];\t\t// Callbacks of index0x%(index)04X\n"%texts |
168 strDeclareHeader += "extern ODCallback_t %(name)s_callbacks[];\t\t/* Callbacks of index0x%(index)04X */\n"%texts |
169 mappedVariableContent += "%(subIndexType)s %(name)s%(suffixe)s = %(value)s;\t\t// Mapped at index 0x%(index)04X, subindex 0x00\n"%texts |
169 mappedVariableContent += "%(subIndexType)s %(name)s%(suffixe)s = %(value)s;\t\t/* Mapped at index 0x%(index)04X, subindex 0x00 */\n"%texts |
170 else: |
170 else: |
171 strIndex += " %(subIndexType)s %(NodeName)s_obj%(index)04X%(suffixe)s = %(value)s;%(comment)s\n"%texts |
171 strIndex += " %(subIndexType)s %(NodeName)s_obj%(index)04X%(suffixe)s = %(value)s;%(comment)s\n"%texts |
172 values = [values] |
172 values = [values] |
173 else: |
173 else: |
174 |
174 |
184 texts["subIndexType"] = typeinfos[0] |
184 texts["subIndexType"] = typeinfos[0] |
185 texts["suffixe"] = typeinfos[1] |
185 texts["suffixe"] = typeinfos[1] |
186 texts["length"] = values[0] |
186 texts["length"] = values[0] |
187 if index in variablelist: |
187 if index in variablelist: |
188 texts["name"] = FormatName(entry_infos["name"]) |
188 texts["name"] = FormatName(entry_infos["name"]) |
189 strDeclareHeader += "extern %(subIndexType)s %(name)s[%(length)d]%(suffixe)s;\t\t// Mapped at index 0x%(index)04X, subindex 0x01 - 0x%(length)02X\n"%texts |
189 strDeclareHeader += "extern %(subIndexType)s %(name)s[%(length)d]%(suffixe)s;\t\t/* Mapped at index 0x%(index)04X, subindex 0x01 - 0x%(length)02X */\n"%texts |
190 if callbacks: |
190 if callbacks: |
191 strDeclareHeader += "extern ODCallback_t %(name)s_callbacks[];\t\t// Callbacks of index0x%(index)04X\n"%texts |
191 strDeclareHeader += "extern ODCallback_t %(name)s_callbacks[];\t\t/* Callbacks of index0x%(index)04X */\n"%texts |
192 mappedVariableContent += "%(subIndexType)s %(name)s[] =\t\t// Mapped at index 0x%(index)04X, subindex 0x01 - 0x%(length)02X\n {\n"%texts |
192 mappedVariableContent += "%(subIndexType)s %(name)s[] =\t\t/* Mapped at index 0x%(index)04X, subindex 0x01 - 0x%(length)02X */\n {\n"%texts |
193 for subIndex, value in enumerate(values): |
193 for subIndex, value in enumerate(values): |
194 sep = "," |
194 sep = "," |
195 comment = "" |
195 comment = "" |
196 if subIndex > 0: |
196 if subIndex > 0: |
197 if subIndex == len(values)-1: |
197 if subIndex == len(values)-1: |
198 sep = "" |
198 sep = "" |
199 if typeinfos[2] == "visible_string": |
199 if typeinfos[2] == "visible_string": |
200 value = "\"%s\""%value |
200 value = "\"%s\""%value |
201 else: |
201 else: |
202 comment = "\t// %s"%str(value) |
202 comment = "\t/* %s */"%str(value) |
203 value = "0x%X"%value |
203 value = "0x%X"%value |
204 mappedVariableContent += " %s%s%s\n"%(value, sep, comment) |
204 mappedVariableContent += " %s%s%s\n"%(value, sep, comment) |
205 mappedVariableContent += " };\n" |
205 mappedVariableContent += " };\n" |
206 else: |
206 else: |
207 strIndex += " %(subIndexType)s %(NodeName)s_obj%(index)04X[] = \n {\n"%texts |
207 strIndex += " %(subIndexType)s %(NodeName)s_obj%(index)04X[] = \n {\n"%texts |
212 if subIndex == len(values)-1: |
212 if subIndex == len(values)-1: |
213 sep = "" |
213 sep = "" |
214 if typeinfos[2] == "visible_string": |
214 if typeinfos[2] == "visible_string": |
215 value = "\"%s\""%value |
215 value = "\"%s\""%value |
216 else: |
216 else: |
217 comment = "\t// %s"%str(value) |
217 comment = "\t/* %s */"%str(value) |
218 value = "0x%X"%value |
218 value = "0x%X"%value |
219 strIndex += " %s%s%s\n"%(value, sep, comment) |
219 strIndex += " %s%s%s\n"%(value, sep, comment) |
220 strIndex += " };\n" |
220 strIndex += " };\n" |
221 else: |
221 else: |
222 |
222 |
237 if typeinfos[2] == "visible_string": |
237 if typeinfos[2] == "visible_string": |
238 texts["value"] = "\"%s\""%value |
238 texts["value"] = "\"%s\""%value |
239 texts["comment"] = "" |
239 texts["comment"] = "" |
240 else: |
240 else: |
241 texts["value"] = "0x%X"%value |
241 texts["value"] = "0x%X"%value |
242 texts["comment"] = "\t// %s"%str(value) |
242 texts["comment"] = "\t/* %s */"%str(value) |
243 texts["name"] = FormatName(subentry_infos["name"]) |
243 texts["name"] = FormatName(subentry_infos["name"]) |
244 if index in variablelist: |
244 if index in variablelist: |
245 strDeclareHeader += "extern %(subIndexType)s %(parent)s_%(name)s%(suffixe)s;\t\t// Mapped at index 0x%(index)04X, subindex 0x%(subIndex)02X\n"%texts |
245 strDeclareHeader += "extern %(subIndexType)s %(parent)s_%(name)s%(suffixe)s;\t\t/* Mapped at index 0x%(index)04X, subindex 0x%(subIndex)02X */\n"%texts |
246 mappedVariableContent += "%(subIndexType)s %(parent)s_%(name)s%(suffixe)s = %(value)s;\t\t// Mapped at index 0x%(index)04X, subindex 0x%(subIndex)02X\n"%texts |
246 mappedVariableContent += "%(subIndexType)s %(parent)s_%(name)s%(suffixe)s = %(value)s;\t\t/* Mapped at index 0x%(index)04X, subindex 0x%(subIndex)02X */\n"%texts |
247 else: |
247 else: |
248 strIndex += " %(subIndexType)s %(NodeName)s_obj%(index)04X_%(name)s%(suffixe)s = %(value)s;%(comment)s\n"%texts |
248 strIndex += " %(subIndexType)s %(NodeName)s_obj%(index)04X_%(name)s%(suffixe)s = %(value)s;%(comment)s\n"%texts |
249 if callbacks: |
249 if callbacks: |
250 strDeclareHeader += "extern ODCallback_t %(parent)s_callbacks[];\t\t// Callbacks of index0x%(index)04X\n"%texts |
250 strDeclareHeader += "extern ODCallback_t %(parent)s_callbacks[];\t\t/* Callbacks of index0x%(index)04X */\n"%texts |
251 |
251 |
252 # Generating Dictionary C++ entry |
252 # Generating Dictionary C++ entry |
253 if callbacks: |
253 if callbacks: |
254 if index in variablelist: |
254 if index in variablelist: |
255 name = FormatName(entry_infos["name"]) |
255 name = FormatName(entry_infos["name"]) |
313 |
313 |
314 if 0x1006 not in communicationlist: |
314 if 0x1006 not in communicationlist: |
315 entry_infos = Manager.GetEntryInfos(0x1006) |
315 entry_infos = Manager.GetEntryInfos(0x1006) |
316 texts["EntryName"] = entry_infos["name"] |
316 texts["EntryName"] = entry_infos["name"] |
317 indexContents[0x1006] = """\n/* index 0x1006 : %(EntryName)s */ |
317 indexContents[0x1006] = """\n/* index 0x1006 : %(EntryName)s */ |
318 UNS32 %(NodeName)s_obj1006 = 0x0; // 0 |
318 UNS32 %(NodeName)s_obj1006 = 0x0; /* 0 */ |
319 """%texts |
319 """%texts |
320 |
320 |
321 if 0x1016 in communicationlist: |
321 if 0x1016 in communicationlist: |
322 texts["nombre"] = Manager.GetCurrentEntry(0x1016, 0) |
322 texts["nombre"] = Manager.GetCurrentEntry(0x1016, 0) |
323 else: |
323 else: |
330 subindex %(NodeName)s_Index1016[]; |
330 subindex %(NodeName)s_Index1016[]; |
331 """%texts |
331 """%texts |
332 if texts["nombre"] > 0: |
332 if texts["nombre"] > 0: |
333 strTimers = "TIMER_HANDLE %(NodeName)s_heartBeatTimers[%(nombre)d] = {TIMER_NONE,};\n"%texts |
333 strTimers = "TIMER_HANDLE %(NodeName)s_heartBeatTimers[%(nombre)d] = {TIMER_NONE,};\n"%texts |
334 else: |
334 else: |
335 strTimers = "TIMER_HANDLE %(NodeName)s_heartBeatTimers[0];\n"%texts |
335 strTimers = "TIMER_HANDLE %(NodeName)s_heartBeatTimers[1];\n"%texts |
336 |
336 |
337 if 0x1017 not in communicationlist: |
337 if 0x1017 not in communicationlist: |
338 entry_infos = Manager.GetEntryInfos(0x1017) |
338 entry_infos = Manager.GetEntryInfos(0x1017) |
339 texts["EntryName"] = entry_infos["name"] |
339 texts["EntryName"] = entry_infos["name"] |
340 indexContents[0x1017] = """\n/* index 0x1017 : %(EntryName)s */ |
340 indexContents[0x1017] = """\n/* index 0x1017 : %(EntryName)s */ |
341 UNS16 %(NodeName)s_obj1017 = 0x0; // 0 |
341 UNS16 %(NodeName)s_obj1017 = 0x0; /* 0 */ |
342 """%texts |
342 """%texts |
343 |
343 |
344 #------------------------------------------------------------------------------- |
344 #------------------------------------------------------------------------------- |
345 # Declaration of navigation in the Object Dictionary |
345 # Declaration of navigation in the Object Dictionary |
346 #------------------------------------------------------------------------------- |
346 #------------------------------------------------------------------------------- |
370 strQuickIndex += "\nquick_index %s_%s = {\n"%(texts["NodeName"], index_cat) |
370 strQuickIndex += "\nquick_index %s_%s = {\n"%(texts["NodeName"], index_cat) |
371 sep = "," |
371 sep = "," |
372 for i, (cat, idx_min, idx_max) in enumerate(categories): |
372 for i, (cat, idx_min, idx_max) in enumerate(categories): |
373 if i == len(categories) - 1: |
373 if i == len(categories) - 1: |
374 sep = "" |
374 sep = "" |
375 strQuickIndex += " %s : %d%s\n"%(cat, quick_index[index_cat][cat], sep) |
375 strQuickIndex += " %d%s /* %s */\n"%(quick_index[index_cat][cat],sep,cat) |
376 strQuickIndex += "};\n" |
376 strQuickIndex += "};\n" |
377 |
377 |
378 #------------------------------------------------------------------------------- |
378 #------------------------------------------------------------------------------- |
379 # Write File Content |
379 # Write File Content |
380 #------------------------------------------------------------------------------- |
380 #------------------------------------------------------------------------------- |
400 /* The node id */ |
400 /* The node id */ |
401 /**************************************************************************/ |
401 /**************************************************************************/ |
402 /* node_id default value.*/ |
402 /* node_id default value.*/ |
403 UNS8 %(NodeName)s_bDeviceNodeId = 0x%(NodeID)02X; |
403 UNS8 %(NodeName)s_bDeviceNodeId = 0x%(NodeID)02X; |
404 |
404 |
405 //*****************************************************************************/ |
405 /**************************************************************************/ |
406 /* Array of message processing information */ |
406 /* Array of message processing information */ |
407 |
407 |
408 const UNS8 %(NodeName)s_iam_a_slave = %(iam_a_slave)d; |
408 const UNS8 %(NodeName)s_iam_a_slave = %(iam_a_slave)d; |
409 |
409 |
410 """%texts |
410 """%texts |
411 fileContent += strTimers |
411 fileContent += strTimers |
412 |
412 |
413 fileContent += """ |
413 fileContent += """ |
414 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ |
414 /* |
415 // |
415 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ |
416 // OBJECT DICTIONARY |
416 |
417 // |
417 OBJECT DICTIONARY |
418 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ |
418 |
|
419 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ |
|
420 */ |
419 """%texts |
421 """%texts |
420 contentlist = indexContents.keys() |
422 contentlist = indexContents.keys() |
421 contentlist.sort() |
423 contentlist.sort() |
422 for index in contentlist: |
424 for index in contentlist: |
423 fileContent += indexContents[index] |
425 fileContent += indexContents[index] |
442 } |
444 } |
443 *errorCode = OD_SUCCESSFUL; |
445 *errorCode = OD_SUCCESSFUL; |
444 return &%(NodeName)s_objdict[i]; |
446 return &%(NodeName)s_objdict[i]; |
445 } |
447 } |
446 |
448 |
447 // To count at which received SYNC a PDO must be sent. |
449 /* To count at which received SYNC a PDO must be sent. |
448 // Even if no pdoTransmit are defined, at least one entry is computed |
450 * Even if no pdoTransmit are defined, at least one entry is computed |
449 // for compilations issues. |
451 * for compilations issues. |
|
452 */ |
450 UNS8 %(NodeName)s_count_sync[%(maxPDOtransmit)d] = {0,}; |
453 UNS8 %(NodeName)s_count_sync[%(maxPDOtransmit)d] = {0,}; |
451 """%texts |
454 """%texts |
452 fileContent += strQuickIndex |
455 fileContent += strQuickIndex |
453 fileContent += """ |
456 fileContent += """ |
454 UNS16 %(NodeName)s_ObjdictSize = sizeof(%(NodeName)s_objdict)/sizeof(%(NodeName)s_objdict[0]); |
457 UNS16 %(NodeName)s_ObjdictSize = sizeof(%(NodeName)s_objdict)/sizeof(%(NodeName)s_objdict[0]); |
462 #------------------------------------------------------------------------------- |
465 #------------------------------------------------------------------------------- |
463 |
466 |
464 HeaderFileContent = generated_tag + """ |
467 HeaderFileContent = generated_tag + """ |
465 #include "data.h" |
468 #include "data.h" |
466 |
469 |
467 // prototypes of function provided by object dictionnary |
470 /* Prototypes of function provided by object dictionnary */ |
468 UNS32 %(NodeName)s_valueRangeTest (UNS8 typeValue, void * value); |
471 UNS32 %(NodeName)s_valueRangeTest (UNS8 typeValue, void * value); |
469 const indextable * %(NodeName)s_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks); |
472 const indextable * %(NodeName)s_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks); |
470 |
473 |
471 // prototypes of function to be filled by app |
474 /* prototypes of function to be filled by app. */ |
472 void %(NodeName)s_SDOtimeoutError(UNS8 line); |
475 void %(NodeName)s_SDOtimeoutError(UNS8 line); |
473 void %(NodeName)s_heartbeatError(UNS8); |
476 void %(NodeName)s_heartbeatError(UNS8); |
474 |
477 |
475 UNS8 %(NodeName)s_canSend(Message *); |
478 UNS8 %(NodeName)s_canSend(Message *); |
476 |
479 |
480 void %(NodeName)s_stopped(void); |
483 void %(NodeName)s_stopped(void); |
481 |
484 |
482 void %(NodeName)s_post_sync(void); |
485 void %(NodeName)s_post_sync(void); |
483 void %(NodeName)s_post_TPDO(void); |
486 void %(NodeName)s_post_TPDO(void); |
484 |
487 |
485 // Master node data struct |
488 /* Master node data struct */ |
486 extern CO_Data %(NodeName)s_Data; |
489 extern CO_Data %(NodeName)s_Data; |
487 |
490 |
488 """%texts |
491 """%texts |
489 HeaderFileContent += strDeclareHeader |
492 HeaderFileContent += strDeclareHeader |
490 |
493 |