pn_print.alc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. include "primitives.alh"
  2. include "modelling.alh"
  3. include "object_operations.alh"
  4. Boolean function pn_print(model : Element):
  5. Element all_places
  6. String place
  7. String name
  8. Integer tokens
  9. String t
  10. Element all_t
  11. log("Places:")
  12. all_places = allInstances(model, "PetriNet/Place")
  13. while (set_len(all_places) > 0):
  14. place = set_pop(all_places)
  15. name = read_attribute(model, place, "name")
  16. tokens = read_attribute(model, place, "tokens")
  17. log(" " + name + ": " + cast_string(tokens))
  18. log("Transitions:")
  19. all_places = allInstances(model, "PetriNet/Transition")
  20. while (set_len(all_places) > 0):
  21. place = set_pop(all_places)
  22. name = read_attribute(model, place, "name")
  23. log(" " + name)
  24. all_t = allIncomingAssociationInstances(model, place, "PetriNet/P2T")
  25. while (set_len(all_t) > 0):
  26. t = set_pop(all_t)
  27. log(" <-- " + cast_value(read_attribute(model, readAssociationSource(model, t), "name")))
  28. all_t = allOutgoingAssociationInstances(model, place, "PetriNet/T2P")
  29. while (set_len(all_t) > 0):
  30. t = set_pop(all_t)
  31. log(" --> " + cast_value(read_attribute(model, readAssociationDestination(model, t), "name")))
  32. return True!