Browse Source

merged test folder testInput with input to have just one;
removed tests which were out-dated;
do_step returns the step taken, so it can be used in an expression and not just a procedure;

Cláudio Gomes 4 years ago
parent
commit
d24fbaa8bb
38 changed files with 215 additions and 572 deletions
  1. 0 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/input/single_folder_spec/window/Window.fmu
  2. 0 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/input/single_folder_spec/window/modelDescription.xml
  3. 2 2
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/window/window_sa_canonical.BASE.sa
  4. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppAutoTest.xtend
  5. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppBasicTest.xtend
  6. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppBasicTest2.xtend
  7. 2 2
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppModuleTest.xtend
  8. 0 63
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/controller_sa.sa
  9. 0 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/inter_module_powerwindow/powerwindow_inline.sa
  10. 0 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/inter_module_powerwindow/powerwindow_model_only.sa
  11. 0 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/inter_module_powerwindow/powerwindow_multi_rate.sa
  12. 0 25
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/plant.sa
  13. 123 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/controller_sa_commented.sa
  14. 8 6
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/loop.sa
  15. 14 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/power.BASE.sa
  16. 38 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/rate.sa
  17. 2 2
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_obstacle_sa_flat.BASE.sa
  18. 2 2
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_sa.BASE.sa
  19. 13 7
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_sa_canonical.BASE.sa
  20. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_sa_canonical_commented.BASE.sa
  21. 0 34
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow.sa
  22. 0 24
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_algebraic_loop_delay_BASE.sa
  23. 0 19
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_algebraic_loop_iteration.sa
  24. 0 111
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_algebraic_loop_iteration_BASE.sa
  25. 0 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/single_folder_spec/window/powerwindow_algebraic_loop_delay.sa
  26. 0 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/single_folder_spec/window/powerwindow_controller_delay.sa
  27. 0 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/single_folder_spec/window/powerwindow_model_only.sa
  28. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/testInputs/single_folder_spec/window2/window_sa_canonical.BASE.sa
  29. 0 31
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/test1.sa
  30. 0 24
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/window_obstacle_sa_loop_BASE.sa
  31. 0 28
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/window_obstacle_sa_loop_BASE_new.sa
  32. 0 18
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/window_obstacle_sa_multirate_BASE.sa
  33. 0 28
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/window_obstacle_sa_multirate_BASE_new.sa
  34. 0 99
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/src/be/uantwerpen/ansymo/semanticadaptation/tests/SemanticAdaptationParsingTest.xtend
  35. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/src/be/uantwerpen/ansymo/semanticadaptation/tests/SingleFolderTest.xtend
  36. 0 13
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/testInputs/single_folder_spec/window/powerwindow_algebraic_loop_delay.sa
  37. 0 23
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/testInputs/single_folder_spec/window/powerwindow_controller_delay.sa
  38. 5 5
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/SemanticAdaptation.xtext

DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/window/Window.fmu → DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/input/single_folder_spec/window/Window.fmu


DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/window/modelDescription.xml → DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/input/single_folder_spec/window/modelDescription.xml


+ 2 - 2
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/window/window_sa_canonical.BASE.sa

@@ -4,7 +4,7 @@ semantic adaptation reactive mealy WindowSA windowSA
 at "./path/to/WindowSA.fmu"
 
 	for inner fmu Window window
-		at "test_input/single_folder_spec/window/Window.fmu"
+		at "input/single_folder_spec/window/Window.fmu"
 		with input ports displacement (rad), speed (rad/s), reaction_force (N)
 		with output ports height (m), reaction_torque (N.m)
 
@@ -21,7 +21,7 @@ output ports	disp,
 				tau
 
 
