main_app.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <class name="MainApp" default="true">
  2. <relationships>
  3. <association name="modelverse" class="Modelverse" min="1" max="1"/>
  4. <association name="windows" class="Window"/>
  5. </relationships>
  6. <constructor>
  7. <parameter name="root"/>
  8. <parameter name="location"/>
  9. <parameter name="username"/>
  10. <parameter name="password"/>
  11. <parameter name="model"/>
  12. <parameter name="limited_mode"/>
  13. <body>
  14. self.nr_of_windows = 0
  15. self.root = root
  16. self.splash_window = None
  17. self.open_model = model
  18. self.limited_mode = limited_mode
  19. global data
  20. data = {}
  21. data['username'] = username
  22. data['password'] = password
  23. data['mv_address'] = location
  24. data['timeout'] = 20.0
  25. </body>
  26. </constructor>
  27. <scxml initial="parallel">
  28. <parallel id="parallel">
  29. <state id="behaviour" initial="init_modelverse">
  30. <state id="init_modelverse" initial="splash">
  31. <state id="splash">
  32. <onentry>
  33. <raise event="create_instance" scope="cd">
  34. <parameter expr="'windows'"/>
  35. <parameter expr="'SplashWindow'"/>
  36. </raise>
  37. </onentry>
  38. <transition event="instance_created" target="../instantiate">
  39. <parameter name="association_name"/>
  40. <raise event="start_instance" scope="cd">
  41. <parameter expr="association_name"/>
  42. </raise>
  43. <script>
  44. self.splash_window = association_name
  45. </script>
  46. </transition>
  47. </state>
  48. <state id="instantiate">
  49. <onentry>
  50. <raise event="create_instance" scope="cd">
  51. <parameter expr="'modelverse'"/>
  52. <parameter expr="'Modelverse'"/>
  53. </raise>
  54. <raise event="update_status" scope="narrow" target="self.splash_window">
  55. <parameter expr="0"/>
  56. <parameter expr="'Waiting for Modelverse Instantiation...'"/>
  57. </raise>
  58. </onentry>
  59. <transition event="instance_created" target="../initializing_network">
  60. <parameter name="association_name"/>
  61. <raise event="start_instance" scope="cd">
  62. <parameter expr="association_name"/>
  63. </raise>
  64. <raise event="update_status" scope="narrow" target="self.splash_window">
  65. <parameter expr="5"/>
  66. <parameter expr="'Waiting for Modelverse Instantiation... OK'"/>
  67. </raise>
  68. </transition>
  69. </state>
  70. <state id="initializing_network">
  71. <onentry>
  72. <raise event="update_status" scope="narrow" target="self.splash_window">
  73. <parameter expr="10"/>
  74. <parameter expr="'Waiting for HTTP connection to Modelverse...'"/>
  75. </raise>
  76. </onentry>
  77. <transition event="mv_ready" target="../initializing_modelverse">
  78. <raise event="update_status" scope="narrow" target="self.splash_window">
  79. <parameter expr="20"/>
  80. <parameter expr="'Waiting for HTTP connection to Modelverse... OK'"/>
  81. </raise>
  82. </transition>
  83. </state>
  84. <state id="initializing_modelverse">
  85. <onentry>
  86. <raise event="mv_request">
  87. <parameter expr="'init'"/>
  88. <parameter expr="[data['mv_address'], data['timeout']]"/>
  89. </raise>
  90. <raise event="update_status" scope="narrow" target="self.splash_window">
  91. <parameter expr="30"/>
  92. <parameter expr="'Waiting for Modelverse initialization...'"/>
  93. </raise>
  94. </onentry>
  95. <transition event="mv_response" target="../logging_in_modelverse/login">
  96. <raise event="update_status" scope="narrow" target="self.splash_window">
  97. <parameter expr="40"/>
  98. <parameter expr="'Waiting for Modelverse initialization... OK'"/>
  99. </raise>
  100. </transition>
  101. </state>
  102. <state id="logging_in_modelverse" initial="prompt_username">
  103. <state id="prompt_username">
  104. <onentry>
  105. <raise event="create_instance" scope="cd">
  106. <parameter expr="'windows'"/>
  107. <parameter expr="'PromptWindow'"/>
  108. <parameter expr="{'username': data['username'], 'password': data['password']}"/>
  109. <parameter expr="{'password': {'show': '*'}}"/>
  110. </raise>
  111. </onentry>
  112. <transition event="instance_created" target="../wait_for_credentials">
  113. <parameter name="association_name"/>
  114. <raise event="start_instance" scope="cd">
  115. <parameter expr="association_name"/>
  116. </raise>
  117. <script>
  118. self.prompt_window = association_name
  119. </script>
  120. </transition>
  121. </state>
  122. <state id="wait_for_credentials">
  123. <state id="responsive">
  124. <transition event="prompt_results" target=".">
  125. <parameter name="results"/>
  126. <script>
  127. data['username'] = results["username"]
  128. data['password'] = results["password"]
  129. </script>
  130. </transition>
  131. <transition event="close_window" cond="data['username'] == ''" target="../../prompt_username"/>
  132. <transition event="close_window" cond="data['username'] != ''" target="../../login"/>
  133. </state>
  134. <onexit>
  135. <raise event="delete_instance" scope="cd">
  136. <parameter expr="self.prompt_window"/>
  137. </raise>
  138. </onexit>
  139. </state>
  140. <state id="login">
  141. <onentry>
  142. <raise event="mv_request">
  143. <parameter expr="'login'"/>
  144. <parameter expr="[data['username'], data['password']]"/>
  145. </raise>
  146. <raise event="update_status" scope="narrow" target="self.splash_window">
  147. <parameter expr="50"/>
  148. <parameter expr="'Logging in...'"/>
  149. </raise>
  150. </onentry>
  151. <transition event="mv_response" target="../register_SCD">
  152. <raise event="update_status" scope="narrow" target="self.splash_window">
  153. <parameter expr="70"/>
  154. <parameter expr="'Logging in... OK'"/>
  155. </raise>
  156. </transition>
  157. <transition event="mv_exception" target="../prompt_username">
  158. <raise event="update_status" scope="narrow" target="self.splash_window">
  159. <parameter expr="40"/>
  160. <parameter expr="'Incorrect username or password'"/>
  161. </raise>
  162. </transition>
  163. </state>
  164. <state id="register_SCD">
  165. <onentry>
  166. <raise event="mv_request">
  167. <parameter expr="'alter_context'"/>
  168. <parameter expr="['formalisms/SimpleClassDiagrams', 'formalisms/SimpleClassDiagrams']"/>
  169. </raise>
  170. </onentry>
  171. <transition event="mv_response" target="../register_conf_bottom"/>
  172. </state>
  173. <state id="register_conf_bottom">
  174. <onentry>
  175. <raise event="mv_request">
  176. <parameter expr="'alter_context'"/>
  177. <parameter expr="['formalisms/Bottom', 'formalisms/SimpleClassDiagrams']"/>
  178. </raise>
  179. </onentry>
  180. <transition event="mv_response" target="../upload_models"/>
  181. </state>
  182. <state id="upload_models" initial="upload_MM_render">
  183. <state id="upload_MM_render">
  184. <onentry>
  185. <raise event="mv_request">
  186. <parameter expr="'model_add'"/>
  187. <parameter expr="['formalisms/MM_render', 'formalisms/SimpleClassDiagrams', open('models/MM_render.mvc', 'r').read()]"/>
  188. </raise>
  189. <raise event="update_status" scope="narrow" target="self.splash_window">
  190. <parameter expr="75"/>
  191. <parameter expr="'Uploading MM render...'"/>
  192. </raise>
  193. </onentry>
  194. <transition event="mv_exception" target="../upload_render_SCD"/>
  195. <transition event="mv_response" target="../upload_render_SCD"/>
  196. </state>
  197. <state id="upload_render_SCD">
  198. <onentry>
  199. <raise event="mv_request">
  200. <parameter expr="'transformation_add_AL'"/>
  201. <parameter expr="[{'rendered': 'formalisms/MM_render', 'abstract': 'formalisms/SimpleClassDiagrams'}, {'rendered': 'formalisms/MM_render'}, 'models/render_SCD', open('models/render_SCD.alc', 'r').read()]"/>
  202. </raise>
  203. <raise event="update_status" scope="narrow" target="self.splash_window">
  204. <parameter expr="80"/>
  205. <parameter expr="'Uploading render_SCD...'"/>
  206. </raise>
  207. </onentry>
  208. <transition event="mv_exception" target="../../../wait_close_splash"/>
  209. <transition event="mv_response" target="../modify_render_SCD">
  210. <parameter name="context"/>
  211. <script>
  212. self.context = context
  213. </script>
  214. </transition>
  215. </state>
  216. <state id="modify_render_SCD" initial="trace_class">
  217. <onexit>
  218. <script>
  219. self.context = None
  220. </script>
  221. </onexit>
  222. <state id="trace_class">
  223. <onentry>
  224. <raise event="mv_request_context">
  225. <parameter expr="'instantiate'"/>
  226. <parameter expr="[None, 'Association', ('abstract/Class', 'rendered/Group'), 'TracabilityClass']"/>
  227. <parameter expr="self.context"/>
  228. </raise>
  229. </onentry>
  230. <transition event="mv_response" target="../trace_association"/>
  231. </state>
  232. <state id="trace_association">
  233. <onentry>
  234. <raise event="mv_request_context">
  235. <parameter expr="'instantiate'"/>
  236. <parameter expr="[None, 'Association', ('abstract/Association', 'rendered/ConnectingLine'), 'TracabilityAssociation']"/>
  237. <parameter expr="self.context"/>
  238. </raise>
  239. </onentry>
  240. <transition event="mv_response" target="../exit"/>
  241. </state>
  242. <state id="exit">
  243. <onentry>
  244. <raise event="mv_request_context">
  245. <parameter expr="'exit'"/>
  246. <parameter expr="[]"/>
  247. <parameter expr="self.context"/>
  248. </raise>
  249. </onentry>
  250. <transition event="mv_response" target="../../../../wait_close_splash"/>
  251. </state>
  252. <transition event="mv_exception" target="../../../wait_close_splash"/>
  253. </state>
  254. </state>
  255. </state>
  256. <state id="wait_close_splash">
  257. <transition after="0.0" target="../closing_splash"/>
  258. </state>
  259. <state id="closing_splash">
  260. <onentry>
  261. <raise event="close" scope="narrow" target="self.splash_window"/>
  262. </onentry>
  263. <transition event="close_window" target="../../init_main_window">
  264. <raise event="delete_instance" scope="cd">
  265. <parameter expr="self.splash_window"/>
  266. </raise>
  267. </transition>
  268. </state>
  269. </state>
  270. <state id="init_main_window">
  271. <onentry>
  272. <raise event="create_instance" scope="cd">
  273. <parameter expr="'windows'"/>
  274. <parameter expr="'MainWindow'"/>
  275. <parameter expr="self.open_model"/>
  276. <parameter expr="self.limited_mode"/>
  277. </raise>
  278. </onentry>
  279. <transition event="instance_created" target="../main_behaviour">
  280. <parameter name="association_name"/>
  281. <raise event="start_instance" scope="cd">
  282. <parameter expr="association_name"/>
  283. </raise>
  284. </transition>
  285. </state>
  286. <state id="main_behaviour">
  287. <transition event="close_window" target="../stopped"/>
  288. </state>
  289. <state id="stopped">
  290. <onentry>
  291. <script>
  292. self.root.quit()
  293. </script>
  294. </onentry>
  295. </state>
  296. </state>
  297. <state id="forward_requests">
  298. <state id="forward">
  299. <transition event="mv_request_context" target=".">
  300. <parameter name="name"/>
  301. <parameter name="params"/>
  302. <parameter name="context" default="None"/>
  303. <raise event="action" scope="narrow" target="'modelverse'">
  304. <parameter expr="name"/>
  305. <parameter expr="None"/>
  306. <parameter expr="context"/>
  307. <parameter expr="params"/>
  308. </raise>
  309. </transition>
  310. <transition event="mv_request" target=".">
  311. <parameter name="name"/>
  312. <parameter name="params"/>
  313. <raise event="action" scope="narrow" target="'modelverse'">
  314. <parameter expr="name"/>
  315. <parameter expr="None"/>
  316. <parameter expr="None"/>
  317. <parameter expr="params"/>
  318. </raise>
  319. </transition>
  320. <transition event="mv_result" target=".">
  321. <parameter name="ID"/>
  322. <parameter name="result"/>
  323. <raise event="mv_response" scope="broad">
  324. <parameter expr="result"/>
  325. </raise>
  326. <raise event="mv_response" scope="local">
  327. <parameter expr="result"/>
  328. </raise>
  329. </transition>
  330. <transition event="mv_exception" target=".">
  331. <parameter name="ID"/>
  332. <parameter name="exception_name"/>
  333. <parameter name="exception"/>
  334. <raise event="mv_exception" scope="broad">
  335. <parameter expr="exception_name"/>
  336. <parameter expr="exception"/>
  337. </raise>
  338. <script>
  339. print("Got Modelverse exception: " + str(exception_name))
  340. print("Details: " + str(exception))
  341. </script>
  342. </transition>
  343. </state>
  344. </state>
  345. </parallel>
  346. </scxml>
  347. </class>