Sfoglia il codice sorgente

Fixed process enactment (again)

Yentl Van Tendeloo 7 anni fa
parent
commit
9dbe21f6ae
3 ha cambiato i file con 48 aggiunte e 8 eliminazioni
  1. 20 5
      wrappers/classes/modelverse.xml
  2. 12 0
      wrappers/modelverse.py
  3. 16 3
      wrappers/modelverse_SCCD.py

+ 20 - 5
wrappers/classes/modelverse.xml

@@ -766,9 +766,21 @@
                             </state>
 
                             <state id="executing">
-                                <transition cond="self.expect_response_partial('Enacting ModelTransformation', pop=False)" target="../enacting/sc"/>
-                                <transition cond="self.expect_response_partial('Enacting ActionLanguage', pop=False)" target="../enacting/sc"/>
-                                <transition cond="self.expect_response_partial('Enacting ManualOperation', pop=False)" target="../enacting/op"/>
+                                <transition cond="self.expect_response_partial('Enacting ModelTransformation', pop=False)" target="../enacting/sc">
+                                    <script>
+                                        self.op_name = self.responses.pop(0).split(": ", 1)[1]
+                                    </script>
+                                </transition>
+                                <transition cond="self.expect_response_partial('Enacting ActionLanguage', pop=False)" target="../enacting/sc">
+                                    <script>
+                                        self.op_name = self.responses.pop(0).split(": ", 1)[1]
+                                    </script>
+                                </transition>
+                                <transition cond="self.expect_response_partial('Enacting ManualOperation', pop=False)" target="../enacting/op">
+                                    <script>
+                                        self.op_name = self.responses.pop(0).split(": ", 1)[1]
+                                    </script>
+                                </transition>
 
                                 <transition cond="self.expect_response('Success', pop=True)" target="../../../../wait_for_action/megamodelling">
                                     <raise event="result">
@@ -787,7 +799,7 @@
                                             </script>
 
                                             <raise event="result">
-                                                <parameter expr="['SC', self.responses.pop(0).split(': ', 1)[1], self.input_context]"/>
+                                                <parameter expr="['SC', self.op_name, self.input_context]"/>
                                             </raise>
                                         </transition>
                                     </state>
@@ -816,7 +828,7 @@
                                             </script>
 
                                             <raise event="result">
-                                                <parameter expr="['OP', self.responses.pop(0).split(': ', 1)[1], self.context]"/>
+                                                <parameter expr="['OP', self.op_name, self.context]"/>
                                             </raise>
                                         </transition>
                                     </state>
@@ -1451,6 +1463,9 @@
                             <parameter expr="'UnknownError'"/>
                             <parameter expr="'Error: %s' % self.responses.pop(0)"/>
                         </raise>
+                        <script>
+                            print("Unknown Error")
+                        </script>
                     </transition>
                 </state>
 

+ 12 - 0
wrappers/modelverse.py

