Browse Source

Fixed process enactment

Yentl Van Tendeloo 7 years ago
parent
commit
09efc30e3d

BIN
bootstrap/bootstrap.m.gz


+ 11 - 14
bootstrap/core_algorithm.alc

@@ -704,7 +704,6 @@ Element function execute_operation(operation_id : String, input_models : Element
 		while (get_entry_id(model_name) != ""):
 		while (get_entry_id(model_name) != ""):
 			model_name = ".tmp/" + random_string(20)
 			model_name = ".tmp/" + random_string(20)
 		model_create(merged_model, model_name, merged_metamodel_id, "Model")
 		model_create(merged_model, model_name, merged_metamodel_id, "Model")
-		log("Transforming...")
 		// We want to modify, so modify
 		// We want to modify, so modify
 		do_spawn_modify(model_name, True)
 		do_spawn_modify(model_name, True)
 		merged_model = get_full_model(get_entry_id(model_name), merged_metamodel_id)
 		merged_model = get_full_model(get_entry_id(model_name), merged_metamodel_id)
@@ -819,6 +818,7 @@ Boolean function enact_action(pm : Element, element : String, mapping : Element)
 
 
 	if (element_eq(result, read_root())):
 	if (element_eq(result, read_root())):
 		// Something went wrong!
 		// Something went wrong!
+		output("Failure")
 		return False!
 		return False!
 	else:
 	else:
 		keys = dict_keys(outputs)
 		keys = dict_keys(outputs)
@@ -829,6 +829,7 @@ Boolean function enact_action(pm : Element, element : String, mapping : Element)
 				model_create(result[key], output_map[key], get_entry_id(outputs[key]), "Model")
 				model_create(result[key], output_map[key], get_entry_id(outputs[key]), "Model")
 			else:
 			else:
 				model_overwrite(result[key], get_entry_id(output_map[key]), get_entry_id(outputs[key]))
 				model_overwrite(result[key], get_entry_id(output_map[key]), get_entry_id(outputs[key]))
+		output("Success")
 		return True!
 		return True!
 
 
 Element function PM_signature(pm : Element):
 Element function PM_signature(pm : Element):
@@ -848,8 +849,11 @@ Void function enact_PM_activity(activity_to_task : Element, task_to_result : Ele
 	Boolean result
 	Boolean result
 	pm_tasks = activity_to_task
 	pm_tasks = activity_to_task
 	set_add(activity_to_task[element], get_taskname())
 	set_add(activity_to_task[element], get_taskname())
+	log("Spawn task for activity " + cast_string(read_attribute(pm, element, "name")))
 	result = enact_action(pm, element, mapping)
 	result = enact_action(pm, element, mapping)
 	dict_add_fast(task_to_result, get_taskname(), result)
 	dict_add_fast(task_to_result, get_taskname(), result)
+	log("Finished task for activity " + cast_string(read_attribute(pm, element, "name")))
+	sleep(50)
 	return!
 	return!
 
 
 Void function enact_PM(pm : Element, mapping : Element):
 Void function enact_PM(pm : Element, mapping : Element):
@@ -921,6 +925,7 @@ Void function enact_PM(pm : Element, mapping : Element):
 
 
 			if (type == "Finish"):
 			if (type == "Finish"):
 				// We have finished, so terminate
 				// We have finished, so terminate
+				log("Finished node reached!")
 				break!
 				break!
 			elif (type == "Join"):
 			elif (type == "Join"):
 				// Only do this if all dependencies are fullfilled
 				// Only do this if all dependencies are fullfilled
@@ -1001,8 +1006,10 @@ Void function enact_PM(pm : Element, mapping : Element):
 				sleep(0.1)
 				sleep(0.1)
 
 
 	// Remove all mock locations again
 	// Remove all mock locations again
+	log("Cleaning up")
 	while (set_len(mock_locations) > 0):
 	while (set_len(mock_locations) > 0):
 		model_delete(get_entry_id(set_pop(mock_locations)))
 		model_delete(get_entry_id(set_pop(mock_locations)))
+	log("Models cleaned up")
 
 
 	return !
 	return !
 
 
@@ -1113,6 +1120,7 @@ String function cmd_process_execute(process : String, mapping : Element):
 				return "Specified model cannot be interpreted as a ProcessModel: " + process!
 				return "Specified model cannot be interpreted as a ProcessModel: " + process!
 
 
 			enact_PM(pm, mapping)
 			enact_PM(pm, mapping)
+			log("Finishing process execute")
 			return "Success"!
 			return "Success"!
 		else:
 		else:
 			return "Permission denied to model: " + process!
 			return "Permission denied to model: " + process!
@@ -1339,12 +1347,8 @@ String function cmd_model_render(model_name : String, mapper_name : String, rend
 		return "Model not found: " + model_name!
 		return "Model not found: " + model_name!
 
 
 Boolean function do_spawn_modify(model_name : String, write : Boolean):
 Boolean function do_spawn_modify(model_name : String, write : Boolean):
-	log("Spawned task for " + model_name)
-	log("Taskname: " + get_taskname())
 	output("Please edit this model before sending next input: " + model_name)
 	output("Please edit this model before sending next input: " + model_name)
-	log("OK, waiting for input")
 	input()
 	input()
-	log("SPAWN MODIFY ENDED")
 	return False!
 	return False!
 
 
 Boolean function do_spawn_activity(transformation_id : String, tracability_name : String, inputs : Element, outputs : Element, output_map : Element):
 Boolean function do_spawn_activity(transformation_id : String, tracability_name : String, inputs : Element, outputs : Element, output_map : Element):
@@ -1363,12 +1367,10 @@ Boolean function do_spawn_activity(transformation_id : String, tracability_name
 	taskname = spawn(spawn_activity, lst)
 	taskname = spawn(spawn_activity, lst)
 
 
 	output("Spawned activity on task: " + taskname)
 	output("Spawned activity on task: " + taskname)
-	log("Spawned activity")
 
 
 	while (set_len(returnvalue) == 0):
 	while (set_len(returnvalue) == 0):
 		sleep(0.1)
 		sleep(0.1)
 
 
-	log("Activity terminated!")
 	output("Finished task: " + taskname)
 	output("Finished task: " + taskname)
 	return cast_boolean(set_pop(returnvalue))!
 	return cast_boolean(set_pop(returnvalue))!
 
 
@@ -1408,14 +1410,12 @@ Void function spawn_activity(returnvalue : Element, transformation_id : String,
 	if (element_eq(result, read_root())):
 	if (element_eq(result, read_root())):
 		// Something went wrong!
 		// Something went wrong!
 		set_add(returnvalue, False)
 		set_add(returnvalue, False)
+		log("FAILURE")
 		output("Failure")
 		output("Failure")
 	else:
 	else:
 		keys = dict_keys(outputs)
 		keys = dict_keys(outputs)
 		while (set_len(keys) > 0):
 		while (set_len(keys) > 0):
 			key = set_pop(keys)
 			key = set_pop(keys)
-			log("Writing away model with key " + cast_string(key))
-			log("Output map: " + dict_to_string(output_map))
-			log("Outputs: " + dict_to_string(outputs))
 			
 			
 			if (get_entry_id(outputs[key]) == ""):
 			if (get_entry_id(outputs[key]) == ""):
 				// New model
 				// New model
@@ -1424,9 +1424,9 @@ Void function spawn_activity(returnvalue : Element, transformation_id : String,
 				model_overwrite(result[key], get_entry_id(outputs[key]), get_entry_id(output_map[key]))
 				model_overwrite(result[key], get_entry_id(outputs[key]), get_entry_id(output_map[key]))
 
 
 		set_add(returnvalue, True)
 		set_add(returnvalue, True)
+		log("SUCCESS")
 		output("Success")
 		output("Success")
 
 
-	sleep(5)
 	return!
 	return!
 
 
 String function cmd_transformation_execute(transformation_name : String, source_models : Element, target_models : Element, tracability_name : String):
 String function cmd_transformation_execute(transformation_name : String, source_models : Element, target_models : Element, tracability_name : String):
@@ -1554,7 +1554,6 @@ String function cmd_model_overwrite(model_name : String, metamodel_name : String
 				if (element_eq(mm, read_root())):
 				if (element_eq(mm, read_root())):
 					return "Metamodel does not conform to formalisms/SimpleClassDiagrams: " + metamodel_name!
 					return "Metamodel does not conform to formalisms/SimpleClassDiagrams: " + metamodel_name!
 
 
-				log("Overwriting...")
 				output("Waiting for model constructors...")
 				output("Waiting for model constructors...")
 				new_model = compile_model(input(), mm)
 				new_model = compile_model(input(), mm)
 
 
@@ -2428,9 +2427,7 @@ Void function user_function_skip_init(user_id : String):
 		elif (cmd == "folder_create"):
 		elif (cmd == "folder_create"):
 			output(cmd_folder_create(single_input("Folder name?")))
 			output(cmd_folder_create(single_input("Folder name?")))
 		elif (cmd == "add_conformance"):
 		elif (cmd == "add_conformance"):
-			log("Adding conformance relation...")
 			output(cmd_conformance_add(single_input("Model name?"), single_input("Metamodel name?")))
 			output(cmd_conformance_add(single_input("Model name?"), single_input("Metamodel name?")))
-			log("Added!")
 		elif (cmd == "remove_conformance"):
 		elif (cmd == "remove_conformance"):
 			// TODO
 			// TODO
 			cmd = "FAIL"
 			cmd = "FAIL"

+ 1 - 0
kernel/modelverse_kernel/main.py

@@ -706,6 +706,7 @@ class ModelverseKernel(object):
             if prev_frame is None:
             if prev_frame is None:
                 _, =            yield [("DN", [task_root])]
                 _, =            yield [("DN", [task_root])]
                 del self.debug_info[self.taskname]
                 del self.debug_info[self.taskname]
+                print("Cleanup task " + str(self.taskname))
             else:
             else:
                 if self.debug_info[self.taskname]:
                 if self.debug_info[self.taskname]:
                     self.debug_info[self.taskname].pop()
                     self.debug_info[self.taskname].pop()

+ 8 - 41
wrappers/classes/modelverse.xml

@@ -172,7 +172,7 @@
                         </raise>
                         </raise>
                         <script>
                         <script>
                             self.responses.append(json.loads(data))
                             self.responses.append(json.loads(data))
-                            print("Got data at %s: %s" % (self.controller.taskname, str(json.loads(data))))
+                            #print("Got data at %s: %s" % (self.controller.taskname, str(json.loads(data))))
                         </script>
                         </script>
                     </transition>
                     </transition>
 
 
@@ -606,7 +606,6 @@
                                 <transition cond="self.expect_response_partial('Please edit this model before sending next input: ', pop=False)" target="../wait_for_user">
                                 <transition cond="self.expect_response_partial('Please edit this model before sending next input: ', pop=False)" target="../wait_for_user">
                                     <script>
                                     <script>
                                         model = self.responses.pop(0).split(": ", 1)[1]
                                         model = self.responses.pop(0).split(": ", 1)[1]
-                                        print("Got model to edit: " + str(model))
                                     </script>
                                     </script>
                                     <raise event="result">
                                     <raise event="result">
                                         <parameter expr="model"/>
                                         <parameter expr="model"/>
@@ -618,7 +617,6 @@
                                 <transition cond="None in self.inputs and self.inputs[None]" target="../upload_changes">
                                 <transition cond="None in self.inputs and self.inputs[None]" target="../upload_changes">
                                     <script>
                                     <script>
                                         self.inputs[None].pop(0)
                                         self.inputs[None].pop(0)
-                                        print("POP input indicating readyness")
                                     </script>
                                     </script>
                                     <raise event="request">
                                     <raise event="request">
                                         <parameter expr="True"/>
                                         <parameter expr="True"/>
@@ -656,7 +654,6 @@
                                     <script>
                                     <script>
                                         if len(self.parameters) > 4 and self.parameters[4] == False:
                                         if len(self.parameters) > 4 and self.parameters[4] == False:
                                             self.finish_output_thread = True
                                             self.finish_output_thread = True
-                                        print("Executing transformation " + str(self.parameters[0]))
                                     </script>
                                     </script>
                                 </onentry>
                                 </onentry>
 
 
@@ -671,20 +668,11 @@
                             </state>
                             </state>
 
 
                             <state id="waiting">
                             <state id="waiting">
-                                <onentry>
-                                    <script>
-                                        print("Waiting on task " + self.sub_sc_taskname)
-                                    </script>
-                                </onentry>
-
                                 <transition cond="self.expect_response('Finished task: ' + self.sub_sc_taskname)" target="."/>
                                 <transition cond="self.expect_response('Finished task: ' + self.sub_sc_taskname)" target="."/>
                                 <transition cond="self.expect_response('Success', pop=False) or self.expect_response('Failure', pop=False)" target="../../../../wait_for_action/megamodelling">
                                 <transition cond="self.expect_response('Success', pop=False) or self.expect_response('Failure', pop=False)" target="../../../../wait_for_action/megamodelling">
                                     <raise event="result">
                                     <raise event="result">
                                         <parameter expr="self.responses.pop(0) == 'Success'"/>
                                         <parameter expr="self.responses.pop(0) == 'Success'"/>
                                     </raise>
                                     </raise>
-                                    <script>
-                                        print("FINISHED")
-                                    </script>
                                 </transition>
                                 </transition>
                             </state>
                             </state>
                         </state>
                         </state>
@@ -711,18 +699,17 @@
                                 </transition>
                                 </transition>
 
 
                                 <transition cond="self.expect_response('Success', pop=True)" target="../../../../wait_for_action/megamodelling">
                                 <transition cond="self.expect_response('Success', pop=True)" target="../../../../wait_for_action/megamodelling">
+                                    <script>
+                                        print("FINISH in SC")
+                                    </script>
                                     <raise event="result">
                                     <raise event="result">
-                                        <parameter expr="'Finished'"/>
+                                        <parameter expr="'Success'"/>
                                     </raise>
                                     </raise>
+                                    <script>
+                                        print("RAISED")
+                                    </script>
                                 </transition>
                                 </transition>
                             </state>
                             </state>
-
-                            <transition cond="self.responses" target="executing">
-                                <!-- TODO remove -->
-                                <script>
-                                    print("RESPONSES: " + self.responses[0])
-                                </script>
-                            </transition>
                         </state>
                         </state>
 
 
                         <history id="history" type="deep"/>
                         <history id="history" type="deep"/>
@@ -1408,9 +1395,6 @@
                     <state id="activity" initial="SC">
                     <state id="activity" initial="SC">
                         <state id="SC">
                         <state id="SC">
                             <onentry>
                             <onentry>
-                                <script>
-                                    print("SC EXEC!")
-                                </script>
                                 <raise event="result">
                                 <raise event="result">
                                     <parameter expr="'SC'"/>
                                     <parameter expr="'SC'"/>
                                 </raise>
                                 </raise>
@@ -1421,9 +1405,6 @@
                                     <raise event="result">
                                     <raise event="result">
                                         <parameter expr="True if self.responses.pop(0) == 'Success' else False"/>
                                         <parameter expr="True if self.responses.pop(0) == 'Success' else False"/>
                                     </raise>
                                     </raise>
-                                    <script>
-                                        print("FINISHED")
-                                    </script>
                                 </transition>
                                 </transition>
 
 
                                 <transition cond="not (self.expect_response('Success', pop=False) or self.expect_response('Failure', pop=False)) and self.expect_response_partial('', pop=False)" target=".">
                                 <transition cond="not (self.expect_response('Success', pop=False) or self.expect_response('Failure', pop=False)) and self.expect_response_partial('', pop=False)" target=".">
@@ -1442,20 +1423,11 @@
 
 
                         <state id="OP">
                         <state id="OP">
                             <onentry>
                             <onentry>
-                                <script>
-                                    print("OP EXEC on " + str(self.controller.taskname))
-                                </script>
                                 <raise event="result">
                                 <raise event="result">
                                     <parameter expr="'OP'"/>
                                     <parameter expr="'OP'"/>
                                 </raise>
                                 </raise>
                             </onentry>
                             </onentry>
 
 
-                            <onexit>
-                                <script>
-                                    print("LEAVING")
-                                </script>
-                            </onexit>
-
                             <state id="forwarding">
                             <state id="forwarding">
                                 <transition cond="self.expect_response_partial('Please perform manual operation ', pop=True)" target="."/>
                                 <transition cond="self.expect_response_partial('Please perform manual operation ', pop=True)" target="."/>
 
 
@@ -1463,14 +1435,10 @@
                                     <raise event="result">
                                     <raise event="result">
                                         <parameter expr="self.responses.pop(0).split(': ')[1]"/>
                                         <parameter expr="self.responses.pop(0).split(': ')[1]"/>
                                     </raise>
                                     </raise>
-                                    <script>
-                                        print("EDITING...")
-                                    </script>
                                 </transition>
                                 </transition>
 
 
                                 <transition cond="None in self.inputs and self.inputs[None]" target="../../../history">
                                 <transition cond="None in self.inputs and self.inputs[None]" target="../../../history">
                                     <script>
                                     <script>
-                                        print("GOT DATA INPUT")
                                         self.inputs[None].pop(0)
                                         self.inputs[None].pop(0)
                                     </script>
                                     </script>
                                     <raise event="request">
                                     <raise event="request">
@@ -2072,7 +2040,6 @@
                         <parameter name="value"/>
                         <parameter name="value"/>
                         <parameter name="context_ID"/>
                         <parameter name="context_ID"/>
                         <script>
                         <script>
-                            print("Got data_input in MV")
                             self.inputs.setdefault(context_ID, []).append({"name": "data_input", "parameters": value})
                             self.inputs.setdefault(context_ID, []).append({"name": "data_input", "parameters": value})
                         </script>
                         </script>
                     </transition>
                     </transition>

+ 26 - 37
wrappers/modelverse.py

@@ -53,34 +53,23 @@ def _next_ID():
     return ID
     return ID
 
 
 def __run_new_modelverse(address, username, password, callback, model):
 def __run_new_modelverse(address, username, password, callback, model):
-    print("RUN NEW")
     init(address)
     init(address)
     login(username, password)
     login(username, password)
-    print("LOGIN OK")
     if callback is not None:
     if callback is not None:
         callback(model)
         callback(model)
     exit_save(model)
     exit_save(model)
-    print("CALLBACK DONE")
 
 
 def __run_new_modelverse_activity(address, username, password, taskname, pipe, callback):
 def __run_new_modelverse_activity(address, username, password, taskname, pipe, callback):
-    print("Run MV activity")
     init(address, taskname=taskname)
     init(address, taskname=taskname)
     controller.username = username
     controller.username = username
     controller.password = password
     controller.password = password
-    print("INIT OK")
     t = OUTPUT()
     t = OUTPUT()
-    print("Got type: " + str(t))
 
 
     if t == "OP":
     if t == "OP":
-        print("Requesting model...")
         model = OUTPUT()
         model = OUTPUT()
-        print("Do manual operations on " + str(model))
         __invoke(callback, model)
         __invoke(callback, model)
-        print("Invocation OK")
         controller.addInput(Event("data_input", "action_in", [None, None]))
         controller.addInput(Event("data_input", "action_in", [None, None]))
-        print("Waiting on output")
-        # TODO fix this to something using OUTPUT or so
-        time.sleep(5)
+        time.sleep(2)
     elif t == "SC":
     elif t == "SC":
         while 1:
         while 1:
             empty = True
             empty = True
@@ -88,7 +77,7 @@ def __run_new_modelverse_activity(address, username, password, taskname, pipe, c
             # Fetch output from the MV
             # Fetch output from the MV
             response = responses.fetch(0)
             response = responses.fetch(0)
             if response is not None:
             if response is not None:
-                print("Output of MV to SC: " + str(response))
+                print("Got response: " + str(response))
                 if response.name == "data_output":
                 if response.name == "data_output":
                     # Got output of MV, so forward to SCCD
                     # Got output of MV, so forward to SCCD
                     if pipe is not None:
                     if pipe is not None:
@@ -96,9 +85,11 @@ def __run_new_modelverse_activity(address, username, password, taskname, pipe, c
                 elif response.name == "result":
                 elif response.name == "result":
                     # Finished execution, so continue and return result
                     # Finished execution, so continue and return result
                     if pipe is not None:
                     if pipe is not None:
+                        print("Sending over pipe!")
                         pipe.send(("terminate", []))
                         pipe.send(("terminate", []))
                         pipe.close()
                         pipe.close()
-                    return response.parameters[1]
+                    print("TERMINATE")
+                    return
                 else:
                 else:
                     raise Exception("Unknown data from MV to SC: " + str(response))
                     raise Exception("Unknown data from MV to SC: " + str(response))
                 empty = False
                 empty = False
@@ -118,13 +109,11 @@ def __run_new_modelverse_activity(address, username, password, taskname, pipe, c
 
 
 def __invoke(callback, model):
 def __invoke(callback, model):
     import multiprocessing
     import multiprocessing
-    print("Invoked action!")
     p = multiprocessing.Process(target=__run_new_modelverse, args=[controller.address, controller.username, controller.password, callback, model])
     p = multiprocessing.Process(target=__run_new_modelverse, args=[controller.address, controller.username, controller.password, callback, model])
     p.start()
     p.start()
     p.join()
     p.join()
-    print("Invocation done")
 
 
-def _process_SC(statechart, port_sc, taskname, block=True):
+def _process_SC(statechart, port_sc, taskname):
     import multiprocessing
     import multiprocessing
     p2c_pipe, c2p_pipe = multiprocessing.Pipe()
     p2c_pipe, c2p_pipe = multiprocessing.Pipe()
     p = multiprocessing.Process(target=__run_new_modelverse_activity, args=[controller.address, controller.username, controller.password, taskname, c2p_pipe, None])
     p = multiprocessing.Process(target=__run_new_modelverse_activity, args=[controller.address, controller.username, controller.password, taskname, c2p_pipe, None])
@@ -134,9 +123,11 @@ def _process_SC(statechart, port_sc, taskname, block=True):
 
 
         if p2c_pipe.poll():
         if p2c_pipe.poll():
             response = p2c_pipe.recv()
             response = p2c_pipe.recv()
+            print("Got SC response: " + str(response))
             statechart[0].addInput(Event(response[0], statechart[1], response[1]))
             statechart[0].addInput(Event(response[0], statechart[1], response[1]))
             
             
             if response[0] == "terminate":
             if response[0] == "terminate":
+                print("Got break")
                 p2c_pipe.close()
                 p2c_pipe.close()
                 break
                 break
             empty = False
             empty = False
@@ -148,20 +139,16 @@ def _process_SC(statechart, port_sc, taskname, block=True):
 
 
         if empty:
         if empty:
             time.sleep(0.05)
             time.sleep(0.05)
-    if block:
-        p.join()
-    else:
-        return p
 
 
-def _process_OP(callback, taskname, block=True):
+    print("Wait for join")
+    p.join()
+    print("Joined SC")
+
+def _process_OP(callback, taskname):
     import multiprocessing
     import multiprocessing
-    print("Running remote operation for taskname " + taskname)
     p = multiprocessing.Process(target=__run_new_modelverse_activity, args=[controller.address, controller.username, controller.password, taskname, None, callback])
     p = multiprocessing.Process(target=__run_new_modelverse_activity, args=[controller.address, controller.username, controller.password, taskname, None, callback])
     p.start()
     p.start()
-    if block:
-        p.join()
-    else:
-        return p
+    p.join()
 
 
 def INPUT(action, context, parameters):
 def INPUT(action, context, parameters):
     controller.addInput(Event("action", "action_in", [action, _next_ID(), context, parameters]))
     controller.addInput(Event("action", "action_in", [action, _next_ID(), context, parameters]))
@@ -305,9 +292,7 @@ def transformation_execute_MANUAL(operation_name, input_models_dict, output_mode
     INPUT("transformation_execute", None, [operation_name, input_models_dict, output_models_dict, tracability_model])
     INPUT("transformation_execute", None, [operation_name, input_models_dict, output_models_dict, tracability_model])
     taskname = OUTPUT()
     taskname = OUTPUT()
 
 
-    print("Running manual task at " + str(taskname))
     _process_OP(callback, taskname)
     _process_OP(callback, taskname)
-    print("Process OP called")
 
 
     return OUTPUT()
     return OUTPUT()
 
 
@@ -469,30 +454,34 @@ def process_execute(process_name, prefix, callbacks=None):
     INPUT("process_execute", None, [process_name, prefix])
     INPUT("process_execute", None, [process_name, prefix])
 
 
     while 1:
     while 1:
+        print("Waiting for output...")
         result = OUTPUT()
         result = OUTPUT()
+        print("Got result: " + str(result))
         if result == "Success":
         if result == "Success":
             # Finished
             # Finished
+            print("FINISHING")
             return None
             return None
         else:
         else:
             taskname, operation = result
             taskname, operation = result
-            print("Operation: " + str(operation))
-            print("Taskname: " + str(taskname))
 
 
             if (operation in callbacks):
             if (operation in callbacks):
                 data = callbacks[operation]
                 data = callbacks[operation]
 
 
                 if isinstance(data, (tuple, list)):
                 if isinstance(data, (tuple, list)):
                     # Statechart, so consider like that
                     # Statechart, so consider like that
-                    print("Starting SC processing")
-                    _process_SC(data, sc_ports[operation], taskname, block=False)
+                    print("A")
+                    threading.Thread(target=_process_SC, args=[data, sc_ports[operation], taskname]).start()
+                    print("AE")
                 else:
                 else:
                     # Assume function
                     # Assume function
-                    print("Starting OP processing")
-                    _process_OP(data, taskname, block=False)
+                    print("B")
+                    threading.Thread(target=_process_OP, args=[data, taskname]).start()
+                    print("BE")
             else:
             else:
                 # Assume empty function
                 # Assume empty function
-                print("Starting OP processing")
-                _process_OP(None, taskname, block=False)
+                print("C")
+                threading.Thread(target=_process_OP, args=[None, taskname]).start()
+                print("CE")
 
 
 def get_taskname():
 def get_taskname():
     """Fetch the taskname of the current connection."""
     """Fetch the taskname of the current connection."""

+ 5 - 34
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)
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
 
-Date:   Mon Nov 13 16:48:22 2017
+Date:   Tue Nov 14 09:33:14 2017
 
 
 Model author: Yentl Van Tendeloo
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
 Model name:   MvK Server
@@ -291,7 +291,6 @@ class Modelverse(RuntimeClassBase):
         
         
         # state /initialized/behaviour/operations/store_on_scripted/transformation_execute/waiting
         # state /initialized/behaviour/operations/store_on_scripted/transformation_execute/waiting
         self.states["/initialized/behaviour/operations/store_on_scripted/transformation_execute/waiting"] = State(48, "/initialized/behaviour/operations/store_on_scripted/transformation_execute/waiting", self)
         self.states["/initialized/behaviour/operations/store_on_scripted/transformation_execute/waiting"] = State(48, "/initialized/behaviour/operations/store_on_scripted/transformation_execute/waiting", self)
-        self.states["/initialized/behaviour/operations/store_on_scripted/transformation_execute/waiting"].setEnter(self._initialized_behaviour_operations_store_on_scripted_transformation_execute_waiting_enter)
         
         
         # state /initialized/behaviour/operations/store_on_scripted/process_execute
         # state /initialized/behaviour/operations/store_on_scripted/process_execute
         self.states["/initialized/behaviour/operations/store_on_scripted/process_execute"] = State(49, "/initialized/behaviour/operations/store_on_scripted/process_execute", self)
         self.states["/initialized/behaviour/operations/store_on_scripted/process_execute"] = State(49, "/initialized/behaviour/operations/store_on_scripted/process_execute", self)
@@ -501,7 +500,6 @@ class Modelverse(RuntimeClassBase):
         # state /initialized/behaviour/wait_for_action/activity/OP
         # state /initialized/behaviour/wait_for_action/activity/OP
         self.states["/initialized/behaviour/wait_for_action/activity/OP"] = State(103, "/initialized/behaviour/wait_for_action/activity/OP", self)
         self.states["/initialized/behaviour/wait_for_action/activity/OP"] = State(103, "/initialized/behaviour/wait_for_action/activity/OP", self)
         self.states["/initialized/behaviour/wait_for_action/activity/OP"].setEnter(self._initialized_behaviour_wait_for_action_activity_OP_enter)
         self.states["/initialized/behaviour/wait_for_action/activity/OP"].setEnter(self._initialized_behaviour_wait_for_action_activity_OP_enter)
-        self.states["/initialized/behaviour/wait_for_action/activity/OP"].setExit(self._initialized_behaviour_wait_for_action_activity_OP_exit)
         
         
         # state /initialized/behaviour/wait_for_action/activity/OP/forwarding
         # state /initialized/behaviour/wait_for_action/activity/OP/forwarding
         self.states["/initialized/behaviour/wait_for_action/activity/OP/forwarding"] = State(104, "/initialized/behaviour/wait_for_action/activity/OP/forwarding", self)
         self.states["/initialized/behaviour/wait_for_action/activity/OP/forwarding"] = State(104, "/initialized/behaviour/wait_for_action/activity/OP/forwarding", self)
@@ -1702,13 +1700,6 @@ class Modelverse(RuntimeClassBase):
         _initialized_behaviour_operations_2.setGuard(self._initialized_behaviour_operations_2_guard)
         _initialized_behaviour_operations_2.setGuard(self._initialized_behaviour_operations_2_guard)
         self.states["/initialized/behaviour/operations"].addTransition(_initialized_behaviour_operations_2)
         self.states["/initialized/behaviour/operations"].addTransition(_initialized_behaviour_operations_2)
         
         
-        # transition /initialized/behaviour/operations/store_on_scripted/process_execute
-        _initialized_behaviour_operations_store_on_scripted_process_execute_0 = Transition(self, self.states["/initialized/behaviour/operations/store_on_scripted/process_execute"], [self.states["/initialized/behaviour/operations/store_on_scripted/process_execute/executing"]])
-        _initialized_behaviour_operations_store_on_scripted_process_execute_0.setAction(self._initialized_behaviour_operations_store_on_scripted_process_execute_0_exec)
-        _initialized_behaviour_operations_store_on_scripted_process_execute_0.setTrigger(None)
-        _initialized_behaviour_operations_store_on_scripted_process_execute_0.setGuard(self._initialized_behaviour_operations_store_on_scripted_process_execute_0_guard)
-        self.states["/initialized/behaviour/operations/store_on_scripted/process_execute"].addTransition(_initialized_behaviour_operations_store_on_scripted_process_execute_0)
-        
         # transition /initialized/behaviour/wait_for_action
         # transition /initialized/behaviour/wait_for_action
         _initialized_behaviour_wait_for_action_0 = Transition(self, self.states["/initialized/behaviour/wait_for_action"], [self.states["/initialized/behaviour/wait_for_action/history"]])
         _initialized_behaviour_wait_for_action_0 = Transition(self, self.states["/initialized/behaviour/wait_for_action"], [self.states["/initialized/behaviour/wait_for_action/history"]])
         _initialized_behaviour_wait_for_action_0.setAction(self._initialized_behaviour_wait_for_action_0_exec)
         _initialized_behaviour_wait_for_action_0.setAction(self._initialized_behaviour_wait_for_action_0_exec)
@@ -1876,16 +1867,11 @@ class Modelverse(RuntimeClassBase):
         self.raiseInternalEvent(Event("request", None, [['verify', self.parameters[0], self.parameters[1]]]))
         self.raiseInternalEvent(Event("request", None, [['verify', self.parameters[0], self.parameters[1]]]))
     
     
     def _initialized_behaviour_wait_for_action_activity_SC_enter(self):
     def _initialized_behaviour_wait_for_action_activity_SC_enter(self):
-        print("SC EXEC!")
         self.raiseInternalEvent(Event("result", None, ['SC']))
         self.raiseInternalEvent(Event("result", None, ['SC']))
     
     
     def _initialized_behaviour_wait_for_action_activity_OP_enter(self):
     def _initialized_behaviour_wait_for_action_activity_OP_enter(self):
-        print("OP EXEC on " + str(self.controller.taskname))
         self.raiseInternalEvent(Event("result", None, ['OP']))
         self.raiseInternalEvent(Event("result", None, ['OP']))
     
     
-    def _initialized_behaviour_wait_for_action_activity_OP_exit(self):
-        print("LEAVING")
-    
     def _init_enter(self):
     def _init_enter(self):
         self.big_step.outputEventOM(Event("create_instance", None, [self, 'http_client', 'HTTPClient']))
         self.big_step.outputEventOM(Event("create_instance", None, [self, 'http_client', 'HTTPClient']))
         self.big_step.outputEventOM(Event("create_instance", None, [self, 'http_client', 'HTTPClient']))
         self.big_step.outputEventOM(Event("create_instance", None, [self, 'http_client', 'HTTPClient']))
@@ -1945,10 +1931,6 @@ class Modelverse(RuntimeClassBase):
         self.raiseInternalEvent(Event("request", None, [['transformation_execute', self.parameters[0]] + self.dict_to_list(self.parameters[1]) + self.dict_to_list(self.parameters[2]) + [self.parameters[3]]]))
         self.raiseInternalEvent(Event("request", None, [['transformation_execute', self.parameters[0]] + self.dict_to_list(self.parameters[1]) + self.dict_to_list(self.parameters[2]) + [self.parameters[3]]]))
         if len(self.parameters) > 4 and self.parameters[4] == False:
         if len(self.parameters) > 4 and self.parameters[4] == False:
             self.finish_output_thread = True
             self.finish_output_thread = True
-        print("Executing transformation " + str(self.parameters[0]))
-    
-    def _initialized_behaviour_operations_store_on_scripted_transformation_execute_waiting_enter(self):
-        print("Waiting on task " + self.sub_sc_taskname)
     
     
     def _initialized_behaviour_operations_store_on_scripted_process_execute_init_enter(self):
     def _initialized_behaviour_operations_store_on_scripted_process_execute_init_enter(self):
         self.raiseInternalEvent(Event("request", None, [['process_execute', self.parameters[0]] + self.dict_to_list(self.parameters[1])]))
         self.raiseInternalEvent(Event("request", None, [['process_execute', self.parameters[0]] + self.dict_to_list(self.parameters[1])]))
@@ -2118,12 +2100,6 @@ class Modelverse(RuntimeClassBase):
     def _initialized_behaviour_operations_2_guard(self, parameters):
     def _initialized_behaviour_operations_2_guard(self, parameters):
         return self.expect_response_partial('', pop=False)
         return self.expect_response_partial('', pop=False)
     
     
-    def _initialized_behaviour_operations_store_on_scripted_process_execute_0_exec(self, parameters):
-        print("RESPONSES: " + self.responses[0])
-    
-    def _initialized_behaviour_operations_store_on_scripted_process_execute_0_guard(self, parameters):
-        return self.responses
-    
     def _initialized_behaviour_wait_for_action_0_exec(self, parameters):
     def _initialized_behaviour_wait_for_action_0_exec(self, parameters):
         print("Got unknown operation: " + str(self.actions[None].pop(0)))
         print("Got unknown operation: " + str(self.actions[None].pop(0)))
         self.raiseInternalEvent(Event("exception", None, ['UnknownOperation', 'Operation is unknown']))
         self.raiseInternalEvent(Event("exception", None, ['UnknownOperation', 'Operation is unknown']))
@@ -2325,7 +2301,7 @@ class Modelverse(RuntimeClassBase):
         data = parameters[0]
         data = parameters[0]
         self.big_step.outputEventOM(Event("narrow_cast", None, [self, self.http_clients[1], Event("HTTP_input", None, [urllib.urlencode({"op": "get_output", "taskname": self.taskname}), "parent"])]))
         self.big_step.outputEventOM(Event("narrow_cast", None, [self, self.http_clients[1], Event("HTTP_input", None, [urllib.urlencode({"op": "get_output", "taskname": self.taskname}), "parent"])]))
         self.responses.append(json.loads(data))
         self.responses.append(json.loads(data))
-        print("Got data at %s: %s" % (self.controller.taskname, str(json.loads(data))))
+        #print("Got data at %s: %s" % (self.controller.taskname, str(json.loads(data))))
     
     
     def _initialized_http_mapper_init_3_guard(self, parameters):
     def _initialized_http_mapper_init_3_guard(self, parameters):
         data = parameters[0]
         data = parameters[0]
@@ -2536,7 +2512,6 @@ class Modelverse(RuntimeClassBase):
     
     
     def _initialized_behaviour_operations_store_on_scripted_transformation_add_send_metadata_0_exec(self, parameters):
     def _initialized_behaviour_operations_store_on_scripted_transformation_add_send_metadata_0_exec(self, parameters):
         model = self.responses.pop(0).split(": ", 1)[1]
         model = self.responses.pop(0).split(": ", 1)[1]
-        print("Got model to edit: " + str(model))
         self.raiseInternalEvent(Event("result", None, [model]))
         self.raiseInternalEvent(Event("result", None, [model]))
     
     
     def _initialized_behaviour_operations_store_on_scripted_transformation_add_send_metadata_0_guard(self, parameters):
     def _initialized_behaviour_operations_store_on_scripted_transformation_add_send_metadata_0_guard(self, parameters):
@@ -2544,7 +2519,6 @@ class Modelverse(RuntimeClassBase):
     
     
     def _initialized_behaviour_operations_store_on_scripted_transformation_add_wait_for_user_0_exec(self, parameters):
     def _initialized_behaviour_operations_store_on_scripted_transformation_add_wait_for_user_0_exec(self, parameters):
         self.inputs[None].pop(0)
         self.inputs[None].pop(0)
-        print("POP input indicating readyness")
         self.raiseInternalEvent(Event("request", None, [True]))
         self.raiseInternalEvent(Event("request", None, [True]))
     
     
     def _initialized_behaviour_operations_store_on_scripted_transformation_add_wait_for_user_0_guard(self, parameters):
     def _initialized_behaviour_operations_store_on_scripted_transformation_add_wait_for_user_0_guard(self, parameters):
@@ -2580,7 +2554,6 @@ class Modelverse(RuntimeClassBase):
     
     
     def _initialized_behaviour_operations_store_on_scripted_transformation_execute_waiting_1_exec(self, parameters):
     def _initialized_behaviour_operations_store_on_scripted_transformation_execute_waiting_1_exec(self, parameters):
         self.raiseInternalEvent(Event("result", None, [self.responses.pop(0) == 'Success']))
         self.raiseInternalEvent(Event("result", None, [self.responses.pop(0) == 'Success']))
-        print("FINISHED")
     
     
     def _initialized_behaviour_operations_store_on_scripted_transformation_execute_waiting_1_guard(self, parameters):
     def _initialized_behaviour_operations_store_on_scripted_transformation_execute_waiting_1_guard(self, parameters):
         return self.expect_response('Success', pop=False) or self.expect_response('Failure', pop=False)
         return self.expect_response('Success', pop=False) or self.expect_response('Failure', pop=False)
@@ -2596,7 +2569,9 @@ class Modelverse(RuntimeClassBase):
         return self.responses and ' : ' in self.responses[0]
         return self.responses and ' : ' in self.responses[0]
     
     
     def _initialized_behaviour_operations_store_on_scripted_process_execute_executing_1_exec(self, parameters):
     def _initialized_behaviour_operations_store_on_scripted_process_execute_executing_1_exec(self, parameters):
-        self.raiseInternalEvent(Event("result", None, ['Finished']))
+        print("FINISH in SC")
+        self.raiseInternalEvent(Event("result", None, ['Success']))
+        print("RAISED")
     
     
     def _initialized_behaviour_operations_store_on_scripted_process_execute_executing_1_guard(self, parameters):
     def _initialized_behaviour_operations_store_on_scripted_process_execute_executing_1_guard(self, parameters):
         return self.expect_response('Success', pop=True)
         return self.expect_response('Success', pop=True)
@@ -2900,7 +2875,6 @@ class Modelverse(RuntimeClassBase):
     
     
     def _initialized_behaviour_wait_for_action_activity_SC_forwarding_0_exec(self, parameters):
     def _initialized_behaviour_wait_for_action_activity_SC_forwarding_0_exec(self, parameters):
         self.raiseInternalEvent(Event("result", None, [True if self.responses.pop(0) == 'Success' else False]))
         self.raiseInternalEvent(Event("result", None, [True if self.responses.pop(0) == 'Success' else False]))
-        print("FINISHED")
     
     
     def _initialized_behaviour_wait_for_action_activity_SC_forwarding_0_guard(self, parameters):
     def _initialized_behaviour_wait_for_action_activity_SC_forwarding_0_guard(self, parameters):
         return self.expect_response('Success', pop=False) or self.expect_response('Failure', pop=False)
         return self.expect_response('Success', pop=False) or self.expect_response('Failure', pop=False)
@@ -2922,13 +2896,11 @@ class Modelverse(RuntimeClassBase):
     
     
     def _initialized_behaviour_wait_for_action_activity_OP_forwarding_1_exec(self, parameters):
     def _initialized_behaviour_wait_for_action_activity_OP_forwarding_1_exec(self, parameters):
         self.raiseInternalEvent(Event("result", None, [self.responses.pop(0).split(': ')[1]]))
         self.raiseInternalEvent(Event("result", None, [self.responses.pop(0).split(': ')[1]]))
-        print("EDITING...")
     
     
     def _initialized_behaviour_wait_for_action_activity_OP_forwarding_1_guard(self, parameters):
     def _initialized_behaviour_wait_for_action_activity_OP_forwarding_1_guard(self, parameters):
         return self.expect_response_partial('Please edit this model before sending next input: ', pop=False)
         return self.expect_response_partial('Please edit this model before sending next input: ', pop=False)
     
     
     def _initialized_behaviour_wait_for_action_activity_OP_forwarding_2_exec(self, parameters):
     def _initialized_behaviour_wait_for_action_activity_OP_forwarding_2_exec(self, parameters):
-        print("GOT DATA INPUT")
         self.inputs[None].pop(0)
         self.inputs[None].pop(0)
         self.raiseInternalEvent(Event("request", None, [0]))
         self.raiseInternalEvent(Event("request", None, [0]))
     
     
@@ -3255,7 +3227,6 @@ class Modelverse(RuntimeClassBase):
     def _initialized_queue_queue_5_exec(self, parameters):
     def _initialized_queue_queue_5_exec(self, parameters):
         value = parameters[0]
         value = parameters[0]
         context_ID = parameters[1]
         context_ID = parameters[1]
-        print("Got data_input in MV")
         self.inputs.setdefault(context_ID, []).append({"name": "data_input", "parameters": value})
         self.inputs.setdefault(context_ID, []).append({"name": "data_input", "parameters": value})
     
     
     def initializeStatechart(self):
     def initializeStatechart(self):