Browse Source

Merge branch 'formalisms' into testing

Yentl Van Tendeloo 7 years ago
parent
commit
13992dd30b
100 changed files with 4526 additions and 330 deletions
  1. 1 1
      bootstrap/constructors.alc
  2. 2 2
      bootstrap/model_management.alc
  3. 8 2
      bootstrap/object_operations.alc
  4. 1 0
      bootstrap/ramify.alc
  5. 19 5
      bootstrap/transform.alc
  6. 9 4
      bootstrap/typing.alc
  7. 2 0
      bootstrap/utils.alc
  8. 40 0
      examples/SCCD_execute.py
  9. 16 0
      examples/analyze_LoLa.py
  10. 30 0
      examples/debug_DEVS.py
  11. 43 0
      examples/live_modelling_CTCBD.py
  12. 53 0
      examples/live_modelling_DTCBD.py
  13. 48 0
      examples/live_modelling_FSA.py
  14. 12 13
      models/pm_translate.py
  15. 25 26
      run_pw.py
  16. 18 0
      examples/render_DTCBD_graphical.py
  17. 18 0
      examples/render_DTCBD_plot.py
  18. 8 3
      hybrid_server/classes/mvkcontroller.xml
  19. 6 2
      hybrid_server/classes/task.xml
  20. 0 0
      integration/code/CBD_mapper.mvc
  21. 0 0
      integration/code/MM_rendered_graphical.mvc
  22. 0 0
      integration/code/SCCD.mvc
  23. 0 0
      integration/code/SCCD_Trace.mvc
  24. 15 15
      integration/code/SCCD_all.mvc
  25. 1 0
      models/SCCD_execute.alc
  26. 60 163
      integration/test_powerwindow.py
  27. 16 1
      interface/simple_plot/main.py
  28. 4 0
      kernel/modelverse_kernel/compiled.py
  29. 50 0
      kernel/modelverse_kernel/main.py
  30. 0 0
      models/ActionLanguage/to_python.alc
  31. 143 0
      models/CTCBD/PM_live_modelling.mvc
  32. 0 0
      models/CTCBD/metamodels/CTCBD_MM.mvc
  33. 0 0
      models/CTCBD/models/spring.mvc
  34. 0 0
      models/CTCBD/transformations/render.alc
  35. 297 0
      models/CTCBD/transformations/render.mvc
  36. 469 0
      models/CTCBD/transformations/to_partial_runtime.mvc
  37. 0 0
      models/ClassicDEVS/metamodels/DEVS.mvc
  38. 0 0
      models/ClassicDEVS/models/process_patterns_library.mvc
  39. 0 0
      models/ClassicDEVS/transformations/merge.alc
  40. 0 0
      models/ClassicDEVS/transformations/simulate.alc
  41. 143 0
      models/DTCBD/PM_live_modelling.mvc
  42. 12 2
      models/cbd_alg_design.mvc
  43. 0 0
      models/DTCBD/metamodels/DTCBD_MM_partial_runtime.mvc
  44. 0 0
      models/DTCBD/metamodels/DTCBD_MM_runtime.mvc
  45. 20 0
      models/DTCBD/models/simple_equation.mvc
  46. 3 3
      models/cbd_merge.alc
  47. 180 0
      models/DTCBD/transformations/render.alc
  48. 297 0
      models/DTCBD/transformations/render.mvc
  49. 204 59
      models/cbd_simulate.alc
  50. 0 0
      models/DTCBD/transformations/to_runtime.alc
  51. 14 0
      models/DiscreteEventTrace/metamodels/trace.mvc
  52. 0 0
      models/EncapsulatedPetriNets/metamodels/epn.mvc
  53. 0 0
      models/EncapsulatedPetriNets/transformations/combine.mvc
  54. 0 0
      models/EncapsulatedPetriNets/transformations/merge.alc
  55. 0 0
      models/EncapsulatedPetriNets/transformations/print.alc
  56. 0 8
      models/WSC/pm_PM_to_DEVS.mvc
  57. 0 0
      models/FTGPM/metamodels/control_patterns.mvc
  58. 0 0
      models/FTGPM/models/example_patterns.mvc
  59. 0 0
      models/FTGPM/transformations/patterns_to_DEVS.mvc
  60. 1835 0
      models/FTGPM/transformations/to_SCCD.mvc
  61. 10 10
      models/pm_live_CBD.mvc
  62. 15 0
      models/FiniteStateAutomata/metamodels/FSA_MM.mvc
  63. 15 0
      models/FiniteStateAutomata/metamodels/FSA_MM_partial_runtime.mvc
  64. 21 0
      models/FiniteStateAutomata/metamodels/FSA_MM_runtime.mvc
  65. 27 0
      models/FiniteStateAutomata/models/alarm.mvc
  66. 108 0
      models/FiniteStateAutomata/transformations/merge.alc
  67. 62 0
      models/FiniteStateAutomata/transformations/simulate.alc
  68. 60 0
      models/FiniteStateAutomata/transformations/to_runtime.alc
  69. 0 0
      models/ObjectDiagrams/transformations/render.alc
  70. 0 0
      models/ParallelDEVS/metamodels/PDEVS.mvc
  71. 0 0
      models/ParallelDEVS/models/produce_consume.mvc
  72. 0 0
      models/ParallelDEVS/transformations/simulate_interactive.alc
  73. 0 0
      models/PetriNets/metamodels/PetriNets.mvc
  74. 0 0
      models/PetriNets/models/critical_section.mvc
  75. 74 0
      models/PetriNets/models/critical_section_with_check.mvc
  76. 12 11
      models/lola.alc
  77. 0 0
      models/PetriNets/transformations/print.alc
  78. 0 0
      models/PetriNets/transformations/reachability.alc
  79. 0 0
      models/PowerWindow/PM_analyze.mvc
  80. 0 0
      models/PowerWindow/PM_analyze_debug.mvc
  81. 0 0
      models/PowerWindow/metamodels/architecture.mvc
  82. 0 0
      models/PowerWindow/metamodels/control.mvc
  83. 0 0
      models/PowerWindow/metamodels/environment.mvc
  84. 0 0
      models/PowerWindow/metamodels/plant.mvc
  85. 0 0
      models/PowerWindow/metamodels/requirements.mvc
  86. 0 0
      models/PowerWindow/models/architecture.mvc
  87. 0 0
      models/PowerWindow/models/control.mvc
  88. 0 0
      models/PowerWindow/models/control_wrong.mvc
  89. 0 0
      models/PowerWindow/models/environment.mvc
  90. 0 0
      models/PowerWindow/models/plant.mvc
  91. 0 0
      models/PowerWindow/models/requirements.mvc
  92. 0 0
      models/PowerWindow/transformations/control_to_EPN.mvc
  93. 0 0
      models/PowerWindow/transformations/environment_to_EPN.mvc
  94. 0 0
      models/PowerWindow/transformations/initialize.mvc
  95. 0 0
      models/PowerWindow/transformations/plant_to_EPN.mvc
  96. 0 0
      models/PythonPDEVS_Experiment/metamodels/experiment.mvc
  97. 0 0
      models/PythonPDEVS_Experiment/models/optimize_PM_resources.mvc
  98. 0 0
      models/ReachabilityGraph/metamodels/reachability_graph.mvc
  99. 0 0
      models/ReachabilityGraph/transformations/bfs.alc
  100. 0 0
      models/matches.mvc

+ 1 - 1
bootstrap/constructors.alc

@@ -112,7 +112,7 @@ String function construct_global(model : Element, list : Element):
 			create_al_link(model, "resolve_var", res, instantiate_value(model, "String", "", "create_node"), "var")
 		elif (op == "const"):
 			value = instantiate_value(model, "constant", "", create_value(!constant))
-			create_al_link(model, "constant_node", value, list_pop_final(list), "node")
+			create_al_link(model, "constant_node", value, instantiate_value(model, "Element", "", list_pop_final(list)), "node")
 		create_al_link(model, "assign_value", assign, value, "value")
 
 		Element result

+ 2 - 2
bootstrap/model_management.alc

@@ -234,8 +234,8 @@ Element function model_join(models : Element, metamodel : Element, tracability_m
 							// Found a match for source and target, so create a link
 							new_name = instantiate_link(new_model, type, "", src_model + src_name, dst_model + dst_name)
 
-							if (new_name == ""):
-								log("ERROR: could not create a tracability link; ignoring")
+							//if (new_name == ""):
+							//	log("ERROR: could not create a tracability link; ignoring")
 	return new_model!
 	
 Element function model_split(merged_model : Element, models : Element, tracability : Boolean):

+ 8 - 2
bootstrap/object_operations.alc

@@ -203,24 +203,30 @@ String function readAssociationDestination(model : Element, name : String):
 Element function allAssociationDestinations(model : Element, name : String, association_type : String):
 	Element tmp
 	Element result
+	String val
 
 	result = set_create()
 	tmp = allOutgoingAssociationInstances(model, name, association_type)
 
 	while (set_len(tmp) > 0):
-		set_add(result, readAssociationDestination(model, set_pop(tmp)))
+		val = readAssociationDestination(model, set_pop(tmp))
+		if (val != ""):
+			set_add(result, val)
 
 	return result!
 
 Element function allAssociationOrigins(model : Element, name : String, association_type : String):
 	Element tmp
 	Element result
+	String val
 
 	result = set_create()
 	tmp = allIncomingAssociationInstances(model, name, association_type)
 
 	while (set_len(tmp) > 0):
-		set_add(result, readAssociationSource(model, set_pop(tmp)))
+		val = readAssociationSource(model, set_pop(tmp))
+		if (val != ""):
+			set_add(result, val)
 
 	return result!
 

+ 1 - 0
bootstrap/ramify.alc

@@ -85,6 +85,7 @@ Element function ramify(model : Element):
 	instantiate_node(new_model, "Class", "PostElement")
 	model_define_attribute(new_model, "PostElement", "label", False, "String")
 	model_define_attribute(new_model, "PostElement", "action", True, "ActionLanguage")
+	model_define_attribute(new_model, "PostElement", "__id__", True, "ActionLanguage")
 
 	// Association RHS_contains (RHS, PostElement) {}
 	instantiate_link(new_model, "Association", "RHS_contains", "RHS", "PostElement")

+ 19 - 5
bootstrap/transform.alc

@@ -359,6 +359,8 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 	String value
 	String action
 	Element original_RHS_labels
+	String new_identifier
+	Element func
 
 	Element reverse
 	reverse = make_reverse_dictionary(schedule_model["model"])
@@ -389,6 +391,14 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 	while (list_len(labels_to_add) > 0):
 		// Add the elements linked to these labels
 		label = list_pop(labels_to_add, list_len(labels_to_add) - 1)
+
+		// Check if we have any requirement for the ID
+		if (element_eq(read_attribute(schedule_model, RHS_map[label], "__id__"), read_root())):
+			new_identifier = ""
+		else:
+			func = get_func_AL_model(import_node(read_attribute(schedule_model, RHS_map[label], "__id__")))
+			new_identifier = func(host_model, mapping)
+
 		if (is_edge(schedule_model["model"][RHS_map[label]])):
 			// Edge
 			src = read_attribute(schedule_model, reverse[cast_id(read_edge_src(schedule_model["model"][RHS_map[label]]))], "label")
@@ -399,7 +409,7 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 				// Both are present, so we can make the link
 				typename = read_type(schedule_model, RHS_map[label])
 				original_typename = string_substr(typename, 5, string_len(typename))
-				new_name = instantiate_link(host_model, original_typename, "", new_mapping[src], new_mapping[dst])
+				new_name = instantiate_link(host_model, original_typename, new_identifier, new_mapping[src], new_mapping[dst])
 				dict_add_fast(new_mapping, label, new_name)
 			else:
 				// Delay this a bit, until all are bound
@@ -409,13 +419,12 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 			// Create the node and add it
 			typename = read_type(schedule_model, RHS_map[label])
 			original_typename = string_substr(typename, 5, string_len(typename))
-			new_name = instantiate_node(host_model, original_typename, "")
+			new_name = instantiate_node(host_model, original_typename, new_identifier)
 			dict_add_fast(new_mapping, label, new_name)
 
 	Element attributes
 	String attribute
 	Element result
-	Element func
 
 	while (set_len(original_RHS_labels) > 0):
 		// Perform actions
@@ -535,9 +544,12 @@ Boolean function transform_atomic(host_model : Element, schedule_model : Element
 	// Execute the atomic transformation
 	Element mappings
 	Element mapping
+
+	//log("Executing rule: " + current)
+
 	mappings = full_match(host_model, schedule_model, current, True)
 
-	log("Executing rule: " + current)
+	//log("Executing rule: " + current)
 
 	if (set_len(mappings) > 0):
 		// Pick one!
@@ -545,8 +557,10 @@ Boolean function transform_atomic(host_model : Element, schedule_model : Element
 		String RHS
 		RHS = set_pop(allAssociationDestinations(schedule_model, current, "RHSLink"))
 		rewrite(host_model, schedule_model, RHS, mapping)
+		//log("Rewrite OK")
 		return True!
 	else:
+		log("Rewrite failed")
 		return False!
 
 Boolean function transform_forall(host_model : Element, schedule_model : Element, current : String):
@@ -556,7 +570,7 @@ Boolean function transform_forall(host_model : Element, schedule_model : Element
 	Element mapping
 	Boolean result
 
-	log("Executing rule: " + current)
+	//log("Executing rule: " + current)
 
 	mappings = full_match(host_model, schedule_model, current, False)
 

+ 9 - 4
bootstrap/typing.alc

@@ -54,15 +54,20 @@ Void function set_type_mapping(model : Element, type_mapping_model : Element):
 
 Element function elements_typed_by(model : Element, type_name : String):
 	Element result
-	result = reverseKeyLookupMulti(get_type_mapping_as_dict(model), type_name)
+	Element temp_result
+	String temp
+
+	result = set_create()
+	temp_result = reverseKeyLookupMulti(get_type_mapping_as_dict(model), type_name)
+	while (set_len(temp_result) > 0):
+		temp = set_pop(temp_result)
+		if (dict_in(model["model"], temp)):
+			set_add(result, temp)
 	return result!
 
 Element function get_type_mapping_as_dict(model : Element):
 	return model["type_mapping"]!
 
-Element function get_elements_typed_by(model : Element, type : String):
-	return reverseKeyLookupMulti(model["type_mapping"], type)!
-
 String function read_type(model : Element, name : String):
 	String result
 	Element tm

+ 2 - 0
bootstrap/utils.alc

@@ -19,7 +19,9 @@ String function JSON_print(model : Element):
 
 	while (set_len(keys_m) > 0):
 		v_m = set_pop(keys_m)
+		log("Check " + v_m)
 		type = read_type(model["metamodel"], read_type(model, v_m))
+		log("Type: " + type)
 
 		if (bool_or(type == "Class", type == "Association")):
 			if (bool_not(first)):

+ 40 - 0
examples/SCCD_execute.py

@@ -0,0 +1,40 @@
+import sys
+sys.path.append("wrappers")
+from modelverse import *
+
+init()
+login("admin", "admin")
+
+model_add("test/SCCD", "formalisms/SimpleClassDiagrams", open("models/SCCD/metamodels/SCCD.mvc", 'r').read())
+model_add("test/SCCD_Trace", "formalisms/SimpleClassDiagrams", open("models/DiscreteEventTrace/metamodels/trace.mvc", 'r').read())
+
+model_add("test/my_SCCD", "test/SCCD", open("models/SCCD/models/dynamic_trafficlight.mvc", 'r').read())
+
+#transformation_add_AL({"SCCD": "test/SCCD"}, {"trace": "test/SCCD_Trace"}, "test/SCCD_execute_afap", open("models/SCCD/transformations/execute.alc", 'r').read().replace("afap = False", "afap = True"))
+transformation_add_AL({"SCCD": "test/SCCD"}, {"trace": "test/SCCD_Trace"}, "test/SCCD_execute_afap", open("models/SCCD/transformations/execute.alc", 'r').read())
+
+import poll_print
+ctrl = poll_print.Controller(keep_running=False)
+
+thrd = threading.Thread(target=ctrl.start)
+thrd.daemon = True
+thrd.start()
+
+def input_thread():
+    import select
+    while thrd.is_alive():
+        if select.select([sys.stdin], [], [], 0.1)[0]:
+            ctrl.addInput(Event("raw_inp", "user_inp", [sys.stdin.readline().strip()]))
+
+thrd2 = threading.Thread(target=input_thread)
+thrd2.daemon = True
+thrd2.start()
+
+transformation_execute_AL("test/SCCD_execute_afap", {"SCCD": "test/my_SCCD"}, {"trace": "test/my_SCCD_trace"}, statechart=(ctrl, "inp", "outp"))
+
+alter_context("test/my_SCCD_trace", "test/SCCD_Trace")
+lst = element_list_nice("test/my_SCCD_trace")
+
+lst.sort(key=lambda i: (i["timestamp"], i["name"]))
+result = [(i["timestamp"], str(i["name"])) for i in lst if i["name"] not in ["updateTimerValue", "updateTimerColour", "resetTimer"]]
+print(result)

+ 16 - 0
examples/analyze_LoLa.py

@@ -0,0 +1,16 @@
+import sys
+sys.path.append("wrappers/")
+from modelverse import *
+
+init()
+login("admin", "admin")
+
+model_add("formalisms/PetriNets", "formalisms/SimpleClassDiagrams", open("models/PetriNets/metamodels/PetriNets.mvc", 'r').read())
+model_add("formalisms/Query", "formalisms/SimpleClassDiagrams", open("models/SafetyQuery/metamodels/query.mvc", 'r').read())
+
+model_add("models/PN", "formalisms/PetriNets", open("models/PetriNets/models/critical_section_with_check.mvc", 'r').read())
+model_add("models/Query", "formalisms/Query", open("models/SafetyQuery/models/both_criticals_enabled.mvc", 'r').read())
+
+transformation_add_AL({"PN": "formalisms/PetriNets", "Query": "formalisms/Query"}, {}, "models/analyze_lola", open("models/PetriNets/transformations/analyze_lola.alc", 'r').read())
+
+transformation_execute_AL("models/analyze_lola", {"PN": "models/PN", "Query": "models/Query"}, {})

+ 30 - 0
examples/debug_DEVS.py

@@ -0,0 +1,30 @@
+import sys
+sys.path.append("wrappers")
+from modelverse import *
+
+init()
+login("admin", "admin")
+
+model_add("formalisms/ParallelDEVS", "formalisms/SimpleClassDiagrams", open("models/ParallelDEVS/metamodels/PDEVS.mvc", 'r').read())
+model_add("models/produce_consume_pdevs", "formalisms/ParallelDEVS", open("models/ParallelDEVS/models/produce_consume.mvc", 'r').read())
+
+transformation_add_AL({"ParallelDEVS": "formalisms/ParallelDEVS"}, {}, "models/paralleldevs_simulator", open("models/ParallelDEVS/transformations/simulate_interactive.alc", "r").read())
+
+import poll_print
+ctrl = poll_print.Controller(keep_running=False)
+
+thrd = threading.Thread(target=ctrl.start)
+thrd.daemon = True
+thrd.start()
+
+def input_thread():
+    import select
+    while thrd.is_alive():
+        if select.select([sys.stdin], [], [], 0.1)[0]:
+            ctrl.addInput(Event("raw_inp", "user_inp", [sys.stdin.readline().strip()]))
+
+thrd2 = threading.Thread(target=input_thread)
+thrd2.daemon = True
+thrd2.start()
+
+transformation_execute_AL("models/paralleldevs_simulator", {"ParallelDEVS": "models/produce_consume_pdevs"}, {}, statechart=(ctrl, "inp", "outp"))

+ 43 - 0
examples/live_modelling_CTCBD.py

@@ -0,0 +1,43 @@
+import sys
+sys.path.append("wrappers")
+from modelverse import *
+import time
+
+init()
+login("admin", "admin")
+
+### live modelling CTCBD
+
+model_add("formalisms/CTCBD/Design_MM", "formalisms/SimpleClassDiagrams", open("models/CTCBD/metamodels/CTCBD_MM.mvc", 'r').read())
+model_add("formalisms/DTCBD/PartialRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/DTCBD/metamodels/DTCBD_MM_partial_runtime.mvc", 'r').read())
+model_add("formalisms/DTCBD/FullRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/DTCBD/metamodels/DTCBD_MM_runtime.mvc", 'r').read())
+
+model_add("models/CTCBD_model", "formalisms/CTCBD/Design_MM", open("models/CTCBD/models/spring.mvc", 'r').read())
+
+transformation_add_MANUAL({"Design": "formalisms/CTCBD/Design_MM"}, {"Design": "formalisms/CTCBD/Design_MM"}, "models/CTCBD/edit")
+
+def trace_D2P(model):
+    instantiate(model, "Association", ("Design/Block", "PartialRuntime/Block"), ID="D2P_block")
+
+transformation_add_MT({"Design": "formalisms/CTCBD/Design_MM", "PartialRuntime": "formalisms/DTCBD/PartialRuntime_MM"}, {"PartialRuntime": "formalisms/DTCBD/PartialRuntime_MM"}, "models/CTCBD/toRuntime", open("models/CTCBD/transformations/to_partial_runtime.mvc", 'r').read(), trace_D2P)
+
+def trace_P2F(model):
+    instantiate(model, "Association", ("PartialRuntime/Block", "FullRuntime/Block"), ID="P2F_block")
+
+transformation_add_AL({"PartialRuntime": "formalisms/DTCBD/PartialRuntime_MM", "FullRuntime": "formalisms/DTCBD/FullRuntime_MM"}, {"NewFullRuntime": "formalisms/DTCBD/FullRuntime_MM"}, "models/DTCBD/merge", open("models/DTCBD/transformations/merge.alc", 'r').read(), trace_P2F)
+transformation_add_AL({"FullRuntime": "formalisms/DTCBD/FullRuntime_MM"}, {"FullRuntime": "formalisms/DTCBD/FullRuntime_MM"}, "models/DTCBD/simulate", open("models/DTCBD/transformations/simulate.alc", 'r').read())
+transformation_add_AL({}, {}, "models/DTCBD/restartSim", open("models/generic/restart_simulation.alc", 'r').read())
+
+model_add("models/live_modelling_CTCBD", "formalisms/ProcessModel", open("models/CTCBD/PM_live_modelling.mvc", 'r').read())
+
+def modify_model(model):
+    elements = element_list_nice(model)
+    for e in elements:
+        if e.get("value", None) == 10.0:
+            attr_assign(model, e["id"], "value", 100.0)
+            break
+    else:
+        while 1:
+            time.sleep(1)
+
+process_execute("models/live_modelling_CTCBD", {"design_model": "models/CTCBD_model"}, {"models/CTCBD/edit": modify_model})

+ 53 - 0
examples/live_modelling_DTCBD.py

@@ -0,0 +1,53 @@
+import sys
+sys.path.append("wrappers")
+from modelverse import *
+
+init()
+login("admin", "admin")
+
+### live modelling DTCBD
+
+model_add("formalisms/DTCBD/Design_MM", "formalisms/SimpleClassDiagrams", open("models/DTCBD/metamodels/DTCBD_MM.mvc", 'r').read())
+model_add("formalisms/DTCBD/PartialRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/DTCBD/metamodels/DTCBD_MM_partial_runtime.mvc", 'r').read())
+model_add("formalisms/DTCBD/FullRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/DTCBD/metamodels/DTCBD_MM_runtime.mvc", 'r').read())
+
+model_add("models/DTCBD_model", "formalisms/DTCBD/Design_MM", open("models/DTCBD/models/simple_equation.mvc", 'r').read())
+
+transformation_add_MANUAL({"Design": "formalisms/DTCBD/Design_MM"}, {"Design": "formalisms/DTCBD/Design_MM"}, "models/DTCBD/edit")
+
+def trace_D2P(model):
+    instantiate(model, "Association", ("Design/Block", "PartialRuntime/Block"), ID="D2P_block")
+
+transformation_add_AL({"Design": "formalisms/DTCBD/Design_MM", "PartialRuntime": "formalisms/DTCBD/PartialRuntime_MM"}, {"PartialRuntime": "formalisms/DTCBD/PartialRuntime_MM"}, "models/DTCBD/toRuntime", open("models/DTCBD/transformations/to_runtime.alc", 'r').read(), trace_D2P)
+
+def trace_P2F(model):
+    instantiate(model, "Association", ("PartialRuntime/Block", "FullRuntime/Block"), ID="P2F_block")
+
+transformation_add_AL({"PartialRuntime": "formalisms/DTCBD/PartialRuntime_MM", "FullRuntime": "formalisms/DTCBD/FullRuntime_MM"}, {"NewFullRuntime": "formalisms/DTCBD/FullRuntime_MM"}, "models/DTCBD/merge", open("models/DTCBD/transformations/merge.alc", 'r').read(), trace_P2F)
+transformation_add_AL({"FullRuntime": "formalisms/DTCBD/FullRuntime_MM"}, {"FullRuntime": "formalisms/DTCBD/FullRuntime_MM"}, "models/DTCBD/simulate", open("models/DTCBD/transformations/simulate.alc", 'r').read())
+transformation_add_AL({}, {}, "models/DTCBD/restartSim", open("models/generic/restart_simulation.alc", 'r').read())
+
+model_add("models/live_modelling_DTCBD", "formalisms/ProcessModel", open("models/DTCBD/PM_live_modelling.mvc", 'r').read())
+
+def modify_model(model):
+    elements = element_list_nice(model)
+    for e in elements:
+        if e.get("value", None) == 2.0:
+            while 1:
+                time.sleep(1)
+        elif e.get("type", None) == "Design/AdditionBlock":
+            adder = e["id"]
+            links = read_outgoing(model, adder, "Design/Link")
+            destinations = [read_association_destination(model, link) for link in links]
+    else:
+        mult = instantiate(model, "Design/MultiplyBlock")
+        two = instantiate(model, "Design/ConstantBlock")
+        attr_assign(model, two, "value", 2.0)
+        instantiate(model, "Design/Link", (adder, mult))
+        instantiate(model, "Design/Link", (two, mult))
+        for link in links:
+            delete_element(model, link)
+        for destination in destinations:
+            instantiate(model, "Design/Link", (mult, destination))
+
+process_execute("models/live_modelling_DTCBD", {"design_model": "models/DTCBD_model"}, {"models/DTCBD/edit": modify_model})

