control_to_EPN.mvc 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. include "primitives.alh"
  2. include "modelling.alh"
  3. All_RAM Control2EPN {
  4. Composite schedule {
  5. {Contains} Failure failure {}
  6. {Contains} Success success {}
  7. {Contains} Atomic init_ports {
  8. LHS {}
  9. RHS {
  10. Post_Encapsulated_PetriNet/Place init_place_0 {
  11. label = "00"
  12. value_name = $
  13. String function value(model : Element, name : String, mapping : Element):
  14. return "cmdDown"!
  15. $
  16. value_tokens = #
  17. Integer function value(model : Element, name : String, mapping : Element):
  18. return 0!
  19. $
  20. }
  21. Post_Encapsulated_PetriNet/Port init_port_0 {
  22. label = "10"
  23. value_name = $
  24. String function value(model : Element, name : String, mapping : Element):
  25. return "cmdDown"!
  26. $
  27. }
  28. Post_Encapsulated_PetriNet/PortPlace (init_port_0, init_place_0) {
  29. label = "20"
  30. }
  31. Post_Encapsulated_PetriNet/Place init_place_1 {
  32. label = "01"
  33. value_name = $
  34. String function value(model : Element, name : String, mapping : Element):
  35. return "cmdNeutral"!
  36. $
  37. value_tokens = #
  38. Integer function value(model : Element, name : String, mapping : Element):
  39. return 0!
  40. $
  41. }
  42. Post_Encapsulated_PetriNet/Port init_port_1 {
  43. label = "11"
  44. value_name = $
  45. String function value(model : Element, name : String, mapping : Element):
  46. return "cmdNeutral"!
  47. $
  48. }
  49. Post_Encapsulated_PetriNet/PortPlace (init_port_1, init_place_1) {
  50. label = "21"
  51. }
  52. Post_Encapsulated_PetriNet/Place init_place_2 {
  53. label = "02"
  54. value_name = $
  55. String function value(model : Element, name : String, mapping : Element):
  56. return "cmdUp"!
  57. $
  58. value_tokens = #
  59. Integer function value(model : Element, name : String, mapping : Element):
  60. return 0!
  61. $
  62. }
  63. Post_Encapsulated_PetriNet/Port init_port_2 {
  64. label = "12"
  65. value_name = $
  66. String function value(model : Element, name : String, mapping : Element):
  67. return "cmdUp"!
  68. $
  69. }
  70. Post_Encapsulated_PetriNet/PortPlace (init_port_2, init_place_2) {
  71. label = "22"
  72. }
  73. Post_Encapsulated_PetriNet/Place init_place_3 {
  74. label = "03"
  75. value_name = $
  76. String function value(model : Element, name : String, mapping : Element):
  77. return "objDetected"!
  78. $
  79. value_tokens = #
  80. Integer function value(model : Element, name : String, mapping : Element):
  81. return 0!
  82. $
  83. }
  84. Post_Encapsulated_PetriNet/Port init_port_3 {
  85. label = "13"
  86. value_name = $
  87. String function value(model : Element, name : String, mapping : Element):
  88. return "objDetected"!
  89. $
  90. }
  91. Post_Encapsulated_PetriNet/PortPlace (init_port_3, init_place_3) {
  92. label = "23"
  93. }
  94. Post_Encapsulated_PetriNet/Place init_place_4 {
  95. label = "04"
  96. value_name = $
  97. String function value(model : Element, name : String, mapping : Element):
  98. return "no_objDetected"!
  99. $
  100. value_tokens = #
  101. Integer function value(model : Element, name : String, mapping : Element):
  102. return 0!
  103. $
  104. }
  105. Post_Encapsulated_PetriNet/Port init_port_4 {
  106. label = "14"
  107. value_name = $
  108. String function value(model : Element, name : String, mapping : Element):
  109. return "no_objDetected"!
  110. $
  111. }
  112. Post_Encapsulated_PetriNet/PortPlace (init_port_4, init_place_4) {
  113. label = "24"
  114. }
  115. Post_Encapsulated_PetriNet/Place init_place_5 {
  116. label = "05"
  117. value_name = $
  118. String function value(model : Element, name : String, mapping : Element):
  119. return "up"!
  120. $
  121. value_tokens = #
  122. Integer function value(model : Element, name : String, mapping : Element):
  123. return 0!
  124. $
  125. }
  126. Post_Encapsulated_PetriNet/Port init_port_5 {
  127. label = "15"
  128. value_name = $
  129. String function value(model : Element, name : String, mapping : Element):
  130. return "up"!
  131. $
  132. }
  133. Post_Encapsulated_PetriNet/PortPlace (init_port_5, init_place_5) {
  134. label = "25"
  135. }
  136. Post_Encapsulated_PetriNet/Place init_place_6 {
  137. label = "06"
  138. value_name = $
  139. String function value(model : Element, name : String, mapping : Element):
  140. return "neutral"!
  141. $
  142. value_tokens = #
  143. Integer function value(model : Element, name : String, mapping : Element):
  144. return 0!
  145. $
  146. }
  147. Post_Encapsulated_PetriNet/Port init_port_6 {
  148. label = "16"
  149. value_name = $
  150. String function value(model : Element, name : String, mapping : Element):
  151. return "neutral"!
  152. $
  153. }
  154. Post_Encapsulated_PetriNet/PortPlace (init_port_6, init_place_6) {
  155. label = "26"
  156. }
  157. Post_Encapsulated_PetriNet/Place init_place_7 {
  158. label = "07"
  159. value_name = $
  160. String function value(model : Element, name : String, mapping : Element):
  161. return "down"!
  162. $
  163. value_tokens = #
  164. Integer function value(model : Element, name : String, mapping : Element):
  165. return 0!
  166. $
  167. }
  168. Post_Encapsulated_PetriNet/Port init_port_7 {
  169. label = "17"
  170. value_name = $
  171. String function value(model : Element, name : String, mapping : Element):
  172. return "down"!
  173. $
  174. }
  175. Post_Encapsulated_PetriNet/PortPlace (init_port_7, init_place_7) {
  176. label = "27"
  177. }
  178. Post_Encapsulated_PetriNet/Place init_place_8 {
  179. label = "08"
  180. value_name = $
  181. String function value(model : Element, name : String, mapping : Element):
  182. return "interrupt"!
  183. $
  184. value_tokens = #
  185. Integer function value(model : Element, name : String, mapping : Element):
  186. return 0!
  187. $
  188. }
  189. Post_Encapsulated_PetriNet/Port init_port_8 {
  190. label = "18"
  191. value_name = $
  192. String function value(model : Element, name : String, mapping : Element):
  193. return "interrupt"!
  194. $
  195. }
  196. Post_Encapsulated_PetriNet/PortPlace (init_port_8, init_place_8) {
  197. label = "28"
  198. }
  199. }
  200. }
  201. {Contains} ForAll create_states {
  202. LHS {
  203. Pre_Control_PW/State {
  204. label = "0"
  205. }
  206. }
  207. RHS {
  208. Post_Control_PW/State cs_s {
  209. label = "0"
  210. }
  211. Post_Encapsulated_PetriNet/Place cs_p {
  212. label = "1"
  213. value_name = $
  214. String function value(model : Element, name : String, mapping : Element):
  215. return read_attribute(model, mapping["0"], "name")!
  216. $
  217. value_tokens = $
  218. Integer function value(model : Element, name : String, mapping : Element):
  219. if (value_eq(read_attribute(model, mapping["0"], "isInitial"), True)):
  220. return 1!
  221. else:
  222. return 0!
  223. $
  224. }
  225. Post_CTRL2EPN_link (cs_s, cs_p) {
  226. label = "2"
  227. }
  228. }
  229. }
  230. {Contains} ForAll create_transitions {
  231. LHS {
  232. Pre_Control_PW/State pre_ct_s1 {
  233. label = "0"
  234. }
  235. Pre_Control_PW/State pre_ct_s2 {
  236. label = "1"
  237. }
  238. Pre_Control_PW/Transition (pre_ct_s1, pre_ct_s2) {
  239. label = "2"
  240. }
  241. Pre_Encapsulated_PetriNet/Place pre_ct_p1 {
  242. label = "3"
  243. }
  244. Pre_Encapsulated_PetriNet/Place pre_ct_p2 {
  245. label = "4"
  246. }
  247. Pre_CTRL2EPN_link (pre_ct_s1, pre_ct_p1) {
  248. label = "5"
  249. }
  250. Pre_CTRL2EPN_link (pre_ct_s2, pre_ct_p2) {
  251. label = "6"
  252. }
  253. Pre_Encapsulated_PetriNet/Place pre_ps1 {
  254. label = "7"
  255. }
  256. Pre_Encapsulated_PetriNet/Place pre_ps2 {
  257. label = "8"
  258. }
  259. Pre_Encapsulated_PetriNet/Port pre_pp1 {
  260. label = "9"
  261. constraint_name = $
  262. Boolean constraint(host_model : Element, name : String):
  263. String t
  264. t = read_attribute(host_model, name, "name")
  265. if (bool_or(bool_or(t == "up", t == "neutral"), t == "down")):
  266. return True:
  267. $
  268. }
  269. Pre_Encapsulated_PetriNet/Port pre_pp2 {
  270. label = "10"
  271. constraint_name = $
  272. Boolean constraint(host_model : Element, name : String):
  273. String t
  274. t = read_attribute(host_model, name, "name")
  275. if (bool_or(bool_or(t == "up", t == "neutral"), t == "down")):
  276. return True:
  277. $
  278. }
  279. Pre_Encapsulated_PetriNet/PortPlace (pre_pp1, pre_ps1) {
  280. label = "11"
  281. }
  282. Pre_Encapsulated_PetriNet/PortPlace (pre_pp2, pre_ps2) {
  283. label = "12"
  284. }
  285. constraint = $
  286. Boolean constraint (host_model : Element, mapping : Element):
  287. // Check whether the bound primary places match with the state
  288. String s1_type
  289. String s2_type
  290. String ps1_type
  291. String ps2_type
  292. s1_type = read_type(host_model, mapping["0"])
  293. s2_type = read_type(host_model, mapping["1"])
  294. ps1_type = read_attribute(host_model, mapping["9"], "name")
  295. ps2_type = read_attribute(host_model, mapping["10"], "name")
  296. if (s1_type == "Up"):
  297. if (ps1_type != "up"):
  298. return False!
  299. elif (s1_type == "Down"):
  300. if (ps1_type != "down"):
  301. return False!
  302. elif (s1_type == "Neutral"):
  303. if (ps1_type != "neutral"):
  304. return False!
  305. if (s2_type == "Up"):
  306. if (ps2_type != "up"):
  307. return False!
  308. elif (s2_type == "Down"):
  309. if (ps2_type != "down"):
  310. return False!
  311. elif (s2_type == "Neutral"):
  312. if (ps2_type != "neutral"):
  313. return False!
  314. return True!
  315. $
  316. }
  317. RHS {
  318. Post_Control_PW/State post_ct_s1 {
  319. label = "0"
  320. }
  321. Post_Control_PW/State post_ct_s2 {
  322. label = "1"
  323. }
  324. Post_Control_PW/Transition (post_ct_s1, post_ct_s2) {
  325. label = "2"
  326. }
  327. Post_Encapsulated_PetriNet/Place post_ct_p1 {
  328. label = "3"
  329. }
  330. Post_Encapsulated_PetriNet/Place post_ct_p2 {
  331. label = "4"
  332. }
  333. Post_CTRL2EPN_link (post_ct_s1, post_ct_p1) {
  334. label = "5"
  335. }
  336. Post_CTRL2EPN_link (post_ct_s2, post_ct_p2) {
  337. label = "6"
  338. }
  339. Post_Encapsulated_PetriNet/Place post_ps1 {
  340. label = "7"
  341. }
  342. Post_Encapsulated_PetriNet/Place post_ps2 {
  343. label = "8"
  344. }
  345. Post_Encapsulated_PetriNet/Port post_pp1 {
  346. label = "9"
  347. }
  348. Post_Encapsulated_PetriNet/Port post_pp2 {
  349. label = "10"
  350. }
  351. Post_Encapsulated_PetriNet/PortPlace (post_pp1, post_ps1) {
  352. label = "11"
  353. }
  354. Post_Encapsulated_PetriNet/PortPlace (post_pp2, post_ps2) {
  355. label = "12"
  356. }
  357. Post_Encapsulated_PetriNet/Transition post_ct_t {
  358. label = "13"
  359. }
  360. Post_Encapsulated_PetriNet/P2T (post_ps1, post_ct_t) {
  361. label = "14"
  362. }
  363. Post_Encapsulated_PetriNet/T2P (post_ct_t, post_ps2) {
  364. label = "15"
  365. }
  366. Post_Encapsulated_PetriNet/P2T (post_ct_p1, post_ct_t) {
  367. label = "16"
  368. }
  369. Post_Encapsulated_PetriNet/T2P (post_ct_t, post_ct_p2) {
  370. label = "17"
  371. }
  372. }
  373. }
  374. {Contains} ForAll check_object {
  375. LHS {
  376. Pre_Control_PW/State pre_cop_s1 {
  377. label = "0"
  378. }
  379. Pre_Control_PW/State pre_cop_s2 {
  380. label = "1"
  381. }
  382. Pre_Control_PW/Transition (pre_cop_s1, pre_cop_s2) {
  383. label = "2"
  384. constraint_objDetected = $
  385. Boolean constraint(host_model : Element, name : String):
  386. String t
  387. t = read_attribute(host_model, name, "objDetected")
  388. if (bool_or(t == "Y", t == "N")):
  389. return True!
  390. else:
  391. return False!
  392. $
  393. }
  394. Pre_Encapsulated_PetriNet/Place pre_cop_p1 {
  395. label = "3"
  396. }
  397. Pre_Encapsulated_PetriNet/Place pre_cop_p2 {
  398. label = "4"
  399. }
  400. Pre_CTRL2EPN_link (pre_cop_s1, pre_cop_p1) {
  401. label = "5"
  402. }
  403. Pre_CTRL2EPN_link (pre_cop_s2, pre_cop_p2) {
  404. label = "6"
  405. }
  406. Pre_Encapsulated_PetriNet/Place pre_cop_ps1 {
  407. label = "8"
  408. }
  409. Pre_Encapsulated_PetriNet/Port pre_pp1 {
  410. label = "11"
  411. constraint_name = $
  412. Boolean constraint(host_model : Element, name : String):
  413. String t
  414. t = read_attribute(host_model, name, "name")
  415. if (bool_or(t == "objDetected", t == "no_objDetected")):
  416. return True!
  417. else:
  418. return False!
  419. $
  420. }
  421. Pre_Encapsulated_PetriNet/PortPlace (pre_pp1, pre_ps1) {
  422. label = "12"
  423. }
  424. Pre_Encapsulated_PetriNet/Transition pre_cop_t {
  425. label = "15"
  426. }
  427. Pre_Encapsulated_PetriNet/P2T (pre_ps1, pre_cop_t) {
  428. label = "16"
  429. }
  430. Pre_Encapsulated_PetriNet/T2P (pre_cop_t, pre_ps2) {
  431. label = "17"
  432. }
  433. constraint = $
  434. Boolean constraint (host_model : Element, mapping : Element):
  435. // Check whether the bound primary places match with the state
  436. String s1_value
  437. String ps1_type
  438. s1_value = read_attribute(host_model, mapping["2"], "objDetected")
  439. ps1_type = read_attribute(host_model, mapping["11"], "name")
  440. if (s1_value == "Y"):
  441. if (ps1_type == "objDetected"):
  442. return True!
  443. elif (s1_value == "N"):
  444. if (ps1_type != "no_objDetected"):
  445. return True!
  446. return False!
  447. $
  448. }
  449. RHS {
  450. Post_Control_PW/State post_ct_s1 {
  451. label = "0"
  452. }
  453. Post_Control_PW/State post_ct_s2 {
  454. label = "1"
  455. }
  456. Post_Control_PW/Transition (post_ct_s1, post_ct_s2) {
  457. label = "2"
  458. }
  459. Post_Encapsulated_PetriNet/Place post_ct_p1 {
  460. label = "3"
  461. }
  462. Post_Encapsulated_PetriNet/Place post_ct_p2 {
  463. label = "4"
  464. }
  465. Post_CTRL2EPN_link (post_ct_s1, post_ct_p1) {
  466. label = "5"
  467. }
  468. Post_CTRL2EPN_link (post_ct_s2, post_ct_p2) {
  469. label = "6"
  470. }
  471. Post_Encapsulated_PetriNet/Place post_ps1 {
  472. label = "8"
  473. }
  474. Post_Encapsulated_PetriNet/Port post_pp1 {
  475. label = "11"
  476. }
  477. Post_Encapsulated_PetriNet/PortPlace (post_pp1, post_ps1) {
  478. label = "12"
  479. }
  480. Post_Encapsulated_PetriNet/Transition post_ct_t {
  481. label = "15"
  482. }
  483. Post_Encapsulated_PetriNet/P2T (post_ps1, post_ct_t) {
  484. label = "16"
  485. }
  486. Post_Encapsulated_PetriNet/T2P (post_ct_t, post_ps2) {
  487. label = "17"
  488. }
  489. Post_Encapsulated_PetriNet/P2T (post_cop_obj, post_cop_t) {
  490. label = "9"
  491. }
  492. Post_Encapsulated_PetriNet/T2P (post_cop_t, post_cop_obj) {
  493. label = "10"
  494. }
  495. }
  496. }
  497. }
  498. Initial (schedule, init_ports) {}
  499. OnSuccess (init_ports, create_states) {}
  500. OnSuccess (create_states, create_transitions) {}
  501. OnSuccess (create_transitions, check_object) {}
  502. OnSuccess (check_object, fix_interrupt) {}
  503. OnSuccess (fix_interrupt, check_input) {}
  504. OnSuccess (check_input, success) {}
  505. OnFailure (init_ports, create_states) {}
  506. OnFailure (create_states, create_transitions) {}
  507. OnFailure (create_transitions, check_object) {}
  508. OnFailure (check_object, fix_interrupt) {}
  509. OnFailure (fix_interrupt, check_input) {}
  510. OnFailure (check_input, success) {}
  511. }
  512. export annotate to models/pn_annotate