epn_print.alc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 (read_nr_out(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_v2s(tokens))
  18. log("Transitions:")
  19. all_places = allInstances(model, "Encapsulated_PetriNet/Transition")
  20. while (read_nr_out(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 (read_nr_out(all_t) > 0):
  26. t = set_pop(all_t)
  27. log(" <-- " + cast_v2s(read_attribute(model, readAssociationSource(model, t), "name")))
  28. all_t = allOutgoingAssociationInstances(model, place, "Encapsulated_PetriNet/T2P")
  29. while (read_nr_out(all_t) > 0):
  30. t = set_pop(all_t)
  31. log(" --> " + cast_v2s(read_attribute(model, readAssociationDestination(model, t), "name")))
  32. log("Ports:")
  33. all_places = allInstances(model, "Encapsulated_PetriNet/Port")
  34. while (read_nr_out(all_places) > 0):
  35. place = set_pop(all_places)
  36. name = read_attribute(model, place, "name")
  37. log(" " + name)
  38. return True!