test_powerwindow.py 21 KB

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