pn_print.alc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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("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. return create_node()!