test_powerwindow.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  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. "PLANT2EPN_link",
  94. "PW_Plant/State",
  95. "Encapsulated_PetriNet/Place",
  96. "instantiate",
  97. "Association",
  98. "ENV2EPN_link",
  99. "PW_Environment/Event",
  100. "Encapsulated_PetriNet/Place",
  101. "instantiate",
  102. "Association",
  103. "EPN2PN_place_link",
  104. "Encapsulated_PetriNet/Place",
  105. "PetriNet/Place",
  106. "instantiate",
  107. "Association",
  108. "EPN2PN_transition_link",
  109. "Encapsulated_PetriNet/Transition",
  110. "PetriNet/Transition",
  111. "exit",
  112. "transformation_RAMify",
  113. "__merged_All_RAM",
  114. "All_RAM",
  115. "transformation_add_MANUAL",
  116. "",
  117. "Requirements",
  118. "",
  119. "define_req",
  120. "transformation_add_MANUAL",
  121. "Requirements",
  122. "PW_Environment",
  123. "",
  124. "PW_Environment",
  125. "",
  126. "refine_environment",
  127. "transformation_add_MANUAL",
  128. "Requirements",
  129. "PW_Plant",
  130. "",
  131. "PW_Plant",
  132. "",
  133. "refine_plant",
  134. "transformation_add_MANUAL",
  135. "Requirements",
  136. "PW_Control",
  137. "",
  138. "PW_Control",
  139. "",
  140. "refine_control",
  141. "transformation_add_MANUAL",
  142. "Requirements",
  143. "Query",
  144. "",
  145. "Query",
  146. "",
  147. "refine_query",
  148. "transformation_add_MT",
  149. "All_RAM",
  150. "",
  151. "PW_Plant",
  152. "PW_Environment",
  153. "PW_Control",
  154. "Query",
  155. "",
  156. "make_initial_models",
  157. ] + get_model_constructor_2("models/initialize.mvc") + [
  158. "transformation_add_MT",
  159. "All_RAM",
  160. "PW_Plant",
  161. "",
  162. "Encapsulated_PetriNet",
  163. "",
  164. "plant_to_EPN",
  165. ] + get_model_constructor_2("models/plant_to_EPN.mvc") + [
  166. "transformation_add_MT",
  167. "All_RAM",
  168. "PW_Control",
  169. "",
  170. "Encapsulated_PetriNet",
  171. "",
  172. "control_to_EPN",
  173. ] + get_model_constructor_2("models/control_to_EPN.mvc") + [
  174. "transformation_add_MT",
  175. "All_RAM",
  176. "PW_Environment",
  177. "",
  178. "Encapsulated_PetriNet",
  179. "",
  180. "environment_to_EPN",
  181. ] + get_model_constructor_2("models/environment_to_EPN.mvc") + [
  182. "transformation_add_MT",
  183. "All_RAM",
  184. "Encapsulated_PetriNet",
  185. "",
  186. "Encapsulated_PetriNet",
  187. "",
  188. "combine_EPN",
  189. ] + get_model_constructor_2("models/combine_EPN.mvc") + [
  190. "transformation_add_AL",
  191. "PetriNet",
  192. "",
  193. "ReachabilityGraph",
  194. "",
  195. "reachability",
  196. ] + get_constructor(open("integration/code/reachability.alc", "r").read()) + [
  197. "transformation_add_MT",
  198. "All_RAM",
  199. "ReachabilityGraph",
  200. "Query",
  201. "",
  202. "",
  203. "matches",
  204. ] + get_model_constructor_2("models/matches.mvc") + [
  205. "transformation_add_AL",
  206. "PetriNet",
  207. "",
  208. "PetriNet",
  209. "",
  210. "pn_print",
  211. ] + get_constructor(open("models/pn_print.alc", "r").read()) + [
  212. "transformation_add_AL",
  213. "Encapsulated_PetriNet",
  214. "",
  215. "Encapsulated_PetriNet",
  216. "",
  217. "epn_print",
  218. ] + get_constructor(open("models/epn_print.alc", "r").read()) + [
  219. "model_list",
  220. "process_execute",
  221. "pm_powerwindow",
  222. "pm_",
  223. # define_req
  224. "upload",
  225. ] + get_model_constructor_2("models/requirements_model.mvc") + [
  226. "exit",
  227. # refine_plant
  228. "upload",
  229. ] + get_model_constructor_2("models/plant_model.mvc") + [
  230. "exit",
  231. # refine_environment
  232. "upload",
  233. ] + get_model_constructor_2("models/environment_model.mvc") + [
  234. "exit",
  235. # refine_control
  236. "upload",
  237. ] + get_model_constructor_2("models/control_model.mvc") + [
  238. "exit",
  239. # refine_query
  240. "upload",
  241. ] + get_model_constructor_2("models/query_model.mvc") + [
  242. "exit",
  243. ],
  244. [ # bootup phase
  245. "Desired username for admin user?",
  246. "Desired password for admin user?",
  247. "Please repeat the password",
  248. "Passwords match!",
  249. "Welcome to the Model Management Interface v2.0!",
  250. "Use the 'help' command for a list of possible commands",
  251. "Ready for command...",
  252. # model_add * 9
  253. ] + [ "Creating new model!",
  254. "Model type?",
  255. "Model name?",
  256. "Waiting for model constructors...",
  257. "Model upload success!",
  258. "Ready for command...", ] * 9 + [
  259. # model_list
  260. model_list |
  261. set([
  262. " ReachabilityGraph : SimpleClassDiagrams",
  263. " PetriNet : SimpleClassDiagrams",
  264. " Encapsulated_PetriNet : SimpleClassDiagrams",
  265. " PW_Plant : SimpleClassDiagrams",
  266. " PW_Environment : SimpleClassDiagrams",
  267. " PW_Control : SimpleClassDiagrams",
  268. " Requirements : SimpleClassDiagrams",
  269. " Query : SimpleClassDiagrams",
  270. " pm_powerwindow : ProcessModel",
  271. ]),
  272. "Ready for command...",
  273. # transformation_add_MT_language
  274. "Formalisms to include (terminate with empty string)?",
  275. "Name of the RAMified transformation metamodel?",
  276. "Ready for command...",
  277. # model_modify
  278. "Which model do you want to modify?",
  279. "Model loaded, ready for commands!",
  280. "Use 'help' command for a list of possible commands",
  281. "Please give your command.",
  282. # instantiate * 5
  283. ] + [ "Type to instantiate?",
  284. "Name of new element?",
  285. "Source name?",
  286. "Destination name?",
  287. "Instantiation successful!",
  288. "Please give your command.", ] * 5 + [
  289. "Ready for command...",
  290. # transformation_RAMify
  291. "Which metamodel do you want to RAMify?",
  292. "Where do you want to store the RAMified metamodel?",
  293. "Ready for command...",
  294. # transformation_add_MANUAL
  295. ] + [
  296. "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
  297. "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
  298. "Model added as target",
  299. "Name of Manual operation model?",
  300. "Ready for command...",
  301. ] + [
  302. # transformation_add_MANUAL * 4
  303. ] + [
  304. "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
  305. "Model added as source",
  306. "Model added as source",
  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. ] * 4 + [
  312. # transformation_add_MT
  313. "RAMified metamodel to use?",
  314. "Supported metamodels:",
  315. set([" PetriNet",
  316. " Encapsulated_PetriNet",
  317. " PW_Plant",
  318. " Query",
  319. " PW_Environment",
  320. " Requirements",
  321. " PW_Control",
  322. " ReachabilityGraph",
  323. ]),
  324. "",
  325. "Which ones do you want to use as source (empty string to finish)?",
  326. "Which ones do you want to use as target (empty string to finish)?",
  327. "Model added as target",
  328. "Model added as target",
  329. "Model added as target",
  330. "Model added as target",
  331. "Name of new transformation?",
  332. "Waiting for model constructors...",
  333. "Ready for command...",
  334. # transformation_add_MT
  335. "RAMified metamodel to use?",
  336. "Supported metamodels:",
  337. set([" PetriNet",
  338. " Encapsulated_PetriNet",
  339. " Query",
  340. " PW_Plant",
  341. " PW_Environment",
  342. " Requirements",
  343. " PW_Control",
  344. " ReachabilityGraph",
  345. ]),
  346. "",
  347. "Which ones do you want to use as source (empty string to finish)?",
  348. "Model added as source",
  349. "Which ones do you want to use as target (empty string to finish)?",
  350. "Model added as target",
  351. "Name of new transformation?",
  352. "Waiting for model constructors...",
  353. "Ready for command...",
  354. # transformation_add_MT
  355. "RAMified metamodel to use?",
  356. "Supported metamodels:",
  357. set([" PetriNet",
  358. " Encapsulated_PetriNet",
  359. " Query",
  360. " PW_Plant",
  361. " PW_Environment",
  362. " Requirements",
  363. " PW_Control",
  364. " ReachabilityGraph",
  365. ]),
  366. "",
  367. "Which ones do you want to use as source (empty string to finish)?",
  368. "Model added as source",
  369. "Which ones do you want to use as target (empty string to finish)?",
  370. "Model added as target",
  371. "Name of new transformation?",
  372. "Waiting for model constructors...",
  373. "Ready for command...",
  374. # transformation_add_MT
  375. "RAMified metamodel to use?",
  376. "Supported metamodels:",
  377. set([" PetriNet",
  378. " Encapsulated_PetriNet",
  379. " Query",
  380. " PW_Plant",
  381. " PW_Environment",
  382. " Requirements",
  383. " PW_Control",
  384. " ReachabilityGraph",
  385. ]),
  386. "",
  387. "Which ones do you want to use as source (empty string to finish)?",
  388. "Model added as source",
  389. "Which ones do you want to use as target (empty string to finish)?",
  390. "Model added as target",
  391. "Name of new transformation?",
  392. "Waiting for model constructors...",
  393. "Ready for command...",
  394. # transformation_add_MT
  395. "RAMified metamodel to use?",
  396. "Supported metamodels:",
  397. set([" PetriNet",
  398. " Encapsulated_PetriNet",
  399. " Query",
  400. " PW_Plant",
  401. " PW_Environment",
  402. " Requirements",
  403. " PW_Control",
  404. " ReachabilityGraph",
  405. ]),
  406. "",
  407. "Which ones do you want to use as source (empty string to finish)?",
  408. "Model added as source",
  409. "Which ones do you want to use as target (empty string to finish)?",
  410. "Model added as target",
  411. "Name of new transformation?",
  412. "Waiting for model constructors...",
  413. "Ready for command...",
  414. # transformation_add_AL
  415. ] + [ "Which metamodels do you want to use as source for the action code (empty string to finish)?",
  416. "Model added as source",
  417. "Which metamodels do you want to use as target for the action code (empty string to finish)?",
  418. "Model added as target",
  419. "Name of Action Language model?",
  420. "Waiting for model constructors...",
  421. "Ready for command...", ] * 1 + [
  422. # transformation_add_MT
  423. "RAMified metamodel to use?",
  424. "Supported metamodels:",
  425. set([" PetriNet",
  426. " Encapsulated_PetriNet",
  427. " Query",
  428. " PW_Plant",
  429. " PW_Environment",
  430. " Requirements",
  431. " PW_Control",
  432. " ReachabilityGraph",
  433. ]),
  434. "",
  435. "Which ones do you want to use as source (empty string to finish)?",
  436. "Model added as source",
  437. "Model added as source",
  438. "Which ones do you want to use as target (empty string to finish)?",
  439. "Name of new transformation?",
  440. "Waiting for model constructors...",
  441. "Ready for command...",
  442. # transformation_add_AL * 2
  443. ] + [ "Which metamodels do you want to use as source for the action code (empty string to finish)?",
  444. "Model added as source",
  445. "Which metamodels do you want to use as target for the action code (empty string to finish)?",
  446. "Model added as target",
  447. "Name of Action Language model?",
  448. "Waiting for model constructors...",
  449. "Ready for command...", ] * 2 + [
  450. # model_list
  451. model_list |
  452. set([
  453. " PetriNet : SimpleClassDiagrams",
  454. " Encapsulated_PetriNet : SimpleClassDiagrams",
  455. " PW_Plant : SimpleClassDiagrams",
  456. " PW_Environment : SimpleClassDiagrams",
  457. " PW_Control : SimpleClassDiagrams",
  458. " Requirements : SimpleClassDiagrams",
  459. " Query : SimpleClassDiagrams",
  460. " reachability : ActionLanguage",
  461. " define_req : ManualOperation",
  462. " refine_plant : ManualOperation",
  463. " refine_control : ManualOperation",
  464. " refine_environment : ManualOperation",
  465. " refine_query : ManualOperation",
  466. " pn_print : ActionLanguage",
  467. " epn_print : ActionLanguage",
  468. " __merged_define_req : SimpleClassDiagrams",
  469. " __merged_All_RAM : SimpleClassDiagrams",
  470. " __merged_refine_plant : SimpleClassDiagrams",
  471. " __merged_refine_control : SimpleClassDiagrams",
  472. " __merged_refine_environment : SimpleClassDiagrams",
  473. " __merged_refine_query : SimpleClassDiagrams",
  474. " matches : All_RAM",
  475. " All_RAM : SimpleClassDiagrams",
  476. " make_initial_models : All_RAM",
  477. " pm_powerwindow : ProcessModel",
  478. " plant_to_EPN : All_RAM",
  479. " combine_EPN : All_RAM",
  480. " environment_to_EPN : All_RAM",
  481. " control_to_EPN : All_RAM",
  482. " ReachabilityGraph : SimpleClassDiagrams",
  483. ]),
  484. "Ready for command...",
  485. # process_execute
  486. "Which process model do you want to execute?",
  487. "Model prefix to use?",
  488. # Manual transformation define_req
  489. "Please perform manual transformation \"define_req\"",
  490. "Model loaded, ready for commands!",
  491. "Use 'help' command for a list of possible commands",
  492. "Please give your command.",
  493. "Waiting for model constructors...",
  494. "Please give your command.",
  495. # Manual transformation refine_plant
  496. "Please perform manual transformation \"refine_plant\"",
  497. "Model loaded, ready for commands!",
  498. "Use 'help' command for a list of possible commands",
  499. "Please give your command.",
  500. "Waiting for model constructors...",
  501. "Please give your command.",
  502. # Manual transformation refine_environment
  503. "Please perform manual transformation \"refine_environment\"",
  504. "Model loaded, ready for commands!",
  505. "Use 'help' command for a list of possible commands",
  506. "Please give your command.",
  507. "Waiting for model constructors...",
  508. "Please give your command.",
  509. # Manual transformation refine_control
  510. "Please perform manual transformation \"refine_control\"",
  511. "Model loaded, ready for commands!",
  512. "Use 'help' command for a list of possible commands",
  513. "Please give your command.",
  514. "Waiting for model constructors...",
  515. "Please give your command.",
  516. # Manual transformation refine_query
  517. "Please perform manual transformation \"refine_query\"",
  518. "Model loaded, ready for commands!",
  519. "Use 'help' command for a list of possible commands",
  520. "Please give your command.",
  521. "Waiting for model constructors...",
  522. "Please give your command.",
  523. # Computations happen without output
  524. # Finished, so we go back to the start
  525. "Ready for command...",
  526. ]))