test_powerwindow.py 21 KB

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