control_to_EPN.mvc 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. include "primitives.alh"
  2. include "modelling.alh"
  3. include "object_operations.alh"
  4. All_RAM Control2EPN {
  5. Composite schedule {
  6. {Contains} Failure failure {}
  7. {Contains} Success success {}
  8. {Contains} Atomic init_ports {
  9. LHS {}
  10. RHS {
  11. Post_Encapsulated_PetriNet/Place post_ports_00 {
  12. label = "00"
  13. value_name = $
  14. String function value(model : Element, name : String, mapping : Element):
  15. return "cmdDown"!
  16. $
  17. value_tokens = $
  18. Integer function value(model : Element, name : String, mapping : Element):
  19. return 0!
  20. $
  21. }
  22. Post_Encapsulated_PetriNet/Port post_ports_10 {
  23. label = "10"
  24. value_name = $
  25. String function value(model : Element, name : String, mapping : Element):
  26. return "cmdDown"!
  27. $
  28. }
  29. Post_Encapsulated_PetriNet/PortPlace (post_ports_10, post_ports_00) {
  30. label = "20"
  31. }
  32. Post_Encapsulated_PetriNet/Place post_ports_01 {
  33. label = "01"
  34. value_name = $
  35. String function value(model : Element, name : String, mapping : Element):
  36. return "cmdNeutral"!
  37. $
  38. value_tokens = $
  39. Integer function value(model : Element, name : String, mapping : Element):
  40. return 0!
  41. $
  42. }
  43. Post_Encapsulated_PetriNet/Port post_ports_11 {
  44. label = "11"
  45. value_name = $
  46. String function value(model : Element, name : String, mapping : Element):
  47. return "cmdNeutral"!
  48. $
  49. }
  50. Post_Encapsulated_PetriNet/PortPlace (post_ports_11, post_ports_01) {
  51. label = "21"
  52. }
  53. Post_Encapsulated_PetriNet/Place post_ports_02 {
  54. label = "02"
  55. value_name = $
  56. String function value(model : Element, name : String, mapping : Element):
  57. return "cmdUp"!
  58. $
  59. value_tokens = $
  60. Integer function value(model : Element, name : String, mapping : Element):
  61. return 0!
  62. $
  63. }
  64. Post_Encapsulated_PetriNet/Port post_ports_12 {
  65. label = "12"
  66. value_name = $
  67. String function value(model : Element, name : String, mapping : Element):
  68. return "cmdUp"!
  69. $
  70. }
  71. Post_Encapsulated_PetriNet/PortPlace (post_ports_12, post_ports_02) {
  72. label = "22"
  73. }
  74. Post_Encapsulated_PetriNet/Place post_ports_03 {
  75. label = "03"
  76. value_name = $
  77. String function value(model : Element, name : String, mapping : Element):
  78. return "objDetected"!
  79. $
  80. value_tokens = $
  81. Integer function value(model : Element, name : String, mapping : Element):
  82. return 0!
  83. $
  84. }
  85. Post_Encapsulated_PetriNet/Port post_ports_13 {
  86. label = "13"
  87. value_name = $
  88. String function value(model : Element, name : String, mapping : Element):
  89. return "objDetected"!
  90. $
  91. }
  92. Post_Encapsulated_PetriNet/PortPlace (post_ports_13, post_ports_03) {
  93. label = "23"
  94. }
  95. Post_Encapsulated_PetriNet/Place post_ports_04 {
  96. label = "04"
  97. value_name = $
  98. String function value(model : Element, name : String, mapping : Element):
  99. return "no_objDetected"!
  100. $
  101. value_tokens = $
  102. Integer function value(model : Element, name : String, mapping : Element):
  103. return 0!
  104. $
  105. }
  106. Post_Encapsulated_PetriNet/Port post_ports_14 {
  107. label = "14"
  108. value_name = $
  109. String function value(model : Element, name : String, mapping : Element):
  110. return "no_objDetected"!
  111. $
  112. }
  113. Post_Encapsulated_PetriNet/PortPlace (post_ports_14, post_ports_04) {
  114. label = "24"
  115. }
  116. Post_Encapsulated_PetriNet/Place post_ports_05 {
  117. label = "05"
  118. value_name = $
  119. String function value(model : Element, name : String, mapping : Element):
  120. return "up"!
  121. $
  122. value_tokens = $
  123. Integer function value(model : Element, name : String, mapping : Element):
  124. // Set the detected output based on the initial state
  125. Element states
  126. String state
  127. states = allInstances(model, "PW_Control/State")
  128. while (read_nr_out(states) > 0):
  129. state = set_pop(states)
  130. if (value_eq(read_attribute(model, state, "isInitial"), True)):
  131. if (read_type(model, state) == "PW_Control/Up"):
  132. return 1!
  133. else:
  134. return 0!
  135. $
  136. }
  137. Post_Encapsulated_PetriNet/Port post_ports_15 {
  138. label = "15"
  139. value_name = $
  140. String function value(model : Element, name : String, mapping : Element):
  141. return "up"!
  142. $
  143. }
  144. Post_Encapsulated_PetriNet/PortPlace (post_ports_15, post_ports_05) {
  145. label = "25"
  146. }
  147. Post_Encapsulated_PetriNet/Place post_ports_06 {
  148. label = "06"
  149. value_name = $
  150. String function value(model : Element, name : String, mapping : Element):
  151. return "neutral"!
  152. $
  153. value_tokens = $
  154. Integer function value(model : Element, name : String, mapping : Element):
  155. // Set the detected output based on the initial state
  156. Element states
  157. String state
  158. states = allInstances(model, "PW_Control/State")
  159. while (read_nr_out(states) > 0):
  160. state = set_pop(states)
  161. if (value_eq(read_attribute(model, state, "isInitial"), True)):
  162. if (read_type(model, state) == "PW_Control/Neutral"):
  163. return 1!
  164. else:
  165. return 0!
  166. $
  167. }
  168. Post_Encapsulated_PetriNet/Port post_ports_16 {
  169. label = "16"
  170. value_name = $
  171. String function value(model : Element, name : String, mapping : Element):
  172. return "neutral"!
  173. $
  174. }
  175. Post_Encapsulated_PetriNet/PortPlace (post_ports_16, post_ports_06) {
  176. label = "26"
  177. }
  178. Post_Encapsulated_PetriNet/Place post_ports_07 {
  179. label = "07"
  180. value_name = $
  181. String function value(model : Element, name : String, mapping : Element):
  182. return "down"!
  183. $
  184. value_tokens = $
  185. Integer function value(model : Element, name : String, mapping : Element):
  186. // Set the detected output based on the initial state
  187. Element states
  188. String state
  189. states = allInstances(model, "PW_Control/State")
  190. while (read_nr_out(states) > 0):
  191. state = set_pop(states)
  192. if (value_eq(read_attribute(model, state, "isInitial"), True)):
  193. if (read_type(model, state) == "PW_Control/Down"):
  194. return 1!
  195. else:
  196. return 0!
  197. $
  198. }
  199. Post_Encapsulated_PetriNet/Port post_ports_17 {
  200. label = "17"
  201. value_name = $
  202. String function value(model : Element, name : String, mapping : Element):
  203. return "down"!
  204. $
  205. }
  206. Post_Encapsulated_PetriNet/PortPlace (post_ports_17, post_ports_07) {
  207. label = "27"
  208. }
  209. Post_Encapsulated_PetriNet/Place post_ports_08 {
  210. label = "08"
  211. value_name = $
  212. String function value(model : Element, name : String, mapping : Element):
  213. return "interrupt"!
  214. $
  215. value_tokens = $
  216. Integer function value(model : Element, name : String, mapping : Element):
  217. return 0!
  218. $
  219. }
  220. Post_Encapsulated_PetriNet/Port post_ports_18 {
  221. label = "18"
  222. value_name = $
  223. String function value(model : Element, name : String, mapping : Element):
  224. return "interrupt"!
  225. $
  226. }
  227. Post_Encapsulated_PetriNet/PortPlace (post_ports_18, post_ports_08) {
  228. label = "28"
  229. }
  230. }
  231. }
  232. {Contains} ForAll create_states {
  233. LHS {
  234. Pre_PW_Control/State {
  235. label = "0"
  236. }
  237. }
  238. RHS {
  239. Post_PW_Control/State post_cs_0 {
  240. label = "0"
  241. }
  242. Post_Encapsulated_PetriNet/Place post_cs_1 {
  243. label = "1"
  244. value_name = $
  245. String function value(model : Element, name : String, mapping : Element):
  246. return read_attribute(model, mapping["0"], "name")!
  247. $
  248. value_tokens = $
  249. Integer function value(model : Element, name : String, mapping : Element):
  250. if (value_eq(read_attribute(model, mapping["0"], "isInitial"), True)):
  251. return 1!
  252. else:
  253. return 0!
  254. $
  255. }
  256. Post_CTRL2EPN_link (post_cs_0, post_cs_1) {
  257. label = "2"
  258. }
  259. }
  260. }
  261. {Contains} ForAll create_transitions {
  262. LHS {
  263. Pre_PW_Control/State pre_ct_0 {
  264. label = "0"
  265. }
  266. Pre_PW_Control/State pre_ct_1 {
  267. label = "1"
  268. }
  269. Pre_PW_Control/Transition pre_ct_2 (pre_ct_0, pre_ct_1) {
  270. label = "2"
  271. }
  272. Pre_Encapsulated_PetriNet/Place pre_ct_3 {
  273. label = "3"
  274. }
  275. Pre_Encapsulated_PetriNet/Place pre_ct_4 {
  276. label = "4"
  277. }
  278. Pre_CTRL2EPN_link (pre_ct_0, pre_ct_3) {
  279. label = "5"
  280. }
  281. Pre_CTRL2EPN_link (pre_ct_1, pre_ct_4) {
  282. label = "6"
  283. }
  284. Pre_Encapsulated_PetriNet/Port pre_ct_9 {
  285. label = "9"
  286. constraint_name = $
  287. Boolean function constraint(value : String):
  288. return bool_or(bool_or(value == "up", value == "neutral"), value == "down")!
  289. $
  290. }
  291. Pre_Encapsulated_PetriNet/Place pre_ct_7 {
  292. label = "7"
  293. }
  294. Pre_Encapsulated_PetriNet/PortPlace (pre_ct_9, pre_ct_7) {
  295. label = "8"
  296. }
  297. Pre_Encapsulated_PetriNet/Port pre_ct_12 {
  298. label = "12"
  299. constraint_name = $
  300. Boolean function constraint(value : String):
  301. return bool_or(bool_or(value == "up", value == "neutral"), value == "down")!
  302. $
  303. }
  304. Pre_Encapsulated_PetriNet/Place pre_ct_10 {
  305. label = "10"
  306. }
  307. Pre_Encapsulated_PetriNet/PortPlace (pre_ct_12, pre_ct_10) {
  308. label = "11"
  309. }
  310. Pre_Encapsulated_PetriNet/Port pre_ct_15 {
  311. label = "15"
  312. constraint_name = $
  313. Boolean function constraint(value : String):
  314. return bool_or(bool_or(value == "cmdUp", value == "cmdNeutral"), value == "cmdDown")!
  315. $
  316. }
  317. Pre_Encapsulated_PetriNet/Place pre_ct_13 {
  318. label = "13"
  319. }
  320. Pre_Encapsulated_PetriNet/PortPlace (pre_ct_15, pre_ct_13) {
  321. label = "14"
  322. }
  323. constraint = $
  324. Boolean function constraint (host_model : Element, mapping : Element):
  325. // Check whether the bound primary places match with the state
  326. String type_0
  327. String type_1
  328. String type_2
  329. String name_9
  330. String name_12
  331. String name_15
  332. type_0 = read_type(host_model, mapping["0"])
  333. type_1 = read_type(host_model, mapping["1"])
  334. type_2 = read_type(host_model, mapping["2"])
  335. name_9 = read_attribute(host_model, mapping["9"], "name")
  336. name_12 = read_attribute(host_model, mapping["12"], "name")
  337. name_15 = read_attribute(host_model, mapping["15"], "name")
  338. // Source part
  339. if (type_0 == "PW_Control/Up"):
  340. if (name_9 != "up"):
  341. return False!
  342. elif (type_0 == "PW_Control/Neutral"):
  343. if (name_9 != "neutral"):
  344. return False!
  345. elif (type_0 == "PW_Control/Down"):
  346. if (name_9 != "down"):
  347. return False!
  348. // Target part
  349. if (type_1 == "PW_Control/Up"):
  350. if (name_12 != "up"):
  351. return False!
  352. elif (type_1 == "PW_Control/Neutral"):
  353. if (name_12 != "neutral"):
  354. return False!
  355. elif (type_1 == "PW_Control/Down"):
  356. if (name_12 != "down"):
  357. return False!
  358. // Link part
  359. if (type_2 == "PW_Control/UpPressed"):
  360. if (name_15 != "cmdUp"):
  361. return False!
  362. elif (type_2 == "PW_Control/NonePressed"):
  363. if (name_15 != "cmdNeutral"):
  364. return False!
  365. elif (type_2 == "PW_Control/DownPressed"):
  366. if (name_15 != "cmdDown"):
  367. return False!
  368. // All passed, so OK!
  369. return True!
  370. $
  371. }
  372. RHS {
  373. Post_PW_Control/State post_ct_0 {
  374. label = "0"
  375. }
  376. Post_PW_Control/State post_ct_1 {
  377. label = "1"
  378. }
  379. Post_PW_Control/Transition post_ct_2 (post_ct_0, post_ct_1) {
  380. label = "2"
  381. }
  382. Post_Encapsulated_PetriNet/Place post_ct_3 {
  383. label = "3"
  384. }
  385. Post_Encapsulated_PetriNet/Place post_ct_4 {
  386. label = "4"
  387. }
  388. Post_CTRL2EPN_link (post_ct_0, post_ct_3) {
  389. label = "5"
  390. }
  391. Post_CTRL2EPN_link (post_ct_1, post_ct_4) {
  392. label = "6"
  393. }
  394. Post_Encapsulated_PetriNet/Place post_ct_7 {
  395. label = "7"
  396. }
  397. Post_Encapsulated_PetriNet/Port post_ct_9 {
  398. label = "9"
  399. }
  400. Post_Encapsulated_PetriNet/PortPlace (post_ct_9, post_ct_7) {
  401. label = "8"
  402. }
  403. Post_Encapsulated_PetriNet/Place post_ct_10 {
  404. label = "10"
  405. }
  406. Post_Encapsulated_PetriNet/Port post_ct_12 {
  407. label = "12"
  408. }
  409. Post_Encapsulated_PetriNet/PortPlace (post_ct_12, post_ct_10) {
  410. label = "11"
  411. }
  412. Post_Encapsulated_PetriNet/Place post_ct_13 {
  413. label = "13"
  414. }
  415. Post_Encapsulated_PetriNet/Port post_ct_15 {
  416. label = "15"
  417. }
  418. Post_Encapsulated_PetriNet/PortPlace (post_ct_15, post_ct_13) {
  419. label = "14"
  420. }
  421. Post_Encapsulated_PetriNet/Transition post_ct_16 {
  422. label = "16"
  423. value_name = $
  424. String function value(model : Element, name : String, mapping : Element):
  425. return string_join(string_join(read_attribute(model, mapping["0"], "name"), read_type(model, mapping["2"])), read_attribute(model, mapping["2"], "objDetected"))!
  426. $
  427. }
  428. Post_Encapsulated_PetriNet/P2T (post_ct_3, post_ct_16) {
  429. label = "17"
  430. }
  431. Post_Encapsulated_PetriNet/T2P (post_ct_16, post_ct_4) {
  432. label = "18"
  433. }
  434. Post_Encapsulated_PetriNet/P2T (post_ct_7, post_ct_16) {
  435. label = "19"
  436. }
  437. Post_Encapsulated_PetriNet/T2P (post_ct_16, post_ct_10) {
  438. label = "20"
  439. }
  440. Post_Encapsulated_PetriNet/P2T (post_ct_13, post_ct_16) {
  441. label = "21"
  442. }
  443. Post_Encapsulated_PetriNet/T2P (post_ct_16, post_ct_13) {
  444. label = "22"
  445. }
  446. Post_CTRL2EPN_tlink (post_ct_2, post_ct_16) {
  447. label = "100"
  448. }
  449. }
  450. }
  451. {Contains} ForAll check_object {
  452. LHS {
  453. Pre_PW_Control/State pre_co_0 {
  454. label = "0"
  455. }
  456. Pre_PW_Control/State pre_co_1 {
  457. label = "1"
  458. }
  459. Pre_PW_Control/Transition pre_co_2 (pre_co_0, pre_co_1) {
  460. label = "2"
  461. constraint_objDetected = $
  462. Boolean function constraint(value : String):
  463. return (bool_or(value == "Y", value == "N"))!
  464. $
  465. }
  466. Pre_Encapsulated_PetriNet/Place pre_co_8 {
  467. label = "8"
  468. }
  469. Pre_Encapsulated_PetriNet/Port pre_co_11 {
  470. label = "11"
  471. constraint_name = $
  472. Boolean function constraint(value : String):
  473. return (bool_or(value == "objDetected", value == "no_objDetected"))!
  474. $
  475. }
  476. Pre_Encapsulated_PetriNet/PortPlace (pre_co_11, pre_co_8) {
  477. label = "12"
  478. }
  479. Pre_Encapsulated_PetriNet/Transition pre_co_15 {
  480. label = "15"
  481. }
  482. Pre_CTRL2EPN_tlink (pre_co_2, pre_co_15) {
  483. label = "100"
  484. }
  485. constraint = $
  486. Boolean function constraint (host_model : Element, mapping : Element):
  487. // Check whether the bound primary places match with the state
  488. String s1_value
  489. String ps1_type
  490. s1_value = read_attribute(host_model, mapping["2"], "objDetected")
  491. ps1_type = read_attribute(host_model, mapping["11"], "name")
  492. if (s1_value == "Y"):
  493. return (ps1_type == "objDetected")!
  494. elif (s1_value == "N"):
  495. return (ps1_type == "no_objDetected")!
  496. else:
  497. return False!
  498. $
  499. }
  500. RHS {
  501. Post_PW_Control/State post_co_0 {
  502. label = "0"
  503. }
  504. Post_PW_Control/State post_co_1 {
  505. label = "1"
  506. }
  507. Post_PW_Control/Transition post_co_2 (post_co_0, post_co_1) {
  508. label = "2"
  509. }
  510. Post_Encapsulated_PetriNet/Place post_co_8 {
  511. label = "8"
  512. }
  513. Post_Encapsulated_PetriNet/Port post_co_11 {
  514. label = "11"
  515. }
  516. Post_Encapsulated_PetriNet/PortPlace (post_co_11, post_co_8) {
  517. label = "12"
  518. }
  519. Post_Encapsulated_PetriNet/Transition post_co_15 {
  520. label = "15"
  521. }
  522. Post_Encapsulated_PetriNet/P2T (post_co_8, post_co_15) {
  523. label = "9"
  524. }
  525. Post_Encapsulated_PetriNet/T2P (post_co_15, post_co_8) {
  526. label = "10"
  527. }
  528. Post_CTRL2EPN_tlink (post_co_2, post_co_15) {
  529. label = "100"
  530. }
  531. }
  532. }
  533. {Contains} ForAll fix_interrupt {
  534. LHS {
  535. Pre_PW_Control/State pre_fi_0 {
  536. label = "0"
  537. }
  538. Pre_PW_Control/State pre_fi_1 {
  539. label = "1"
  540. constraint_isError = $
  541. Boolean function constraint(value : Boolean):
  542. return value!
  543. $
  544. }
  545. Pre_Encapsulated_PetriNet/Place pre_fi_2 {
  546. label = "2"
  547. }
  548. Pre_Encapsulated_PetriNet/Place pre_fi_3 {
  549. label = "3"
  550. }
  551. Pre_CTRL2EPN_link (pre_fi_0, pre_fi_2) {
  552. label = "4"
  553. }
  554. Pre_CTRL2EPN_link (pre_fi_1, pre_fi_3) {
  555. label = "5"
  556. }
  557. Pre_Encapsulated_PetriNet/Place pre_fi_6 {
  558. label = "6"
  559. }
  560. Pre_Encapsulated_PetriNet/Place pre_fi_12 {
  561. label = "12"
  562. }
  563. Pre_Encapsulated_PetriNet/Port pre_fi_13 {
  564. label = "13"
  565. }
  566. Pre_Encapsulated_PetriNet/PortPlace (pre_fi_13, pre_fi_12) {
  567. label = "14"
  568. }
  569. Pre_Encapsulated_PetriNet/Port pre_fi_15 {
  570. label = "15"
  571. constraint_name = $
  572. Boolean function constraint(value : String):
  573. return (value == "interrupt")!
  574. $
  575. }
  576. Pre_Encapsulated_PetriNet/PortPlace (pre_fi_15, pre_fi_6) {
  577. label = "16"
  578. }
  579. constraint = $
  580. Boolean function constraint (host_model : Element, mapping : Element):
  581. // Check whether the bound primary places match with the state
  582. String s_err_type
  583. String p_name
  584. s_err_type = read_type(host_model, mapping["1"])
  585. p_name = read_attribute(host_model, mapping["13"], "name")
  586. if (s_err_type == "PW_Control/Up"):
  587. return (p_name == "up")!
  588. elif (s_err_type == "PW_Control/Neutral"):
  589. return (p_name == "neutral")!
  590. elif (s_err_type == "PW_Control/Down"):
  591. return (p_name == "down")!
  592. else:
  593. return False!
  594. $
  595. }
  596. RHS {
  597. Post_PW_Control/State post_fi_0 {
  598. label = "0"
  599. }
  600. Post_PW_Control/State post_fi_1 {
  601. label = "1"
  602. }
  603. Post_Encapsulated_PetriNet/Place post_fi_2 {
  604. label = "2"
  605. }
  606. Post_Encapsulated_PetriNet/Place post_fi_3 {
  607. label = "3"
  608. }
  609. Post_CTRL2EPN_link (post_fi_0, post_fi_2) {
  610. label = "4"
  611. }
  612. Post_CTRL2EPN_link (post_fi_1, post_fi_3) {
  613. label = "5"
  614. }
  615. Post_Encapsulated_PetriNet/Place post_fi_6 {
  616. label = "6"
  617. }
  618. Post_Encapsulated_PetriNet/Place post_fi_12 {
  619. label = "12"
  620. }
  621. Post_Encapsulated_PetriNet/Port post_fi_13 {
  622. label = "13"
  623. }
  624. Post_Encapsulated_PetriNet/PortPlace (post_fi_13, post_fi_12) {
  625. label = "14"
  626. }
  627. Post_Encapsulated_PetriNet/Port post_fi_15 {
  628. label = "15"
  629. }
  630. Post_Encapsulated_PetriNet/PortPlace (post_fi_15, post_fi_6) {
  631. label = "16"
  632. }
  633. Post_Encapsulated_PetriNet/Transition post_fi_7 {
  634. label = "7"
  635. value_name = $
  636. String function value(model : Element, name : String, mapping : Element):
  637. return string_join(read_attribute(model, mapping["0"], "name"), "_onInterrupt")!
  638. $
  639. }
  640. Post_Encapsulated_PetriNet/P2T (post_fi_2, post_fi_7) {
  641. label = "8"
  642. }
  643. Post_Encapsulated_PetriNet/T2P (post_fi_7, post_fi_3) {
  644. label = "9"
  645. }
  646. Post_Encapsulated_PetriNet/P2T (post_fi_6, post_fi_7) {
  647. label = "10"
  648. }
  649. Post_Encapsulated_PetriNet/T2P (post_fi_7, post_fi_12) {
  650. label = "11"
  651. }
  652. }
  653. }
  654. {Contains} ForAll fix_interrupt_self {
  655. LHS {
  656. Pre_PW_Control/State pre_fis_0 {
  657. label = "0"
  658. constraint_isError = $
  659. Boolean function constraint(value : Boolean):
  660. return value!
  661. $
  662. }
  663. Pre_Encapsulated_PetriNet/Place pre_fis_1 {
  664. label = "1"
  665. }
  666. Pre_CTRL2EPN_link (pre_fis_0, pre_fis_1) {
  667. label = "2"
  668. }
  669. Pre_Encapsulated_PetriNet/Place pre_fis_3 {
  670. label = "3"
  671. }
  672. Pre_Encapsulated_PetriNet/Port pre_fis_4 {
  673. label = "4"
  674. constraint_name = $
  675. Boolean function constraint(value : String):
  676. return (value == "interrupt")!
  677. $
  678. }
  679. Pre_Encapsulated_PetriNet/PortPlace (pre_fis_4, pre_fis_3) {
  680. label = "5"
  681. }
  682. Pre_Encapsulated_PetriNet/Place pre_fis_6 {
  683. label = "6"
  684. }
  685. Pre_Encapsulated_PetriNet/Port pre_fis_7 {
  686. label = "7"
  687. }
  688. Pre_Encapsulated_PetriNet/PortPlace (pre_fis_7, pre_fis_6) {
  689. label = "8"
  690. }
  691. constraint = $
  692. Boolean function constraint (host_model : Element, mapping : Element):
  693. // Check whether the bound primary places match with the state
  694. String s_err_type
  695. String p_name
  696. s_err_type = read_type(host_model, mapping["0"])
  697. p_name = read_attribute(host_model, mapping["7"], "name")
  698. if (s_err_type == "PW_Control/Up"):
  699. return (p_name == "up")!
  700. elif (s_err_type == "PW_Control/Neutral"):
  701. return (p_name == "neutral")!
  702. elif (s_err_type == "PW_Control/Down"):
  703. return (p_name == "down")!
  704. else:
  705. return False!
  706. $
  707. }
  708. RHS {
  709. Post_PW_Control/State post_fis_0 {
  710. label = "0"
  711. }
  712. Post_Encapsulated_PetriNet/Place post_fis_1 {
  713. label = "1"
  714. }
  715. Post_CTRL2EPN_link (post_fis_0, post_fis_1) {
  716. label = "2"
  717. }
  718. Post_Encapsulated_PetriNet/Place post_fis_3 {
  719. label = "3"
  720. }
  721. Post_Encapsulated_PetriNet/Port post_fis_4 {
  722. label = "4"
  723. }
  724. Post_Encapsulated_PetriNet/PortPlace (post_fis_4, post_fis_3) {
  725. label = "5"
  726. }
  727. Post_Encapsulated_PetriNet/Place post_fis_6 {
  728. label = "6"
  729. }
  730. Post_Encapsulated_PetriNet/Port post_fis_7 {
  731. label = "7"
  732. }
  733. Post_Encapsulated_PetriNet/PortPlace (post_fis_7, post_fis_6) {
  734. label = "8"
  735. }
  736. Post_Encapsulated_PetriNet/Transition post_fis_9 {
  737. label = "9"
  738. value_name = $
  739. String function value(model : Element, name : String, mapping : Element):
  740. return string_join(read_attribute(model, mapping["0"], "name"), "_onInterrupt")!
  741. $
  742. }
  743. Post_Encapsulated_PetriNet/P2T (post_fis_3, post_fis_9) {
  744. label = "10"
  745. }
  746. Post_Encapsulated_PetriNet/T2P (post_fis_9, post_fis_6) {
  747. label = "11"
  748. }
  749. Post_Encapsulated_PetriNet/P2T (post_fis_1, post_fis_9) {
  750. label = "12"
  751. }
  752. Post_Encapsulated_PetriNet/T2P (post_fis_9, post_fis_1) {
  753. label = "13"
  754. }
  755. }
  756. }
  757. }
  758. Initial (schedule, init_ports) {}
  759. OnSuccess (init_ports, create_states) {}
  760. OnSuccess (create_states, create_transitions) {}
  761. OnSuccess (create_transitions, check_object) {}
  762. OnSuccess (check_object, fix_interrupt) {}
  763. OnSuccess (fix_interrupt, fix_interrupt_self) {}
  764. OnSuccess (fix_interrupt_self, success) {}
  765. OnFailure (init_ports, create_states) {}
  766. OnFailure (create_states, create_transitions) {}
  767. OnFailure (create_transitions, check_object) {}
  768. OnFailure (check_object, fix_interrupt) {}
  769. OnFailure (fix_interrupt, fix_interrupt_self) {}
  770. OnFailure (fix_interrupt_self, success) {}
  771. }