Browse Source

notes from meeting with Bart

Cláudio Gomes 8 years ago
parent
commit
8bd95260d3

+ 46 - 23
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/examples/algorithm.c

@@ -3,8 +3,8 @@ code AdaptedFMU:
 	/*
 	These maps will keep track of which rules execute and which don't
 	*/
-	var out_condition_executed = empty map
 	var in_condition_executed = empty map
+	var out_condition_executed = empty map
 	
 	var fmu1 //FMU fmu1 ref
 	var fmu2 //FMU fmu2 ref
@@ -22,13 +22,17 @@ code AdaptedFMU:
 	...
 	
 	// in vars
-	var cv1 = init_cv1
+	var iv1 = init_iv1
 	...
 	
 	// out vars
 	var ov1 = init_ov1
 	...
 	
+	// control vars
+	var cv1 = init_cv1
+	...
+	
 	function instantiate()
 		fmu1.instantiate()
 		...
@@ -36,7 +40,7 @@ code AdaptedFMU:
 	end function
 	
 	function setup_experiment(t,...) 
-		window.setup_experiment(t,...)
+		fmu1.setup_experiment(t,...)
 		time_last_fmu1 = t
 		...
 		return
@@ -54,11 +58,15 @@ code AdaptedFMU:
 		return
 	end function
 	
-	function setValues(ports, values) 
+	function fmi2SetValues(ports, values) 
 		/*
 		Evaluates each condition (and sa_in rule) in order.
 		*/
 		
+		/*
+		TODO: First eval all conditions, and only then run the blocks.
+		*/
+		
 		if (in_condition_1) then
 			in_condition_executed[IN_COND_1] = true
 			<sa_in_1>
@@ -69,7 +77,7 @@ code AdaptedFMU:
 				*/
 				var h = 0
 				var dt = 0
-				<update_sa_in_1>
+				<update_in_1>
 			}
 			<end if>
 		end if
@@ -78,22 +86,7 @@ code AdaptedFMU:
 		out_condition_executed := empty map // force output computation.
 	end function
 	
-	function doStep(t, H)
-		
-		/*
-		A new doStep means that a new set of conditions will be triggered.
-		*/
-		out_condition_executed = empty map
-		
-		/*
-		Calculate the elapsed time since the last transition
-		*/
-		var elapsed_fmu1 = t - time_last_fmu1
-		...
-		var e = min(elapsed_fmu1, ...)
-		
-		<control_block_part_1>
-		
+	function do_inner_step(fmu, t, inner_t, h) 
 		/*
 		Evaluate each update_in block of the rules that were successfully evaluated before the doStep was called.
 		This is because the window.doStep will be called immediately afterward.
@@ -113,11 +106,14 @@ code AdaptedFMU:
 			<update_in_2>
 		end if
 		...
-		do_step(fmu1, inner_t, h)
+		fmi2DoStep(fmu1, inner_t, h)
 		/*
 		Executes the update_out blocks.
 		These always execute after a doStep is called on an internal FMU.
 		*/
+		/*
+		TODO: First eval all conditions, and only then run the blocks.
+		*/
 		if (<out_condition_1>) then
 			out_condition_executed[OUT_COND_1] = true
 			var h = h
@@ -125,12 +121,37 @@ code AdaptedFMU:
 			<update_out_1>
 		end if
 		...
+	end function
+	
+	function fmi2DoStep(t, H)
+		
+		/*
+		A new doStep means that a new set of conditions will be triggered.
+		*/
+		out_condition_executed = empty map
+		
+		/*
+		Calculate the elapsed time since the last transition
+		*/
+		var elapsed_fmu1 = t - time_last_fmu1
+		...
+		var e = min(elapsed_fmu1, ...)
+		
+		<control_block_part_1>
+		
+		do_inner_step(fmu1, t, inner_t, h);
+		
+		<control_block_part_2>
 		
 		in_condition_executed = empty map;
 		
 	end function
 	
-	function getValues(ports)
+	function fmi2GetValues(ports)
+		var values = empty map;
+		/*
+		TODO: First eval all conditions, and only then run the blocks.
+		*/
 		if out_condition_executed == empty map then
 			// This can happen since the adapted unit is a mealy machine
 			// So execute the update_out blocks
@@ -148,4 +169,6 @@ code AdaptedFMU:
 			<sa_out_1>
 		end if
 		...
+		
+		return values;
 	end function

+ 5 - 4
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/examples/controller_sa.BASE.sa

@@ -1,6 +1,6 @@
 module Controller_SA
 
-semantic adaptation reactive mealy controller_sa
+semantic adaptation reactive moore controller_sa
 
 for fmu Controller controller
 at "./path/to/Controller.fmu"
@@ -11,9 +11,10 @@ output ports up, down, stop
 Added support for simple wildcars in the input ports.
 According to Casper and Kenneth, some FMUs have thousands of ports...
 */
-input ports armature_current, 
-			passenger_*, 
-			driver_*;
+input ports obj_detected,
+			armature_current, 
+			passenger_*, // These are not supported for now.
+			driver_*; // These are not supported for now.
 
 output ports	u,
 				d;

+ 2 - 2
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/examples/window_obstacle_sa.BASE.sa

@@ -15,8 +15,8 @@ at "./path/to/Window_sa.fmu"
 input ports displacement (rad), speed (rad/s), reaction_force (N)
 output ports disp (m), tau (N.m);
 
-for fmu WindowSA obstacle
-at "./path/to/obstacle.fmu"
+for fmu Obstacle obstacle
+at "./path/to/Obstacle.fmu"
 input ports disp (m),
 output ports reaction_force (m);