Browse Source

Added a "slow" test which first uploads a bad control model

Yentl Van Tendeloo 8 years ago
parent
commit
0842848b7f

+ 1 - 12
core/core_algorithm.alc

@@ -528,8 +528,6 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 		schedule_model = get_full_model(transformation_id)
 
 		// 1) Create empty instance of merged metamodel
-		log("T1")
-
 		ramified_metamodel_id = set_pop(followAssociation(core, transformation_id, "instanceOf"))
 		trace_links = allOutgoingAssociationInstances(core, ramified_metamodel_id, "tracability")
 		merged_metamodel_id = ""
@@ -542,8 +540,6 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 			merged_model = instantiate_model(get_full_model(merged_metamodel_id))
 
 			// 2) Merge source models
-			log("T2")
-
 			String key
 			Element keys
 			Element input_keys
@@ -555,14 +551,10 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 				model_join(merged_model, get_full_model(get_model_id(inputs[key])), string_join(types[key], "/"))
 
 			// 3) Transform
-			log("T3")
-
 			result = transform(merged_model, schedule_model)
-			log("Transformation result: " + cast_e2s(result))
+			log("Transformation result: " + cast_b2s(result))
 
 			// 4) Split in different files depending on type
-			log("T4")
-
 			String desired_metamodel_id
 			Element split_off_model
 
@@ -573,8 +565,6 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 				split_off_model = model_split(merged_model, get_full_model(desired_metamodel_id), key + "/")
 
 				// Check if the destination model already exists
-				log("Write result to " + cast_v2s(outputs[key]))
-				log("Model size: " + cast_v2s(read_nr_out(split_off_model["model"])))
 				if (get_model_id(outputs[key]) == ""):
 					// New model
 					model_create(split_off_model, outputs[key], user_id, desired_metamodel_id, "Model")
@@ -768,7 +758,6 @@ Void function enact_PM(pm : Element, prefix : String, user_id : String):
 			next = set_pop(all_next)
 			set_add(worklist, create_tuple(next, result))
 
-	log("FINISHED")
 	// Reached a finish element, so stop
 	return !
 

+ 0 - 1
integration/code/reachability.alc

@@ -97,7 +97,6 @@ Element function reachability_graph(params : Element, output_mms : Element):
 
 	while (read_nr_out(workset) > 0):
 		state_id = set_pop(workset)
-		log("Reachable states: " + cast_i2s(read_nr_out(reachable_states)))
 
 		dict_repr = reachable_states[state_id]
 

+ 527 - 0
integration/test_powerwindow.py

@@ -516,6 +516,533 @@ class TestPowerWindow(unittest.TestCase):
                 "Ready for command...",
             ]))
 