+ 48 - 0
examples/live_modelling_FSA.py

@@ -0,0 +1,48 @@
+import sys
+sys.path.append("wrappers")
+from modelverse import *
+
+init()
+login("admin", "admin")
+
+### live modelling FSA
+
+model_add("formalisms/FSA/Design_MM", "formalisms/SimpleClassDiagrams", open("models/FiniteStateAutomata/metamodels/FSA_MM.mvc", 'r').read())
+model_add("formalisms/FSA/PartialRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/FiniteStateAutomata/metamodels/FSA_MM_partial_runtime.mvc", 'r').read())
+model_add("formalisms/FSA/FullRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/FiniteStateAutomata/metamodels/FSA_MM_runtime.mvc", 'r').read())
+
+model_add("models/FSA_model", "formalisms/FSA/Design_MM", open("models/FiniteStateAutomata/models/alarm.mvc", 'r').read())
+
+transformation_add_MANUAL({"Design": "formalisms/FSA/Design_MM"}, {"Design": "formalisms/FSA/Design_MM"}, "models/FSA/edit")
+
+def trace_D2P(model):
+    instantiate(model, "Association", ("Design/State", "PartialRuntime/State"), ID="D2P_state")
+
+transformation_add_AL({"Design": "formalisms/FSA/Design_MM", "PartialRuntime": "formalisms/FSA/PartialRuntime_MM"}, {"PartialRuntime": "formalisms/FSA/PartialRuntime_MM"}, "models/FSA/toRuntime", open("models/FiniteStateAutomata/transformations/to_runtime.alc", 'r').read(), trace_D2P)
+
+def trace_P2F(model):
+    instantiate(model, "Association", ("PartialRuntime/State", "FullRuntime/State"), ID="P2F_state")
+
+transformation_add_AL({"PartialRuntime": "formalisms/FSA/PartialRuntime_MM", "FullRuntime": "formalisms/FSA/FullRuntime_MM"}, {"NewFullRuntime": "formalisms/FSA/FullRuntime_MM"}, "models/FSA/merge", open("models/FiniteStateAutomata/transformations/merge.alc", 'r').read(), trace_P2F)
+transformation_add_AL({"FullRuntime": "formalisms/FSA/FullRuntime_MM"}, {"FullRuntime": "formalisms/FSA/FullRuntime_MM"}, "models/FSA/simulate", open("models/FiniteStateAutomata/transformations/simulate.alc", 'r').read())
+transformation_add_AL({}, {}, "models/FSA/restartSim", open("models/generic/restart_simulation.alc", 'r').read())
+
+model_add("models/live_modelling_FSA", "formalisms/ProcessModel", open("models/FiniteStateAutomata/PM_live_modelling.mvc", 'r').read())
+
+def edit_FSA(model):
+    elements = element_list_nice(model)
+    for e in elements:
+        if e.get("name", None) == "idle":
+            delete_element(model, e["id"])
+            break
+    else:
+        while 1:
+            time.sleep(1)
+
+    # Removed, so set a new element as initial
+    for e in elements:
+        if e.get("name", None) == "armed":
+            attr_assign(model, e["id"], "initial", True)
+            break
+
+process_execute("models/live_modelling_FSA", {"design_model": "models/FSA_model"}, {"models/FSA/edit": modify_model})

+ 12 - 13
models/pm_translate.py

@@ -6,23 +6,22 @@ from modelverse import *
 init()
 login("admin", "admin")
 
-model_add("formalisms/DEVS/DEVS_MM", "formalisms/SimpleClassDiagrams", open("models/WSC/DEVS.mvc", 'r').read())
-model_add("formalisms/Metrics/Metrics_MM", "formalisms/SimpleClassDiagrams", open("models/WSC/metrics.mvc", 'r').read())
-model_add("formalisms/PM/PM_Extended_MM", "formalisms/SimpleClassDiagrams", open("models/WSC/pm.mvc", 'r').read())
-model_add("formalisms/Experiment/Experiment_MM", "formalisms/SimpleClassDiagrams", open("models/WSC/experiment.mvc", 'r').read())
+model_add("formalisms/DEVS/DEVS_MM", "formalisms/SimpleClassDiagrams", open("models/ClassicDEVS/metamodels/DEVS.mvc", 'r').read())
+model_add("formalisms/PM/PM_Extended_MM", "formalisms/SimpleClassDiagrams", open("models/FTGPM/metamodels/control_patterns.mvc", 'r').read())
+model_add("formalisms/Experiment/Experiment_MM", "formalisms/SimpleClassDiagrams", open("models/PythonPDEVS_Experiment/metamodels/experiment.mvc", 'r').read())
 
-model_add("models/PM/to_DEVS", "formalisms/ProcessModel", open("models/WSC/pm_PM_to_DEVS.mvc").read())
+model_add("models/PM/to_DEVS", "formalisms/ProcessModel", open("models/FTGPM/PM_patterns_simulation.mvc").read())
 
-model_add("models/DEVS/PM_library", "formalisms/DEVS/DEVS_MM", open("models/WSC/pm_library.mvc", 'r').read())
-model_add("models/PM/example_PM", "formalisms/PM/PM_Extended_MM", open("models/WSC/pm_example.mvc", 'r').read())
-model_add("models/Experiment/example_experiment", "formalisms/Experiment/Experiment_MM", open("models/WSC/experiment_example.mvc", 'r').read())
+model_add("models/DEVS/PM_library", "formalisms/DEVS/DEVS_MM", open("models/ClassicDEVS/models/process_patterns_library.mvc", 'r').read())
+model_add("models/PM/example_PM", "formalisms/PM/PM_Extended_MM", open("models/FTGPM/models/example_patterns.mvc", 'r').read())
+model_add("models/Experiment/example_experiment", "formalisms/Experiment/Experiment_MM", open("models/PythonPDEVS_Experiment/models/optimize_PM_resources.mvc", 'r').read())
 
 def traceability_pm_devs(model):
     instantiate(model, "Association", ("PM/ProcessNode", "DEVS/DEVSInstance"), ID="Trace")
-    
-transformation_add_MT({"PM": "formalisms/PM/PM_Extended_MM"}, {"DEVS": "formalisms/DEVS/DEVS_MM"}, "formalisms/PM/to_DEVS", open("models/WSC/PM_to_DEVS.mvc", 'r').read(), traceability_pm_devs)
 
-transformation_add_AL({"model1": "formalisms/DEVS/DEVS_MM", "model2": "formalisms/DEVS/DEVS_MM"}, {"result": "formalisms/DEVS/DEVS_MM"}, "formalisms/DEVS/merge", open("models/WSC/DEVS_merge.alc", 'r').read())
-transformation_add_AL({"DEVS": "formalisms/DEVS/DEVS_MM", "Experiment": "formalisms/Experiment/Experiment_MM"}, {"metrics": "formalisms/Metrics/Metrics_MM"}, "formalisms/DEVS/simulate", open("models/WSC/DEVS_simulate.alc", 'r').read())
+transformation_add_MT({"PM": "formalisms/PM/PM_Extended_MM"}, {"DEVS": "formalisms/DEVS/DEVS_MM"}, "formalisms/PM/to_DEVS", open("models/FTGPM/transformations/patterns_to_DEVS.mvc", 'r').read(), traceability_pm_devs)
 
-process_execute("models/PM/to_DEVS", {"PM": "models/PM/example_PM", "DEVS library": "models/DEVS/PM_library", "Metrics": "models/Metrics/metric", "Experiment": "models/Experiment/example_experiment"}, {})
+transformation_add_AL({"model1": "formalisms/DEVS/DEVS_MM", "model2": "formalisms/DEVS/DEVS_MM"}, {"result": "formalisms/DEVS/DEVS_MM"}, "formalisms/DEVS/merge", open("models/ClassicDEVS/transformations/merge.alc", 'r').read())
+transformation_add_AL({"DEVS": "formalisms/DEVS/DEVS_MM", "Experiment": "formalisms/Experiment/Experiment_MM"}, {}, "formalisms/DEVS/simulate", open("models/ClassicDEVS/transformations/simulate.alc", 'r').read())
+
+process_execute("models/PM/to_DEVS", {"PM": "models/PM/example_PM", "DEVS library": "models/DEVS/PM_library", "Experiment": "models/Experiment/example_experiment"}, {})

+ 25 - 26
run_pw.py

@@ -3,22 +3,21 @@ import sys
 import os
 sys.path.append("wrappers")
 from modelverse import *
-import threading
 
 init()
 login("admin", "admin")
 
