pn_print.alc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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["pn"]
  7. Element all_places
  8. String place
  9. String name
  10. Integer tokens
  11. String t
  12. Element all_t
  13. log(set_to_string(dict_keys(model["metamodel"]["model"])))
  14. log("Places:")
  15. all_places = allInstances(model, "Place")
  16. while (read_nr_out(all_places) > 0):
  17. place = set_pop(all_places)
  18. name = read_attribute(model, place, "name")
  19. tokens = read_attribute(model, place, "tokens")
  20. log(((" " + name) + ": ") + cast_v2s(tokens))
  21. all_t = allIncomingAssociationInstances(model, place, "P2T")
  22. while (read_nr_out(all_t) > 0):
  23. t = set_pop(all_t)
  24. log(" <-- " + cast_v2s(read_attribute(model, readAssociationSource(model, t), "name")))
  25. all_t = allOutgoingAssociationInstances(model, place, "T2P")
  26. while (read_nr_out(all_t) > 0):
  27. t = set_pop(all_t)
  28. log(" --> " + cast_v2s(read_attribute(model, readAssociationDestination(model, t), "name")))
  29. log("Transitions:")
  30. all_places = allInstances(model, "Transition")
  31. while (read_nr_out(all_places) > 0):
  32. place = set_pop(all_places)
  33. name = read_attribute(model, place, "name")
  34. log(" " + name)
  35. return create_node()!