environment_to_EPN.mvc 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. include "primitives.alh"
  2. include "modelling.alh"
  3. include "object_operations.alh"
  4. A B {
  5. Composite schedule {
  6. {Contains} Success success {}
  7. {Contains} Failure failure {}
  8. {Contains} ForAll create_ports {
  9. LHS {
  10. Pre_PW_Environment/Event {
  11. label = "1"
  12. }
  13. }
  14. RHS {
  15. Post_PW_Environment/Event cp_evt {
  16. label = "1"
  17. }
  18. Post_Encapsulated_PetriNet/Place cp_place {
  19. label = "2"
  20. value_name = $
  21. String function value(model : Element, name : String, mapping : Element):
  22. return read_attribute(model, mapping["1"], "name")!
  23. $
  24. value_tokens = $
  25. Integer function value(model : Element, name : String, mapping : Element):
  26. Boolean initial
  27. initial = read_attribute(model, mapping["1"], "initial")
  28. if (initial):
  29. return 1!
  30. else:
  31. return 0!
  32. $
  33. }
  34. Post_Encapsulated_PetriNet/Port cp_port {
  35. label = "3"
  36. value_name = $
  37. String function value(model : Element, name : String, mapping : Element):
  38. return string_join("environment/", read_attribute(model, mapping["1"], "name"))!
  39. $
  40. }
  41. Post_ENV2EPN_link (cp_evt, cp_place) {
  42. label = "4"
  43. }
  44. Post_Encapsulated_PetriNet/PortPlace (cp_port, cp_place) {
  45. label = "5"
  46. }
  47. }
  48. }
  49. {Contains} ForAll create_switches {
  50. LHS {
  51. Pre_PW_Environment/Group pre_grp {
  52. label = "1"
  53. }
  54. Pre_PW_Environment/Event pre_evt_a {
  55. label = "2"
  56. }
  57. Pre_PW_Environment/Event pre_evt_b {
  58. label = "3"
  59. }
  60. Pre_PW_Environment/Contains (pre_grp, pre_evt_a) {
  61. label = "4"
  62. }
  63. Pre_PW_Environment/Contains (pre_grp, pre_evt_b) {
  64. label = "5"
  65. }
  66. Pre_Encapsulated_PetriNet/Place pre_place_a {
  67. label = "8"
  68. }
  69. Pre_Encapsulated_PetriNet/Place pre_place_b {
  70. label = "9"
  71. }
  72. Pre_ENV2EPN_link (pre_evt_a, pre_place_a) {
  73. label = "6"
  74. }
  75. Pre_ENV2EPN_link (pre_evt_b, pre_place_b) {
  76. label = "7"
  77. }
  78. }
  79. RHS {
  80. Post_PW_Environment/Group post_grp {
  81. label = "1"
  82. }
  83. Post_PW_Environment/Event post_evt_a {
  84. label = "2"
  85. }
  86. Post_PW_Environment/Event post_evt_b {
  87. label = "3"
  88. }
  89. Post_PW_Environment/Contains (post_grp, post_evt_a) {
  90. label = "4"
  91. }
  92. Post_PW_Environment/Contains (post_grp, post_evt_b) {
  93. label = "5"
  94. }
  95. Post_Encapsulated_PetriNet/Place post_place_a {
  96. label = "8"
  97. }
  98. Post_Encapsulated_PetriNet/Place post_place_b {
  99. label = "9"
  100. }
  101. Post_Encapsulated_PetriNet/Transition post_transition {
  102. label = "12"
  103. value_name = $
  104. String function value(model : Element, name : String, mapping : Element):
  105. return string_join(string_join(read_attribute(model, mapping["2"], "name"), " -> "), read_attribute(model, mapping["3"], "name"))!
  106. $
  107. }
  108. Post_Encapsulated_PetriNet/P2T (post_place_a, post_transition) {
  109. label = "10"
  110. }
  111. Post_Encapsulated_PetriNet/T2P (post_transition, post_place_b) {
  112. label = "11"
  113. }
  114. Post_ENV2EPN_link (post_evt_a, post_place_a) {
  115. label = "6"
  116. }
  117. Post_ENV2EPN_link (post_evt_b, post_place_b) {
  118. label = "7"
  119. }
  120. }
  121. }
  122. }
  123. Initial (schedule, create_ports) {}
  124. OnSuccess (create_ports, create_switches) {}
  125. OnSuccess (create_switches, success) {}
  126. OnFailure (create_ports, failure) {}
  127. OnFailure (create_switches, failure) {}
  128. }