Yentl Van Tendeloo преди 8 години
родител
ревизия
22634df961
променени са 2 файла, в които са добавени 18 реда и са изтрити 19 реда
  1. 14 19
      integration/code/fsa_semantics.alc
  2. 4 0
      interface/FSA/main.py

+ 14 - 19
integration/code/fsa_semantics.alc

@@ -97,12 +97,17 @@ Void function do_transition(model : Element, start_time : Float, event : String)
 		transition = set_pop(all_transitions)
 		if (value_eq(read_attribute(model, transition, "event"), event)):
 			// Found a match
+			new_state = readAssociationDestination(model, transition)
+			log("Transition to " + new_state)
+
+			// Delete current state
 			model_delete_element(model, cstate_link)
 
 			// Set destination of state
 			instantiate_link(model, "CurrentStateLink", "", cstate_obj, new_state)
 
-			output("SIM_STATE " + cast_v2s(new_state))
+			log("Do state change")
+			output("SIM_STATE " + cast_v2s(read_attribute(model, new_state, "name")))
 
 			// Raise "raise" attribute of transition
 			raise = read_attribute(model, transition, "raise")
@@ -139,22 +144,10 @@ Void function execute_fsa(design_model : Element):
 		output("CONFORMANCE_FAIL")
 
 	while (True):
-		if (has_input()):
-			cmd = input()
-		else:
-			if (bool_and(conforming == "OK", running)):
-				cmd = "skip"
-			else:
-				cmd = input()
+		cmd = input()
 		log("Do: " + cmd)
 
-		// Process input
-		if (cmd == "skip"):
-			if (conforming == "OK"):
-				output("SIM_TIME " + cast_v2s(time() - start_time))
-				output("SIM_STATE " + cast_v2s(readAssociationDestination(runtime_model, set_pop(allInstances(runtime_model, "CurrentStateLink")))))
-			
-		elif (cmd == "pause"):
+		if (cmd == "pause"):
 			// Pausing merely stops a running simulation
 			if (running):
 				simulation_time = time() - start_time
@@ -172,10 +165,8 @@ Void function execute_fsa(design_model : Element):
 			automatic_sanitization = input()
 
 		elif (cmd == "event"):
-			String evt
-			evt = input()
-
-			do_transition(runtime_model, start_time, evt)
+			log("Got event")
+			do_transition(runtime_model, start_time, input())
 
 		elif (cmd == "read_available_attributes"):
 			// Returns a list of all available attributes
@@ -248,6 +239,10 @@ Void function execute_fsa(design_model : Element):
 		else:
 			log("Did not understand command: " + cmd)
 
+		if (conforming == "OK"):
+			output("SIM_TIME " + cast_v2s(time() - start_time))
+			output("SIM_STATE " + cast_v2s(read_attribute(runtime_model, readAssociationDestination(runtime_model, set_pop(allInstances(runtime_model, "CurrentStateLink"))), "name")))
+
 Void function main():
 	Element model
 	String verify_result

+ 4 - 0
interface/FSA/main.py

@@ -202,6 +202,7 @@ class MvLayer():
         urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"pause"', "username": username}))).read()
 
     def send_event(self, event):
+        print("SENDING EVENT")
         urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"event"', "username": username}))).read()
         urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"%s"' % (event), "username": username}))).read()
 
@@ -487,6 +488,9 @@ def update_graphs():
         lookup[v] = k
     a_state.clear()
     a_state.plot(times, events, linestyle="solid", marker="o", drawstyle="steps-post")
+    print("Lookup: " + str(lookup))
+    print("Reverse lookup: " + str(reverse_lookup_state))
+    print("Events: " + str(events))
     #f_state.get_axes()[0].set_xbound(lower=0.0, upper=10.0)
     f_state.get_axes()[0].set_yticks(range(-2, len(lookup) + 2))
     f_state.get_axes()[0].set_yticklabels(["", ""] + lookup + ["", ""])