Пример #1
0
def load_project(element, target_envs, build_target="build", load_nets=True):
    target_env = utils.xml_str(element, "target_env")
    if target_env not in target_envs:
        raise utils.PtpException("Unknown target environment")

    description = element.find("description").text
    name = utils.xml_str(element, "name")
    root_directory = utils.xml_str(element, "root-directory")

    p = Project(name,
                root_directory,
                target_envs[target_env],
                description)
    p.build_target = build_target

    p.library_rpc = utils.xml_bool(element, "library-rpc", False)
    p.library_octave = utils.xml_bool(element, "library-octave", False)
    p.tracing = utils.xml_bool(element, "tracing", False)

    load_configuration(element.find("configuration"), p)

    if not load_nets:
        return p

    nets = [ (e, load_net(e, p)) for e in element.findall("net") ]
    p.nets = [ net for e, net in nets ]
    for e, net in nets:
        load_net_content(e, p, net)
    return p
Пример #2
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
Пример #3
0
def load_place_tracing(element, place):
    if element is None:
        return
    place.trace_tokens = utils.xml_bool(element, "trace-tokens", False)
    for e in element.findall("function"):
        place.trace_tokens_functions.append(
            (e.get("name"), e.get("return-type")))
Пример #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_tracing(element, place):
    if element is None:
        return
    place.trace_tokens = utils.xml_bool(element, "trace-tokens", False)
    for e in element.findall("function"):
        place.trace_tokens_functions.append((e.get("name"), e.get("return-type")))