-model_add("formalisms/ReachabilityGraph", "formalisms/SimpleClassDiagrams", open("models/reachability_graph.mvc", "r").read())
-model_add("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("integration/code/pn_design.mvc", 'r').read())
-model_add("formalisms/Encapsulated_PetriNet", "formalisms/SimpleClassDiagrams", open("models/petrinet_ports.mvc", 'r').read())
-model_add("formalisms/PW_Plant", "formalisms/SimpleClassDiagrams", open("models/plant_PW.mvc", 'r').read())
-model_add("formalisms/PW_Environment", "formalisms/SimpleClassDiagrams", open("models/environment_PW.mvc", 'r').read())
-model_add("formalisms/PW_Control", "formalisms/SimpleClassDiagrams", open("models/control_PW.mvc", 'r').read())
-model_add("formalisms/Requirements", "formalisms/SimpleClassDiagrams", open("models/requirements.mvc", 'r').read())
-model_add("formalisms/Query", "formalisms/SimpleClassDiagrams", open("models/query.mvc", 'r').read())
-model_add("formalisms/Architecture", "formalisms/SimpleClassDiagrams", open("models/architecture.mvc", 'r').read())
+model_add("formalisms/ReachabilityGraph", "formalisms/SimpleClassDiagrams", open("models/ReachabilityGraph/metamodels/reachability_graph.mvc", "r").read())
+model_add("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("models/PetriNets/metamodels/PetriNets.mvc", 'r').read())
+model_add("formalisms/Encapsulated_PetriNet", "formalisms/SimpleClassDiagrams", open("models/EncapsulatedPetriNets/metamodels/epn.mvc", 'r').read())
+model_add("formalisms/PW_Plant", "formalisms/SimpleClassDiagrams", open("models/PowerWindow/metamodels/plant.mvc", 'r').read())
+model_add("formalisms/PW_Environment", "formalisms/SimpleClassDiagrams", open("models/PowerWindow/metamodels/environment.mvc", 'r').read())
+model_add("formalisms/PW_Control", "formalisms/SimpleClassDiagrams", open("models/PowerWindow/metamodels/control.mvc", 'r').read())
+model_add("formalisms/Requirements", "formalisms/SimpleClassDiagrams", open("models/PowerWindow/metamodels/requirements.mvc", 'r').read())
+model_add("formalisms/Query", "formalisms/SimpleClassDiagrams", open("models/SafetyQuery/metamodels/query.mvc", 'r').read())
+model_add("formalisms/Architecture", "formalisms/SimpleClassDiagrams", open("models/PowerWindow/metamodels/architecture.mvc", 'r').read())
 
-model_add("models/pm_powerwindow", "formalisms/ProcessModel", open("models/pm_req_analyse.mvc", 'r').read())
+model_add("models/pm_powerwindow", "formalisms/ProcessModel", open("models/PowerWindow/PM_analyze.mvc", 'r').read())
 
 transformation_add_MANUAL({"Requirements": "formalisms/Requirements"}, {"Requirements": "formalisms/Requirements"}, "models/revise_req")
 transformation_add_MANUAL({"Requirements": "formalisms/Requirements", "PW_Environment": "formalisms/PW_Environment"}, {"PW_Environment": "formalisms/PW_Environment"}, "models/revise_environment")
@@ -42,16 +41,16 @@ def tracability_EPN2PN(model):
     instantiate(model, "Association", ("Encapsulated_PetriNet/Place", "PetriNet/Place"), ID="EPN2PN_transition_link")
     instantiate(model, "Association", ("Encapsulated_PetriNet/Transition", "PetriNet/Transition"), ID="EPN2PN_place_link")
 
-transformation_add_MT({}, {"PW_Plant": "formalisms/PW_Plant", "PW_Environment": "formalisms/PW_Environment", "PW_Control": "formalisms/PW_Control", "Query": "formalisms/Query", "Architecture": "formalisms/Architecture", "Requirements": "formalisms/Requirements"}, "models/make_initial_models", open("models/initialize.mvc", 'r').read())
-transformation_add_MT({"PW_Plant": "formalisms/PW_Plant"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/plant_to_EPN", open("models/plant_to_EPN.mvc", 'r').read(), tracability_PLANT2EPN)
-transformation_add_MT({"PW_Control": "formalisms/PW_Control"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/control_to_EPN", open("models/control_to_EPN.mvc", 'r').read(), tracability_CTRL2EPN)
-transformation_add_MT({"PW_Environment": "formalisms/PW_Environment"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/environment_to_EPN", open("models/environment_to_EPN.mvc", 'r').read(), tracability_ENV2EPN)
-transformation_add_MT({"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet", "Architecture": "formalisms/Architecture"}, {"PetriNet": "formalisms/PetriNet"}, "models/combine_EPN", open("models/combine_EPN.mvc", 'r').read(), tracability_EPN2PN)
-transformation_add_MT({"ReachabilityGraph": "formalisms/ReachabilityGraph", "Query": "formalisms/Query"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/match", open("models/matches.mvc", 'r').read())
+transformation_add_MT({}, {"PW_Plant": "formalisms/PW_Plant", "PW_Environment": "formalisms/PW_Environment", "PW_Control": "formalisms/PW_Control", "Query": "formalisms/Query", "Architecture": "formalisms/Architecture", "Requirements": "formalisms/Requirements"}, "models/make_initial_models", open("models/PowerWindow/transformations/initialize.mvc", 'r').read())
+transformation_add_MT({"PW_Plant": "formalisms/PW_Plant"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/plant_to_EPN", open("models/PowerWindow/transformations/plant_to_EPN.mvc", 'r').read(), tracability_PLANT2EPN)
+transformation_add_MT({"PW_Control": "formalisms/PW_Control"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/control_to_EPN", open("models/PowerWindow/transformations/control_to_EPN.mvc", 'r').read(), tracability_CTRL2EPN)
+transformation_add_MT({"PW_Environment": "formalisms/PW_Environment"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/environment_to_EPN", open("models/PowerWindow/transformations/environment_to_EPN.mvc", 'r').read(), tracability_ENV2EPN)
+transformation_add_MT({"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet", "Architecture": "formalisms/Architecture"}, {"PetriNet": "formalisms/PetriNet"}, "models/combine_EPN", open("models/EncapsulatedPetriNets/transformations/combine.mvc", 'r').read(), tracability_EPN2PN)
+transformation_add_MT({"ReachabilityGraph": "formalisms/ReachabilityGraph", "Query": "formalisms/Query"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/match", open("models/ReachabilityGraph/transformations/match_query.mvc", 'r').read())
 
-transformation_add_AL({"PetriNet": "formalisms/PetriNet"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/reachability", open("models/reachability.alc", 'r').read())
-transformation_add_AL({"ReachabilityGraph": "formalisms/ReachabilityGraph"}, {}, "models/bfs", open("models/bfs.alc", 'r').read())
-transformation_add_AL({"EPN_Plant": "formalisms/Encapsulated_PetriNet", "EPN_Control": "formalisms/Encapsulated_PetriNet", "EPN_Environment": "formalisms/Encapsulated_PetriNet"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/merge_EPN", open("models/merge_EPN.alc", 'r').read())
+transformation_add_AL({"PetriNet": "formalisms/PetriNet"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/reachability", open("models/PetriNets/transformations/reachability.alc", 'r').read())
+transformation_add_AL({"ReachabilityGraph": "formalisms/ReachabilityGraph"}, {}, "models/bfs", open("models/ReachabilityGraph/transformations/bfs.alc", 'r').read())
+transformation_add_AL({"EPN_Plant": "formalisms/Encapsulated_PetriNet", "EPN_Control": "formalisms/Encapsulated_PetriNet", "EPN_Environment": "formalisms/Encapsulated_PetriNet"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/merge_EPN", open("models/EncapsulatedPetriNets/transformations/merge.alc", 'r').read())
 
 nr_of_operations = 6
 
@@ -75,12 +74,12 @@ def get_function(filename):
         model_overwrite(model, open(filename, "r").read())
     return func
 
-cb_req = get_function("models/requirements_model.mvc")
-cb_plant = get_function("models/plant_model.mvc")
-cb_env = get_function("models/environment_model.mvc")
-cb_ctrl = get_function("models/control_model.mvc")
-cb_query = get_function("models/query_model.mvc")
-cb_arch = get_function("models/architecture_model.mvc")
+cb_req = get_function(  "models/PowerWindow/models/requirements.mvc")
+cb_plant = get_function("models/PowerWindow/models/plant.mvc")
+cb_env = get_function(  "models/PowerWindow/models/environment.mvc")
+cb_ctrl = get_function( "models/PowerWindow/models/control.mvc")
+cb_query = get_function("models/SafetyQuery/models/powerwindow_safe.mvc")
+cb_arch = get_function( "models/PowerWindow/models/architecture.mvc")
 
 callbacks = {
         "models/revise_req": cb_req,

+ 18 - 0
examples/render_DTCBD_graphical.py

@@ -0,0 +1,18 @@
+import sys
+sys.path.append("wrappers")
+from modelverse import *
+
+init()
+login("admin", "admin")
+
+model_add("formalisms/DTCBD/Design_MM", "formalisms/SimpleClassDiagrams", open("models/DTCBD/metamodels/DTCBD_MM.mvc", 'r').read())
+model_add("models/DTCBD_model", "formalisms/DTCBD/Design_MM", open("models/DTCBD/models/simple_equation.mvc", 'r').read())
+
+model_add("formalisms/MM_render/graphical", "formalisms/SimpleClassDiagrams", open("models/render/metamodels/graphical.mvc", 'r').read())
+
+def add_trace_CBD(model):
+    instantiate(model, "Association", ("abstract/Block", "rendered/Group"), ID="TracabilityClass")
+
+transformation_add_AL({"abstract": "formalisms/DTCBD/Design_MM", "rendered": "formalisms/MM_render/graphical"}, {"rendered": "formalisms/MM_render/graphical"}, "models/DTCBD/render_graphical", open("models/DTCBD/transformations/render.alc", 'r').read(), add_trace_CBD)
+
+print(model_render("models/DTCBD_model", "models/DTCBD/render_graphical", "perceptualized/DTCBD_model"))

+ 18 - 0
examples/render_DTCBD_plot.py

@@ -0,0 +1,18 @@
+import sys
+sys.path.append("wrappers")
+from modelverse import *
+
+init()
+login("admin", "admin")
+
+model_add("formalisms/Trace", "formalisms/SimpleClassDiagrams", open("models/Signal/metamodels/trace.mvc", 'r').read())
+model_add("models/trace", "formalisms/Trace", open("models/Signal/models/spring.mvc", 'r').read())
+
+model_add("formalisms/MM_render/plot", "formalisms/SimpleClassDiagrams", open("models/render/metamodels/plot.mvc", 'r').read())
+
+def add_trace_trace(model):
+    instantiate(model, "Association", ("abstract/Signal", "rendered/Dataset"), ID="TracabilityLink")
+
+transformation_add_MT({"abstract": "formalisms/Trace", "rendered": "formalisms/MM_render/plot"}, {"rendered": "formalisms/MM_render/plot"}, "models/trace_mapper", open("models/Signal/transformations/render.mvc", 'r').read(), add_trace_trace)
+
+print(model_render("models/trace", "models/trace_mapper", "perceptualized/Trace_model"))

+ 8 - 3
hybrid_server/classes/mvkcontroller.xml

@@ -298,7 +298,6 @@
                     </state>
                 </state>
 
-                <!--
                 <state id="mvs_GC" initial="suspend_tasks">
                     <state id="suspend_tasks">
                         <onentry>
@@ -311,14 +310,20 @@
                     <state id="mvs_GC">
                         <onentry>
                             <script>
+                                print("Modelverse Garbage Collection")
+                                self.execute_modelverse("", "protect_temporary_variables", [])
                                 self.mvs.purge()
+                                self.execute_modelverse("", "unprotect_temporary_variables", [])
+
+                                # Clean up all used memory now, as this is rather much due to the copy of the MvS
+                                import gc
+                                gc.collect()
                             </script>
                             <raise scope="broad" event="resume_task"/>
                         </onentry>
-                        <transition after="self.sccd_yield() + 10" target="."/>
+                        <transition after="self.sccd_yield() + 100" target="."/>
                     </state>
                 </state>
-                -->
             </parallel>
 
             <state id="remove_sockets">

+ 6 - 2
hybrid_server/classes/task.xml

@@ -50,10 +50,14 @@
                 printed_stack = []
                 for gen in stack:
                     try:
-                        line = getattr(getattr(gen, 'gi_frame', {}), 'f_lineno', None)
+                        line = gen.gi_frame.f_lineno
                     except:
                         line = "?"
-                    printed_stack.append("%s:%s" % (gen.__name__, line))
+                    try:
+                        variables = gen.gi_frame.f_locals
+                    except:
+                        variables = "?"
+                    printed_stack.append("%s:%s {%s}" % (gen.__name__, line, variables))
                 print("Stack @ MvK:\n" + str("\n".join(printed_stack)))
                 print(traceback.format_exc())
                 return (float('inf'), False)

models/CBD_mapper.mvc → integration/code/CBD_mapper.mvc


models/MM_rendered_graphical.mvc → integration/code/MM_rendered_graphical.mvc


models/SCCD.mvc → integration/code/SCCD.mvc


models/SCCD_Trace.mvc → integration/code/SCCD_Trace.mvc


+ 15 - 15
integration/code/SCCD_all.mvc

@@ -110,7 +110,7 @@ transition (manager_main_parallel_input_1, manager_main_parallel_input_2) {
         scope = "broad"
         event = "create"
         parameter = $
-                Element function raise(attributes : Element, parameters : Element):
+                Element function raises(attributes : Element, parameters : Element):
                     return list_create()!
             $
     }
@@ -127,7 +127,7 @@ transition (manager_main_parallel_input_2, manager_main_parallel_input_3) {
         scope = "broad"
         event = "toggle"
         parameter = $
-                Element function raise(attributes : Element, parameters : Element):
+                Element function raises(attributes : Element, parameters : Element):
                     return list_create()!
             $
     }
@@ -144,7 +144,7 @@ transition (manager_main_parallel_input_3, manager_main_parallel_input_4) {
         scope = "broad"
         event = "create"
         parameter = $
-                Element function raise(attributes : Element, parameters : Element):
+                Element function raises(attributes : Element, parameters : Element):
                     return list_create()!
             $
     }
@@ -161,7 +161,7 @@ transition (manager_main_parallel_input_4, manager_main_parallel_input_5) {
         scope = "broad"
         event = "police_interrupt"
         parameter = $
-                Element function raise(attributes : Element, parameters : Element):
+                Element function raises(attributes : Element, parameters : Element):
                     return list_create()!
             $
     }
@@ -178,7 +178,7 @@ transition (manager_main_parallel_input_5, manager_main_parallel_input_6) {
         scope = "broad"
         event = "toggle"
         parameter = $
-                Element function raise(attributes : Element, parameters : Element):
+                Element function raises(attributes : Element, parameters : Element):
                     return list_create()!
             $
     }
@@ -195,7 +195,7 @@ transition (manager_main_parallel_input_6, manager_main_parallel_input_7) {
         scope = "broad"
         event = "toggle"
         parameter = $
-                Element function raise(attributes : Element, parameters : Element):
+                Element function raises(attributes : Element, parameters : Element):
                     return list_create()!
             $
     }
@@ -212,7 +212,7 @@ transition (manager_main_parallel_input_7, manager_main_parallel_input_8) {
         scope = "broad"
         event = "police_interrupt"
         parameter = $
-                Element function raise(attributes : Element, parameters : Element):
+                Element function raises(attributes : Element, parameters : Element):
                     return list_create()!
             $
     }
@@ -229,7 +229,7 @@ transition (manager_main_parallel_input_8, manager_main_parallel_input_9) {
         scope = "broad"
         event = "delete"
         parameter = $
-                Element function raise(attributes : Element, parameters : Element):
+                Element function raises(attributes : Element, parameters : Element):
                     return list_create()!
             $
     }
@@ -246,7 +246,7 @@ transition (manager_main_parallel_input_9, manager_main_parallel_input_10) {
         scope = "broad"
         event = "delete"
         parameter = $
-                Element function raise(attributes : Element, parameters : Element):
+                Element function raises(attributes : Element, parameters : Element):
                     return list_create()!
             $
     }
@@ -263,7 +263,7 @@ transition (manager_main_parallel_input_10, manager_main_parallel_input_11) {
         scope = "broad"
         event = "exit"
         parameter = $
-                Element function raise(attributes : Element, parameters : Element):
+                Element function raises(attributes : Element, parameters : Element):
                     return list_create()!
             $
     }
@@ -277,7 +277,7 @@ transition (manager_main_parallel_core_start, manager_main_parallel_core_start)
         scope = "cd"
         event = "create_instance"
         parameter = $
-                Element function raise(attributes : Element, parameters : Element):
+                Element function raises(attributes : Element, parameters : Element):
                     Element result
                     result = list_create()
                     list_append(result, "trafficlights")
@@ -307,7 +307,7 @@ transition (manager_main_parallel_core_start, manager_main_parallel_core_start)
         scope = "cd"
         event = "delete_instance"
         parameter = $
-                Element function raise(attributes : Element, parameters : Element):
+                Element function raises(attributes : Element, parameters : Element):
                     Element result
                     result = list_create()
                     list_append(result, "0")
@@ -324,7 +324,7 @@ transition (manager_main_parallel_core_start, manager_main_parallel_core_start)
         scope = "cd"
         event = "delete_instance"
         parameter = $
-                Element function raise(attributes : Element, parameters : Element):
+                Element function raises(attributes : Element, parameters : Element):
                     Element result
                     result = list_create()
                     list_append(result, list_pop_final(attributes["trafficlights"]))
@@ -499,7 +499,7 @@ Class trafficlight {
                             event = "updateTimerValue"
                             scope = "output"
                             parameter = $
-                                    Element function raise(attributes : Element):
+                                    Element function raises(attributes : Element):
                                         return attributes["counter"]!
                                 $
                         }
@@ -512,7 +512,7 @@ Class trafficlight {
                         {onEntryRaise} Raise {
                             event = "updateTimerValue"
                             parameter = $
-                                    Element function raise(attributes : Element):
+                                    Element function raises(attributes : Element):
                                         return attributes["counter"]!
                                 $
                         }

+ 1 - 0
models/SCCD_execute.alc

@@ -128,6 +128,7 @@ Element function expand_parallel_state(model : Element, parallel_state : String,
 Void function delete_class(model : Element, data : Element, identifier : String):
 	// Stop a specific class instance, with attached statechart, from executing
 	dict_delete(data["classes"], identifier)
+	return!
 
 String function start_class(model : Element, data : Element, class : String, parameters : Element):
 	// Start up the class and assign its initial state to it

+ 60 - 163
integration/test_powerwindow.py

@@ -19,17 +19,17 @@ class TestPowerWindow(unittest.TestCase):
         kill(self.proc)
 
     def test_process_powerwindow_fast(self):
-        model_add("formalisms/ReachabilityGraph", "formalisms/SimpleClassDiagrams", open("models/reachability_graph.mvc", "r").read())
-        model_add("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("integration/code/pn_design.mvc", 'r').read())
-        model_add("formalisms/Encapsulated_PetriNet", "formalisms/SimpleClassDiagrams", open("models/petrinet_ports.mvc", 'r').read())
-        model_add("formalisms/PW_Plant", "formalisms/SimpleClassDiagrams", open("models/plant_PW.mvc", 'r').read())
-        model_add("formalisms/PW_Environment", "formalisms/SimpleClassDiagrams", open("models/environment_PW.mvc", 'r').read())
-        model_add("formalisms/PW_Control", "formalisms/SimpleClassDiagrams", open("models/control_PW.mvc", 'r').read())
-        model_add("formalisms/Requirements", "formalisms/SimpleClassDiagrams", open("models/requirements.mvc", 'r').read())
-        model_add("formalisms/Query", "formalisms/SimpleClassDiagrams", open("models/query.mvc", 'r').read())
-        model_add("formalisms/Architecture", "formalisms/SimpleClassDiagrams", open("models/architecture.mvc", 'r').read())
-
-        model_add("models/pm_powerwindow", "formalisms/ProcessModel", open("models/pm_req_analyse.mvc", 'r').read())
+        model_add("formalisms/ReachabilityGraph", "formalisms/SimpleClassDiagrams", open("models/ReachabilityGraph/metamodels/reachability_graph.mvc", "r").read())
+        model_add("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("models/PetriNets/metamodels/PetriNets.mvc", 'r').read())
+        model_add("formalisms/Encapsulated_PetriNet", "formalisms/SimpleClassDiagrams", open("models/EncapsulatedPetriNets/metamodels/epn.mvc", 'r').read())
+        model_add("formalisms/PW_Plant", "formalisms/SimpleClassDiagrams", open("models/PowerWindow/metamodels/plant.mvc", 'r').read())
+        model_add("formalisms/PW_Environment", "formalisms/SimpleClassDiagrams", open("models/PowerWindow/metamodels/environment.mvc", 'r').read())
+        model_add("formalisms/PW_Control", "formalisms/SimpleClassDiagrams", open("models/PowerWindow/metamodels/control.mvc", 'r').read())
+        model_add("formalisms/Requirements", "formalisms/SimpleClassDiagrams", open("models/PowerWindow/metamodels/requirements.mvc", 'r').read())
+        model_add("formalisms/Query", "formalisms/SimpleClassDiagrams", open("models/SafetyQuery/metamodels/query.mvc", 'r').read())
+        model_add("formalisms/Architecture", "formalisms/SimpleClassDiagrams", open("models/PowerWindow/metamodels/architecture.mvc", 'r').read())
+
+        model_add("models/pm_powerwindow", "formalisms/ProcessModel", open("models/PowerWindow/PM_analyze.mvc", 'r').read())
 
         transformation_add_MANUAL({"Requirements": "formalisms/Requirements"}, {"Requirements": "formalisms/Requirements"}, "models/revise_req")
         transformation_add_MANUAL({"Requirements": "formalisms/Requirements", "PW_Environment": "formalisms/PW_Environment"}, {"PW_Environment": "formalisms/PW_Environment"}, "models/revise_environment")
@@ -53,16 +53,16 @@ class TestPowerWindow(unittest.TestCase):
             instantiate(model, "Association", ("Encapsulated_PetriNet/Place", "PetriNet/Place"), ID="EPN2PN_transition_link")
             instantiate(model, "Association", ("Encapsulated_PetriNet/Transition", "PetriNet/Transition"), ID="EPN2PN_place_link")
 
-        transformation_add_MT({}, {"PW_Plant": "formalisms/PW_Plant", "PW_Environment": "formalisms/PW_Environment", "PW_Control": "formalisms/PW_Control", "Query": "formalisms/Query", "Architecture": "formalisms/Architecture", "Requirements": "formalisms/Requirements"}, "models/make_initial_models", open("models/initialize.mvc", 'r').read())
-        transformation_add_MT({"PW_Plant": "formalisms/PW_Plant"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/plant_to_EPN", open("models/plant_to_EPN.mvc", 'r').read(), tracability_PLANT2EPN)
-        transformation_add_MT({"PW_Control": "formalisms/PW_Control"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/control_to_EPN", open("models/control_to_EPN.mvc", 'r').read(), tracability_CTRL2EPN)
-        transformation_add_MT({"PW_Environment": "formalisms/PW_Environment"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/environment_to_EPN", open("models/environment_to_EPN.mvc", 'r').read(), tracability_ENV2EPN)
-        transformation_add_MT({"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet", "Architecture": "formalisms/Architecture"}, {"PetriNet": "formalisms/PetriNet"}, "models/combine_EPN", open("models/combine_EPN.mvc", 'r').read(), tracability_EPN2PN)
-        transformation_add_MT({"ReachabilityGraph": "formalisms/ReachabilityGraph", "Query": "formalisms/Query"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/match", open("models/matches.mvc", 'r').read())
+        transformation_add_MT({}, {"PW_Plant": "formalisms/PW_Plant", "PW_Environment": "formalisms/PW_Environment", "PW_Control": "formalisms/PW_Control", "Query": "formalisms/Query", "Architecture": "formalisms/Architecture", "Requirements": "formalisms/Requirements"}, "models/make_initial_models", open("models/PowerWindow/transformations/initialize.mvc", 'r').read())
+        transformation_add_MT({"PW_Plant": "formalisms/PW_Plant"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/plant_to_EPN", open("models/PowerWindow/transformations/plant_to_EPN.mvc", 'r').read(), tracability_PLANT2EPN)
+        transformation_add_MT({"PW_Control": "formalisms/PW_Control"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/control_to_EPN", open("models/PowerWindow/transformations/control_to_EPN.mvc", 'r').read(), tracability_CTRL2EPN)
+        transformation_add_MT({"PW_Environment": "formalisms/PW_Environment"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/environment_to_EPN", open("models/PowerWindow/transformations/environment_to_EPN.mvc", 'r').read(), tracability_ENV2EPN)
+        transformation_add_MT({"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet", "Architecture": "formalisms/Architecture"}, {"PetriNet": "formalisms/PetriNet"}, "models/combine_EPN", open("models/EncapsulatedPetriNets/transformations/combine.mvc", 'r').read(), tracability_EPN2PN)
+        transformation_add_MT({"ReachabilityGraph": "formalisms/ReachabilityGraph", "Query": "formalisms/Query"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/match", open("models/ReachabilityGraph/transformations/match_query.mvc", 'r').read())
 
-        transformation_add_AL({"PetriNet": "formalisms/PetriNet"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/reachability", open("models/reachability.alc", 'r').read())
-        transformation_add_AL({"ReachabilityGraph": "formalisms/ReachabilityGraph"}, {}, "models/bfs", open("models/bfs.alc", 'r').read())
-        transformation_add_AL({"EPN_Plant": "formalisms/Encapsulated_PetriNet", "EPN_Control": "formalisms/Encapsulated_PetriNet", "EPN_Environment": "formalisms/Encapsulated_PetriNet"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/merge_EPN", open("models/merge_EPN.alc", 'r').read())
+        transformation_add_AL({"PetriNet": "formalisms/PetriNet"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/reachability", open("models/PetriNets/transformations/reachability.alc", 'r').read())
+        transformation_add_AL({"ReachabilityGraph": "formalisms/ReachabilityGraph"}, {}, "models/bfs", open("models/ReachabilityGraph/transformations/bfs.alc", 'r').read())
+        transformation_add_AL({"EPN_Plant": "formalisms/Encapsulated_PetriNet", "EPN_Control": "formalisms/Encapsulated_PetriNet", "EPN_Environment": "formalisms/Encapsulated_PetriNet"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/merge_EPN", open("models/EncapsulatedPetriNets/transformations/merge.alc", 'r').read())
 
         nr_of_operations = 6
 
@@ -86,20 +86,20 @@ class TestPowerWindow(unittest.TestCase):
                 model_overwrite(model, open(filename, "r").read())
             return func
 
-        cb_req = get_function("models/requirements_model.mvc")
-        cb_plant = get_function("models/plant_model.mvc")
-        cb_env = get_function("models/environment_model.mvc")
-        cb_ctrl = get_function("models/control_model.mvc")
-        cb_query = get_function("models/query_model.mvc")
-        cb_arch = get_function("models/architecture_model.mvc")
+        cb_req = get_function(  "models/PowerWindow/models/requirements.mvc")
+        cb_plant = get_function("models/PowerWindow/models/plant.mvc")
+        cb_env = get_function(  "models/PowerWindow/models/environment.mvc")
+        cb_ctrl = get_function( "models/PowerWindow/models/control.mvc")
+        cb_query = get_function("models/SafetyQuery/models/powerwindow_safe.mvc")
+        cb_arch = get_function( "models/PowerWindow/models/architecture.mvc")
 
         callbacks = {
-                "models/revise_req": cb_req,
-                "models/revise_plant": cb_plant,
-                "models/revise_environment": cb_env,
-                "models/revise_control": cb_ctrl,
-                "models/revise_query": cb_query,
-                "models/revise_architecture": cb_arch,
+            "models/revise_req": cb_req,
+            "models/revise_plant": cb_plant,
+            "models/revise_environment": cb_env,
+            "models/revise_control": cb_ctrl,
+            "models/revise_query": cb_query,
+            "models/revise_architecture": cb_arch,
             }
 
         try:
@@ -108,6 +108,7 @@ class TestPowerWindow(unittest.TestCase):
             import traceback
             print(traceback.format_exc())
 
+
         called = len(os.listdir(".TEST_POWER_WINDOW/"))
         shutil.rmtree(".TEST_POWER_WINDOW")
         if called != 6:
@@ -116,18 +117,17 @@ class TestPowerWindow(unittest.TestCase):
 
     @slow
     def test_process_powerwindow_debug(self):
-        model_add("formalisms/ReachabilityGraph", "formalisms/SimpleClassDiagrams", open("models/reachability_graph.mvc", "r").read())
-        model_add("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("integration/code/pn_design.mvc", 'r').read())
-        model_add("formalisms/Encapsulated_PetriNet", "formalisms/SimpleClassDiagrams", open("models/petrinet_ports.mvc", 'r').read())
-        model_add("formalisms/PW_Plant", "formalisms/SimpleClassDiagrams", open("models/plant_PW.mvc", 'r').read())
-        model_add("formalisms/PW_Environment", "formalisms/SimpleClassDiagrams", open("models/environment_PW.mvc", 'r').read())
-        model_add("formalisms/PW_Control", "formalisms/SimpleClassDiagrams", open("models/control_PW.mvc", 'r').read())
-        model_add("formalisms/Requirements", "formalisms/SimpleClassDiagrams", open("models/requirements.mvc", 'r').read())
-        model_add("formalisms/Query", "formalisms/SimpleClassDiagrams", open("models/query.mvc", 'r').read())
-        model_add("formalisms/Architecture", "formalisms/SimpleClassDiagrams", open("models/architecture.mvc", 'r').read())
-
-        #model_add("models/pm_powerwindow", "formalisms/ProcessModel", open("models/pm_req_analyse_debug.mvc", 'r').read())
-        model_add("models/pm_powerwindow", "formalisms/ProcessModel", open("models/pm_req_analyse.mvc", 'r').read())
+        model_add("formalisms/ReachabilityGraph", "formalisms/SimpleClassDiagrams", open("models/ReachabilityGraph/metamodels/reachability_graph.mvc", "r").read())
+        model_add("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("models/PetriNets/metamodels/PetriNets.mvc", 'r').read())
+        model_add("formalisms/Encapsulated_PetriNet", "formalisms/SimpleClassDiagrams", open("models/EncapsulatedPetriNets/metamodels/epn.mvc", 'r').read())
+        model_add("formalisms/PW_Plant", "formalisms/SimpleClassDiagrams", open("models/PowerWindow/metamodels/plant.mvc", 'r').read())
+        model_add("formalisms/PW_Environment", "formalisms/SimpleClassDiagrams", open("models/PowerWindow/metamodels/environment.mvc", 'r').read())
+        model_add("formalisms/PW_Control", "formalisms/SimpleClassDiagrams", open("models/PowerWindow/metamodels/control.mvc", 'r').read())
+        model_add("formalisms/Requirements", "formalisms/SimpleClassDiagrams", open("models/PowerWindow/metamodels/requirements.mvc", 'r').read())
+        model_add("formalisms/Query", "formalisms/SimpleClassDiagrams", open("models/SafetyQuery/metamodels/query.mvc", 'r').read())
+        model_add("formalisms/Architecture", "formalisms/SimpleClassDiagrams", open("models/PowerWindow/metamodels/architecture.mvc", 'r').read())
+
+        model_add("models/pm_powerwindow", "formalisms/ProcessModel", open("models/PowerWindow/PM_analyze.mvc", 'r').read())
 
         transformation_add_MANUAL({"Requirements": "formalisms/Requirements"}, {"Requirements": "formalisms/Requirements"}, "models/revise_req")
         transformation_add_MANUAL({"Requirements": "formalisms/Requirements", "PW_Environment": "formalisms/PW_Environment"}, {"PW_Environment": "formalisms/PW_Environment"}, "models/revise_environment")
@@ -151,19 +151,16 @@ class TestPowerWindow(unittest.TestCase):
             instantiate(model, "Association", ("Encapsulated_PetriNet/Place", "PetriNet/Place"), ID="EPN2PN_transition_link")
             instantiate(model, "Association", ("Encapsulated_PetriNet/Transition", "PetriNet/Transition"), ID="EPN2PN_place_link")
 
-        transformation_add_MT({}, {"PW_Plant": "formalisms/PW_Plant", "PW_Environment": "formalisms/PW_Environment", "PW_Control": "formalisms/PW_Control", "Query": "formalisms/Query", "Architecture": "formalisms/Architecture", "Requirements": "formalisms/Requirements"}, "models/make_initial_models", open("models/initialize.mvc", 'r').read())
-        transformation_add_MT({"PW_Plant": "formalisms/PW_Plant"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/plant_to_EPN", open("models/plant_to_EPN.mvc", 'r').read(), tracability_PLANT2EPN)
-        transformation_add_MT({"PW_Control": "formalisms/PW_Control"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/control_to_EPN", open("models/control_to_EPN.mvc", 'r').read(), tracability_CTRL2EPN)
-        transformation_add_MT({"PW_Environment": "formalisms/PW_Environment"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/environment_to_EPN", open("models/environment_to_EPN.mvc", 'r').read(), tracability_ENV2EPN)
-        transformation_add_MT({"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet", "Architecture": "formalisms/Architecture"}, {"PetriNet": "formalisms/PetriNet"}, "models/combine_EPN", open("models/combine_EPN.mvc", 'r').read(), tracability_EPN2PN)
-        transformation_add_MT({"ReachabilityGraph": "formalisms/ReachabilityGraph", "Query": "formalisms/Query"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/match", open("models/matches.mvc", 'r').read())
-
-        transformation_add_AL({"PetriNet": "formalisms/PetriNet"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/reachability", open("models/reachability.alc", 'r').read())
-        transformation_add_AL({"ReachabilityGraph": "formalisms/ReachabilityGraph"}, {}, "models/bfs", open("models/bfs.alc", 'r').read())
-        transformation_add_AL({"EPN_Plant": "formalisms/Encapsulated_PetriNet", "EPN_Control": "formalisms/Encapsulated_PetriNet", "EPN_Environment": "formalisms/Encapsulated_PetriNet"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/merge_EPN", open("models/merge_EPN.alc", 'r').read())
+        transformation_add_MT({}, {"PW_Plant": "formalisms/PW_Plant", "PW_Environment": "formalisms/PW_Environment", "PW_Control": "formalisms/PW_Control", "Query": "formalisms/Query", "Architecture": "formalisms/Architecture", "Requirements": "formalisms/Requirements"}, "models/make_initial_models", open("models/PowerWindow/transformations/initialize.mvc", 'r').read())
+        transformation_add_MT({"PW_Plant": "formalisms/PW_Plant"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/plant_to_EPN", open("models/PowerWindow/transformations/plant_to_EPN.mvc", 'r').read(), tracability_PLANT2EPN)
+        transformation_add_MT({"PW_Control": "formalisms/PW_Control"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/control_to_EPN", open("models/PowerWindow/transformations/control_to_EPN.mvc", 'r').read(), tracability_CTRL2EPN)
+        transformation_add_MT({"PW_Environment": "formalisms/PW_Environment"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/environment_to_EPN", open("models/PowerWindow/transformations/environment_to_EPN.mvc", 'r').read(), tracability_ENV2EPN)
+        transformation_add_MT({"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet", "Architecture": "formalisms/Architecture"}, {"PetriNet": "formalisms/PetriNet"}, "models/combine_EPN", open("models/EncapsulatedPetriNets/transformations/combine.mvc", 'r').read(), tracability_EPN2PN)
+        transformation_add_MT({"ReachabilityGraph": "formalisms/ReachabilityGraph", "Query": "formalisms/Query"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/match", open("models/ReachabilityGraph/transformations/match_query.mvc", 'r').read())
 
-        #transformation_add_AL({"Encapsulated_PetriNet": "Encapsulated_PetriNet"}, {}, "epn_print", open("models/epn_print.alc").read())
-        #transformation_add_AL({"PetriNet": "PetriNet"}, {}, "pn_print", open("models/pn_print.alc").read())
+        transformation_add_AL({"PetriNet": "formalisms/PetriNet"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/reachability", open("models/PetriNets/transformations/reachability.alc", 'r').read())
+        transformation_add_AL({"ReachabilityGraph": "formalisms/ReachabilityGraph"}, {}, "models/bfs", open("models/ReachabilityGraph/transformations/bfs.alc", 'r').read())
+        transformation_add_AL({"EPN_Plant": "formalisms/Encapsulated_PetriNet", "EPN_Control": "formalisms/Encapsulated_PetriNet", "EPN_Environment": "formalisms/Encapsulated_PetriNet"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/merge_EPN", open("models/EncapsulatedPetriNets/transformations/merge.alc", 'r').read())
 
         try:
             shutil.rmtree(".TEST_POWER_WINDOW")
@@ -190,12 +187,13 @@ class TestPowerWindow(unittest.TestCase):
                 open(".TEST_POWER_WINDOW/%s_%s" % (filename.rsplit("/", 1)[-1], uuid.uuid4()), 'w').close()
             return func
 
-        cb_req = get_function("models/requirements_model.mvc")
-        cb_plant = get_function("models/plant_model.mvc")
-        cb_env = get_function("models/environment_model.mvc")
-        cb_ctrl = get_function("models/control_model_wrong.mvc", fixed="models/control_model.mvc")
-        cb_query = get_function("models/query_model.mvc")
-        cb_arch = get_function("models/architecture_model.mvc")
+        cb_req = get_function(  "models/PowerWindow/models/requirements.mvc")
+        cb_plant = get_function("models/PowerWindow/models/plant.mvc")
+        cb_env = get_function(  "models/PowerWindow/models/environment.mvc")
+        cb_ctrl = get_function( "models/PowerWindow/models/control_wrong.mvc", fixed="models/PowerWindow/models/control.mvc")
+        cb_query = get_function("models/SafetyQuery/models/powerwindow_safe.mvc")
+        cb_arch = get_function( "models/PowerWindow/models/architecture.mvc")
+
 
         import log_output
         error_path = []
@@ -226,104 +224,3 @@ class TestPowerWindow(unittest.TestCase):
             raise Exception("Not executed sufficiently:" + str(called))
 
         assert len(error_path) == 10
-
-
-    """
-    @slow
-    def test_process_powerwindow_print(self):
-        model_add("formalisms/ReachabilityGraph", "formalisms/SimpleClassDiagrams", open("models/reachability_graph.mvc", "r").read())
-        model_add("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("integration/code/pn_design.mvc", 'r').read())
-        model_add("formalisms/Encapsulated_PetriNet", "formalisms/SimpleClassDiagrams", open("models/petrinet_ports.mvc", 'r').read())
-        model_add("formalisms/PW_Plant", "formalisms/SimpleClassDiagrams", open("models/plant_PW.mvc", 'r').read())
-        model_add("formalisms/PW_Environment", "formalisms/SimpleClassDiagrams", open("models/environment_PW.mvc", 'r').read())
-        model_add("formalisms/PW_Control", "formalisms/SimpleClassDiagrams", open("models/control_PW.mvc", 'r').read())
-        model_add("formalisms/Requirements", "formalisms/SimpleClassDiagrams", open("models/requirements.mvc", 'r').read())
-        model_add("formalisms/Query", "formalisms/SimpleClassDiagrams", open("models/query.mvc", 'r').read())
-        model_add("formalisms/Architecture", "formalisms/SimpleClassDiagrams", open("models/architecture.mvc", 'r').read())
-
-        model_add("models/pm_powerwindow", "formalisms/ProcessModel", open("models/pm_req_analyse_print.mvc", 'r').read())
-
-        transformation_add_MANUAL({"Requirements": "formalisms/Requirements"}, {"Requirements": "formalisms/Requirements"}, "models/revise_req")
-        transformation_add_MANUAL({"Requirements": "formalisms/Requirements", "PW_Environment": "formalisms/PW_Environment"}, {"PW_Environment": "formalisms/PW_Environment"}, "models/revise_environment")
-        transformation_add_MANUAL({"Requirements": "formalisms/Requirements", "PW_Plant": "formalisms/PW_Plant"}, {"PW_Plant": "formalisms/PW_Plant"}, "models/revise_plant")
-        transformation_add_MANUAL({"Requirements": "formalisms/Requirements", "PW_Control": "formalisms/PW_Control"}, {"PW_Control": "formalisms/PW_Control"}, "models/revise_control")
-        transformation_add_MANUAL({"Requirements": "formalisms/Requirements", "Query": "formalisms/Query"}, {"Query": "formalisms/Query"}, "models/revise_query")
-        transformation_add_MANUAL({"Requirements": "formalisms/Requirements", "Architecture": "formalisms/Architecture"}, {"Architecture": "formalisms/Architecture"}, "models/revise_architecture")
-
-        def tracability_CTRL2EPN(model):
-            instantiate(model, "Association", ("PW_Control/State", "Encapsulated_PetriNet/Place"), ID="CTRL2EPN_link")
-            instantiate(model, "Association", ("PW_Control/Transition", "Encapsulated_PetriNet/Transition"), ID="CTRL2EPN_tlink")
-
-        def tracability_PLANT2EPN(model):
-            instantiate(model, "Association", ("PW_Plant/State", "Encapsulated_PetriNet/Place"), ID="PLANT2EPN_link")
-            instantiate(model, "Association", ("PW_Plant/Transition", "Encapsulated_PetriNet/Transition"), ID="PLANT2EPN_tlink")
-
-        def tracability_ENV2EPN(model):
-            instantiate(model, "Association", ("PW_Environment/Event", "Encapsulated_PetriNet/Place"), ID="ENV2EPN_link")
-
-        def tracability_EPN2PN(model):
-            instantiate(model, "Association", ("Encapsulated_PetriNet/Place", "PetriNet/Place"), ID="EPN2PN_transition_link")
-            instantiate(model, "Association", ("Encapsulated_PetriNet/Transition", "PetriNet/Transition"), ID="EPN2PN_place_link")
-
-        transformation_add_MT({}, {"PW_Plant": "formalisms/PW_Plant", "PW_Environment": "formalisms/PW_Environment", "PW_Control": "formalisms/PW_Control", "Query": "formalisms/Query", "Architecture": "formalisms/Architecture", "Requirements": "formalisms/Requirements"}, "models/make_initial_models", open("models/initialize.mvc", 'r').read())
-        transformation_add_MT({"PW_Plant": "formalisms/PW_Plant"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/plant_to_EPN", open("models/plant_to_EPN.mvc", 'r').read(), tracability_PLANT2EPN)
-        transformation_add_MT({"PW_Control": "formalisms/PW_Control"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/control_to_EPN", open("models/control_to_EPN.mvc", 'r').read(), tracability_CTRL2EPN)
-        transformation_add_MT({"PW_Environment": "formalisms/PW_Environment"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/environment_to_EPN", open("models/environment_to_EPN.mvc", 'r').read(), tracability_ENV2EPN)
-        transformation_add_MT({"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet", "Architecture": "formalisms/Architecture"}, {"PetriNet": "formalisms/PetriNet"}, "models/combine_EPN", open("models/combine_EPN.mvc", 'r').read(), tracability_EPN2PN)
-        transformation_add_MT({"ReachabilityGraph": "formalisms/ReachabilityGraph", "Query": "formalisms/Query"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/match", open("models/matches.mvc", 'r').read())
-        transformation_add_MT({"ReachabilityGraph": "formalisms/ReachabilityGraph"}, {}, "models/reachability_graph_print", open("models/reachabilitygraph_print.mvc", 'r').read())
-
-        transformation_add_AL({"PetriNet": "formalisms/PetriNet"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/reachability", open("models/reachability.alc", 'r').read())
-        transformation_add_AL({"ReachabilityGraph": "formalisms/ReachabilityGraph"}, {}, "models/bfs", open("models/bfs.alc", 'r').read())
-        transformation_add_AL({"EPN_Plant": "formalisms/Encapsulated_PetriNet", "EPN_Control": "formalisms/Encapsulated_PetriNet", "EPN_Environment": "formalisms/Encapsulated_PetriNet"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/merge_EPN", open("models/merge_EPN.alc", 'r').read())
-
-        nr_of_operations = 6
-
-        try:
-            shutil.rmtree(".TEST_POWER_WINDOW")
-        except:
-            pass
-        os.makedirs(".TEST_POWER_WINDOW")
-
-        def get_function(filename):
-            def func(model):
-                import uuid
-                import os
-                called = len(os.listdir(".TEST_POWER_WINDOW/"))
-                if called > nr_of_operations:
-                    raise Exception("Seemingly called some operation twice!")
-                else:
-                    f = open(".TEST_POWER_WINDOW/%s" % str(uuid.uuid4()), 'w')
-                    f.write(filename)
-                    f.close()
-                model_overwrite(model, open(filename, "r").read())
-            return func
-
-        cb_req = get_function("models/requirements_model.mvc")
-        cb_plant = get_function("models/plant_model.mvc")
-        cb_env = get_function("models/environment_model.mvc")
-        cb_ctrl = get_function("models/control_model.mvc")
-        cb_query = get_function("models/query_model.mvc")
-        cb_arch = get_function("models/architecture_model.mvc")
-
-        callbacks = {
-                "models/revise_req": cb_req,
-                "models/revise_plant": cb_plant,
-                "models/revise_environment": cb_env,
-                "models/revise_control": cb_ctrl,
-                "models/revise_query": cb_query,
-                "models/revise_architecture": cb_arch,
-            }
-
-        try:
-            process_execute("models/pm_powerwindow", {}, callbacks)
-        except:
-            import traceback
-            print(traceback.format_exc())
-
-        called = len(os.listdir(".TEST_POWER_WINDOW/"))
-        shutil.rmtree(".TEST_POWER_WINDOW")
-        if called != 6:
-            print(called)
-            raise Exception("Not executed sufficiently:" + str(called))
-    """

+ 16 - 1
interface/simple_plot/main.py

@@ -26,6 +26,7 @@ maps = {}
 if time <= old_time:
     # Overwrites current values, so flush
     d = {}
+    plt.legend()
 else:
     for key in d:
         maps[key], = plt.plot(d[key][0], d[key][1])
@@ -48,7 +49,12 @@ while 1:
         continue
     time, key, value = l.split(" ")
     time = float(time)
-    value = float(value)
+    try:
+        value = float(value)
+    except:
+        # Value is not a number, so we work with discrete states, just ignore!
+        pass
+        value = value.strip()
 
     if key not in maps:
         maps[key], = plt.plot([], [])
@@ -60,6 +66,15 @@ while 1:
 
     d[key][0].append(time)
     d[key][1].append(value)
+
+    if isinstance(value, str) and value not in d[key][1][:-1]:
+        for key in d:
+            prev_color = maps[key].get_color()
+            maps[key].remove()
+            maps[key], = plt.plot(d[key][0], d[key][1], c=prev_color)
+            maps[key].set_label(key)
+        plt.legend()
+
     maps[key].set_xdata(d[key][0])
     maps[key].set_ydata(d[key][1])
     plt.gca().set_xlim([min(d[key][0]), max(d[key][0])])

+ 4 - 0
kernel/modelverse_kernel/compiled.py

@@ -73,6 +73,10 @@ def reverseKeyLookupMulti(a, b, **remainder):
 
 def reverseKeyLookup(a, b, **remainder):
     edges_out, edges_in = yield [("RO", [a['id']]), ("RI", [b['id']])]
+
+    if edges_out is None or edges_in is None:
+        yield [("RETURN", [{'value': ""}])]
+
     options = set(edges_out) & set(edges_in)
     if options:
         # Select one option randomly

+ 50 - 0
kernel/modelverse_kernel/main.py

@@ -37,6 +37,54 @@ class ModelverseKernel(object):
 
         self.debug_info = defaultdict(list)
 
+    def try_to_protect(self, var):
+        if isinstance(var, dict) and "id" in var and var['id'] is not None:
+            return set([var['id']])
+        elif type(var) == int:
+            return set([var])
+        elif isinstance(var, dict):
+            protect = set()
+            for v in var.values():
+                protect |= self.try_to_protect(v)
+            return protect
+        elif isinstance(var, list):
+            protect = set()
+            for v in var:
+                protect |= self.try_to_protect(v)
+            return protect
+        elif isinstance(var, set):
+            protect = set()
+            for v in var:
+                protect |= self.try_to_protect(v)
+            return protect
+        return set()
+
+    def protect_temporary_variables(self, taskname):
+        generators = []
+        for h in self.request_handlers.values():
+            for handler in h.values():
+                for generator in handler.generator_stack:
+                    generators.append(generator)
+
+        to_protect = set()
+        for gen in generators:
+            try:
+                variables = gen.gi_frame.f_locals
+                for var in variables.values():
+                    to_protect |= self.try_to_protect(var)
+            except:
+                pass
+
+        # Create the node to which everything is attached
+        self.fixed_node, = yield [("CN", [])]
+        yield [("CE", [self.root, self.fixed_node])]
+        yield [("CE", [self.fixed_node, node]) for node in to_protect]
+        yield [("RETURN", [None])]
+
+    def unprotect_temporary_variables(self, taskname):
+        yield [("DN", [self.fixed_node])]
+        yield [("RETURN", [None])]
+
     def execute_yields(self, taskname, operation, params, reply):
         self.taskname = taskname
         if taskname not in self.request_handlers:
@@ -308,6 +356,8 @@ class ModelverseKernel(object):
                           "  " * (indent + 2) + "%s['value'], = yield [('RV', [%s['id']])]\n" % (instruction_cond, instruction_cond) + \
                           "  " * (indent + 1) + "if not (%s['value']):\n" % instruction_cond + \
                           "  " * (indent + 2) + "break\n" + \
+                          "  " * (indent + 1) + "else:\n" + \
+                          "  " * (indent + 2) + "yield None\n" + \
                           prev_body + instruction_body
 
         next_inst, = yield [("RD", [inst, "next"])]

models/AL_to_py.alc → models/ActionLanguage/to_python.alc


+ 143 - 0
models/CTCBD/PM_live_modelling.mvc

@@ -0,0 +1,143 @@
+Start start {}
+
+Exec toRuntime_0 {
+    name = "models/CTCBD/toRuntime"
+}
+
+Exec merge_0 {
+    name = "models/DTCBD/merge"
+}
+
+Exec edit {
+    name = "models/CTCBD/edit"
+}
+
+Exec toRuntime {
+    name = "models/CTCBD/toRuntime"
+}
+
+Exec restartSim {
+    name = "models/DTCBD/restartSim"
+}
+
+Exec simulate {
+    name = "models/DTCBD/simulate"
+}
+
+Exec merge {
+    name = "models/DTCBD/merge"
+}
+
+Fork fork1 {}
+Fork fork2 {}
+
+Data traceability_D2P {
+    name = "traceability_D2P"
+    type = "formalisms/Tracability"
+}
+Data traceability_P2F {
+    name = "traceability_P2F"
+    type = "formalisms/Tracability"
+}
+
+Data design_model {
+    name = "design_model"
+    type = "formalisms/CTCBD/Design_MM"
+}
+
+Data partial_runtime_model {
+    name = "partial_runtime_model"
+    type = "formalisms/DTCBD/PartialRuntime_MM"
+}
+
+Data full_runtime_model {
+    name = "full_runtime_model"
+    type = "formalisms/DTCBD/FullRuntime_MM"
+}
+
+Next (start, toRuntime_0) {}
+Next (toRuntime_0, merge_0) {}
+Next (merge_0, fork1) {}
+Next (fork1, edit) {}
+Next (fork1, simulate) {}
+Next (edit, toRuntime) {}
+Next (toRuntime, fork2) {}
+Next (fork2, edit) {}
+Next (fork2, restartSim) {}
+Next (simulate, merge) {}
+Next (merge, simulate) {}
+
+Consumes (edit, design_model) {
+    name = "Design"
+}
+Produces (edit, design_model) {
+    name = "Design"
+}
+
+Consumes (toRuntime, design_model) {
+    name = "Design"
+}
+Consumes (toRuntime, partial_runtime_model) {
+    name = "PartialRuntime"
+}
+Consumes (toRuntime, traceability_D2P) {
+    name = "__traceability"
+}
+Produces (toRuntime, traceability_D2P) {
+    name = "__traceability"
+}
+Produces (toRuntime, partial_runtime_model) {
+    name = "PartialRuntime"
+}
+
+Consumes (toRuntime_0, design_model) {
+    name = "Design"
+}
+Consumes (toRuntime_0, traceability_D2P) {
+    name = "__traceability"
+}
+Produces (toRuntime_0, traceability_D2P) {
+    name = "__traceability"
+}
+Produces (toRuntime_0, partial_runtime_model) {
+    name = "PartialRuntime"
+}
+
+Consumes (merge, partial_runtime_model) {
+    name = "PartialRuntime"
+}
+Consumes (merge, full_runtime_model) {
+    name = "FullRuntime"
+}
+Consumes (merge, traceability_P2F) {
+    name = "__traceability"
+}
+Produces (merge, traceability_P2F) {
+    name = "__traceability"
+}
+Produces (merge, full_runtime_model) {
+    name = "NewFullRuntime"
+}
+
+Consumes (merge_0, partial_runtime_model) {
+    name = "PartialRuntime"
+}
+Consumes (merge_0, full_runtime_model) {
+    name = "FullRuntime"
+}
+Consumes (merge_0, traceability_P2F) {
+    name = "__traceability"
+}
+Produces (merge_0, traceability_P2F) {
+    name = "__traceability"
+}
+Produces (merge_0, full_runtime_model) {
+    name = "NewFullRuntime"
+}
+
+Consumes (simulate, full_runtime_model) {
+    name = "FullRuntime"
+}
+Produces (simulate, full_runtime_model) {
+    name = "FullRuntime"
+}

models/cbd_design.mvc → models/CTCBD/metamodels/CTCBD_MM.mvc


models/cbd_spring.mvc → models/CTCBD/models/spring.mvc


models/CBD_mapper.alc → models/CTCBD/transformations/render.alc


+ 297 - 0
models/CTCBD/transformations/render.mvc

@@ -0,0 +1,297 @@
+include "primitives.alh"
+include "modelling.alh"
+include "object_operations.alh"
+
+Composite schedule {
+    {Contains} Success success {}
+    {Contains} Failure failure {}
+
+    {Contains} ForAll update_blocks {
+        LHS {
+            Pre_abstract/Block pre_update_0 {
+                label = "0"
+            }
+            Pre_rendered/Group pre_update_1 {
+                label = "1"
+            }
+            Pre_TracabilityLink (pre_update_0, pre_update_1){
+                label = "2"
+            }
+        }
+        RHS {
+            Post_abstract/Block post_update_0 {
+                label = "0"
+            }
+            Post_rendered/Group post_update_1 {
+                label = "1"
+                value___asid = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        // Update the mapping!
+                        if (read_nr_out(string_split(mapping["0"], "/")) > 1):
+                            return list_read(string_split(mapping["0"], "/"), 1)!
+                        else:
+                            return mapping["0"]!
+                    $
+                value_x = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return read_attribute(model, name, "x")!
+                    $
+                value_y = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return read_attribute(model, name, "y")!
+                    $
+            }
+            Post_TracabilityLink (post_update_0, post_update_1){
+                label = "2"
+            }
+        }
+    }
+
+    {Contains} ForAll render_blocks {
+        LHS {
+            Pre_abstract/Block pre_block_0 {
+                label = "0"
+            }
+
+            constraint = $
+                Boolean function constraint(model : Element, mapping : Element):
+                    Element trace_links
+                    trace_links = allOutgoingAssociationInstances(model, mapping["0"], "TracabilityLink")
+                    if (read_nr_out(trace_links) > 0):
+                        log("Block already connected; ignoring!")
+                        return False!
+                    else:
+                        return True!
+                $
+        }
+        RHS {
+            Post_abstract/Block post_block_0 {
+                label = "0"
+            }
+            Post_rendered/Group post_block_1 {
+                label = "1"
+                value___asid = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        if (list_len(string_split(mapping["0"], "/")) > 1):
+                            return list_read(string_split(mapping["0"], "/"), 1)!
+                        else:
+                            return mapping["0"]!
+                    $
+                value_x = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 0!
+                    $
+                value_y = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 0!
+                    $
+            }
+            Post_rendered/Rectangle post_block_2 {
+                label = "2"
+                value_x = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 0!
+                    $
+                value_y = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 0!
+                    $
+                value_width = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 30!
+                    $
+                value_height = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 30!
+                    $
+                value_lineWidth = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 2!
+                    $
+                value_lineColour = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "black"!
+                    $
+                value_fillColour = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "white"!
+                    $
+            }
+            Post_rendered/Text post_block_3 {
+                label = "3"
+                value_x = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 10!
+                    $
+                value_y = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 10!
+                    $
+                value_lineWidth = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 1!
+                    $
+                value_lineColour = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "black"!
+                    $
+                value_text = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        String type
+                        type = read_type(model, mapping["0"])
+                        if (type == "abstract/AdditionBlock"):
+                            return "+"!
+                        elif (type == "abstract/NegatorBlock"):
+                            return "-"!
+                        elif (type == "abstract/ConstantBlock"):
+                            return "c"!
+                        elif (type == "abstract/MultiplyBlock"):
+                            return "*"!
+                        elif (type == "abstract/InverseBlock"):
+                            return "/"!
+                        elif (type == "abstract/DerivatorBlock"):
+                            return "d/dx"!
+                        elif (type == "abstract/IntegratorBlock"):
+                            return "1/s"!
+                        elif (type == "abstract/DelayBlock"):
+                            return "DELAY"!
+                        elif (type == "abstract/ProbeBlock"):
+                            return "PROBE"!
+                        else:
+                            return ("Unknown type: " + type)!
+                    $
+            }
+            Post_rendered/contains (post_block_1, post_block_2) {
+                label = "4"
+            }
+            Post_rendered/contains (post_block_1, post_block_3) {
+                label = "5"
+            }
+
+            Post_TracabilityLink (post_block_0, post_block_1) {
+                label = "6"
+            }
+        }
+    }
+
+    {Contains} ForAll remove_connections {
+        LHS {
+            Pre_rendered/Line {
+                label = "0"
+            }
+        }
+        RHS {
+        }
+    }
+
+    {Contains} ForAll render_connections {
+        LHS {
+            Pre_abstract/Block pre_conn_0 {
+                label = "0"
+            }
+
+            Pre_abstract/Block pre_conn_1 {
+                label = "1"
+            }
+
+            Pre_abstract/Link (pre_conn_0, pre_conn_1){
+                label = "2"
+            }
+
+            Pre_rendered/Group pre_conn_3 {
+                label = "3"
+            }
+
+            Pre_rendered/Group pre_conn_4 {
+                label = "4"
+            }
+
+            Pre_TracabilityLink (pre_conn_0, pre_conn_3) {
+                label = "5"
+            }
+            Pre_TracabilityLink (pre_conn_1, pre_conn_4) {
+                label = "6"
+            }
+        }
+        RHS {
+            Post_abstract/Block post_conn_0 {
+                label = "0"
+            }
+
+            Post_abstract/Block post_conn_1 {
+                label = "1"
+            }
+
+            Post_abstract/Link (post_conn_0, post_conn_1){
+                label = "2"
+            }
+
+            Post_rendered/Group post_conn_3 {
+                label = "3"
+            }
+
+            Post_rendered/Group post_conn_4 {
+                label = "4"
+            }
+
+            Post_TracabilityLink (post_conn_0, post_conn_3) {
+                label = "5"
+            }
+            Post_TracabilityLink (post_conn_1, post_conn_4) {
+                label = "6"
+            }
+
+            Post_rendered/Line {
+                label = "7"
+                value___asid = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        if (list_len(string_split(mapping["2"], "/")) > 1):
+                            return list_read(string_split(mapping["2"], "/"), 1)!
+                        else:
+                            return mapping["2"]!
+                    $
+                value_x = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return read_attribute(model, mapping["3"], "x")!
+                    $
+                value_y = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return read_attribute(model, mapping["3"], "y")!
+                    $
+                value_lineWidth = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 1!
+                    $
+                value_lineColour = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        if (read_type(model, name) == "ICLink"):
+                            return "red"!
+                        else:
+                            return "black"!
+                    $
+                value_targetX = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return read_attribute(model, mapping["4"], "x")!
+                    $
+                value_targetY = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return read_attribute(model, mapping["4"], "y")!
+                    $
+            }
+        }
+    }
+}
+
+Initial (schedule, update_blocks) {}
+
+OnSuccess (update_blocks, render_blocks) {}
+OnFailure (update_blocks, render_blocks) {}
+
+OnSuccess (render_blocks, remove_connections) {}
+OnFailure (render_blocks, remove_connections) {}
+
+OnSuccess (remove_connections, render_connections) {}
+OnFailure (remove_connections, render_connections) {}
+
+OnSuccess (render_connections, success) {}
+OnFailure (render_connections, success) {}

+ 469 - 0
models/CTCBD/transformations/to_partial_runtime.mvc

@@ -0,0 +1,469 @@
+include "primitives.alh"
+include "modelling.alh"
+include "object_operations.alh"
+
+Composite schedule {
+    {Contains} Success success {}
+    {Contains} Atomic expand {
+        LHS {
+            Pre_Design/Block expand_lhs_0 {
+                label = "0"
+            }
+            Pre_Design/IntegratorBlock expand_lhs_1 {
+                label = "1"
+            }
+            Pre_Design/Block expand_lhs_2 {
+                label = "2"
+            }
+            Pre_Design/Block expand_lhs_3 {
+                label = "3"
+            }
+            Pre_Design/InitialCondition (expand_lhs_3, expand_lhs_1) {
+                label = "4"
+            }
+            Pre_Design/Link (expand_lhs_0, expand_lhs_1) {
+                label = "5"
+            }
+            Pre_Design/Link (expand_lhs_1, expand_lhs_2) {
+                label = "6"
+            }
+        }
+        RHS {
+            Post_Design/Block expand_rhs_0 {
+                label = "0"
+            }
+            Post_Design/IntegratorBlock expand_rhs_1 {
+                label = "1"
+            }
+            Post_Design/Block expand_rhs_2 {
+                label = "2"
+            }
+            Post_Design/Block expand_rhs_3 {
+                label = "3"
+            }
+            Post_Design/InitialCondition (expand_rhs_3, expand_rhs_1) {
+                label = "4"
+            }
+            Post_Design/Link (expand_rhs_0, expand_rhs_1) {
+                label = "5"
+            }
+            Post_Design/ConstantBlock expand_rhs_7 {
+                label = "7"
+                value_value = $
+                            Float function value(model : Element, name : String, mapping : Element):
+                                return 0.01!
+                        $
+            }
+            Post_Design/MultiplyBlock expand_rhs_8 {
+                label = "8"
+            }
+            Post_Design/AdditionBlock expand_rhs_9 {
+                label = "9"
+            }
+            Post_Design/DelayBlock expand_rhs_10 {
+                label = "10"
+                __id__ = $
+                            String function new_id(model : Element, mapping : Element):
+                                String result
+                                result = cast_string(list_read(string_split(mapping["1"], "/"), 1)) + "_" + cast_string(list_read(string_split(mapping["2"], "/"), 1)) + "_D1"
+                                log("Generate new delayblock with ID " + result)
+                                return result!
+                         $
+            }
+            Post_Design/DelayBlock expand_rhs_11 {
+                label = "11"
+                __id__ = $
+                            String function new_id(model : Element, mapping : Element):
+                                String result
+                                result = cast_string(list_read(string_split(mapping["1"], "/"), 1)) + "_" + cast_string(list_read(string_split(mapping["2"], "/"), 1)) + "_D2"
+                                log("Generate new delayblock with ID " + result)
+                                return result!
+                         $
+            }
+            Post_Design/ConstantBlock expand_rhs_12 {
+                label = "12"
+                value_value = $
+                            Float function value(model : Element, name : String, mapping : Element):
+                                return 0!
+                        $
+            }
+            Post_Design/Link (expand_rhs_0, expand_rhs_10) {
+                label = "13"
+            }
+            Post_Design/Link (expand_rhs_7, expand_rhs_8) {
+                label = "14"
+            }
+            Post_Design/Link (expand_rhs_10, expand_rhs_8) {
+                label = "15"
+            }
+            Post_Design/Link (expand_rhs_8, expand_rhs_9) {
+                label = "16"
+            }
+            Post_Design/Link (expand_rhs_9, expand_rhs_2) {
+                label = "17"
+            }
+            Post_Design/Link (expand_rhs_9, expand_rhs_11) {
+                label = "18"
+            }
+            Post_Design/Link (expand_rhs_11, expand_rhs_9) {
+                label = "19"
+            }
+            Post_Design/InitialCondition (expand_rhs_12, expand_rhs_10) {
+                label = "20"
+            }
+            Post_Design/InitialCondition (expand_rhs_3, expand_rhs_11) {
+                label = "21"
+            }
+        }
+    }
+
+    {Contains} ForAll optimize_inverse {
+        LHS {
+            Pre_Design/ConstantBlock opt_inv_lhs_0 {
+                label = "0"
+            }
+            Pre_Design/InverseBlock opt_inv_lhs_1 {
+                label = "1"
+            }
+            Pre_Design/Block opt_inv_lhs_2 {
+                label = "2"
+            }
+            Pre_Design/Link (opt_inv_lhs_0, opt_inv_lhs_1) {
+                label = "3"
+            }
+            Pre_Design/Link (opt_inv_lhs_1, opt_inv_lhs_2) {
+                label = "4"
+            }
+        }
+        RHS {
+            Post_Design/ConstantBlock opt_inv_rhs_0 {
+                label = "0"
+            }
+            Post_Design/InverseBlock opt_inv_rhs_1 {
+                label = "1"
+            }
+            Post_Design/Block opt_inv_rhs_2 {
+                label = "2"
+            }
+            Post_Design/Link (opt_inv_rhs_0, opt_inv_rhs_1) {
+                label = "3"
+            }
+            Post_Design/ConstantBlock opt_inv_rhs_5 {
+                label = "5"
+                value_value = $
+                            Float function value(model : Element, name : String, mapping : Element):
+                                return float_division(1, read_attribute(model, mapping["0"], "value"))!
+                        $
+            }
+            Post_Design/Link (opt_inv_rhs_5, opt_inv_rhs_2) {
+                label = "6"
+            }
+        }
+    }
+
+    {Contains} ForAll optimize_negator {
+        LHS {
+            Pre_Design/ConstantBlock opt_neg_lhs_0 {
+                label = "0"
+            }
+            Pre_Design/InverseBlock opt_neg_lhs_1 {
+                label = "1"
+            }
+            Pre_Design/Block opt_neg_lhs_2 {
+                label = "2"
+            }
+            Pre_Design/Link (opt_neg_lhs_0, opt_neg_lhs_1) {
+                label = "3"
+            }
+            Pre_Design/Link (opt_neg_lhs_1, opt_neg_lhs_2) {
+                label = "4"
+            }
+        }
+        RHS {
+            Post_Design/ConstantBlock opt_neg_rhs_0 {
+                label = "0"
+            }
+            Post_Design/InverseBlock opt_neg_rhs_1 {
+                label = "1"
+            }
+            Post_Design/Block opt_neg_rhs_2 {
+                label = "2"
+            }
+            Post_Design/Link (opt_neg_rhs_0, opt_neg_rhs_1) {
+                label = "3"
+            }
+            Post_Design/ConstantBlock opt_neg_rhs_5 {
+                label = "5"
+                value_value = $
+                            Float function value(model : Element, name : String, mapping : Element):
+                                return float_subtraction(0, read_attribute(model, mapping["0"], "value"))!
+                        $
+            }
+            Post_Design/Link (opt_neg_rhs_5, opt_neg_rhs_2) {
+                label = "6"
+            }
+        }
+    }
+
+    {Contains} ForAll remove_blocks {
+        LHS {
+            Pre_Design/Block rem_lhs_0 {
+                label = "0"
+                constraint = $
+                                Boolean function constraint(model : Element, name : String):
+                                    if (set_len(allOutgoingAssociationInstances(model, name, "Design/Link")) > 0):
+                                        return False!
+                                    elif (set_len(allOutgoingAssociationInstances(model, name, "Design/InitialCondition")) > 0):
+                                        return False!
+                                    else:
+                                        return read_type(model, name) != "Design/ProbeBlock"!
+                             $
+            }
+        }
+        RHS {}
+    }
+
+    {Contains} ForAll optimize_adder {
+        LHS {
+            Pre_Design/ConstantBlock opt_add_lhs_0 {
+                label = "0"
+            }
+            Pre_Design/ConstantBlock opt_add_lhs_1 {
+                label = "1"
+            }
+            Pre_Design/AdditionBlock opt_add_lhs_2 {
+                label = "2"
+            }
+            Pre_Design/Block opt_add_lhs_3 {
+                label = "3"
+            }
+            Pre_Design/Link (opt_add_lhs_0, opt_add_lhs_2) {
+                label = "4"
+            }
+            Pre_Design/Link (opt_add_lhs_1, opt_add_lhs_2) {
+                label = "5"
+            }
+            Pre_Design/Link (opt_add_lhs_2, opt_add_lhs_3) {
+                label = "6"
+            }
+        }
+        RHS {
+            Post_Design/ConstantBlock opt_add_rhs_0 {
+                label = "0"
+            }
+            Post_Design/ConstantBlock opt_add_rhs_1 {
+                label = "1"
+            }
+            Post_Design/AdditionBlock opt_add_rhs_2 {
+                label = "2"
+            }
+            Post_Design/Block opt_add_rhs_3 {
+                label = "3"
+            }
+            Post_Design/Link (opt_add_rhs_0, opt_add_rhs_2) {
+                label = "4"
+            }
+            Post_Design/Link (opt_add_rhs_1, opt_add_rhs_2) {
+                label = "5"
+            }
+            Post_Design/ConstantBlock opt_add_rhs_7 {
+                label = "7"
+                value_value = $
+                            Float function value(model : Element, name : String, mapping : Element):
+                                return float_addition(read_attribute(model, mapping["0"], "value"),  read_attribute(model, mapping["1"], "value"))!
+                        $
+            }
+            Post_Design/Link (opt_add_rhs_7, opt_add_rhs_3) {
+                label = "8"
+            }
+        }
+    }
+
+    {Contains} ForAll optimize_multiplier {
+        LHS {
+            Pre_Design/ConstantBlock opt_mult_lhs_0 {
+                label = "0"
+            }
+            Pre_Design/ConstantBlock opt_mult_lhs_1 {
+                label = "1"
+            }
+            Pre_Design/MultiplyBlock opt_mult_lhs_2 {
+                label = "2"
+            }
+            Pre_Design/Block opt_mult_lhs_3 {
+                label = "3"
+            }
+            Pre_Design/Link (opt_mult_lhs_0, opt_mult_lhs_2) {
+                label = "4"
+            }
+            Pre_Design/Link (opt_mult_lhs_1, opt_mult_lhs_2) {
+                label = "5"
+            }
+            Pre_Design/Link (opt_mult_lhs_2, opt_mult_lhs_3) {
+                label = "6"
+            }
+        }
+        RHS {
+            Post_Design/ConstantBlock opt_mult_rhs_0 {
+                label = "0"
+            }
+            Post_Design/ConstantBlock opt_mult_rhs_1 {
+                label = "1"
+            }
+            Post_Design/MultiplyBlock opt_mult_rhs_2 {
+                label = "2"
+            }
+            Post_Design/Block opt_mult_rhs_3 {
+                label = "3"
+            }
+            Post_Design/Link (opt_mult_rhs_0, opt_mult_rhs_2) {
+                label = "4"
+            }
+            Post_Design/Link (opt_mult_rhs_1, opt_mult_rhs_2) {
+                label = "5"
+            }
+            Post_Design/ConstantBlock opt_mult_rhs_7 {
+                label = "7"
+                value_value = $
+                            Float function value(model : Element, name : String, mapping : Element):
+                                return float_multiplication(read_attribute(model, mapping["0"], "value"), read_attribute(model, mapping["1"], "value"))!
+                        $
+            }
+            Post_Design/Link (opt_mult_rhs_7, opt_mult_rhs_3) {
+                label = "8"
+            }
+        }
+    }
+
+    {Contains} ForAll optimize_constant {
+        LHS {
+            Pre_Design/ConstantBlock opt_const_lhs_0 {
+                label = "0"
+            }
+            Pre_Design/Block opt_const_lhs_1 {
+                label = "1"
+            }
+            Pre_Design/ConstantBlock opt_const_lhs_2 {
+                label = "2"
+            }
+            Pre_Design/Block opt_const_lhs_3 {
+                label = "3"
+            }
+            Pre_Design/Link (opt_const_lhs_0, opt_const_lhs_1) {
+                label = "4"
+            }
+            Pre_Design/Link (opt_const_lhs_2, opt_const_lhs_3) {
+                label = "5"
+            }
+
+            constraint = $
+                            Boolean function constraint(model : Element, mapping : Element):
+                                return (cast_integer(cast_id(mapping["0"])) < cast_integer(cast_id(mapping["2"])))!
+                         $
+        }
+        RHS {
+            Post_Design/ConstantBlock opt_const_rhs_0 {
+                label = "0"
+            }
+            Post_Design/Block opt_const_rhs_1 {
+                label = "1"
+            }
+            Post_Design/ConstantBlock opt_const_rhs_2 {
+                label = "2"
+            }
+            Post_Design/Block opt_const_rhs_3 {
+                label = "3"
+            }
+            Post_Design/Link (opt_const_rhs_0, opt_const_rhs_1) {
+                label = "4"
+            }
+            Post_Design/Link (opt_const_rhs_0, opt_const_rhs_3) {
+                label = "6"
+            }
+        }
+    }
+
+    {Contains} Atomic map_to_partial {
+        LHS {}
+        RHS {
+            action = $
+                        Void function action(model : Element, mapping : Element):
+                            Element all_blocks
+                            String element_name
+                            String new_element_name
+                            String mm_type_name
+                            Element all_links
+
+                            all_blocks = allInstances(model, "Design/Block")
+                            while (set_len(all_blocks) > 0):
+                                element_name = set_pop(all_blocks)
+                                mm_type_name = "PartialRuntime/" + cast_string(list_read(string_split(read_type(model, element_name), "/"), 1))
+
+                                if (set_len(allOutgoingAssociationInstances(model, element_name, "D2P_block")) == 0):
+                                    // New design element, so create in partial runtime model as well
+                                    String new_name
+                                    if (mm_type_name == "PartialRuntime/DelayBlock"):
+                                        new_name = "PartialRuntime/" + string_replace(element_name, "/", "_")
+                                    else:
+                                        new_name = ""
+                                    new_element_name = instantiate_node(model, mm_type_name, new_name)
+                                    instantiate_link(model, "D2P_block", "", element_name, new_element_name)
+
+                                // Always update the value of attributes of PartialRuntime
+                                new_element_name = map_D2P(model, element_name)
+                                if (mm_type_name == "PartialRuntime/ConstantBlock"):
+                                    instantiate_attribute(model, new_element_name, "value", read_attribute(model, element_name, "value"))
+                                elif (mm_type_name == "PartialRuntime/ProbeBlock"):
+                                    instantiate_attribute(model, new_element_name, "name", read_attribute(model, element_name, "name"))
+
+                            all_blocks = allInstances(model, "PartialRuntime/Block")
+                            while (set_len(all_blocks) > 0):
+                                element_name = set_pop(all_blocks)
+                                if (set_len(allIncomingAssociationInstances(model, element_name, "D2P_block")) == 0):
+                                    // Old partial runtime element, so remove
+                                    model_delete_element(model, element_name)
+
+                            // Delete all existing links
+                            all_links = allInstances(model, "PartialRuntime/Link")
+                            while (set_len(all_links) > 0):
+                                model_delete_element(model, set_pop(all_links))
+
+                            all_links = allInstances(model, "PartialRuntime/InitialCondition")
+                            while (set_len(all_links) > 0):
+                                model_delete_element(model, set_pop(all_links))
+
+                            // Recreate all of them
+                            all_links = allInstances(model, "Design/Link")
+                            while (set_len(all_links) > 0):
+                                element_name = set_pop(all_links)
+                                instantiate_link(model, "PartialRuntime/Link", "", map_D2P(model, readAssociationSource(model, element_name)), map_D2P(model, readAssociationDestination(model, element_name)))
+
+                            all_links = allInstances(model, "Design/InitialCondition")
+                            while (set_len(all_links) > 0):
+                                element_name = set_pop(all_links)
+                                instantiate_link(model, "PartialRuntime/InitialCondition", "", map_D2P(model, readAssociationSource(model, element_name)), map_D2P(model, readAssociationDestination(model, element_name)))
+
+                            return!
+
+                        String function map_D2P(model : Element, name : String):
+                            Element destinations
+                            String pick
+
+                            destinations = allAssociationDestinations(model, name, "D2P_block")
+
+                            pick = name
+                            while (pick == name):
+                                pick = set_pop(destinations)
+
+                            return pick!
+                     $
+        }
+    }
+}
+
+Initial (schedule, expand) {}
+
+OnSuccess (expand, expand) {}
+OnFailure (expand, remove_blocks) {}
+OnSuccess (remove_blocks, map_to_partial) {}
+OnSuccess (map_to_partial, success) {}

models/WSC/DEVS.mvc → models/ClassicDEVS/metamodels/DEVS.mvc


models/WSC/pm_library.mvc → models/ClassicDEVS/models/process_patterns_library.mvc


models/WSC/DEVS_merge.alc → models/ClassicDEVS/transformations/merge.alc


models/WSC/DEVS_simulate.alc → models/ClassicDEVS/transformations/simulate.alc


+ 143 - 0
models/DTCBD/PM_live_modelling.mvc

@@ -0,0 +1,143 @@
+Start start {}
+
+Exec toRuntime_0 {
+    name = "models/DTCBD/toRuntime"
+}
+
+Exec merge_0 {
+    name = "models/DTCBD/merge"
+}
+
+Exec edit {
+    name = "models/DTCBD/edit"
+}
+
+Exec toRuntime {
+    name = "models/DTCBD/toRuntime"
+}
+
+Exec restartSim {
+    name = "models/DTCBD/restartSim"
+}
+
+Exec simulate {
+    name = "models/DTCBD/simulate"
+}
+
+Exec merge {
+    name = "models/DTCBD/merge"
+}
+
+Fork fork1 {}
+Fork fork2 {}
+
+Data traceability_D2P {
+    name = "traceability_D2P"
+    type = "formalisms/Tracability"
+}
+Data traceability_P2F {
+    name = "traceability_P2F"
+    type = "formalisms/Tracability"
+}
+
+Data design_model {
+    name = "design_model"
+    type = "formalisms/DTCBD/Design_MM"
+}
+
+Data partial_runtime_model {
+    name = "partial_runtime_model"
+    type = "formalisms/DTCBD/PartialRuntime_MM"
+}
+
+Data full_runtime_model {
+    name = "full_runtime_model"
+    type = "formalisms/DTCBD/FullRuntime_MM"
+}
+
+Next (start, toRuntime_0) {}
+Next (toRuntime_0, merge_0) {}
+Next (merge_0, fork1) {}
+Next (fork1, edit) {}
+Next (fork1, simulate) {}
+Next (edit, toRuntime) {}
+Next (toRuntime, fork2) {}
+Next (fork2, edit) {}
+Next (fork2, restartSim) {}
+Next (simulate, merge) {}
+Next (merge, simulate) {}
+
+Consumes (edit, design_model) {
+    name = "Design"
+}
+Produces (edit, design_model) {
+    name = "Design"
+}
+
+Consumes (toRuntime, design_model) {
+    name = "Design"
+}
+Consumes (toRuntime, partial_runtime_model) {
+    name = "PartialRuntime"
+}
+Consumes (toRuntime, traceability_D2P) {
+    name = "__traceability"
+}
+Produces (toRuntime, traceability_D2P) {
+    name = "__traceability"
+}
+Produces (toRuntime, partial_runtime_model) {
+    name = "PartialRuntime"
+}
+
+Consumes (toRuntime_0, design_model) {
+    name = "Design"
+}
+Consumes (toRuntime_0, traceability_D2P) {
+    name = "__traceability"
+}
+Produces (toRuntime_0, traceability_D2P) {
+    name = "__traceability"
+}
+Produces (toRuntime_0, partial_runtime_model) {
+    name = "PartialRuntime"
+}
+
+Consumes (merge, partial_runtime_model) {
+    name = "PartialRuntime"
+}
+Consumes (merge, full_runtime_model) {
+    name = "FullRuntime"
+}
+Consumes (merge, traceability_P2F) {
+    name = "__traceability"
+}
+Produces (merge, traceability_P2F) {
+    name = "__traceability"
+}
+Produces (merge, full_runtime_model) {
+    name = "NewFullRuntime"
+}
+
+Consumes (merge_0, partial_runtime_model) {
+    name = "PartialRuntime"
+}
+Consumes (merge_0, full_runtime_model) {
+    name = "FullRuntime"
+}
+Consumes (merge_0, traceability_P2F) {
+    name = "__traceability"
+}
+Produces (merge_0, traceability_P2F) {
+    name = "__traceability"
+}
+Produces (merge_0, full_runtime_model) {
+    name = "NewFullRuntime"
+}
+
+Consumes (simulate, full_runtime_model) {
+    name = "FullRuntime"
+}
+Produces (simulate, full_runtime_model) {
+    name = "FullRuntime"
+}

+ 12 - 2
models/cbd_alg_design.mvc

@@ -1,9 +1,10 @@
 include "primitives.alh"
 
-Class Float {}
-Class String {}
+SimpleAttribute Float {}
+SimpleAttribute String {}
 
 Class Block{}
+Class ICBlock{}
 
 Class ConstantBlock{
     name = "Constant"
@@ -25,6 +26,9 @@ Class MultiplyBlock{
 Class InverseBlock{
     name = "Inverse"
 }
+Class DelayBlock{
+    name = "Delay"
+}
 Class ProbeBlock{
     name = "Probe"
     name : String {
@@ -34,6 +38,10 @@ Class ProbeBlock{
 }
 
 Association Link(Block, Block){}
+Association InitialCondition(Block, ICBlock){
+    source_lower_cardinality = 1
+    source_upper_cardinality = 1
+}
 
 Inheritance (ConstantBlock, Block){}
 Inheritance (AdditionBlock, Block){}
@@ -41,3 +49,5 @@ Inheritance (NegatorBlock, Block){}
 Inheritance (MultiplyBlock, Block){}
 Inheritance (InverseBlock, Block){}
 Inheritance (ProbeBlock, Block){}
+Inheritance (ICBlock, Block){}
+Inheritance (DelayBlock, ICBlock){}

models/cbd_partial_runtime.mvc → models/DTCBD/metamodels/DTCBD_MM_partial_runtime.mvc


models/cbd_runtime.mvc → models/DTCBD/metamodels/DTCBD_MM_runtime.mvc


+ 20 - 0
models/DTCBD/models/simple_equation.mvc

@@ -0,0 +1,20 @@
+ConstantBlock cte_x {
+    value = 1
+}
+DelayBlock delay {}
+AdditionBlock adder {}
+NegatorBlock neg {}
+ProbeBlock y {
+    name = "y"
+}
+ProbeBlock z {
+    name = "z"
+}
+
+InitialCondition (cte_x, delay){}
+Link (cte_x, adder) {}
+Link (adder, delay) {}
+Link (adder, y) {}
+Link (adder, neg) {}
+Link (delay, z) {}
+Link (neg, adder) {}

+ 3 - 3
models/cbd_merge.alc

@@ -24,6 +24,7 @@ Boolean function main(model : Element):
 	Float current_time
 	String time_block
 
+	log("Merging!")
 	all_blocks = allInstances(model, "PartialRuntime/Block")
 	while (set_len(all_blocks) > 0):
 		element_name = set_pop(all_blocks)
@@ -31,9 +32,7 @@ Boolean function main(model : Element):
 			// Element already exists in full, so copy existing attributes
             if (is_nominal_instance(model, element_name, "PartialRuntime/ICBlock")):
                 instantiate_attribute(model, element_name, "last_in", read_attribute(model, map_P2F(model, element_name), "last_in"))
-            if (is_nominal_instance(model, element_name, "PartialRuntime/IntegratorBlock")):
-                instantiate_attribute(model, element_name, "last_out", read_attribute(model, map_P2F(model, element_name), "last_out"))
-            instantiate_attribute(model, element_name, "signal", read_attribute(model, map_P2F(model, element_name), "signal"))
+            // instantiate_attribute(model, element_name, "signal", read_attribute(model, map_P2F(model, element_name), "signal"))
 		else:
 			// Element doesn't exist, so initialize with 0.0
             instantiate_attribute(model, element_name, "signal", 0.0)
@@ -58,4 +57,5 @@ Boolean function main(model : Element):
 		if (string_startswith(read_type(model, elem), "PartialRuntime/")):
 			retype(model, elem, "NewFullRuntime/" + cast_string(list_read(string_split_nr(read_type(model, elem), "/", 1), 1)))
 
+	log("Merge OK")
 	return True!

+ 180 - 0
models/DTCBD/transformations/render.alc

@@ -0,0 +1,180 @@
+include "primitives.alh"
+include "modelling.alh"
+include "object_operations.alh"
+include "utils.alh"
+
+Boolean function main(model : Element):
+	Element elements
+	String class
+	Element attrs
+	Element attr_keys
+	String attr_key
+	String group
+	String elem
+	Integer loc
+	Integer text_loc
+	Element related_groups
+	loc = 10
+
+	Element groups
+	groups = dict_create()
+
+	elements = allInstances(model, "rendered/Group")
+	while (set_len(elements) > 0):
+		group = set_pop(elements)
+		if (set_len(allIncomingAssociationInstances(model, group, "TracabilityClass")) == 0):
+			Element to_remove
+			String elem_to_remove
+			to_remove = allAssociationDestinations(model, group, "rendered/contains")
+			while (set_len(to_remove) > 0):
+				elem_to_remove = set_pop(to_remove)
+				if (read_type(model, elem_to_remove) == "rendered/Group"):
+					set_add(to_remove, elem_to_remove)
+				else:
+					model_delete_element(model, elem_to_remove)
+			model_delete_element(model, group)
+
+	elements = allInstances(model, "abstract/Block")
+	while (set_len(elements) > 0):
+		class = set_pop(elements)
+		
+		Integer x
+		Integer y
+		x = loc
+		y = 10
+
+		// Check if there is already an associated element
+		if (set_len(allOutgoingAssociationInstances(model, class, "TracabilityClass")) > 0):
+			// Yes, but is it still clean?
+			Boolean dirty
+			dirty = False
+
+			related_groups = allAssociationDestinations(model, class, "TracabilityClass")
+			while (set_len(related_groups) > 0):
+				group = set_pop(related_groups)
+				if (value_eq(read_attribute(model, group, "dirty"), True)):
+					// No, so mark all as dirty
+					dirty = True
+					break!
+				else:
+					// Yes, so just ignore this!
+					continue!
+
+			if (bool_not(dirty)):
+				dict_add(groups, class, group)
+				continue!
+			else:
+				related_groups = allAssociationDestinations(model, class, "TracabilityClass")
+				Element to_remove
+				String elem_to_remove
+				while (set_len(related_groups) > 0):
+					group = set_pop(related_groups)
+					to_remove = allAssociationDestinations(model, group, "rendered/contains")
+					x = create_value(read_attribute(model, group, "x"))
+					y = create_value(read_attribute(model, group, "y"))
+					while (set_len(to_remove) > 0):
+						elem_to_remove = set_pop(to_remove)
+						if (read_type(model, elem_to_remove) == "rendered/Group"):
+							set_add(to_remove, elem_to_remove)
+						else:
+							model_delete_element(model, elem_to_remove)
+					model_delete_element(model, group)
+
+		attr_keys = dict_keys(getAttributeList(model, class))
+		text_loc = 5
+
+		group = instantiate_node(model, "rendered/Group", "")
+		instantiate_attribute(model, group, "x", x)
+		instantiate_attribute(model, group, "y", y)
+		instantiate_attribute(model, group, "__asid", list_read(string_split_nr(class, "/", 1), 1))
+		instantiate_attribute(model, group, "layer", 0)
+		dict_add(groups, class, group)
+		loc = loc + 100
+
+		elem = instantiate_node(model, "rendered/Rectangle", "")
+		instantiate_attribute(model, elem, "x", 0)
+		instantiate_attribute(model, elem, "y", 0)
+		instantiate_attribute(model, elem, "height", 50)
+		instantiate_attribute(model, elem, "width", 50)
+		instantiate_attribute(model, elem, "lineWidth", 4) 
+		instantiate_attribute(model, elem, "lineColour", "black")
+		instantiate_attribute(model, elem, "fillColour", "white")
+		instantiate_attribute(model, elem, "layer", 1)
+		instantiate_link(model, "rendered/contains", "", group, elem)
+
+		elem = instantiate_node(model, "rendered/Text", "")
+		instantiate_attribute(model, elem, "x", 20)
+		instantiate_attribute(model, elem, "y", 20)
+		instantiate_attribute(model, elem, "lineWidth", 1)
+		instantiate_attribute(model, elem, "lineColour", "black")
+		
+		String type
+		type = read_type(model, class)
+		if (type == "abstract/ConstantBlock"):
+			if (element_neq(read_attribute(model, class, "value"), read_root())):
+				instantiate_attribute(model, elem, "text", cast_string(read_attribute(model, class, "value")))
+			else:
+				instantiate_attribute(model, elem, "text", "?")
+		elif (type == "abstract/AdditionBlock"):
+			instantiate_attribute(model, elem, "text", "+")
+		elif (type == "abstract/NegatorBlock"):
+			instantiate_attribute(model, elem, "text", "-")
+		elif (type == "abstract/MultiplyBlock"):
+			instantiate_attribute(model, elem, "text", "X")
+		elif (type == "abstract/InverseBlock"):
+			instantiate_attribute(model, elem, "text", "1/x")
+		elif (type == "abstract/DelayBlock"):
+			instantiate_attribute(model, elem, "text", "DELAY")
+		elif (type == "abstract/IntegratorBlock"):
+			instantiate_attribute(model, elem, "text", "1/s")
+		elif (type == "abstract/DerivatorBlock"):
+			instantiate_attribute(model, elem, "text", "dx")
+		elif (type == "abstract/ProbeBlock"):
+			instantiate_attribute(model, elem, "text", "PROBE")
+
+		instantiate_attribute(model, elem, "layer", 2)
+		instantiate_link(model, "rendered/contains", "", group, elem)
+
+		instantiate_link(model, "TracabilityClass", "", class, group)
+
+	// Flush all associations
+	elements = allInstances(model, "rendered/ConnectingLine")
+	while (set_len(elements) > 0):
+		class = set_pop(elements)
+		model_delete_element(model, class)
+
+	// Rerender associations
+	elements = allInstances(model, "abstract/Link")
+	while (set_len(elements) > 0):
+		class = set_pop(elements)
+
+		elem = instantiate_link(model, "rendered/ConnectingLine", "", groups[readAssociationSource(model, class)], groups[readAssociationDestination(model, class)])
+		instantiate_attribute(model, elem, "offsetSourceX", 25)
+		instantiate_attribute(model, elem, "offsetSourceY", 25)
+		instantiate_attribute(model, elem, "offsetTargetX", 25)
+		instantiate_attribute(model, elem, "offsetTargetY", 25)
+		instantiate_attribute(model, elem, "lineWidth", 1)
+		instantiate_attribute(model, elem, "lineColour", "black")
+		instantiate_attribute(model, elem, "arrow", True)
+		instantiate_attribute(model, elem, "__asid", list_read(string_split_nr(class, "/", 1), 1))
+		instantiate_attribute(model, elem, "layer", 0)
+		instantiate_link(model, "rendered/contains", "", group, elem)
+
+	// Rerender initial conditions
+	elements = allInstances(model, "abstract/InitialCondition")
+	while (set_len(elements) > 0):
+		class = set_pop(elements)
+
+		elem = instantiate_link(model, "rendered/ConnectingLine", "", groups[readAssociationSource(model, class)], groups[readAssociationDestination(model, class)])
+		instantiate_attribute(model, elem, "offsetSourceX", 25)
+		instantiate_attribute(model, elem, "offsetSourceY", 25)
+		instantiate_attribute(model, elem, "offsetTargetX", 25)
+		instantiate_attribute(model, elem, "offsetTargetY", 25)
+		instantiate_attribute(model, elem, "lineWidth", 1)
+		instantiate_attribute(model, elem, "lineColour", "red")
+		instantiate_attribute(model, elem, "arrow", True)
+		instantiate_attribute(model, elem, "__asid", list_read(string_split_nr(class, "/", 1), 1))
+		instantiate_attribute(model, elem, "layer", 0)
+		instantiate_link(model, "rendered/contains", "", group, elem)
+
+	return True!

+ 297 - 0
models/DTCBD/transformations/render.mvc

@@ -0,0 +1,297 @@
+include "primitives.alh"
+include "modelling.alh"
+include "object_operations.alh"
+
+Composite schedule {
+    {Contains} Success success {}
+    {Contains} Failure failure {}
+
+    {Contains} ForAll update_blocks {
+        LHS {
+            Pre_abstract/Block pre_update_0 {
+                label = "0"
+            }
+            Pre_rendered/Group pre_update_1 {
+                label = "1"
+            }
+            Pre_TracabilityLink (pre_update_0, pre_update_1){
+                label = "2"
+            }
+        }
+        RHS {
+            Post_abstract/Block post_update_0 {
+                label = "0"
+            }
+            Post_rendered/Group post_update_1 {
+                label = "1"
+                value___asid = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        // Update the mapping!
+                        if (read_nr_out(string_split(mapping["0"], "/")) > 1):
+                            return list_read(string_split(mapping["0"], "/"), 1)!
+                        else:
+                            return mapping["0"]!
+                    $
+                value_x = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return read_attribute(model, name, "x")!
+                    $
+                value_y = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return read_attribute(model, name, "y")!
+                    $
+            }
+            Post_TracabilityLink (post_update_0, post_update_1){
+                label = "2"
+            }
+        }
+    }
+
+    {Contains} ForAll render_blocks {
+        LHS {
+            Pre_abstract/Block pre_block_0 {
+                label = "0"
+            }
+
+            constraint = $
+                Boolean function constraint(model : Element, mapping : Element):
+                    Element trace_links
+                    trace_links = allOutgoingAssociationInstances(model, mapping["0"], "TracabilityLink")
+                    if (read_nr_out(trace_links) > 0):
+                        log("Block already connected; ignoring!")
+                        return False!
+                    else:
+                        return True!
+                $
+        }
+        RHS {
+            Post_abstract/Block post_block_0 {
+                label = "0"
+            }
+            Post_rendered/Group post_block_1 {
+                label = "1"
+                value___asid = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        if (list_len(string_split(mapping["0"], "/")) > 1):
+                            return list_read(string_split(mapping["0"], "/"), 1)!
+                        else:
+                            return mapping["0"]!
+                    $
+                value_x = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 0!
+                    $
+                value_y = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 0!
+                    $
+            }
+            Post_rendered/Rectangle post_block_2 {
+                label = "2"
+                value_x = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 0!
+                    $
+                value_y = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 0!
+                    $
+                value_width = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 30!
+                    $
+                value_height = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 30!
+                    $
+                value_lineWidth = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 2!
+                    $
+                value_lineColour = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "black"!
+                    $
+                value_fillColour = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "white"!
+                    $
+            }
+            Post_rendered/Text post_block_3 {
+                label = "3"
+                value_x = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 10!
+                    $
+                value_y = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 10!
+                    $
+                value_lineWidth = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 1!
+                    $
+                value_lineColour = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "black"!
+                    $
+                value_text = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        String type
+                        type = read_type(model, mapping["0"])
+                        if (type == "abstract/AdditionBlock"):
+                            return "+"!
+                        elif (type == "abstract/NegatorBlock"):
+                            return "-"!
+                        elif (type == "abstract/ConstantBlock"):
+                            return "c"!
+                        elif (type == "abstract/MultiplyBlock"):
+                            return "*"!
+                        elif (type == "abstract/InverseBlock"):
+                            return "/"!
+                        elif (type == "abstract/DerivatorBlock"):
+                            return "d/dx"!
+                        elif (type == "abstract/IntegratorBlock"):
+                            return "1/s"!
+                        elif (type == "abstract/DelayBlock"):
+                            return "DELAY"!
+                        elif (type == "abstract/ProbeBlock"):
+                            return "PROBE"!
+                        else:
+                            return ("Unknown type: " + type)!
+                    $
+            }
+            Post_rendered/contains (post_block_1, post_block_2) {
+                label = "4"
+            }
+            Post_rendered/contains (post_block_1, post_block_3) {
+                label = "5"
+            }
+
+            Post_TracabilityLink (post_block_0, post_block_1) {
+                label = "6"
+            }
+        }
+    }
+
+    {Contains} ForAll remove_connections {
+        LHS {
+            Pre_rendered/Line {
+                label = "0"
+            }
+        }
+        RHS {
+        }
+    }
+
+    {Contains} ForAll render_connections {
+        LHS {
+            Pre_abstract/Block pre_conn_0 {
+                label = "0"
+            }
+
+            Pre_abstract/Block pre_conn_1 {
+                label = "1"
+            }
+
+            Pre_abstract/Link (pre_conn_0, pre_conn_1){
+                label = "2"
+            }
+
+            Pre_rendered/Group pre_conn_3 {
+                label = "3"
+            }
+
+            Pre_rendered/Group pre_conn_4 {
+                label = "4"
+            }
+
+            Pre_TracabilityLink (pre_conn_0, pre_conn_3) {
+                label = "5"
+            }
+            Pre_TracabilityLink (pre_conn_1, pre_conn_4) {
+                label = "6"
+            }
+        }
+        RHS {
+            Post_abstract/Block post_conn_0 {
+                label = "0"
+            }
+
+            Post_abstract/Block post_conn_1 {
+                label = "1"
+            }
+
+            Post_abstract/Link (post_conn_0, post_conn_1){
+                label = "2"
+            }
+
+            Post_rendered/Group post_conn_3 {
+                label = "3"
+            }
+
+            Post_rendered/Group post_conn_4 {
+                label = "4"
+            }
+
+            Post_TracabilityLink (post_conn_0, post_conn_3) {
+                label = "5"
+            }
+            Post_TracabilityLink (post_conn_1, post_conn_4) {
+                label = "6"
+            }
+
+            Post_rendered/Line {
+                label = "7"
+                value___asid = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        if (list_len(string_split(mapping["2"], "/")) > 1):
+                            return list_read(string_split(mapping["2"], "/"), 1)!
+                        else:
+                            return mapping["2"]!
+                    $
+                value_x = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return read_attribute(model, mapping["3"], "x")!
+                    $
+                value_y = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return read_attribute(model, mapping["3"], "y")!
+                    $
+                value_lineWidth = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return 1!
+                    $
+                value_lineColour = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        if (read_type(model, name) == "ICLink"):
+                            return "red"!
+                        else:
+                            return "black"!
+                    $
+                value_targetX = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return read_attribute(model, mapping["4"], "x")!
+                    $
+                value_targetY = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return read_attribute(model, mapping["4"], "y")!
+                    $
+            }
+        }
+    }
+}
+
+Initial (schedule, update_blocks) {}
+
+OnSuccess (update_blocks, render_blocks) {}
+OnFailure (update_blocks, render_blocks) {}
+
+OnSuccess (render_blocks, remove_connections) {}
+OnFailure (render_blocks, remove_connections) {}
+
+OnSuccess (remove_connections, render_connections) {}
+OnFailure (remove_connections, render_connections) {}
+
+OnSuccess (render_connections, success) {}
+OnFailure (render_connections, success) {}

+ 204 - 59
models/cbd_simulate.alc

@@ -5,8 +5,10 @@ include "conformance_scd.alh"
 include "io.alh"
 include "metamodels.alh"
 include "mini_modify.alh"
+include "utils.alh"
 
 Boolean function main(model : Element):
+	log("Start DTCBD simulation!")
 	String cmd
 	Boolean running
 	Element schedule_init
@@ -17,6 +19,7 @@ Boolean function main(model : Element):
 	String time
 	time = set_pop(allInstances(model, "FullRuntime/Time"))
 	current_time = read_attribute(model, time, "current_time")
+	log("Fetching time now: " + cast_value(current_time))
 
 	schedule_init = create_schedule(model)
 	schedule_run = read_root()
@@ -40,6 +43,7 @@ Boolean function main(model : Element):
 		current_time = step_simulation(model, schedule, current_time, inputs)
 
 	instantiate_attribute(model, time, "current_time", current_time)
+	log("CLOSE")
 	output("CLOSE")
 	return True!
 
@@ -47,60 +51,197 @@ Element function create_schedule(model : Element):
 	// Create nice graph first
 	Element nodes
 	Element successors
-	Element predecessors
 	String element_name
 	Element incoming_links
 	Element all_blocks
 
 	nodes = allInstances(model, "FullRuntime/Block")
-	successors = dict_create()
-	predecessors = dict_create()
+	successors = set_create()
 	while (set_len(nodes) > 0):
 		element_name = set_pop(nodes)
-		if (bool_not(dict_in(successors, element_name))):
-			dict_add(successors, element_name, create_node())
-		if (bool_not(dict_in(predecessors, element_name))):
-			dict_add(predecessors, element_name, create_node())
+		log("Block " + element_name + " : " + read_type(model, element_name))
 
 		if (is_nominal_instance(model, element_name, "FullRuntime/ICBlock")):
 			if (bool_not(is_physical_float(read_attribute(model, element_name, "last_in")))):
 				incoming_links = allIncomingAssociationInstances(model, element_name, "FullRuntime/InitialCondition")
 			else:
 				incoming_links = create_node()
-			if (is_nominal_instance(model, element_name, "FullRuntime/DerivatorBlock")):
-				Element new_incoming_links
-				new_incoming_links = allIncomingAssociationInstances(model, element_name, "FullRuntime/Link")
-				while (read_nr_out(new_incoming_links) > 0):
-					list_append(incoming_links, set_pop(new_incoming_links))
 		else:
 			incoming_links = allIncomingAssociationInstances(model, element_name, "FullRuntime/Link")
 
 		while (set_len(incoming_links) > 0):
 			String source
 			source = readAssociationSource(model, set_pop(incoming_links))
-			if (bool_not(dict_in(successors, source))):
-				dict_add(successors, source, create_node())
-			set_add(successors[source], element_name)
-			set_add(predecessors[element_name], source)
-	
+			list_append(successors, create_tuple(source, element_name))
+			log("Found edge: " + source + " --> " + element_name)
+
 	Element values
 	values = create_node()
-	dict_add(values, "model", model)
-	dict_add(values, "S", create_node())
-	dict_add(values, "index", 0)
-	dict_add(values, "indices", create_node())
-	dict_add(values, "lowlink", create_node())
-	dict_add(values, "onStack", create_node())
-	dict_add(values, "successors", successors)
-	dict_add(values, "predecessors", predecessors)
-	dict_add(values, "SCC", create_node())
-
-	nodes = get_topolist(values)
-	while (list_len(nodes) > 0):
-		strongconnect(list_pop_final(nodes), values)
+	//dict_add(values, "model", model)
+	//dict_add(values, "S", create_node())
+	//dict_add(values, "index", 0)
+	//dict_add(values, "indices", create_node())
+	//dict_add(values, "lowlink", create_node())
+	//dict_add(values, "onStack", create_node())
+	//dict_add(values, "successors", successors)
+	//dict_add(values, "predecessors", predecessors)
+	//dict_add(values, "SCC", create_node())
+
+	dict_add(values, "edges", successors)
+	dict_add(values, "nodes", allInstances(model, "FullRuntime/Block"))
+	dict_add(values, "dfsCounter", 0)
+	dict_add(values, "orderNumber", dict_create())
+	dict_add(values, "visited_topSort", set_create())
+	dict_add(values, "unvisited_strongComp", set_create())
+
+	log("Toposort")
+	//nodes = get_topolist(values)
+	//while (list_len(nodes) > 0):
+	//	log("Strong connect")
+	//	strongconnect(list_pop_final(nodes), values)
+
+	dict_overwrite(values, "SCC", strongComp(values))
+
+	//nodes = allInstances(model, "FullRuntime/Block")
+	//while (set_len(nodes) > 0):
+	//	strongconnect(set_pop(nodes), values)
+
+	log("OK")
 
 	return values["SCC"]!
 
+Void function topSort(values : Element):
+	Element nodes_copy
+	String node
+
+	// for node in graph:
+	//     node.visited = False
+	dict_overwrite(values, "visited_topSort", set_create())
+
+	// for node in graph:
+	//     if not node.visited:
+	//          dfsLabelling(node)
+	nodes_copy = set_copy(values["nodes"])
+	while (set_len(nodes_copy) > 0):
+		node = set_pop(nodes_copy)
+		if (bool_not(set_in(values["visited_topSort"], node))):
+			dfsLabelling(values, node)
+	log("Order: " + dict_to_string(values["orderNumber"]))
+
+	return!
+
+Element function get_successors(values : Element, node : String, key : String):
+	Element edges
+	Element result
+	String edge
+
+	result = set_create()
+	edges = list_copy(values[key])
+	while (list_len(edges) > 0):
+		edge = list_pop_final(edges)
+		if (cast_string(edge[0]) == node):
+			set_add(result, edge[1])
+
+	return result!
+
+Void function dfsLabelling(values : Element, node : String):
+	Element successors
+	String successor
+
+	// if not node.visited
+	if (bool_not(set_in(values["visited_topSort"], node))):
+		// node.visited = True
+		set_add(values["visited_topSort"], node)
+
+		// for neighbour in node.out_neighbours:
+		//     dfsLabelling(neighbour, graph)
+		successors = get_successors(values, node, "edges")
+		while (set_len(successors) > 0):
+			successor = set_pop(successors)
+			dfsLabelling(values, successor)
+
+		// node.orderNumber = dfsCounter
+		dict_overwrite(values["orderNumber"], node, values["dfsCounter"])
+
+		// dfsCounter += 1
+		dict_overwrite(values, "dfsCounter", cast_integer(values["dfsCounter"]) + 1)
+
+	return !
+
+Element function dfsCollect(values : Element, start_node : String):
+	Element result
+	String successor
+	Element successors
+
+	result = set_create()
+
+	// if not node.visited
+	if (set_in(values["unvisited_strongComp"], start_node)):
+		list_append(result, start_node)
+		// node.visited = True
+		set_remove(values["unvisited_strongComp"], start_node)
+
+		// for neighbour in node.out_neighbours:
+		//     dfsLabelling(neighbour, graph)
+		successors = get_successors(values, start_node, "rev_edges")
+		while (set_len(successors) > 0):
+			successor = set_pop(successors)
+			list_extend(result, dfsCollect(values, successor))
+
+	return result!
+
+String function highest_orderNumber(values : Element):
+	Integer max
+	String max_element
+	Element search
+	String elem
+
+	max = -1
+	search = set_copy(values["unvisited_strongComp"])
+	while (set_len(search) > 0):
+		elem = set_pop(search)
+		if (cast_integer(values["orderNumber"][elem]) > max):
+			max = values["orderNumber"][elem]
+			max_element = elem
+		
+	return max_element!
+
+Element function reverse_edges(edges : Element):
+	Element result
+	Element elem
+
+	result = list_create()
+	edges = list_copy(edges)
+	while (list_len(edges) > 0):
+		elem = list_pop_final(edges)
+		list_append(result, create_tuple(elem[1], elem[0]))
+	return result!
+
+Element function strongComp(values : Element):
+	Element graph
+	Element sccs
+	String start_node
+	Element strong_components
+	Element component
+
+	sccs = list_create()
+
+	topSort(values)
+
+	dict_overwrite(values, "unvisited_strongComp", set_copy(values["nodes"]))
+
+	dict_overwrite(values, "rev_edges", reverse_edges(values["edges"]))
+	strong_components = list_create()
+
+	while (set_len(values["unvisited_strongComp"]) > 0):
+		start_node = highest_orderNumber(values)
+
+		component = dfsCollect(values, start_node)
+		list_append(sccs, component)
+		log("Got strong component: " + list_to_string(component))
+
+	return sccs!
+
 Element function get_topolist(values : Element):
 	Element result
 	Element predecessors
@@ -131,41 +272,64 @@ Integer function min(a : Integer, b : Integer):
 		return b!
 
 Void function strongconnect(v : String, values : Element):
+	// if (v.index is undefined) then
+	//    strongconnect(V)
 	if (dict_in(values["indices"], v)):
 		return!
 
+	// v.index := index
 	dict_overwrite(values["indices"], v, values["index"])
+	// v.lowlink := indwx
 	dict_overwrite(values["lowlink"], v, values["index"])
+	// index := index + 1
 	dict_overwrite(values, "index", cast_integer(values["index"]) + 1)
 
+	// S.push(v)
 	list_append(values["S"], v)
+	// v.onStack := true
 	dict_overwrite(values["onStack"], v, True)
 	
 	Element successors
 	String w
 	successors = values["successors"][v]
 	while (set_len(successors) > 0):
+		// for each (v, w) in E do
 		w = set_pop(successors)
+		// if (w.index is undefined) then
 		if (bool_not(dict_in(values["indices"], w))):
+			// strongconnect(w)
 			strongconnect(w, values)
+			// v.lowlink := min(v.lowlink, w.lowlink)
 			dict_overwrite(values["lowlink"], v, min(values["lowlink"][v], values["lowlink"][w]))
 		elif (dict_in(values["onStack"], w)):
+			// else if (w.onStack)
 			if (values["onStack"][w]):
+				// v.lowlink := min(v.lowlink, w.index)
 				dict_overwrite(values["lowlink"], v, min(values["lowlink"][v], values["indices"][w]))
 	
+	// if (v.lowlink == v.index) then
 	if (value_eq(values["lowlink"][v], values["indices"][v])):
 		Element scc
+		// Start a new strongly connected component
 		scc = create_node()
 		// It will always differ now
+		// w := S.pop()
 		w = list_pop_final(values["S"])
-		list_append(scc, w)
+		// w.onStack = false
 		dict_overwrite(values["onStack"], w, False)
+		// add w to current strongly connected component
+		list_append(scc, w)
+		// while w != v
 		while (w != v):
+			// w := S.pop()
 			w = list_pop_final(values["S"])
-			list_append(scc, w)
+			// w.onStack = false
 			dict_overwrite(values["onStack"], w, False)
+			// add w to current strongly connected component
+			list_append(scc, w)
+		// output the current strongly connected component
 		list_insert(values["SCC"], scc, 0)
-
+		log("Found new SCC: " + list_to_string(scc))
 	return!
 
 Boolean function solve_scc(model : Element, scc : Element):
@@ -208,14 +372,14 @@ Boolean function solve_scc(model : Element, scc : Element):
 		elif (blocktype == "FullRuntime/MultiplyBlock"):
 			constant = 1.0
 
-		incoming = allIncomingAssociationInstances(model, block, "Link")
+		incoming = allIncomingAssociationInstances(model, block, "FullRuntime/Link")
 
 		Integer index_to_write_constant
 		index_to_write_constant = -1
 		while (read_nr_out(incoming) > 0):
 			selected = readAssociationSource(model, set_pop(incoming))
 
-			if (set_in(scc, selected)):
+			if (list_in(scc, selected)):
 				// Part of the loop, so in the index of selected in scc
 				// Five options:
 				if (blocktype == "FullRuntime/AdditionBlock"):
@@ -308,6 +472,7 @@ Float function step_simulation(model : Element, schedule : Element, time : Float
 
 		if (list_len(scc) > 1):
 			if (bool_not(solve_scc(model, scc))):
+				log("ALGEBRAIC_LOOP")
 				output("ALGEBRAIC_LOOP")
 				return time!
 		else:
@@ -315,9 +480,10 @@ Float function step_simulation(model : Element, schedule : Element, time : Float
 
 			// Execute "block"
 			blocktype = read_type(model, block)
+			//log("Execute block " + block + " : " + blocktype)
 			incoming = set_copy(inputs[block])
 			if (blocktype == "FullRuntime/ConstantBlock"):
-				signal = read_attribute(model, block, "value")
+				signal = cast_float(read_attribute(model, block, "value"))
 			elif (blocktype == "FullRuntime/AdditionBlock"):
 				signal = 0.0
 				while (set_len(incoming) > 0):
@@ -349,33 +515,12 @@ Float function step_simulation(model : Element, schedule : Element, time : Float
 				else:
 					signal = read_attribute(model, block, "last_in")
 				set_add(memory_blocks, block)
-			elif (blocktype == "FullRuntime/IntegratorBlock"):
-				if (bool_not(is_physical_float(read_attribute(model, block, "last_in")))):
-					// No history yet, so use initial values
-					incoming = allAssociationOrigins(model, block, "FullRuntime/InitialCondition")
-					while (set_len(incoming) > 0):
-						selected = set_pop(incoming)
-						signal = cast_float(read_attribute(model, selected, "signal"))
-				else:
-					signal = cast_float(read_attribute(model, block, "last_out")) + (delta_t * cast_float(read_attribute(model, block, "last_in")))
-				instantiate_attribute(model, block, "last_out", signal)
-				set_add(memory_blocks, block)
-			elif (blocktype == "FullRuntime/DerivatorBlock"):
-				if (bool_not(is_physical_float(read_attribute(model, block, "last_in")))):
-					// No history yet, so use initial values
-					incoming = allAssociationOrigins(model, block, "FullRuntime/InitialCondition")
-					while (set_len(incoming) > 0):
-						selected = set_pop(incoming)
-						signal = cast_float(read_attribute(model, selected, "signal"))
-				else:
-					while (set_len(incoming) > 0):
-						selected = set_pop(incoming)
-						signal = (cast_float(read_attribute(model, selected, "signal")) - cast_float(read_attribute(model, block, "last_in"))) / delta_t
-				set_add(memory_blocks, block)
 			elif (blocktype == "FullRuntime/ProbeBlock"):
+				signal = 0.0
 				while (set_len(incoming) > 0):
 					signal = cast_float(read_attribute(model, set_pop(incoming), "signal"))
 					output(cast_string(time) + " " + cast_string(read_attribute(model, block, "name")) + " " + cast_string(signal))
+					log(cast_string(time) + " " + cast_string(read_attribute(model, block, "name")) + " " + cast_string(signal))
 
 			instantiate_attribute(model, block, "signal", signal)
 	

models/cbd_toRuntime.alc → models/DTCBD/transformations/to_runtime.alc


+ 14 - 0
models/DiscreteEventTrace/metamodels/trace.mvc

@@ -0,0 +1,14 @@
+SimpleAttribute Float {
+    name = "Float"
+}
+SimpleAttribute String {
+    name = "String"
+}
+
+Class Event{
+    name = "Event"
+    timestamp : Float
+    name : String
+    parameter : String
+}
+

models/petrinet_ports.mvc → models/EncapsulatedPetriNets/metamodels/epn.mvc


models/combine_EPN.mvc → models/EncapsulatedPetriNets/transformations/combine.mvc


models/merge_EPN.alc → models/EncapsulatedPetriNets/transformations/merge.alc


models/epn_print.alc → models/EncapsulatedPetriNets/transformations/print.alc


+ 0 - 8
models/WSC/pm_PM_to_DEVS.mvc

@@ -44,11 +44,6 @@ Data experiment_model {
     type = "formalisms/Experiment/Experiment_MM"
 }
 
-Data metrics_model {
-    name = "Metrics"
-    type = "formalisms/Metrics/Metrics_MM"
-}
-
 Consumes (translate, pm_model) {
     name = "PM"
 }
@@ -72,6 +67,3 @@ Consumes (simulate, devs_model) {
 Consumes (simulate, experiment_model) {
     name = "Experiment"
 }
-Produces (simulate, metrics_model) {
-    name = "metrics"
-}

models/WSC/pm.mvc → models/FTGPM/metamodels/control_patterns.mvc


models/WSC/pm_example.mvc → models/FTGPM/models/example_patterns.mvc


models/WSC/PM_to_DEVS.mvc → models/FTGPM/transformations/patterns_to_DEVS.mvc


File diff suppressed because it is too large
+ 1835 - 0
models/FTGPM/transformations/to_SCCD.mvc


+ 10 - 10
models/pm_live_CBD.mvc

@@ -1,31 +1,31 @@
 Start start {}
 
 Exec toRuntime_0 {
-    name = "models/CBD/toRuntime"
+    name = "models/FSA/toRuntime"
 }
 
 Exec merge_0 {
-    name = "models/CBD/merge"
+    name = "models/FSA/merge"
 }
 
 Exec edit {
-    name = "models/CBD/edit"
+    name = "models/FSA/edit"
 }
 
 Exec toRuntime {
-    name = "models/CBD/toRuntime"
+    name = "models/FSA/toRuntime"
 }
 
 Exec restartSim {
-    name = "models/CBD/restartSim"
+    name = "models/FSA/restartSim"
 }
 
 Exec simulate {
-    name = "models/CBD/simulate"
+    name = "models/FSA/simulate"
 }
 
 Exec merge {
-    name = "models/CBD/merge"
+    name = "models/FSA/merge"
 }
 
 Fork fork1 {}
@@ -42,17 +42,17 @@ Data traceability_P2F {
 
 Data design_model {
     name = "design_model"
-    type = "formalisms/CBD/Design_MM"
+    type = "formalisms/FSA/Design_MM"
 }
 
 Data partial_runtime_model {
     name = "partial_runtime_model"
-    type = "formalisms/CBD/PartialRuntime_MM"
+    type = "formalisms/FSA/PartialRuntime_MM"
 }
 
 Data full_runtime_model {
     name = "full_runtime_model"
-    type = "formalisms/CBD/FullRuntime_MM"
+    type = "formalisms/FSA/FullRuntime_MM"
 }
 
 Next (start, toRuntime_0) {}

+ 15 - 0
models/FiniteStateAutomata/metamodels/FSA_MM.mvc

@@ -0,0 +1,15 @@
+include "primitives.alh"
+
+SimpleAttribute String {}
+SimpleAttribute Boolean {}
+
+Class State {
+    name = "State"
+    name : String
+    initial : Boolean
+}
+
+Association Transition (State, State) {
+    trigger? : String {}
+    raise? : String {}
+}

+ 15 - 0
models/FiniteStateAutomata/metamodels/FSA_MM_partial_runtime.mvc

@@ -0,0 +1,15 @@
+include "primitives.alh"
+
+Class String {}
+Class Boolean {}
+
+Class State {
+    name = "State"
+    name : String
+    initial : Boolean
+}
+
+Association Transition (State, State) {
+    trigger? : String {}
+    raise? : String {}
+}

+ 21 - 0
models/FiniteStateAutomata/metamodels/FSA_MM_runtime.mvc

@@ -0,0 +1,21 @@
+include "primitives.alh"
+
+Class String {}
+Class Boolean {}
+Class Float {}
+
+Class Time {
+    current_time : Float
+}
+
+Class State {
+    name = "State"
+    name : String
+    current : Boolean
+    initial : Boolean
+}
+
+Association Transition (State, State) {
+    trigger? : String {}
+    raise? : String {}
+}

+ 27 - 0
models/FiniteStateAutomata/models/alarm.mvc

@@ -0,0 +1,27 @@
+State idle {
+    name = "idle"
+    initial = True
+}
+State armed {
+    name = "armed"
+    initial = False
+}
+State detected {
+    name = "detected"
+    initial = False
+}
+
+Transition (idle, armed) {
+    trigger = "Arm"
+}
+Transition (armed, idle) {
+    trigger = "Disable"
+}
+Transition (armed, detected) {
+    trigger = "PersonDetected"
+    raise = "SoundAlarm"
+}
+Transition (detected, armed) {
+    trigger = "CorrectCode"
+    raise = "DisableAlarm"
+}

+ 108 - 0
models/FiniteStateAutomata/transformations/merge.alc

@@ -0,0 +1,108 @@
+include "primitives.alh"
+include "modelling.alh"
+include "object_operations.alh"
+include "conformance_scd.alh"
+include "utils.alh"
+include "typing.alh"
+include "mini_modify.alh"
+
+String function map_P2F(model : Element, name : String):
+	Element destinations
+	String pick
+
+	destinations = allAssociationDestinations(model, name, "P2F_state")
+
+	pick = name
+	while (pick == name):
+		pick = set_pop(destinations)
+
+	return pick!
+
+Boolean function main(model : Element):
+	Element all_states
+	String element_name
+	Boolean found_current
+	Boolean flag_initial
+	String new_current
+
+	found_current = False
+	new_current = read_root()
+
+	if (set_len(allInstances(model, "FullRuntime/State")) == 0):
+		// No execution in full runtime, so just flag the initial state
+		flag_initial = True
+		log("Searching for new initial state...")
+
+		// And add a new time
+		element_name = instantiate_node(model, "NewFullRuntime/Time", "")
+		instantiate_attribute(model, element_name, "current_time", 0.0)
+	else:
+		flag_initial = False
+		log("No searching for state!")
+
+		// Copy the time though
+		element_name = instantiate_node(model, "NewFullRuntime/Time", "")
+		instantiate_attribute(model, element_name, "current_time", read_attribute(model, set_pop(allInstances(model, "FullRuntime/Time")), "current_time"))
+		log("Time copied OK")
+
+	log("Reading existing data")
+	all_states = allInstances(model, "PartialRuntime/State")
+	while (set_len(all_states) > 0):
+		element_name = set_pop(all_states)
+		if (set_len(allOutgoingAssociationInstances(model, element_name, "P2F_state")) > 0):
+			// Element already exists in full, so check whether this is the current state
+			log("Found existing state")
+			if (read_attribute(model, map_P2F(model, element_name), "current")):
+				found_current = True
+				new_current = element_name
+		else:
+			// New state, so assume that it is not current
+			log("Read value: " + cast_value(read_attribute(model, element_name, "initial")))
+			if (bool_and(flag_initial, read_attribute(model, element_name, "initial"))):
+				log("FOUND IT!")
+				new_current = element_name
+			instantiate_link(model, "P2F_state", "", element_name, element_name)
+	
+	log("Deleting elements...")
+	all_states = allInstances(model, "NewFullRuntime/State")
+	while (set_len(all_states) > 0):
+		element_name = set_pop(all_states)
+		model_delete_element(model, element_name)
+
+	log("Copying elements...")
+	Element all_elements
+	String elem
+	all_elements = dict_keys(model["model"])
+	while (set_len(all_elements) > 0):
+		elem = set_pop(all_elements)
+		if (string_startswith(read_type(model, elem), "PartialRuntime/")):
+			retype(model, elem, "NewFullRuntime/" + cast_string(list_read(string_split_nr(read_type(model, elem), "/", 1), 1)))
+
+			if (read_type(model, elem) == "NewFullRuntime/State"):
+				instantiate_attribute(model, elem, "current", elem == new_current)
+
+	log("Setting current state...")
+	String new_state
+	if (found_current == False):
+		if (False):
+			// Prompt for new state
+			output("FIX_NEW_STATE")
+			new_state = input()
+			all_states = allInstances(model, "NewFullRuntime/State")
+			while (set_len(all_states) > 0):
+				element_name = set_pop(all_states)
+				if (value_eq(read_attribute(model, element_name, "name"), new_state)):
+					instantiate_attribute(model, element_name, "current", True)
+					break!
+		else:
+			// Reset to initial
+			log("Resetting to initial state!")
+			all_states = allInstances(model, "NewFullRuntime/State")
+			while (set_len(all_states) > 0):
+				element_name = set_pop(all_states)
+				if (value_eq(read_attribute(model, element_name, "initial"), True)):
+					log("Found initial state: " + cast_value(read_attribute(model, element_name, "name")))
+					instantiate_attribute(model, element_name, "current", True)
+					break!
+	log("DONE!")
+	return True!

+ 62 - 0
models/FiniteStateAutomata/transformations/simulate.alc

@@ -0,0 +1,62 @@
+include "primitives.alh"
+include "modelling.alh"
+include "object_operations.alh"
+include "conformance_scd.alh"
+include "io.alh"
+include "metamodels.alh"
+include "mini_modify.alh"
+
+Boolean function main(model : Element):
+	String input_value
+	Float start_time
+	String current_state
+	String old_state
+	Element transitions
+	String transition
+
+	start_time = time() - cast_float(read_attribute(model, set_pop(allInstances(model, "FullRuntime/Time")), "current_time"))
+
+	Element all_states
+	String element_name
+	all_states = allInstances(model, "FullRuntime/State")
+	while (set_len(all_states) > 0):
+		element_name = set_pop(all_states)
+		log("Check " + cast_value(read_attribute(model, element_name, "name")))
+		log("  Current: " + cast_value(read_attribute(model, element_name, "current")))
+		if (value_eq(read_attribute(model, element_name, "current"), True)):
+			log("Found current: " + cast_value(read_attribute(model, element_name, "current")))
+			current_state = element_name
+			old_state = element_name
+			break!
+
+	while (True):
+		if (has_input()):
+			input_value = input()
+
+			if (input_value == "__EXIT__"):
+				break!
+
+			log(cast_value(time() - start_time) + " input " + input_value)
+			output(cast_value(time() - start_time) + " input " + input_value)
+
+			transitions = allOutgoingAssociationInstances(model, current_state, "FullRuntime/Transition")
+			while (set_len(transitions) > 0):
+				transition = set_pop(transitions)
+				if (cast_string(read_attribute(model, transition, "trigger")) == input_value):
+					if (element_neq(read_attribute(model, transition, "raise"), read_root())):
+						log(cast_value(time() - start_time) + " output " + cast_string(read_attribute(model, transition, "raise")))
+						output(cast_value(time() - start_time) + " output " + cast_string(read_attribute(model, transition, "raise")))
+					current_state = readAssociationDestination(model, transition)
+					break!
+
+		log(cast_value(time() - start_time) + " state " + cast_string(read_attribute(model, current_state, "name")))
+		output(cast_value(time() - start_time) + " state " + cast_string(read_attribute(model, current_state, "name")))
+		sleep(0.2)
+
+	log("CLOSE")
+	output("CLOSE")
+	
+	instantiate_attribute(model, current_state, "current", True)
+	instantiate_attribute(model, old_state, "current", True)
+	instantiate_attribute(model, set_pop(allInstances(model, "FullRuntime/Time")), "current_time", time() - start_time)
+	return True!

+ 60 - 0
models/FiniteStateAutomata/transformations/to_runtime.alc

@@ -0,0 +1,60 @@
+include "primitives.alh"
+include "modelling.alh"
+include "object_operations.alh"
+
+String function map_D2P(model : Element, name : String):
+	Element destinations
+	String pick
+
+	destinations = allAssociationDestinations(model, name, "D2P_state")
+
+	pick = name
+	while (pick == name):
+		pick = set_pop(destinations)
+
+	return pick!
+
+Boolean function main(model : Element):
+	Element all_states
+	String element_name
+	String new_element_name
+	String mm_type_name
+	Element all_links
+
+	all_states = allInstances(model, "Design/State")
+	while (set_len(all_states) > 0):
+		element_name = set_pop(all_states)
+		mm_type_name = "PartialRuntime/" + cast_string(list_read(string_split(read_type(model, element_name), "/"), 1))
+
+		if (set_len(allOutgoingAssociationInstances(model, element_name, "D2P_state")) == 0):
+			// New design element, so create in partial runtime model as well
+			new_element_name = instantiate_node(model, mm_type_name, "")
+			instantiate_link(model, "D2P_state", "", element_name, new_element_name)
+
+		// Always update the value of attributes of PartialRuntime
+		new_element_name = map_D2P(model, element_name)
+        instantiate_attribute(model, new_element_name, "name", read_attribute(model, element_name, "name"))
+        instantiate_attribute(model, new_element_name, "initial", read_attribute(model, element_name, "initial"))
+		log("Copied state initial: " + cast_value(new_element_name) + ", initial: " + cast_value(read_attribute(model, element_name, "initial")))
+
+	all_states = allInstances(model, "PartialRuntime/State")
+	while (set_len(all_states) > 0):
+		element_name = set_pop(all_states)
+		if (set_len(allIncomingAssociationInstances(model, element_name, "D2P_state")) == 0):
+			// Old partial runtime element, so remove
+			model_delete_element(model, element_name)
+
+	// Delete all existing transitions
+    all_links = allInstances(model, "PartialRuntime/Transition")
+    while (set_len(all_links) > 0):
+        model_delete_element(model, set_pop(all_links))
+
+	// Recreate all transitions
+    all_links = allInstances(model, "Design/Transition")
+    while (set_len(all_links) > 0):
+        element_name = set_pop(all_links)
+        new_element_name = instantiate_link(model, "PartialRuntime/Transition", "", map_D2P(model, readAssociationSource(model, element_name)), map_D2P(model, readAssociationDestination(model, element_name)))
+		instantiate_attribute(model, new_element_name, "trigger", read_attribute(model, element_name, "trigger"))
+		instantiate_attribute(model, new_element_name, "raise", read_attribute(model, element_name, "raise"))
+
+	return True!

models/render_OD.alc → models/ObjectDiagrams/transformations/render.alc


models/paralleldevs_design.mvc → models/ParallelDEVS/metamodels/PDEVS.mvc


models/produce_consume_PDEVS.mvc → models/ParallelDEVS/models/produce_consume.mvc


models/pdevs_client.alc → models/ParallelDEVS/transformations/simulate_interactive.alc


models/petrinets.mvc → models/PetriNets/metamodels/PetriNets.mvc


models/my_pn.mvc → models/PetriNets/models/critical_section.mvc


+ 74 - 0
models/PetriNets/models/critical_section_with_check.mvc

@@ -0,0 +1,74 @@
+Place critical_section_1 {
+    tokens = 0
+    name = "critical_section_1"
+}
+Place critical_section_2 {
+    tokens = 0
+    name = "critical_section_2"
+}
+Place lock_available {
+    tokens = 1
+    name = "lock_available"
+}
+
+Transition release_section_1 {
+    name = "release_section_1"
+}
+Transition release_section_2 {
+    name = "release_section_2"
+}
+Transition acquire_section_1 {
+    name = "acquire_section_1"
+}
+Transition acquire_section_2 {
+    name = "acquire_section_2"
+}
+
+P2T (critical_section_1, release_section_1) {
+    weight = 1
+}
+
+P2T (critical_section_2, release_section_2) {
+    weight = 1
+}
+
+P2T (lock_available, acquire_section_1) {
+    weight = 1
+}
+
+P2T (lock_available, acquire_section_2) {
+    weight = 1
+}
+
+T2P (release_section_1, lock_available) {
+    weight = 1
+}
+
+T2P (release_section_2, lock_available) {
+    weight = 1
+}
+
+T2P (acquire_section_1, critical_section_1) {
+    weight = 1
+}
+
+T2P (acquire_section_2, critical_section_2) {
+    weight = 1
+}
+
+Place check {
+    tokens = 0
+    name = "ERROR"
+}
+Transition error {
+    name = "both_enabled"
+}
+P2T (critical_section_1, error) {
+    weight = 1
+}
+P2T (critical_section_2, error) {
+    weight = 1
+}
+T2P (error, check) {
+    weight = 1
+}

+ 12 - 11
models/lola.alc

@@ -18,10 +18,11 @@ Boolean function lola_format(model : Element):
 	String place_output
 	String marking_output
 	String transition_output
+	String outp
 
 	all_places = allInstances(model, "PN/Place")
 	log("ALL PLACES")
-	log(cast_i2s(list_len(all_places)))
+	log(cast_string(list_len(all_places)))
 	place_output = "PLACE "
 	marking_output = "MARKING "
 	while (set_len(all_places) > 0):
@@ -36,7 +37,7 @@ Boolean function lola_format(model : Element):
 				marking_output = string_join(marking_output, ", ")
 			marking_output = string_join(marking_output, name)
 			marking_output = string_join(marking_output, ": ")
-			marking_output = string_join(marking_output, cast_i2s(tokens))
+			marking_output = string_join(marking_output, cast_string(tokens))
 	
 		if list_len(all_places) == 0:
 			place_output = string_join(place_output, ";")
@@ -61,7 +62,7 @@ Boolean function lola_format(model : Element):
 			association = set_pop(associations)
 			place = readAssociationSource(model, association)
 			weight = read_attribute(model, association, "weight")
-			if cast_s2i(weight) > 0:
+			if cast_integer(weight) > 0:
 				transition_output = string_join(transition_output, read_attribute(model, place, "name"))
 				transition_output = string_join(transition_output, ": ")
 				transition_output = string_join(transition_output, weight)
@@ -78,7 +79,7 @@ Boolean function lola_format(model : Element):
 			association = set_pop(associations)
 			place = readAssociationDestination(model, association)
 			weight = read_attribute(model, association, "weight")
-			if cast_s2i(weight) > 0:
+			if cast_integer(weight) > 0:
 				transition_output = string_join(transition_output, read_attribute(model, place, "name"))
 				transition_output = string_join(transition_output, ": ")
 				transition_output = string_join(transition_output, weight)
@@ -96,23 +97,23 @@ Boolean function lola_format(model : Element):
 		name = read_attribute(model, place, "name")
 		tokens = read_attribute(model, place, "tokens")
 		query = string_join(name, ' = ')
-		query = string_join(query, cast_i2s(tokens))
+		query = string_join(query, cast_string(tokens))
 
 	log("PETRINET OUTPUT")
 	log(lola_net)
 	log("\n QUERY OUTPUT")
 	log(query)
-	output = string_join("{\"petrinet\":\"", lola_net)
-	output = string_join(output, "\" , \"query\":\"")
-	output = string_join(output, query)
-	output = string_join(output, "\"}")
+	outp = string_join("{\"petrinet\":\"", lola_net)
+	outp = string_join(outp, "\" , \"query\":\"")
+	outp = string_join(outp, query)
+	outp = string_join(outp, "\"}")
 
 	log("\n JSON OUTPUT")
-	log(output)
+	log(outp)
 
 	String port
 	port = comm_connect("lola")
-	comm_set(port, output)
+	comm_set(port, outp)
 
 	String result
 	String path

models/pn_print.alc → models/PetriNets/transformations/print.alc


models/reachability.alc → models/PetriNets/transformations/reachability.alc


models/pm_req_analyse.mvc → models/PowerWindow/PM_analyze.mvc


models/pm_req_analyse_debug.mvc → models/PowerWindow/PM_analyze_debug.mvc


models/architecture.mvc → models/PowerWindow/metamodels/architecture.mvc


models/control_PW.mvc → models/PowerWindow/metamodels/control.mvc


models/environment_PW.mvc → models/PowerWindow/metamodels/environment.mvc


models/plant_PW.mvc → models/PowerWindow/metamodels/plant.mvc


models/requirements.mvc → models/PowerWindow/metamodels/requirements.mvc


models/architecture_model.mvc → models/PowerWindow/models/architecture.mvc


models/control_model.mvc → models/PowerWindow/models/control.mvc


models/control_model_wrong.mvc → models/PowerWindow/models/control_wrong.mvc


models/environment_model.mvc → models/PowerWindow/models/environment.mvc


models/plant_model.mvc → models/PowerWindow/models/plant.mvc


models/requirements_model.mvc → models/PowerWindow/models/requirements.mvc


models/control_to_EPN.mvc → models/PowerWindow/transformations/control_to_EPN.mvc


models/environment_to_EPN.mvc → models/PowerWindow/transformations/environment_to_EPN.mvc


models/initialize.mvc → models/PowerWindow/transformations/initialize.mvc


models/plant_to_EPN.mvc → models/PowerWindow/transformations/plant_to_EPN.mvc


models/WSC/experiment.mvc → models/PythonPDEVS_Experiment/metamodels/experiment.mvc


models/WSC/experiment_example.mvc → models/PythonPDEVS_Experiment/models/optimize_PM_resources.mvc


models/reachability_graph.mvc → models/ReachabilityGraph/metamodels/reachability_graph.mvc


models/bfs.alc → models/ReachabilityGraph/transformations/bfs.alc


+ 0 - 0
models/matches.mvc


Some files were not shown because too many files changed in this diff