+    def test_process_powerwindow_slow(self):
+        self.assertTrue(run_file(all_files,
+            [ "root", "root", "root", 
+                "model_add",
+                    "SimpleClassDiagrams",
+                    "ReachabilityGraph",
+                    ] + get_model_constructor_2("integration/code/reachability_graph.mvc") + [
+                "model_add",
+                    "SimpleClassDiagrams",
+                    "PetriNet",
+                    ] + get_model_constructor_2("integration/code/pn_design.mvc") + [
+                "model_add",
+                    "SimpleClassDiagrams",
+                    "Encapsulated_PetriNet",
+                    ] + get_model_constructor_2("models/petrinet_ports.mvc") + [
+                "model_add",
+                    "SimpleClassDiagrams",
+                    "PW_Plant",
+                    ] + get_model_constructor_2("models/plant_PW.mvc") + [
+                "model_add",
+                    "SimpleClassDiagrams",
+                    "PW_Environment",
+                    ] + get_model_constructor_2("models/environment_PW.mvc") + [
+                "model_add",
+                    "SimpleClassDiagrams",
+                    "PW_Control",
+                    ] + get_model_constructor_2("models/control_PW.mvc") + [
+                "model_add",
+                    "SimpleClassDiagrams",
+                    "Requirements",
+                    ] + get_model_constructor_2("models/requirements.mvc") + [
+                "model_add",
+                    "SimpleClassDiagrams",
+                    "Query",
+                    ] + get_model_constructor_2("models/query.mvc") + [
+                "model_add",
+                    "ProcessModel",
+                    "pm_powerwindow",
+                    ] + get_model_constructor_2("models/pm_req_analyse.mvc") + [
+                "model_list",
+                "transformation_add_MT_language",
+                "PetriNet",
+                "Encapsulated_PetriNet",
+                "PW_Plant",
+                "PW_Control",
+                "PW_Environment",
+                "Requirements",
+                "ReachabilityGraph",
+                "Query",
+                "",
+                "All_RAM",
+                "model_modify",
+                    "__merged_All_RAM",
+                        "instantiate",
+                            "Association",
+                            "CTRL2EPN_link",
+                            "PW_Control/State",
+                            "Encapsulated_PetriNet/Place",
+                        "instantiate",
+                            "Association",
+                            "CTRL2EPN_tlink",
+                            "PW_Control/Transition",
+                            "Encapsulated_PetriNet/Transition",
+                        "instantiate",
+                            "Association",
+                            "PLANT2EPN_link",
+                            "PW_Plant/State",
+                            "Encapsulated_PetriNet/Place",
+                        "instantiate",
+                            "Association",
+                            "PLANT2EPN_tlink",
+                            "PW_Plant/Transition",
+                            "Encapsulated_PetriNet/Transition",
+                        "instantiate",
+                            "Association",
+                            "ENV2EPN_link",
+                            "PW_Environment/Event",
+                            "Encapsulated_PetriNet/Place",
+                        "instantiate",
+                            "Association",
+                            "EPN2PN_place_link",
+                            "Encapsulated_PetriNet/Place",
+                            "PetriNet/Place",
+                        "instantiate",
+                            "Association",
+                            "EPN2PN_transition_link",
+                            "Encapsulated_PetriNet/Transition",
+                            "PetriNet/Transition",
+                        "exit",
+                "transformation_RAMify",
+                    "__merged_All_RAM",
+                    "All_RAM",
+                "transformation_add_MANUAL",
+                    "",
+                    "Requirements",
+                    "",
+                    "define_req",
+                "transformation_add_MANUAL",
+                    "Requirements",
+                    "PW_Environment",
+                    "",
+                    "PW_Environment",
+                    "",
+                    "refine_environment",
+                "transformation_add_MANUAL",
+                    "Requirements",
+                    "PW_Plant",
+                    "",
+                    "PW_Plant",
+                    "",
+                    "refine_plant",
+                "transformation_add_MANUAL",
+                    "Requirements",
+                    "PW_Control",
+                    "",
+                    "PW_Control",
+                    "",
+                    "refine_control",
+                "transformation_add_MANUAL",
+                    "Requirements",
+                    "Query",
+                    "",
+                    "Query",
+                    "",
+                    "refine_query",
+                "transformation_add_MT",
+                    "All_RAM",
+                    "",
+                    "PW_Plant",
+                    "PW_Environment",
+                    "PW_Control",
+                    "Query",
+                    "",
+                    "make_initial_models",
+                    ] + get_model_constructor_2("models/initialize.mvc") + [
+                "transformation_add_MT",
+                    "All_RAM",
+                    "PW_Plant",
+                    "",
+                    "Encapsulated_PetriNet",
+                    "",
+                    "plant_to_EPN",
+                    ] + get_model_constructor_2("models/plant_to_EPN.mvc") + [
+                "transformation_add_MT",
+                    "All_RAM",
+                    "PW_Control",
+                    "",
+                    "Encapsulated_PetriNet",
+                    "",
+                    "control_to_EPN",
+                    ] + get_model_constructor_2("models/control_to_EPN.mvc") + [
+                "transformation_add_MT",
+                    "All_RAM",
+                    "PW_Environment",
+                    "",
+                    "Encapsulated_PetriNet",
+                    "",
+                    "environment_to_EPN",
+                    ] + get_model_constructor_2("models/environment_to_EPN.mvc") + [
+                "transformation_add_MT",
+                    "All_RAM",
+                    "Encapsulated_PetriNet",
+                    "",
+                    "Encapsulated_PetriNet",
+                    "",
+                    "combine_EPN",
+                    ] + get_model_constructor_2("models/combine_EPN.mvc") + [
+                "transformation_add_AL",
+                    "PetriNet",
+                    "",
+                    "ReachabilityGraph",
+                    "",
+                    "reachability",
+                    ] + get_constructor(open("integration/code/reachability.alc", "r").read()) + [
+                "transformation_add_MT",
+                    "All_RAM",
+                    "ReachabilityGraph",
+                    "Query",
+                    "",
+                    "",
+                    "matches",
+                    ] + get_model_constructor_2("models/matches.mvc") + [
+                "model_list",
+                "process_execute",
+                "pm_powerwindow",
+                "pm_",
+                # define_req
+                "upload",
+                ] + get_model_constructor_2("models/requirements_model.mvc") + [
+                "exit",
+                # FIRST ITERATION
+                # refine_plant
+                "upload",
+                ] + get_model_constructor_2("models/plant_model.mvc") + [
+                "exit",
+                # refine_environment
+                "upload",
+                ] + get_model_constructor_2("models/environment_model.mvc") + [
+                "exit",
+                # refine_control
+                "upload",
+                ] + get_model_constructor_2("models/control_model_wrong.mvc") + [
+                "exit",
+                # refine_query
+                "upload",
+                ] + get_model_constructor_2("models/query_model.mvc") + [
+                "exit",
+                # SECOND ITERATION
+                # refine_plant
+                "upload",
+                ] + get_model_constructor_2("models/plant_model.mvc") + [
+                "exit",
+                # refine_environment
+                "upload",
+                ] + get_model_constructor_2("models/environment_model.mvc") + [
+                "exit",
+                # refine_control
+                "upload",
+                ] + get_model_constructor_2("models/control_model.mvc") + [
+                "exit",
+                # refine_query
+                "upload",
+                ] + get_model_constructor_2("models/query_model.mvc") + [
+                "exit",
+            ],
+            [   # bootup phase
+                "Desired username for admin user?",
+                "Desired password for admin user?",
+                "Please repeat the password",
+                "Passwords match!",
+                "Welcome to the Model Management Interface v2.0!",
+                "Use the 'help' command for a list of possible commands",
+                "Ready for command...",
+                # model_add * 9
+                ] + [   "Creating new model!",
+                        "Model type?",
+                        "Model name?",
+                        "Waiting for model constructors...",
+                        "Model upload success!",
+                        "Ready for command...", ] * 9 + [
+                # model_list
+                model_list |
+                set([
+                     "  ReachabilityGraph : SimpleClassDiagrams",
+                     "  PetriNet : SimpleClassDiagrams",
+                     "  Encapsulated_PetriNet : SimpleClassDiagrams",
+                     "  PW_Plant : SimpleClassDiagrams",
+                     "  PW_Environment : SimpleClassDiagrams",
+                     "  PW_Control : SimpleClassDiagrams",
+                     "  Requirements : SimpleClassDiagrams",
+                     "  Query : SimpleClassDiagrams",
+                     "  pm_powerwindow : ProcessModel",
+                     ]),
+                "Ready for command...",
+                # transformation_add_MT_language
+                "Formalisms to include (terminate with empty string)?",
+                "Name of the RAMified transformation metamodel?",
+                "Ready for command...",
+                # model_modify
+                "Which model do you want to modify?",
+                "Model loaded, ready for commands!",
+                "Use 'help' command for a list of possible commands",
+                "Please give your command.",
+                # instantiate * 7
+                ] + [   "Type to instantiate?",
+                        "Name of new element?",
+                        "Source name?",
+                        "Destination name?",
+                        "Instantiation successful!",
+                        "Please give your command.", ] * 7 + [
+                "Ready for command...",
+                # transformation_RAMify
+                "Which metamodel do you want to RAMify?",
+                "Where do you want to store the RAMified metamodel?",
+                "Ready for command...",
+                # transformation_add_MANUAL
+                ] + [
+                    "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
+                    "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
+                    "Model added as target",
+                    "Name of Manual operation model?",
+                    "Ready for command...",
+                    ] + [
+                # transformation_add_MANUAL * 4
+                ] + [
+                    "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
+                    "Model added as source",
+                    "Model added as source",
+                    "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
+                    "Model added as target",
+                    "Name of Manual operation model?",
+                    "Ready for command...",
+                    ] * 4 + [
+                # transformation_add_MT
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set(["  PetriNet",
+                     "  Encapsulated_PetriNet",
+                     "  PW_Plant",
+                     "  Query",
+                     "  PW_Environment",
+                     "  Requirements",
+                     "  PW_Control",
+                     "  ReachabilityGraph",
+                    ]),
+                "",
+                "Which ones do you want to use as source (empty string to finish)?",
+                "Which ones do you want to use as target (empty string to finish)?",
+                "Model added as target",
+                "Model added as target",
+                "Model added as target",
+                "Model added as target",
+                "Name of new transformation?",
+                "Waiting for model constructors...",
+                "Ready for command...",
+                # transformation_add_MT
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set(["  PetriNet",
+                     "  Encapsulated_PetriNet",
+                     "  Query",
+                     "  PW_Plant",
+                     "  PW_Environment",
+                     "  Requirements",
+                     "  PW_Control",
+                     "  ReachabilityGraph",
+                    ]),
+                "",
+                "Which ones do you want to use as source (empty string to finish)?",
+                "Model added as source",
+                "Which ones do you want to use as target (empty string to finish)?",
+                "Model added as target",
+                "Name of new transformation?",
+                "Waiting for model constructors...",
+                "Ready for command...",
+                # transformation_add_MT
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set(["  PetriNet",
+                     "  Encapsulated_PetriNet",
+                     "  Query",
+                     "  PW_Plant",
+                     "  PW_Environment",
+                     "  Requirements",
+                     "  PW_Control",
+                     "  ReachabilityGraph",
+                    ]),
+                "",
+                "Which ones do you want to use as source (empty string to finish)?",
+                "Model added as source",
+                "Which ones do you want to use as target (empty string to finish)?",
+                "Model added as target",
+                "Name of new transformation?",
+                "Waiting for model constructors...",
+                "Ready for command...",
+                # transformation_add_MT
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set(["  PetriNet",
+                     "  Encapsulated_PetriNet",
+                     "  Query",
+                     "  PW_Plant",
+                     "  PW_Environment",
+                     "  Requirements",
+                     "  PW_Control",
+                     "  ReachabilityGraph",
+                    ]),
+                "",
+                "Which ones do you want to use as source (empty string to finish)?",
+                "Model added as source",
+                "Which ones do you want to use as target (empty string to finish)?",
+                "Model added as target",
+                "Name of new transformation?",
+                "Waiting for model constructors...",
+                "Ready for command...",
+                # transformation_add_MT
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set(["  PetriNet",
+                     "  Encapsulated_PetriNet",
+                     "  Query",
+                     "  PW_Plant",
+                     "  PW_Environment",
+                     "  Requirements",
+                     "  PW_Control",
+                     "  ReachabilityGraph",
+                    ]),
+                "",
+                "Which ones do you want to use as source (empty string to finish)?",
+                "Model added as source",
+                "Which ones do you want to use as target (empty string to finish)?",
+                "Model added as target",
+                "Name of new transformation?",
+                "Waiting for model constructors...",
+                "Ready for command...",
+                # transformation_add_AL
+                ] + [   "Which metamodels do you want to use as source for the action code (empty string to finish)?",
+                        "Model added as source",
+                        "Which metamodels do you want to use as target for the action code (empty string to finish)?",
+                        "Model added as target",
+                        "Name of Action Language model?",
+                        "Waiting for model constructors...",
+                        "Ready for command...", ] * 1 + [
+                # transformation_add_MT
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set(["  PetriNet",
+                     "  Encapsulated_PetriNet",
+                     "  Query",
+                     "  PW_Plant",
+                     "  PW_Environment",
+                     "  Requirements",
+                     "  PW_Control",
+                     "  ReachabilityGraph",
+                    ]),
+                "",
+                "Which ones do you want to use as source (empty string to finish)?",
+                "Model added as source",
+                "Model added as source",
+                "Which ones do you want to use as target (empty string to finish)?",
+                "Name of new transformation?",
+                "Waiting for model constructors...",
+                "Ready for command...",
+                # model_list
+                model_list |
+                set([
+                     "  PetriNet : SimpleClassDiagrams",
+                     "  Encapsulated_PetriNet : SimpleClassDiagrams",
+                     "  PW_Plant : SimpleClassDiagrams",
+                     "  PW_Environment : SimpleClassDiagrams",
+                     "  PW_Control : SimpleClassDiagrams",
+                     "  Requirements : SimpleClassDiagrams",
+                     "  Query : SimpleClassDiagrams",
+                     "  reachability : ActionLanguage",
+                     "  define_req : ManualOperation",
+                     "  refine_plant : ManualOperation",
+                     "  refine_control : ManualOperation",
+                     "  refine_environment : ManualOperation",
+                     "  refine_query : ManualOperation",
+                     "  __merged_define_req : SimpleClassDiagrams",
+                     "  __merged_All_RAM : SimpleClassDiagrams",
+                     "  __merged_refine_plant : SimpleClassDiagrams",
+                     "  __merged_refine_control : SimpleClassDiagrams",
+                     "  __merged_refine_environment : SimpleClassDiagrams",
+                     "  __merged_refine_query : SimpleClassDiagrams",
+                     "  matches : All_RAM",
+                     "  All_RAM : SimpleClassDiagrams",
+                     "  make_initial_models : All_RAM",
+                     "  pm_powerwindow : ProcessModel",
+                     "  plant_to_EPN : All_RAM",
+                     "  combine_EPN : All_RAM",
+                     "  environment_to_EPN : All_RAM",
+                     "  control_to_EPN : All_RAM",
+                     "  ReachabilityGraph : SimpleClassDiagrams",
+                     ]),
+                "Ready for command...",
+                # process_execute
+                "Which process model do you want to execute?",
+                "Model prefix to use?",
+                # Manual transformation define_req
+                "Please perform manual transformation \"define_req\"",
+                "Model loaded, ready for commands!",
+                "Use 'help' command for a list of possible commands",
+                "Please give your command.",
+                "Waiting for model constructors...",
+                "Please give your command.",
+                # Manual transformation refine_plant
+                "Please perform manual transformation \"refine_plant\"",
+                "Model loaded, ready for commands!",
+                "Use 'help' command for a list of possible commands",
+                "Please give your command.",
+                "Waiting for model constructors...",
+                "Please give your command.",
+                # Manual transformation refine_environment
+                "Please perform manual transformation \"refine_environment\"",
+                "Model loaded, ready for commands!",
+                "Use 'help' command for a list of possible commands",
+                "Please give your command.",
+                "Waiting for model constructors...",
+                "Please give your command.",
+                # Manual transformation refine_control
+                "Please perform manual transformation \"refine_control\"",
+                "Model loaded, ready for commands!",
+                "Use 'help' command for a list of possible commands",
+                "Please give your command.",
+                "Waiting for model constructors...",
+                "Please give your command.",
+                # Manual transformation refine_query
+                "Please perform manual transformation \"refine_query\"",
+                "Model loaded, ready for commands!",
+                "Use 'help' command for a list of possible commands",
+                "Please give your command.",
+                "Waiting for model constructors...",
+                "Please give your command.",
+                # Computations happen without output
+                # ERROR: element matches, so we go back to the forkjoin
+                # Manual transformation refine_plant
+                "Please perform manual transformation \"refine_plant\"",
+                "Model loaded, ready for commands!",
+                "Use 'help' command for a list of possible commands",
+                "Please give your command.",
+                "Waiting for model constructors...",
+                "Please give your command.",
+                # Manual transformation refine_environment
+                "Please perform manual transformation \"refine_environment\"",
+                "Model loaded, ready for commands!",
+                "Use 'help' command for a list of possible commands",
+                "Please give your command.",
+                "Waiting for model constructors...",
+                "Please give your command.",
+                # Manual transformation refine_control
+                "Please perform manual transformation \"refine_control\"",
+                "Model loaded, ready for commands!",
+                "Use 'help' command for a list of possible commands",
+                "Please give your command.",
+                "Waiting for model constructors...",
+                "Please give your command.",
+                # Manual transformation refine_query
+                "Please perform manual transformation \"refine_query\"",
+                "Model loaded, ready for commands!",
+                "Use 'help' command for a list of possible commands",
+                "Please give your command.",
+                "Waiting for model constructors...",
+                "Please give your command.",
+                # Finished, so we go back to the start
+                "Ready for command...",
+            ]))
     def test_process_powerwindow_debug(self):
         self.assertTrue(run_file(all_files,
             [ "root", "root", "root", 

+ 0 - 1
models/combine_EPN.mvc

@@ -64,7 +64,6 @@ A B {
                     label = "0"
                     value_selected = $
                         Boolean function value(model : Element, name : String, mapping : Element):
-                            log("Mark as selected: " + cast_v2s(read_attribute(model, name, "name")))
                             return True!
                         $
                 }

+ 36 - 0
models/control_model_wrong.mvc

@@ -0,0 +1,36 @@
+Control_PW control_model_PW {
+    PW_Control/Up up {
+        isInitial = False
+        isError = False
+        name = "ctrl_up"
+    }
+    PW_Control/Down down {
+        isInitial = False
+        isError = False
+        name = "ctrl_down"
+    }
+    PW_Control/Neutral neutral {
+        isInitial = True
+        isError = True
+        name = "ctrl_neutral"
+    }
+
+    PW_Control/UpPressed (down, neutral) {
+        objDetected = "*"
+    }
+    PW_Control/UpPressed (neutral, up) {
+        objDetected = "*"
+    }
+    PW_Control/DownPressed (up, neutral) {
+        objDetected = "*"
+    }
+    PW_Control/DownPressed (neutral, down) {
+        objDetected = "*"
+    }
+    PW_Control/NonePressed (up, neutral) {
+        objDetected = "*"
+    }
+    PW_Control/NonePressed (down, neutral) {
+        objDetected = "*"
+    }
+}