nice visualization
This commit is contained in:
parent
fecce51828
commit
a8cf1f19e9
1 changed files with 23 additions and 1 deletions
|
|
@ -61,6 +61,7 @@ from transformation.cloner import clone_od
|
||||||
from transformation import rewriter
|
from transformation import rewriter
|
||||||
from concrete_syntax.textual_od.renderer import render_od
|
from concrete_syntax.textual_od.renderer import render_od
|
||||||
from concrete_syntax.common import indent
|
from concrete_syntax.common import indent
|
||||||
|
from api.od import ODAPI
|
||||||
|
|
||||||
state = DevState()
|
state = DevState()
|
||||||
mmm = bootstrap_scd(state)
|
mmm = bootstrap_scd(state)
|
||||||
|
|
@ -166,11 +167,32 @@ def fire_transition(m, transition_match):
|
||||||
for match_outgoing in match_od(state, m, mm, lhs_outgoing, mm_ramified, pivot=transition_match):
|
for match_outgoing in match_od(state, m, mm, lhs_outgoing, mm_ramified, pivot=transition_match):
|
||||||
rewriter.rewrite(state, lhs_outgoing, rhs_outgoing, mm_ramified, match_outgoing, m, mm)
|
rewriter.rewrite(state, lhs_outgoing, rhs_outgoing, mm_ramified, match_outgoing, m, mm)
|
||||||
|
|
||||||
|
def show_petri_net(m):
|
||||||
|
odapi = ODAPI(state, m, mm)
|
||||||
|
p1 = odapi.get_slot_value(odapi.get("p1"), "tokens")
|
||||||
|
p2 = odapi.get_slot_value(odapi.get("p2"), "tokens")
|
||||||
|
cp1 = odapi.get_slot_value(odapi.get("cp1"), "tokens")
|
||||||
|
cp2 = odapi.get_slot_value(odapi.get("cp2"), "tokens")
|
||||||
|
return f"""
|
||||||
|
t1 t2 t3
|
||||||
|
┌─┐ p1 ┌─┐ p2 ┌─┐
|
||||||
|
│ │ --- │ │ --- │ │
|
||||||
|
│ ├─────► ( {p1} )─────►│ │─────► ( {p2} )─────►│ │
|
||||||
|
└─┘ --- └─┘ --- └─┘
|
||||||
|
▲ │ ▲ │
|
||||||
|
│ │ │ │
|
||||||
|
│ │ │ │
|
||||||
|
│ │ │ │
|
||||||
|
│ --- │ │ --- │
|
||||||
|
└───────( {cp1} )◄──────┘ └──────( {cp2} )◄───────┘
|
||||||
|
--- ---
|
||||||
|
cp1 cp2 """
|
||||||
|
|
||||||
# Let's see if it works:
|
# Let's see if it works:
|
||||||
while len(enabled) > 0:
|
while len(enabled) > 0:
|
||||||
|
print(show_petri_net(m))
|
||||||
|
print("\nenabled PN transitions:", enabled)
|
||||||
print("press ENTER to fire", enabled[0]['t'])
|
print("press ENTER to fire", enabled[0]['t'])
|
||||||
input()
|
input()
|
||||||
fire_transition(m, enabled[0])
|
fire_transition(m, enabled[0])
|
||||||
enabled = list(find_enabled_transitions(m))
|
enabled = list(find_enabled_transitions(m))
|
||||||
print("\nenabled PN transitions:", enabled)
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue