|
@@ -85,6 +85,23 @@ Void function petrinet_fire(model : Element):
|
|
|
output("Unknown transition; aborting")
|
|
|
return
|
|
|
|
|
|
+Void function petrinet_list(model : Element):
|
|
|
+ Element keys
|
|
|
+ Element typemap
|
|
|
+ Element place
|
|
|
+ String name
|
|
|
+
|
|
|
+ keys = dict_keys(model["model"])
|
|
|
+ typemap = model["type_mapping"]
|
|
|
+ place = model["metamodel"]["model"]["Place"]
|
|
|
+
|
|
|
+ while (list_len(keys) > 0):
|
|
|
+ name = set_pop(keys)
|
|
|
+ if (element_eq(dict_read_node(typemap, model["model"][name]), place)):
|
|
|
+ // Found a place
|
|
|
+ output((name + ": ") + cast_i2s(read_attribute(model, name, "tokens")))
|
|
|
+ return
|
|
|
+
|
|
|
Void function main():
|
|
|
Element model
|
|
|
String cmd
|
|
@@ -104,10 +121,13 @@ Void function main():
|
|
|
output(" help -- this information")
|
|
|
output(" enabled -- list the enabled transitions")
|
|
|
output(" fire -- fire a transition")
|
|
|
+ output(" list -- list the state of the petrinet")
|
|
|
elif (cmd == "enabled"):
|
|
|
petrinet_enabled(model)
|
|
|
elif (cmd == "fire"):
|
|
|
petrinet_fire(model)
|
|
|
+ elif (cmd == "list"):
|
|
|
+ petrinet_list(model)
|
|
|
else:
|
|
|
output("Did not understand command!")
|
|
|
|