test_powerwindow.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. import unittest
  2. from utils import *
  3. model_list = set([" SimpleClassDiagrams : SimpleClassDiagrams",
  4. " CoreFormalism : SimpleClassDiagrams",
  5. " ManualOperation : SimpleClassDiagrams",
  6. " ActionLanguage : SimpleClassDiagrams",
  7. " ProcessModel : SimpleClassDiagrams",
  8. " core : CoreFormalism"])
  9. model_full_list = set([" 221 root admin SimpleClassDiagrams : SimpleClassDiagrams",
  10. " 221 root admin CoreFormalism : SimpleClassDiagrams",
  11. " 221 root admin ActionLanguage : SimpleClassDiagrams",
  12. " 221 root admin ManualOperation : SimpleClassDiagrams",
  13. " 221 root admin ProcessModel : SimpleClassDiagrams",
  14. " 200 root admin core : CoreFormalism"])
  15. all_files = [ "core/mini_modify.alc",
  16. "core/core_formalism.mvc",
  17. "core/core_algorithm.alc",
  18. "core/pm.mvc",
  19. "primitives.alc",
  20. "object_operations.alc",
  21. "conformance_scd.alc",
  22. "library.alc",
  23. "transform.alc",
  24. "model_management.alc",
  25. "ramify.alc",
  26. "metamodels.alc",
  27. "random.alc",
  28. "constructors.alc",
  29. "modelling.alc",
  30. "compilation_manager.alc",
  31. ]
  32. class TestPowerWindow(unittest.TestCase):
  33. def test_process_powerwindow(self):
  34. self.assertTrue(run_file(all_files,
  35. [ "root", "root", "root",
  36. "model_add",
  37. "SimpleClassDiagrams",
  38. "ReachabilityGraph",
  39. ] + get_model_constructor_2("integration/code/reachability_graph.mvc") + [
  40. "model_add",
  41. "SimpleClassDiagrams",
  42. "PetriNet",
  43. ] + get_model_constructor_2("integration/code/pn_design.mvc") + [
  44. "model_add",
  45. "SimpleClassDiagrams",
  46. "Encapsulated_PetriNet",
  47. ] + get_model_constructor_2("models/petrinet_ports.mvc") + [
  48. "model_add",
  49. "SimpleClassDiagrams",
  50. "PW_Plant",
  51. ] + get_model_constructor_2("models/plant_PW.mvc") + [
  52. "model_add",
  53. "SimpleClassDiagrams",
  54. "PW_Environment",
  55. ] + get_model_constructor_2("models/environment_PW.mvc") + [
  56. "model_add",
  57. "SimpleClassDiagrams",
  58. "PW_Control",
  59. ] + get_model_constructor_2("models/control_PW.mvc") + [
  60. "model_add",
  61. "SimpleClassDiagrams",
  62. "Requirements",
  63. ] + get_model_constructor_2("models/requirements.mvc") + [
  64. "model_add",
  65. "SimpleClassDiagrams",
  66. "Query",
  67. ] + get_model_constructor_2("models/query.mvc") + [
  68. "model_add",
  69. "ProcessModel",
  70. "pm_powerwindow",
  71. ] + get_model_constructor_2("models/pm_req_analyse.mvc") + [
  72. "model_list",
  73. "transformation_add_MT_language",
  74. "PetriNet",
  75. "Encapsulated_PetriNet",
  76. "PW_Plant",
  77. "PW_Control",
  78. "PW_Environment",
  79. "Requirements",
  80. "ReachabilityGraph",
  81. "Query",
  82. "",
  83. "All_RAM",
  84. "model_modify",
  85. "__merged_All_RAM",
  86. "instantiate",
  87. "Association",
  88. "CTRL2EPN_link",
  89. "PW_Control/State",
  90. "Encapsulated_PetriNet/Place",
  91. "instantiate",
  92. "Association",
  93. "CTRL2EPN_tlink",
  94. "PW_Control/Transition",
  95. "Encapsulated_PetriNet/Transition",
  96. "instantiate",
  97. "Association",
  98. "PLANT2EPN_link",
  99. "PW_Plant/State",
  100. "Encapsulated_PetriNet/Place",
  101. "instantiate",
  102. "Association",
  103. "PLANT2EPN_tlink",
  104. "PW_Plant/Transition",
  105. "Encapsulated_PetriNet/Transition",
  106. "instantiate",
  107. "Association",
  108. "ENV2EPN_link",
  109. "PW_Environment/Event",
  110. "Encapsulated_PetriNet/Place",
  111. "instantiate",
  112. "Association",
  113. "EPN2PN_place_link",
  114. "Encapsulated_PetriNet/Place",
  115. "PetriNet/Place",
  116. "instantiate",
  117. "Association",
  118. "EPN2PN_transition_link",
  119. "Encapsulated_PetriNet/Transition",
  120. "PetriNet/Transition",
  121. "exit",
  122. "transformation_RAMify",
  123. "__merged_All_RAM",
  124. "All_RAM",
  125. "transformation_add_MANUAL",
  126. "",
  127. "Requirements",
  128. "",
  129. "define_req",
  130. "transformation_add_MANUAL",
  131. "Requirements",
  132. "PW_Environment",
  133. "",
  134. "PW_Environment",
  135. "",
  136. "refine_environment",
  137. "transformation_add_MANUAL",
  138. "Requirements",
  139. "PW_Plant",
  140. "",
  141. "PW_Plant",
  142. "",
  143. "refine_plant",
  144. "transformation_add_MANUAL",
  145. "Requirements",
  146. "PW_Control",
  147. "",
  148. "PW_Control",
  149. "",
  150. "refine_control",
  151. "transformation_add_MANUAL",
  152. "Requirements",
  153. "Query",
  154. "",
  155. "Query",
  156. "",
  157. "refine_query",
  158. "transformation_add_MT",
  159. "All_RAM",
  160. "",
  161. "PW_Plant",
  162. "PW_Environment",
  163. "PW_Control",
  164. "Query",
  165. "",
  166. "make_initial_models",
  167. ] + get_model_constructor_2("models/initialize.mvc") + [
  168. "transformation_add_MT",
  169. "All_RAM",
  170. "PW_Plant",
  171. "",
  172. "Encapsulated_PetriNet",
  173. "",
  174. "plant_to_EPN",
  175. ] + get_model_constructor_2("models/plant_to_EPN.mvc") + [
  176. "transformation_add_MT",
  177. "All_RAM",
  178. "PW_Control",
  179. "",
  180. "Encapsulated_PetriNet",
  181. "",
  182. "control_to_EPN",
  183. ] + get_model_constructor_2("models/control_to_EPN.mvc") + [
  184. "transformation_add_MT",
  185. "All_RAM",
  186. "PW_Environment",
  187. "",
  188. "Encapsulated_PetriNet",
  189. "",
  190. "environment_to_EPN",
  191. ] + get_model_constructor_2("models/environment_to_EPN.mvc") + [
  192. "transformation_add_MT",
  193. "All_RAM",
  194. "Encapsulated_PetriNet",
  195. "",
  196. "Encapsulated_PetriNet",
  197. "",
  198. "combine_EPN",
  199. ] + get_model_constructor_2("models/combine_EPN.mvc") + [
  200. "transformation_add_MT",
  201. "All_RAM",
  202. "ReachabilityGraph",
  203. "",
  204. "",
  205. "print_reachability",
  206. ] + get_model_constructor_2("integration/code/reachabilitygraph_print.mvc") + [
  207. "transformation_add_AL",
  208. "PetriNet",
  209. "",
  210. "ReachabilityGraph",
  211. "",
  212. "reachability",
  213. ] + get_constructor(open("integration/code/reachability.alc", "r").read()) + [
  214. "transformation_add_MT",
  215. "All_RAM",
  216. "ReachabilityGraph",
  217. "Query",
  218. "",
  219. "",
  220. "matches",
  221. ] + get_model_constructor_2("models/matches.mvc") + [
  222. "transformation_add_AL",
  223. "PetriNet",
  224. "",
  225. "PetriNet",
  226. "",
  227. "pn_print",
  228. ] + get_constructor(open("models/pn_print.alc", "r").read()) + [
  229. "transformation_add_AL",
  230. "Encapsulated_PetriNet",
  231. "",
  232. "Encapsulated_PetriNet",
  233. "",
  234. "epn_print",
  235. ] + get_constructor(open("models/epn_print.alc", "r").read()) + [
  236. "model_list",
  237. "process_execute",
  238. "pm_powerwindow",
  239. "pm_",
  240. # define_req
  241. "upload",
  242. ] + get_model_constructor_2("models/requirements_model.mvc") + [
  243. "exit",
  244. # refine_plant
  245. "upload",
  246. ] + get_model_constructor_2("models/plant_model.mvc") + [
  247. "exit",
  248. # refine_environment
  249. "upload",
  250. ] + get_model_constructor_2("models/environment_model.mvc") + [
  251. "exit",
  252. # refine_control
  253. "upload",
  254. ] + get_model_constructor_2("models/control_model.mvc") + [
  255. "exit",
  256. # refine_query
  257. "upload",
  258. ] + get_model_constructor_2("models/query_model.mvc") + [
  259. "exit",
  260. ],
  261. [ # bootup phase
  262. "Desired username for admin user?",
  263. "Desired password for admin user?",
  264. "Please repeat the password",
  265. "Passwords match!",
  266. "Welcome to the Model Management Interface v2.0!",
  267. "Use the 'help' command for a list of possible commands",
  268. "Ready for command...",
  269. # model_add * 9
  270. ] + [ "Creating new model!",
  271. "Model type?",
  272. "Model name?",
  273. "Waiting for model constructors...",
  274. "Model upload success!",
  275. "Ready for command...", ] * 9 + [
  276. # model_list
  277. model_list |
  278. set([
  279. " ReachabilityGraph : SimpleClassDiagrams",
  280. " PetriNet : SimpleClassDiagrams",
  281. " Encapsulated_PetriNet : SimpleClassDiagrams",
  282. " PW_Plant : SimpleClassDiagrams",
  283. " PW_Environment : SimpleClassDiagrams",
  284. " PW_Control : SimpleClassDiagrams",
  285. " Requirements : SimpleClassDiagrams",
  286. " Query : SimpleClassDiagrams",
  287. " pm_powerwindow : ProcessModel",
  288. ]),
  289. "Ready for command...",
  290. # transformation_add_MT_language
  291. "Formalisms to include (terminate with empty string)?",
  292. "Name of the RAMified transformation metamodel?",
  293. "Ready for command...",
  294. # model_modify
  295. "Which model do you want to modify?",
  296. "Model loaded, ready for commands!",
  297. "Use 'help' command for a list of possible commands",
  298. "Please give your command.",
  299. # instantiate * 7
  300. ] + [ "Type to instantiate?",
  301. "Name of new element?",
  302. "Source name?",
  303. "Destination name?",
  304. "Instantiation successful!",
  305. "Please give your command.", ] * 7 + [
  306. "Ready for command...",
  307. # transformation_RAMify
  308. "Which metamodel do you want to RAMify?",
  309. "Where do you want to store the RAMified metamodel?",
  310. "Ready for command...",
  311. # transformation_add_MANUAL
  312. ] + [
  313. "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
  314. "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
  315. "Model added as target",
  316. "Name of Manual operation model?",
  317. "Ready for command...",
  318. ] + [
  319. # transformation_add_MANUAL * 4
  320. ] + [
  321. "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
  322. "Model added as source",
  323. "Model added as source",
  324. "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
  325. "Model added as target",
  326. "Name of Manual operation model?",
  327. "Ready for command...",
  328. ] * 4 + [
  329. # transformation_add_MT
  330. "RAMified metamodel to use?",
  331. "Supported metamodels:",
  332. set([" PetriNet",
  333. " Encapsulated_PetriNet",
  334. " PW_Plant",
  335. " Query",
  336. " PW_Environment",
  337. " Requirements",
  338. " PW_Control",
  339. " ReachabilityGraph",
  340. ]),
  341. "",
  342. "Which ones do you want to use as source (empty string to finish)?",
  343. "Which ones do you want to use as target (empty string to finish)?",
  344. "Model added as target",
  345. "Model added as target",
  346. "Model added as target",
  347. "Model added as target",
  348. "Name of new transformation?",
  349. "Waiting for model constructors...",
  350. "Ready for command...",
  351. # transformation_add_MT
  352. "RAMified metamodel to use?",
  353. "Supported metamodels:",
  354. set([" PetriNet",
  355. " Encapsulated_PetriNet",
  356. " Query",
  357. " PW_Plant",
  358. " PW_Environment",
  359. " Requirements",
  360. " PW_Control",
  361. " ReachabilityGraph",
  362. ]),
  363. "",
  364. "Which ones do you want to use as source (empty string to finish)?",
  365. "Model added as source",
  366. "Which ones do you want to use as target (empty string to finish)?",
  367. "Model added as target",
  368. "Name of new transformation?",
  369. "Waiting for model constructors...",
  370. "Ready for command...",
  371. # transformation_add_MT
  372. "RAMified metamodel to use?",
  373. "Supported metamodels:",
  374. set([" PetriNet",
  375. " Encapsulated_PetriNet",
  376. " Query",
  377. " PW_Plant",
  378. " PW_Environment",
  379. " Requirements",
  380. " PW_Control",
  381. " ReachabilityGraph",
  382. ]),
  383. "",
  384. "Which ones do you want to use as source (empty string to finish)?",
  385. "Model added as source",
  386. "Which ones do you want to use as target (empty string to finish)?",
  387. "Model added as target",
  388. "Name of new transformation?",
  389. "Waiting for model constructors...",
  390. "Ready for command...",
  391. # transformation_add_MT
  392. "RAMified metamodel to use?",
  393. "Supported metamodels:",
  394. set([" PetriNet",
  395. " Encapsulated_PetriNet",
  396. " Query",
  397. " PW_Plant",
  398. " PW_Environment",
  399. " Requirements",
  400. " PW_Control",
  401. " ReachabilityGraph",
  402. ]),
  403. "",
  404. "Which ones do you want to use as source (empty string to finish)?",
  405. "Model added as source",
  406. "Which ones do you want to use as target (empty string to finish)?",
  407. "Model added as target",
  408. "Name of new transformation?",
  409. "Waiting for model constructors...",
  410. "Ready for command...",
  411. # transformation_add_MT
  412. "RAMified metamodel to use?",
  413. "Supported metamodels:",
  414. set([" PetriNet",
  415. " Encapsulated_PetriNet",
  416. " Query",
  417. " PW_Plant",
  418. " PW_Environment",
  419. " Requirements",
  420. " PW_Control",
  421. " ReachabilityGraph",
  422. ]),
  423. "",
  424. "Which ones do you want to use as source (empty string to finish)?",
  425. "Model added as source",
  426. "Which ones do you want to use as target (empty string to finish)?",
  427. "Model added as target",
  428. "Name of new transformation?",
  429. "Waiting for model constructors...",
  430. "Ready for command...",
  431. # transformation_add_MT
  432. "RAMified metamodel to use?",
  433. "Supported metamodels:",
  434. set([" PetriNet",
  435. " Encapsulated_PetriNet",
  436. " Query",
  437. " PW_Plant",
  438. " PW_Environment",
  439. " Requirements",
  440. " PW_Control",
  441. " ReachabilityGraph",
  442. ]),
  443. "",
  444. "Which ones do you want to use as source (empty string to finish)?",
  445. "Model added as source",
  446. "Which ones do you want to use as target (empty string to finish)?",
  447. "Name of new transformation?",
  448. "Waiting for model constructors...",
  449. "Ready for command...",
  450. # transformation_add_AL
  451. ] + [ "Which metamodels do you want to use as source for the action code (empty string to finish)?",
  452. "Model added as source",
  453. "Which metamodels do you want to use as target for the action code (empty string to finish)?",
  454. "Model added as target",
  455. "Name of Action Language model?",
  456. "Waiting for model constructors...",
  457. "Ready for command...", ] * 1 + [
  458. # transformation_add_MT
  459. "RAMified metamodel to use?",
  460. "Supported metamodels:",
  461. set([" PetriNet",
  462. " Encapsulated_PetriNet",
  463. " Query",
  464. " PW_Plant",
  465. " PW_Environment",
  466. " Requirements",
  467. " PW_Control",
  468. " ReachabilityGraph",
  469. ]),
  470. "",
  471. "Which ones do you want to use as source (empty string to finish)?",
  472. "Model added as source",
  473. "Model added as source",
  474. "Which ones do you want to use as target (empty string to finish)?",
  475. "Name of new transformation?",
  476. "Waiting for model constructors...",
  477. "Ready for command...",
  478. # transformation_add_AL * 2
  479. ] + [ "Which metamodels do you want to use as source for the action code (empty string to finish)?",
  480. "Model added as source",
  481. "Which metamodels do you want to use as target for the action code (empty string to finish)?",
  482. "Model added as target",
  483. "Name of Action Language model?",
  484. "Waiting for model constructors...",
  485. "Ready for command...", ] * 2 + [
  486. # model_list
  487. model_list |
  488. set([
  489. " PetriNet : SimpleClassDiagrams",
  490. " Encapsulated_PetriNet : SimpleClassDiagrams",
  491. " PW_Plant : SimpleClassDiagrams",
  492. " PW_Environment : SimpleClassDiagrams",
  493. " PW_Control : SimpleClassDiagrams",
  494. " Requirements : SimpleClassDiagrams",
  495. " Query : SimpleClassDiagrams",
  496. " reachability : ActionLanguage",
  497. " define_req : ManualOperation",
  498. " refine_plant : ManualOperation",
  499. " refine_control : ManualOperation",
  500. " refine_environment : ManualOperation",
  501. " refine_query : ManualOperation",
  502. " pn_print : ActionLanguage",
  503. " epn_print : ActionLanguage",
  504. " __merged_define_req : SimpleClassDiagrams",
  505. " __merged_All_RAM : SimpleClassDiagrams",
  506. " __merged_refine_plant : SimpleClassDiagrams",
  507. " __merged_refine_control : SimpleClassDiagrams",
  508. " __merged_refine_environment : SimpleClassDiagrams",
  509. " __merged_refine_query : SimpleClassDiagrams",
  510. " matches : All_RAM",
  511. " All_RAM : SimpleClassDiagrams",
  512. " make_initial_models : All_RAM",
  513. " pm_powerwindow : ProcessModel",
  514. " plant_to_EPN : All_RAM",
  515. " print_reachability : All_RAM",
  516. " combine_EPN : All_RAM",
  517. " environment_to_EPN : All_RAM",
  518. " control_to_EPN : All_RAM",
  519. " ReachabilityGraph : SimpleClassDiagrams",
  520. ]),
  521. "Ready for command...",
  522. # process_execute
  523. "Which process model do you want to execute?",
  524. "Model prefix to use?",
  525. # Manual transformation define_req
  526. "Please perform manual transformation \"define_req\"",
  527. "Model loaded, ready for commands!",
  528. "Use 'help' command for a list of possible commands",
  529. "Please give your command.",
  530. "Waiting for model constructors...",
  531. "Please give your command.",
  532. # Manual transformation refine_plant
  533. "Please perform manual transformation \"refine_plant\"",
  534. "Model loaded, ready for commands!",
  535. "Use 'help' command for a list of possible commands",
  536. "Please give your command.",
  537. "Waiting for model constructors...",
  538. "Please give your command.",
  539. # Manual transformation refine_environment
  540. "Please perform manual transformation \"refine_environment\"",
  541. "Model loaded, ready for commands!",
  542. "Use 'help' command for a list of possible commands",
  543. "Please give your command.",
  544. "Waiting for model constructors...",
  545. "Please give your command.",
  546. # Manual transformation refine_control
  547. "Please perform manual transformation \"refine_control\"",
  548. "Model loaded, ready for commands!",
  549. "Use 'help' command for a list of possible commands",
  550. "Please give your command.",
  551. "Waiting for model constructors...",
  552. "Please give your command.",
  553. # Manual transformation refine_query
  554. "Please perform manual transformation \"refine_query\"",
  555. "Model loaded, ready for commands!",
  556. "Use 'help' command for a list of possible commands",
  557. "Please give your command.",
  558. "Waiting for model constructors...",
  559. "Please give your command.",
  560. # Computations happen without output
  561. # Finished, so we go back to the start
  562. "Ready for command...",
  563. ]))