def load_parameter(element, project): p = Parameter() p.name = utils.xml_str(element, "name") p.description = utils.xml_str(element, "description", "") p.default = utils.xml_str(element, "default", "0") p.type = utils.xml_str(element, "type") p.policy = utils.xml_str(element, "policy", "mandatory") p.changed() project.add_parameter(p)
def load_place(element, net, loader): id = loader.get_id(element) place = net.add_place((xml_int(element,"x"), xml_int(element, "y")), id) place.box.name = xml_str(element, "name", "") place.box.radius = xml_int(element,"radius") place.box.size = (xml_int(element,"sx", 0), xml_int(element,"sy", 0)) if element.find("place-type") is not None: canvastext_from_xml(element.find("place-type"), place.place_type) else: place.place_type.text = element.get("place_type", "") # Backward compatability if element.find("init") is not None: canvastext_from_xml(element.find("init"), place.init) else: place.init.text = element.get("init_string", "") # Backward compatability place.set_code(load_code(element)) place.tracing = load_place_tracing(element) interface = element.find("interface") if interface is not None: place.interface.set_position((xml_int(interface, "x"), xml_int(interface, "y"))) place.interface.interface_in = interface.get("in") place.interface.interface_out = interface.get("out") place.interface.update() e = element.find("verif-final-marking") if e is not None: place.final_marking = bool(e.text)
def load_transition(element, net, loader): id = loader.get_id(element) transition = net.add_transition((xml_int(element,"x"), xml_int(element, "y")), id) sx = xml_int(element,"sx") sy = xml_int(element,"sy") transition.box.size = (sx, sy) transition.box.name = xml_str(element,"name", "") if element.find("guard") is not None: canvastext_from_xml(element.find("guard"), transition.guard) else: transition.guard.text = element.get("guard", "") # Backward compatability transition.set_code(load_code(element)) transition.tracing = load_tracing(element) transition.clock = utils.xml_bool(element, "clock", False) if element.find("time-substitution") is not None: transition.time_substitution = True transition.time_substitution_code = element.find("time-substitution").text if element.find("clock-substitution") is not None: transition.clock_substitution = True transition.clock_substitution_code = element.find("clock-substitution").text e = element.find("verif-occurrence") if e is not None: transition.occurrence_analysis = True transition.occurrence_analysis_compare_process = utils.xml_bool(e, "process") transition.occurrence_analysis_compare_binding = utils.xml_bool(e, "binding") transition.set_priority(element.get("priority", ""))
def load_build_option(element, project): name = utils.xml_str(element, "name") value = element.text if value is None: # For backward compatability return if name == "CC": # For backward compatability return project.set_build_option(name, value)
def load_area(element, net, loader): id = loader.get_id(element) sx = xml_int(element,"sx") sy = xml_int(element,"sy") px = xml_int(element, "x") py = xml_int(element, "y") area = net.add_area((px, py), (sx, sy), id) if element.find("init") is not None: canvastext_from_xml(element.find("init"), area.init) else: area.init.text = xml_str(element,"init-expr", "")
def load_area(element, net, loader): id = loader.get_id(element) sx = xml_int(element, "sx") sy = xml_int(element, "sy") px = xml_int(element, "x") py = xml_int(element, "y") area = net.add_area((px, py), (sx, sy), id) if element.find("init") is not None: canvastext_from_xml(element.find("init"), area.init) else: area.init.text = xml_str(element, "init-expr", "")
def load_transition(element, net, loader): id = loader.get_id(element) transition = net.add_transition( (xml_int(element, "x"), xml_int(element, "y")), id) sx = xml_int(element, "sx") sy = xml_int(element, "sy") if element.get("label-x") and element.get("label-y"): label_x = xml_int(element, "label-x") label_y = xml_int(element, "label-y") transition.label_placement.set_position((label_x, label_y)) transition.box.size = (sx, sy) transition.box.name = xml_str(element, "name", "") if element.find("guard") is not None: canvastext_from_xml(element.find("guard"), transition.guard) else: transition.guard.text = element.get("guard", "") # Backward compatability if element.find("root") is not None: canvastext_from_xml(element.find("root"), transition.root) transition.set_code(load_code(element)) transition.trace_fire = element.find("trace") is not None transition.clock = utils.xml_bool(element, "clock", False) transition.set_collective(utils.xml_bool(element, "collective", False)) if element.find("time-substitution") is not None: transition.time_substitution = True transition.time_substitution_code = element.find( "time-substitution").text if element.find("clock-substitution") is not None: transition.clock_substitution = True transition.clock_substitution_code = element.find( "clock-substitution").text e = element.find("verif-occurrence") if e is not None: transition.occurrence_analysis = True transition.occurrence_analysis_compare_process = utils.xml_bool( e, "process") transition.occurrence_analysis_compare_binding = utils.xml_bool( e, "binding") transition.set_priority(element.get("priority", ""))
def load_edge(element, net, loader): id = loader.get_id(element) fitem = net.item_by_id(loader.translate_id(xml_int(element, "from_item"))) assert fitem is not None titem = net.item_by_id(loader.translate_id(xml_int(element, "to_item"))) assert titem is not None points = [ (xml_int(e, "x"), xml_int(e,"y")) for e in element.findall("point") ] edge = net.add_edge(fitem, titem, points, id) edge.line.bidirectional = utils.xml_bool(element, "bidirectional", False) if element.find("inscription") is not None: canvastext_from_xml(element.find("inscription"), edge.inscription) else: # Backward compitabality if element.get("inscription") is not None: edge.inscription.text = xml_str(element, "inscription") if element.find("size-substitution") is not None: edge.size_substitution = True edge.size_substitution_code = element.find("size-substitution").text
def load_edge(element, net, loader): id = loader.get_id(element) fitem = net.item_by_id(loader.translate_id(xml_int(element, "from_item"))) assert fitem is not None titem = net.item_by_id(loader.translate_id(xml_int(element, "to_item"))) assert titem is not None points = [(xml_int(e, "x"), xml_int(e, "y")) for e in element.findall("point")] edge = net.add_edge(fitem, titem, points, id) edge.line.bidirectional = utils.xml_bool(element, "bidirectional", False) if element.find("inscription") is not None: canvastext_from_xml(element.find("inscription"), edge.inscription) else: # Backward compitabality if element.get("inscription") is not None: edge.inscription.text = xml_str(element, "inscription") if element.find("size-substitution") is not None: edge.size_substitution = True edge.size_substitution_code = element.find("size-substitution").text
def load_place(element, net, loader): id = loader.get_id(element) place = net.add_place((xml_int(element, "x"), xml_int(element, "y")), id) place.box.name = xml_str(element, "name", "") place.box.radius = xml_int(element, "radius") place.box.size = (xml_int(element, "sx", 0), xml_int(element, "sy", 0)) if element.get("label-x") and element.get("label-y"): label_x = xml_int(element, "label-x") label_y = xml_int(element, "label-y") place.label_placement.set_position((label_x, label_y)) if element.find("place-type") is not None: canvastext_from_xml(element.find("place-type"), place.place_type) else: place.place_type.text = element.get("place_type", "") # Backward compatability if element.find("init") is not None: canvastext_from_xml(element.find("init"), place.init) else: place.init.text = element.get("init_string", "") # Backward compatability place.set_code(load_code(element)) load_place_tracing(element.find("trace"), place) interface = element.find("interface") if interface is not None: place.interface.set_position((xml_int(interface, "x"), xml_int(interface, "y"))) place.interface.interface_in = interface.get("in") place.interface.interface_out = interface.get("out") place.interface.update() e = element.find("verif-final-marking") if e is not None: place.final_marking = bool(e.text)