예제 #1
0
파일: project.py 프로젝트: Kobzol/kaira
def load_area(element, project, net):
    id = utils.xml_int(element, "id")
    init_type, init_value = project.parse_init_expression(
        element.get("init-expr"),
        get_source(element, "init"))
    if init_type is None:
        raise utils.PtpException("Expression is empty", get_source(element, "init"))
    places = [ net.get_place(utils.xml_int(e, "id"))
               for e in element.findall("place") ]
    return Area(net, id, init_type, init_value, places)
예제 #2
0
파일: project.py 프로젝트: Kobzol/kaira
def load_edge_in(element, project, net, transition):
    id = utils.xml_int(element, "id")
    place_id = utils.xml_int(element, "place-id")
    inscriptions = [ EdgeInscription(config, expr, target)
                     for (config, expr, target) in
                         project.parse_edge_expression(element.get("expr"),
                                                       get_source(element, "inscription")) ]
    edge = Edge(id, transition, net.get_place(place_id), inscriptions)
    if element.find("size-substitution") is not None:
        edge.size_substitution = element.find("size-substitution").text
    return edge
예제 #3
0
파일: project.py 프로젝트: Kobzol/kaira
def load_transition(element, project, net):
    id = utils.xml_int(element, "id")

    name = element.get("name")
    guard = project.parse_expression(element.get("guard"),
                                     get_source(element, "guard"),
                                     allow_empty=True)
    transition = Transition(net, id, name, guard)
    transition.collective = utils.xml_bool(element, "collective", False)
    transition.edges_in = map(lambda e:
        load_edge_in(e, project, net, transition), element.findall("edge-in"))
    transition.edges_out = map(lambda e:
        load_edge_out(e, project, net, transition), element.findall("edge-out"))
    if element.find("code") is not None:
        transition.code = element.find("code").text
    transition.trace_fire = element.find("trace") is not None
    transition.clock = utils.xml_bool(element, "clock", False)

    if transition.collective:
        transition.root = project.parse_expression(element.get("root"),
                                                   get_source(element, "root"),
                                                   allow_empty=True)

    if element.find("time-substitution") is not None:
        transition.time_substitution = element.find("time-substitution").text
    if element.find("clock-substitution") is not None:
        transition.clock_substitution = element.find("clock-substitution").text

    if element.find("verif-quit_flag") is not None:
        transition.calls_quit = True
    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")

    priority = element.get("priority").strip()
    if priority == "":
        transition.priority = 0
    elif utils.is_integer(priority):
        transition.priority = int(priority)
    else:
        raise utils.PtpException("Priority has to be integer or empty",
                                 get_source(element, "priority"))
    return transition
예제 #4
0
def load_transition(element, project, net):
    id = utils.xml_int(element, "id")

    name = element.get("name")
    guard = project.parse_expression(element.get("guard"),
                                     get_source(element, "guard"),
                                     allow_empty=True)
    transition = Transition(net, id, name, guard)
    transition.collective = utils.xml_bool(element, "collective", False)
    transition.edges_in = map(lambda e:
        load_edge_in(e, project, net, transition), element.findall("edge-in"))
    transition.edges_out = map(lambda e:
        load_edge_out(e, project, net, transition), element.findall("edge-out"))
    if element.find("code") is not None:
        transition.code = element.find("code").text
    transition.trace_fire = element.find("trace") is not None
    transition.clock = utils.xml_bool(element, "clock", False)

    if transition.collective:
        transition.root = project.parse_expression(element.get("root"),
                                                   get_source(element, "root"),
                                                   allow_empty=True)

    if element.find("time-substitution") is not None:
        transition.time_substitution = element.find("time-substitution").text
    if element.find("clock-substitution") is not None:
        transition.clock_substitution = element.find("clock-substitution").text

    if element.find("verif-quit_flag") is not None:
        transition.calls_quit = True
    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")

    priority = element.get("priority").strip()
    if priority == "":
        transition.priority = 0
    elif utils.is_integer(priority):
        transition.priority = int(priority)
    else:
        raise utils.PtpException("Priority has to be integer or empty",
                                 get_source(element, "priority"))
    return transition
예제 #5
0
def load_place(element, project, net):
    id = utils.xml_int(element, "id")
    typename = element.get("type")
    project.parse_typename(typename,
                           get_source(element, "type")) # Throws exception if incorrect type
    init_type, init_value = project.parse_init_expression(element.get("init-expr", ""),
                                                      get_source(element, "init"))
    place = Place(net, id, typename, init_type, init_value)
    if element.find("code") is not None:
        place.code = element.find("code").text

    load_place_tracing(element.find("trace"), place)

    if element.find("verif-final-marking") is not None:
        place.final_marking = bool(element.find("verif-final-marking").text)
    place.interface_input = element.get("in")
    place.interface_output = element.get("out")
    return place
예제 #6
0
def load_net(element, project):
    net = Net(project, utils.xml_int(element, "id"), utils.xml_str(element, "name"))
    return net
예제 #7
0
def get_source(element, name):
    id = utils.xml_int(element, "id")
    return get_source_path(id, name)