瀏覽代碼

Updated test_SCCD for new SCCD execution, fixing use of input and output events

Yentl Van Tendeloo 8 年之前
父節點
當前提交
9f2012b5bb
共有 2 個文件被更改,包括 29 次插入11 次删除
  1. 12 4
      models/SCCD_execute.alc
  2. 17 7
      wrappers/test_SCCD.py

+ 12 - 4
models/SCCD_execute.alc

@@ -6,6 +6,8 @@ include "random.alh"
 include "library.alh"
 include "io.alh"
 
+Boolean afap = False
+
 Element function resolve_function(location : String, data : Element):
 	if (bool_not(dict_in(data["cache_operations"], location))):
 		dict_add(data["cache_operations"], location, get_func_AL_model(import_node(location)))
@@ -340,6 +342,16 @@ Void function process_raised_event(model : Element, event : Element, parameter_a
 	elif (scope == "output"):
 		// Store it in the output event model
 		String evt
+
+		if (bool_not(afap)):
+			Element val
+			val = dict_create()
+			dict_add(val, "timestamp", data["time_sim"])
+			dict_add(val, "name", read_attribute(model, event, "event"))
+			dict_add(val, "parameter", parameter_action)
+
+			output("EVENT: " + dict_to_string(val))
+
 		evt = instantiate_node(model, "trace/Event", "")
 		instantiate_attribute(model, evt, "timestamp", data["time_sim"])
 		instantiate_attribute(model, evt, "name", read_attribute(model, event, "event"))
@@ -736,10 +748,6 @@ Boolean function main(model : Element):
 	time_sim = 0.0
 	dict_add(data, "time_sim", 0.0)
 
-	Boolean afap
-	// NOTE this can be changed to True for testing
-	afap = False
-
 	// Prepare for input
 	output("Ready for input!")
 

+ 17 - 7
wrappers/test_SCCD.py

@@ -7,21 +7,31 @@ login("admin", "admin")
 
 # Assume that we don't change the SCCD MM
 try:
-    model_add("SCCD", "SimpleClassDiagrams", open("models/SCCD.mvc", 'r').read())
+    model_add("formalisms/SCCD", "formalisms/SimpleClassDiagrams", open("models/SCCD.mvc", 'r').read())
+except ModelExists:
+    pass
+
+try:
+    model_add("formalisms/SCCD_Trace", "formalisms/SimpleClassDiagrams", open("models/SCCD_Trace.mvc", 'r').read())
 except ModelExists:
     pass
 
 # Update the model of the traffic light
-if "my_SCCD" in [i[0] for i in model_list()]:
-    model_delete("my_SCCD")
-model_add("my_SCCD", "SCCD", open("models/dynamic_trafficlight.mvc", 'r').read())
+if "my_SCCD" in [i[0] for i in model_list("models")]:
+    model_delete("models/my_SCCD")
+#model_add("models/my_SCCD", "formalisms/SCCD", open("models/dynamic_trafficlight.mvc", 'r').read())
+model_add("models/my_SCCD", "formalisms/SCCD", open("integration/code/SCCD_all.mvc", 'r').read())
 
 # Add SCCD execution semantics
-transformation_add_AL({"SCCD": "SCCD"}, {}, "SCCD_execute", open("models/SCCD_execute.alc", 'r').read())
+transformation_add_AL({"SCCD": "formalisms/SCCD"}, {"trace": "formalisms/SCCD_Trace"}, "models/SCCD_execute", open("models/SCCD_execute.alc", 'r').read())
 
 # Execute it, while interacting through the console
 def callback(inp):
     print(inp)
-    return raw_input()
+    inp = raw_input()
+    if inp == "":
+        return None
+    else:
+        return inp
 
-transformation_execute_AL("SCCD_execute", {"SCCD": "my_SCCD"}, {}, callback=callback)
+transformation_execute_AL("models/SCCD_execute", {"SCCD": "models/my_SCCD"}, {"trace": "models/my_trace"}, callback=callback)