test_powerwindow.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  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_AL",
  201. "PetriNet",
  202. "",
  203. "ReachabilityGraph",
  204. "",
  205. "reachability",
  206. ] + get_constructor(open("integration/code/reachability.alc", "r").read()) + [
  207. "transformation_add_MT",
  208. "All_RAM",
  209. "ReachabilityGraph",
  210. "Query",
  211. "",
  212. "",
  213. "matches",
  214. ] + get_model_constructor_2("models/matches.mvc") + [
  215. "transformation_add_AL",
  216. "PetriNet",
  217. "",
  218. "PetriNet",
  219. "",
  220. "pn_print",
  221. ] + get_constructor(open("models/pn_print.alc", "r").read()) + [
  222. "transformation_add_AL",
  223. "Encapsulated_PetriNet",
  224. "",
  225. "Encapsulated_PetriNet",
  226. "",
  227. "epn_print",
  228. ] + get_constructor(open("models/epn_print.alc", "r").read()) + [
  229. "model_list",
  230. "process_execute",
  231. "pm_powerwindow",
  232. "pm_",
  233. # define_req
  234. "upload",
  235. ] + get_model_constructor_2("models/requirements_model.mvc") + [
  236. "exit",
  237. # refine_plant
  238. "upload",
  239. ] + get_model_constructor_2("models/plant_model.mvc") + [
  240. "exit",
  241. # refine_environment
  242. "upload",
  243. ] + get_model_constructor_2("models/environment_model.mvc") + [
  244. "exit",
  245. # refine_control
  246. "upload",
  247. ] + get_model_constructor_2("models/control_model.mvc") + [
  248. "exit",
  249. # refine_query
  250. "upload",
  251. ] + get_model_constructor_2("models/query_model.mvc") + [
  252. "exit",
  253. ],
  254. [ # bootup phase
  255. "Desired username for admin user?",
  256. "Desired password for admin user?",
  257. "Please repeat the password",
  258. "Passwords match!",
  259. "Welcome to the Model Management Interface v2.0!",
  260. "Use the 'help' command for a list of possible commands",
  261. "Ready for command...",
  262. # model_add * 9
  263. ] + [ "Creating new model!",
  264. "Model type?",
  265. "Model name?",
  266. "Waiting for model constructors...",
  267. "Model upload success!",
  268. "Ready for command...", ] * 9 + [
  269. # model_list
  270. model_list |
  271. set([
  272. " ReachabilityGraph : SimpleClassDiagrams",
  273. " PetriNet : SimpleClassDiagrams",
  274. " Encapsulated_PetriNet : SimpleClassDiagrams",
  275. " PW_Plant : SimpleClassDiagrams",
  276. " PW_Environment : SimpleClassDiagrams",
  277. " PW_Control : SimpleClassDiagrams",
  278. " Requirements : SimpleClassDiagrams",
  279. " Query : SimpleClassDiagrams",
  280. " pm_powerwindow : ProcessModel",
  281. ]),
  282. "Ready for command...",
  283. # transformation_add_MT_language
  284. "Formalisms to include (terminate with empty string)?",
  285. "Name of the RAMified transformation metamodel?",
  286. "Ready for command...",
  287. # model_modify
  288. "Which model do you want to modify?",
  289. "Model loaded, ready for commands!",
  290. "Use 'help' command for a list of possible commands",
  291. "Please give your command.",
  292. # instantiate * 7
  293. ] + [ "Type to instantiate?",
  294. "Name of new element?",
  295. "Source name?",
  296. "Destination name?",
  297. "Instantiation successful!",
  298. "Please give your command.", ] * 7 + [
  299. "Ready for command...",
  300. # transformation_RAMify
  301. "Which metamodel do you want to RAMify?",
  302. "Where do you want to store the RAMified metamodel?",
  303. "Ready for command...",
  304. # transformation_add_MANUAL
  305. ] + [
  306. "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
  307. "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
  308. "Model added as target",
  309. "Name of Manual operation model?",
  310. "Ready for command...",
  311. ] + [
  312. # transformation_add_MANUAL * 4
  313. ] + [
  314. "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
  315. "Model added as source",
  316. "Model added as source",
  317. "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
  318. "Model added as target",
  319. "Name of Manual operation model?",
  320. "Ready for command...",
  321. ] * 4 + [
  322. # transformation_add_MT
  323. "RAMified metamodel to use?",
  324. "Supported metamodels:",
  325. set([" PetriNet",
  326. " Encapsulated_PetriNet",
  327. " PW_Plant",
  328. " Query",
  329. " PW_Environment",
  330. " Requirements",
  331. " PW_Control",
  332. " ReachabilityGraph",
  333. ]),
  334. "",
  335. "Which ones do you want to use as source (empty string to finish)?",
  336. "Which ones do you want to use as target (empty string to finish)?",
  337. "Model added as target",
  338. "Model added as target",
  339. "Model added as target",
  340. "Model added as target",
  341. "Name of new transformation?",
  342. "Waiting for model constructors...",
  343. "Ready for command...",
  344. # transformation_add_MT
  345. "RAMified metamodel to use?",
  346. "Supported metamodels:",
  347. set([" PetriNet",
  348. " Encapsulated_PetriNet",
  349. " Query",
  350. " PW_Plant",
  351. " PW_Environment",
  352. " Requirements",
  353. " PW_Control",
  354. " ReachabilityGraph",
  355. ]),
  356. "",
  357. "Which ones do you want to use as source (empty string to finish)?",
  358. "Model added as source",
  359. "Which ones do you want to use as target (empty string to finish)?",
  360. "Model added as target",
  361. "Name of new transformation?",
  362. "Waiting for model constructors...",
  363. "Ready for command...",
  364. # transformation_add_MT
  365. "RAMified metamodel to use?",
  366. "Supported metamodels:",
  367. set([" PetriNet",
  368. " Encapsulated_PetriNet",
  369. " Query",
  370. " PW_Plant",
  371. " PW_Environment",
  372. " Requirements",
  373. " PW_Control",
  374. " ReachabilityGraph",
  375. ]),
  376. "",
  377. "Which ones do you want to use as source (empty string to finish)?",
  378. "Model added as source",
  379. "Which ones do you want to use as target (empty string to finish)?",
  380. "Model added as target",
  381. "Name of new transformation?",
  382. "Waiting for model constructors...",
  383. "Ready for command...",
  384. # transformation_add_MT
  385. "RAMified metamodel to use?",
  386. "Supported metamodels:",
  387. set([" PetriNet",
  388. " Encapsulated_PetriNet",
  389. " Query",
  390. " PW_Plant",
  391. " PW_Environment",
  392. " Requirements",
  393. " PW_Control",
  394. " ReachabilityGraph",
  395. ]),
  396. "",
  397. "Which ones do you want to use as source (empty string to finish)?",
  398. "Model added as source",
  399. "Which ones do you want to use as target (empty string to finish)?",
  400. "Model added as target",
  401. "Name of new transformation?",
  402. "Waiting for model constructors...",
  403. "Ready for command...",
  404. # transformation_add_MT
  405. "RAMified metamodel to use?",
  406. "Supported metamodels:",
  407. set([" PetriNet",
  408. " Encapsulated_PetriNet",
  409. " Query",
  410. " PW_Plant",
  411. " PW_Environment",
  412. " Requirements",
  413. " PW_Control",
  414. " ReachabilityGraph",
  415. ]),
  416. "",
  417. "Which ones do you want to use as source (empty string to finish)?",
  418. "Model added as source",
  419. "Which ones do you want to use as target (empty string to finish)?",
  420. "Model added as target",
  421. "Name of new transformation?",
  422. "Waiting for model constructors...",
  423. "Ready for command...",
  424. # transformation_add_AL
  425. ] + [ "Which metamodels do you want to use as source for the action code (empty string to finish)?",
  426. "Model added as source",
  427. "Which metamodels do you want to use as target for the action code (empty string to finish)?",
  428. "Model added as target",
  429. "Name of Action Language model?",
  430. "Waiting for model constructors...",
  431. "Ready for command...", ] * 1 + [
  432. # transformation_add_MT
  433. "RAMified metamodel to use?",
  434. "Supported metamodels:",
  435. set([" PetriNet",
  436. " Encapsulated_PetriNet",
  437. " Query",
  438. " PW_Plant",
  439. " PW_Environment",
  440. " Requirements",
  441. " PW_Control",
  442. " ReachabilityGraph",
  443. ]),
  444. "",
  445. "Which ones do you want to use as source (empty string to finish)?",
  446. "Model added as source",
  447. "Model added as source",
  448. "Which ones do you want to use as target (empty string to finish)?",
  449. "Name of new transformation?",
  450. "Waiting for model constructors...",
  451. "Ready for command...",
  452. # transformation_add_AL * 2
  453. ] + [ "Which metamodels do you want to use as source for the action code (empty string to finish)?",
  454. "Model added as source",
  455. "Which metamodels do you want to use as target for the action code (empty string to finish)?",
  456. "Model added as target",
  457. "Name of Action Language model?",
  458. "Waiting for model constructors...",
  459. "Ready for command...", ] * 2 + [
  460. # model_list
  461. model_list |
  462. set([
  463. " PetriNet : SimpleClassDiagrams",
  464. " Encapsulated_PetriNet : SimpleClassDiagrams",
  465. " PW_Plant : SimpleClassDiagrams",
  466. " PW_Environment : SimpleClassDiagrams",
  467. " PW_Control : SimpleClassDiagrams",
  468. " Requirements : SimpleClassDiagrams",
  469. " Query : SimpleClassDiagrams",
  470. " reachability : ActionLanguage",
  471. " define_req : ManualOperation",
  472. " refine_plant : ManualOperation",
  473. " refine_control : ManualOperation",
  474. " refine_environment : ManualOperation",
  475. " refine_query : ManualOperation",
  476. " pn_print : ActionLanguage",
  477. " epn_print : ActionLanguage",
  478. " __merged_define_req : SimpleClassDiagrams",
  479. " __merged_All_RAM : SimpleClassDiagrams",
  480. " __merged_refine_plant : SimpleClassDiagrams",
  481. " __merged_refine_control : SimpleClassDiagrams",
  482. " __merged_refine_environment : SimpleClassDiagrams",
  483. " __merged_refine_query : SimpleClassDiagrams",
  484. " matches : All_RAM",
  485. " All_RAM : SimpleClassDiagrams",
  486. " make_initial_models : All_RAM",
  487. " pm_powerwindow : ProcessModel",
  488. " plant_to_EPN : All_RAM",
  489. " combine_EPN : All_RAM",
  490. " environment_to_EPN : All_RAM",
  491. " control_to_EPN : All_RAM",
  492. " ReachabilityGraph : SimpleClassDiagrams",
  493. ]),
  494. "Ready for command...",
  495. # process_execute
  496. "Which process model do you want to execute?",
  497. "Model prefix to use?",
  498. # Manual transformation define_req
  499. "Please perform manual transformation \"define_req\"",
  500. "Model loaded, ready for commands!",
  501. "Use 'help' command for a list of possible commands",
  502. "Please give your command.",
  503. "Waiting for model constructors...",
  504. "Please give your command.",
  505. # Manual transformation refine_plant
  506. "Please perform manual transformation \"refine_plant\"",
  507. "Model loaded, ready for commands!",
  508. "Use 'help' command for a list of possible commands",
  509. "Please give your command.",
  510. "Waiting for model constructors...",
  511. "Please give your command.",
  512. # Manual transformation refine_environment
  513. "Please perform manual transformation \"refine_environment\"",
  514. "Model loaded, ready for commands!",
  515. "Use 'help' command for a list of possible commands",
  516. "Please give your command.",
  517. "Waiting for model constructors...",
  518. "Please give your command.",
  519. # Manual transformation refine_control
  520. "Please perform manual transformation \"refine_control\"",
  521. "Model loaded, ready for commands!",
  522. "Use 'help' command for a list of possible commands",
  523. "Please give your command.",
  524. "Waiting for model constructors...",
  525. "Please give your command.",
  526. # Manual transformation refine_query
  527. "Please perform manual transformation \"refine_query\"",
  528. "Model loaded, ready for commands!",
  529. "Use 'help' command for a list of possible commands",
  530. "Please give your command.",
  531. "Waiting for model constructors...",
  532. "Please give your command.",
  533. # Computations happen without output
  534. # Finished, so we go back to the start
  535. "Ready for command...",
  536. ]))