test_powerwindow.py 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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(open("integration/code/reachability_graph.mvc", "r").read()) + [
  40. "model_add",
  41. "SimpleClassDiagrams",
  42. "PetriNet",
  43. ] + get_model_constructor(open("integration/code/pn_design.mvc", "r").read()) + [
  44. "model_add",
  45. "SimpleClassDiagrams",
  46. "Encapsulated_PetriNet",
  47. ] + get_model_constructor(open("models/petrinet_ports.mvc", "r").read()) + [
  48. "model_add",
  49. "SimpleClassDiagrams",
  50. "PW_Plant",
  51. ] + get_model_constructor(open("models/plant_PW.mvc", "r").read()) + [
  52. "model_add",
  53. "SimpleClassDiagrams",
  54. "PW_Environment",
  55. ] + get_model_constructor(open("models/environment_PW.mvc", "r").read()) + [
  56. "model_add",
  57. "SimpleClassDiagrams",
  58. "PW_Control",
  59. ] + get_model_constructor(open("models/control_PW.mvc", "r").read()) + [
  60. "model_add",
  61. "SimpleClassDiagrams",
  62. "Requirements",
  63. ] + get_model_constructor(open("models/requirements.mvc", "r").read()) + [
  64. "model_add",
  65. "SimpleClassDiagrams",
  66. "Query",
  67. ] + get_model_constructor(open("models/query.mvc", "r").read()) + [
  68. "model_add",
  69. "ProcessModel",
  70. "pm_powerwindow",
  71. ] + get_model_constructor(open("models/pm_req_analyse.mvc", "r").read()) + [
  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. "PW_Environment",
  112. "",
  113. "PW_Environment",
  114. "",
  115. "refine_environment",
  116. "transformation_add_MANUAL",
  117. "PW_Plant",
  118. "",
  119. "PW_Plant",
  120. "",
  121. "refine_plant",
  122. "transformation_add_MANUAL",
  123. "PW_Control",
  124. "",
  125. "PW_Control",
  126. "",
  127. "refine_control",
  128. "transformation_add_MANUAL",
  129. "Query",
  130. "",
  131. "Query",
  132. "",
  133. "refine_query",
  134. "transformation_add_MT",
  135. "All_RAM",
  136. "",
  137. "PW_Plant",
  138. "PW_Environment",
  139. "PW_Control",
  140. "Query",
  141. "",
  142. "make_initial_models",
  143. ] + get_model_constructor(open("models/initialize.mvc", "r").read()) + [
  144. "transformation_add_MT",
  145. "All_RAM",
  146. "PW_Plant",
  147. "",
  148. "Encapsulated_PetriNet",
  149. "",
  150. "plant_to_EPN",
  151. ] + get_model_constructor(open("models/plant_to_EPN.mvc", "r").read()) + [
  152. "transformation_add_MT",
  153. "All_RAM",
  154. "PW_Control",
  155. "",
  156. "Encapsulated_PetriNet",
  157. "",
  158. "control_to_EPN",
  159. ] + get_model_constructor(open("models/control_to_EPN.mvc", "r").read()) + [
  160. "transformation_add_MT",
  161. "All_RAM",
  162. "PW_Environment",
  163. "",
  164. "Encapsulated_PetriNet",
  165. "",
  166. "environment_to_EPN",
  167. ] + get_constructor(open("models/environment_to_EPN.mvc", "r").read()) + [
  168. "transformation_add_AL",
  169. "PetriNet",
  170. "",
  171. "ReachabilityGraph",
  172. "",
  173. "reachability",
  174. ] + get_constructor(open("integration/code/reachability.alc", "r").read()) + [
  175. "model_list",
  176. ],
  177. [ # bootup phase
  178. "Desired username for admin user?",
  179. "Desired password for admin user?",
  180. "Please repeat the password",
  181. "Passwords match!",
  182. "Welcome to the Model Management Interface v2.0!",
  183. "Use the 'help' command for a list of possible commands",
  184. "Ready for command...",
  185. # model_add * 9
  186. ] + [ "Creating new model!",
  187. "Model type?",
  188. "Model name?",
  189. "Waiting for model constructors...",
  190. "Model upload success!",
  191. "Ready for command...", ] * 9 + [
  192. # model_list
  193. model_list |
  194. set([
  195. " ReachabilityGraph : SimpleClassDiagrams",
  196. " PetriNet : SimpleClassDiagrams",
  197. " Encapsulated_PetriNet : SimpleClassDiagrams",
  198. " PW_Plant : SimpleClassDiagrams",
  199. " PW_Environment : SimpleClassDiagrams",
  200. " PW_Control : SimpleClassDiagrams",
  201. " Requirements : SimpleClassDiagrams",
  202. " Query : SimpleClassDiagrams",
  203. " pm_powerwindow : ProcessModel",
  204. ]),
  205. "Ready for command...",
  206. # transformation_add_MT_language
  207. "Formalisms to include (terminate with empty string)?",
  208. "Name of the RAMified transformation metamodel?",
  209. "Ready for command...",
  210. # model_modify
  211. "Which model do you want to modify?",
  212. "Model loaded, ready for commands!",
  213. "Use 'help' command for a list of possible commands",
  214. "Please give your command.",
  215. # instantiate * 3
  216. ] + [ "Type to instantiate?",
  217. "Name of new element?",
  218. "Source name?",
  219. "Destination name?",
  220. "Instantiation successful!",
  221. "Please give your command.", ] * 3 + [
  222. "Ready for command...",
  223. # transformation_RAMify
  224. "Which metamodel do you want to RAMify?",
  225. "Where do you want to store the RAMified metamodel?",
  226. "Ready for command...",
  227. # transformation_add_MANUAL
  228. ] + [
  229. "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
  230. "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
  231. "Model added as target",
  232. "Name of Manual operation model?",
  233. "Ready for command...",
  234. ] + [
  235. # transformation_add_MANUAL * 4
  236. ] + [
  237. "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
  238. "Model added as source",
  239. "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
  240. "Model added as target",
  241. "Name of Manual operation model?",
  242. "Ready for command...",
  243. ] * 4 + [
  244. # transformation_add_MT
  245. "RAMified metamodel to use?",
  246. "Supported metamodels:",
  247. set([" PetriNet",
  248. " Encapsulated_PetriNet",
  249. " PW_Plant",
  250. " Query",
  251. " PW_Environment",
  252. " Requirements",
  253. " PW_Control",
  254. " ReachabilityGraph",
  255. ]),
  256. "",
  257. "Which ones do you want to use as source (empty string to finish)?",
  258. "Which ones do you want to use as target (empty string to finish)?",
  259. "Model added as target",
  260. "Model added as target",
  261. "Model added as target",
  262. "Model added as target",
  263. "Model added as target",
  264. "Name of new transformation?",
  265. "Waiting for model constructors...",
  266. "Ready for command...",
  267. # transformation_add_MT
  268. "RAMified metamodel to use?",
  269. "Supported metamodels:",
  270. set([" PetriNet",
  271. " Encapsulated_PetriNet",
  272. " Query",
  273. " PW_Plant",
  274. " PW_Environment",
  275. " Requirements",
  276. " PW_Control",
  277. " ReachabilityGraph",
  278. ]),
  279. "",
  280. "Which ones do you want to use as source (empty string to finish)?",
  281. "Model added as source",
  282. "Which ones do you want to use as target (empty string to finish)?",
  283. "Model added as target",
  284. "Name of new transformation?",
  285. "Waiting for model constructors...",
  286. "Ready for command...",
  287. # transformation_add_MT
  288. ] + [ "RAMified metamodel to use?",
  289. "Supported metamodels:",
  290. set([" PetriNet",
  291. " Encapsulated_PetriNet",
  292. " Query",
  293. " PW_Plant",
  294. " PW_Environment",
  295. " Requirements",
  296. " PW_Control",
  297. " ReachabilityGraph",
  298. ]),
  299. "",
  300. "Which ones do you want to use as source (empty string to finish)?",
  301. "Model added as source",
  302. "Which ones do you want to use as target (empty string to finish)?",
  303. "Model added as target",
  304. "Name of new transformation?",
  305. "Waiting for model constructors...",
  306. "Ready for command...", ] * 3 + [
  307. # transformation_add_AL
  308. ] + [ "Which metamodels do you want to use as source for the action code (empty string to finish)?",
  309. "Model added as source",
  310. "Which metamodels do you want to use as target for the action code (empty string to finish)?",
  311. "Model added as target",
  312. "Name of Action Language model?",
  313. "Waiting for model constructors...",
  314. "Ready for command...", ] * 1 + [
  315. # model_list
  316. model_list |
  317. set([
  318. " PetriNet : SimpleClassDiagrams",
  319. " Encapsulated_PetriNet : SimpleClassDiagrams",
  320. " PW_Plant : SimpleClassDiagrams",
  321. " PW_Environment : SimpleClassDiagrams",
  322. " PW_Control : SimpleClassDiagrams",
  323. " Requirements : SimpleClassDiagrams",
  324. " Query : SimpleClassDiagrams",
  325. " reachability : ActionLanguage",
  326. " define_req : ManualOperation",
  327. " refine_plant : ManualOperation",
  328. " refine_control : ManualOperation",
  329. " refine_environment : ManualOperation",
  330. " refine_query : ManualOperation",
  331. " __merged_define_req : SimpleClassDiagrams",
  332. " __merged_All_RAM : SimpleClassDiagrams",
  333. " __merged_refine_plant : SimpleClassDiagrams",
  334. " __merged_refine_control : SimpleClassDiagrams",
  335. " __merged_refine_environment : SimpleClassDiagrams",
  336. " __merged_refine_query : SimpleClassDiagrams",
  337. " All_RAM : SimpleClassDiagrams",
  338. " make_initial_models : All_RAM",
  339. " pm_powerwindow : ProcessModel",
  340. " plant_to_EPN : All_RAM",
  341. " environment_to_EPN : All_RAM",
  342. " control_to_EPN : All_RAM",
  343. " ReachabilityGraph : SimpleClassDiagrams",
  344. ]),
  345. "Ready for command...",
  346. ]))