reachabilitygraph_print.mvc 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. include "primitives.alh"
  2. include "modelling.alh"
  3. include "object_operations.alh"
  4. ReachabilityGraph_RAM reachabilitygraph_print {
  5. Composite schedule {
  6. {Contains} Success success {}
  7. {Contains} Failure failure {}
  8. {Contains} ForAll print_states {
  9. LHS {
  10. Pre_ReachabilityGraph/State {
  11. label = "0"
  12. }
  13. }
  14. RHS {
  15. Post_ReachabilityGraph/State {
  16. label = "0"
  17. action = $
  18. Void function action(model : Element, name : String, mapping : Element):
  19. log("State action")
  20. Element dict_values
  21. Element all_values
  22. String place
  23. dict_values = create_node()
  24. all_values = allAssociationDestinations(model, name, "ReachabilityGraph/Contains")
  25. while (read_nr_out(all_values) > 0):
  26. place = set_pop(all_values)
  27. dict_add(dict_values, read_attribute(model, place, "name"), read_attribute(model, place, "tokens"))
  28. output((cast_v2s(read_attribute(model, name, "name")) + ": ") + dict_to_string(dict_values))
  29. return!
  30. $
  31. }
  32. }
  33. }
  34. {Contains} ForAll print_transitions {
  35. LHS {
  36. Pre_ReachabilityGraph/State pre_s1 {
  37. label = "0"
  38. }
  39. Pre_ReachabilityGraph/State pre_s2 {
  40. label = "1"
  41. }
  42. Pre_ReachabilityGraph/Transition (pre_s1, pre_s2){
  43. label = "2"
  44. }
  45. }
  46. RHS {
  47. Post_ReachabilityGraph/State post_s1 {
  48. label = "0"
  49. }
  50. Post_ReachabilityGraph/State post_s2 {
  51. label = "1"
  52. }
  53. Post_ReachabilityGraph/Transition (post_s1, post_s2) {
  54. label = "2"
  55. action = $
  56. Void function action(model : Element, name : String, mapping : Element):
  57. output((((cast_v2s(read_attribute(model, mapping["0"], "name")) + " --[") + cast_v2s(read_attribute(model, name, "name"))) + "]--> ") + cast_v2s(read_attribute(model, mapping["1"], "name")))
  58. return!
  59. $
  60. }
  61. }
  62. }
  63. }
  64. Initial (schedule, print_states) {}
  65. OnSuccess (print_states, print_transitions) {}
  66. OnFailure (print_states, failure) {}
  67. OnSuccess (print_transitions, success) {}
  68. OnFailure (print_transitions, success) {}
  69. }