12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- include "primitives.alh"
- include "modelling.alh"
- include "object_operations.alh"
- Boolean function pn_print(model : Element):
- Element all_places
- String place
- String name
- Integer tokens
- Element all_t
- String t
- log("Places:")
- all_places = allInstances(model, "Encapsulated_PetriNet/Place")
- while (set_len(all_places) > 0):
- place = set_pop(all_places)
- name = read_attribute(model, place, "name")
- tokens = read_attribute(model, place, "tokens")
- log(" " + name + ": " + cast_string(tokens))
- log("Transitions:")
- all_places = allInstances(model, "Encapsulated_PetriNet/Transition")
- while (set_len(all_places) > 0):
- place = set_pop(all_places)
- name = read_attribute(model, place, "name")
- log(" " + name)
- all_t = allIncomingAssociationInstances(model, place, "Encapsulated_PetriNet/P2T")
- while (set_len(all_t) > 0):
- t = set_pop(all_t)
- log(" <-- " + cast_value(read_attribute(model, readAssociationSource(model, t), "name")))
- all_t = allOutgoingAssociationInstances(model, place, "Encapsulated_PetriNet/T2P")
- while (set_len(all_t) > 0):
- t = set_pop(all_t)
- log(" --> " + cast_value(read_attribute(model, readAssociationDestination(model, t), "name")))
- log("Ports:")
- all_places = allInstances(model, "Encapsulated_PetriNet/Port")
- while (set_len(all_places) > 0):
- place = set_pop(all_places)
- name = read_attribute(model, place, "name")
- log(" " + name)
- return True!
|