|
@@ -26,7 +26,7 @@
|
|
|
|
|
|
<method name="expect_response">
|
|
|
<parameter name="expected"/>
|
|
|
- <parameter name="pop" default="False"/>
|
|
|
+ <parameter name="pop" default="True"/>
|
|
|
<body>
|
|
|
if self.responses and self.responses[0] == expected:
|
|
|
if pop:
|
|
@@ -55,7 +55,7 @@
|
|
|
<parameter name="expected"/>
|
|
|
<body>
|
|
|
if isinstance(expected, list):
|
|
|
- return self.actions[context] and expected in self.actions[context][0]["name"]
|
|
|
+ return self.actions[context] and self.actions[context][0]["name"] in expected
|
|
|
else:
|
|
|
return self.actions[context] and self.actions[context][0]["name"] == expected
|
|
|
</body>
|
|
@@ -66,10 +66,12 @@
|
|
|
self.actions = {None: []}
|
|
|
self.responses = []
|
|
|
self.http_clients = []
|
|
|
+ self.context = None
|
|
|
+ self.registered_metamodel = {}
|
|
|
</body>
|
|
|
</constructor>
|
|
|
|
|
|
- <scxml initial="init">
|
|
|
+ <scxml initial="init" priority="source_child">
|
|
|
<state id="init">
|
|
|
<onentry>
|
|
|
<raise scope="cd" event="create_instance">
|
|
@@ -140,6 +142,7 @@
|
|
|
<parameter expr='"parent"'/>
|
|
|
</raise>
|
|
|
<script>
|
|
|
+ print("Got input from HTTP: " + str(data))
|
|
|
self.responses.append(json.loads(data))
|
|
|
</script>
|
|
|
</transition>
|
|
@@ -273,21 +276,14 @@
|
|
|
<state id="send_metadata">
|
|
|
<onentry>
|
|
|
<raise event="request">
|
|
|
- <parameter expr="['model_add', self.parameters[1], self.parameters[0]]"/>
|
|
|
- </raise>
|
|
|
- </onentry>
|
|
|
-
|
|
|
- <transition cond="self.expect_response('Waiting for model constructors...')" target="../send_model"/>
|
|
|
- </state>
|
|
|
-
|
|
|
- <state id="send_model">
|
|
|
- <onentry>
|
|
|
- <raise event="request">
|
|
|
- <parameter expr="self.parameters[2]"/>
|
|
|
+ <parameter expr="['model_add', self.parameters[1], self.parameters[0], self.parameters[2]]"/>
|
|
|
</raise>
|
|
|
</onentry>
|
|
|
|
|
|
<transition cond="self.expect_response('Success')" target="../../../wait_for_action/history">
|
|
|
+ <script>
|
|
|
+ self.registered_metamodel[self.parameters[0]] = self.parameters[1]
|
|
|
+ </script>
|
|
|
<raise event="result">
|
|
|
<parameter expr="None"/>
|
|
|
</raise>
|
|
@@ -317,8 +313,15 @@
|
|
|
</onentry>
|
|
|
|
|
|
<transition cond="self.expect_response_partial('Success: ', pop=False)" target="../../wait_for_action/history">
|
|
|
+ <script>
|
|
|
+ response = self.split_response(self.responses.pop(0))
|
|
|
+ result = set()
|
|
|
+ for res in response:
|
|
|
+ i = res.split(" ", 3)
|
|
|
+ result.add((i[3], i[1], i[2], i[0]))
|
|
|
+ </script>
|
|
|
<raise event="result">
|
|
|
- <parameter expr="set(self.split_response(self.responses.pop(0)))"/>
|
|
|
+ <parameter expr="result"/>
|
|
|
</raise>
|
|
|
</transition>
|
|
|
</state>
|
|
@@ -332,7 +335,7 @@
|
|
|
|
|
|
<transition cond="self.expect_response_partial('Success: ', pop=False)" target="../../wait_for_action/history">
|
|
|
<raise event="result">
|
|
|
- <parameter expr="self.split_response(self.responses.pop(0))"/>
|
|
|
+ <parameter expr="self.split_response(self.responses.pop(0))[0]"/>
|
|
|
</raise>
|
|
|
</transition>
|
|
|
</state>
|
|
@@ -454,7 +457,7 @@
|
|
|
</state>
|
|
|
|
|
|
<state id="edit_metamodel">
|
|
|
- <transition cond="self.expect_response('Model loaded, ready for commands!')" target="../../../wait_for_action/modelling/recognized_operation/scripted"/>
|
|
|
+ <transition cond="self.expect_response('Model loaded, ready for commands!')" target="../../../going_scripted"/>
|
|
|
<transition cond="self.expect_response('Waiting for model constructors...')" target="../send_model"/>
|
|
|
</state>
|
|
|
|
|
@@ -471,6 +474,12 @@
|
|
|
</raise>
|
|
|
</transition>
|
|
|
</state>
|
|
|
+
|
|
|
+ <transition cond="self.expect_response_partial('', pop=False)" target="../../wait_for_action/history">
|
|
|
+ <script>
|
|
|
+ print("UNKNOWN RESPONSE received: " + str(self.responses.pop(0)))
|
|
|
+ </script>
|
|
|
+ </transition>
|
|
|
</state>
|
|
|
|
|
|
<state id="transformation_add_AL" initial="send_metadata">
|
|
@@ -494,7 +503,7 @@
|
|
|
</state>
|
|
|
|
|
|
<state id="edit_metamodel">
|
|
|
- <transition cond="self.expect_response('Model loaded, ready for commands!')" target="../../../wait_for_action/modelling/recognized_operation/scripted"/>
|
|
|
+ <transition cond="self.expect_response('Model loaded, ready for commands!')" target="../../../going_scripted"/>
|
|
|
<transition cond="self.expect_response('Waiting for code constructors...')" target="../send_model"/>
|
|
|
</state>
|
|
|
|
|
@@ -534,7 +543,7 @@
|
|
|
</state>
|
|
|
|
|
|
<state id="edit_metamodel">
|
|
|
- <transition cond="self.expect_response('Model loaded, ready for commands!')" target="../../../wait_for_action/modelling/recognized_operation/scripted"/>
|
|
|
+ <transition cond="self.expect_response('Model loaded, ready for commands!')" target="../../../going_scripted"/>
|
|
|
<transition cond="self.expect_response('Success')" target="../../../wait_for_action/megamodelling">
|
|
|
<raise event="result">
|
|
|
<parameter expr="None"/>
|
|
@@ -575,7 +584,7 @@
|
|
|
</raise>
|
|
|
</transition>
|
|
|
|
|
|
- <transition cond="self.expect_action(self.context, 'data_input', pop=False)" target=".">
|
|
|
+ <transition cond="self.expect_action(self.context, 'data_input')" target=".">
|
|
|
<raise event="request">
|
|
|
<parameter expr="self.actions[self.context].pop(0)['parameters']"/>
|
|
|
</raise>
|
|
@@ -615,7 +624,7 @@
|
|
|
</raise>
|
|
|
</transition>
|
|
|
|
|
|
- <transition cond="self.expect_action(self.context, 'data_input', pop=False)" target=".">
|
|
|
+ <transition cond="self.expect_action(self.context, 'data_input')" target=".">
|
|
|
<raise event="request">
|
|
|
<parameter expr="self.actions[self.context].pop(0)['parameters']"/>
|
|
|
</raise>
|
|
@@ -644,7 +653,7 @@
|
|
|
</state>
|
|
|
|
|
|
<state id="edit_model">
|
|
|
- <transition cond="self.expect_response('Model loaded, ready for commands!')" target="../../../wait_for_action/modelling/recognized_operation/scripted"/>
|
|
|
+ <transition cond="self.expect_response('Model loaded, ready for commands!')" target="../../../going_scripted"/>
|
|
|
<transition cond="self.expect_response('Success')" target="../../../wait_for_action/megamodelling">
|
|
|
<raise event="result">
|
|
|
<parameter expr="None"/>
|
|
@@ -1162,6 +1171,17 @@
|
|
|
</raise>
|
|
|
</transition>
|
|
|
</state>
|
|
|
+
|
|
|
+ <transition cond="self.expect_response_partial('Element not found: ', pop=False)" target="../wait_for_action/history">
|
|
|
+ <raise event="exception">
|
|
|
+ <parameter expr="'UnknownIdentifier'"/>
|
|
|
+ <parameter expr="'Element could not be found'"/>
|
|
|
+ </raise>
|
|
|
+
|
|
|
+ <script>
|
|
|
+ self.responses.pop(0)
|
|
|
+ </script>
|
|
|
+ </transition>
|
|
|
</state>
|
|
|
|
|
|
<state id="wait_for_action" initial="disconnected">
|
|
@@ -1203,7 +1223,6 @@
|
|
|
<transition cond="self.expect_action(None, 'model_list_full')" target="../../operations/model_list_full">
|
|
|
<script>
|
|
|
self.load_action(None)
|
|
|
- print("MLF")
|
|
|
</script>
|
|
|
</transition>
|
|
|
|
|
@@ -1397,37 +1416,31 @@
|
|
|
</script>
|
|
|
</transition>
|
|
|
|
|
|
- <transition cond="self.expect_action(None, ['element_list', 'element_list_nice', 'types', 'types_full', 'read_info', 'read_attrs', 'instantiate', 'delete_element', 'attr_assign', 'attr_assign_code', 'attr_delete', 'read_outgoing', 'read_incoming', 'read_association_source', 'read_association_destination', 'connections_between', 'define_attribute', 'all_instances'], pop=False)" target="../modelling/recognized_operation/manual"/>
|
|
|
+ <transition cond="self.expect_action(None, ['element_list', 'element_list_nice', 'types', 'types_full', 'read_info', 'read_attrs', 'instantiate', 'delete_element', 'attr_assign', 'attr_assign_code', 'attr_delete', 'read_outgoing', 'read_incoming', 'read_association_source', 'read_association_destination', 'connections_between', 'define_attribute', 'all_instances'])" target="../../going_manual"/>
|
|
|
</state>
|
|
|
|
|
|
- <state id="modelling" initial="recognized_operation">
|
|
|
- <onexit>
|
|
|
- <raise event="request">
|
|
|
- <parameter expr="'exit'"/>
|
|
|
- </raise>
|
|
|
- </onexit>
|
|
|
+ <state id="modelling">
|
|
|
+ <onentry>
|
|
|
+ <script>
|
|
|
+ print("Start modelling!")
|
|
|
+ print("Context: " + str(self.context))
|
|
|
+ print("actions: " + str(self.actions[self.context]))
|
|
|
+ </script>
|
|
|
+ </onentry>
|
|
|
|
|
|
- <state id="recognized_operation" initial="manual">
|
|
|
+ <state id="recognized" initial="manual">
|
|
|
<state id="manual">
|
|
|
- <onentry>
|
|
|
- self.context = None
|
|
|
- self.current_model = self.actions[None][0].parameters[0]
|
|
|
- </onentry>
|
|
|
-
|
|
|
- <transition cond="self.expect_action(self.context, 'exit')" target="../../../megamodelling"/>
|
|
|
+ <transition cond="self.expect_action(self.context, 'exit')" target="../../../../leaving_modelling"/>
|
|
|
|
|
|
- <transition cond="self.actions[self.context] and self.actions[0].parameters != self.current_model" target="../../../megamodelling">
|
|
|
+ <transition cond="self.actions[self.context] and self.actions[self.context][0]['parameters'][0] != self.current_model" target="../../../../leaving_modelling">
|
|
|
<script>
|
|
|
print("Sudden switch between two models: perform context switch!")
|
|
|
+ print("Requested operation for " + str(self.actions[self.context][0]['parameters'][0]))
|
|
|
</script>
|
|
|
</transition>
|
|
|
</state>
|
|
|
|
|
|
<state id="scripted">
|
|
|
- <onentry>
|
|
|
- self.current_model = None
|
|
|
- </onentry>
|
|
|
-
|
|
|
<transition cond="self.expect_action(self.context, 'exit')" target="../../../../operations/history"/>
|
|
|
</state>
|
|
|
|
|
@@ -1540,20 +1553,20 @@
|
|
|
</transition>
|
|
|
</state>
|
|
|
|
|
|
- <transition cond="self.context is not None and self.actions[self.context]" target=".">
|
|
|
+ <transition cond="self.context is not None and self.actions[self.context]" target="../history">
|
|
|
<script>
|
|
|
- print("Got unexpected operation: " + str(self.actions[self.context][0]))
|
|
|
+ print("Got unexpected operation: " + str(self.actions[self.context].pop(0)))
|
|
|
</script>
|
|
|
|
|
|
- <raise event="error">
|
|
|
+ <raise event="exception">
|
|
|
<parameter expr="'IllegalContextOperation'"/>
|
|
|
<parameter expr="'Operation not allowed in a context!'"/>
|
|
|
</raise>
|
|
|
</transition>
|
|
|
|
|
|
- <transition cond="self.context is None and self.action[None]" target="../megamodelling">
|
|
|
+ <transition cond="self.context is None and self.actions[None]" target="../../leaving_modelling">
|
|
|
<script>
|
|
|
- print("Got megamodelling operation in model: transferring")
|
|
|
+ print("Got megamodelling operation in model (%s) : transferring" % self.actions[None][0])
|
|
|
</script>
|
|
|
</transition>
|
|
|
</state>
|
|
@@ -1562,17 +1575,59 @@
|
|
|
|
|
|
<history id="history" type="deep"/>
|
|
|
|
|
|
- <transition cond="self.unexpected_action(None)" target=".">
|
|
|
+ <transition cond="self.actions[None]" target="history">
|
|
|
<script>
|
|
|
- print("Got unknown operation: " + str(self.actions[self.context][0]))
|
|
|
+ print("Got unknown operation: " + str(self.actions[None].pop(0)))
|
|
|
</script>
|
|
|
|
|
|
- <raise event="error">
|
|
|
+ <raise event="exception">
|
|
|
<parameter expr="'UnknownOperation'"/>
|
|
|
<parameter expr="'Operation is unknown'"/>
|
|
|
</raise>
|
|
|
</transition>
|
|
|
</state>
|
|
|
+
|
|
|
+ <state id="going_manual">
|
|
|
+ <onentry>
|
|
|
+ <script>
|
|
|
+ self.context = None
|
|
|
+ self.current_model = self.actions[None][0]["parameters"][0]
|
|
|
+ print("Setting current model to " + str(self.current_model))
|
|
|
+ </script>
|
|
|
+
|
|
|
+ <raise event="request">
|
|
|
+ <parameter expr="['model_modify', self.current_model, self.registered_metamodel[self.current_model]]"/>
|
|
|
+ </raise>
|
|
|
+ </onentry>
|
|
|
+
|
|
|
+ <transition cond="self.expect_response('Model loaded, ready for commands!', pop=True)" target="../wait_for_action/modelling/recognized/manual">
|
|
|
+ <script>
|
|
|
+ print("Going to manual!")
|
|
|
+ </script>
|
|
|
+ </transition>
|
|
|
+ </state>
|
|
|
+
|
|
|
+ <state id="going_scripted">
|
|
|
+ <onentry>
|
|
|
+ <script>
|
|
|
+ self.current_model = None
|
|
|
+ print("Setting current model to " + str(self.current_model))
|
|
|
+ </script>
|
|
|
+ </onentry>
|
|
|
+
|
|
|
+ <transition cond="self.expect_response('Model loaded, ready for commands!', pop=True)" target="../wait_for_action/modelling/recognized/scripted"/>
|
|
|
+ </state>
|
|
|
+
|
|
|
+ <state id="leaving_modelling">
|
|
|
+ <onentry>
|
|
|
+ <raise event="request">
|
|
|
+ <parameter expr="'exit'"/>
|
|
|
+ </raise>
|
|
|
+ </onentry>
|
|
|
+
|
|
|
+ <transition cond="self.expect_response('Success', pop=True)" target="../wait_for_action/megamodelling"/>
|
|
|
+ </state>
|
|
|
+
|
|
|
</state>
|
|
|
|
|
|
<state id="queue">
|