Joachim Denil 4 years ago
parent
commit
7fc3f0d056

+ 170 - 170
SemanticAdaptationForFMI/Experiments/power_window_case_study/case/result_Control_sa.csv

@@ -99,176 +99,176 @@
 0.980000,0,1
 0.990000,0,1
 1.000000,0,1
-1.010000,1,0
-1.020000,1,0
-1.030000,1,0
-1.040000,1,0
-1.050000,1,0
-1.060000,1,0
-1.070000,1,0
-1.080000,1,0
-1.090000,1,0
-1.100000,1,0
-1.110000,1,0
-1.120000,1,0
-1.130000,1,0
-1.140000,1,0
-1.150000,1,0
-1.160000,1,0
-1.170000,1,0
-1.180000,1,0
-1.190000,1,0
-1.200000,1,0
-1.210000,1,0
-1.220000,1,0
-1.230000,1,0
-1.240000,1,0
-1.250000,1,0
-1.260000,1,0
-1.270000,1,0
-1.280000,1,0
-1.290000,1,0
-1.300000,1,0
-1.310000,1,0
-1.320000,1,0
-1.330000,1,0
-1.340000,1,0
-1.350000,1,0
-1.360000,1,0
-1.370000,1,0
-1.380000,1,0
-1.390000,1,0
-1.400000,1,0
-1.410000,1,0
-1.420000,1,0
-1.430000,1,0
-1.440000,1,0
-1.450000,1,0
-1.460000,1,0
-1.470000,1,0
-1.480000,1,0
-1.490000,1,0
-1.500000,1,0
-1.510000,1,0
-1.520000,1,0
-1.530000,1,0
-1.540000,1,0
-1.550000,1,0
-1.560000,1,0
-1.570000,1,0
-1.580000,1,0
-1.590000,1,0
-1.600000,1,0
-1.610000,1,0
-1.620000,1,0
-1.630000,1,0
-1.640000,1,0
-1.650000,1,0
-1.660000,1,0
-1.670000,1,0
-1.680000,1,0
-1.690000,1,0
-1.700000,1,0
-1.710000,1,0
-1.720000,1,0
-1.730000,1,0
-1.740000,1,0
-1.750000,1,0
-1.760000,1,0
-1.770000,1,0
-1.780000,1,0
-1.790000,1,0
-1.800000,1,0
-1.810000,1,0
-1.820000,1,0
-1.830000,1,0
-1.840000,1,0
-1.850000,1,0
-1.860000,1,0
-1.870000,1,0
-1.880000,1,0
-1.890000,1,0
-1.900000,1,0
-1.910000,1,0
-1.920000,1,0
-1.930000,1,0
-1.940000,1,0
-1.950000,1,0
-1.960000,1,0
-1.970000,1,0
-1.980000,1,0
-1.990000,1,0
-2.000000,1,0
-2.010000,0,0
-2.020000,0,0
-2.030000,0,0
-2.040000,0,0
-2.050000,0,0
-2.060000,0,0
-2.070000,0,0
-2.080000,0,0
-2.090000,0,0
-2.100000,0,0
-2.110000,0,0
-2.120000,0,0
-2.130000,0,0
-2.140000,0,0
-2.150000,0,0
-2.160000,0,0
-2.170000,0,0
-2.180000,0,0
-2.190000,0,0
-2.200000,0,0
-2.210000,0,0
-2.220000,0,0
-2.230000,0,0
-2.240000,0,0
-2.250000,0,0
-2.260000,0,0
-2.270000,0,0
-2.280000,0,0
-2.290000,0,0
-2.300000,0,0
-2.310000,0,0
-2.320000,0,0
-2.330000,0,0
-2.340000,0,0
-2.350000,0,0
-2.360000,0,0
-2.370000,0,0
-2.380000,0,0
-2.390000,0,0
-2.400000,0,0
-2.410000,0,0
-2.420000,0,0
-2.430000,0,0
-2.440000,0,0
-2.450000,0,0
-2.460000,0,0
-2.470000,0,0
-2.480000,0,0
-2.490000,0,0
-2.500000,0,0
-2.510000,0,0
-2.520000,0,0
-2.530000,0,0
-2.540000,0,0
-2.550000,0,0
-2.560000,0,0
-2.570000,0,0
-2.580000,0,0
-2.590000,0,0
-2.600000,0,0
-2.610000,0,0
-2.620000,0,0
-2.630000,0,0
-2.640000,0,0
-2.650000,0,0
-2.660000,0,0
-2.670000,0,0
-2.680000,0,0
-2.690000,0,0
-2.700000,0,0
+1.010000,0,1
+1.020000,0,1
+1.030000,0,1
+1.040000,0,1
+1.050000,0,1
+1.060000,0,1
+1.070000,0,1
+1.080000,0,1
+1.090000,0,1
+1.100000,0,1
+1.110000,0,1
+1.120000,0,1
+1.130000,0,1
+1.140000,0,1
+1.150000,0,1
+1.160000,0,1
+1.170000,0,1
+1.180000,0,1
+1.190000,0,1
+1.200000,0,1
+1.210000,0,1
+1.220000,0,1
+1.230000,0,1
+1.240000,0,1
+1.250000,0,1
+1.260000,0,1
+1.270000,0,1
+1.280000,0,1
+1.290000,0,1
+1.300000,0,1
+1.310000,0,1
+1.320000,0,1
+1.330000,0,1
+1.340000,0,1
+1.350000,0,1
+1.360000,0,1
+1.370000,0,1
+1.380000,0,1
+1.390000,0,1
+1.400000,0,1
+1.410000,0,1
+1.420000,0,1
+1.430000,0,1
+1.440000,0,1
+1.450000,0,1
+1.460000,0,1
+1.470000,0,1
+1.480000,0,1
+1.490000,0,1
+1.500000,0,1
+1.510000,0,1
+1.520000,0,1
+1.530000,0,1
+1.540000,0,1
+1.550000,0,1
+1.560000,0,1
+1.570000,0,1
+1.580000,0,1
+1.590000,0,1
+1.600000,0,1
+1.610000,0,1
+1.620000,0,1
+1.630000,0,1
+1.640000,0,1
+1.650000,0,1
+1.660000,0,1
+1.670000,0,1
+1.680000,0,1
+1.690000,0,1
+1.700000,0,1
+1.710000,0,1
+1.720000,0,1
+1.730000,0,1
+1.740000,0,1
+1.750000,0,1
+1.760000,0,1
+1.770000,0,1
+1.780000,0,1
+1.790000,0,1
+1.800000,0,1
+1.810000,0,1
+1.820000,0,1
+1.830000,0,1
+1.840000,0,1
+1.850000,0,1
+1.860000,0,1
+1.870000,0,1
+1.880000,0,1
+1.890000,0,1
+1.900000,0,1
+1.910000,0,1
+1.920000,0,1
+1.930000,0,1
+1.940000,0,1
+1.950000,0,1
+1.960000,0,1
+1.970000,0,1
+1.980000,0,1
+1.990000,0,1
+2.000000,0,1
+2.010000,0,1
+2.020000,0,1
+2.030000,0,1
+2.040000,0,1
+2.050000,0,1
+2.060000,0,1
+2.070000,0,1
+2.080000,0,1
+2.090000,0,1
+2.100000,0,1
+2.110000,0,1
+2.120000,0,1
+2.130000,0,1
+2.140000,0,1
+2.150000,0,1
+2.160000,0,1
+2.170000,0,1
+2.180000,0,1
+2.190000,0,1
+2.200000,0,1
+2.210000,0,1
+2.220000,0,1
+2.230000,0,1
+2.240000,0,1
+2.250000,0,1
+2.260000,0,1
+2.270000,0,1
+2.280000,0,1
+2.290000,0,1
+2.300000,0,1
+2.310000,0,1
+2.320000,0,1
+2.330000,0,1
+2.340000,0,1
+2.350000,0,1
+2.360000,0,1
+2.370000,0,1
+2.380000,0,1
+2.390000,0,1
+2.400000,0,1
+2.410000,0,1
+2.420000,0,1
+2.430000,0,1
+2.440000,0,1
+2.450000,0,1
+2.460000,0,1
+2.470000,0,1
+2.480000,0,1
+2.490000,0,1
+2.500000,0,1
+2.510000,0,1
+2.520000,0,1
+2.530000,0,1
+2.540000,0,1
+2.550000,0,1
+2.560000,0,1
+2.570000,0,1
+2.580000,0,1
+2.590000,0,1
+2.600000,0,1
+2.610000,0,1
+2.620000,0,1
+2.630000,0,1
+2.640000,0,1
+2.650000,0,1
+2.660000,0,1
+2.670000,0,1
+2.680000,0,1
+2.690000,0,1
+2.700000,0,1
 2.710000,0,1
 2.720000,0,1
 2.730000,0,1

