Browse Source

Traced down cause of bug with stalled Modelverse: read_root() was being modified

Yentl Van Tendeloo 8 years ago
parent
commit
0a73cc09fa

+ 4 - 1
bootstrap/conformance_finding.alc

@@ -16,6 +16,7 @@ Boolean function find_type_mapping(model : Element):
 	String elem
 
 	tm = get_type_mapping_as_dict(model)
+	log("Got type mapping: " + cast_e2s(tm))
 
 	// 1) remove elements from type mapping that are not in the model or metamodel
 	elems = dict_keys(tm)
@@ -31,7 +32,6 @@ Boolean function find_type_mapping(model : Element):
 		
 	// 2) find a mapping based on the current partial mapping, but only if it is not yet complete
 	if (dict_len(model["model"]) > dict_len(tm)):
-		log("Searching for model type!")
 
 		// TODO for now, this only returns something for a simple case, where the MM has one edge, and one node
 		//      and it makes the assumption that SCD is the M3 level...
@@ -61,6 +61,9 @@ Boolean function find_type_mapping(model : Element):
 						return False!
 					edge_element = elem
 
+		if (bool_or(element_eq(node_element, read_root()), element_eq(edge_element, read_root()))):
+			return False!
+
 		// Now we have bot an edge_element and node_element of the metamodel
 		// Now just trivially bind all elements!
 		elems = dict_keys(model["model"])

+ 14 - 2
bootstrap/core_algorithm.alc

@@ -43,6 +43,7 @@ String function get_instanceOf_link(model_id : String, metamodel_id : String):
 	if (set_len(all_links) > 1):
 		log("WARNING: multiple instanceOf relations were detected for this model; picking one at random!")
 	elif (set_len(all_links) == 0):
+		log("No types found!")
 		return read_root()!
 	
 	choice = set_pop(all_links)
@@ -71,6 +72,7 @@ Element function get_full_model(model_id : String, metamodel_id : String):
 		Element mm
 		mm = get_full_model(metamodel_id, get_model_id("SimpleClassDiagrams"))
 		if (element_eq(mm, read_root())):
+			log("Metamodel is broken!")
 			return read_root()!
 		else:
 			dict_add(m, "metamodel", mm)
@@ -79,6 +81,8 @@ Element function get_full_model(model_id : String, metamodel_id : String):
 		if (set_len(allAssociationDestinations(core, choice, "typing")) == 1):
 			// Add the preferred original type mapping
 			dict_add(m, "type_mapping", import_node(read_attribute(core, set_pop(allAssociationDestinations(core, choice, "typing")), "location")))
+			log("Imported type mapping with ID " + cast_e2s(m["type_mapping"]))
+			log("Location was: " + cast_e2s(read_attribute(core, set_pop(allAssociationDestinations(core, choice, "typing")), "location")))
 		else:
 			// Start from scratch
 			dict_add(m, "type_mapping", new_type_mapping())
@@ -90,6 +94,7 @@ Element function get_full_model(model_id : String, metamodel_id : String):
 		// TODO store the found type model somewhere
 		return m!
 	else:
+		log("No type mapping could be deduced!")
 		return read_root()!
 
 Integer function get_relation_to_model(user_id : String, model_id : String):
@@ -275,6 +280,7 @@ String function export_typing(model : Element, name : String, user_id : String):
 	String location
 	location = "type_mappings/" + cast_id2s(model["type_mapping"])
 	export_node(location, model["type_mapping"])
+	log("Export typing information to " + location)
 
 	String instance_of
 	instantiate_attribute(core, result, "name", "TM_" + name)
@@ -1217,7 +1223,12 @@ String function transformation_add(user_id : String, source_models : Element, ta
 
 		if (operation_type == "manual"):
 			// Finished with all information, now create the model itself!
-			model_create(instantiate_model(get_full_model(get_model_id("ManualOperation"), get_model_id("SimpleClassDiagrams"))), operation_name, user_id, get_model_id("ManualOperation"), "ManualOperation")
+			Element m
+			m = get_full_model(get_model_id("ManualOperation"), get_model_id("SimpleClassDiagrams"))
+			if (element_eq(m, read_root())):
+				log("Error when opening ManualOperation: no conformance relation found")
+				return "Error when opening ManualOperation: no conformance relation found"!
+			model_create(instantiate_model(m), operation_name, user_id, get_model_id("ManualOperation"), "ManualOperation")
 			model_id = get_model_id(operation_name)
 
 		elif (operation_type == "actionlanguage"):
@@ -1255,7 +1266,7 @@ String function transformation_add(user_id : String, source_models : Element, ta
 				key = set_pop(keys)
 				link = instantiate_link(core, "transformOutput", "", model_id, target[key])
 				instantiate_attribute(core, link, "name", key)
-				
+			
 		return "Success"!
 	else:
 		return "Model exists: " + operation_name!
@@ -1782,6 +1793,7 @@ Void function user_function_skip_init(user_id : String):
 
 	while (True):
 		cmd = input()
+		log("Executing " + cmd)
 		if (cmd == "help"):
 			output(cmd_help(user_id))
 		elif (cmd == "model_add"):

+ 2 - 0
bootstrap/semi_primitives.alc

@@ -73,12 +73,14 @@ Element function set_pop(a : Element):
 		log("Value: " + cast_v2s(result))
 		return result!
 	else:
+		log("Set pop on empty set!")
 		return read_root()!
 
 Element function set_read(a : Element):
 	if (integer_gt(set_len(a), 0)):
 		return read_edge_dst(read_out(read_out(a, 0), 0))!
 	else:
+		log("Set read on empty set!")
 		return read_root()!
 
 Void function sleep(a : Float):

+ 2 - 1
hybrid_server/classes/mvkcontroller.xml

@@ -290,7 +290,7 @@
 
                         <transition cond="self.new_tasks" target="../create_SC"/>
                         <transition cond="not self.new_tasks and self.old_tasks" target="../remove_SC"/>
-                        <transition after="1" target="."/>
+                        <transition after="0.01" target="."/>
                     </state>
 
                     <state id="create_SC" initial="creating">
@@ -334,6 +334,7 @@
                                 <parameter expr="self.sc_map[task]"/>
                             </raise>
                             <script>
+                                print("Delete task")
                                 del self.sc_map[task]
                             </script>
                         </transition>

+ 1 - 1
hybrid_server/classes/task.xml

@@ -147,7 +147,7 @@
                                     </script>
                                 </onentry>
 
-                                <transition after="self.sccd_yield() + 0.05" target="."/>
+                                <transition after="self.sccd_yield() + 0.1" target="."/>
                             </state>
                         </state>
                     </parallel>