Add petrinet language
This commit is contained in:
parent
dd7a0536c9
commit
5240c7e21a
12 changed files with 137 additions and 7 deletions
|
|
@ -0,0 +1 @@
|
|||
t:RAM_Transition
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
# A place with no tokens:
|
||||
|
||||
p:RAM_Place
|
||||
ps:RAM_PlaceState {
|
||||
RAM_numTokens = `get_value(this) == 0`;
|
||||
}
|
||||
:RAM_of (ps -> p)
|
||||
|
||||
# An incoming arc from that place to our transition:
|
||||
|
||||
t:RAM_Transition
|
||||
|
||||
:RAM_arc (p -> t)
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
t:RAM_Transition {
|
||||
condition = ```
|
||||
# remove 1 token from every place connected with incoming arc
|
||||
for incoming in get_incoming(this, "arc"):
|
||||
in_place = get_source(incoming)
|
||||
in_place_state = get_source(get_incoming(in_place, "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")
|
||||
|
||||
# add 1 token to every place connected with outgoing arc
|
||||
for outgoing in get_outgoing(this, "arc"):
|
||||
out_place = get_target(outgoing)
|
||||
out_place_state = get_source(get_incoming(out_place, "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")
|
||||
```;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue