objdictgen/nodemanager.py
changeset 68 234dad27b398
parent 63 2be18e405e40
child 171 db7a030babb2
equal deleted inserted replaced
67:51642fb5a0af 68:234dad27b398
   776                     value = eval("0x%s"%self.NameTranslation[value])
   776                     value = eval("0x%s"%self.NameTranslation[value])
   777                     self.CurrentNode.SetEntry(index, subIndex, value)
   777                     self.CurrentNode.SetEntry(index, subIndex, value)
   778                 elif editor == "bool":
   778                 elif editor == "bool":
   779                     value = value == "True"
   779                     value = value == "True"
   780                     self.CurrentNode.SetEntry(index, subIndex, value)
   780                     self.CurrentNode.SetEntry(index, subIndex, value)
       
   781                 elif editor == "time":
       
   782                     self.CurrentNode.SetEntry(index, subIndex, value)
   781                 else:
   783                 else:
   782                     subentry_infos = self.GetSubentryInfos(index, subIndex)
   784                     subentry_infos = self.GetSubentryInfos(index, subIndex)
   783                     type = subentry_infos["type"]
   785                     type = subentry_infos["type"]
   784                     dic = {}
   786                     dic = {}
   785                     for typeindex, typevalue in CustomisableTypes:
   787                     for typeindex, typevalue in CustomisableTypes:
   804             else:
   806             else:
   805                 if editor == "type":
   807                 if editor == "type":
   806                     value = self.TypeTranslation[value]
   808                     value = self.TypeTranslation[value]
   807                     size = self.GetEntryInfos(value)["size"]
   809                     size = self.GetEntryInfos(value)["size"]
   808                     self.CurrentNode.UpdateMapVariable(index, subIndex, size)
   810                     self.CurrentNode.UpdateMapVariable(index, subIndex, size)
   809                 elif editor == "access":
   811                 elif editor in ["access","raccess"]:
   810                     dic = {}
   812                     dic = {}
   811                     for abbrev,access in AccessType.iteritems():
   813                     for abbrev,access in AccessType.iteritems():
   812                         dic[access] = abbrev
   814                         dic[access] = abbrev
   813                     value = dic[value]
   815                     value = dic[value]
       
   816                     if editor == "raccess" and not self.CurrentNode.IsMappingEntry(index):
       
   817                         entry_infos = self.GetEntryInfos(index)
       
   818                         self.CurrentNode.AddMappingEntry(index, name = entry_infos["name"], struct = 7)
       
   819                         self.CurrentNode.AddMappingEntry(index, 0, values = self.GetSubentryInfos(index, 0, False).copy())
       
   820                         self.CurrentNode.AddMappingEntry(index, 1, values = self.GetSubentryInfos(index, 1, False).copy())
   814                 self.CurrentNode.SetMappingEntry(index, subIndex, values = {name : value})
   821                 self.CurrentNode.SetMappingEntry(index, subIndex, values = {name : value})
   815                 if name == "name" or editor == "type":
   822                 if name == "name" or editor == "type":
   816                     self.GenerateMapList()
   823                     self.GenerateMapList()
   817             self.BufferCurrentNode()
   824             self.BufferCurrentNode()
   818 
   825 
  1080                 dic["save"] = OptionType[dic["save"]]
  1087                 dic["save"] = OptionType[dic["save"]]
  1081                 editor = {"subindex" : None, "save" : "option", "callback" : "option", "comment" : "string"}
  1088                 editor = {"subindex" : None, "save" : "option", "callback" : "option", "comment" : "string"}
  1082                 if type(values) == ListType and i == 0:
  1089                 if type(values) == ListType and i == 0:
  1083                     editor["name"] = None
  1090                     editor["name"] = None
  1084                     editor["type"] = None
  1091                     editor["type"] = None
  1085                     editor["access"] = None
  1092                     if 0x1600 <= index <= 0x17FF or 0x1A00 <= index <= 0x1C00:
       
  1093                         editor["access"] = "raccess"
       
  1094                     else:
       
  1095                         editor["access"] = None
  1086                     editor["value"] = None
  1096                     editor["value"] = None
  1087                 else:
  1097                 else:
  1088                     if infos["user_defined"]:
  1098                     if infos["user_defined"]:
  1089                         if entry_infos["struct"] & OD_IdenticalSubindexes:
  1099                         if entry_infos["struct"] & OD_IdenticalSubindexes:
  1090                             editor["name"] = None
  1100                             editor["name"] = None
  1113                         editor["value"] = "map"
  1123                         editor["value"] = "map"
  1114                         dic["value"] = self.MapTranslation["%08X"%dic["value"]]
  1124                         dic["value"] = self.MapTranslation["%08X"%dic["value"]]
  1115                     else:
  1125                     else:
  1116                         if dic["type"].startswith("VISIBLE_STRING"):
  1126                         if dic["type"].startswith("VISIBLE_STRING"):
  1117                             editor["value"] = "string"
  1127                             editor["value"] = "string"
       
  1128                         if dic["type"] in ["TIME_OF_DAY","TIME_DIFFERENCE"]:
       
  1129                             editor["value"] = "time"
  1118                         elif dic["type"] == "BOOLEAN":
  1130                         elif dic["type"] == "BOOLEAN":
  1119                             editor["value"] = "bool"
  1131                             editor["value"] = "bool"
  1120                             dic["value"] = BoolType[dic["value"]]
  1132                             dic["value"] = BoolType[dic["value"]]
  1121                         result = type_model.match(dic["type"])
  1133                         result = type_model.match(dic["type"])
  1122                         if result:
  1134                         if result:
  1148         values = self.CurrentNode.GetEntry(index)
  1160         values = self.CurrentNode.GetEntry(index)
  1149         customisabletypes = self.GetCustomisableTypes()
  1161         customisabletypes = self.GetCustomisableTypes()
  1150         return values, customisabletypes[values[1]][1]
  1162         return values, customisabletypes[values[1]][1]
  1151 
  1163 
  1152     def GetEntryName(self, index, node = True):
  1164     def GetEntryName(self, index, node = True):
  1153         result = FindEntryName(index, MappingDictionary)
  1165         result = None
  1154         if result == None and node:
  1166         if node:
  1155             NodeMappings = self.CurrentNode.GetMappings()
  1167             NodeMappings = self.CurrentNode.GetMappings()
  1156             i = 0
  1168             i = 0
  1157             while not result and i < len(NodeMappings):
  1169             while not result and i < len(NodeMappings):
  1158                 result = FindEntryName(index, NodeMappings[i])
  1170                 result = FindEntryName(index, NodeMappings[i])
  1159                 i += 1
  1171                 i += 1
       
  1172         if result == None:
       
  1173             result = FindEntryName(index, MappingDictionary)
  1160         return result
  1174         return result
  1161     
  1175     
  1162     def GetEntryInfos(self, index, node = True):
  1176     def GetEntryInfos(self, index, node = True):
  1163         result = FindEntryInfos(index, MappingDictionary)
  1177         result = None
  1164         if result == None and node:
  1178         if node:
  1165             NodeMappings = self.CurrentNode.GetMappings()
  1179             NodeMappings = self.CurrentNode.GetMappings()
  1166             i = 0
  1180             i = 0
  1167             while not result and i < len(NodeMappings):
  1181             while not result and i < len(NodeMappings):
  1168                 result = FindEntryInfos(index, NodeMappings[i])
  1182                 result = FindEntryInfos(index, NodeMappings[i])
  1169                 i += 1
  1183                 i += 1
       
  1184         if result == None:
       
  1185             result = FindEntryInfos(index, MappingDictionary)
  1170         return result
  1186         return result
  1171     
  1187     
  1172     def GetSubentryInfos(self, index, subIndex, node = True):
  1188     def GetSubentryInfos(self, index, subIndex, node = True):
  1173         result = FindSubentryInfos(index, subIndex, MappingDictionary)
  1189         result = None
  1174         if result == None and node:
  1190         if node:
  1175             NodeMappings = self.CurrentNode.GetMappings()
  1191             NodeMappings = self.CurrentNode.GetMappings()
  1176             i = 0
  1192             i = 0
  1177             while not result and i < len(NodeMappings):
  1193             while not result and i < len(NodeMappings):
  1178                 result = FindSubentryInfos(index, subIndex, NodeMappings[i])
  1194                 result = FindSubentryInfos(index, subIndex, NodeMappings[i])
  1179                 if result:
  1195                 if result:
  1180                     result["user_defined"] = i == len(NodeMappings) - 1 and index >= 0x1000
  1196                     result["user_defined"] = i == len(NodeMappings) - 1 and index >= 0x1000
  1181                 i += 1
  1197                 i += 1
  1182         else :
  1198         if result == None:    
  1183             result["user_defined"] = False
  1199             result = FindSubentryInfos(index, subIndex, MappingDictionary)
       
  1200             if result:
       
  1201                 result["user_defined"] = False
  1184         return result
  1202         return result
  1185     
  1203     
  1186     def GetTypeIndex(self, typename, node = True):
  1204     def GetTypeIndex(self, typename, node = True):
  1187         result = FindTypeIndex(typename, MappingDictionary)
  1205         result = None
  1188         if result == None and node:
  1206         if node:
  1189             NodeMappings = self.CurrentNode.GetMappings()
  1207             NodeMappings = self.CurrentNode.GetMappings()
  1190             i = 0
  1208             i = 0
  1191             while not result and i < len(NodeMappings):
  1209             while not result and i < len(NodeMappings):
  1192                 result = FindTypeIndex(typename, NodeMappings[i])
  1210                 result = FindTypeIndex(typename, NodeMappings[i])
  1193                 i += 1
  1211                 i += 1
       
  1212         if result == None:
       
  1213             result = FindTypeIndex(typename, MappingDictionary)
  1194         return result
  1214         return result
  1195     
  1215     
  1196     def GetTypeName(self, typeindex, node = True):
  1216     def GetTypeName(self, typeindex, node = True):
  1197         result = FindTypeName(typeindex, MappingDictionary)
  1217         result = None
  1198         if result == None and node:
  1218         if node:
  1199             NodeMappings = self.CurrentNode.GetMappings()
  1219             NodeMappings = self.CurrentNode.GetMappings()
  1200             i = 0
  1220             i = 0
  1201             while not result and i < len(NodeMappings):
  1221             while not result and i < len(NodeMappings):
  1202                 result = FindTypeName(typeindex, NodeMappings[i])
  1222                 result = FindTypeName(typeindex, NodeMappings[i])
  1203                 i += 1
  1223                 i += 1
       
  1224         if result == None:
       
  1225             result = FindTypeName(typeindex, MappingDictionary)
  1204         return result
  1226         return result
  1205     
  1227     
  1206     def GetTypeDefaultValue(self, typeindex, node = True):
  1228     def GetTypeDefaultValue(self, typeindex, node = True):
  1207         result = FindTypeDefaultValue(typeindex, MappingDictionary)
  1229         result = None
  1208         if result == None and node:
  1230         if node:
  1209             NodeMappings = self.CurrentNode.GetMappings()
  1231             NodeMappings = self.CurrentNode.GetMappings()
  1210             i = 0
  1232             i = 0
  1211             while not result and i < len(NodeMappings):
  1233             while not result and i < len(NodeMappings):
  1212                 result = FindTypeDefaultValue(typeindex, NodeMappings[i])
  1234                 result = FindTypeDefaultValue(typeindex, NodeMappings[i])
  1213                 i += 1
  1235                 i += 1
       
  1236         if result == None:
       
  1237             result = FindTypeDefaultValue(typeindex, MappingDictionary)
  1214         return result
  1238         return result
  1215     
  1239     
  1216     def GetTypeList(self, node = True):
  1240     def GetTypeList(self, node = True):
  1217         list = FindTypeList(MappingDictionary)
  1241         list = FindTypeList(MappingDictionary)
  1218         if node:
  1242         if node: