equal
deleted
inserted
replaced
306 value = value.strip() |
306 value = value.strip() |
307 # First case, value starts with "$NODEID", then it's a formula |
307 # First case, value starts with "$NODEID", then it's a formula |
308 if value.startswith("$NODEID"): |
308 if value.startswith("$NODEID"): |
309 try: |
309 try: |
310 test = int(value.replace("$NODEID+", ""), 16) |
310 test = int(value.replace("$NODEID+", ""), 16) |
311 computed_value = value.replace("$NODEID", "self.ID") |
311 computed_value = "\"%s\""%value |
312 except: |
312 except: |
313 raise SyntaxError, "\"%s\" is not a valid formula for attribute \"%s\" of section \"[%s]\""%(value, keyname, section_name) |
313 raise SyntaxError, "\"%s\" is not a valid formula for attribute \"%s\" of section \"[%s]\""%(value, keyname, section_name) |
314 # Second case, value starts with "0x", then it's an hexadecimal value |
314 # Second case, value starts with "0x", then it's an hexadecimal value |
315 elif value.startswith("0x"): |
315 elif value.startswith("0x"): |
316 try: |
316 try: |
385 elif values["DATATYPE"] in (0x08, 0x11): |
385 elif values["DATATYPE"] in (0x08, 0x11): |
386 values["DEFAULTVALUE"] = float(values["DEFAULTVALUE"]) |
386 values["DEFAULTVALUE"] = float(values["DEFAULTVALUE"]) |
387 elif values["DATATYPE"] == 0x01: |
387 elif values["DATATYPE"] == 0x01: |
388 values["DEFAULTVALUE"] = {0 : True, 1 : False}[values["DEFAULTVALUE"]] |
388 values["DEFAULTVALUE"] = {0 : True, 1 : False}[values["DEFAULTVALUE"]] |
389 else: |
389 else: |
390 if type(values["DEFAULTVALUE"]) != IntType and values["DEFAULTVALUE"].find("self.ID") == -1: |
390 if type(values["DEFAULTVALUE"]) != IntType and values["DEFAULTVALUE"].find("$NODEID") == -1: |
391 raise |
391 raise |
392 except: |
392 except: |
393 raise SyntaxError, "Error on section \"[%s]\":\nDefaultValue incompatible with DataType"%section_name |
393 raise SyntaxError, "Error on section \"[%s]\":\nDefaultValue incompatible with DataType"%section_name |
394 |
394 |
395 return eds_dict |
395 return eds_dict |
494 |
494 |
495 # For each entry, we generate the entry section or sections if there is subindexes |
495 # For each entry, we generate the entry section or sections if there is subindexes |
496 for entry in entries: |
496 for entry in entries: |
497 # Extract infos and values for the entry |
497 # Extract infos and values for the entry |
498 entry_infos = Manager.GetEntryInfos(entry) |
498 entry_infos = Manager.GetEntryInfos(entry) |
499 values = Manager.GetCurrentEntry(entry) |
499 values = Manager.GetCurrentEntry(entry, compute = False) |
500 # Define section name |
500 # Define section name |
501 text = "\n[%X]\n"%entry |
501 text = "\n[%X]\n"%entry |
502 # If there is only one value, it's a VAR entry |
502 # If there is only one value, it's a VAR entry |
503 if type(values) != ListType: |
503 if type(values) != ListType: |
504 # Extract the informations of the first subindex |
504 # Extract the informations of the first subindex |
724 # Extract maximum subindex number defined |
724 # Extract maximum subindex number defined |
725 try: |
725 try: |
726 max_subindex = values["subindexes"][0]["DEFAULTVALUE"] |
726 max_subindex = values["subindexes"][0]["DEFAULTVALUE"] |
727 except: |
727 except: |
728 raise SyntaxError, "Error on entry 0x%4.4X:\nSubindex 0 must be defined for an ARRAY or a RECORD entry"%entry |
728 raise SyntaxError, "Error on entry 0x%4.4X:\nSubindex 0 must be defined for an ARRAY or a RECORD entry"%entry |
|
729 Node.AddEntry(entry, value = []) |
729 # Define value for all subindexes except the first |
730 # Define value for all subindexes except the first |
730 for subindex in xrange(1, int(max_subindex) + 1): |
731 for subindex in xrange(1, int(max_subindex) + 1): |
731 # Take default value if it is defined and entry is defined |
732 # Take default value if it is defined and entry is defined |
732 if subindex in values["subindexes"] and "DEFAULTVALUE" in values["subindexes"][subindex]: |
733 if subindex in values["subindexes"] and "DEFAULTVALUE" in values["subindexes"][subindex]: |
733 value = values["subindexes"][subindex]["DEFAULTVALUE"] |
734 value = values["subindexes"][subindex]["DEFAULTVALUE"] |