-control {
+control rules {
 	do_step(window, t, H); // includes update_in rules and update_out (update-in rules do not update state)
 	return H;
 }

+ 1 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppAutoTest.xtend

@@ -44,7 +44,7 @@ class CgCppAutoTest extends AbstractSemanticAdaptationTest {
 	@Parameters(name = "{index}")
 	def static Collection<Object[]> data() {
 		val files = new ArrayList<List<File>>();
-		listf("test_input/single_folder_spec", files);
+		listf("input/single_folder_spec", files);
 		val test = new ArrayList();
 		test.add(files.get(0));
 		//val test2 = new ArrayList();

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

@@ -30,7 +30,7 @@ class CgCppBasicTest extends AbstractSemanticAdaptationTest {
 	@Inject extension  ValidationTestHelper
 
 	
-	@Test def powerwindow_model_only() { __parseNoErrors('test_input/single_folder_spec/window/window_sa_canonical.BASE.sa') }
+	@Test def powerwindow_model_only() { __parseNoErrors('input/single_folder_spec/window/window_sa_canonical.BASE.sa') }
 
 	def __parseNoErrors(String filename) {
 		val model = __parse(filename)

+ 1 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppBasicTest2.xtend

@@ -30,7 +30,7 @@ class CgCppBasicTest2 extends AbstractSemanticAdaptationTest {
 	@Inject extension  ValidationTestHelper
 
 	@Ignore
-	@Test def powerwindow_model_only() { __parseNoErrors('test_input/window/window_sa_canonical.BASE.sa') }
+	@Test def powerwindow_model_only() { __parseNoErrors('input/window/window_sa_canonical.BASE.sa') }
 
 	def __parseNoErrors(String filename) {
 		val model = __parse(filename)

+ 2 - 2
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppModuleTest.xtend

@@ -33,14 +33,14 @@ class CgCppModuleTest extends AbstractSemanticAdaptationTest {
 	@Inject extension  ValidationTestHelper
 
 	@Ignore
-	@Test def powerwindow_model_only() { __parseNoErrors('test_input/single_folder_spec/window/window_sa_canonical.BASE.sa') }
+	@Test def powerwindow_model_only() { __parseNoErrors('input/single_folder_spec/window/window_sa_canonical.BASE.sa') }
 
 	def __parseNoErrors(String filename) {
 
 		val file = new File(filename)
 
 		assertTrue("File not found: " + filename, file.exists);
-
+		
 		var SemanticAdaptation model = null;
 		if (file.isDirectory) {
 			for (f : file.listFiles) {

+ 0 - 63
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/controller_sa.sa

@@ -1,63 +0,0 @@
-// outdated
-
-import PowerWindowModel
-
-module Controller_SA
-
-semantic adaptation controller_sa
-for fmu controller
-input ports armature_current -> obj_detected, passenger_up, passenger_down, driver_up, driver_down
-output ports up, down
-param REL_TOL = 0.0001;
-param ABS_TOL = 1e-8;
-param CROSSING = 5;
-param init_armature_current = CROSSING;
-param init_up = 0;
-param init_down = 0;
-control var internal_transition;
-control rules { // overwriting master! What to do in case of roll back? How to reuse generic algorithm
-	if (not is_set(internal_transition)) { // only at start of simulation
-		var state := get_state(controller);
-		internal_transition := do_step(controller, MAX) + t; // may return internal transition time or MAX
-		set_state(controller, state);
-	}
-	var step_size; // may be used to determine roll-back
-	if (signal == true or t >= internal_transition) {
-		step_size := do_step(controller, H); // do a step, then decide next internal transition
-		var state := get_state(controller);
-		internal_transition := do_step(controller, MAX) + t;
-		set_state(controller, state);
-	}
-	return step_size;
-}
-in var stored_armature_current := init_armature_current;
-in rules {
-	true -> {
-		obj_detected := false;
-		if (not (not is_close(stored_armature_current, CROSSING, REL_TOL, ABS_TOL) and stored_armature_current > CROSSING)
-					and (not is_close(armature_current, CROSSING, REL_TOL, ABS_TOL) and armature_current > CROSSING)) { // crossing, but not within tolerance
-			var negative_value := stored_armature_current - CROSSING;
-			var positive_value := armature_current - CROSSING;
-			var new_step_size := (H * (- negative_value)) / (positive_value - negative_value);
-			discard(new_step_size);
-		} else {
-			if (not (not is_close(stored_armature_current, CROSSING, REL_TOL, ABS_TOL) and stored_armature_current > CROSSING)
-						and is_close(armature_current, CROSSING, REL_TOL, ABS_TOL)) { // crossing within tolerance found
-				obj_detected := true;
-			}
-		}
-		stored_armature_current := armature_current;
-	} --> { };
-}
-out var stored_up := init_up;
-out var stored_down := init_down;
-out rules {
-	up == true -> { up := 1; } --> { };
-	otherwise up -> { } --> { };
-	down == true -> { down := 1; } --> { };
-	otherwise down -> { } --> { };
-	stop == true -> { up := 0; down := 0; } --> { };
-	otherwise stop -> { } --> { };
-	true -> { up := stored_up; stored_up := up; } --> { };
-	true -> { down := stored_down; stored_down := down; } --> { }; 
-}

DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_inline.sa → DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/inter_module_powerwindow/powerwindow_inline.sa


DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_model_only.sa → DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/inter_module_powerwindow/powerwindow_model_only.sa


DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_multi_rate.sa → DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/inter_module_powerwindow/powerwindow_multi_rate.sa


+ 0 - 25
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/plant.sa

@@ -1,25 +0,0 @@
-// outdated
-
-semantic adaptation power_sa
-for continuous time
-input ports up, down, reaction_torque
-output ports armature_current, motor_speed
-in rules {} // needs to be detected exactly when reaction_torque starts to change rapidly -> zero crossing on derivative abs(reaction_torque') >! 100
-out rules {}
-control rules {}
-
-semantic adaptation window_sa
-for continuous time
-input ports motor_speed
-output ports height, window_reaction_torque
-in rules {}
-out rules {}
-control rules {}
-
-semantic adaptation obstacle_sa
-for continuous time
-input ports height
-output ports obstacle_reaction_torque
-in rules {}
-out rules {}
-control rules {}

+ 123 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/controller_sa_commented.sa

@@ -0,0 +1,123 @@
+module Controller_SA
+
+semantic adaptation reactive moore ControllerSA controller_sa
+at "./path/to/ControllerSA.fmu"
+
+	for inner fmu Controller controller
+	at "./path/to/Controller.fmu"
+	with input ports obj_detected, passenger_up, passenger_down, passenger_stop, driver_up, driver_down, driver_stop
+	with output ports up, down, stop
+
+/*
+At some point in the future, we support for simple wildcars in the input ports.
+According to Casper and Kenneth, some FMUs have thousands of ports...
+*/
+input ports armature_current -> controller.obj_detected, 
+			passenger_up -> controller.passenger_up, // You could write passenger_* here.
+			passenger_down -> controller.passenger_down,
+			passenger_stop -> controller.passenger_stop,
+			driver_up -> controller.driver_up, // You could write driver_* here.
+			driver_down -> controller.driver_down,
+			driver_stop -> controller.driver_stop
+
+output ports	u,
+				d
+
+param	REL_TOL := 0.0001,
+		ABS_TOL := 1e-8,
+		CROSSING := 5.0,
+		INIT_ARMATURE_CURRENT := 0.0,
+		INIT_U := 0.0,
+		INIT_D := 0.0;
+
+control var	aux_obj_detected := 0,
+			get_next_step := true,
+			previous_arm_current := INIT_ARMATURE_CURRENT;
+control rules {
+	var step_size := H;
+	aux_obj_detected := false;
+	if ((not is_close(previous_arm_current, CROSSING, REL_TOL, ABS_TOL) and previous_arm_current < CROSSING)
+				and (not is_close(future_arm_current, CROSSING, REL_TOL, ABS_TOL) and future_arm_current > CROSSING)) { // crossing, but not within tolerance
+		var negative_value := previous_arm_current - CROSSING;
+		var positive_value := future_arm_current - CROSSING;
+		step_size := (H * (- negative_value)) / (positive_value - negative_value);
+	} else {
+		if ((not is_close(previous_arm_current, CROSSING, REL_TOL, ABS_TOL) and previous_arm_current < CROSSING)
+					and is_close(future_arm_current, CROSSING, REL_TOL, ABS_TOL )) { // crossing within tolerance found
+			aux_obj_detected := true;
+		}
+	}
+	
+	if (aux_obj_detected == true or t >= next_time_step) {
+		var aux_h := do_step(controller, t-e, e); // do a step, then decide next internal transition
+		//assert aux_h == e; this must always be the case, otherwise it is better not to use the timed transition adaptation.
+		get_next_step := true; // next time the setValues is called, the internal transition will be set again.
+	} else {
+		get_next_step := false;
+	}
+	if (is_close(step_size, H, REL_TOL, ABS_TOL)) {
+		// Step accepted, so store the known input.
+		// We cannot store the armature current at the in rules because we may not accept the step and because they may be called multiple times. 
+		// If that happens, we want to still have the old value of armature current, to compare it with the new one.
+		previous_arm_current := future_arm_current;
+	}
+	return step_size;
+}
+
+in var	next_time_step := -1.0,
+		future_arm_current := INIT_ARMATURE_CURRENT;
+in rules {
+	get_next_step -> {
+		next_time_step := get_next_time_step(controller) + last_execution_time(controller); 
+		/*
+		The get_next_time_step(controller) function is equivalent to the following snippet:
+		save_state(controller);
+		internal_transition := do_step(controller, last_execution_time(controller), MAX);
+		next_time_step := last_execution_time(controller) + internal_transition;
+		rollback(controller);
+		*/
+	} --> { };
+	
+	true -> {
+		future_arm_current := armature_current;
+	} --> {
+		obj_detected := aux_obj_detected; // Sets this input to the FMU 
+	};
+}
+
+out var stored_up := INIT_U,
+		stored_down := INIT_D;
+out rules {
+	true -> {
+		/*
+		Previously, there was this intruction here:
+		internal_transition := get_next_time_step(controller) + t
+		
+		However, it cannot be here, since there is no guarantee in the control rules block, that the doStep of the controller will be called.
+		*/
+	} --> {};
+	
+	/*
+	What does "otherwise var" mean?
+	Suppose I have the following rules:
+		var1 == true and var2 == false -> ...
+		otherwise var1 -> ...
+	
+	controller.up == true -> { stored_up := 1; } --> { };
+	otherwise up -> { } --> { }; 
+	down == true -> { down := 1; } --> { };
+	otherwise down -> { } --> { };
+	stop == true -> { up := 0; down := 0; } --> { };
+	otherwise stop -> { } --> { };
+	true -> { up := stored_up; stored_up := up; } --> { };
+	true -> { down := stored_down; stored_down := down; } --> { }; 
+	*/
+	controller.up -> {stored_up := 1; } --> {u := stored_up; };
+	not controller.up -> {stored_up := 0; } --> {u := stored_up; };
+	
+	controller.down -> {stored_down := 1; } --> {d := stored_down; };
+	not controller.down -> {stored_down := 0; } --> {d := stored_down; };
+	
+	controller.stop -> {stored_down := 0; stored_up :=0; } --> {u := stored_up ; d := stored_down; };
+	
+}

+ 8 - 6
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/loop.sa

@@ -1,6 +1,6 @@
 module Loop_SA
 
-semantic adaptation reactive mealy LoopSA adaptedFMU
+semantic adaptation reactive moore LoopSA loop_sa
 at "./path/to/LoopSA.fmu"
 
 	for inner fmu WindowSA window_sa
@@ -16,14 +16,15 @@ at "./path/to/LoopSA.fmu"
 	with window_sa.disp -> obstacle.disp
 	with obstacle.reaction_force -> window_sa.reaction_force
 
-output ports tau
+output ports tau (N.m) <- window_sa.tau
 
 param 	MAXITER := 10, 
 		REL_TOL := 1e-05, 
 		ABS_TOL := 1e-05;
 
-ctrl var prev_disp := 0.0;
-control {
+control var prev_disp := 0.0;
+control rules {
+	var repeat := false;
 	for (var iter in 0 .. MAXITER) {
 		save_state(obstacle);
 		save_state(window_sa);
@@ -31,10 +32,11 @@ control {
 		do_step(obstacle,t,H);
 		do_step(window_sa,t,H);
 		
-		if (is_close(prev_disp, window_sa.disp, REL_TOL, ABS_TOL)) {
+		repeat := is_close(prev_disp, window_sa.disp, REL_TOL, ABS_TOL);
+		prev_disp := window_sa.disp;
+		if (repeat) {
 			break;
 		} else {
-			prev_disp := window_sa.disp;
 			rollback(obstacle);
 			rollback(window_sa);
 		}

+ 14 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/power.BASE.sa

@@ -0,0 +1,14 @@
+module Power_SA
+
+semantic adaptation delayed moore PowerSA power_sa
+at "./path/to/PowerSA.fmu"
+
+	for inner fmu Power power
+	at "./path/to/Power.fmu"
+	with input ports u, d, tau (N.m)
+	with output ports armature_current (A), speed (rad/s), displacement (rad)
+
+output ports armature_current <- power.armature_current, 
+			speed <- power.speed,
+			displacement <- power.displacement
+

+ 38 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/rate.sa

@@ -0,0 +1,38 @@
+module Rate_SA
+
+semantic adaptation reactive moore RateSA rate_sa
+at "./path/to/RateSA.fmu"
+
+	for inner fmu LoopSA loop_sa
+		at "./path/to/LoopSA.fmu"
+		with input ports displacement (rad), speed (rad/s)
+		with output ports tau (N.m)
+	
+input ports speed
+output ports tau <- loop_sa.tau
+
+param 	RATE := 10;
+
+control var previous_speed := 0;
+control rules {
+	var micro_step := H/RATE;
+	var inner_time := t;
+	
+	for (var iter in 0 .. RATE) { 
+		do_step(loop_sa,inner_time,micro_step);
+		inner_time := inner_time + micro_step;	
+	}
+	
+	previous_speed := current_speed;
+	return H;
+}
+
+in var current_speed := 0;
+in rules {
+	true -> {
+		current_speed := speed;
+	} --> {
+		loop_sa.speed := previous_speed + (current_speed - previous_speed)*(dt + h);
+	};
+}
+

+ 2 - 2
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_obstacle_sa_flat.BASE.sa

@@ -31,8 +31,8 @@ param 	RATE := 10,
 		REL_TOL := 1e-05, 
 		ABS_TOL := 1e-05;
 
-ctrl var previous_speed := 0, future_speed := 0;
-control {
+control var previous_speed := 0, future_speed := 0;
+control rules {
 	var inner_dt := H/RATE;
 	/*
 	The two instructions below need to be made, because previously they were made in the sa_in block, but multiple calls to the sa_in block would make them fail.

+ 2 - 2
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_sa.BASE.sa

@@ -8,11 +8,11 @@ at "./path/to/WindowSA.fmu"
 		with input ports displacement (rad), speed (rad/s), reaction_force (N)
 		with output ports height (cm), reaction_torque (N.m)
 
-output ports disp (m)  <- height, tau
+output ports disp (m)  <- window.height, tau
 
 out rules {
 	true -> {} --> {
-		tau := -reaction_force;
+		tau := -window.reaction_force;
 	};
 }
 

+ 13 - 7
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_sa_canonical.BASE.sa

@@ -15,14 +15,20 @@ input ports 	reaction_force,
 output ports	disp,
 				tau
 
-control {
+param 	INIT_WINDOWSA_REACTION_FORCE := 0.0,
+		INIT_WINDOWSA_DISPLACEMENT := 0.0,
+		INIT_WINDOWSA_SPEED := 0.0,
+		INIT_WINDOW_REACTION_TORQUE := 0.0,
+		INIT_WINDOW_REACTION_HEIGHT := 0.0;
+
+control rules {
 	do_step(window, t, H);
 	return H;
 }
 
-in var 	stored_windowsa_reaction_force := 0.0, 
-		stored_windowsa_displacement := 0.0, 
-		stored_windowsa_speed := 0.0;
+in var 	stored_windowsa_reaction_force := INIT_WINDOWSA_REACTION_FORCE, 
+		stored_windowsa_displacement := INIT_WINDOWSA_DISPLACEMENT, 
+		stored_windowsa_speed := INIT_WINDOWSA_SPEED;
 
 in rules {
 	true -> {
@@ -36,9 +42,9 @@ in rules {
 	};
 }
 
-out var stored_window_reaction_torque := 0,
-		stored_window_height := 0;
-		
+out var stored_window_reaction_torque := INIT_WINDOW_REACTION_TORQUE,
+		stored_window_height := INIT_WINDOW_REACTION_HEIGHT;
+
 out rules {
 	true -> {
 		stored_window_reaction_torque := window.reaction_torque;

+ 1 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_sa_canonical_commented.BASE.sa

@@ -21,7 +21,7 @@ output ports	disp,
 				tau
 
 
-control {
+control rules {
 	do_step(window, t, H); // includes update_in rules and update_out (update-in rules do not update state)
 	return H;
 }

+ 0 - 34
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow.sa

@@ -1,34 +0,0 @@
-import PowerWindowModel
-
-semantic adaptation ArmatureCurrentSA armature_current_sa
-at "./path/to/ArmatureCurrentSA.fmu"
-for fmu controller
-triggered by signal == true
-in rules with crossing absolute tolerance = 1e-8 and relative tolerance = 0.0001, no hold {
-	armature_current >! 5 -> obj_detected := true;
-	otherwise -> obj_detected := false;
-}
-out rules with zero order hold {
-	"up" -> up := 1;
-	"stop" -> { up := 0; down := 0; };
-	"down" -> down := 1;
-	delay at up and down;
-}
-
-semantic adaptation WindowSA window_sa
-at "./path/to/WindowSA.fmu"
-for fmu window
-out rules {
-	reaction_torque := -reaction_torque;
-}
-
-semantic adaptation WindowObstacleSA window_obstacle_sa
-at "./path/to/WindowObstacleSA.fmu"
-for fmu window_sa, obstacle
-multiply rate 10 times with first order interpolation
-successive substitution starts at height with absolute tolerance = 1e-8 and relative tolerance = 0.0001
-
-semantic adaptation PlantSA plant_sa
-at "./path/to/PlantSA.fmu"
-for fmu power, window_obstacle_sa
-successive substitution starts at reaction_torque with absolute tolerance = 1e-6 and relative tolerance = 1e-6

+ 0 - 24
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_algebraic_loop_delay_BASE.sa

@@ -1,24 +0,0 @@
-import PowerWindowModel
-import Controller_SA
-
-// this one could be joined with the one below, if we assume certain priorities in executing the rules
-semantic adaptation WindowSA window_sa
-at "./path/to/WindowSA.fmu"
-for fmu window
-out rules {
-	true -> { } --> { reaction_torque := -reaction_torque; };
-}
-
-// algebraic loop, simply use delay... written in baseDSL
-semantic adaptation WindowSADelay window_sa_delay //with master
-at "./path/to/WindowSADelay.fmu"
-for fmu window_sa // inner SA, makes it possible to enforce order among adaptations this way
-param init_height := 0;
-param init_reaction_torque := 0;
-out var stored_height := init_height;
-out var stored_reaction_torque := init_reaction_torque;
-out rules {
-	true -> { var temp_height := height; height := stored_height; stored_height := temp_height; } --> { };
-	true -> { var temp_reaction_torque := reaction_torque; reaction_torque := stored_reaction_torque; stored_reaction_torque := temp_reaction_torque; } --> { }; 
-}
-

+ 0 - 19
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_algebraic_loop_iteration.sa

@@ -1,19 +0,0 @@
-import PowerWindowModel
-import Controller_SA
-
-// this one could be joined with the one below, if we assume certain priorities in executing the rules
-semantic adaptation WindowSA window_sa
-at "./path/to/WindowSA.fmu"
-for fmu window
-out rules {
-	reaction_torque := -reaction_torque;
-}
-
-// algebraic loop
-semantic adaptation PowerWindowObstacleSA power_window_obstacle_sa
-at "./path/to/PowerWindowObstacleSA.fmu"
-for fmu power, window_sa, obstacle
-input ports up, down // optional, can be figured out from model
-output ports armature_current // optional, can be figured out from model
-successive substitution starts at reaction_torque and height with absolute tolerance = 1e-8 and relative tolerance = 0.0001
-

+ 0 - 111
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_algebraic_loop_iteration_BASE.sa

@@ -1,111 +0,0 @@
-import PowerWindowModel
-import Controller_SA
-
-// this one could be joined with the one below, if we assume certain priorities in executing the rules
-semantic adaptation WindowSA window_sa
-at "./path/to/WindowSA.fmu"
-for fmu Window window
-out rules {
-	true -> { } --> { reaction_torque := -reaction_torque; };
-}
-
-// algebraic loop
-semantic adaptation PowerWindowObstacleSA power_window_obstacle_sa // without master -> not necessary: custom control rules override master
-at "./path/to/PowerWindowObstacleSA.fmu"
-for fmu power, window_sa, obstacle
-input ports up, down
-output ports armature_current
-//algebraic loop fix point iteration at reaction_torque and height with absolute tolerance = 1e-8 and relative tolerance = 0.0001
-param MAXITER := 100;
-param REL_TOL := 1e-8;
-param ABS_TOL := 1e-8;
-control {
-	// do_step will always use the last values, do_step does not advance time so will replace the last signal values! 
-	// therefore, we must set the signal at time t+h of reaction_torque and height
-	// this is done by a very weird statement:
-	reaction_torque := reaction_torque;
-	height := height;
-	// and just initialise other values at time t+h
-	armature_current := 0;
-	motor_speed := 0;
-	reaction_force := 0;
-	// now, all inputs are set at time t+h and we can start substituting them
-	var converged := false;
-	var temp_height; // to compare new value with previous value
-	var temp_reaction_torque; // to compare new value with previous value
-	// from here on: taken from Claudio's example
-	var prev_height := window_sa.height;
-	var inner_time := t;
-	for (var iter in 0 .. MAXITER) {
-		save_state(obstacle); // Inspired by transactions in databases.
-		save_state(window_sa);
-		do_step(obstacle, inner_time,h);
-		do_step(window_sa,inner_time,h);
-		
-		if (is_close(prev_height, height, REL_TOL, ABS_TOL)) {
-			break;
-		} else {
-			prev_height := height;
-			rollback(obstacle);
-			rollback(window_sa);
-		}
-	}
-	return H;
-}
-
-/*// this is the one for the paper
-semantic adaptation WindowObstacleSALoop window_obstacle_sa_loop// overrides master -> not necessary: custom control rules override master
-at "./path/to/WindowObstacleSALoop.fmu"
-for fmu window_sa, obstacle
-input ports motor_speed
-output ports reaction_torque
-param MAXITER := 100;
-param REL_TOL := 1e-8;
-param ABS_TOL := 1e-8;
-control {
-	var prev_height; // to compare new value with previous value
-	var window_state;
-	var obstacle_state;
-	height := height; // do_step will always use the last values, local_step does not advance time so will replace the last signal values! therefore, we must set the signal at time t+h of reaction_torque and height. this is done by a very weird statement:
-	reaction_force := 0; // and just initialise other values at time t+h
-	for (var iter in 0 .. MAXITER) {
-		prev_height := height;
-		local_step(obstacle); // with delayed input for height. overwrite current time step: basically a set_state (state at previous time step), do_step (with time step H)
-		local_step(window_sa);
-		if (is_close(prev_height, height, REL_TOL, ABS_TOL)) {
-			break;
-		}
-	}
-	return H;
-}
-
-// other version without local_step
-semantic adaptation WindowObstacleSALoop2 window_obstacle_sa_loop2// overrides master -> not necessary: custom control rules override master
-at "./path/to/WindowObstacleSALoop2.fmu"
-for fmu window_sa, obstacle
-input ports motor_speed
-output ports reaction_torque
-param MAXITER := 100;
-param REL_TOL := 1e-8;
-param ABS_TOL := 1e-8;
-control {
-	var prev_height; // to compare new value with previous value
-	var window_state;
-	var obstacle_state;
-	for (var iter in 0 .. MAXITER) {
-		window_state := get_state(window_sa);
-		obstacle_state := get_state(obstacle);
-		prev_height := height;
-		do_step(obstacle, H); // with delayed input for height
-		do_step(window_sa, H);
-		if (is_close(prev_height, height, REL_TOL, ABS_TOL)) {
-			break;
-		} else {
-			set_state(window_sa, window_state);
-			set_state(obstacle, obstacle_state);
-		}
-	}
-	return H;
-}
-*/
-

DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_algebraic_loop_delay.sa → DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/single_folder_spec/window/powerwindow_algebraic_loop_delay.sa


DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_controller_delay.sa → DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/single_folder_spec/window/powerwindow_controller_delay.sa


DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/testInputs/single_folder_spec/window/powerwindow_model_only.sa → DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/single_folder_spec/window/powerwindow_model_only.sa


+ 1 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/testInputs/single_folder_spec/window2/window_sa_canonical.BASE.sa

@@ -21,7 +21,7 @@ output ports	disp,
 				tau
 
 
-control {
+control rules {
 	do_step(window, t, H); // includes update_in rules and update_out (update-in rules do not update state)
 	return H;
 }

+ 0 - 31
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/test1.sa

@@ -1,31 +0,0 @@
-// horribly outdated, never look at this again!
-
-semantic adaptation TEST
-for discrete event
-input ports x[1 .. 2] (kg.m/s 2), y, z
-output ports a, b, c
-extract directionalderivative 
-{= (signal-signal[prev]) / h }
-{
-	def firstorder(s) {
-		var temp;
-		temp = s-s[prev];
-		return temp / h;
-	}
-	return firstorder(x);
-}
-
-in rules with zero crossing tolerance = 0.001, no hold { // for CT to inner DE
-	not x[prev]+3 > 2+2*floor(y[now]+round(8.2)) and y < 4 -> todo --> todo;
-	x >! 2 with tolerance = 0.0001 -> "high" --> no hold; // means condition -> IN action -> UPDATE IN action
-	x >! 1 or x <! 2 -> "low" --> no hold;
-	x <! 1 -> "off"; // i.e., no hold is the default
-	otherwise(x) -> null --> zero order hold;
-	quantize(y, "off", 1, "low", 2, "high") --> no hold;
-	quantize(z, ="event"+floor(z + 0.5)) --> no hold;
-	quantize(z, ="event"+round(z)) --> no hold;
-	quantize z every 2 offset 1 --> no hold;
-}
-//out rules with buffer[10] {}
-out rules {}
-control rules {}

+ 0 - 24
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/window_obstacle_sa_loop_BASE.sa

@@ -1,24 +0,0 @@
-// outdated
-
-semantic adaptation window_obstacle_sa_loop overrides master
-for fmu window_sa, obstacle
-input ports motor_speed
-output ports reaction_torque
-param MAXITER = 100;
-param REL_TOL = 1e-8;
-param ABS_TOL = 1e-8;
-in rules {
-	true -> {
-		height := height; // do_step will always use the last values, local_step does not advance time so will replace the last signal values! therefore, we must set the signal at time t+h of reaction_torque and height. this is done by a very weird statement:
-		reaction_force := 0; // and just initialise other values at time t+h
-		var prev_height; // to compare new value with previous value
-		for (var iter in 0 .. MAXITER) {
-			prev_height := height;
-			local_step(obstacle); // with delayed input for height
-			local_step(window_sa);
-			if (is_close(prev_height, height, REL_TOL, ABS_TOL)) {
-				break;
-			}
-		}
-	} --> { };
-}

+ 0 - 28
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/window_obstacle_sa_loop_BASE_new.sa

@@ -1,28 +0,0 @@
-//outdated
-
-semantic adaptation window_obstacle_sa_loop
-for fmu window_sa, obstacle
-input ports motor_speed
-output ports reaction_torque
-param MAXITER = 100;
-param REL_TOL = 1e-8;
-param ABS_TOL = 1e-8;
-control rules {
-	var prev_height;
-	var window_state;
-	var obstacle_state;
-	for (var iter in 0 .. MAXITER) {
-		window_state := get_state(window_sa);
-		obstacle_state := get_state(obstacle);
-		prev_height := height;
-		do_step(obstacle, H); // with delayed input for height
-		do_step(window_sa, H);
-		if (is_close(prev_height, height, REL_TOL, ABS_TOL)) {
-			break;
-		} else {
-			set_state(window_sa, window_state);
-			set_state(obstacle, obstacle_state);
-		}
-	}
-	return H;
-}

+ 0 - 18
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/window_obstacle_sa_multirate_BASE.sa

@@ -1,18 +0,0 @@
-// outdated
-
-semantic adaptation window_obstacle_sa_multirate
-for fmu window_obstacle_sa_loop
-input ports motor_speed
-output ports reaction_torque
-param init_motor_speed = 0;
-control rules { multiplied 10 times }
-in var stored_motor_speed := init_motor_speed;
-in var linear_increment;
-in rules {
-	true -> {
-		linear_increment := (motor_speed - stored_motor_speed) / 10;
-		stored_motor_speed := motor_speed;
-	} --> {
-		motor_speed := motor_speed + linear_increment;
-	};
-}

+ 0 - 28
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/window_obstacle_sa_multirate_BASE_new.sa

@@ -1,28 +0,0 @@
-// outdated
-
-semantic adaptation window_obstacle_sa_multirate
-for fmu window_obstacle_sa_loop
-input ports motor_speed
-output ports reaction_torque
-param init_motor_speed = 0;
-control rules {
-	var h := H/10;
-	var proposed_h := H;
-	for (var iter in 0 .. 10) {
-		var returned_h := do_step(window_obstacle_sa_loop, h);
-		if (returned_h != h) { // for backtracking
-			 proposed_h := iter*h + returned_h;
-		}
-	}
-	return proposed_h;
-}
-in var stored_motor_speed := init_motor_speed;
-in var linear_increment;
-in rules {
-	true -> {
-		linear_increment := (motor_speed - stored_motor_speed) / 10;
-		stored_motor_speed := motor_speed;
-	} --> {
-		motor_speed := motor_speed + linear_increment;
-	};
-}

+ 0 - 99
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/src/be/uantwerpen/ansymo/semanticadaptation/tests/SemanticAdaptationParsingTest.xtend

@@ -1,99 +0,0 @@
-/*
- * generated by Xtext 2.10.0
- */
-package be.uantwerpen.ansymo.semanticadaptation.tests
-
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SemanticAdaptation
-import com.google.inject.Inject
-import java.util.regex.Pattern
-import org.eclipse.emf.ecore.EObject
-import org.eclipse.xtext.testing.InjectWith
-import org.eclipse.xtext.testing.XtextRunner
-import org.eclipse.xtext.testing.util.ParseHelper
-import org.eclipse.xtext.testing.validation.ValidationTestHelper
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.Ignore
-
-@RunWith(XtextRunner)
-@InjectWith(SemanticAdaptationInjectorProvider)
-class SemanticAdaptationParsingTest extends AbstractSemanticAdaptationTest{
-	
-	@Inject extension ParseHelper<SemanticAdaptation>
-	@Inject extension ValidationTestHelper
-
-//	@Test 
-//	def void loadModule() {
-//		//val root = this.parseInputFile('test1.sa')
-//		val root = readFile('input/test1.sa').parse
-//		root.assertNoErrors
-//		Assert.assertNotNull(root.adaptations.get(0))
-//		Assert.assertNotNull(root.adaptations.get(0).extractsensitivity)
-//		Assert.assertTrue(root.adaptations.get(0).extractsensitivity.length > 0)
-//		Assert.assertTrue(root.adaptations.get(0).inports.length > 0)
-//		Assert.assertEquals(root.adaptations.get(0).inports.get(0).name, 'x')
-//		print_ast(root)
-//	}
-
-	@Test def power_window__window_obstacle_sa_flat() { __parseNoErrors('input/power_window_case_study/window_obstacle_sa_flat.BASE.sa') }
-	@Test def power_window__window_sa() { __parseNoErrors('input/power_window_case_study/window_sa.BASE.sa') }
-	@Test def power_window__window_sa_canonical() { __parseNoErrors('input/power_window_case_study/window_sa_canonical.BASE.sa') }
-	@Ignore @Test def powerwindow_model_only() { __parseNoErrors('input/powerwindow_model_only.sa') }
-	@Ignore @Test def powerwindow_algebraic_loop_delay_BASE() { __parseNoErrors('input/powerwindow_algebraic_loop_delay_BASE.sa') }
-	@Ignore @Test def powerwindow_algebraic_loop_delay() { __parseNoErrors('input/powerwindow_algebraic_loop_delay.sa') }
-	@Ignore @Test def powerwindow_algebraic_loop_iteration_BASE() { __parseNoErrors('input/powerwindow_algebraic_loop_iteration_BASE.sa') }
-	@Ignore @Test def powerwindow_algebraic_loop_iteration() { __parseNoErrors('input/powerwindow_algebraic_loop_iteration.sa') }
-	@Ignore @Test def powerwindow_controller_delay() { __parseNoErrors('input/powerwindow_controller_delay.sa') }
-	@Ignore @Test def powerwindow_multi_rate() { __parseNoErrors('input/powerwindow_multi_rate.sa') }
-	@Ignore @Test def powerwindow() { __parseNoErrors('input/powerwindow.sa') }
-	@Ignore @Test def powerwindow_inline() { __parseNoErrors('input/powerwindow_inline.sa') }
-	
-	def __parseNoErrors(String filename) {
-		val root = __parse(filename)
-		__assertNoParseErrors(root, filename)
-	}
-	
-	def __parseNoErrorsPrint(String filename) {
-		val root = __parse(filename)
-		print_ast(root)
-		__assertNoParseErrors(root, filename)
-	}
-	
-	def __parse(String filename) {
-		val model = readFile('input/powerwindow_controller_delay.sa').parse
-		val controller = readFile('input/powerwindow_model_only.sa').parse(model.eResource.resourceSet)
-		val algebraicloop = readFile('input/powerwindow_algebraic_loop_delay.sa').parse(controller.eResource.resourceSet)
-		return readFile(filename).parse(algebraicloop.eResource.resourceSet)
-	}
-	
-	def __assertNoParseErrors(EObject root, String filename) {
-		try {
-			root.assertNoErrors
-		} catch (AssertionError e) {
-			val p = Pattern.compile(".*, offset (?<offset>[0-9]+), length (?<length>[0-9]+)")
-			val code = readFile(filename)
-			for (String line : e.message.split("\n")) {
-				val m = p.matcher(line)
-				m.matches()
-				val count = __occurrencesInString(code.subSequence(0, Integer.valueOf(m.group("offset"))).toString(), "\n")
-				print(filename + " at line " + (count+1) + ": ")
-				println(line)
-			}
-			throw e
-		}
-	}
-	
-	def __occurrencesInString(String str, String findstr) {
-		var lastIndex = 0
-		var count = 0
-		while (lastIndex != -1) {
-			lastIndex = str.indexOf(findstr,lastIndex)
-			if (lastIndex != -1) {
-		        count ++
-		        lastIndex += findstr.length()
-		    }
-		}
-		return count
-	}
-
-}

+ 1 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/src/be/uantwerpen/ansymo/semanticadaptation/tests/SingleFolderTest.xtend

@@ -20,7 +20,7 @@ class SingleFolderTest extends ParserFolderTest {
 		
 		val List<Object[]> tests = new Vector
 		
-		for (file : new File("testInputs/single_folder_spec".replace('/',File.separatorChar)).listFiles) {
+		for (file : new File("input/single_folder_spec".replace('/',File.separatorChar)).listFiles) {
 			tests.add(#[file]);
 		}
 		

+ 0 - 13
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/testInputs/single_folder_spec/window/powerwindow_algebraic_loop_delay.sa

@@ -1,13 +0,0 @@
-import PowerWindowModel
-import Controller_SA
-
-module Algebraic_Loop_SA
-
-// this one could be joined with the one below, if we assume certain priorities in executing the rules
-semantic adaptation WindowSA window_sa
-at "./path/to/WindowSA.fmu"
-for fmu window
-out rules {
-	reaction_torque := -reaction_torque;
-	delay at reaction_torque and height;
-}

+ 0 - 23
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/testInputs/single_folder_spec/window/powerwindow_controller_delay.sa

@@ -1,23 +0,0 @@
-import PowerWindowModel
-
-module Controller_SA
-
-semantic adaptation ArmatureCurrentSA armature_current_sa
-at "./path/to/ArmatureCurrentSA.fmu"
-for fmu controller
-triggered by signal == true
-in rules with crossing absolute tolerance = 1e-8 and relative tolerance = 0.0001, no hold {
-	armature_current >! 5 -> obj_detected := true;
-	otherwise -> obj_detected := false;
-}
-
-semantic adaptation InOutSA in_out_sa
-at "./path/to/InOutSA.fmu"
-for fmu controller
-out rules with zero order hold {
-	"up" -> up := 1;
-	"stop" -> { up := 0; down := 0; };
-	"down" -> down := 1;
-	delay at up and down;
-}
-

+ 5 - 5
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/SemanticAdaptation.xtext

@@ -117,7 +117,7 @@ OutRulesBlock:
 	{OutRulesBlock} ('out' globalOutVars+=Declaration)* 'out' 'rules' ('with' setting+=GeneralSetting (',' setting+=GeneralSetting)*)? '{' iterationvars+=Declaration* rules+=DataRule* '}';
 
 ControlRuleBlock:
-	('ctrl' globalCtrlVars+=Declaration)* rule=ControlRule; // TODO: multiple rules or just one?
+	('control' globalCtrlVars+=Declaration)* rule=ControlRule; // TODO: multiple rules or just one?
 
 DataRule: // condition -> state transition --> output function
 	(((condition=RuleCondition "->" statetransitionfunction=StateTransitionFunction) | ConditionStateTransition | ConditionLessRule) ("-->" outputfunction=OutputFunction)? | AlgebraicLoopSolution) ';';
@@ -165,19 +165,19 @@ OutputFunction:
 	{FirstOrderHold} (('first' 'order' 'hold') | 'FOH') |
 	{CustomOutputFunction} expr=Expression |
 	{CompositeOutputFunction} '{' statements+=Statement* (returnstatement=ReturnStatement)? '}';
-	
+
 ControlRule:
 	{ImpliedControlRule} 'implied' | // the default
 	{TriggeredControlRule} 'triggered' 'by' condition=Expression |
 	{PeriodicControlRule} 'periodic' ('at' init_time=REALTYPE)? 'every' period=REALTYPE | 
 	{MultipliedControlRule} 'multiplied' multiplication=INT 'times' | 
-	{CustomControlRule} 'control' '{' ControlRulestatements+=Statement* returnstatement=ReturnStatement '}'; // TODO: how do we know if control is given?
+	{CustomControlRule} 'control' 'rules' '{' ControlRulestatements+=Statement* returnstatement=ReturnStatement '}'; // TODO: how do we know if control is given?
 
 AnonymousFunction: // has access to ports
 	{FunctionExpression} '{=' code=Expression '}'| 
 	{FunctionBody} '{' statements+=Statement* returnstatement=ReturnStatement '}' |  // should return something
 	FunctionDeclaration; // TODO: should return something
-	
+
 SpecifiedPort: // if ports need owners
 	(owner=[FMU] '.' )? port=[Port];
 
@@ -361,7 +361,7 @@ BuiltinFunction:
 	{Abs} name='abs' '(' args=ArithmeticExpression ')' |
 	{Close} name='is_close' '(' args+=ArithmeticExpression ',' args+=ArithmeticExpression ',' args+=ArithmeticExpression ',' args+=ArithmeticExpression ')' |  // a, b, relative tolerance, absolute tolerance 
 	{IsSet} name='is_set' '(' args=Var ')' | 
-//	{DoStepFun} name='do_step' '(' fmu=[FMU] ',' t=ArithmeticExpression ',' h=ArithmeticExpression ')' |
+	{DoStepFun} name='do_step' '(' fmu=[FMU] ',' t=ArithmeticExpression ',' h=ArithmeticExpression ')' |
 	{GetNextInternalTimeStep} name='get_next_time_step' '(' fmu=[FMU] ')' | // is actually the time step returned by do_step(fmu), preceded by get_state and succeeded by set_state
 	{Elapsed} name='elapsed' '(' fmu=[FMU] ')' |
 	{LastExecutionTime} name='last_execution_time' '(' fmu=[FMU] ')';