Переглянути джерело

Patched some problems to make the process model at least enact for the first few activities

Yentl Van Tendeloo 7 роки тому
батько
коміт
52da08b140

+ 10 - 0
bootstrap/core_algorithm.alc

@@ -91,6 +91,7 @@ Element function get_full_model(model_id : String, metamodel_id : String):
 	Element m
 	Element all_links
 	String choice
+	log("Reading full model of " + cast_string(read_attribute(core, model_id, "name")))
 
 	choice = get_instanceOf_link(model_id, metamodel_id)
 
@@ -630,6 +631,11 @@ Element function execute_operation(operation_id : String, input_models : Element
 	while (set_len(iter) > 0):
 		edge = set_pop(iter)
 		dict_add(output_metamodels, read_attribute(core, edge, "name"), full_name(readAssociationDestination(core, edge)))
+
+	log("Input models: " + dict_to_string(input_models))
+	log("Found signature:")
+	log("Input: " + dict_to_string(input_metamodels))
+	log("Output: " + dict_to_string(output_metamodels))
 	
 	// 1) Find merged metamodel
 
@@ -649,7 +655,11 @@ Element function execute_operation(operation_id : String, input_models : Element
 		while (set_len(keys) > 0):
 			key = set_pop(keys)
 			Element mm
+			log("Getting full model for " + key)
+			log("Input: " + get_entry_id(input_models[key]))
+			log("Input MM: " + get_entry_id(input_metamodels[key]))
 			mm = get_full_model(get_entry_id(input_models[key]), get_entry_id(input_metamodels[key]))
+			log("Success!")
 			if (element_eq(mm, read_root())):
 				log("Signature mismatch in operation for tag " + key)
 				output("Signature mismatch in operation for tag " + key)

+ 1 - 0
models/cbd_simulate.alc

@@ -12,6 +12,7 @@ Boolean function main(model : Element):
 	Element schedule_run
 	Element schedule
 	String conforming
+	log("Start simulation of model!")
 
 	schedule_init = create_schedule(model)
 	schedule_run = read_root()

+ 6 - 6
models/cbd_spring.mvc

@@ -18,19 +18,19 @@ ConstantBlock cte_y0 {
     value = 20
 }
 
-MultiplicationBlock m0 {}
-MultiplicationBlock m1 {}
-MultiplicationBlock m2 {}
-NegationBlock n0 {}
+MultiplyBlock m0 {}
+MultiplyBlock m1 {}
+MultiplyBlock m2 {}
+NegatorBlock n0 {}
 InverseBlock i0 {}
 AdditionBlock a0 {}
 IntegratorBlock int0 {}
 IntegratorBlock int1 {}
 
-Probe pv {
+ProbeBlock pv {
     name = "velocity"
 }
-Probe py {
+ProbeBlock py {
     name = "displacement"
 }
 

+ 26 - 21
models/pm_live_CBD.mvc

@@ -1,5 +1,13 @@
 Start start {}
 
+Exec toRuntime_0 {
+    name = "models/CBD/toRuntime"
+}
+
+Exec merge_0 {
+    name = "models/CBD/merge"
+}
+
 Exec edit {
     name = "models/CBD/edit"
 }
@@ -23,16 +31,6 @@ Exec merge {
 Fork fork1 {}
 Fork fork2 {}
 
-Data trace_Design2Partial {
-    name = "trace_D2P"
-    type = "formalisms/Tracability"
-}
-
-Data trace_Partial2Runtime {
-    name = "trace_P2R"
-    type = "formalisms/Tracability"
-}
-
 Data design_model {
     name = "design_model"
     type = "formalisms/CBD/Design_MM"
@@ -48,7 +46,9 @@ Data full_runtime_model {
     type = "formalisms/CBD/FullRuntime_MM"
 }
 
-Next (start, fork1) {}
+Next (start, toRuntime_0) {}
+Next (toRuntime_0, merge_0) {}
+Next (merge_0, fork1) {}
 Next (fork1, edit) {}
 Next (fork1, simulate) {}
 Next (edit, toRuntime) {}
@@ -68,14 +68,15 @@ Produces (edit, design_model) {
 Consumes (toRuntime, design_model) {
     name = "Design"
 }
-Consumes (toRuntime, trace_Design2Partial) {
-    name = "__traceability"
-}
 Produces (toRuntime, partial_runtime_model) {
     name = "PartialRuntime"
 }
-Produces (toRuntime, trace_Design2Partial) {
-    name = "__traceability"
+
+Consumes (toRuntime_0, design_model) {
+    name = "Design"
+}
+Produces (toRuntime_0, partial_runtime_model) {
+    name = "PartialRuntime"
 }
 
 Consumes (merge, partial_runtime_model) {
@@ -84,14 +85,18 @@ Consumes (merge, partial_runtime_model) {
 Consumes (merge, full_runtime_model) {
     name = "FullRuntime"
 }
-Consumes (merge, trace_Partial2Runtime) {
-    name = "__traceability"
-}
 Produces (merge, full_runtime_model) {
     name = "PartialRuntime"
 }
-Produces (merge, trace_Partial2Runtime) {
-    name = "__traceability"
+
+Consumes (merge_0, partial_runtime_model) {
+    name = "PartialRuntime"
+}
+Consumes (merge_0, full_runtime_model) {
+    name = "FullRuntime"
+}
+Produces (merge_0, full_runtime_model) {
+    name = "PartialRuntime"
 }
 
 Consumes (simulate, full_runtime_model) {

+ 4 - 10
models/upload_models.py

@@ -7,30 +7,24 @@ login("admin", "admin")
 folder_create("formalisms/CBD")
 folder_create("models/CBD")
 
-print("Add design")
 model_add("formalisms/CBD/Design_MM", "formalisms/SimpleClassDiagrams", open("models/cbd_design.mvc", 'r').read())
-print("Add partial")
 model_add("formalisms/CBD/PartialRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/cbd_partial_runtime.mvc", 'r').read())
-print("Add full")
 model_add("formalisms/CBD/FullRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/cbd_runtime.mvc", 'r').read())
 
-print("Add model")
 model_add("models/CBD_spring", "formalisms/CBD/Design_MM", open("models/cbd_spring.mvc", 'r').read())
+model_add("models/cbd_empty_partial", "formalisms/CBD/PartialRuntime_MM", "")
+model_add("models/cbd_empty_full", "formalisms/CBD/FullRuntime_MM", "")
 
-print("Add transformation edit")
 transformation_add_MANUAL({"Design": "formalisms/CBD/Design_MM"}, {"Design": "formalisms/CBD/Design_MM"}, "models/CBD/edit")
-print("Add transformation toRuntime")
 transformation_add_AL({"Design": "formalisms/CBD/Design_MM"}, {"PartialRuntime": "formalisms/CBD/PartialRuntime_MM"}, "models/CBD/toRuntime", open("models/cbd_toRuntime.alc", 'r').read())
-print("Add transformation merge")
 transformation_add_AL({"PartialRuntime": "formalisms/CBD/PartialRuntime_MM", "FullRuntime": "formalisms/CBD/FullRuntime_MM"}, {"FullRuntime": "formalisms/CBD/FullRuntime_MM"}, "models/CBD/merge", open("models/cbd_merge.alc", 'r').read())
-print("Add transformation simulate")
 transformation_add_AL({"FullRuntime": "formalisms/CBD/FullRuntime_MM"}, {"FullRuntime": "formalisms/CBD/FullRuntime_MM"}, "models/CBD/simulate", open("models/cbd_simulate.alc", 'r').read())
-print("Add transformation restart")
 transformation_add_AL({}, {}, "models/CBD/restartSim", open("models/cbd_restartSim.alc", 'r').read())
 
-print("Add process model")
 model_add("models/live_modelling_CBD", "formalisms/ProcessModel", open("models/pm_live_CBD.mvc", 'r').read())
 
+process_execute("models/live_modelling_CBD", {"design_model": "models/CBD_spring", "partial_runtime_model": "models/cbd_empty_partial", "full_runtime_model": "models/cbd_empty_full"}, {})
+
 """
 model_add("formalisms/PW_Plant", "formalisms/SimpleClassDiagrams", open("models/plant_PW.mvc", 'r').read())
 model_add("models/plant", "formalisms/PW_Plant", open("models/plant_model.mvc", 'r').read().replace("PW_Plant/", ""))

+ 2 - 2
wrappers/modelverse.py

@@ -442,7 +442,7 @@ def all_instances(model_name, type_name, context=None):
     INPUT("all_instances", context, [model_name, type_name])
     return OUTPUT()
 
-def process_execute(process_name, prefix, callbacks=None):
+def process_execute(process_name, model_mapping, callbacks=None):
     # for all callbacks to SCs, start up the output port already
     sc_ports = {}
     for k, v in callbacks.items():
@@ -450,7 +450,7 @@ def process_execute(process_name, prefix, callbacks=None):
             # Is a statechart, so register already
             sc_ports[k] = v[0].addOutputListener(v[2])
 
-    INPUT("process_execute", None, [process_name, prefix])
+    INPUT("process_execute", None, [process_name, model_mapping])
 
     while 1:
         print("Waiting for output...")

+ 1 - 1
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:   Wed Nov 15 16:03:44 2017
+Date:   Wed Nov 15 16:56:08 2017
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server