|
@@ -52,6 +52,39 @@ def _next_ID():
|
|
|
ID += 1
|
|
|
return ID
|
|
|
|
|
|
+def _process_SC(statechart, port_sc, context):
|
|
|
+ print("Context: " + str(context))
|
|
|
+ while 1:
|
|
|
+ empty = True
|
|
|
+
|
|
|
+ # Fetch output from the MV
|
|
|
+ response = responses.fetch(0)
|
|
|
+ if response is not None:
|
|
|
+ print("Output of MV to SC")
|
|
|
+ if response.name == "data_output":
|
|
|
+ # Got output of MV, so forward to SCCD
|
|
|
+ statechart[0].addInput(Event("input", statechart[1], response.parameters))
|
|
|
+ elif response.name == "result":
|
|
|
+ # Finished execution, so continue and return result
|
|
|
+ statechart[0].addInput(Event("terminate", statechart[1], []))
|
|
|
+ return response.parameters[1]
|
|
|
+ else:
|
|
|
+ raise Exception("Unknown data from MV to SC: " + str(response))
|
|
|
+ empty = False
|
|
|
+
|
|
|
+ # Fetch output from the SC
|
|
|
+ response = port_sc.fetch(0)
|
|
|
+ if response is not None:
|
|
|
+ print("Output of SC to MV")
|
|
|
+ if response.name == "output":
|
|
|
+ controller.addInput(Event("data_input", "action_in", [response.parameters, context]))
|
|
|
+ else:
|
|
|
+ raise Exception("Unknown data from SC to MV: " + str(response))
|
|
|
+ empty = False
|
|
|
+
|
|
|
+ if empty:
|
|
|
+ time.sleep(0.5)
|
|
|
+
|
|
|
def INPUT(action, context, parameters):
|
|
|
controller.addInput(Event("action", "action_in", [action, _next_ID(), context, parameters]))
|
|
|
|
|
@@ -174,30 +207,7 @@ def __transformation_execute(operation_name, input_models_dict, output_models_di
|
|
|
INPUT("transformation_execute", None, [operation_name, input_models_dict, output_models_dict, tracability_model, fetch_output])
|
|
|
op, name, context = OUTPUT()
|
|
|
if statechart is not None:
|
|
|
- while 1:
|
|
|
- empty = True
|
|
|
-
|
|
|
- # Fetch output from the MV
|
|
|
- response = responses.fetch(0)
|
|
|
- if response is not None:
|
|
|
- if response.name == "data_output":
|
|
|
- # Got output of MV, so forward to SCCD
|
|
|
- statechart[0].addInput(Event("input", statechart[1], response.parameters))
|
|
|
- elif response.name == "result":
|
|
|
- # Finished execution, so continue and return result
|
|
|
- statechart[0].addInput(Event("terminate", statechart[1], []))
|
|
|
- return response.parameters[1]
|
|
|
- empty = False
|
|
|
-
|
|
|
- # Fetch output from the SC
|
|
|
- response = port_sc.fetch(0)
|
|
|
- if response is not None:
|
|
|
- if response.name == "output":
|
|
|
- controller.addInput(Event("data_input", "action_in", [response.parameters, context]))
|
|
|
- empty = False
|
|
|
-
|
|
|
- if empty:
|
|
|
- time.sleep(0.01)
|
|
|
+ threading.Thread(target=_process_SC, args=[statechart, port_sc, context]).start()
|
|
|
else:
|
|
|
val = OUTPUT()
|
|
|
print("Transformation result: " + str(val))
|