+ 50 - 50
SemanticAdaptationForFMI/Experiments/power_window_case_study/case/result_power_sa.csv

@@ -98,56 +98,56 @@
 0.970000,0.000000,0.000000,0.000000
 0.980000,0.000000,0.000000,0.000000
 0.990000,0.000000,0.000000,0.000000
-1.000000,5.000000,0.000000,0.000000
-1.010000,5.000000,0.000000,0.000000
-1.020000,5.000000,0.000000,0.000000
-1.030000,5.000000,0.000000,0.000000
-1.040000,5.000000,0.000000,0.000000
-1.050000,5.000000,0.000000,0.000000
-1.060000,5.000000,0.000000,0.000000
-1.070000,5.000000,0.000000,0.000000
-1.080000,5.000000,0.000000,0.000000
-1.090000,5.000000,0.000000,0.000000
-1.100000,5.000000,0.000000,0.000000
-1.110000,5.000000,0.000000,0.000000
-1.120000,5.000000,0.000000,0.000000
-1.130000,5.000000,0.000000,0.000000
-1.140000,5.000000,0.000000,0.000000
-1.150000,5.000000,0.000000,0.000000
-1.160000,5.000000,0.000000,0.000000
-1.170000,5.000000,0.000000,0.000000
-1.180000,5.000000,0.000000,0.000000
-1.190000,5.000000,0.000000,0.000000
-1.200000,5.000000,0.000000,0.000000
-1.210000,5.000000,0.000000,0.000000
-1.220000,5.000000,0.000000,0.000000
-1.230000,5.000000,0.000000,0.000000
-1.240000,5.000000,0.000000,0.000000
-1.250000,5.000000,0.000000,0.000000
-1.260000,5.000000,0.000000,0.000000
-1.270000,5.000000,0.000000,0.000000
-1.280000,5.000000,0.000000,0.000000
-1.290000,5.000000,0.000000,0.000000
-1.300000,5.000000,0.000000,0.000000
-1.310000,5.000000,0.000000,0.000000
-1.320000,5.000000,0.000000,0.000000
-1.330000,5.000000,0.000000,0.000000
-1.340000,5.000000,0.000000,0.000000
-1.350000,5.000000,0.000000,0.000000
-1.360000,5.000000,0.000000,0.000000
-1.370000,5.000000,0.000000,0.000000
-1.380000,5.000000,0.000000,0.000000
-1.390000,5.000000,0.000000,0.000000
-1.400000,5.000000,0.000000,0.000000
-1.410000,5.000000,0.000000,0.000000
-1.420000,5.000000,0.000000,0.000000
-1.430000,5.000000,0.000000,0.000000
-1.440000,5.000000,0.000000,0.000000
-1.450000,5.000000,0.000000,0.000000
-1.460000,5.000000,0.000000,0.000000
-1.470000,5.000000,0.000000,0.000000
-1.480000,5.000000,0.000000,0.000000
-1.490000,5.000000,0.000000,0.000000
+1.000000,0.000000,0.000000,0.000000
+1.010000,0.000000,0.000000,0.000000
+1.020000,0.000000,0.000000,0.000000
+1.030000,0.000000,0.000000,0.000000
+1.040000,0.000000,0.000000,0.000000
+1.050000,0.000000,0.000000,0.000000
+1.060000,0.000000,0.000000,0.000000
+1.070000,0.000000,0.000000,0.000000
+1.080000,0.000000,0.000000,0.000000
+1.090000,0.000000,0.000000,0.000000
+1.100000,0.000000,0.000000,0.000000
+1.110000,0.000000,0.000000,0.000000
+1.120000,0.000000,0.000000,0.000000
+1.130000,0.000000,0.000000,0.000000
+1.140000,0.000000,0.000000,0.000000
+1.150000,0.000000,0.000000,0.000000
+1.160000,0.000000,0.000000,0.000000
+1.170000,0.000000,0.000000,0.000000
+1.180000,0.000000,0.000000,0.000000
+1.190000,0.000000,0.000000,0.000000
+1.200000,0.000000,0.000000,0.000000
+1.210000,0.000000,0.000000,0.000000
+1.220000,0.000000,0.000000,0.000000
+1.230000,0.000000,0.000000,0.000000
+1.240000,0.000000,0.000000,0.000000
+1.250000,0.000000,0.000000,0.000000
+1.260000,0.000000,0.000000,0.000000
+1.270000,0.000000,0.000000,0.000000
+1.280000,0.000000,0.000000,0.000000
+1.290000,0.000000,0.000000,0.000000
+1.300000,0.000000,0.000000,0.000000
+1.310000,0.000000,0.000000,0.000000
+1.320000,0.000000,0.000000,0.000000
+1.330000,0.000000,0.000000,0.000000
+1.340000,0.000000,0.000000,0.000000
+1.350000,0.000000,0.000000,0.000000
+1.360000,0.000000,0.000000,0.000000
+1.370000,0.000000,0.000000,0.000000
+1.380000,0.000000,0.000000,0.000000
+1.390000,0.000000,0.000000,0.000000
+1.400000,0.000000,0.000000,0.000000
+1.410000,0.000000,0.000000,0.000000
+1.420000,0.000000,0.000000,0.000000
+1.430000,0.000000,0.000000,0.000000
+1.440000,0.000000,0.000000,0.000000
+1.450000,0.000000,0.000000,0.000000
+1.460000,0.000000,0.000000,0.000000
+1.470000,0.000000,0.000000,0.000000
+1.480000,0.000000,0.000000,0.000000
+1.490000,0.000000,0.000000,0.000000
 1.500000,0.000000,0.000000,0.000000
 1.510000,0.000000,0.000000,0.000000
 1.520000,0.000000,0.000000,0.000000

