test_powerwindow.py 22 KB

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