test_powerwindow.py 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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. "SimpleClassDiagrams",
  70. "Network",
  71. ] + get_model_constructor(open("models/network.mvc", "r").read()) + [
  72. "model_add",
  73. "ProcessModel",
  74. "pm_powerwindow",
  75. ] + get_model_constructor(open("models/pm_req_analyse.mvc", "r").read()) + [
  76. "model_list",
  77. "transformation_add_MT_language",
  78. "PetriNet",
  79. "Encapsulated_PetriNet",
  80. "PW_Plant",
  81. "PW_Control",
  82. "PW_Environment",
  83. "Requirements",
  84. "ReachabilityGraph",
  85. "Network",
  86. "Query",
  87. "",
  88. "All_RAM",
  89. "model_modify",
  90. "__merged_All_RAM",
  91. "instantiate",
  92. "Association",
  93. "C2P_PlaceLink",
  94. "PW_Control/State",
  95. "Encapsulated_PetriNet/Place",
  96. "instantiate",
  97. "Association",
  98. "C2P_TransitionLink",
  99. "PW_Control/Transition",
  100. "Encapsulated_PetriNet/Transition",
  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. "Network",
  130. "",
  131. "Network",
  132. "",
  133. "refine_network",
  134. "transformation_add_MANUAL",
  135. "Query",
  136. "",
  137. "Query",
  138. "",
  139. "refine_query",
  140. "transformation_add_MT",
  141. "All_RAM",
  142. "",
  143. "PW_Plant",
  144. "PW_Environment",
  145. "PW_Control",
  146. "Network",
  147. "Query",
  148. "",
  149. "make_initial_models",
  150. ] + get_model_constructor(open("models/initialize.mvc", "r").read()) + [
  151. "transformation_add_MT",
  152. "All_RAM",
  153. "PW_Plant",
  154. "",
  155. "Encapsulated_PetriNet",
  156. "",
  157. "plant_to_EPN",
  158. ] + get_model_constructor(open("models/plant_to_EPN.mvc", "r").read()) + [
  159. "transformation_add_MT",
  160. "All_RAM",
  161. "PW_Control",
  162. "",
  163. "Encapsulated_PetriNet",
  164. "",
  165. "control_to_EPN",
  166. ] + get_model_constructor(open("models/control_to_EPN.mvc", "r").read()) + [
  167. "transformation_add_AL",
  168. "PetriNet",
  169. "",
  170. "ReachabilityGraph",
  171. "",
  172. "reachability",
  173. ] + get_constructor(open("integration/code/reachability.alc", "r").read()) + [
  174. "transformation_add_AL",
  175. "PW_Environment",
  176. "",
  177. "Encapsulated_PetriNet",
  178. "",
  179. "environment_to_EPN",
  180. ] + get_constructor(open("models/environment_to_EPN.alc", "r").read()) + [
  181. "model_list",
  182. ],
  183. [ # bootup phase
  184. "Desired username for admin user?",
  185. "Desired password for admin user?",
  186. "Please repeat the password",
  187. "Passwords match!",
  188. "Welcome to the Model Management Interface v2.0!",
  189. "Use the 'help' command for a list of possible commands",
  190. "Ready for command...",
  191. # model_add * 10
  192. ] + [ "Creating new model!",
  193. "Model type?",
  194. "Model name?",
  195. "Waiting for model constructors...",
  196. "Model upload success!",
  197. "Ready for command...", ] * 10 + [
  198. # model_list
  199. model_list |
  200. set([
  201. " ReachabilityGraph : SimpleClassDiagrams",
  202. " PetriNet : SimpleClassDiagrams",
  203. " Encapsulated_PetriNet : SimpleClassDiagrams",
  204. " PW_Plant : SimpleClassDiagrams",
  205. " PW_Environment : SimpleClassDiagrams",
  206. " PW_Control : SimpleClassDiagrams",
  207. " Requirements : SimpleClassDiagrams",
  208. " Query : SimpleClassDiagrams",
  209. " Network : SimpleClassDiagrams",
  210. " pm_powerwindow : ProcessModel",
  211. ]),
  212. "Ready for command...",
  213. # transformation_add_MT_language
  214. "Formalisms to include (terminate with empty string)?",
  215. "Name of the RAMified transformation metamodel?",
  216. "Ready for command...",
  217. # model_modify
  218. "Which model do you want to modify?",
  219. "Model loaded, ready for commands!",
  220. "Use 'help' command for a list of possible commands",
  221. "Please give your command.",
  222. # instantiate 1
  223. "Type to instantiate?",
  224. "Name of new element?",
  225. "Source name?",
  226. "Destination name?",
  227. "Instantiation successful!",
  228. "Please give your command.",
  229. # instantiate 2
  230. "Type to instantiate?",
  231. "Name of new element?",
  232. "Source name?",
  233. "Destination name?",
  234. "Instantiation successful!",
  235. "Please give your command.",
  236. "Ready for command...",
  237. # transformation_RAMify
  238. "Which metamodel do you want to RAMify?",
  239. "Where do you want to store the RAMified metamodel?",
  240. "Ready for command...",
  241. # transformation_add_MANUAL
  242. ] + [
  243. "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
  244. "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
  245. "Model added as target",
  246. "Name of Manual operation model?",
  247. "Ready for command...",
  248. ] + [
  249. # transformation_add_MANUAL * 5
  250. ] + [
  251. "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
  252. "Model added as source",
  253. "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
  254. "Model added as target",
  255. "Name of Manual operation model?",
  256. "Ready for command...",
  257. ] * 5 + [
  258. # transformation_add_MT
  259. "RAMified metamodel to use?",
  260. "Supported metamodels:",
  261. set([" PetriNet",
  262. " Encapsulated_PetriNet",
  263. " PW_Plant",
  264. " Network",
  265. " Query",
  266. " PW_Environment",
  267. " Requirements",
  268. " PW_Control",
  269. " ReachabilityGraph",
  270. ]),
  271. "",
  272. "Which ones do you want to use as source (empty string to finish)?",
  273. "Which ones do you want to use as target (empty string to finish)?",
  274. "Model added as target",
  275. "Model added as target",
  276. "Model added as target",
  277. "Model added as target",
  278. "Model added as target",
  279. "Name of new transformation?",
  280. "Waiting for model constructors...",
  281. "Ready for command...",
  282. # transformation_add_MT
  283. "RAMified metamodel to use?",
  284. "Supported metamodels:",
  285. set([" PetriNet",
  286. " Encapsulated_PetriNet",
  287. " Network",
  288. " Query",
  289. " PW_Plant",
  290. " PW_Environment",
  291. " Requirements",
  292. " PW_Control",
  293. " ReachabilityGraph",
  294. ]),
  295. "",
  296. "Which ones do you want to use as source (empty string to finish)?",
  297. "Model added as source",
  298. "Which ones do you want to use as target (empty string to finish)?",
  299. "Model added as target",
  300. "Name of new transformation?",
  301. "Waiting for model constructors...",
  302. "Ready for command...",
  303. # transformation_add_MT
  304. "RAMified metamodel to use?",
  305. "Supported metamodels:",
  306. set([" PetriNet",
  307. " Encapsulated_PetriNet",
  308. " Network",
  309. " Query",
  310. " PW_Plant",
  311. " PW_Environment",
  312. " Requirements",
  313. " PW_Control",
  314. " ReachabilityGraph",
  315. ]),
  316. "",
  317. "Which ones do you want to use as source (empty string to finish)?",
  318. "Model added as source",
  319. "Which ones do you want to use as target (empty string to finish)?",
  320. "Model added as target",
  321. "Name of new transformation?",
  322. "Waiting for model constructors...",
  323. "Ready for command...",
  324. # transformation_add_AL
  325. "Which metamodels do you want to use as source for the action code (empty string to finish)?",
  326. "Model added as source",
  327. "Which metamodels do you want to use as target for the action code (empty string to finish)?",
  328. "Model added as target",
  329. "Name of Action Language model?",
  330. "Waiting for model constructors...",
  331. "Ready for command...",
  332. # transformation_add_AL
  333. "Which metamodels do you want to use as source for the action code (empty string to finish)?",
  334. "Model added as source",
  335. "Which metamodels do you want to use as target for the action code (empty string to finish)?",
  336. "Model added as target",
  337. "Name of Action Language model?",
  338. "Waiting for model constructors...",
  339. "Ready for command...",
  340. # model_list
  341. model_list |
  342. set([
  343. " PetriNet : SimpleClassDiagrams",
  344. " Encapsulated_PetriNet : SimpleClassDiagrams",
  345. " PW_Plant : SimpleClassDiagrams",
  346. " PW_Environment : SimpleClassDiagrams",
  347. " PW_Control : SimpleClassDiagrams",
  348. " Requirements : SimpleClassDiagrams",
  349. " Network : SimpleClassDiagrams",
  350. " Query : SimpleClassDiagrams",
  351. " reachability : ActionLanguage",
  352. " define_req : ManualOperation",
  353. " refine_plant : ManualOperation",
  354. " refine_control : ManualOperation",
  355. " refine_environment : ManualOperation",
  356. " refine_network : ManualOperation",
  357. " refine_query : ManualOperation",
  358. " __merged_define_req : SimpleClassDiagrams",
  359. " __merged_All_RAM : SimpleClassDiagrams",
  360. " __merged_refine_plant : SimpleClassDiagrams",
  361. " __merged_refine_control : SimpleClassDiagrams",
  362. " __merged_refine_environment : SimpleClassDiagrams",
  363. " __merged_refine_network : SimpleClassDiagrams",
  364. " __merged_refine_query : SimpleClassDiagrams",
  365. " All_RAM : SimpleClassDiagrams",
  366. " make_initial_models : All_RAM",
  367. " pm_powerwindow : ProcessModel",
  368. " plant_to_EPN : All_RAM",
  369. " environment_to_EPN : ActionLanguage",
  370. " control_to_EPN : All_RAM",
  371. " ReachabilityGraph : SimpleClassDiagrams",
  372. ]),
  373. "Ready for command...",
  374. ]))