+ 27 - 23
SemanticAdaptationForFMI/Experiments/power_window_case_study/case/src/pw_case.c

@@ -17,7 +17,7 @@
 #define STOP_TIME 10.0
 #define STEP_SIZE 0.01
 
-FMU fmu_env, fmu_control_sa, fmu_power_sa, fmu_window_sa;
+FMU fmu_env, fmu_control_sa, fmu_power_sa, fmu_loop_sa;
 
 int main(void) {
 
@@ -33,25 +33,25 @@ int main(void) {
     loadDll("libFMI_Environment.dll", &fmu_env, "PW_ENV");
     loadDll("libFMI_controller_sa.dll", &fmu_control_sa, "PW_CONTROLLER_SA");
     loadDll("libFMI_power_sa.dll", &fmu_power_sa, "POWER_SA");
-    loadDll("libFMI_Window_sa.dll", &fmu_window_sa, "WINDOW_SA");
+    loadDll("libFMI_loop_sa.dll", &fmu_loop_sa, "LOOP_SA");
 
     puts("instantiating fmus\n");
-    fmi2Component c_env, c_control_sa, c_power_sa, c_window_sa;
+    fmi2Component c_env, c_control_sa, c_power_sa, c_loop_sa;
 
     char *fmuResourceLocation_env = "libFMI_Environment.dll";
     char *fmuResourceLocation_control_sa = "libFMI_controller_sa.dll";
     char *fmuResourceLocation_power_sa = "libFMI_power_sa.dll";
-    char *fmuResourceLocation_window_sa = "libFMI_Wower_sa.dll";
+    char *fmuResourceLocation_window_sa = "libFMI_loop_sa.dll";
 
     fmi2CallbackFunctions callbacks_env= {fmuLogger, calloc, free, NULL, &fmu_env};
     fmi2CallbackFunctions callbacks_control_sa = {fmuLogger, calloc, free, NULL, &fmu_control_sa};
     fmi2CallbackFunctions callbacks_power_sa = {fmuLogger, calloc, free, NULL, &fmu_power_sa};
-    fmi2CallbackFunctions callbacks_window_sa = {fmuLogger, calloc, free, NULL, &fmu_window_sa};
+    fmi2CallbackFunctions callbacks_loop_sa = {fmuLogger, calloc, free, NULL, &fmu_loop_sa};
 
     c_env = fmu_env.instantiate("env", fmi2CoSimulation, "1", fmuResourceLocation_env, &callbacks_env, fmi2False, fmi2False);
     c_control_sa = fmu_control_sa.instantiate("control_sa", fmi2CoSimulation, "1", fmuResourceLocation_control_sa, &callbacks_control_sa, fmi2False, fmi2False);
     c_power_sa = fmu_power_sa.instantiate("power_sa", fmi2CoSimulation, "1", fmuResourceLocation_power_sa, &callbacks_power_sa, fmi2False, fmi2False);
-    c_window_sa = fmu_window_sa.instantiate("window_sa",fmi2CoSimulation, "1", fmuResourceLocation_window_sa, &callbacks_window_sa, fmi2False, fmi2False );
+    c_loop_sa = fmu_loop_sa.instantiate("loop_sa",fmi2CoSimulation, "1", fmuResourceLocation_window_sa, &callbacks_loop_sa, fmi2False, fmi2False );
 
     fmi2Boolean toleranceDefined = fmi2False;  // true if model description define tolerance
     fmi2Real tolerance = 0;                    // used in setting up the experiment
@@ -70,7 +70,7 @@ int main(void) {
     if (fmi2Flag[2] == fmi2Error){
     	return -1;
     }
-    fmi2Flag[3] = fmu_window_sa.setupExperiment(c_window_sa, toleranceDefined, tolerance, START_TIME, fmi2True, STOP_TIME);
+    fmi2Flag[3] = fmu_loop_sa.setupExperiment(c_loop_sa, toleranceDefined, tolerance, START_TIME, fmi2True, STOP_TIME);
     if (fmi2Flag[3] == fmi2Error){
     	return -1;
     }
@@ -88,7 +88,7 @@ int main(void) {
     if (fmi2Flag[2] == fmi2Error){
     	return -1;
     }
-    fmi2Flag[3] = fmu_window_sa.enterInitializationMode(c_window_sa);
+    fmi2Flag[3] = fmu_loop_sa.enterInitializationMode(c_loop_sa);
     if (fmi2Flag[3] == fmi2Error){
     	return -1;
     }
@@ -106,19 +106,16 @@ int main(void) {
     if (fmi2Flag[2] == fmi2Error){
     	return -1;
     }
-    fmi2Flag[3] = fmu_window_sa.exitInitializationMode(c_window_sa);
+    fmi2Flag[3] = fmu_loop_sa.exitInitializationMode(c_loop_sa);
     if (fmi2Flag[3] == fmi2Error){
     	return -1;
     }
 
     fmi2ValueReference vr_out_env[9]={0,1,2,3,4,5,6,7,8};
     fmi2Boolean b_out_env[9];
-    fmi2ValueReference vr_out_window[1]={0};
-    fmi2Real r_out_window[1]={0};
     fmi2ValueReference vr_in_control_sa_from_env[8]={0,1,2,3,4,5,6,7};
     fmi2ValueReference vr_in_control_sa_from_window[1] = {0};
     fmi2ValueReference vr_out_control_sa[2]={9,10};
-    fmi2ValueReference vr_out_power_i[1] = {0};
     fmi2ValueReference vr_in_power_sa_u_d_tau[3] = {3,4,5};
     fmi2Real r_in_power[3];
     fmi2ValueReference vr_out_power_sa[3] = {0,1,2};
@@ -140,7 +137,7 @@ int main(void) {
     	if (fmu_env.getBoolean(c_env, vr_out_env, 9, &b_out_env[0]) != fmi2OK){
     	            return 1;
     	}
-    	if (fmu_power_sa.getBoolean(c_power_sa, vr_out_power_i, 1, &r_out_window[0]) != fmi2OK){
+    	if (fmu_power_sa.getReal(c_power_sa, vr_out_power_sa, 3, &r_out_power[0]) != fmi2OK){
     	    	            return 1;
     	    	}
 
@@ -155,16 +152,12 @@ int main(void) {
 				b_out_env[6],
 				b_out_env[7],
 				b_out_env[8]);
-    	if (b_out_env[8]){
-    		r_out_window[0] = 5;
-    	}else{
-    		r_out_window[0]= 0;
-    	}
+
     	fmi2Flag[1] = fmu_control_sa.setBoolean(c_control_sa,vr_in_control_sa_from_env,8,&b_out_env[0]);
     	if(fmi2Flag[1] != fmi2OK){
     		return 1;
     	}
-    	fmi2Flag[1] = fmu_control_sa.setReal(c_control_sa,vr_in_control_sa_from_window,1, &r_out_window[0]);
+    	fmi2Flag[1] = fmu_control_sa.setReal(c_control_sa,vr_in_control_sa_from_window,1, &r_out_power[0]);
     	if(fmi2Flag[1] != fmi2OK){
     	    		return 1;
     	}
@@ -190,15 +183,26 @@ int main(void) {
 
     	fmi2Flag[2] = fmu_power_sa.doStep(c_power_sa, currentTime, STEP_SIZE, fmi2True);
 
-    	if (fmu_env.setReal(c_power_sa, vr_out_power_sa, 3, &r_out_power[0]) != fmi2OK){
+    	if (fmu_power_sa.setReal(c_power_sa, vr_out_power_sa, 3, &r_out_power[0]) != fmi2OK){
     	    	            return 1;
     	    	}
 
     	fprintf(fp_fmu_power_sa,"%f,%f,%f,%f\n",
     	    			currentTime,
-    					r_out_window[0],
-    					r_out_window[1],
-						r_out_window[2]);
+    					r_out_power[0],
+    					r_out_power[1],
+						r_out_power[2]);
+
+
+    	fmi2ValueReference vr_toLoop[2] = {1,2};
+    	fmi2Real toLoop[2];
+    	toLoop[0] = r_out_power[1];
+    	toLoop[1] = r_out_power[2];
+
+    	if (fmu_loop_sa.setReal(c_loop_sa, vr_toLoop, 2, &toLoop[0]) != fmi2OK){
+    	    	    	            return 1;
+    	    	    	}
+    	fmi2Flag[3] = fmu_loop_sa.doStep(c_loop_sa, currentTime, STEP_SIZE, fmi2True);
 
     	int redoStep  = 0;
     	for(int i=0; i<2; i++)