pn_design_to_runtime.mvc 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. import models/RAM_PetriNets_Design_Runtime as RAM_PN_DR
  2. RAM_PN_DR annotate {
  3. Composite schedule {
  4. {Contains} Failure failure {}
  5. {Contains} Success success {}
  6. {Contains} ForAll copy_transitions {
  7. LHS {
  8. Pre_PetriNets/Transition {
  9. label = "0"
  10. }
  11. }
  12. RHS {
  13. Post_PetriNets/Transition ct1 {
  14. label = "0"
  15. }
  16. Post_PetriNets_Runtime/Transition ct2 {
  17. label = "1"
  18. action = $
  19. include "primitives.alh"
  20. include "modelling.alh"
  21. Void function action(model : Element, name : String, mapping : Element):
  22. instantiate_attribute(model, name, "executing", False)
  23. return!
  24. $
  25. }
  26. Post_D2R_TransitionLink (ct1, ct2){
  27. label = "2"
  28. }
  29. }
  30. }
  31. {Contains} ForAll copy_places {
  32. LHS {
  33. Pre_PetriNets/Place {
  34. label = "0"
  35. }
  36. }
  37. RHS {
  38. Post_PetriNets/Place cp1 {
  39. label = "0"
  40. }
  41. Post_PetriNets_Runtime/Place cp2 {
  42. label = "1"
  43. action = $
  44. include "primitives.alh"
  45. include "modelling.alh"
  46. Void function action(model : Element, name : String, mapping : Element):
  47. instantiate_attribute(model, name, "tokens", read_attribute(model, mapping["0"], "tokens"))
  48. instantiate_attribute(model, name, "name", read_attribute(model, mapping["0"], "name"))
  49. return!
  50. $
  51. }
  52. Post_D2R_PlaceLink (cp1, cp2){
  53. label = "2"
  54. }
  55. }
  56. }
  57. {Contains} ForAll copy_P2T {
  58. LHS {
  59. Pre_PetriNets/Place cp2t_p{
  60. label = "0"
  61. }
  62. Pre_PetriNets/Transition cp2t_t{
  63. label = "1"
  64. }
  65. Pre_PetriNets/P2T (cp2t_p, cp2t_t){
  66. label = "2"
  67. }
  68. Pre_PetriNets_Runtime/Place cp2t_p2{
  69. label = "3"
  70. }
  71. Pre_PetriNets_Runtime/Transition cp2t_t2{
  72. label = "4"
  73. }
  74. Pre_D2R_PlaceLink (cp2t_p, cp2t_p2){
  75. label = "5"
  76. }
  77. Pre_D2R_TransitionLink (cp2t_t, cp2t_t2){
  78. label = "6"
  79. }
  80. }
  81. RHS {
  82. Post_PetriNets/Place rhs_cp2t_p{
  83. label = "0"
  84. }
  85. Post_PetriNets/Transition rhs_cp2t_t{
  86. label = "1"
  87. }
  88. Post_PetriNets/P2T rhs_cp2t_p2t (rhs_cp2t_p, rhs_cp2t_t){
  89. label = "2"
  90. }
  91. Post_PetriNets_Runtime/Place rhs_cp2t_p2 {
  92. label = "3"
  93. }
  94. Post_PetriNets_Runtime/Transition rhs_cp2t_t2 {
  95. label = "4"
  96. }
  97. Post_D2R_PlaceLink (rhs_cp2t_p, rhs_cp2t_p2){
  98. label = "5"
  99. }
  100. Post_D2R_TransitionLink (rhs_cp2t_t, rhs_cp2t_t2){
  101. label = "6"
  102. }
  103. Post_PetriNets_Runtime/P2T rhs_cp2t_p2t2(rhs_cp2t_p2, rhs_cp2t_t2) {
  104. label = "7"
  105. action = $
  106. include "primitives.alh"
  107. include "modelling.alh"
  108. Void function action(host_model : Element, name : String, mapping : Element):
  109. instantiate_attribute(host_model, name, "weight", read_attribute(host_model, mapping["2"], "weight"))
  110. return!
  111. $
  112. }
  113. }
  114. }
  115. {Contains} ForAll copy_T2P {
  116. LHS {
  117. Pre_PetriNets/Place ct2p_p{
  118. label = "0"
  119. }
  120. Pre_PetriNets/Transition ct2p_t{
  121. label = "1"
  122. }
  123. Pre_PetriNets/T2P (ct2p_t, ct2p_p){
  124. label = "2"
  125. }
  126. Pre_PetriNets_Runtime/Place ct2p_p2{
  127. label = "3"
  128. }
  129. Pre_PetriNets_Runtime/Transition ct2p_t2{
  130. label = "4"
  131. }
  132. Pre_D2R_PlaceLink (ct2p_p, ct2p_p2){
  133. label = "5"
  134. }
  135. Pre_D2R_TransitionLink (ct2p_t, ct2p_t2){
  136. label = "6"
  137. }
  138. }
  139. RHS {
  140. Post_PetriNets/Place rhs_ct2p_p{
  141. label = "0"
  142. }
  143. Post_PetriNets/Transition rhs_ct2p_t{
  144. label = "1"
  145. }
  146. Post_PetriNets/T2P (rhs_ct2p_t, rhs_ct2p_p){
  147. label = "2"
  148. }
  149. Post_PetriNets_Runtime/Place rhs_ct2p_p2 {
  150. label = "3"
  151. }
  152. Post_PetriNets_Runtime/Transition rhs_ct2p_t2 {
  153. label = "4"
  154. }
  155. Post_D2R_PlaceLink (rhs_ct2p_p, rhs_ct2p_p2){
  156. label = "5"
  157. }
  158. Post_D2R_TransitionLink (rhs_ct2p_t, rhs_ct2p_t2){
  159. label = "6"
  160. }
  161. Post_PetriNets_Runtime/T2P (rhs_ct2p_t2, rhs_ct2p_p2) {
  162. label = "7"
  163. action = $
  164. include "primitives.alh"
  165. include "modelling.alh"
  166. Void function action(host_model : Element, name : String, mapping : Element):
  167. instantiate_attribute(host_model, name, "weight", read_attribute(host_model, mapping["2"], "weight"))
  168. return!
  169. $
  170. }
  171. }
  172. }
  173. }
  174. OnSuccess (copy_places, copy_transitions) {}
  175. OnSuccess (copy_transitions, copy_P2T) {}
  176. OnSuccess (copy_P2T, copy_T2P) {}
  177. OnSuccess (copy_T2P, success) {}
  178. OnFailure (copy_places, copy_transitions) {}
  179. OnFailure (copy_transitions, copy_P2T) {}
  180. OnFailure (copy_P2T, copy_T2P) {}
  181. OnFailure (copy_T2P, success) {}
  182. Initial (schedule, copy_places) {}
  183. }
  184. export annotate to models/pn_annotate