objdictgen/node.py
changeset 510 96d50ac2dea3
parent 453 c74a73474cce
child 513 f0343a7457b8
equal deleted inserted replaced
509:88c2ea321049 510:96d50ac2dea3
   126     0x1010 : {"name" : "Store parameters", "struct" : array, "need" : False, "values" :
   126     0x1010 : {"name" : "Store parameters", "struct" : array, "need" : False, "values" :
   127                 [{"name" : "Number of Entries", "type" : 0x05, "access" : 'ro', "pdo" : False},
   127                 [{"name" : "Number of Entries", "type" : 0x05, "access" : 'ro', "pdo" : False},
   128                  {"name" : "Save All Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
   128                  {"name" : "Save All Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
   129                  {"name" : "Save Communication Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
   129                  {"name" : "Save Communication Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
   130                  {"name" : "Save Application Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
   130                  {"name" : "Save Application Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
   131                  {"name" : "Save Manufacturer Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False, "nbmax" : 0x7C}]},
   131                  {"name" : "Save Manufacturer Parameters %d[(sub - 3)]", "type" : 0x07, "access" : 'rw', "pdo" : False, "nbmax" : 0x7C}]},
   132     0x1011 : {"name" : "Restore Default Parameters", "struct" : array, "need" : False, "values" :
   132     0x1011 : {"name" : "Restore Default Parameters", "struct" : array, "need" : False, "values" :
   133                 [{"name" : "Number of Entries", "type" : 0x05, "access" : 'ro', "pdo" : False},
   133                 [{"name" : "Number of Entries", "type" : 0x05, "access" : 'ro', "pdo" : False},
   134                  {"name" : "Restore All Default Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
   134                  {"name" : "Restore All Default Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
   135                  {"name" : "Restore Communication Default Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
   135                  {"name" : "Restore Communication Default Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
   136                  {"name" : "Restore Application Default Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
   136                  {"name" : "Restore Application Default Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
   137                  {"name" : "Restore Manufacturer Default Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False, "nbmax" : 0x7C}]},
   137                  {"name" : "Restore Manufacturer Defined Default Parameters %d[(sub - 3)]", "type" : 0x07, "access" : 'rw', "pdo" : False, "nbmax" : 0x7C}]},
   138     0x1012 : {"name" : "TIME COB ID", "struct" : var, "need" : False, "values" :
   138     0x1012 : {"name" : "TIME COB ID", "struct" : var, "need" : False, "values" :
   139                 [{"name" : "TIME COB ID", "type" : 0x07, "access" : 'rw', "pdo" : False}]},
   139                 [{"name" : "TIME COB ID", "type" : 0x07, "access" : 'rw', "pdo" : False}]},
   140     0x1013 : {"name" : "High Resolution Timestamp", "struct" : var, "need" : False, "values" :
   140     0x1013 : {"name" : "High Resolution Timestamp", "struct" : var, "need" : False, "values" :
   141                 [{"name" : "High Resolution Time Stamp", "type" : 0x07, "access" : 'rw', "pdo" : True}]},
   141                 [{"name" : "High Resolution Time Stamp", "type" : 0x07, "access" : 'rw', "pdo" : True}]},
   142     0x1014 : {"name" : "Emergency COB ID", "struct" : var, "need" : False, "values" :
   142     0x1014 : {"name" : "Emergency COB ID", "struct" : var, "need" : False, "values" :
   298 """
   298 """
   299 def FindSubentryInfos(index, subIndex, mappingdictionary):
   299 def FindSubentryInfos(index, subIndex, mappingdictionary):
   300     base_index = FindIndex(index, mappingdictionary)
   300     base_index = FindIndex(index, mappingdictionary)
   301     if base_index:
   301     if base_index:
   302         struct = mappingdictionary[base_index]["struct"]
   302         struct = mappingdictionary[base_index]["struct"]
       
   303         if struct & OD_IdenticalIndexes:
       
   304             incr = mappingdictionary[base_index]["incr"]
       
   305         else:
       
   306             incr = 1
   303         if struct & OD_Subindex:
   307         if struct & OD_Subindex:
       
   308             infos = None
   304             if struct & OD_IdenticalSubindexes:
   309             if struct & OD_IdenticalSubindexes:
   305                 if struct & OD_IdenticalIndexes:
       
   306                     incr = mappingdictionary[base_index]["incr"]
       
   307                 else:
       
   308                     incr = 1
       
   309                 if subIndex == 0:
   310                 if subIndex == 0:
   310                     return mappingdictionary[base_index]["values"][0].copy()
   311                     infos = mappingdictionary[base_index]["values"][0].copy()
   311                 elif 0 < subIndex <= mappingdictionary[base_index]["values"][1]["nbmax"]:
   312                 elif 0 < subIndex <= mappingdictionary[base_index]["values"][1]["nbmax"]:
   312                     copy = mappingdictionary[base_index]["values"][1].copy()
   313                     infos = mappingdictionary[base_index]["values"][1].copy()
   313                     copy["name"] = StringFormat(copy["name"], (index - base_index) / incr + 1, subIndex)
   314             elif struct & OD_MultipleSubindexes:
   314                     return copy
   315                 idx = 0
   315             elif struct & OD_MultipleSubindexes and 0 <= subIndex < len(mappingdictionary[base_index]["values"]):
   316                 for subindex_infos in mappingdictionary[base_index]["values"]:
   316                 return mappingdictionary[base_index]["values"][subIndex].copy()
   317                     if "nbmax" in subindex_infos:
       
   318                         if idx <= subIndex < idx + subindex_infos["nbmax"]:
       
   319                             infos = subindex_infos.copy()
       
   320                             break;
       
   321                         idx += subindex_infos["nbmax"]
       
   322                     else:
       
   323                         if subIndex == idx:
       
   324                             infos = subindex_infos.copy()
       
   325                             break;
       
   326                         idx += 1
   317             elif subIndex == 0:
   327             elif subIndex == 0:
   318                 return mappingdictionary[base_index]["values"][0].copy()
   328                 infos = mappingdictionary[base_index]["values"][0].copy()
       
   329             if infos is not None:
       
   330                 infos["name"] = StringFormat(infos["name"], (index - base_index) / incr + 1, subIndex)
       
   331             return infos
   319     return None
   332     return None
   320 
   333 
   321 """
   334 """
   322 Return the list of variables that can be mapped defined in mappingdictionary 
   335 Return the list of variables that can be mapped defined in mappingdictionary 
   323 """
   336 """