فهرست منبع

PM enactment seems to work (though reachability doesn't)

Yentl Van Tendeloo 8 سال پیش
والد
کامیت
703a4a8014
2فایلهای تغییر یافته به همراه72 افزوده شده و 5 حذف شده
  1. 12 5
      core/core_algorithm.alc
  2. 60 0
      integration/test_mvc.py

+ 12 - 5
core/core_algorithm.alc

@@ -9,7 +9,6 @@ include "ramify.alh"
 include "conformance_scd.alh"
 include "transform.alh"
 include "metamodels.alh"
-include "random.alh"
 
 Element core = ?
 
@@ -511,6 +510,7 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 
 	exact_type = read_type(core, transformation_id)
 	log("Exact type: " + exact_type)
+	log("EXECUTE OPERATION " + cast_e2s(read_attribute(core, transformation_id, "name")))
 	if (exact_type == "ModelTransformation"):
 		// Model transformation is always in-place and uses only a single metamodel
 		// Therefore, we must:
@@ -528,7 +528,6 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 		Element merged_model
 		String merged_metamodel_id
 		String ramified_metamodel_id
-		Boolean result
 
 		schedule_model = get_full_model(transformation_id)
 
@@ -566,7 +565,6 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 
 			// 3) Transform
 
-			log("EXECUTE TRANSFORMATION " + cast_e2s(read_attribute(core, transformation_id, "name")))
 			result = transform(merged_model, schedule_model)
 
 			// 4) Split in different files depending on type
@@ -696,6 +694,9 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 					model_overwrite(split_off_model, get_model_id(outputs[key]))
 		else:
 			output("Could not find merged metamodel")
+
+		// TODO find out whether it succeeded or not
+		result = True
 	else:
 		log("Type name: " + exact_type)
 		log("From " + transformation_id)
@@ -725,9 +726,10 @@ Void function enact_PM(pm : Element, prefix : String, user_id : String):
 
 	while (bool_not(pm_finished(worklist, pm))):
 		// Pop a random element from the list and execute it
-		tuple = random_choice(set_to_list(worklist))
+		tuple = set_pop(worklist)
 		element = tuple[0]
 		result = tuple[1]
+		log("EXECUTING " + element)
 
 		// Find the type (to see what to do with it)
 		//   this does not yet yield the type of transformation, if it is an Execution
@@ -768,6 +770,8 @@ Void function enact_PM(pm : Element, prefix : String, user_id : String):
 			// This the difficult part!
 
 			result = enact_action(pm, element, prefix, user_id)
+			log("Executed Exec of " + element)
+			log("Result: " + cast_v2s(result))
 
 		elif (type == "Decision"):
 			// If the previous result is true, we add the normal one, otherwise the false one
@@ -780,8 +784,11 @@ Void function enact_PM(pm : Element, prefix : String, user_id : String):
 		// We have finished the execution, so add all outgoing edges to the worklist
 		Element all_next
 		all_next = allAssociationDestinations(pm, element, "Next")
+		String next
 		while (read_nr_out(all_next) > 0):
-			set_add(worklist, create_tuple(set_pop(all_next), True))
+			next = set_pop(all_next)
+			log("Queueing next: " + next)
+			set_add(worklist, create_tuple(next, result))
 
 	// Reached a finish element, so stop
 	return !

+ 60 - 0
integration/test_mvc.py

@@ -1935,6 +1935,26 @@ class TestModelverseCore(unittest.TestCase):
                 "process_execute",
                 "pn_reachability",
                 "my_",
+                    "instantiate",
+                        "PetriNet/Place",
+                        "p1",
+                    "attr_add",
+                        "p1",
+                        "name",
+                        "p1",
+                    "attr_add",
+                        "p1",
+                        "tokens",
+                        1,
+                    "instantiate",
+                        "PetriNet/Transition",
+                        "t1",
+                    "instantiate",
+                        "PetriNet/P2T",
+                        "p2t",
+                        "p1",
+                        "t1",
+                    "exit",
                 "model_list",
             ],
             [   # bootup phase
@@ -2037,6 +2057,46 @@ class TestModelverseCore(unittest.TestCase):
                 # process_execute
                 "Which process model do you want to execute?",
                 "Model prefix to use?",
+                    "Model loaded, ready for commands!",
+                    "Use 'help' command for a list of possible commands",
+                    "Please give your command.",
+                    # instantiate p1
+                        "Type to instantiate?",
+                        "Name of new element?",
+                        "Instantiation successful!",
+                        "Please give your command.",
+                        "Which model do you want to assign an attribute to?",
+                        "Which attribute do you wish to assign?",
+                        "Value of attribute?",
+                        "Added attribute!",
+                        "Please give your command.",
+                        "Which model do you want to assign an attribute to?",
+                        "Which attribute do you wish to assign?",
+                        "Value of attribute?",
+                        "Added attribute!",
+                        "Please give your command.",
+                    # instantiate t1
+                        "Type to instantiate?",
+                        "Name of new element?",
+                        "Instantiation successful!",
+                        "Please give your command.",
+                        "Which model do you want to assign an attribute to?",
+                        "Which attribute do you wish to assign?",
+                        "Value of attribute?",
+                        "Added attribute!",
+                        "Please give your command.",
+                    # instantiate p2t
+                        "Type to instantiate?",
+                        "Name of new element?",
+                        "Source name?",
+                        "Destination name?",
+                        "Instantiation successful!",
+                        "Please give your command.",
+                        "Which model do you want to assign an attribute to?",
+                        "Which attribute do you wish to assign?",
+                        "Value of attribute?",
+                        "Added attribute!",
+                        "Please give your command.",
                 "Ready for command...",
                 # model_list
                 model_list |