else:
attributes = "Attribute \"%s\" is"%unsupported[0]
raise SyntaxError, "Error on section \"[%s]\":\n%s unsupported for a%s entry"%(section_name, attributes, ENTRY_TYPES[objecttype]["name"])
-
+
+ if "DEFAULTVALUE" in values:
+ try:
+ if values["DATATYPE"] in (0x09, 0x0A, 0x0B, 0x0F):
+ values["DEFAULTVALUE"] = str(values["DEFAULTVALUE"])
+ elif values["DATATYPE"] in (0x08, 0x11):
+ values["DEFAULTVALUE"] = float(values["DEFAULTVALUE"])
+ elif values["DATATYPE"] == 0x01:
+ values["DEFAULTVALUE"] = {0 : True, 1 : False}[values["DEFAULTVALUE"]]
+ else:
+ if type(values["DEFAULTVALUE"]) != IntType and values["DEFAULTVALUE"].find("self.ID") == -1:
+ raise
+ except:
+ raise SyntaxError, "Error on section \"[%s]\":\nDefaultValue incompatible with DataType"%section_name
+
return eds_dict
# Format a string for making a C++ variable
def FormatName(name):
wordlist = [word for word in word_model.findall(name) if word != '']
- result = ''
- sep = ''
- for word in wordlist:
- result += "%s%s"%(sep,word)
- sep = '_'
- return result
+ return "_".join(wordlist)
# Extract the informations from a given type name
def GetValidTypeInfos(typename):
strDeclareCallback = ""
indexContents = {}
indexCallbacks = {}
+ translate_characters = "".join([chr(i) for i in xrange(128)] + ["_" for i in xrange(128)])
for index in listIndex:
texts["index"] = index
strIndex = ""
entry_infos = Manager.GetEntryInfos(index)
- texts["EntryName"] = entry_infos["name"]
+ texts["EntryName"] = entry_infos["name"].translate(translate_characters)
values = Manager.GetCurrentEntry(index)
callbacks = Manager.HasCurrentEntryCallbacks(index)
if index in variablelist:
value = "\"%s\""%value
elif typeinfos[2] == "domain":
value = "\"%s\""%''.join(["\\x%2.2x"%ord(char) for char in value])
- else:
+ else:
comment = "\t/* %s */"%str(value)
value = "0x%X"%value
mappedVariableContent += " %s%s%s\n"%(value, sep, comment)
elif typeinfos[2] == "domain":
texts["value"] = "\"%s\""%''.join(["\\x%2.2x"%ord(char) for char in value])
texts["comment"] = ""
- else:
+ else:
texts["value"] = "0x%X"%value
texts["comment"] = "\t/* %s */"%str(value)
texts["name"] = FormatName(subentry_infos["name"])
values.append(self.CompileValue(value, index))
return values
else:
- return self.Dictionary[index]
+ return self.CompileValue(self.Dictionary[index], index)
elif subIndex == 0:
if type(self.Dictionary[index]) == ListType:
return len(self.Dictionary[index])
for mapping in self.GetMappings():
result = FindIndex(index, mapping)
if result != None:
- return (index - result) / mapping[result]["incr"]
+ return (index - result) / mapping[result].get("incr", 1)
result = FindIndex(index, MappingDictionary)
if result != None:
- return (index - result) / MappingDictionary[result]["incr"]
+ return (index - result) / MappingDictionary[result].get("incr", 1)
return 0
def GetCustomisedTypeValues(self, index):
from types import *
import os, re, platform, sys, time, traceback, getopt
-__version__ = "$Revision: 1.22 $"
+__version__ = "$Revision: 1.23 $"
from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes
event.Skip()
def OnExportCMenu(self, event):
- dialog = wxFileDialog(self, "Choose a file", os.getcwd(), self.Manager.GetCurrentNodeInfos()[0], "CANFestival OD files (*.c)|*.c|All files|*.*", wxSAVE|wxOVERWRITE_PROMPT|wxCHANGE_DIR)
+ dialog = wxFileDialog(self, "Choose a file", os.getcwd(), self.Manager.GetCurrentNodeInfos()[0], "CANFestival C files (*.c)|*.c|All files|*.*", wxSAVE|wxOVERWRITE_PROMPT|wxCHANGE_DIR)
if dialog.ShowModal() == wxID_OK:
filepath = dialog.GetPath()
if os.path.isdir(os.path.dirname(filepath)):