Browse Source

Added PM to FTG transformation

Yentl Van Tendeloo 3 years ago
parent
commit
ae577b488e

+ 4 - 2
examples/FTG_generate.py

@@ -24,6 +24,8 @@ def add_traceability(model):
     instantiate(model, "Association", edge=("PM/Exec", "FTG/Activity"), ID="activity_link")
     instantiate(model, "Association", edge=("PM/Data", "FTG/Formalism"), ID="formalism_link")
 
-transformation_add_MT({"PM": "formalisms/ProcessModel"}, {"FTG": "formalisms/FormalismTransformationGraph"}, "models/generate_FTG", open("models/FTGPM/transformations/PM_to_FTG.mvc", 'r').read(), add_traceability)
+transformation_add_AL({"PM": "formalisms/ProcessModel"}, {"FTG": "formalisms/FormalismTransformationGraph"}, "models/generate_FTG", open("models/FTGPM/transformations/PM_to_FTG.alc", 'r').read(), add_traceability)
 
-transformation_execute_MT("models/generate_FTG", {"PM": "models/pm_powerwindow"}, {"FTG": "models/ftg_powerwindow"})
+transformation_execute_AL("models/generate_FTG", {"PM": "models/pm_powerwindow"}, {"FTG": "models/ftg_powerwindow"})
+for i in element_list_nice("models/ftg_powerwindow"):
+    print(i)

+ 0 - 2
models/FTGPM/metamodels/FTG_MM.mvc

@@ -1,5 +1,4 @@
 SimpleAttribute String {}
-SimpleAttribute Boolean {}
 
 Class Formalism {
     name : String
@@ -7,7 +6,6 @@ Class Formalism {
 
 Class Activity {
     name : String
-    automatic : Boolean
 }
 
 Association Consumes (Formalism, Activity) {

+ 59 - 0
models/FTGPM/transformations/PM_to_FTG.alc

@@ -0,0 +1,59 @@
+include "primitives.alh"
+include "modelling.alh"
+include "object_operations.alh"
+
+Boolean function main(model : Element):
+	// Find all activities
+	Element known_activities
+	Element known_formalisms
+	Element activity_mapping
+	Element formalism_mapping
+	Element elems
+	String elem
+	String type
+	String new_elem
+
+	activity_mapping = dict_create()
+	formalism_mapping = dict_create()
+	known_activities = dict_create()
+	known_formalisms = dict_create()
+
+	elems = allInstances(model, "PM/Exec")
+	while (set_len(elems) > 0):
+		elem = set_pop(elems)
+		type = read_attribute(model, elem, "name")
+
+		if dict_in(known_activities, type):
+			new_elem = known_activities[type]
+		else:
+			new_elem = instantiate_node(model, "FTG/Activity", "")
+			instantiate_attribute(model, new_elem, "name", type)
+			dict_add(known_activities, type, new_elem)
+		dict_add(activity_mapping, elem, new_elem)
+
+	elems = allInstances(model, "PM/Data")
+	while (set_len(elems) > 0):
+		elem = set_pop(elems)
+		type = read_attribute(model, elem, "type")
+
+		if dict_in(known_formalisms, type):
+			new_elem = known_formalisms[type]
+		else:
+			new_elem = instantiate_node(model, "FTG/Formalism", "")
+			instantiate_attribute(model, new_elem, "name", type)
+			dict_add(known_formalisms, type, new_elem)
+		dict_add(formalism_mapping, elem, new_elem)
+
+	elems = allInstances(model, "PM/Produces")
+	while (set_len(elems) > 0):
+		elem = set_pop(elems)
+		new_elem = instantiate_link(model, "FTG/Produces", "", activity_mapping[readAssociationSource(model, elem)], formalism_mapping[readAssociationDestination(model, elem)])
+		instantiate_attribute(model, new_elem, "name", read_attribute(model, elem, "name"))
+
+	elems = allInstances(model, "PM/Consumes")
+	while (set_len(elems) > 0):
+		elem = set_pop(elems)
+		new_elem = instantiate_link(model, "FTG/Consumes", "", formalism_mapping[readAssociationDestination(model, elem)], activity_mapping[readAssociationSource(model, elem)])
+		instantiate_attribute(model, new_elem, "name", read_attribute(model, elem, "name"))
+
+	return True!

+ 0 - 23
models/FTGPM/transformations/PM_to_FTG.mvc

@@ -1,23 +0,0 @@
-// TODO for each activity, we make the parent
-// TODO for each formalism, we make the type
-// TODO for each link, we make the consume/produce link
-// TODO ignore the control links and control elements
-
-include "primitives.alh"
-include "modelling.alh"
-include "object_operations.alh"
-
-Composite schedule {
-    {Contains} Failure failure {}
-    {Contains} Success success {}
-}
-
-// Initial (schedule, translate_activity) {}
-
-// OnSuccess (translate_activity, translate_formalism) {}
-// OnFailure (translate_activity, translate_formalism) {}
-
-translate_activity
-translate_formalism
-translate_consume
-translate_produce

+ 1 - 1
wrappers/modelverse_SCCD.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Fri May 25 16:52:45 2018
+Date:   Mon May 28 10:12:07 2018
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server