diff --git a/examples/petrinet/metamodels/mm_design.od b/examples/petrinet/metamodels/mm_design.od index f315e6c..ffe4864 100644 --- a/examples/petrinet/metamodels/mm_design.od +++ b/examples/petrinet/metamodels/mm_design.od @@ -1,11 +1,11 @@ # Places, transitions, arcs (and only one kind of arc) -Connectable:Class { abstract = True; } +PNConnectable:Class { abstract = True; } -arc:Association (Connectable -> Connectable) +pn_arc:Association (PNConnectable -> PNConnectable) -Place:Class -Transition:Class +PNPlace:Class +PNTransition:Class -:Inheritance (Place -> Connectable) -:Inheritance (Transition -> Connectable) \ No newline at end of file +:Inheritance (PNPlace -> PNConnectable) +:Inheritance (PNTransition -> PNConnectable) \ No newline at end of file diff --git a/examples/petrinet/metamodels/mm_runtime.od b/examples/petrinet/metamodels/mm_runtime.od index 731afdb..1e15296 100644 --- a/examples/petrinet/metamodels/mm_runtime.od +++ b/examples/petrinet/metamodels/mm_runtime.od @@ -1,13 +1,13 @@ # A place has a number of tokens, and that's it. -PlaceState:Class -PlaceState_numTokens:AttributeLink (PlaceState -> Integer) { +PNPlaceState:Class +PNPlaceState_numTokens:AttributeLink (PNPlaceState -> Integer) { name = "numTokens"; optional = False; constraint = `"numTokens cannot be negative" if get_value(get_target(this)) < 0 else None`; } -of:Association (PlaceState -> Place) { +pn_of:Association (PNPlaceState -> PNPlace) { # one-to-one source_lower_cardinality = 1; source_upper_cardinality = 1; diff --git a/examples/petrinet/models/m_example_mutex.od b/examples/petrinet/models/m_example_mutex.od index 75cc67b..91c9600 100644 --- a/examples/petrinet/models/m_example_mutex.od +++ b/examples/petrinet/models/m_example_mutex.od @@ -2,29 +2,29 @@ # http://msdl.uantwerpen.be/people/hv/teaching/MoSIS/lectures/presentation.PetriNets.pdf # page 51 -general_1:Place -general_2:Place -critical_1:Place -critical_2:Place -semaphore:Place +general_1:PNPlace +general_2:PNPlace +critical_1:PNPlace +critical_2:PNPlace +semaphore:PNPlace -enterCritical_1:Transition -leaveCritical_1:Transition -enterCritical_2:Transition -leaveCritical_2:Transition +enterCritical_1:PNTransition +leaveCritical_1:PNTransition +enterCritical_2:PNTransition +leaveCritical_2:PNTransition -:arc (general_1 -> enterCritical_1) -:arc (semaphore -> enterCritical_1) -:arc (enterCritical_1 -> critical_1) +:pn_arc (general_1 -> enterCritical_1) +:pn_arc (semaphore -> enterCritical_1) +:pn_arc (enterCritical_1 -> critical_1) -:arc (critical_1 -> leaveCritical_1) -:arc (leaveCritical_1 -> semaphore) -:arc (leaveCritical_1 -> general_1) +:pn_arc (critical_1 -> leaveCritical_1) +:pn_arc (leaveCritical_1 -> semaphore) +:pn_arc (leaveCritical_1 -> general_1) -:arc (semaphore -> enterCritical_2) -:arc (general_2 -> enterCritical_2) -:arc (enterCritical_2 -> critical_2) +:pn_arc (semaphore -> enterCritical_2) +:pn_arc (general_2 -> enterCritical_2) +:pn_arc (enterCritical_2 -> critical_2) -:arc (leaveCritical_2 -> semaphore) -:arc (leaveCritical_2 -> general_2) -:arc (critical_2 -> leaveCritical_2) \ No newline at end of file +:pn_arc (leaveCritical_2 -> semaphore) +:pn_arc (leaveCritical_2 -> general_2) +:pn_arc (critical_2 -> leaveCritical_2) \ No newline at end of file diff --git a/examples/petrinet/models/m_example_mutex_rt_initial.od b/examples/petrinet/models/m_example_mutex_rt_initial.od index 83efc8c..5192e7b 100644 --- a/examples/petrinet/models/m_example_mutex_rt_initial.od +++ b/examples/petrinet/models/m_example_mutex_rt_initial.od @@ -1,25 +1,25 @@ -general_1_s:PlaceState { +general_1_s:PNPlaceState { numTokens = 1; } -general_2_s:PlaceState { +general_2_s:PNPlaceState { numTokens = 1; } -critical_1_s:PlaceState { +critical_1_s:PNPlaceState { numTokens = 0; } -critical_2_s:PlaceState { +critical_2_s:PNPlaceState { numTokens = 0; } -semaphore_s:PlaceState { +semaphore_s:PNPlaceState { numTokens = 1; } -:of (general_1_s -> general_1) -:of (general_2_s -> general_2) -:of (critical_1_s -> critical_1) -:of (critical_2_s -> critical_2) -:of (semaphore_s -> semaphore) +:pn_of (general_1_s -> general_1) +:pn_of (general_2_s -> general_2) +:pn_of (critical_1_s -> critical_1) +:pn_of (critical_2_s -> critical_2) +:pn_of (semaphore_s -> semaphore) diff --git a/examples/petrinet/models/m_example_simple.od b/examples/petrinet/models/m_example_simple.od index 136242d..347ab75 100644 --- a/examples/petrinet/models/m_example_simple.od +++ b/examples/petrinet/models/m_example_simple.od @@ -1,10 +1,10 @@ -p0:Place -p1:Place +p0:PNPlace +p1:PNPlace -t0:Transition -:arc (p0 -> t0) -:arc (t0 -> p1) +t0:PNTransition +:pn_arc (p0 -> t0) +:pn_arc (t0 -> p1) -t1:Transition -:arc (p1 -> t1) -:arc (t1 -> p0) \ No newline at end of file +t1:PNTransition +:pn_arc (p1 -> t1) +:pn_arc (t1 -> p0) \ No newline at end of file diff --git a/examples/petrinet/models/m_example_simple_rt_initial.od b/examples/petrinet/models/m_example_simple_rt_initial.od index 6cf3076..fa93f4e 100644 --- a/examples/petrinet/models/m_example_simple_rt_initial.od +++ b/examples/petrinet/models/m_example_simple_rt_initial.od @@ -1,11 +1,11 @@ -p0s:PlaceState { +p0s:PNPlaceState { numTokens = 1; } -:of (p0s -> p0) +:pn_of (p0s -> p0) -p1s:PlaceState { +p1s:PNPlaceState { numTokens = 0; } -:of (p1s -> p1) +:pn_of (p1s -> p1) diff --git a/examples/petrinet/operational_semantics/r_fire_transition_lhs.od b/examples/petrinet/operational_semantics/r_fire_transition_lhs.od index bfe4c69..c3bd82c 100644 --- a/examples/petrinet/operational_semantics/r_fire_transition_lhs.od +++ b/examples/petrinet/operational_semantics/r_fire_transition_lhs.od @@ -1 +1 @@ -t:RAM_Transition \ No newline at end of file +t:RAM_PNTransition \ No newline at end of file diff --git a/examples/petrinet/operational_semantics/r_fire_transition_nac.od b/examples/petrinet/operational_semantics/r_fire_transition_nac.od index d5b0cdb..3c49f28 100644 --- a/examples/petrinet/operational_semantics/r_fire_transition_nac.od +++ b/examples/petrinet/operational_semantics/r_fire_transition_nac.od @@ -1,13 +1,13 @@ # A place with no tokens: -p:RAM_Place -ps:RAM_PlaceState { +p:RAM_PNPlace +ps:RAM_PNPlaceState { RAM_numTokens = `get_value(this) == 0`; } -:RAM_of (ps -> p) +:RAM_pn_of (ps -> p) # An incoming arc from that place to our transition: -t:RAM_Transition +t:RAM_PNTransition -:RAM_arc (p -> t) +:RAM_pn_arc (p -> t) diff --git a/examples/petrinet/operational_semantics/r_fire_transition_rhs.od b/examples/petrinet/operational_semantics/r_fire_transition_rhs.od index bef4b52..50b1b19 100644 --- a/examples/petrinet/operational_semantics/r_fire_transition_rhs.od +++ b/examples/petrinet/operational_semantics/r_fire_transition_rhs.od @@ -1,19 +1,19 @@ -t:RAM_Transition { +t:RAM_PNTransition { condition = ``` # remove 1 token from every place connected with incoming arc - for incoming in get_incoming(this, "arc"): + for incoming in get_incoming(this, "pn_arc"): in_place = get_source(incoming) - in_place_state = get_source(get_incoming(in_place, "of")[0]) + in_place_state = get_source(get_incoming(in_place, "pn_of")[0]) in_num_tokens = get_slot_value(in_place_state, "numTokens") set_slot_value(in_place_state, "numTokens", in_num_tokens - 1) - print("place", get_name(in_place_state), "now has", in_num_tokens-1, "tokens") + print("PNPlace", get_name(in_place_state), "now has", in_num_tokens-1, "tokens") # add 1 token to every place connected with outgoing arc - for outgoing in get_outgoing(this, "arc"): + for outgoing in get_outgoing(this, "pn_arc"): out_place = get_target(outgoing) - out_place_state = get_source(get_incoming(out_place, "of")[0]) + out_place_state = get_source(get_incoming(out_place, "pn_of")[0]) out_num_tokens = get_slot_value(out_place_state, "numTokens") set_slot_value(out_place_state, "numTokens", out_num_tokens + 1) - print("place", get_name(out_place_state), "now has", out_num_tokens+1, "tokens") + print("PNPlace", get_name(out_place_state), "now has", out_num_tokens+1, "tokens") ```; } diff --git a/examples/petrinet/renderer.py b/examples/petrinet/renderer.py index 66eb630..a7d4777 100644 --- a/examples/petrinet/renderer.py +++ b/examples/petrinet/renderer.py @@ -24,18 +24,18 @@ def render_petri_net(od: ODAPI): dot += "node[fontname=Arial,fontsize=10];\n" dot += "subgraph places {" dot += " node [shape=circle,fixedsize=true,label=\"\", height=.35,width=.35];" - for _, place_state in od.get_all_instances("PlaceState"): - place = od.get_target(od.get_outgoing(place_state, "of")[0]) + for _, place_state in od.get_all_instances("PNPlaceState"): + place = od.get_target(od.get_outgoing(place_state, "pn_of")[0]) place_name = od.get_name(place) num_tokens = od.get_slot_value(place_state, "numTokens") dot += f" {place_name} [label=\"{place_name}\\n\\n{render_tokens(num_tokens)}\\n\\n­\"];\n" dot += "}\n" dot += "subgraph transitions {" dot += " node [shape=rect,fixedsize=true,height=.3,width=.12,style=filled,fillcolor=black,color=white];\n" - for transition_name, _ in od.get_all_instances("Transition"): + for transition_name, _ in od.get_all_instances("PNTransition"): dot += f" {transition_name} [label=\"{transition_name}\\n\\n\\n­\"];\n" dot += "}\n" - for _, arc in od.get_all_instances("arc"): + for _, arc in od.get_all_instances("pn_arc"): src_name = od.get_name(od.get_source(arc)) tgt_name = od.get_name(od.get_target(arc)) dot += f"{src_name} -> {tgt_name};"