@@ -227,6 +227,7 @@ def transformation_execute_AL(operation_name, input_models_dict, output_models_d
         return OUTPUT()
 
 def transformation_execute_MANUAL(operation_name, input_models_dict, output_models_dict, callback=None, tracability_model=""):
+    print("EXEC MANUAL")
     INPUT("transformation_execute_MANUAL", None, [operation_name, input_models_dict, output_models_dict, tracability_model])
     context = OUTPUT()
     if callback is not None:
@@ -384,21 +385,30 @@ def process_execute(process_name, prefix, callbacks=None):
             sc_ports[k] = v[0].addOutputListener(v[2])
 
     INPUT("process_execute", None, [process_name, prefix])
+    print("Process execute")
 
     operation = OUTPUT()
+    print("Operation: " + str(operation))
     while 1:
         if isinstance(operation, (list, tuple)):
             t, name, context = operation
             if t == "OP":
+                print("Got OP")
                 if name in callbacks:
+                    print("Callbacks")
                     callbacks[name](context)
+                    print("DONE")
                 INPUT("exit", context, [])
                 operation = OUTPUT()
+                print("OK, next operation: " + str(operation))
             elif t == "SC":
+                print("Got SC")
                 if name in callbacks:
                     statechart = callbacks[name]
+                    print("SC")
                 else:
                     statechart = None
+                    print("NONE")
 
                 while 1:
                     empty = True
@@ -411,11 +421,13 @@ def process_execute(process_name, prefix, callbacks=None):
                             if statechart:
                                 statechart[0].addInput(Event("input", statechart[1], response.parameters))
                         elif response.name == "result":
+                            print("Result")
                             # Finished execution, so continue and return result
                             if statechart:
                                 statechart[0].addInput(Event("terminate", statechart[1], []))
                             # Break from the most inner loop
                             operation = response.parameters[1]
+                            print("OK, next operation: " + str(operation))
                             break
                         empty = False
 

+ 16 - 3
wrappers/modelverse_SCCD.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Mon Oct 30 16:24:14 2017
+Date:   Tue Oct 31 08:43:26 2017
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
@@ -1075,14 +1075,17 @@ class Modelverse(RuntimeClassBase):
         
         # transition /initialized/behaviour/operations/store_on_scripted/process_execute/executing
         _initialized_behaviour_operations_store_on_scripted_process_execute_executing_0 = Transition(self, self.states["/initialized/behaviour/operations/store_on_scripted/process_execute/executing"], [self.states["/initialized/behaviour/operations/store_on_scripted/process_execute/enacting/sc"]])
+        _initialized_behaviour_operations_store_on_scripted_process_execute_executing_0.setAction(self._initialized_behaviour_operations_store_on_scripted_process_execute_executing_0_exec)
         _initialized_behaviour_operations_store_on_scripted_process_execute_executing_0.setTrigger(None)
         _initialized_behaviour_operations_store_on_scripted_process_execute_executing_0.setGuard(self._initialized_behaviour_operations_store_on_scripted_process_execute_executing_0_guard)
         self.states["/initialized/behaviour/operations/store_on_scripted/process_execute/executing"].addTransition(_initialized_behaviour_operations_store_on_scripted_process_execute_executing_0)
         _initialized_behaviour_operations_store_on_scripted_process_execute_executing_1 = Transition(self, self.states["/initialized/behaviour/operations/store_on_scripted/process_execute/executing"], [self.states["/initialized/behaviour/operations/store_on_scripted/process_execute/enacting/sc"]])
+        _initialized_behaviour_operations_store_on_scripted_process_execute_executing_1.setAction(self._initialized_behaviour_operations_store_on_scripted_process_execute_executing_1_exec)
         _initialized_behaviour_operations_store_on_scripted_process_execute_executing_1.setTrigger(None)
         _initialized_behaviour_operations_store_on_scripted_process_execute_executing_1.setGuard(self._initialized_behaviour_operations_store_on_scripted_process_execute_executing_1_guard)
         self.states["/initialized/behaviour/operations/store_on_scripted/process_execute/executing"].addTransition(_initialized_behaviour_operations_store_on_scripted_process_execute_executing_1)
         _initialized_behaviour_operations_store_on_scripted_process_execute_executing_2 = Transition(self, self.states["/initialized/behaviour/operations/store_on_scripted/process_execute/executing"], [self.states["/initialized/behaviour/operations/store_on_scripted/process_execute/enacting/op"]])
+        _initialized_behaviour_operations_store_on_scripted_process_execute_executing_2.setAction(self._initialized_behaviour_operations_store_on_scripted_process_execute_executing_2_exec)
         _initialized_behaviour_operations_store_on_scripted_process_execute_executing_2.setTrigger(None)
         _initialized_behaviour_operations_store_on_scripted_process_execute_executing_2.setGuard(self._initialized_behaviour_operations_store_on_scripted_process_execute_executing_2_guard)
         self.states["/initialized/behaviour/operations/store_on_scripted/process_execute/executing"].addTransition(_initialized_behaviour_operations_store_on_scripted_process_execute_executing_2)
@@ -2136,6 +2139,7 @@ class Modelverse(RuntimeClassBase):
     
     def _initialized_behaviour_operations_2_exec(self, parameters):
         self.raiseInternalEvent(Event("exception", None, ['UnknownError', 'Error: %s' % self.responses.pop(0)]))
+        print("Unknown Error")
     
     def _initialized_behaviour_operations_2_guard(self, parameters):
         return self.expect_response_partial('', pop=False)
@@ -2622,12 +2626,21 @@ class Modelverse(RuntimeClassBase):
     def _initialized_behaviour_operations_store_on_scripted_process_execute_init_0_guard(self, parameters):
         return self.expect_response('Success', pop=True)
     
+    def _initialized_behaviour_operations_store_on_scripted_process_execute_executing_0_exec(self, parameters):
+        self.op_name = self.responses.pop(0).split(": ", 1)[1]
+    
     def _initialized_behaviour_operations_store_on_scripted_process_execute_executing_0_guard(self, parameters):
         return self.expect_response_partial('Enacting ModelTransformation', pop=False)
     
+    def _initialized_behaviour_operations_store_on_scripted_process_execute_executing_1_exec(self, parameters):
+        self.op_name = self.responses.pop(0).split(": ", 1)[1]
+    
     def _initialized_behaviour_operations_store_on_scripted_process_execute_executing_1_guard(self, parameters):
         return self.expect_response_partial('Enacting ActionLanguage', pop=False)
     
+    def _initialized_behaviour_operations_store_on_scripted_process_execute_executing_2_exec(self, parameters):
+        self.op_name = self.responses.pop(0).split(": ", 1)[1]
+    
     def _initialized_behaviour_operations_store_on_scripted_process_execute_executing_2_guard(self, parameters):
         return self.expect_response_partial('Enacting ManualOperation', pop=False)
     
@@ -2640,7 +2653,7 @@ class Modelverse(RuntimeClassBase):
     def _initialized_behaviour_operations_store_on_scripted_process_execute_enacting_sc_init_0_exec(self, parameters):
         self.input_context = str(uuid.uuid4())
         self.inputs[self.input_context] = []
-        self.raiseInternalEvent(Event("result", None, [['SC', self.responses.pop(0).split(': ', 1)[1], self.input_context]]))
+        self.raiseInternalEvent(Event("result", None, [['SC', self.op_name, self.input_context]]))
     
     def _initialized_behaviour_operations_store_on_scripted_process_execute_enacting_sc_processing_0_exec(self, parameters):
         self.raiseInternalEvent(Event("data_output", None, [self.responses.pop(0)]))
@@ -2657,7 +2670,7 @@ class Modelverse(RuntimeClassBase):
     def _initialized_behaviour_operations_store_on_scripted_process_execute_enacting_op_init_0_exec(self, parameters):
         self.context = str(uuid.uuid4())
         self.actions[self.context] = []
-        self.raiseInternalEvent(Event("result", None, [['OP', self.responses.pop(0).split(': ', 1)[1], self.context]]))
+        self.raiseInternalEvent(Event("result", None, [['OP', self.op_name, self.context]]))
     
     def _initialized_behaviour_operations_store_on_scripted_process_execute_enacting_op_processing_0_guard(self, parameters):
         return self.expect_response_partial('Please perform manual operation ', pop=True)