test_powerwindow.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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. @slow
  34. def test_process_powerwindow_fast(self):
  35. self.assertTrue(run_file(all_files,
  36. [ "root", "root", "root",
  37. "model_add",
  38. "SimpleClassDiagrams",
  39. "ReachabilityGraph",
  40. ] + get_model_constructor_2("models/reachability_graph.mvc") + [
  41. "model_add",
  42. "SimpleClassDiagrams",
  43. "PetriNet",
  44. ] + get_model_constructor_2("integration/code/pn_design.mvc") + [
  45. "model_add",
  46. "SimpleClassDiagrams",
  47. "Encapsulated_PetriNet",
  48. ] + get_model_constructor_2("models/petrinet_ports.mvc") + [
  49. "model_add",
  50. "SimpleClassDiagrams",
  51. "PW_Plant",
  52. ] + get_model_constructor_2("models/plant_PW.mvc") + [
  53. "model_add",
  54. "SimpleClassDiagrams",
  55. "PW_Environment",
  56. ] + get_model_constructor_2("models/environment_PW.mvc") + [
  57. "model_add",
  58. "SimpleClassDiagrams",
  59. "PW_Control",
  60. ] + get_model_constructor_2("models/control_PW.mvc") + [
  61. "model_add",
  62. "SimpleClassDiagrams",
  63. "Requirements",
  64. ] + get_model_constructor_2("models/requirements.mvc") + [
  65. "model_add",
  66. "SimpleClassDiagrams",
  67. "Query",
  68. ] + get_model_constructor_2("models/query.mvc") + [
  69. "model_add",
  70. "ProcessModel",
  71. "pm_powerwindow",
  72. ] + get_model_constructor_2("models/pm_req_analyse.mvc") + [
  73. "model_add",
  74. "SimpleClassDiagrams",
  75. "Architecture",
  76. ] + get_model_constructor_2("models/architecture.mvc") + [
  77. "model_list",
  78. "transformation_add_MT_language",
  79. "PetriNet",
  80. "Encapsulated_PetriNet",
  81. "PW_Plant",
  82. "PW_Control",
  83. "PW_Environment",
  84. "Requirements",
  85. "ReachabilityGraph",
  86. "Query",
  87. "Architecture",
  88. "",
  89. "All_RAM",
  90. "model_modify",
  91. "__merged_All_RAM",
  92. "instantiate",
  93. "Association",
  94. "CTRL2EPN_link",
  95. "PW_Control/State",
  96. "Encapsulated_PetriNet/Place",
  97. "instantiate",
  98. "Association",
  99. "CTRL2EPN_tlink",
  100. "PW_Control/Transition",
  101. "Encapsulated_PetriNet/Transition",
  102. "instantiate",
  103. "Association",
  104. "PLANT2EPN_link",
  105. "PW_Plant/State",
  106. "Encapsulated_PetriNet/Place",
  107. "instantiate",
  108. "Association",
  109. "PLANT2EPN_tlink",
  110. "PW_Plant/Transition",
  111. "Encapsulated_PetriNet/Transition",
  112. "instantiate",
  113. "Association",
  114. "ENV2EPN_link",
  115. "PW_Environment/Event",
  116. "Encapsulated_PetriNet/Place",
  117. "instantiate",
  118. "Association",
  119. "EPN2PN_place_link",
  120. "Encapsulated_PetriNet/Place",
  121. "PetriNet/Place",
  122. "instantiate",
  123. "Association",
  124. "EPN2PN_transition_link",
  125. "Encapsulated_PetriNet/Transition",
  126. "PetriNet/Transition",
  127. "exit",
  128. "transformation_RAMify",
  129. "__merged_All_RAM",
  130. "All_RAM",
  131. "transformation_add_MANUAL",
  132. "Requirements",
  133. "",
  134. "Requirements",
  135. "",
  136. "revise_req",
  137. "transformation_add_MANUAL",
  138. "Requirements",
  139. "PW_Environment",
  140. "",
  141. "PW_Environment",
  142. "",
  143. "revise_environment",
  144. "transformation_add_MANUAL",
  145. "Requirements",
  146. "PW_Plant",
  147. "",
  148. "PW_Plant",
  149. "",
  150. "revise_plant",
  151. "transformation_add_MANUAL",
  152. "Requirements",
  153. "PW_Control",
  154. "",
  155. "PW_Control",
  156. "",
  157. "revise_control",
  158. "transformation_add_MANUAL",
  159. "Requirements",
  160. "Query",
  161. "",
  162. "Query",
  163. "",
  164. "revise_query",
  165. "transformation_add_MANUAL",
  166. "Requirements",
  167. "Architecture",
  168. "",
  169. "Architecture",
  170. "",
  171. "revise_architecture",
  172. "transformation_add_MT",
  173. "All_RAM",
  174. "",
  175. "PW_Plant",
  176. "PW_Environment",
  177. "PW_Control",
  178. "Query",
  179. "Architecture",
  180. "Requirements",
  181. "",
  182. "make_initial_models",
  183. ] + get_model_constructor_2("models/initialize.mvc") + [
  184. "transformation_add_MT",
  185. "All_RAM",
  186. "PW_Plant",
  187. "",
  188. "Encapsulated_PetriNet",
  189. "",
  190. "plant_to_EPN",
  191. ] + get_model_constructor_2("models/plant_to_EPN.mvc") + [
  192. "transformation_add_MT",
  193. "All_RAM",
  194. "PW_Control",
  195. "",
  196. "Encapsulated_PetriNet",
  197. "",
  198. "control_to_EPN",
  199. ] + get_model_constructor_2("models/control_to_EPN.mvc") + [
  200. "transformation_add_MT",
  201. "All_RAM",
  202. "PW_Environment",
  203. "",
  204. "Encapsulated_PetriNet",
  205. "",
  206. "environment_to_EPN",
  207. ] + get_model_constructor_2("models/environment_to_EPN.mvc") + [
  208. "transformation_add_MT",
  209. "All_RAM",
  210. "Encapsulated_PetriNet",
  211. "Architecture",
  212. "",
  213. "Encapsulated_PetriNet",
  214. "",
  215. "combine_EPN",
  216. ] + get_model_constructor_2("models/combine_EPN.mvc") + [
  217. "transformation_add_MT",
  218. "All_RAM",
  219. "ReachabilityGraph",
  220. "Query",
  221. "",
  222. "",
  223. "match",
  224. ] + get_model_constructor_2("models/matches.mvc") + [
  225. "transformation_add_AL",
  226. "PetriNet",
  227. "",
  228. "ReachabilityGraph",
  229. "",
  230. "reachability",
  231. ] + get_constructor(open("models/reachability.alc", "r").read()) + [
  232. "transformation_add_AL",
  233. "ReachabilityGraph",
  234. "",
  235. "",
  236. "bfs",
  237. ] + get_constructor(open("models/bfs.alc", "r").read()) + [
  238. "model_list",
  239. "process_execute",
  240. "pm_powerwindow",
  241. "pm_",
  242. # revise_req
  243. "upload",
  244. ] + get_model_constructor_2("models/requirements_model.mvc") + [
  245. "exit",
  246. # revise_plant
  247. "upload",
  248. ] + get_model_constructor_2("models/plant_model.mvc") + [
  249. "exit",
  250. # revise_environment
  251. "upload",
  252. ] + get_model_constructor_2("models/environment_model.mvc") + [
  253. "exit",
  254. # revise_control
  255. "upload",
  256. ] + get_model_constructor_2("models/control_model.mvc") + [
  257. "exit",
  258. # revise_query
  259. "upload",
  260. ] + get_model_constructor_2("models/query_model.mvc") + [
  261. "exit",
  262. # revise_architecture
  263. "upload",
  264. ] + get_model_constructor_2("models/architecture_model.mvc") + [
  265. "exit",
  266. ],
  267. [ # bootup phase
  268. "Desired username for admin user?",
  269. "Desired password for admin user?",
  270. "Please repeat the password",
  271. "Passwords match!",
  272. "Welcome to the Model Management Interface v2.0!",
  273. "Use the 'help' command for a list of possible commands",
  274. "Ready for command...",
  275. # model_add * 10
  276. ] + [ "Creating new model!",
  277. "Model type?",
  278. "Model name?",
  279. "Waiting for model constructors...",
  280. "Model upload success!",
  281. "Ready for command...", ] * 10 + [
  282. # model_list
  283. model_list |
  284. set([
  285. " ReachabilityGraph : SimpleClassDiagrams",
  286. " PetriNet : SimpleClassDiagrams",
  287. " Encapsulated_PetriNet : SimpleClassDiagrams",
  288. " PW_Plant : SimpleClassDiagrams",
  289. " PW_Environment : SimpleClassDiagrams",
  290. " PW_Control : SimpleClassDiagrams",
  291. " Requirements : SimpleClassDiagrams",
  292. " Query : SimpleClassDiagrams",
  293. " pm_powerwindow : ProcessModel",
  294. " Architecture : SimpleClassDiagrams",
  295. ]),
  296. "Ready for command...",
  297. # transformation_add_MT_language
  298. "Formalisms to include (terminate with empty string)?",
  299. "Name of the RAMified transformation metamodel?",
  300. "Ready for command...",
  301. # model_modify
  302. "Which model do you want to modify?",
  303. "Model loaded, ready for commands!",
  304. "Use 'help' command for a list of possible commands",
  305. "Please give your command.",
  306. # instantiate * 7
  307. ] + [ "Type to instantiate?",
  308. "Name of new element?",
  309. "Source name?",
  310. "Destination name?",
  311. "Instantiation successful!",
  312. "Please give your command.", ] * 7 + [
  313. "Ready for command...",
  314. # transformation_RAMify
  315. "Which metamodel do you want to RAMify?",
  316. "Where do you want to store the RAMified metamodel?",
  317. "Ready for command...",
  318. # transformation_add_MANUAL * 6
  319. ] + [
  320. "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
  321. "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
  322. "Name of Manual operation model?",
  323. "Ready for command...",
  324. ] * 6 + [
  325. # transformation_add_MT * 6
  326. ] + [
  327. "RAMified metamodel to use?",
  328. "Supported metamodels:",
  329. set([" PetriNet",
  330. " Encapsulated_PetriNet",
  331. " PW_Plant",
  332. " Architecture",
  333. " Query",
  334. " PW_Environment",
  335. " Requirements",
  336. " PW_Control",
  337. " ReachabilityGraph",
  338. ]),
  339. "",
  340. "Which ones do you want to use as source (empty string to finish)?",
  341. "Which ones do you want to use as target (empty string to finish)?",
  342. "Name of new transformation?",
  343. "Waiting for model constructors...",
  344. "Ready for command...",
  345. ] * 6 + [
  346. # transformation_add_AL * 2
  347. ] + [ "Which metamodels do you want to use as source for the action code (empty string to finish)?",
  348. "Which metamodels do you want to use as target for the action code (empty string to finish)?",
  349. "Name of Action Language model?",
  350. "Waiting for model constructors...",
  351. "Ready for command...", ] * 2 + [
  352. # model_list
  353. model_list |
  354. set([
  355. " PetriNet : SimpleClassDiagrams",
  356. " Encapsulated_PetriNet : SimpleClassDiagrams",
  357. " PW_Plant : SimpleClassDiagrams",
  358. " PW_Environment : SimpleClassDiagrams",
  359. " PW_Control : SimpleClassDiagrams",
  360. " Requirements : SimpleClassDiagrams",
  361. " Query : SimpleClassDiagrams",
  362. " reachability : ActionLanguage",
  363. " revise_req : ManualOperation",
  364. " revise_plant : ManualOperation",
  365. " revise_control : ManualOperation",
  366. " revise_environment : ManualOperation",
  367. " revise_query : ManualOperation",
  368. " revise_architecture : ManualOperation",
  369. " __merged_revise_req : SimpleClassDiagrams",
  370. " __merged_All_RAM : SimpleClassDiagrams",
  371. " __merged_revise_plant : SimpleClassDiagrams",
  372. " __merged_revise_control : SimpleClassDiagrams",
  373. " __merged_revise_environment : SimpleClassDiagrams",
  374. " __merged_revise_query : SimpleClassDiagrams",
  375. " __merged_revise_architecture : SimpleClassDiagrams",
  376. " matches : All_RAM",
  377. " All_RAM : SimpleClassDiagrams",
  378. " make_initial_models : All_RAM",
  379. " pm_powerwindow : ProcessModel",
  380. " plant_to_EPN : All_RAM",
  381. " combine_EPN : All_RAM",
  382. " environment_to_EPN : All_RAM",
  383. " control_to_EPN : All_RAM",
  384. " ReachabilityGraph : SimpleClassDiagrams",
  385. " Architecture : SimpleClassDiagrams",
  386. " bfs : ActionLanguage",
  387. ]),
  388. "Ready for command...",
  389. # process_execute
  390. "Which process model do you want to execute?",
  391. "Model prefix to use?",
  392. # Manual transformation revise_req
  393. "Please perform manual transformation \"revise_req\"",
  394. "Model loaded, ready for commands!",
  395. "Use 'help' command for a list of possible commands",
  396. "Please give your command.",
  397. "Waiting for model constructors...",
  398. "Please give your command.",
  399. # Manual transformation revise_plant
  400. "Please perform manual transformation \"revise_plant\"",
  401. "Model loaded, ready for commands!",
  402. "Use 'help' command for a list of possible commands",
  403. "Please give your command.",
  404. "Waiting for model constructors...",
  405. "Please give your command.",
  406. # Manual transformation revise_environment
  407. "Please perform manual transformation \"revise_environment\"",
  408. "Model loaded, ready for commands!",
  409. "Use 'help' command for a list of possible commands",
  410. "Please give your command.",
  411. "Waiting for model constructors...",
  412. "Please give your command.",
  413. # Manual transformation revise_control
  414. "Please perform manual transformation \"revise_control\"",
  415. "Model loaded, ready for commands!",
  416. "Use 'help' command for a list of possible commands",
  417. "Please give your command.",
  418. "Waiting for model constructors...",
  419. "Please give your command.",
  420. # Manual transformation revise_query
  421. "Please perform manual transformation \"revise_query\"",
  422. "Model loaded, ready for commands!",
  423. "Use 'help' command for a list of possible commands",
  424. "Please give your command.",
  425. "Waiting for model constructors...",
  426. "Please give your command.",
  427. # Manual transformation revise_architecture
  428. "Please perform manual transformation \"revise_architecture\"",
  429. "Model loaded, ready for commands!",
  430. "Use 'help' command for a list of possible commands",
  431. "Please give your command.",
  432. "Waiting for model constructors...",
  433. "Please give your command.",
  434. # Computations happen without output
  435. # Finished, so we go back to the start
  436. "Ready for command...",
  437. ]))