reachabilitygraph_print.mvc 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. log("All values: " + set_to_string(all_values))
  26. while (read_nr_out(all_values) > 0):
  27. place = set_pop(all_values)
  28. dict_add(dict_values, read_attribute(model, place, "name"), read_attribute(model, place, "tokens"))
  29. log((cast_v2s(mapping["0"]) + ": ") + dict_to_string(dict_values))
  30. output((cast_v2s(mapping["0"]) + ": ") + dict_to_string(dict_values))
  31. return!
  32. $
  33. }
  34. }
  35. }
  36. {Contains} ForAll print_transitions {
  37. LHS {
  38. Pre_ReachabilityGraph/State pre_s1 {
  39. label = "0"
  40. }
  41. Pre_ReachabilityGraph/State pre_s2 {
  42. label = "1"
  43. }
  44. Pre_ReachabilityGraph/Transition (pre_s1, pre_s2){
  45. label = "2"
  46. }
  47. }
  48. RHS {
  49. Post_ReachabilityGraph/State post_s1 {
  50. label = "0"
  51. }
  52. Post_ReachabilityGraph/State post_s2 {
  53. label = "1"
  54. }
  55. Post_ReachabilityGraph/Transition (post_s1, post_s2) {
  56. label = "2"
  57. action = $
  58. Void function action(model : Element, name : String, mapping : Element):
  59. log("Transition action")
  60. log((((cast_v2s(mapping["0"]) + " --[") + cast_v2s(read_attribute(model, name, "name"))) + "]--> ") + cast_v2s(mapping["1"]))
  61. output((((cast_v2s(mapping["0"]) + " --[") + cast_v2s(read_attribute(model, name, "name"))) + "]--> ") + cast_v2s(mapping["1"]))
  62. return!
  63. $
  64. }
  65. }
  66. }
  67. }
  68. Initial (schedule, print_states) {}
  69. OnSuccess (print_states, print_transitions) {}
  70. OnFailure (print_states, failure) {}
  71. OnSuccess (print_transitions, success) {}
  72. OnFailure (print_transitions, success) {}
  73. }