test_powerwindow.py 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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_AL",
  173. "PetriNet",
  174. "",
  175. "ReachabilityGraph",
  176. "",
  177. "reachability",
  178. ] + get_constructor(open("integration/code/reachability.alc", "r").read()) + [
  179. "model_list",
  180. "process_execute",
  181. "pm_powerwindow",
  182. "pm_",
  183. # define_req
  184. "upload",
  185. ] + get_model_constructor_2("models/requirements_model.mvc") + [
  186. "exit",
  187. # refine_plant
  188. "upload",
  189. ] + get_model_constructor_2("models/plant_model.mvc") + [
  190. "exit",
  191. # refine_environment
  192. "upload",
  193. ] + get_model_constructor_2("models/environment_model.mvc") + [
  194. "exit",
  195. # refine_control
  196. "upload",
  197. ] + get_model_constructor_2("models/control_model.mvc") + [
  198. "exit",
  199. # refine_query
  200. "upload",
  201. ] + get_model_constructor_2("models/query_model.mvc") + [
  202. "exit",
  203. ],
  204. [ # bootup phase
  205. "Desired username for admin user?",
  206. "Desired password for admin user?",
  207. "Please repeat the password",
  208. "Passwords match!",
  209. "Welcome to the Model Management Interface v2.0!",
  210. "Use the 'help' command for a list of possible commands",
  211. "Ready for command...",
  212. # model_add * 9
  213. ] + [ "Creating new model!",
  214. "Model type?",
  215. "Model name?",
  216. "Waiting for model constructors...",
  217. "Model upload success!",
  218. "Ready for command...", ] * 9 + [
  219. # model_list
  220. model_list |
  221. set([
  222. " ReachabilityGraph : SimpleClassDiagrams",
  223. " PetriNet : SimpleClassDiagrams",
  224. " Encapsulated_PetriNet : SimpleClassDiagrams",
  225. " PW_Plant : SimpleClassDiagrams",
  226. " PW_Environment : SimpleClassDiagrams",
  227. " PW_Control : SimpleClassDiagrams",
  228. " Requirements : SimpleClassDiagrams",
  229. " Query : SimpleClassDiagrams",
  230. " pm_powerwindow : ProcessModel",
  231. ]),
  232. "Ready for command...",
  233. # transformation_add_MT_language
  234. "Formalisms to include (terminate with empty string)?",
  235. "Name of the RAMified transformation metamodel?",
  236. "Ready for command...",
  237. # model_modify
  238. "Which model do you want to modify?",
  239. "Model loaded, ready for commands!",
  240. "Use 'help' command for a list of possible commands",
  241. "Please give your command.",
  242. # instantiate * 3
  243. ] + [ "Type to instantiate?",
  244. "Name of new element?",
  245. "Source name?",
  246. "Destination name?",
  247. "Instantiation successful!",
  248. "Please give your command.", ] * 3 + [
  249. "Ready for command...",
  250. # transformation_RAMify
  251. "Which metamodel do you want to RAMify?",
  252. "Where do you want to store the RAMified metamodel?",
  253. "Ready for command...",
  254. # transformation_add_MANUAL
  255. ] + [
  256. "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
  257. "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
  258. "Model added as target",
  259. "Name of Manual operation model?",
  260. "Ready for command...",
  261. ] + [
  262. # transformation_add_MANUAL * 4
  263. ] + [
  264. "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
  265. "Model added as source",
  266. "Model added as source",
  267. "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
  268. "Model added as target",
  269. "Name of Manual operation model?",
  270. "Ready for command...",
  271. ] * 4 + [
  272. # transformation_add_MT
  273. "RAMified metamodel to use?",
  274. "Supported metamodels:",
  275. set([" PetriNet",
  276. " Encapsulated_PetriNet",
  277. " PW_Plant",
  278. " Query",
  279. " PW_Environment",
  280. " Requirements",
  281. " PW_Control",
  282. " ReachabilityGraph",
  283. ]),
  284. "",
  285. "Which ones do you want to use as source (empty string to finish)?",
  286. "Which ones do you want to use as target (empty string to finish)?",
  287. "Model added as target",
  288. "Model added as target",
  289. "Model added as target",
  290. "Model added as target",
  291. "Name of new transformation?",
  292. "Waiting for model constructors...",
  293. "Ready for command...",
  294. # transformation_add_MT
  295. "RAMified metamodel to use?",
  296. "Supported metamodels:",
  297. set([" PetriNet",
  298. " Encapsulated_PetriNet",
  299. " Query",
  300. " PW_Plant",
  301. " PW_Environment",
  302. " Requirements",
  303. " PW_Control",
  304. " ReachabilityGraph",
  305. ]),
  306. "",
  307. "Which ones do you want to use as source (empty string to finish)?",
  308. "Model added as source",
  309. "Which ones do you want to use as target (empty string to finish)?",
  310. "Model added as target",
  311. "Name of new transformation?",
  312. "Waiting for model constructors...",
  313. "Ready for command...",
  314. # transformation_add_MT
  315. "RAMified metamodel to use?",
  316. "Supported metamodels:",
  317. set([" PetriNet",
  318. " Encapsulated_PetriNet",
  319. " Query",
  320. " PW_Plant",
  321. " PW_Environment",
  322. " Requirements",
  323. " PW_Control",
  324. " ReachabilityGraph",
  325. ]),
  326. "",
  327. "Which ones do you want to use as source (empty string to finish)?",
  328. "Model added as source",
  329. "Which ones do you want to use as target (empty string to finish)?",
  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_AL
  355. ] + [ "Which metamodels do you want to use as source for the action code (empty string to finish)?",
  356. "Model added as source",
  357. "Which metamodels do you want to use as target for the action code (empty string to finish)?",
  358. "Model added as target",
  359. "Name of Action Language model?",
  360. "Waiting for model constructors...",
  361. "Ready for command...", ] * 1 + [
  362. # model_list
  363. model_list |
  364. set([
  365. " PetriNet : SimpleClassDiagrams",
  366. " Encapsulated_PetriNet : SimpleClassDiagrams",
  367. " PW_Plant : SimpleClassDiagrams",
  368. " PW_Environment : SimpleClassDiagrams",
  369. " PW_Control : SimpleClassDiagrams",
  370. " Requirements : SimpleClassDiagrams",
  371. " Query : SimpleClassDiagrams",
  372. " reachability : ActionLanguage",
  373. " define_req : ManualOperation",
  374. " refine_plant : ManualOperation",
  375. " refine_control : ManualOperation",
  376. " refine_environment : ManualOperation",
  377. " refine_query : ManualOperation",
  378. " __merged_define_req : SimpleClassDiagrams",
  379. " __merged_All_RAM : SimpleClassDiagrams",
  380. " __merged_refine_plant : SimpleClassDiagrams",
  381. " __merged_refine_control : SimpleClassDiagrams",
  382. " __merged_refine_environment : SimpleClassDiagrams",
  383. " __merged_refine_query : SimpleClassDiagrams",
  384. " All_RAM : SimpleClassDiagrams",
  385. " make_initial_models : All_RAM",
  386. " pm_powerwindow : ProcessModel",
  387. " plant_to_EPN : All_RAM",
  388. " environment_to_EPN : All_RAM",
  389. " control_to_EPN : All_RAM",
  390. " ReachabilityGraph : SimpleClassDiagrams",
  391. ]),
  392. "Ready for command...",
  393. # process_execute
  394. "Which process model do you want to execute?",
  395. "Model prefix to use?",
  396. # Manual transformation define_req
  397. "Please perform manual transformation \"define_req\"",
  398. "Model loaded, ready for commands!",
  399. "Use 'help' command for a list of possible commands",
  400. "Please give your command.",
  401. "Waiting for model constructors...",
  402. "Please give your command.",
  403. # Manual transformation refine_plant
  404. "Please perform manual transformation \"refine_plant\"",
  405. "Model loaded, ready for commands!",
  406. "Use 'help' command for a list of possible commands",
  407. "Please give your command.",
  408. "Waiting for model constructors...",
  409. "Please give your command.",
  410. # Manual transformation refine_environment
  411. "Please perform manual transformation \"refine_environment\"",
  412. "Model loaded, ready for commands!",
  413. "Use 'help' command for a list of possible commands",
  414. "Please give your command.",
  415. "Waiting for model constructors...",
  416. "Please give your command.",
  417. # Manual transformation refine_control
  418. "Please perform manual transformation \"refine_control\"",
  419. "Model loaded, ready for commands!",
  420. "Use 'help' command for a list of possible commands",
  421. "Please give your command.",
  422. "Waiting for model constructors...",
  423. "Please give your command.",
  424. # Manual transformation refine_query
  425. "Please perform manual transformation \"refine_query\"",
  426. "Model loaded, ready for commands!",
  427. "Use 'help' command for a list of possible commands",
  428. "Please give your command.",
  429. "Waiting for model constructors...",
  430. "Please give your command.",
  431. # Computations happen without output
  432. "",
  433. ]))