Finish starting point for assignment 6

This commit is contained in:
Joeri Exelmans 2024-12-03 23:49:25 +01:00
parent 7391d7d9a6
commit f77ae21e70
7 changed files with 195 additions and 0 deletions

View file

@ -0,0 +1,5 @@
# Look for a Place and its PlaceState:
port_place:RAM_Place
port_place_state:RAM_PlaceState
port_of:RAM_of (port_place_state -> port_place)

View file

@ -0,0 +1,14 @@
# Our LHS:
port_place:RAM_Place
port_place_state:RAM_PlaceState
port_of:RAM_of (port_place_state -> port_place)
# The elements from our RHS (this prevents the rule from firing forever):
pn_place:RAM_PNPlace
place2place:RAM_generic_link (pn_place -> port_place)
pn_place_state:RAM_PNPlaceState
:RAM_pn_of(pn_place_state -> pn_place)

View file

@ -0,0 +1,22 @@
# Our entire LHS:
port_place:RAM_Place
port_place_state:RAM_PlaceState
port_of:RAM_of (port_place_state -> port_place)
# To create: a Petri Net-place, and link it to our Port-place
pn_place:RAM_PNPlace {
# new feature: you can control the name of the object to be created:
name = `f"pn_{get_name(matched("port_place"))}"`;
}
place2place:RAM_generic_link (pn_place -> port_place)
# And also create: a Petri Net-PlaceState (indicating the amount of tokens in our newly created place)
pn_place_state:RAM_PNPlaceState {
RAM_numTokens = `get_slot_value(matched('port_place_state'), "numShips")`;
}
:RAM_pn_of(pn_place_state -> pn_place)

View file

@ -0,0 +1,5 @@
# Just look for a connection:
port_src:RAM_Source
port_snk:RAM_Sink
port_conn:RAM_connection (port_src -> port_snk)

View file

@ -0,0 +1,10 @@
# Our LHS:
port_src:RAM_Source
port_snk:RAM_Sink
port_conn:RAM_connection (port_src -> port_snk)
# There should not yet be a Petri Net transition linked to the connection:
pn_transition:RAM_PNTransition
:RAM_generic_link (pn_transition -> port_conn)

View file

@ -0,0 +1,14 @@
# Our LHS:
port_src:RAM_Source
port_snk:RAM_Sink
port_conn:RAM_connection (port_src -> port_snk)
# Create a Petri Net transition, and link it to our port-connection:
pn_transition:RAM_PNTransition {
name = `f"pn_{get_name(matched("port_conn"))}"`;
}
trans2conn:RAM_generic_link (pn_transition -> port_conn)
# Note that we are not yet creating any incoming/outgoing petri net arcs! This will be done in another rule.