Procházet zdrojové kódy

Added a timer in the FSA logic

Yentl Van Tendeloo před 8 roky
rodič
revize
f414fef9fe
3 změnil soubory, kde provedl 15 přidání a 1 odebrání
  1. 5 0
      models/fsa_full_runtime.mvc
  2. 8 0
      models/fsa_merge.alc
  3. 2 1
      models/fsa_simulate.alc

+ 5 - 0
models/fsa_full_runtime.mvc

@@ -2,6 +2,11 @@ include "primitives.alh"
 
 Class String {}
 Class Boolean {}
+Class Float {}
+
+Class Time {
+    current_time : Float
+}
 
 Class State {
     name = "State"

+ 8 - 0
models/fsa_merge.alc

@@ -32,10 +32,18 @@ Boolean function main(model : Element):
 		// No execution in full runtime, so just flag the initial state
 		flag_initial = True
 		log("Searching for new initial state...")
+
+		// And add a new time
+		element_name = instantiate_node(model, "NewFullRuntime/Time", "")
+		instantiate_attribute(model, element_name, "current_time", 0.0)
 	else:
 		flag_initial = False
 		log("No searching for state!")
 
+		// Copy the time though
+		element_name = instantiate_node(model, "NewFullRuntime/Time", "")
+		instantiate_attribute(model, element_name, "current_time", read_attribute(model, set_pop(allInstances(model, "FullRuntime/Time")), "current_time"))
+
 	all_states = allInstances(model, "PartialRuntime/State")
 	while (set_len(all_states) > 0):
 		element_name = set_pop(all_states)

+ 2 - 1
models/fsa_simulate.alc

@@ -14,7 +14,7 @@ Boolean function main(model : Element):
 	Element transitions
 	String transition
 
-	start_time = time()
+	start_time = time() - cast_float(read_attribute(model, set_pop(allInstances(model, "FullRuntime/Time")), "current_time"))
 
 	Element all_states
 	String element_name
@@ -55,4 +55,5 @@ Boolean function main(model : Element):
 	
 	instantiate_attribute(model, current_state, "current", True)
 	instantiate_attribute(model, old_state, "current", True)
+	instantiate_attribute(model, set_pop(allInstances(model, "FullRuntime/Time")), "current_time", time() - start_time)
 	return True!