Browse Source

PN interface works mostly again (no model manipulation operations yet)

Yentl Van Tendeloo 9 years ago
parent
commit
8815bf7fbb

+ 1 - 0
bootstrap/modelling.alc

@@ -1,5 +1,6 @@
 include "primitives.alh"
 include "io.alh"
+include "object_operations.alh"
 
 String function instantiated_name(element : Element, original : String):
 	if (original == ""):

+ 19 - 19
integration/code/pn_interface.alc

@@ -71,7 +71,7 @@ Element function petrinet_fire(model : Element):
 			while (0 < read_nr_out(workset)):
 				working_arc = set_pop(workset)
 				working_place = read_edge_src(working_arc)
-				setAttribute(model, working_place, "tokens", integer_subtraction(readAttribute(model, working_place, "tokens"), readAttribute(model, working_arc, "weight")))
+				//setAttribute(model, working_place, "tokens", integer_subtraction(readAttribute(model, working_place, "tokens"), readAttribute(model, working_arc, "weight")))
 				output((("  " + getName(model, working_place)) + ": ") + cast_i2s(readAttribute(model, working_place, "tokens")))
 
 			// Add tokens
@@ -79,7 +79,7 @@ Element function petrinet_fire(model : Element):
 			while (0 < read_nr_out(workset)):
 				working_arc = set_pop(workset)
 				working_place = read_edge_dst(working_arc)
-				setAttribute(model, working_place, "tokens", integer_addition(readAttribute(model, working_place, "tokens"), readAttribute(model, working_arc, "weight")))
+				//setAttribute(model, working_place, "tokens", integer_addition(readAttribute(model, working_place, "tokens"), readAttribute(model, working_arc, "weight")))
 				output((("  " + getName(model, working_place)) + ": ") + cast_i2s(readAttribute(model, working_place, "tokens")))
 			output("Transition fired!")
 		else:
@@ -168,21 +168,21 @@ Element function petrinet_loaded(model : Element):
 						else:
 							output("Unknown source; aborting")
 							cnt = False
-					if (type_eq(typeof(metamodel_element_pn), Type)):
+					if (has_value(metamodel_element_pn)):
 						// It is a value
 						output("Value?")
 						list_append(additional_opts, input())
 					if (cnt):
-						attr_list_pn = getAttributeList(model, metamodel_element_pn)
-						attr_keys_pn = dict_keys(attr_list_pn)
-						Element attrs
-						attrs = create_node()
-						while (0 < read_nr_out(attr_keys_pn)):
-							attr_key_pn = set_pop(attr_keys_pn)
-							output(((attr_key_pn + " : ") + cast_t2s(attr_list_pn[attr_key_pn])) + "?")
-							dict_add(attrs, attr_key_pn, input())
-						Element resulting_element
-						resulting_element = instantiate_model_lib(model, metamodel_element_pn, element_name, additional_opts, create_node(), attrs)
+						//attr_list_pn = getAttributeList(model, metamodel_element_pn)
+						//attr_keys_pn = dict_keys(attr_list_pn)
+						//Element attrs
+						//attrs = create_node()
+						//while (0 < read_nr_out(attr_keys_pn)):
+						//	attr_key_pn = set_pop(attr_keys_pn)
+						//	output(((attr_key_pn + " : ") + cast_e2s(attr_list_pn[attr_key_pn])) + "?")
+						//	dict_add(attrs, attr_key_pn, input())
+						//Element resulting_element
+						//resulting_element = instantiate_model_lib(model, metamodel_element_pn, element_name, additional_opts, create_node(), attrs)
 						output("Instantiation successful!")
 			else:
 				output("Unknown type specified; aborting")
@@ -206,14 +206,14 @@ Element function petrinet_loaded(model : Element):
 				attr_keys_pn = dict_keys(attr_list_pn)
 				while (0 < read_nr_out(attr_keys_pn)):
 					attr_key_pn = set_pop(attr_keys_pn)
-					output((("   " + attr_key_pn) + " : ") + cast_t2s(attr_list_pn[attr_key_pn]))
+					output((("   " + attr_key_pn) + " : ") + cast_e2s(attr_list_pn[attr_key_pn]))
 
 				output("Attribute to modify?")
 				String attr_name
 				attr_name = input()
 				if (set_in(dict_keys(getAttributeList(model, metamodel_element_pn)), attr_name)):
 					output("New value?")
-					setAttribute(model, mod, attr_name, input())
+					//setAttribute(model, mod, attr_name, input())
 					output("Modified!")
 				else:
 					output("Unknown attribute; aborting")
@@ -266,13 +266,13 @@ Element function petrinet_loaded(model : Element):
 				attr_keys_pn = dict_keys(attr_list_pn)
 				while (0 < read_nr_out(attr_keys_pn)):
 					attr_key_pn = set_pop(attr_keys_pn)
-					output(((("   " + attr_key_pn) + " : ") + cast_t2s(attr_list_pn[attr_key_pn])))
+					output(((("   " + attr_key_pn) + " : ") + cast_e2s(attr_list_pn[attr_key_pn])))
 				output("Attributes:")
 				attr_list_pn = getAttributeList(model, metamodel_element_pn)
 				attr_keys_pn = dict_keys(attr_list_pn)
 				while (0 < read_nr_out(attr_keys_pn)):
 					attr_key_pn = set_pop(attr_keys_pn)
-					output((((("   " + attr_key_pn) + " : ") + cast_t2s(attr_list_pn[attr_key_pn])) + " = ") + cast_v2s(readAttribute(model, read_elem, attr_key_pn)))
+					output((((("   " + attr_key_pn) + " : ") + cast_e2s(attr_list_pn[attr_key_pn])) + " = ") + cast_v2s(readAttribute(model, read_elem, attr_key_pn)))
 			else:
 				output("Unknown element; aborting")
 		elif (cmd == "verify"):
@@ -362,8 +362,8 @@ Element function initial_prompt():
 				if (dict_in(root, name)):
 					output("Model exists; aborting")
 				else:
-					my_model = instantiate_new_model(root[mm_name], create_node())
-					dict_add(root, name, my_model)
+					//my_model = instantiate_new_model(root[mm_name], create_node())
+					//dict_add(root, name, my_model)
 					petrinet_loaded(my_model)
 			else:
 				output("Unknown metamodel; aborting")

+ 0 - 1
interface/HUTN/includes/object_operations.alh

@@ -4,7 +4,6 @@ Element function allIncomingAssociationInstances(a: Element, b: Element, c: Elem
 Element function readElementByName(a: Element, b: String)
 Element function findAttribute(a: Element, b: Element, c: Element, d: Element)
 Element function readAttribute(a: Element, b: Element, c: String)
-Element function setAttribute(a: Element, b: Element, c: String, d: Element)
 Element function deleteAttribute(a: Element, b: Element, c: Element)
 Element function getAttributeList(a: Element, b: Element)
 Element function getInstantiatableAttributes(a: Element, b: Element)