Sfoglia il codice sorgente

First part of code for FSA semantics implementation

Yentl Van Tendeloo 8 anni fa
parent
commit
d93ed39c51
1 ha cambiato i file con 24 aggiunte e 1 eliminazioni
  1. 24 1
      integration/code/fsa_semantics.alc

+ 24 - 1
integration/code/fsa_semantics.alc

@@ -115,6 +115,28 @@ Integer function list_index_of(lst : Element, elem : Element):
 			i = i + 1
 	return -1!
 
+Void function do_transition(model : Element, start_time : Float, event : String):
+	// Read out current state
+	String cstate_link
+	String cstate
+	cstate_link = set_pop(allInstances(model, "CurrentStateLink"))
+	cstate = readAssociationDestination(model, cstate_link)
+
+	// Read out all outgoing transitions
+	Element all_transitions
+	all_transitions = allOutgoingAssociationInstances(model, cstate, "Transition")
+
+	while (read_nr_out(all_transitions) > 0):
+		if (value_eq(read_attribute(model, cstate, "event"), event)):
+			// Found a match
+			model_delete_element(model, cstate_link)
+			// TODO
+			// Set destination of state
+			// Raise "raise" attribute of transition
+			return !
+
+	return!
+
 Void function execute_fsa(design_model : Element):
 	String verify_result
 	Element runtime_model
@@ -130,6 +152,7 @@ Void function execute_fsa(design_model : Element):
 	old_runtime_model = instantiate_model(import_node("models/FiniteStateAutomata_Runtime"))
 	runtime_model = retype_to_runtime(design_model)
 	runtime_model = sanitize(runtime_model, old_runtime_model)
+
 	conforming = conformance_scd(design_model)
 	if (conforming == "OK"):
 		output("CONFORMANCE_OK")
@@ -155,7 +178,7 @@ Void function execute_fsa(design_model : Element):
 			String evt
 			evt = input()
 
-			transition(runtime_model, start_time, evt)
+			do_transition(runtime_model, start_time, evt)
 			
 		elif (cmd == "read_available_attributes"):
 			// Returns a list of all available attributes