ps_to_devs.mvc 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546
  1. include "primitives.alh"
  2. include "modelling.alh"
  3. include "object_operations.alh"
  4. include "mini_modify.alh"
  5. Composite schedule {
  6. {Contains} Success success {}
  7. {Contains} Failure failure {}
  8. {Contains} Atomic init {
  9. LHS {}
  10. RHS {
  11. Post_ParallelDEVS/CoupledDEVSBlock {
  12. label = "root"
  13. value_name = $
  14. String function value(model : Element, name : String, mapping : Element):
  15. return "Root"!
  16. $
  17. }
  18. Post_ParallelDEVS/AtomicDEVSBlock init_convbelt {
  19. label = "convbelt"
  20. value_name = $
  21. String function value(model : Element, name : String, mapping : Element):
  22. return "ConveyorBelt"!
  23. $
  24. value_initialState = $
  25. String function value(model : Element, name : String, mapping : Element):
  26. return "\t\treturn {'name': 'waiting', 'product': None}"!
  27. $
  28. value_intTransition = $
  29. String function value(model : Element, name : String, mapping : Element):
  30. return "\t\tif self.state['name'] == 'transporting':\n\t\t\tself.state['name'] == 'waiting'\n\t\treturn self.state"!
  31. $
  32. value_outputFnc = $
  33. String function value(model : Element, name : String, mapping : Element):
  34. return "\t\treturn {self.my_ports['conv_out']: [self.state['product']]}"!
  35. $
  36. value_extTransition = $
  37. String function value(model : Element, name : String, mapping : Element):
  38. return "\t\tif self.state['name'] == 'waiting':\n\t\t\tself.state['product'] = my_inputs[self.my_ports['conv_in']][0]\n\t\t\tself.state['name'] = 'transporting'\n\t\treturn self.state"!
  39. $
  40. value_confTransition = $
  41. String function value(model : Element, name : String, mapping : Element):
  42. return "\t\treturn AtomicDEVS.confTransition(self, my_inputs)"!
  43. $
  44. value_timeAdvance = $
  45. String function value(model : Element, name : String, mapping : Element):
  46. return "\t\tif self.state['name'] == 'waiting':\n\t\t\treturn INFINITY\n\t\telif self.state['name'] == 'transporting':\n\t\t\treturn 1"!
  47. $
  48. }
  49. Post_ParallelDEVS/InputPort init_iport {
  50. label = "iport"
  51. value_name = $
  52. String function value(model : Element, name : String, mapping : Element):
  53. return "conv_in"!
  54. $
  55. }
  56. Post_ParallelDEVS/DEVSBlockToPort(init_convbelt, init_iport) {
  57. label = "convbelt_to_iport"
  58. }
  59. Post_ParallelDEVS/OutputPort init_oport {
  60. label = "oport"
  61. value_name = $
  62. String function value(model : Element, name : String, mapping : Element):
  63. return "conv_out"!
  64. $
  65. }
  66. Post_ParallelDEVS/DEVSBlockToPort(init_convbelt, init_oport) {
  67. label = "convbelt_to_oport"
  68. }
  69. Post_ParallelDEVS/AtomicDEVSBlock init_op {
  70. label = "op"
  71. value_name = $
  72. String function value(model : Element, name : String, mapping : Element):
  73. return "Operator"!
  74. $
  75. value_initialState = $
  76. String function value(model : Element, name : String, mapping : Element):
  77. return "\t\treturn {'name': 'waiting', 'req_queue': [], 'query_queue': [], 'requester': None}"!
  78. $
  79. value_intTransition = $
  80. String function value(model : Element, name : String, mapping : Element):
  81. return "\t\tif self.state['name'] == 'requested':\n\t\t\tself.state['name'] = 'allocating'\n\t\t\tself.state['requester'] = self.state['req_queue'].pop()\n\t\telif self.state['name'] == 'allocating':\n\t\t\tself.state['name'] = 'allocated'\n\t\tif self.state['query_queue']:\n\t\t\tself.state['query_queue'] = []\n\t\treturn self.state"!
  82. $
  83. value_outputFnc = $
  84. String function value(model : Element, name : String, mapping : Element):
  85. return "\t\toutput = {}\n\t\tif self.state['query_queue']:\n\t\t\toutput[self.my_ports['op_out']] = []\n\t\t\tfor it in self.state['query_queue']:\n\t\t\t\toutput[self.my_ports['op_out']].append({'type': 'response', 'req_name': it, 'op_name': id(self), 'free': self.state['name'] == 'waiting'})\n\t\tif self.state['name'] == 'allocating':\n\t\t\tif self.my_ports['op_out'] in output:\n\t\t\t\toutput[self.my_ports['op_out']].append({'type': 'allocate', 'req_name': self.state['requester'], 'op_name': id(self)})\n\t\t\telse:\n\t\t\t\toutput[self.my_ports['op_out']] = [({'type': 'allocate', 'req_name': self.state['requester'], 'op_name': id(self)})]\n\t\treturn output"!
  86. $
  87. value_extTransition = $
  88. String function value(model : Element, name : String, mapping : Element):
  89. return "\t\tmsgs = my_inputs[self.my_ports['op_in']]\n\t\trelease_msgs = [it for it in msgs if it['type'] == 'release' and it['op_name'] == id(self)]\n\t\treq_msgs = [it for it in msgs if it['type'] == 'request' and it['op_name'] == id(self)]\n\t\tquery_msgs = [it for it in msgs if it['type'] == 'query']\n\t\t\n\t\tif release_msgs:\n\t\t\tself.state['name'] = 'requested' if self.state['req_queue'] else 'waiting'\n\t\tfor r_m in req_msgs:\n\t\t\tself.state['req_queue'].append(r_m['req_name'])\n\t\t\tself.state['name'] = 'requested'\n\t\tfor q_m in query_msgs:\n\t\t\tself.state['query_queue'].append(q_m['req_name'])\n\t\treturn self.state"!
  90. $
  91. value_confTransition = $
  92. String function value(model : Element, name : String, mapping : Element):
  93. return "\t\treturn AtomicDEVS.confTransition(self, my_inputs)"!
  94. $
  95. value_timeAdvance = $
  96. String function value(model : Element, name : String, mapping : Element):
  97. return "\t\tif self.state['query_queue']:\n\t\t\treturn 0\n\t\telif self.state['name'] == 'waiting':\n\t\t\treturn INFINITY\n\t\telif self.state['name'] == 'requested':\n\t\t\treturn 0\n\t\telif self.state['name'] == 'allocating':\n\t\t\treturn 0\n\t\telif self.state['name'] == 'allocated':\n\t\t\treturn INFINITY"!
  98. $
  99. }
  100. Post_ParallelDEVS/InputPort init_op_iport {
  101. label = "op_iport"
  102. value_name = $
  103. String function value(model : Element, name : String, mapping : Element):
  104. return "op_in"!
  105. $
  106. }
  107. Post_ParallelDEVS/DEVSBlockToPort(init_op, init_op_iport) {
  108. label = "op_to_op_iport"
  109. }
  110. Post_ParallelDEVS/OutputPort init_op_oport {
  111. label = "op_oport"
  112. value_name = $
  113. String function value(model : Element, name : String, mapping : Element):
  114. return "op_out"!
  115. $
  116. }
  117. Post_ParallelDEVS/DEVSBlockToPort(init_op, init_op_oport) {
  118. label = "op_to_op_oport"
  119. }
  120. }
  121. }
  122. {Contains} ForAll gen_to_adevs {
  123. LHS {
  124. Pre_ProductionSystem/Generator gen_to_adevs_pre_gen {
  125. label = "gen"
  126. }
  127. Pre_ProductionSystem/Part gen_to_adevs_pre_part {
  128. label = "part"
  129. }
  130. Pre_ProductionSystem/Gen_To_Part(gen_to_adevs_pre_gen, gen_to_adevs_pre_part) {
  131. label = "gen_to_part"
  132. }
  133. Pre_ParallelDEVS/CoupledDEVSBlock gen_to_adevs_pre_root {
  134. label = "root"
  135. constraint_name = $
  136. Boolean function constraint(value: String):
  137. return (value == "Root")!
  138. $
  139. }
  140. }
  141. RHS {
  142. Post_ProductionSystem/Generator gen_to_adevs_post_gen {
  143. label = "gen"
  144. }
  145. Post_ProductionSystem/Part gen_to_adevs_post_part {
  146. label = "part"
  147. }
  148. Post_ProductionSystem/Gen_To_Part(gen_to_adevs_post_gen, gen_to_adevs_post_part) {
  149. label = "gen_to_part"
  150. }
  151. Post_ParallelDEVS/AtomicDEVSBlock gen_to_adevs_post_adevs {
  152. label = "adevs"
  153. value_name = $
  154. String function value(model : Element, name : String, mapping : Element):
  155. return list_read(string_split(mapping["gen"], "/"), 1)!
  156. $
  157. value_initialState = $
  158. String function value(model : Element, name : String, mapping : Element):
  159. return "\t\treturn {'name': 'generating'}"!
  160. $
  161. value_intTransition = $
  162. String function value(model : Element, name : String, mapping : Element):
  163. return "\t\treturn AtomicDEVS.intTransition(self)"!
  164. $
  165. value_outputFnc = $
  166. String function value(model : Element, name : String, mapping : Element):
  167. return "\t\tif self.state['name'] == 'generating':\n\t\t\tnew_item = {'type': '" + cast_i2s(list_read(string_split(read_type(model, mapping["part"]), "/"), 1)) + "', 'broken': False}\n\t\t\tnew_item['id'] = id(new_item)\n\t\t\treturn {self.my_ports['g_out']: [new_item]}"!
  168. $
  169. value_extTransition = $
  170. String function value(model : Element, name : String, mapping : Element):
  171. return "\t\treturn AtomicDEVS.extTransition(self, my_inputs)"!
  172. $
  173. value_confTransition = $
  174. String function value(model : Element, name : String, mapping : Element):
  175. return "\t\treturn AtomicDEVS.confTransition(self, my_inputs)"!
  176. $
  177. value_timeAdvance = $
  178. String function value(model : Element, name : String, mapping : Element):
  179. return "\t\tif self.state['name'] == 'generating':\n\t\t\treturn 1"!
  180. $
  181. }
  182. Post_ParallelDEVS/OutputPort gen_to_adevs_post_port {
  183. label = "port"
  184. value_name = $
  185. String function value(model : Element, name : String, mapping : Element):
  186. return "g_out"!
  187. $
  188. }
  189. Post_ParallelDEVS/DEVSBlockToPort(gen_to_adevs_post_adevs, gen_to_adevs_post_port) {
  190. label = "gen_to_port"
  191. }
  192. Post_ParallelDEVS/DEVSInstance gen_to_adevs_post_devsi {
  193. label = "devsi"
  194. value_type = $
  195. String function value(model : Element, name : String, mapping : Element):
  196. return list_read(string_split(mapping["gen"], "/"), 1)!
  197. $
  198. value_name = $
  199. String function value(model : Element, name : String, mapping : Element):
  200. return (cast_i2s(list_read(string_split(mapping["gen"], "/"), 1)) + "_i")!
  201. $
  202. }
  203. Post_ParallelDEVS/OutputPort gen_to_adevs_post_porti {
  204. label = "porti"
  205. value_name = $
  206. String function value(model : Element, name : String, mapping : Element):
  207. return "g_out"!
  208. $
  209. }
  210. Post_ParallelDEVS/DEVSInstanceToPort(gen_to_adevs_post_devsi, gen_to_adevs_post_porti) {
  211. label = "devsi_to_porti"
  212. }
  213. Post_ParallelDEVS/CoupledDEVSBlock gen_to_adevs_post_root {
  214. label = "root"
  215. }
  216. Post_ParallelDEVS/SubModel(gen_to_adevs_post_root, gen_to_adevs_post_devsi) {
  217. label = "root_to_devsi"
  218. }
  219. Post_PS2DEVS_typelink(gen_to_adevs_post_gen, gen_to_adevs_post_adevs) {
  220. label = "typelink"
  221. }
  222. Post_PS2DEVS_instancelink(gen_to_adevs_post_gen, gen_to_adevs_post_devsi) {
  223. label = "instancelink"
  224. }
  225. }
  226. }
  227. {Contains} ForAll coll_to_adevs {
  228. LHS {
  229. Pre_ProductionSystem/Collector coll_to_adevs_pre_coll {
  230. label = "coll"
  231. }
  232. Pre_ParallelDEVS/CoupledDEVSBlock coll_to_adevs_pre_root {
  233. label = "root"
  234. constraint_name = $
  235. Boolean function constraint(value: String):
  236. return (value == "Root")!
  237. $
  238. }
  239. }
  240. RHS {
  241. Post_ProductionSystem/Collector coll_to_adevs_post_coll {
  242. label = "coll"
  243. }
  244. Post_ParallelDEVS/AtomicDEVSBlock coll_to_adevs_post_adevs {
  245. label = "adevs"
  246. value_name = $
  247. String function value(model : Element, name : String, mapping : Element):
  248. return list_read(string_split(mapping["coll"], "/"), 1)!
  249. $
  250. value_initialState = $
  251. String function value(model : Element, name : String, mapping : Element):
  252. return "\t\treturn {'name': 'collecting', 'WarAPCs': 0, 'RiotAPCS': 0}"!
  253. $
  254. value_intTransition = $
  255. String function value(model : Element, name : String, mapping : Element):
  256. return "\t\treturn AtomicDEVS.intTransition(self)"!
  257. $
  258. value_outputFnc = $
  259. String function value(model : Element, name : String, mapping : Element):
  260. return "\t\treturn AtomicDEVS.outputFnc(self)"!
  261. $
  262. value_extTransition = $
  263. String function value(model : Element, name : String, mapping : Element):
  264. return "\t\tif (my_inputs[self.my_ports['c_in']][0]['type'] == 'WarAPC'):\n\t\t\tself.state['WarAPCs'] += 1\n\t\telif (my_inputs[self.my_ports['c_in']][0]['type'] == 'RiotAPC'):\n\t\t\tself.state['RiotAPCs'] += 1\n\t\treturn self.state"!
  265. $
  266. value_confTransition = $
  267. String function value(model : Element, name : String, mapping : Element):
  268. return "\t\treturn AtomicDEVS.confTransition(self, my_inputs)"!
  269. $
  270. value_timeAdvance = $
  271. String function value(model : Element, name : String, mapping : Element):
  272. return "\t\tif self.state['name'] == 'collecting':\n\t\t\treturn INFINITY"!
  273. $
  274. }
  275. Post_ParallelDEVS/InputPort coll_to_adevs_post_port {
  276. label = "port"
  277. value_name = $
  278. String function value(model : Element, name : String, mapping : Element):
  279. return "c_in"!
  280. $
  281. }
  282. Post_ParallelDEVS/DEVSBlockToPort(coll_to_adevs_post_adevs, coll_to_adevs_post_port) {
  283. label = "coll_to_port"
  284. }
  285. Post_ParallelDEVS/DEVSInstance coll_to_adevs_post_devsi {
  286. label = "devsi"
  287. value_type = $
  288. String function value(model : Element, name : String, mapping : Element):
  289. return list_read(string_split(mapping["coll"], "/"), 1)!
  290. $
  291. value_name = $
  292. String function value(model : Element, name : String, mapping : Element):
  293. return (cast_i2s(list_read(string_split(mapping["coll"], "/"), 1)) + "_i")!
  294. $
  295. }
  296. Post_ParallelDEVS/InputPort coll_to_adevs_post_porti {
  297. label = "porti"
  298. value_name = $
  299. String function value(model : Element, name : String, mapping : Element):
  300. return "c_in"!
  301. $
  302. }
  303. Post_ParallelDEVS/DEVSInstanceToPort(coll_to_adevs_post_devsi, coll_to_adevs_post_porti) {
  304. label = "devsi_to_porti"
  305. }
  306. Post_ParallelDEVS/CoupledDEVSBlock coll_to_adevs_post_root {
  307. label = "root"
  308. }
  309. Post_ParallelDEVS/SubModel(coll_to_adevs_post_root, coll_to_adevs_post_devsi) {
  310. label = "root_to_devsi"
  311. }
  312. Post_PS2DEVS_typelink(coll_to_adevs_post_coll, coll_to_adevs_post_adevs) {
  313. label = "typelink"
  314. }
  315. Post_PS2DEVS_instancelink(coll_to_adevs_post_coll, coll_to_adevs_post_devsi) {
  316. label = "instancelink"
  317. }
  318. }
  319. }
  320. {Contains} ForAll ass_to_adevs {
  321. LHS {
  322. Pre_ProductionSystem/Assembler ass_to_adevs_pre_ass {
  323. label = "ass"
  324. }
  325. Pre_ParallelDEVS/CoupledDEVSBlock ass_to_adevs_pre_root {
  326. label = "root"
  327. constraint_name = $
  328. Boolean function constraint(value: String):
  329. return (value == "Root")!
  330. $
  331. }
  332. }
  333. RHS {
  334. Post_ProductionSystem/Assembler ass_to_adevs_post_ass {
  335. label = "ass"
  336. }
  337. Post_ParallelDEVS/AtomicDEVSBlock ass_to_adevs_post_adevs {
  338. label = "adevs"
  339. value_name = $
  340. String function value(model : Element, name : String, mapping : Element):
  341. return list_read(string_split(mapping["ass"], "/"), 1)!
  342. $
  343. value_initialState = $
  344. String function value(model : Element, name : String, mapping : Element):
  345. return "\t\treturn {'name': 'waiting', 'queue': [], 'finishedProduct': None, 'op_name': None, 'op_to_send': None}"!
  346. $
  347. value_intTransition = $
  348. String function value(model : Element, name : String, mapping : Element):
  349. return "\t\tif self.state['name'] == 'producing':\n\t\t\tself.state['name'] = 'waiting'\n\t\telif self.state['name'] == 'sending_req_to_op':\n\t\t\tself.state['name'] = 'waiting_for_op'\n\t\treturn self.state"!
  350. $
  351. value_outputFnc = $
  352. String function value(model : Element, name : String, mapping : Element):
  353. return "\t\tif self.state['name'] == 'producing':\n\t\t\treturn {self.my_ports['ass_out']: [self.state['finishedProduct']], self.my_ports['ass_op_out']: [{'type': 'release', 'op_name': self.state['op_name']}]}\n\t\telif self.state['name'] == 'looking_for_op':\n\t\t\treturn {self.my_ports['ass_op_out']: [{'type': 'query', 'req_name': id(self)}]}\n\t\telif self.state['name'] == 'sending_req_to_op':\n\t\t\treturn {self.my_ports['ass_op_out']: [{'type': 'request', 'req_name': id(self), 'op_name': self.state['op_to_send']}]}\n\t\telse:\n\t\t\treturn AtomicDEVS.outputFnc(self)"!
  354. $
  355. value_extTransition = $
  356. String function value(model : Element, name : String, mapping : Element):
  357. return "\t\tif self.state['name'] == 'producing':\n\t\t\tself.wait_time -= self.elapsed\n\t\t\n\t\timport helpers, random\n\t\tif self.my_ports['ass_in'] in my_inputs:\n\t\t\tself.state['queue'].extend([i['type'] for i in my_inputs[self.my_ports['ass_in']]])\n\t\t\tif (self.state['name'] == 'waiting' and (helpers.canWarAPC(self.state['queue']) or helpers.canRiotAPC(self.state['queue']))):\n\t\t\t\tself.state['name'] = 'looking_for_op'\n\t\tif self.state['name'] == 'looking_for_op' and self.my_ports['ass_op_in'] in my_inputs:\n\t\t\tmsgs = my_inputs[self.my_ports['ass_op_in']]\n\t\t\tfree = [msg['op_name'] for msg in msgs if msg['req_name'] == id(self) and msg['type'] == 'response' and msg['free']]\n\t\t\tnotfree = [msg['op_name'] for msg in msgs if msg['req_name'] == id(self) and msg['type'] == 'response' and not msg['free']]\n\t\t\tif free:\n\t\t\t\tself.state['op_to_send'] = free[0]\n\t\t\telse:\n\t\t\t\tself.state['op_to_send'] = notfree[0]\n\t\t\tself.state['name'] = 'sending_req_to_op'\n\t\telif self.state['name'] == 'waiting_for_op' and self.my_ports['ass_op_in'] in my_inputs:\n\t\t\tforme = [msg for msg in my_inputs[self.my_ports['ass_op_in']] if msg['req_name'] == id(self) and msg['type'] == 'allocate']\n\t\t\tif forme:\n\t\t\t\tself.state['op_name'] = my_inputs[self.my_ports['ass_op_in']][0]['op_name']\n\t\t\t\tif helpers.isWarAPC(self.state['queue']):\n\t\t\t\t\tself.state['finishedProduct'] = {'type': 'WarAPC', 'broken': (random.random() < 0.05)}\n\t\t\t\telif helpers.isRiotAPC(self.state['queue']):\n\t\t\t\t\tself.state['finishedProduct'] = {'type': 'RiotAPC', 'broken': (random.random() < 0.05)}\n\t\t\t\tself.state['name'] = 'producing'\n\t\t\t\tself.wait_time = 2\n\t\treturn self.state"!
  358. $
  359. value_confTransition = $
  360. String function value(model : Element, name : String, mapping : Element):
  361. return "\t\treturn AtomicDEVS.confTransition(self, my_inputs)"!
  362. $
  363. value_timeAdvance = $
  364. String function value(model : Element, name : String, mapping : Element):
  365. return "\t\tif self.state['name'] == 'waiting':\n\t\t\treturn INFINITY\n\t\telif self.state['name'] == 'looking_for_op':\n\t\t\treturn 0\n\t\telif self.state['name'] == 'sending_req_to_op':\n\t\t\treturn 0\n\t\telif self.state['name'] == 'waiting_for_op':\n\t\t\treturn INFINITY\n\t\telif self.state['name'] == 'producing':\n\t\t\treturn self.wait_time"!
  366. $
  367. }
  368. Post_ParallelDEVS/InputPort ass_to_adevs_post_iport {
  369. label = "iport"
  370. value_name = $
  371. String function value(model : Element, name : String, mapping : Element):
  372. return "ass_in"!
  373. $
  374. }
  375. Post_ParallelDEVS/DEVSBlockToPort(ass_to_adevs_post_adevs, ass_to_adevs_post_iport) {
  376. label = "ass_to_iport"
  377. }
  378. Post_ParallelDEVS/InputPort ass_to_adevs_post_iport_op {
  379. label = "iport_op"
  380. value_name = $
  381. String function value(model : Element, name : String, mapping : Element):
  382. return "ass_op_in"!
  383. $
  384. }
  385. Post_ParallelDEVS/DEVSBlockToPort(ass_to_adevs_post_adevs, ass_to_adevs_post_iport_op) {
  386. label = "ass_to_iport_op"
  387. }
  388. Post_ParallelDEVS/OutputPort ass_to_adevs_post_oport {
  389. label = "oport"
  390. value_name = $
  391. String function value(model : Element, name : String, mapping : Element):
  392. return "ass_out"!
  393. $
  394. }
  395. Post_ParallelDEVS/DEVSBlockToPort(ass_to_adevs_post_adevs, ass_to_adevs_post_oport) {
  396. label = "ass_to_oport"
  397. }
  398. Post_ParallelDEVS/OutputPort ass_to_adevs_post_oport_op {
  399. label = "oport_op"
  400. value_name = $
  401. String function value(model : Element, name : String, mapping : Element):
  402. return "ass_op_out"!
  403. $
  404. }
  405. Post_ParallelDEVS/DEVSBlockToPort(ass_to_adevs_post_adevs, ass_to_adevs_post_oport_op) {
  406. label = "ass_to_oport_op"
  407. }
  408. Post_ParallelDEVS/DEVSInstance ass_to_adevs_post_devsi {
  409. label = "devsi"
  410. value_type = $
  411. String function value(model : Element, name : String, mapping : Element):
  412. return list_read(string_split(mapping["ass"], "/"), 1)!
  413. $
  414. value_name = $
  415. String function value(model : Element, name : String, mapping : Element):
  416. return (cast_i2s(list_read(string_split(mapping["ass"], "/"), 1)) + "_i")!
  417. $
  418. }
  419. Post_ParallelDEVS/InputPort ass_to_adevs_post_iporti {
  420. label = "iporti"
  421. value_name = $
  422. String function value(model : Element, name : String, mapping : Element):
  423. return "ass_in"!
  424. $
  425. }
  426. Post_ParallelDEVS/DEVSInstanceToPort(ass_to_adevs_post_devsi, ass_to_adevs_post_iporti) {
  427. label = "devsi_to_iporti"
  428. }
  429. Post_ParallelDEVS/InputPort ass_to_adevs_post_iporti_op {
  430. label = "iporti_op"
  431. value_name = $
  432. String function value(model : Element, name : String, mapping : Element):
  433. return "ass_op_in"!
  434. $
  435. }
  436. Post_ParallelDEVS/DEVSInstanceToPort(ass_to_adevs_post_devsi, ass_to_adevs_post_iporti_op) {
  437. label = "devsi_to_iporti_op"
  438. }
  439. Post_ParallelDEVS/OutputPort ass_to_adevs_post_oporti {
  440. label = "oporti"
  441. value_name = $
  442. String function value(model : Element, name : String, mapping : Element):
  443. return "ass_out"!
  444. $
  445. }
  446. Post_ParallelDEVS/DEVSInstanceToPort(ass_to_adevs_post_devsi, ass_to_adevs_post_oporti) {
  447. label = "devsi_to_oporti"
  448. }
  449. Post_ParallelDEVS/OutputPort ass_to_adevs_post_oporti_op {
  450. label = "oporti_op"
  451. value_name = $
  452. String function value(model : Element, name : String, mapping : Element):
  453. return "ass_op_out"!
  454. $
  455. }
  456. Post_ParallelDEVS/DEVSInstanceToPort(ass_to_adevs_post_devsi, ass_to_adevs_post_oporti_op) {
  457. label = "devsi_to_oporti_op"
  458. }
  459. Post_ParallelDEVS/CoupledDEVSBlock ass_to_adevs_post_root {
  460. label = "root"
  461. }
  462. Post_ParallelDEVS/SubModel(ass_to_adevs_post_root, ass_to_adevs_post_devsi) {
  463. label = "root_to_devsi"
  464. }
  465. Post_PS2DEVS_typelink(ass_to_adevs_post_ass, ass_to_adevs_post_adevs) {
  466. label = "typelink"
  467. }
  468. Post_PS2DEVS_instancelink(ass_to_adevs_post_ass, ass_to_adevs_post_devsi) {
  469. label = "instancelink"
  470. }
  471. }
  472. }
  473. {Contains} ForAll rep_to_adevs {
  474. LHS {
  475. Pre_ProductionSystem/Repair rep_to_adevs_pre_ass {
  476. label = "rep"
  477. }
  478. Pre_ParallelDEVS/CoupledDEVSBlock rep_to_adevs_pre_root {
  479. label = "root"
  480. constraint_name = $
  481. Boolean function constraint(value: String):
  482. return (value == "Root")!
  483. $
  484. }
  485. }
  486. RHS {
  487. Post_ProductionSystem/Repair rep_to_adevs_post_ass {
  488. label = "rep"
  489. }
  490. Post_ParallelDEVS/AtomicDEVSBlock rep_to_adevs_post_adevs {
  491. label = "adevs"
  492. value_name = $
  493. String function value(model : Element, name : String, mapping : Element):
  494. return list_read(string_split(mapping["rep"], "/"), 1)!
  495. $
  496. value_initialState = $
  497. String function value(model : Element, name : String, mapping : Element):
  498. return "\t\treturn {'name': 'waiting', 'item': None, 'op_to_send': None, 'op_name': None}"!
  499. $
  500. value_intTransition = $
  501. String function value(model : Element, name : String, mapping : Element):
  502. return "\t\tif self.state['name'] == 'repairing':\n\t\t\tself.state['name'] = 'waiting'\n\t\telif self.state['name'] == 'sending_req_to_op':\n\t\t\tself.state['name'] = 'waiting_for_op'\n\t\treturn self.state"!
  503. $
  504. value_outputFnc = $
  505. String function value(model : Element, name : String, mapping : Element):
  506. return "\t\tif self.state['name'] == 'repairing':\n\t\t\treturn {self.my_ports['rep_out']: [self.state['item']], self.my_ports['rep_op_out']: [{'type': 'release', 'op_name': self.state['op_name']}]}\n\t\telif self.state['name'] == 'looking_for_op':\n\t\t\treturn {self.my_ports['rep_op_out']: [{'type': 'query', 'req_name': id(self)}]}\n\t\telif self.state['name'] == 'sending_req_to_op':\n\t\t\treturn {self.my_ports['rep_op_out']: [{'type': 'request', 'req_name': id(self), 'op_name': self.state['op_to_send']}]}\n\t\telse:\n\t\t\treturn AtomicDEVS.outputFnc(self)"!
  507. $
  508. value_extTransition = $
  509. String function value(model : Element, name : String, mapping : Element):
  510. return "\t\tif self.state['name'] == 'repairing':\n\t\t\tself.wait_time -= self.elapsed\n\t\t\n\t\tif self.state['name'] == 'waiting' and self.my_ports['rep_in'] in my_inputs:\n\t\t\tself.state['item'] = my_inputs[self.my_ports['rep_in']][0]\n\t\t\tself.state['name'] = 'looking_for_op'\n\t\telif self.state['name'] == 'looking_for_op' and self.my_ports['rep_op_in'] in my_inputs:\n\t\t\tmsgs = my_inputs[self.my_ports['rep_op_in']]\n\t\t\tfree = [msg['op_name'] for msg in msgs if msg['req_name'] == id(self) and msg['type'] == 'response' and msg['free']]\n\t\t\tnotfree = [msg['op_name'] for msg in msgs if msg['req_name'] == id(self) and msg['type'] == 'response' and not msg['free']]\n\t\t\tif free:\n\t\t\t\tself.state['op_to_send'] = free[0]\n\t\t\telse:\n\t\t\t\tself.state['op_to_send'] = notfree[0]\n\t\t\tself.state['name'] = 'sending_req_to_op'\n\t\telif self.state['name'] == 'waiting_for_op' and self.my_ports['rep_op_in'] in my_inputs:\n\t\t\tforme = [msg for msg in my_inputs[self.my_ports['rep_op_in']] if msg['req_name'] == id(self) and msg['type'] == 'allocate']\n\t\t\tif forme:\n\t\t\t\tself.state['op_name'] = my_inputs[self.my_ports['rep_op_in']][0]['op_name']\t\t\t\t\n\t\t\t\tself.state['item']['broken'] = False\n\t\t\t\tself.state['name'] = 'repairing'\n\t\t\t\tself.wait_time = 2\n\t\treturn self.state"!
  511. $
  512. value_confTransition = $
  513. String function value(model : Element, name : String, mapping : Element):
  514. return "\t\treturn AtomicDEVS.confTransition(self, my_inputs)"!
  515. $
  516. value_timeAdvance = $
  517. String function value(model : Element, name : String, mapping : Element):
  518. return "\t\tif self.state['name'] == 'waiting':\n\t\t\treturn INFINITY\n\t\telif self.state['name'] == 'looking_for_op':\n\t\t\treturn 0\n\t\telif self.state['name'] == 'sending_req_to_op':\n\t\t\treturn 0\n\t\telif self.state['name'] == 'waiting_for_op':\n\t\t\treturn INFINITY\n\t\telif self.state['name'] == 'repairing':\n\t\t\treturn self.wait_time"!
  519. $
  520. }
  521. Post_ParallelDEVS/InputPort rep_to_adevs_post_iport {
  522. label = "iport"
  523. value_name = $
  524. String function value(model : Element, name : String, mapping : Element):
  525. return "rep_in"!
  526. $
  527. }
  528. Post_ParallelDEVS/DEVSBlockToPort(rep_to_adevs_post_adevs, rep_to_adevs_post_iport) {
  529. label = "rep_to_iport"
  530. }
  531. Post_ParallelDEVS/InputPort rep_to_adevs_post_iport_op {
  532. label = "iport_op"
  533. value_name = $
  534. String function value(model : Element, name : String, mapping : Element):
  535. return "rep_op_in"!
  536. $
  537. }
  538. Post_ParallelDEVS/DEVSBlockToPort(rep_to_adevs_post_adevs, rep_to_adevs_post_iport_op) {
  539. label = "rep_to_iport_op"
  540. }
  541. Post_ParallelDEVS/OutputPort rep_to_adevs_post_oport {
  542. label = "oport"
  543. value_name = $
  544. String function value(model : Element, name : String, mapping : Element):
  545. return "rep_out"!
  546. $
  547. }
  548. Post_ParallelDEVS/DEVSBlockToPort(rep_to_adevs_post_adevs, rep_to_adevs_post_oport) {
  549. label = "rep_to_oport"
  550. }
  551. Post_ParallelDEVS/OutputPort rep_to_adevs_post_oport_op {
  552. label = "oport_op"
  553. value_name = $
  554. String function value(model : Element, name : String, mapping : Element):
  555. return "rep_op_out"!
  556. $
  557. }
  558. Post_ParallelDEVS/DEVSBlockToPort(rep_to_adevs_post_adevs, rep_to_adevs_post_oport_op) {
  559. label = "rep_to_oport_op"
  560. }
  561. Post_ParallelDEVS/DEVSInstance rep_to_adevs_post_devsi {
  562. label = "devsi"
  563. value_type = $
  564. String function value(model : Element, name : String, mapping : Element):
  565. return list_read(string_split(mapping["rep"], "/"), 1)!
  566. $
  567. value_name = $
  568. String function value(model : Element, name : String, mapping : Element):
  569. return (cast_i2s(list_read(string_split(mapping["rep"], "/"), 1)) + "_i")!
  570. $
  571. }
  572. Post_ParallelDEVS/InputPort rep_to_adevs_post_iporti {
  573. label = "iporti"
  574. value_name = $
  575. String function value(model : Element, name : String, mapping : Element):
  576. return "rep_in"!
  577. $
  578. }
  579. Post_ParallelDEVS/DEVSInstanceToPort(rep_to_adevs_post_devsi, rep_to_adevs_post_iporti) {
  580. label = "devsi_to_iporti"
  581. }
  582. Post_ParallelDEVS/InputPort rep_to_adevs_post_iporti_op {
  583. label = "iporti_op"
  584. value_name = $
  585. String function value(model : Element, name : String, mapping : Element):
  586. return "rep_op_in"!
  587. $
  588. }
  589. Post_ParallelDEVS/DEVSInstanceToPort(rep_to_adevs_post_devsi, rep_to_adevs_post_iporti_op) {
  590. label = "devsi_to_iporti_op"
  591. }
  592. Post_ParallelDEVS/OutputPort rep_to_adevs_post_oporti {
  593. label = "oporti"
  594. value_name = $
  595. String function value(model : Element, name : String, mapping : Element):
  596. return "rep_out"!
  597. $
  598. }
  599. Post_ParallelDEVS/DEVSInstanceToPort(rep_to_adevs_post_devsi, rep_to_adevs_post_oporti) {
  600. label = "devsi_to_oporti"
  601. }
  602. Post_ParallelDEVS/OutputPort rep_to_adevs_post_oporti_op {
  603. label = "oporti_op"
  604. value_name = $
  605. String function value(model : Element, name : String, mapping : Element):
  606. return "rep_op_out"!
  607. $
  608. }
  609. Post_ParallelDEVS/DEVSInstanceToPort(rep_to_adevs_post_devsi, rep_to_adevs_post_oporti_op) {
  610. label = "devsi_to_oporti_op"
  611. }
  612. Post_ParallelDEVS/CoupledDEVSBlock rep_to_adevs_post_root {
  613. label = "root"
  614. }
  615. Post_ParallelDEVS/SubModel(rep_to_adevs_post_root, rep_to_adevs_post_devsi) {
  616. label = "root_to_devsi"
  617. }
  618. Post_PS2DEVS_typelink(rep_to_adevs_post_ass, rep_to_adevs_post_adevs) {
  619. label = "typelink"
  620. }
  621. Post_PS2DEVS_instancelink(rep_to_adevs_post_ass, rep_to_adevs_post_devsi) {
  622. label = "instancelink"
  623. }
  624. }
  625. }
  626. {Contains} ForAll qc_to_adevs {
  627. LHS {
  628. Pre_ProductionSystem/QualityControl qc_to_adevs_pre_qc {
  629. label = "qc"
  630. }
  631. Pre_ParallelDEVS/CoupledDEVSBlock qc_to_adevs_pre_root {
  632. label = "root"
  633. constraint_name = $
  634. Boolean function constraint(value: String):
  635. return (value == "Root")!
  636. $
  637. }
  638. }
  639. RHS {
  640. Post_ProductionSystem/QualityControl qc_to_adevs_post_qc {
  641. label = "qc"
  642. }
  643. Post_ParallelDEVS/AtomicDEVSBlock qc_to_adevs_post_adevs {
  644. label = "adevs"
  645. value_name = $
  646. String function value(model : Element, name : String, mapping : Element):
  647. return list_read(string_split(mapping["qc"], "/"), 1)!
  648. $
  649. value_initialState = $
  650. String function value(model : Element, name : String, mapping : Element):
  651. return "\t\treturn {'name': 'waiting', 'item': None}"!
  652. $
  653. value_intTransition = $
  654. String function value(model : Element, name : String, mapping : Element):
  655. return "\t\tif self.state['name'] == 'checking':\n\t\t\tself.state['name'] = 'waiting'\n\t\telif self.state['name'] == 'looking_for_op':\n\t\t\tself.state['name'] = 'waiting_for_op_query_answer'\n\t\telif self.state['name'] == 'sending_req_to_op':\n\t\t\tself.state['name'] = 'waiting_for_op'\n\t\treturn self.state"!
  656. $
  657. value_outputFnc = $
  658. String function value(model : Element, name : String, mapping : Element):
  659. return "\t\tif self.state['name'] == 'checking':\n\t\t\tif self.state['item']['broken']:\n\t\t\t\treturn {self.my_ports['qc_out_broken']: [self.state['item']], self.my_ports['qc_op_out']: [{'type': 'release', 'op_name': self.state['op_name']}]}\n\t\t\telse:\n\t\t\t\treturn {self.my_ports['qc_out_working']: [self.state['item']], self.my_ports['qc_op_out']: [{'type': 'release', 'op_name': self.state['op_name']}]}\n\t\telif self.state['name'] == 'looking_for_op':\n\t\t\treturn {self.my_ports['qc_op_out']: [{'type': 'query', 'req_name': id(self)}]}\n\t\telif self.state['name'] == 'sending_req_to_op':\n\t\t\treturn {self.my_ports['qc_op_out']: [{'type': 'request', 'req_name': id(self), 'op_name': self.state['op_to_send']}]}\n\t\telse:\n\t\t\treturn AtomicDEVS.outputFnc(self)"!
  660. $
  661. value_extTransition = $
  662. String function value(model : Element, name : String, mapping : Element):
  663. return "\t\tif self.state['name'] == 'repairing':\n\t\t\tself.wait_time -= self.elapsed\n\t\t\n\t\tif self.state['name'] == 'waiting' and self.my_ports['qc_in'] in my_inputs:\n\t\t\tself.state['item'] = my_inputs[self.my_ports['qc_in']][0]\n\t\t\tself.state['name'] = 'looking_for_op'\n\t\telif self.state['name'] == 'waiting_for_op_query_answer' and self.my_ports['qc_op_in'] in my_inputs:\n\t\t\tmsgs = my_inputs[self.my_ports['qc_op_in']]\n\t\t\tfree = [msg['op_name'] for msg in msgs if msg['req_name'] == id(self) and msg['type'] == 'response' and msg['free']]\n\t\t\tnotfree = [msg['op_name'] for msg in msgs if msg['req_name'] == id(self) and msg['type'] == 'response' and not msg['free']]\n\t\t\tif free:\n\t\t\t\tself.state['op_to_send'] = free[0]\n\t\t\telse:\n\t\t\t\tself.state['op_to_send'] = notfree[0]\n\t\t\tself.state['name'] = 'sending_req_to_op'\n\t\telif self.state['name'] == 'waiting_for_op' and self.my_ports['qc_op_in'] in my_inputs:\n\t\t\tforme = [msg for msg in my_inputs[self.my_ports['qc_op_in']] if msg['req_name'] == id(self) and msg['type'] == 'allocate']\n\t\t\tif forme:\n\t\t\t\tself.state['name'] = 'checking'\n\t\treturn self.state"!
  664. $
  665. value_confTransition = $
  666. String function value(model : Element, name : String, mapping : Element):
  667. return "\t\treturn AtomicDEVS.confTransition(self, my_inputs)"!
  668. $
  669. value_timeAdvance = $
  670. String function value(model : Element, name : String, mapping : Element):
  671. return "\t\tif self.state['name'] == 'waiting':\n\t\t\treturn INFINITY\n\t\telif self.state['name'] == 'looking_for_op':\n\t\t\treturn 0\n\t\telif self.state['name'] == 'sending_req_to_op':\n\t\t\treturn 0\n\t\telif self.state['name'] == 'waiting_for_op_query_answer':\n\t\t\treturn INFINITY\n\t\telif self.state['name'] == 'waiting_for_op':\n\t\t\treturn INFINITY\n\t\telif self.state['name'] == 'checking':\n\t\t\treturn self.wait_time"!
  672. $
  673. }
  674. Post_ParallelDEVS/InputPort qc_to_adevs_post_iport {
  675. label = "iport"
  676. value_name = $
  677. String function value(model : Element, name : String, mapping : Element):
  678. return "qc_in"!
  679. $
  680. }
  681. Post_ParallelDEVS/DEVSBlockToPort(qc_to_adevs_post_adevs, qc_to_adevs_post_iport) {
  682. label = "qc_to_iport"
  683. }
  684. Post_ParallelDEVS/InputPort qc_to_adevs_post_iport_op {
  685. label = "iport_op"
  686. value_name = $
  687. String function value(model : Element, name : String, mapping : Element):
  688. return "qc_op_in"!
  689. $
  690. }
  691. Post_ParallelDEVS/DEVSBlockToPort(qc_to_adevs_post_adevs, qc_to_adevs_post_iport_op) {
  692. label = "qc_to_iport_op"
  693. }
  694. Post_ParallelDEVS/OutputPort qc_to_adevs_post_oport_broken {
  695. label = "oport_broken"
  696. value_name = $
  697. String function value(model : Element, name : String, mapping : Element):
  698. return "qc_out_broken"!
  699. $
  700. }
  701. Post_ParallelDEVS/DEVSBlockToPort(qc_to_adevs_post_adevs, qc_to_adevs_post_oport_broken) {
  702. label = "qc_to_oport_broken"
  703. }
  704. Post_ParallelDEVS/OutputPort qc_to_adevs_post_oport_working {
  705. label = "oport_working"
  706. value_name = $
  707. String function value(model : Element, name : String, mapping : Element):
  708. return "qc_out_working"!
  709. $
  710. }
  711. Post_ParallelDEVS/DEVSBlockToPort(qc_to_adevs_post_adevs, qc_to_adevs_post_oport_working) {
  712. label = "qc_to_oport_working"
  713. }
  714. Post_ParallelDEVS/OutputPort qc_to_adevs_post_oport_op {
  715. label = "oport_op"
  716. value_name = $
  717. String function value(model : Element, name : String, mapping : Element):
  718. return "qc_op_out"!
  719. $
  720. }
  721. Post_ParallelDEVS/DEVSBlockToPort(qc_to_adevs_post_adevs, qc_to_adevs_post_oport_op) {
  722. label = "qc_to_oport_op"
  723. }
  724. Post_ParallelDEVS/DEVSInstance qc_to_adevs_post_devsi {
  725. label = "devsi"
  726. value_type = $
  727. String function value(model : Element, name : String, mapping : Element):
  728. return list_read(string_split(mapping["qc"], "/"), 1)!
  729. $
  730. value_name = $
  731. String function value(model : Element, name : String, mapping : Element):
  732. return (cast_i2s(list_read(string_split(mapping["qc"], "/"), 1)) + "_i")!
  733. $
  734. }
  735. Post_ParallelDEVS/InputPort qc_to_adevs_post_iporti {
  736. label = "iporti"
  737. value_name = $
  738. String function value(model : Element, name : String, mapping : Element):
  739. return "qc_in"!
  740. $
  741. }
  742. Post_ParallelDEVS/DEVSInstanceToPort(qc_to_adevs_post_devsi, qc_to_adevs_post_iporti) {
  743. label = "devsi_to_iporti"
  744. }
  745. Post_ParallelDEVS/OutputPort qc_to_adevs_post_oport_brokeni {
  746. label = "oport_brokeni"
  747. value_name = $
  748. String function value(model : Element, name : String, mapping : Element):
  749. return "qc_out_broken"!
  750. $
  751. }
  752. Post_ParallelDEVS/DEVSInstanceToPort(qc_to_adevs_post_devsi, qc_to_adevs_post_oport_brokeni) {
  753. label = "devsi_to_oport_brokeni"
  754. }
  755. Post_ParallelDEVS/OutputPort qc_to_adevs_post_oport_workingi {
  756. label = "oport_workingi"
  757. value_name = $
  758. String function value(model : Element, name : String, mapping : Element):
  759. return "qc_out_working"!
  760. $
  761. }
  762. Post_ParallelDEVS/DEVSInstanceToPort(qc_to_adevs_post_devsi, qc_to_adevs_post_oport_workingi) {
  763. label = "devsi_to_oport_workingi"
  764. }
  765. Post_ParallelDEVS/InputPort qc_to_adevs_post_iporti_op {
  766. label = "iporti_op"
  767. value_name = $
  768. String function value(model : Element, name : String, mapping : Element):
  769. return "qc_op_in"!
  770. $
  771. }
  772. Post_ParallelDEVS/DEVSInstanceToPort(qc_to_adevs_post_devsi, qc_to_adevs_post_iporti_op) {
  773. label = "devsi_to_iporti_op"
  774. }
  775. Post_ParallelDEVS/OutputPort qc_to_adevs_post_oporti_op {
  776. label = "oporti_op"
  777. value_name = $
  778. String function value(model : Element, name : String, mapping : Element):
  779. return "qc_op_out"!
  780. $
  781. }
  782. Post_ParallelDEVS/DEVSInstanceToPort(qc_to_adevs_post_devsi, qc_to_adevs_post_oporti_op) {
  783. label = "devsi_to_oporti_op"
  784. }
  785. Post_ParallelDEVS/CoupledDEVSBlock qc_to_adevs_post_root {
  786. label = "root"
  787. }
  788. Post_ParallelDEVS/SubModel(qc_to_adevs_post_root, qc_to_adevs_post_devsi) {
  789. label = "root_to_devsi"
  790. }
  791. Post_PS2DEVS_typelink(qc_to_adevs_post_qc, qc_to_adevs_post_adevs) {
  792. label = "typelink"
  793. }
  794. Post_PS2DEVS_instancelink(qc_to_adevs_post_qc, qc_to_adevs_post_devsi) {
  795. label = "instancelink"
  796. }
  797. }
  798. }
  799. {Contains} ForAll op_to_adevs {
  800. LHS {
  801. Pre_ProductionSystem/Operator op_to_adevs_pre_op {
  802. label = "op"
  803. }
  804. Pre_ParallelDEVS/CoupledDEVSBlock op_to_adevs_pre_root {
  805. label = "root"
  806. constraint_name = $
  807. Boolean function constraint(value: String):
  808. return (value == "Root")!
  809. $
  810. }
  811. }
  812. RHS {
  813. Post_ProductionSystem/Operator op_to_adevs_post_op {
  814. label = "op"
  815. }
  816. Post_ParallelDEVS/DEVSInstance op_to_adevs_post_devsi {
  817. label = "devsi"
  818. value_type = $
  819. String function value(model : Element, name : String, mapping : Element):
  820. return "Operator"!
  821. $
  822. value_name = $
  823. String function value(model : Element, name : String, mapping : Element):
  824. return (cast_i2s(list_read(string_split(mapping["op"], "/"), 1)) + "_i")!
  825. $
  826. }
  827. Post_ParallelDEVS/InputPort op_to_adevs_post_iporti {
  828. label = "iporti"
  829. value_name = $
  830. String function value(model : Element, name : String, mapping : Element):
  831. return "op_in"!
  832. $
  833. }
  834. Post_ParallelDEVS/DEVSInstanceToPort(op_to_adevs_post_devsi, op_to_adevs_post_iporti) {
  835. label = "devsi_to_iporti"
  836. }
  837. Post_ParallelDEVS/OutputPort op_to_adevs_post_oporti {
  838. label = "oporti"
  839. value_name = $
  840. String function value(model : Element, name : String, mapping : Element):
  841. return "op_out"!
  842. $
  843. }
  844. Post_ParallelDEVS/DEVSInstanceToPort(op_to_adevs_post_devsi, op_to_adevs_post_oporti) {
  845. label = "devsi_to_oporti"
  846. }
  847. Post_ParallelDEVS/CoupledDEVSBlock op_to_adevs_post_root {
  848. label = "root"
  849. }
  850. Post_ParallelDEVS/SubModel(op_to_adevs_post_root, op_to_adevs_post_devsi) {
  851. label = "root_to_devsi"
  852. }
  853. Post_PS2DEVS_instancelink(op_to_adevs_post_op, op_to_adevs_post_devsi) {
  854. label = "instancelink"
  855. }
  856. }
  857. }
  858. {Contains} ForAll connect_op_to_machine {
  859. LHS {
  860. Pre_ProductionSystem/Machine connect_op_to_machine_pre_machine {
  861. label = "machine"
  862. }
  863. Pre_ProductionSystem/Operator connect_op_to_machine_pre_op {
  864. label = "op"
  865. }
  866. Pre_ParallelDEVS/DEVSInstance connect_op_to_machine_pre_devsmachine {
  867. label = "devsmachine"
  868. }
  869. Pre_ParallelDEVS/DEVSInstance connect_op_to_machine_pre_devsop {
  870. label = "devsop"
  871. }
  872. Pre_ParallelDEVS/OutputPort connect_op_to_machine_pre_devsmachine_oport {
  873. label = "devsmachine_oport"
  874. constraint_name = $
  875. Boolean function constraint(value: String):
  876. if (value == "ass_op_out"):
  877. return True!
  878. if (value == "qc_op_out"):
  879. return True!
  880. if (value == "rep_op_out"):
  881. return True!
  882. return False!
  883. $
  884. }
  885. Pre_ParallelDEVS/InputPort connect_op_to_machine_pre_devsmachine_iport {
  886. label = "devsmachine_iport"
  887. constraint_name = $
  888. Boolean function constraint(value: String):
  889. if (value == "ass_op_in"):
  890. return True!
  891. if (value == "qc_op_in"):
  892. return True!
  893. if (value == "rep_op_in"):
  894. return True!
  895. return False!
  896. $
  897. }
  898. Pre_ParallelDEVS/OutputPort connect_op_to_machine_pre_devsop_oport {
  899. label = "devsop_oport"
  900. }
  901. Pre_ParallelDEVS/InputPort connect_op_to_machine_pre_devsop_iport {
  902. label = "devsop_iport"
  903. }
  904. Pre_ParallelDEVS/DEVSInstanceToPort(connect_op_to_machine_pre_devsmachine, connect_op_to_machine_pre_devsmachine_oport) {
  905. label = "devsmachine_to_oport"
  906. }
  907. Pre_ParallelDEVS/DEVSInstanceToPort(connect_op_to_machine_pre_devsmachine, connect_op_to_machine_pre_devsmachine_iport) {
  908. label = "devsmachine_to_iport"
  909. }
  910. Pre_ParallelDEVS/DEVSInstanceToPort(connect_op_to_machine_pre_devsop, connect_op_to_machine_pre_devsop_oport) {
  911. label = "devsop_to_oport"
  912. }
  913. Pre_ParallelDEVS/DEVSInstanceToPort(connect_op_to_machine_pre_devsop, connect_op_to_machine_pre_devsop_iport) {
  914. label = "devsop_to_iport"
  915. }
  916. Pre_PS2DEVS_instancelink(connect_op_to_machine_pre_machine, connect_op_to_machine_pre_devsmachine) {
  917. label = "machine_instancelink"
  918. }
  919. Pre_PS2DEVS_instancelink(connect_op_to_machine_pre_op, connect_op_to_machine_pre_devsop) {
  920. label = "op_instancelink"
  921. }
  922. }
  923. RHS {
  924. Post_ProductionSystem/Machine connect_op_to_machine_post_machine {
  925. label = "machine"
  926. }
  927. Post_ProductionSystem/Operator connect_op_to_machine_post_op {
  928. label = "op"
  929. }
  930. Post_ParallelDEVS/DEVSInstance connect_op_to_machine_post_devsmachine {
  931. label = "devsmachine"
  932. }
  933. Post_ParallelDEVS/DEVSInstance connect_op_to_machine_post_devsop {
  934. label = "devsop"
  935. }
  936. Post_ParallelDEVS/OutputPort connect_op_to_machine_post_devsmachine_oport {
  937. label = "devsmachine_oport"
  938. }
  939. Post_ParallelDEVS/InputPort connect_op_to_machine_post_devsmachine_iport {
  940. label = "devsmachine_iport"
  941. }
  942. Post_ParallelDEVS/OutputPort connect_op_to_machine_post_devsop_oport {
  943. label = "devsop_oport"
  944. }
  945. Post_ParallelDEVS/InputPort connect_op_to_machine_post_devsop_iport {
  946. label = "devsop_iport"
  947. }
  948. Post_ParallelDEVS/Channel(connect_op_to_machine_post_devsmachine_oport, connect_op_to_machine_post_devsop_iport) {
  949. label = "channel"
  950. }
  951. Post_ParallelDEVS/Channel(connect_op_to_machine_post_devsop_oport, connect_op_to_machine_post_devsmachine_iport) {
  952. label = "channel2"
  953. }
  954. Post_ParallelDEVS/DEVSInstanceToPort(connect_op_to_machine_post_devsmachine, connect_op_to_machine_post_devsmachine_oport) {
  955. label = "devsmachine_to_oport"
  956. }
  957. Post_ParallelDEVS/DEVSInstanceToPort(connect_op_to_machine_post_devsmachine, connect_op_to_machine_post_devsmachine_iport) {
  958. label = "devsmachine_to_iport"
  959. }
  960. Post_ParallelDEVS/DEVSInstanceToPort(connect_op_to_machine_post_devsop, connect_op_to_machine_post_devsop_oport) {
  961. label = "devsop_to_oport"
  962. }
  963. Post_ParallelDEVS/DEVSInstanceToPort(connect_op_to_machine_post_devsop, connect_op_to_machine_post_devsop_iport) {
  964. label = "devsop_to_iport"
  965. }
  966. Post_PS2DEVS_instancelink(connect_op_to_machine_post_machine, connect_op_to_machine_post_devsmachine) {
  967. label = "machine_instancelink"
  968. }
  969. Post_PS2DEVS_instancelink(connect_op_to_machine_post_op, connect_op_to_machine_post_devsop) {
  970. label = "op_instancelink"
  971. }
  972. }
  973. }
  974. {Contains} ForAll convbelt_to_adevs_init {
  975. LHS {
  976. Pre_ProductionSystem/ConveyorBelt convbelt_to_adevs_init_pre_convbelt {
  977. label = "convbelt"
  978. }
  979. Pre_ParallelDEVS/CoupledDEVSBlock convbelt_to_adevs_init_pre_root {
  980. label = "root"
  981. constraint_name = $
  982. Boolean function constraint(value: String):
  983. return (value == "Root")!
  984. $
  985. }
  986. }
  987. RHS {
  988. Post_ProductionSystem/ConveyorBelt convbelt_to_adevs_init_post_convbelt {
  989. label = "convbelt"
  990. }
  991. Post_ParallelDEVS/DEVSInstance convbelt_to_adevs_init_post_devsi {
  992. label = "devsi"
  993. value_type = $
  994. String function value(model : Element, name : String, mapping : Element):
  995. return "ConveyorBelt"!
  996. $
  997. value_name = $
  998. String function value(model : Element, name : String, mapping : Element):
  999. return (cast_i2s(list_read(string_split(mapping["convbelt"], "/"), 1)) + "_i" + cast_i2s(set_len(allOutgoingAssociationInstances(model, mapping["convbelt"], "PS2DEVS_instancelink"))))!
  1000. $
  1001. }
  1002. Post_ParallelDEVS/InputPort convbelt_to_adevs_init_post_iporti {
  1003. label = "iporti"
  1004. value_name = $
  1005. String function value(model : Element, name : String, mapping : Element):
  1006. return "conv_in"!
  1007. $
  1008. }
  1009. Post_ParallelDEVS/DEVSInstanceToPort(convbelt_to_adevs_init_post_devsi, convbelt_to_adevs_init_post_iporti) {
  1010. label = "devsi_to_iporti"
  1011. }
  1012. Post_ParallelDEVS/OutputPort convbelt_to_adevs_init_post_oporti {
  1013. label = "oporti"
  1014. value_name = $
  1015. String function value(model : Element, name : String, mapping : Element):
  1016. return "conv_out"!
  1017. $
  1018. }
  1019. Post_ParallelDEVS/DEVSInstanceToPort(convbelt_to_adevs_init_post_devsi, convbelt_to_adevs_init_post_oporti) {
  1020. label = "devsi_to_oporti"
  1021. }
  1022. Post_ParallelDEVS/CoupledDEVSBlock convbelt_to_adevs_init_post_root {
  1023. label = "root"
  1024. }
  1025. Post_ParallelDEVS/SubModel(convbelt_to_adevs_init_post_root, convbelt_to_adevs_init_post_devsi) {
  1026. label = "root_to_devsi"
  1027. }
  1028. Post_PS2DEVS_instancelink(convbelt_to_adevs_init_post_convbelt, convbelt_to_adevs_init_post_devsi) {
  1029. label = "instancelink"
  1030. }
  1031. }
  1032. }
  1033. {Contains} Atomic convbelt_to_adevs_next {
  1034. LHS {
  1035. Pre_ProductionSystem/ConveyorBelt convbelt_to_adevs_next_pre_convbelt {
  1036. label = "convbelt"
  1037. }
  1038. Pre_ParallelDEVS/DEVSInstance convbelt_to_adevs_next_pre_prev {
  1039. label = "prev"
  1040. }
  1041. Pre_ParallelDEVS/OutputPort convbelt_to_adevs_next_pre_prev_oport {
  1042. label = "prev_oport"
  1043. }
  1044. Pre_ParallelDEVS/DEVSInstanceToPort(convbelt_to_adevs_next_pre_prev, convbelt_to_adevs_next_pre_prev_oport) {
  1045. label = "prev_to_prev_oport"
  1046. }
  1047. Pre_PS2DEVS_instancelink(convbelt_to_adevs_next_pre_convbelt, convbelt_to_adevs_next_pre_prev) {
  1048. label = "prev_instancelink"
  1049. }
  1050. Pre_ParallelDEVS/CoupledDEVSBlock convbelt_to_adevs_next_pre_root {
  1051. label = "root"
  1052. constraint_name = $
  1053. Boolean function constraint(value: String):
  1054. return (value == "Root")!
  1055. $
  1056. }
  1057. constraint = $
  1058. Boolean function constraint(model : Element, mapping : Element):
  1059. return (set_len(allOutgoingAssociationInstances(model, mapping["convbelt"], "PS2DEVS_instancelink")) < cast_s2i(read_attribute(model, mapping["convbelt"], "capacity")))!
  1060. $
  1061. }
  1062. NAC {
  1063. Pre_ParallelDEVS/DEVSInstance convbelt_to_adevs_next_nac_prev {
  1064. label = "prev"
  1065. }
  1066. Pre_ParallelDEVS/DEVSInstance convbelt_to_adevs_next_nac_next {
  1067. label = "next"
  1068. }
  1069. Pre_ParallelDEVS/OutputPort convbelt_to_adevs_next_nac_prev_oport {
  1070. label = "prev_oport"
  1071. }
  1072. Pre_ParallelDEVS/InputPort convbelt_to_adevs_next_nac_next_iport {
  1073. label = "next_iport"
  1074. }
  1075. Pre_ParallelDEVS/DEVSInstanceToPort(convbelt_to_adevs_next_nac_prev, convbelt_to_adevs_next_nac_prev_oport) {
  1076. label = "prev_to_prev_oport"
  1077. }
  1078. Pre_ParallelDEVS/DEVSInstanceToPort(convbelt_to_adevs_next_nac_next, convbelt_to_adevs_next_nac_next_iport) {
  1079. label = "nac_pre_next_to_next_iport"
  1080. }
  1081. Pre_ParallelDEVS/Channel(convbelt_to_adevs_next_nac_prev_oport, convbelt_to_adevs_next_nac_next_iport) {
  1082. label = "nac_oport_to_iport"
  1083. }
  1084. }
  1085. RHS {
  1086. Post_ProductionSystem/ConveyorBelt convbelt_to_adevs_next_post_convbelt {
  1087. label = "convbelt"
  1088. }
  1089. Post_ParallelDEVS/DEVSInstance convbelt_to_adevs_next_post_prev {
  1090. label = "prev"
  1091. }
  1092. Post_ParallelDEVS/OutputPort convbelt_to_adevs_next_post_prev_oport {
  1093. label = "prev_oport"
  1094. }
  1095. Post_ParallelDEVS/DEVSInstanceToPort(convbelt_to_adevs_next_post_prev, convbelt_to_adevs_next_post_prev_oport) {
  1096. label = "prev_to_prev_oport"
  1097. }
  1098. Post_PS2DEVS_instancelink(convbelt_to_adevs_next_post_convbelt, convbelt_to_adevs_next_post_prev) {
  1099. label = "prev_instancelink"
  1100. }
  1101. Post_ParallelDEVS/DEVSInstance convbelt_to_adevs_next_post_devsi {
  1102. label = "devsi"
  1103. value_type = $
  1104. String function value(model : Element, name : String, mapping : Element):
  1105. return "ConveyorBelt"!
  1106. $
  1107. value_name = $
  1108. String function value(model : Element, name : String, mapping : Element):
  1109. return (cast_i2s(list_read(string_split(mapping["convbelt"], "/"), 1)) + "_i" + cast_i2s(set_len(allOutgoingAssociationInstances(model, mapping["convbelt"], "PS2DEVS_instancelink"))))!
  1110. $
  1111. }
  1112. Post_ParallelDEVS/InputPort convbelt_to_adevs_next_post_iporti {
  1113. label = "iporti"
  1114. value_name = $
  1115. String function value(model : Element, name : String, mapping : Element):
  1116. return "conv_in"!
  1117. $
  1118. }
  1119. Post_ParallelDEVS/DEVSInstanceToPort(convbelt_to_adevs_next_post_devsi, convbelt_to_adevs_next_post_iporti) {
  1120. label = "devsi_to_iporti"
  1121. }
  1122. Post_ParallelDEVS/OutputPort convbelt_to_adevs_next_post_oporti {
  1123. label = "oporti"
  1124. value_name = $
  1125. String function value(model : Element, name : String, mapping : Element):
  1126. return "conv_out"!
  1127. $
  1128. }
  1129. Post_ParallelDEVS/DEVSInstanceToPort(convbelt_to_adevs_next_post_devsi, convbelt_to_adevs_next_post_oporti) {
  1130. label = "devsi_to_oporti"
  1131. }
  1132. Post_ParallelDEVS/Channel(convbelt_to_adevs_next_post_prev_oport, convbelt_to_adevs_next_post_iporti) {
  1133. label = "oporti_to_iporti"
  1134. }
  1135. Post_ParallelDEVS/CoupledDEVSBlock convbelt_to_adevs_next_post_root {
  1136. label = "root"
  1137. }
  1138. Post_ParallelDEVS/SubModel(convbelt_to_adevs_next_post_root, convbelt_to_adevs_next_post_devsi) {
  1139. label = "root_to_devsi"
  1140. }
  1141. Post_PS2DEVS_instancelink(convbelt_to_adevs_next_post_convbelt, convbelt_to_adevs_next_post_devsi) {
  1142. label = "instancelink"
  1143. }
  1144. action = $
  1145. Void function action(host_model: Element, mapping: Element):
  1146. log('ConveyorBelt next...')
  1147. log(cast_v2s(set_len(allOutgoingAssociationInstances(host_model, mapping["convbelt"], "PS2DEVS_instancelink"))))
  1148. return!
  1149. $
  1150. }
  1151. }
  1152. {Contains} ForAll connect_machine_to_convbelt {
  1153. LHS {
  1154. Pre_ProductionSystem/Machine connect_machine_to_convbelt_pre_machine {
  1155. label = "machine"
  1156. }
  1157. Pre_ProductionSystem/ConveyorBelt connect_machine_to_convbelt_pre_convbelt {
  1158. label = "convbelt"
  1159. }
  1160. Pre_ProductionSystem/M_To_Conv(connect_machine_to_convbelt_pre_machine, connect_machine_to_convbelt_pre_convbelt) {
  1161. label = "m_to_conv"
  1162. }
  1163. Pre_ParallelDEVS/DEVSInstance connect_machine_to_convbelt_pre_devsmachine {
  1164. label = "devsmachine"
  1165. }
  1166. Pre_ParallelDEVS/DEVSInstance connect_machine_to_convbelt_pre_devsconvbelt {
  1167. label = "devsconvbelt"
  1168. }
  1169. Pre_ParallelDEVS/OutputPort connect_machine_to_convbelt_pre_devsmachine_oport {
  1170. label = "devsmachine_oport"
  1171. constraint_name = $
  1172. Boolean function constraint(value: String):
  1173. if (value == "ass_out"):
  1174. return True!
  1175. if (value == "qc_out_working"):
  1176. return True!
  1177. if (value == "rep_out"):
  1178. return True!
  1179. if (value == "g_out"):
  1180. return True!
  1181. return False!
  1182. $
  1183. }
  1184. Pre_ParallelDEVS/InputPort connect_machine_to_convbelt_pre_devsconvbelt_iport {
  1185. label = "devsconvbelt_iport"
  1186. }
  1187. Pre_ParallelDEVS/DEVSInstanceToPort(connect_machine_to_convbelt_pre_devsmachine, connect_machine_to_convbelt_pre_devsmachine_oport) {
  1188. label = "devsmachine_to_oport"
  1189. }
  1190. Pre_ParallelDEVS/DEVSInstanceToPort(connect_machine_to_convbelt_pre_devsconvbelt, connect_machine_to_convbelt_pre_devsconvbelt_iport) {
  1191. label = "devsconvbelt_to_iport"
  1192. }
  1193. Pre_PS2DEVS_instancelink(connect_machine_to_convbelt_pre_machine, connect_machine_to_convbelt_pre_devsmachine) {
  1194. label = "machine_instancelink"
  1195. }
  1196. Pre_PS2DEVS_instancelink(connect_machine_to_convbelt_pre_convbelt, connect_machine_to_convbelt_pre_devsconvbelt) {
  1197. label = "convbelt_instancelink"
  1198. }
  1199. }
  1200. NAC {
  1201. Pre_ProductionSystem/ConveyorBelt connect_machine_to_convbelt_nac_convbelt {
  1202. label = "convbelt"
  1203. }
  1204. Pre_ParallelDEVS/DEVSInstance connect_machine_to_convbelt_nac_devsconvbelt {
  1205. label = "devsconvbelt"
  1206. }
  1207. Pre_PS2DEVS_instancelink(connect_machine_to_convbelt_nac_convbelt, connect_machine_to_convbelt_nac_devsconvbelt) {
  1208. label = "convbelt_instancelink"
  1209. }
  1210. Pre_ParallelDEVS/DEVSInstance connect_machine_to_convbelt_nac_devsconvbelt2 {
  1211. label = "devsconvbelt2"
  1212. }
  1213. Pre_PS2DEVS_instancelink(connect_machine_to_convbelt_nac_convbelt, connect_machine_to_convbelt_nac_devsconvbelt2) {
  1214. label = "convbelt_instancelink2"
  1215. }
  1216. Pre_ParallelDEVS/InputPort connect_machine_to_convbelt_nac_devsconvbelt_iport {
  1217. label = "devsconvbelt_iport"
  1218. }
  1219. Pre_ParallelDEVS/DEVSInstanceToPort(connect_machine_to_convbelt_nac_devsconvbelt, connect_machine_to_convbelt_nac_devsconvbelt_iport) {
  1220. label = "devsconvbelt_to_iport"
  1221. }
  1222. Pre_ParallelDEVS/OutputPort connect_machine_to_convbelt_nac_devsconvbelt2_oport {
  1223. label = "devsconvbelt2_oport"
  1224. }
  1225. Pre_ParallelDEVS/DEVSInstanceToPort(connect_machine_to_convbelt_nac_devsconvbelt2, connect_machine_to_convbelt_nac_devsconvbelt2_oport) {
  1226. label = "devsconvbelt2_to_oport"
  1227. }
  1228. Pre_ParallelDEVS/Channel(connect_machine_to_convbelt_nac_devsconvbelt2_oport, connect_machine_to_convbelt_nac_devsconvbelt_iport) {
  1229. label = "convbelt_channel"
  1230. }
  1231. }
  1232. RHS {
  1233. Post_ProductionSystem/Machine connect_machine_to_convbelt_post_machine {
  1234. label = "machine"
  1235. }
  1236. Post_ProductionSystem/ConveyorBelt connect_machine_to_convbelt_post_convbelt {
  1237. label = "convbelt"
  1238. }
  1239. Post_ProductionSystem/M_To_Conv(connect_machine_to_convbelt_post_machine, connect_machine_to_convbelt_post_convbelt) {
  1240. label = "m_to_conv"
  1241. }
  1242. Post_ParallelDEVS/DEVSInstance connect_machine_to_convbelt_post_devsmachine {
  1243. label = "devsmachine"
  1244. }
  1245. Post_ParallelDEVS/DEVSInstance connect_machine_to_convbelt_post_devsconvbelt {
  1246. label = "devsconvbelt"
  1247. }
  1248. Post_ParallelDEVS/OutputPort connect_machine_to_convbelt_post_devsmachine_oport {
  1249. label = "devsmachine_oport"
  1250. }
  1251. Post_ParallelDEVS/InputPort connect_machine_to_convbelt_post_devsconvbelt_iport {
  1252. label = "devsconvbelt_iport"
  1253. }
  1254. Post_ParallelDEVS/Channel(connect_machine_to_convbelt_post_devsmachine_oport, connect_machine_to_convbelt_post_devsconvbelt_iport) {
  1255. label = "channel"
  1256. }
  1257. Post_ParallelDEVS/DEVSInstanceToPort(connect_machine_to_convbelt_post_devsmachine, connect_machine_to_convbelt_post_devsmachine_oport) {
  1258. label = "devsmachine_to_oport"
  1259. }
  1260. Post_ParallelDEVS/DEVSInstanceToPort(connect_machine_to_convbelt_post_devsconvbelt, connect_machine_to_convbelt_post_devsconvbelt_iport) {
  1261. label = "devsconvbelt_to_iport"
  1262. }
  1263. Post_PS2DEVS_instancelink(connect_machine_to_convbelt_post_machine, connect_machine_to_convbelt_post_devsmachine) {
  1264. label = "machine_instancelink"
  1265. }
  1266. Post_PS2DEVS_instancelink(connect_machine_to_convbelt_post_convbelt, connect_machine_to_convbelt_post_devsconvbelt) {
  1267. label = "convbelt_instancelink"
  1268. }
  1269. }
  1270. }
  1271. {Contains} ForAll connect_qc_to_convbelt {
  1272. LHS {
  1273. Pre_ProductionSystem/QualityControl connect_qc_to_convbelt_pre_machine {
  1274. label = "qc"
  1275. }
  1276. Pre_ProductionSystem/ConveyorBelt connect_qc_to_convbelt_pre_convbelt {
  1277. label = "convbelt"
  1278. }
  1279. Pre_ProductionSystem/QC_To_Conv(connect_qc_to_convbelt_pre_machine, connect_qc_to_convbelt_pre_convbelt) {
  1280. label = "qc_to_conv"
  1281. }
  1282. Pre_ParallelDEVS/DEVSInstance connect_qc_to_convbelt_pre_devsmachine {
  1283. label = "devsmachine"
  1284. }
  1285. Pre_ParallelDEVS/DEVSInstance connect_qc_to_convbelt_pre_devsconvbelt {
  1286. label = "devsconvbelt"
  1287. }
  1288. Pre_ParallelDEVS/OutputPort connect_qc_to_convbelt_pre_devsmachine_oport {
  1289. label = "devsmachine_oport"
  1290. constraint_name = $
  1291. Boolean function constraint(value: String):
  1292. if (value == "qc_out_broken"):
  1293. return True!
  1294. return False!
  1295. $
  1296. }
  1297. Pre_ParallelDEVS/InputPort connect_qc_to_convbelt_pre_devsconvbelt_iport {
  1298. label = "devsconvbelt_iport"
  1299. }
  1300. Pre_ParallelDEVS/DEVSInstanceToPort(connect_qc_to_convbelt_pre_devsmachine, connect_qc_to_convbelt_pre_devsmachine_oport) {
  1301. label = "devsmachine_to_oport"
  1302. }
  1303. Pre_ParallelDEVS/DEVSInstanceToPort(connect_qc_to_convbelt_pre_devsconvbelt, connect_qc_to_convbelt_pre_devsconvbelt_iport) {
  1304. label = "devsconvbelt_to_iport"
  1305. }
  1306. Pre_PS2DEVS_instancelink(connect_qc_to_convbelt_pre_machine, connect_qc_to_convbelt_pre_devsmachine) {
  1307. label = "machine_instancelink"
  1308. }
  1309. Pre_PS2DEVS_instancelink(connect_qc_to_convbelt_pre_convbelt, connect_qc_to_convbelt_pre_devsconvbelt) {
  1310. label = "convbelt_instancelink"
  1311. }
  1312. }
  1313. NAC {
  1314. Pre_ProductionSystem/ConveyorBelt connect_qc_to_convbelt_nac_convbelt {
  1315. label = "convbelt"
  1316. }
  1317. Pre_ParallelDEVS/DEVSInstance connect_qc_to_convbelt_nac_devsconvbelt {
  1318. label = "devsconvbelt"
  1319. }
  1320. Pre_PS2DEVS_instancelink(connect_qc_to_convbelt_nac_convbelt, connect_qc_to_convbelt_nac_devsconvbelt) {
  1321. label = "convbelt_instancelink"
  1322. }
  1323. Pre_ParallelDEVS/DEVSInstance connect_qc_to_convbelt_nac_devsconvbelt2 {
  1324. label = "devsconvbelt2"
  1325. }
  1326. Pre_PS2DEVS_instancelink(connect_qc_to_convbelt_nac_convbelt, connect_qc_to_convbelt_nac_devsconvbelt2) {
  1327. label = "convbelt_instancelink2"
  1328. }
  1329. Pre_ParallelDEVS/InputPort connect_qc_to_convbelt_nac_devsconvbelt_iport {
  1330. label = "devsconvbelt_iport"
  1331. }
  1332. Pre_ParallelDEVS/DEVSInstanceToPort(connect_qc_to_convbelt_nac_devsconvbelt, connect_qc_to_convbelt_nac_devsconvbelt_iport) {
  1333. label = "devsconvbelt_to_iport"
  1334. }
  1335. Pre_ParallelDEVS/OutputPort connect_qc_to_convbelt_nac_devsconvbelt2_oport {
  1336. label = "devsconvbelt2_oport"
  1337. }
  1338. Pre_ParallelDEVS/DEVSInstanceToPort(connect_qc_to_convbelt_nac_devsconvbelt2, connect_qc_to_convbelt_nac_devsconvbelt2_oport) {
  1339. label = "devsconvbelt2_to_oport"
  1340. }
  1341. Pre_ParallelDEVS/Channel(connect_qc_to_convbelt_nac_devsconvbelt2_oport, connect_qc_to_convbelt_nac_devsconvbelt_iport) {
  1342. label = "convbelt_channel"
  1343. }
  1344. }
  1345. RHS {
  1346. Post_ProductionSystem/QualityControl connect_qc_to_convbelt_post_machine {
  1347. label = "qc"
  1348. }
  1349. Post_ProductionSystem/ConveyorBelt connect_qc_to_convbelt_post_convbelt {
  1350. label = "convbelt"
  1351. }
  1352. Post_ProductionSystem/M_To_Conv(connect_qc_to_convbelt_post_machine, connect_qc_to_convbelt_post_convbelt) {
  1353. label = "qc_to_conv"
  1354. }
  1355. Post_ParallelDEVS/DEVSInstance connect_qc_to_convbelt_post_devsmachine {
  1356. label = "devsmachine"
  1357. }
  1358. Post_ParallelDEVS/DEVSInstance connect_qc_to_convbelt_post_devsconvbelt {
  1359. label = "devsconvbelt"
  1360. }
  1361. Post_ParallelDEVS/OutputPort connect_qc_to_convbelt_post_devsmachine_oport {
  1362. label = "devsmachine_oport"
  1363. }
  1364. Post_ParallelDEVS/InputPort connect_qc_to_convbelt_post_devsconvbelt_iport {
  1365. label = "devsconvbelt_iport"
  1366. }
  1367. Post_ParallelDEVS/Channel(connect_qc_to_convbelt_post_devsmachine_oport, connect_qc_to_convbelt_post_devsconvbelt_iport) {
  1368. label = "channel"
  1369. }
  1370. Post_ParallelDEVS/DEVSInstanceToPort(connect_qc_to_convbelt_post_devsmachine, connect_qc_to_convbelt_post_devsmachine_oport) {
  1371. label = "devsmachine_to_oport"
  1372. }
  1373. Post_ParallelDEVS/DEVSInstanceToPort(connect_qc_to_convbelt_post_devsconvbelt, connect_qc_to_convbelt_post_devsconvbelt_iport) {
  1374. label = "devsconvbelt_to_iport"
  1375. }
  1376. Post_PS2DEVS_instancelink(connect_qc_to_convbelt_post_machine, connect_qc_to_convbelt_post_devsmachine) {
  1377. label = "machine_instancelink"
  1378. }
  1379. Post_PS2DEVS_instancelink(connect_qc_to_convbelt_post_convbelt, connect_qc_to_convbelt_post_devsconvbelt) {
  1380. label = "convbelt_instancelink"
  1381. }
  1382. }
  1383. }
  1384. {Contains} ForAll connect_convbelt_to_machine {
  1385. LHS {
  1386. Pre_ProductionSystem/ConveyorBelt connect_convbelt_to_machine_pre_convbelt {
  1387. label = "convbelt"
  1388. }
  1389. Pre_ProductionSystem/Machine connect_convbelt_to_machine_pre_machine {
  1390. label = "machine"
  1391. }
  1392. Pre_ProductionSystem/Conv_To_M(connect_convbelt_to_machine_pre_convbelt, connect_convbelt_to_machine_pre_machine) {
  1393. label = "conv_to_m"
  1394. }
  1395. Pre_ParallelDEVS/DEVSInstance connect_convbelt_to_machine_pre_devsconvbelt {
  1396. label = "devsconvbelt"
  1397. }
  1398. Pre_ParallelDEVS/DEVSInstance connect_convbelt_to_machine_pre_devsmachine {
  1399. label = "devsmachine"
  1400. }
  1401. Pre_ParallelDEVS/OutputPort connect_convbelt_to_machine_pre_devsconvbelt_oport {
  1402. label = "devsconvbelt_oport"
  1403. }
  1404. Pre_ParallelDEVS/InputPort connect_convbelt_to_machine_pre_devsmachine_iport {
  1405. label = "devsmachine_iport"
  1406. constraint_name = $
  1407. Boolean function constraint(value: String):
  1408. if (value == "ass_in"):
  1409. return True!
  1410. if (value == "qc_in"):
  1411. return True!
  1412. if (value == "rep_in"):
  1413. return True!
  1414. if (value == "c_in"):
  1415. return True!
  1416. return False!
  1417. $
  1418. }
  1419. Pre_ParallelDEVS/DEVSInstanceToPort(connect_convbelt_to_machine_pre_devsconvbelt, connect_convbelt_to_machine_pre_devsconvbelt_oport) {
  1420. label = "devsconvbelt_to_oport"
  1421. }
  1422. Pre_ParallelDEVS/DEVSInstanceToPort(connect_convbelt_to_machine_pre_devsmachine, connect_convbelt_to_machine_pre_devsmachine_iport) {
  1423. label = "devsmachine_to_iport"
  1424. }
  1425. Pre_PS2DEVS_instancelink(connect_convbelt_to_machine_pre_convbelt, connect_convbelt_to_machine_pre_devsconvbelt) {
  1426. label = "convbelt_instancelink"
  1427. }
  1428. Pre_PS2DEVS_instancelink(connect_convbelt_to_machine_pre_machine, connect_convbelt_to_machine_pre_devsmachine) {
  1429. label = "machine_instancelink"
  1430. }
  1431. }
  1432. NAC {
  1433. Pre_ProductionSystem/ConveyorBelt connect_convbelt_to_machine_nac_convbelt {
  1434. label = "convbelt"
  1435. }
  1436. Pre_ParallelDEVS/DEVSInstance connect_convbelt_to_machine_nac_devsconvbelt {
  1437. label = "devsconvbelt"
  1438. }
  1439. Pre_PS2DEVS_instancelink(connect_convbelt_to_machine_nac_convbelt, connect_convbelt_to_machine_nac_devsconvbelt) {
  1440. label = "convbelt_instancelink"
  1441. }
  1442. Pre_ParallelDEVS/DEVSInstance connect_convbelt_to_machine_nac_devsconvbelt2 {
  1443. label = "devsconvbelt2"
  1444. }
  1445. Pre_PS2DEVS_instancelink(connect_convbelt_to_machine_nac_convbelt, connect_convbelt_to_machine_nac_devsconvbelt2) {
  1446. label = "convbelt_instancelink2"
  1447. }
  1448. Pre_ParallelDEVS/OutputPort connect_convbelt_to_machine_nac_devsconvbelt_oport {
  1449. label = "devsconvbelt_oport"
  1450. }
  1451. Pre_ParallelDEVS/DEVSInstanceToPort(connect_convbelt_to_machine_nac_devsconvbelt, connect_convbelt_to_machine_nac_devsconvbelt_oport) {
  1452. label = "devsconvbelt_to_oport"
  1453. }
  1454. Pre_ParallelDEVS/InputPort connect_convbelt_to_machine_nac_devsconvbelt2_iport {
  1455. label = "devsconvbelt2_iport"
  1456. }
  1457. Pre_ParallelDEVS/DEVSInstanceToPort(connect_convbelt_to_machine_nac_devsconvbelt2, connect_convbelt_to_machine_nac_devsconvbelt2_iport) {
  1458. label = "devsconvbelt2_to_iport"
  1459. }
  1460. Pre_ParallelDEVS/Channel(connect_convbelt_to_machine_nac_devsconvbelt_oport, connect_convbelt_to_machine_nac_devsconvbelt2_iport) {
  1461. label = "convbelt_channel"
  1462. }
  1463. }
  1464. RHS {
  1465. Post_ProductionSystem/ConveyorBelt connect_convbelt_to_machine_post_convbelt {
  1466. label = "convbelt"
  1467. }
  1468. Post_ProductionSystem/Machine connect_convbelt_to_machine_post_machine {
  1469. label = "machine"
  1470. }
  1471. Post_ProductionSystem/Conv_To_M(connect_convbelt_to_machine_post_convbelt, connect_convbelt_to_machine_post_machine) {
  1472. label = "conv_to_m"
  1473. }
  1474. Post_ParallelDEVS/DEVSInstance connect_convbelt_to_machine_post_devsconvbelt {
  1475. label = "devsconvbelt"
  1476. }
  1477. Post_ParallelDEVS/DEVSInstance connect_convbelt_to_machine_post_devsmachine {
  1478. label = "devsmachine"
  1479. }
  1480. Post_ParallelDEVS/OutputPort connect_convbelt_to_machine_post_devsconvbelt_oport {
  1481. label = "devsconvbelt_oport"
  1482. }
  1483. Post_ParallelDEVS/InputPort connect_convbelt_to_machine_post_devsmachine_iport {
  1484. label = "devsmachine_iport"
  1485. }
  1486. Post_ParallelDEVS/Channel(connect_convbelt_to_machine_post_devsconvbelt_oport, connect_convbelt_to_machine_post_devsmachine_iport) {
  1487. label = "channel"
  1488. }
  1489. Post_ParallelDEVS/DEVSInstanceToPort(connect_convbelt_to_machine_post_devsconvbelt, connect_convbelt_to_machine_post_devsconvbelt_oport) {
  1490. label = "devsconvbelt_to_oport"
  1491. }
  1492. Post_ParallelDEVS/DEVSInstanceToPort(connect_convbelt_to_machine_post_devsmachine, connect_convbelt_to_machine_post_devsmachine_iport) {
  1493. label = "devsmachine_to_iport"
  1494. }
  1495. Post_PS2DEVS_instancelink(connect_convbelt_to_machine_post_machine, connect_convbelt_to_machine_post_devsmachine) {
  1496. label = "machine_instancelink"
  1497. }
  1498. Post_PS2DEVS_instancelink(connect_convbelt_to_machine_post_convbelt, connect_convbelt_to_machine_post_devsconvbelt) {
  1499. label = "convbelt_instancelink"
  1500. }
  1501. }
  1502. }
  1503. {Contains} Atomic finish {
  1504. LHS {}
  1505. RHS {
  1506. action = $
  1507. Void function action(host_model: Element, mapping: Element):
  1508. //log(pretty_print(host_model))
  1509. return!
  1510. $
  1511. }
  1512. }
  1513. }
  1514. Initial (schedule, init) {}
  1515. OnSuccess (init, gen_to_adevs) {}
  1516. OnSuccess (gen_to_adevs, coll_to_adevs) {}
  1517. OnSuccess (coll_to_adevs, ass_to_adevs) {}
  1518. OnSuccess (ass_to_adevs, rep_to_adevs) {}
  1519. OnSuccess (rep_to_adevs, qc_to_adevs) {}
  1520. OnSuccess (qc_to_adevs, op_to_adevs) {}
  1521. OnSuccess (op_to_adevs, connect_op_to_machine) {}
  1522. OnSuccess (connect_op_to_machine, convbelt_to_adevs_init) {}
  1523. OnSuccess (convbelt_to_adevs_init, convbelt_to_adevs_next) {}
  1524. OnSuccess (convbelt_to_adevs_next, convbelt_to_adevs_next) {}
  1525. OnFailure (convbelt_to_adevs_next, connect_machine_to_convbelt) {}
  1526. OnSuccess (connect_machine_to_convbelt, connect_qc_to_convbelt) {}
  1527. OnSuccess (connect_qc_to_convbelt, connect_convbelt_to_machine) {}
  1528. OnSuccess (connect_convbelt_to_machine, finish) {}
  1529. OnSuccess (finish, success) {}
  1530. OnFailure (init, gen_to_adevs) {}
  1531. OnFailure (gen_to_adevs, coll_to_adevs) {}
  1532. OnFailure (coll_to_adevs, ass_to_adevs) {}
  1533. OnFailure (ass_to_adevs, rep_to_adevs) {}
  1534. OnFailure (rep_to_adevs, qc_to_adevs) {}
  1535. OnFailure (qc_to_adevs, op_to_adevs) {}
  1536. OnFailure (op_to_adevs, connect_op_to_machine) {}
  1537. OnFailure (connect_op_to_machine, convbelt_to_adevs_init) {}
  1538. OnFailure (convbelt_to_adevs_init, connect_machine_to_convbelt) {}
  1539. OnFailure (connect_machine_to_convbelt, connect_qc_to_convbelt) {}
  1540. OnFailure (connect_qc_to_convbelt, connect_convbelt_to_machine) {}
  1541. OnFailure (connect_convbelt_to_machine, finish) {}
  1542. OnFailure (finish, failure) {}