epn_print.alc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. include "primitives.alh"
  2. include "modelling.alh"
  3. include "object_operations.alh"
  4. Element function pn_print(params : Element, output_mms : Element):
  5. Element model
  6. model = params["epn"]
  7. Element all_places
  8. String place
  9. String name
  10. Integer tokens
  11. Element all_t
  12. String t
  13. log("Places:")
  14. all_places = allInstances(model, "Place")
  15. while (read_nr_out(all_places) > 0):
  16. place = set_pop(all_places)
  17. name = read_attribute(model, place, "name")
  18. tokens = read_attribute(model, place, "tokens")
  19. log(((" " + name) + ": ") + cast_v2s(tokens))
  20. log("Transitions:")
  21. all_places = allInstances(model, "Transition")
  22. while (read_nr_out(all_places) > 0):
  23. place = set_pop(all_places)
  24. name = read_attribute(model, place, "name")
  25. log(" " + name)
  26. all_t = allIncomingAssociationInstances(model, place, "P2T")
  27. while (read_nr_out(all_t) > 0):
  28. t = set_pop(all_t)
  29. log(" <-- " + cast_v2s(read_attribute(model, readAssociationSource(model, t), "name")))
  30. all_t = allOutgoingAssociationInstances(model, place, "T2P")
  31. while (read_nr_out(all_t) > 0):
  32. t = set_pop(all_t)
  33. log(" --> " + cast_v2s(read_attribute(model, readAssociationDestination(model, t), "name")))
  34. log("Ports:")
  35. all_places = allInstances(model, "Port")
  36. while (read_nr_out(all_places) > 0):
  37. place = set_pop(all_places)
  38. name = read_attribute(model, place, "name")
  39. log(" " + name)
  40. return create_node()!