objdictgen/eds_utils.py
changeset 776 30ced15f996f
parent 740 b6646a975f23
child 784 8aefbd0d39ff
equal deleted inserted replaced
775:c8df14b3a388 776:30ced15f996f
    90 # Function that search into Node Mappings the informations about an index or a subindex
    90 # Function that search into Node Mappings the informations about an index or a subindex
    91 # and return the default value
    91 # and return the default value
    92 def GetDefaultValue(Node, index, subIndex = None):
    92 def GetDefaultValue(Node, index, subIndex = None):
    93     infos = Node.GetEntryInfos(index)
    93     infos = Node.GetEntryInfos(index)
    94     if infos["struct"] & node.OD_MultipleSubindexes:
    94     if infos["struct"] & node.OD_MultipleSubindexes:
    95         # First case entry is a record
    95         # First case entry is a array
    96         if infos["struct"] & node.OD_IdenticalSubindexes:
    96         if infos["struct"] & node.OD_IdenticalSubindexes:
    97             subentry_infos = Node.GetSubentryInfos(index, 1)
    97             subentry_infos = Node.GetSubentryInfos(index, 1)
    98         # Second case entry is an array
    98         # Second case entry is an record
    99         else:
    99         else:
   100             subentry_infos = Node.GetSubentryInfos(index, subIndex)
   100             subentry_infos = Node.GetSubentryInfos(index, subIndex)
   101         # If a default value is defined for this subindex, returns it
   101         # If a default value is defined for this subindex, returns it
   102         if "default" in subentry_infos:
   102         if "default" in subentry_infos:
   103             return subentry_infos["default"]
   103             return subentry_infos["default"]
   321                 
   321                 
   322                 # keyname must be immediately followed by the "=" sign, so we
   322                 # keyname must be immediately followed by the "=" sign, so we
   323                 # verify that there is no whitespace into keyname
   323                 # verify that there is no whitespace into keyname
   324                 if keyname.isalnum():
   324                 if keyname.isalnum():
   325                     # value can be preceded and followed by whitespaces, so we escape them
   325                     # value can be preceded and followed by whitespaces, so we escape them
   326                     value = value.strip().replace(" ", "")
   326                     value = value.strip()
   327                     # First case, value starts with "$NODEID", then it's a formula
   327                     # First case, value starts with "$NODEID", then it's a formula
   328                     if value.upper().startswith("$NODEID"):
   328                     if value.upper().startswith("$NODEID"):
   329                         try:
   329                         try:
   330                             test = int(value.upper().replace("$NODEID+", ""), 16)
   330                             test = int(value.upper().replace("$NODEID+", ""), 16)
   331                             computed_value = "\"%s\""%value
   331                             computed_value = "\"%s\""%value
   546             text += "PDOMapping=%s\n"%BOOL_TRANSLATE[subentry_infos["pdo"]]
   546             text += "PDOMapping=%s\n"%BOOL_TRANSLATE[subentry_infos["pdo"]]
   547         else:
   547         else:
   548             # Generate EDS informations for the entry
   548             # Generate EDS informations for the entry
   549             text += "ParameterName=%s\n"%entry_infos["name"]
   549             text += "ParameterName=%s\n"%entry_infos["name"]
   550             if entry_infos["struct"] & node.OD_IdenticalSubindexes:
   550             if entry_infos["struct"] & node.OD_IdenticalSubindexes:
       
   551                 text += "ObjectType=0x8\n"
       
   552             else:
   551                 text += "ObjectType=0x9\n"
   553                 text += "ObjectType=0x9\n"
   552             else:
       
   553                 text += "ObjectType=0x8\n"
       
   554             
   554             
   555             # Generate EDS informations for subindexes of the entry in a separate text
   555             # Generate EDS informations for subindexes of the entry in a separate text
   556             subtext = ""
   556             subtext = ""
   557             # Reset number of subindex defined 
   557             # Reset number of subindex defined 
   558             nb_subentry = 0
   558             nb_subentry = 0