objdictgen/eds_utils.py
changeset 445 666f2cf93f06
parent 332 97a7a0538dd1
child 489 cfba6bf99701
equal deleted inserted replaced
444:9a7f7bc82257 445:666f2cf93f06
   390                     if values["DATATYPE"] in (0x09, 0x0A, 0x0B, 0x0F):
   390                     if values["DATATYPE"] in (0x09, 0x0A, 0x0B, 0x0F):
   391                         values["PARAMETERVALUE"] = str(values["PARAMETERVALUE"])
   391                         values["PARAMETERVALUE"] = str(values["PARAMETERVALUE"])
   392                     elif values["DATATYPE"] in (0x08, 0x11):
   392                     elif values["DATATYPE"] in (0x08, 0x11):
   393                         values["PARAMETERVALUE"] = float(values["PARAMETERVALUE"])
   393                         values["PARAMETERVALUE"] = float(values["PARAMETERVALUE"])
   394                     elif values["DATATYPE"] == 0x01:
   394                     elif values["DATATYPE"] == 0x01:
   395                         values["PARAMETERVALUE"] = {0 : True, 1 : False}[values["PARAMETERVALUE"]]
   395                         values["PARAMETERVALUE"] = {0 : False, 1 : True}[values["PARAMETERVALUE"]]
   396                     else:
   396                     else:
   397                         if type(values["PARAMETERVALUE"]) != IntType and values["PARAMETERVALUE"].find("$NODEID") == -1:
   397                         if type(values["PARAMETERVALUE"]) != IntType and values["PARAMETERVALUE"].find("$NODEID") == -1:
   398                             raise
   398                             raise
   399                 except:
   399                 except:
   400                     raise SyntaxError, "Error on section \"[%s]\":\nParameterValue incompatible with DataType"%section_name
   400                     raise SyntaxError, "Error on section \"[%s]\":\nParameterValue incompatible with DataType"%section_name
   527             # Generate EDS informations for the entry
   527             # Generate EDS informations for the entry
   528             text += "ParameterName=%s\n"%subentry_infos["name"]
   528             text += "ParameterName=%s\n"%subentry_infos["name"]
   529             text += "ObjectType=0x7\n"
   529             text += "ObjectType=0x7\n"
   530             text += "DataType=0x%4.4X\n"%subentry_infos["type"]
   530             text += "DataType=0x%4.4X\n"%subentry_infos["type"]
   531             text += "AccessType=%s\n"%subentry_infos["access"]
   531             text += "AccessType=%s\n"%subentry_infos["access"]
   532             text += "DefaultValue=%s\n"%values
   532             if subentry_infos["type"] == 1:
       
   533                 text += "DefaultValue=%s\n"%BOOL_TRANSLATE[values]
       
   534             else:
       
   535                 text += "DefaultValue=%s\n"%values
   533             text += "PDOMapping=%s\n"%BOOL_TRANSLATE[subentry_infos["pdo"]]
   536             text += "PDOMapping=%s\n"%BOOL_TRANSLATE[subentry_infos["pdo"]]
   534         else:
   537         else:
   535             # Generate EDS informations for the entry
   538             # Generate EDS informations for the entry
   536             text += "ParameterName=%s\n"%entry_infos["name"]
   539             text += "ParameterName=%s\n"%entry_infos["name"]
   537             if entry_infos["struct"] & node.OD_IdenticalSubindexes:
   540             if entry_infos["struct"] & node.OD_IdenticalSubindexes:
   551                     subtext += "\n[%Xsub%X]\n"%(entry, subentry)
   554                     subtext += "\n[%Xsub%X]\n"%(entry, subentry)
   552                     subtext += "ParameterName=%s\n"%subentry_infos["name"]
   555                     subtext += "ParameterName=%s\n"%subentry_infos["name"]
   553                     subtext += "ObjectType=0x7\n"
   556                     subtext += "ObjectType=0x7\n"
   554                     subtext += "DataType=0x%4.4X\n"%subentry_infos["type"]
   557                     subtext += "DataType=0x%4.4X\n"%subentry_infos["type"]
   555                     subtext += "AccessType=%s\n"%subentry_infos["access"]
   558                     subtext += "AccessType=%s\n"%subentry_infos["access"]
   556                     subtext += "DefaultValue=%s\n"%value
   559                     if subentry_infos["type"] == 1:
       
   560                         subtext += "DefaultValue=%s\n"%BOOL_TRANSLATE[value]
       
   561                     else:
       
   562                         subtext += "DefaultValue=%s\n"%value
   557                     subtext += "PDOMapping=%s\n"%BOOL_TRANSLATE[subentry_infos["pdo"]]
   563                     subtext += "PDOMapping=%s\n"%BOOL_TRANSLATE[subentry_infos["pdo"]]
   558                     # Increment number of subindex defined 
   564                     # Increment number of subindex defined 
   559                     nb_subentry += 1
   565                     nb_subentry += 1
   560             # Write number of subindex defined for the entry
   566             # Write number of subindex defined for the entry
   561             text += "SubNumber=%d\n"%nb_subentry
   567             text += "SubNumber=%d\n"%nb_subentry