Browse Source

Created get set state test

Casper Thule 3 years ago
parent
commit
3f45f8d5f3

+ 5 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppBasicTest.xtend

@@ -64,6 +64,11 @@ class CgCppBasicTest extends AbstractSemanticAdaptationTest {
 			"powerwindow");
 	}
 
+	@Test def getSetState_sa() {
+		__parseNoErrors('test_input/single_folder_spec/getsetstate/GetSetState.sa', 'generated',
+			"getSetState");
+	}
+
 	@Test def lazy_canonical() {
 		__parseNoErrors('test_input/single_folder_spec/lazy/lazy_canonical.sa', 'generated', "lazy");
 	}

BIN
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/getsetstate/GetSetState.fmu


+ 42 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/getsetstate/GetSetState.sa

@@ -0,0 +1,42 @@
+semantic adaptation reactive mealy GetSetStateSA getSetStateSA
+at "./path/to/GetSetStateSA.fmu"
+
+	for inner fmu GetSetState getSetState
+		at "test_input/single_folder_spec/getsetstate/GetSetState.fmu"
+		with input ports valve
+		with output ports level
+
+input ports 	valve
+
+output ports	level
+
+control rules {
+	save_state(getSetState);
+	var H_getSetState := do_step(getSetState, t, H);
+	if(dt < 1.0 and dt > 0.5)
+	{	
+		rollback(getSetState);
+	}
+	return H_getSetState;
+}
+
+in var 	stored_getsetstatesa_valve := false;
+
+in rules {
+	true -> {
+		stored_getsetstatesa_valve := getSetStateSA.valve;
+	} --> {
+		getSetState.valve := stored_getsetstatesa_valve;
+	};
+}
+
+out var stored_getsetstatesa_level := 1.0;
+
+out rules {
+	true -> {
+		stored_getsetstatesa_level := getSetState.level;
+	} --> {
+		getSetStateSA.level := stored_getsetstatesa_level;
+	};
+	
+}