simplepdltopetrinet.atl 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. -- @path simplepdl=/BenchSimplePDL2PetriNet/SimplePDLSemantics_updated.ecore
  2. -- @path petrinet=/BenchSimplePDL2PetriNet/PetriNetSemantics_updated.ecore
  3. module simplepdltopetrinet;
  4. create OUT: petrinet from IN: simplepdl;
  5. -- Process -> PetriNet
  6. rule Process2PetriNet {
  7. from
  8. p: simplepdl!Process
  9. to
  10. --Petri net creation (sufficient for flat exemple, should be a bit modified for the nested version)
  11. pn: petrinet!PetriNet (
  12. name <- p.name,
  13. nodes <- simplepdl!WorkDefinition.allInstances()->collect(pl | thisModule.resolveTemp(pl,'p_ready')) -- WD2PN nodes
  14. .union(simplepdl!WorkDefinition.allInstances()->collect(tr | thisModule.resolveTemp(tr,'t_start')))
  15. .union(simplepdl!WorkDefinition.allInstances()->collect(pl | thisModule.resolveTemp(pl,'p_started')))
  16. .union(simplepdl!WorkDefinition.allInstances()->collect(pl | thisModule.resolveTemp(pl,'p_running')))
  17. .union(simplepdl!WorkDefinition.allInstances()->collect(tr | thisModule.resolveTemp(tr,'t_finish')))
  18. .union(simplepdl!WorkDefinition.allInstances()->collect(pl | thisModule.resolveTemp(pl,'p_finished')))
  19. .append(p_ready) -- P2PN nodes
  20. .append(t_start)
  21. .append(p_running)
  22. .append(t_finish)
  23. .append(p_finished)
  24. ,
  25. arcs <- simplepdl!WorkDefinition.allInstances()->collect(a | thisModule.resolveTemp(a,'a_ready2start')) -- WD2PN arcs
  26. .union(simplepdl!WorkDefinition.allInstances()->collect(a | thisModule.resolveTemp(a,'a_start2started')))
  27. .union(simplepdl!WorkDefinition.allInstances()->collect(a | thisModule.resolveTemp(a,'a_start2running')))
  28. .union(simplepdl!WorkDefinition.allInstances()->collect(a | thisModule.resolveTemp(a,'a_running2finish')))
  29. .union(simplepdl!WorkDefinition.allInstances()->collect(a | thisModule.resolveTemp(a,'a_finish2finished')))
  30. .union(simplepdl!WorkDefinition.allInstances()->collect(a | thisModule.resolveTemp(a,'a_distribute')))
  31. .union(simplepdl!WorkDefinition.allInstances()->collect(a | thisModule.resolveTemp(a,'a_rejoin')))
  32. .union(simplepdl!WorkSequence.allInstances()->collect(a | thisModule.resolveTemp(a,'a_ws'))) -- WS2PN arc
  33. .append(a_ready2start) -- P2PN arcs
  34. .append(a_start2running)
  35. .append(a_running2finish)
  36. .append(a_finish2finished)
  37. ),
  38. -- Process PLACES
  39. p_ready: petrinet!Place (
  40. name <- p.name + '_ready',
  41. initialMarking <- 1
  42. ),
  43. p_running: petrinet!Place (
  44. name <- p.name + '_running',
  45. initialMarking <- 0
  46. ),
  47. p_finished: petrinet!Place (
  48. name <- p.name + '_finished',
  49. initialMarking <- 0
  50. ),
  51. -- Process TRANSITIONS
  52. t_start: petrinet!Transition (
  53. name <- p.name + '_start',
  54. min_time <- 0,
  55. max_time <- 0
  56. ),
  57. t_finish: petrinet!Transition (
  58. name <- p.name + '_finish',
  59. min_time <- 0,
  60. max_time <- 0
  61. ),
  62. -- Process ARCS
  63. a_ready2start: petrinet!Arc (
  64. source <- p_ready,
  65. target <- t_start,
  66. weight <- 1,
  67. kind <- #normal
  68. ),
  69. a_start2running: petrinet!Arc (
  70. source <- t_start,
  71. target <- p_running,
  72. weight <- 1,
  73. kind <- #normal
  74. ),
  75. a_running2finish: petrinet!Arc (
  76. source <- p_running,
  77. target <- t_finish,
  78. weight <- 1,
  79. kind <- #normal
  80. ),
  81. a_finish2finished: petrinet!Arc (
  82. source <- t_finish,
  83. target <- p_finished,
  84. weight <- 1,
  85. kind <- #normal
  86. )
  87. -- nested case
  88. --if (p.from!=null)
  89. --then
  90. --ain: petrinet!Arc (
  91. -- source <- thisModule.resolveTemp(p.from, 't_start'),
  92. -- target <- p_ready,
  93. -- weight <- 1,
  94. -- kind <- #read_arc
  95. --),
  96. --aout: petrinet!Arc (
  97. -- source <- p_finished,
  98. -- target <- thisModule.resolveTemp(p.from, 't_finish'),
  99. -- weight <- 1,
  100. -- kind <- #read_arc
  101. --)
  102. --else
  103. --endif
  104. }
  105. -- WorkDefinition -> PetriNet
  106. rule WorkDefinition2PetriNet {
  107. from
  108. wd: simplepdl!WorkDefinition
  109. to
  110. -- WorkDefinition PLACES
  111. p_ready: petrinet!Place (
  112. name <- wd.name + '_ready',
  113. initialMarking <- 1
  114. ),
  115. p_started: petrinet!Place (
  116. name <- wd.name + '_started',
  117. initialMarking <- 0
  118. ),
  119. -- place that allows to memorize a task has been started
  120. p_running: petrinet!Place (
  121. name <- wd.name + '_running',
  122. initialMarking <- 0
  123. ),
  124. p_finished: petrinet!Place (
  125. name <- wd.name + '_finished',
  126. initialMarking <- 0
  127. ),
  128. -- WorkDefinition TRANSITIONS
  129. t_start: petrinet!Transition (
  130. name <- wd.name + '_start',
  131. min_time <- 0,
  132. max_time <- 0
  133. ),
  134. t_finish: petrinet!Transition (
  135. name <- wd.name + '_finish',
  136. min_time <- 0,
  137. max_time <- 0
  138. ),
  139. -- WorkDefinition ARCS
  140. a_ready2start: petrinet!Arc (
  141. source <- p_ready,
  142. target <- t_start,
  143. weight <- 1,
  144. kind <- #normal
  145. ),
  146. a_start2started: petrinet!Arc (
  147. source <- t_start,
  148. target <- p_started,
  149. weight <- 1,
  150. kind <- #normal
  151. ),
  152. a_start2running: petrinet!Arc (
  153. source <- t_start,
  154. target <- p_running,
  155. weight <- 1,
  156. kind <- #normal
  157. ),
  158. a_running2finish: petrinet!Arc (
  159. source <- p_running,
  160. target <- t_finish,
  161. weight <- 1,
  162. kind <- #normal
  163. ),
  164. a_finish2finished: petrinet!Arc (
  165. source <- t_finish,
  166. target <- p_finished,
  167. weight <- 1,
  168. kind <- #normal
  169. ),
  170. -- synchonization ARCS (case of a process described by activities)
  171. a_distribute: petrinet!Arc (
  172. source <- thisModule.resolveTemp(wd.parent, 't_start'),
  173. target <- p_ready,
  174. weight <- 1,
  175. kind <- #normal
  176. ),
  177. a_rejoin: petrinet!Arc(
  178. source <- p_finished,
  179. target <- thisModule.resolveTemp(wd.parent, 't_finish'),
  180. weight <- 1,
  181. kind <- #read_arc
  182. )
  183. }
  184. -- WorkSequence -> PetriNet
  185. rule WorkSequence2PetriNet {
  186. from
  187. ws: simplepdl!WorkSequence
  188. to
  189. -- WorkSequence ARC
  190. a_ws: petrinet!Arc (
  191. source <- if (ws.linkType = #finishToStart or ws.linkType = #finishToFinish)
  192. then
  193. thisModule.resolveTemp(ws.predecessor, 'p_finished')
  194. else
  195. thisModule.resolveTemp(ws.predecessor, 'p_started')
  196. endif,
  197. target <- if (ws.linkType = #startToFinish or ws.linkType = #finishToFinish)
  198. then
  199. thisModule.resolveTemp(ws.successor, 't_finish')
  200. else
  201. thisModule.resolveTemp(ws.successor, 't_start')
  202. endif,
  203. weight <- 1,
  204. kind <- #read_arc
  205. )
  206. }