print.alc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. Element all_t
  10. String t
  11. log("Places:")
  12. all_places = allInstances(model, "Encapsulated_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, "Encapsulated_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, "Encapsulated_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, "Encapsulated_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. log("Ports:")
  33. all_places = allInstances(model, "Encapsulated_PetriNet/Port")
  34. while (set_len(all_places) > 0):
  35. place = set_pop(all_places)
  36. name = read_attribute(model, place, "name")
  37. log(" " + name)
  38. return True!