Browse Source

merged power_sa with its copy

Cláudio Gomes 3 years ago
parent
commit
e4d4107e7a

+ 22 - 2
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_power_sa - Copy (2)/FMI_power_sa.c

@@ -77,11 +77,31 @@ fmi2Status fmi2GetString(fmi2Component fc, const fmi2ValueReference vr[], size_t
 fmi2Status fmi2SetReal(fmi2Component fc, const fmi2ValueReference vr[], size_t nvr, const fmi2Real value[])
 {
 	FMUInstance* comp = (FMUInstance *)fc;
-	int i;
-	for (i = 0; i < nvr; i++)
+	for (int i = 0; i < nvr; i++)
 	{
 		comp->r[vr[i]] = value[i];
+		fmi2Real theval = value[i];
+		printf("%f\n", theval);
+	}
+	fmi2Boolean in_condition[_NR_OF_IN_CONDITIONS];
+	/*Condition checking:*/
+	// true
+	in_condition[0] = 1;
+
+	for (int i = 0; i < nvr; i++){
+		if(in_condition[0] && (vr[i] == _in_u)){
+			comp->stored_windowsa_u = comp->r[_in_u];
+		}
+		if(in_condition[0] && (vr[i] == _in_d)){
+			comp->stored_windowsa_d = comp->r[_in_d];
+		}
+		if(in_condition[0] && (vr[i] == _in_tau)){
+			comp->stored_tau = comp->r[_in_tau];
+		}
+		/* If mealy do update_in and recursive call */
+
 	}
+	
 	//out_condition_executed := empty map
 	memset(comp->out_conditions_executed,0,sizeof(fmi2Boolean)*_NR_OF_OUT_CONDITIONS);
 	return fmi2OK;

+ 27 - 6
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_power_sa/FMI_power_sa.c

@@ -126,11 +126,13 @@ fmi2Status fmi2GetReal(fmi2Component fc, const fmi2ValueReference vr[], size_t n
 		comp->out_conditions_executed[0] = 1;
 	}
 
-	for(int i=0; i<_NR_OF_OUT_CONDITIONS;i++){
-		if(comp->out_conditions_executed[i]){
-			comp->r[_out_i] = comp->stored_armature_current;
-			comp->r[_out_omega] = comp->stored_speed;
-			comp->r[_out_theta] = comp->stored_displacement;
+	if (isEmpty){
+		for(int i=0; i<_NR_OF_OUT_CONDITIONS;i++){
+			if(comp->out_conditions_executed[i]){
+				comp->r[_out_i] = comp->stored_armature_current;
+				comp->r[_out_omega] = comp->stored_speed;
+				comp->r[_out_theta] = comp->stored_displacement;
+			}
 		}
 	}
 	for (int i = 0; i < nvr; i++)
@@ -144,8 +146,27 @@ fmi2Status fmi2GetReal(fmi2Component fc, const fmi2ValueReference vr[], size_t n
 fmi2Status fmi2SetBoolean(fmi2Component fc, const fmi2ValueReference vr[], size_t nvr, const fmi2Boolean value[])
 {
 	FMUInstance* comp = (FMUInstance *)fc;
-	printf("Error!!!! Not implemented!!!\n");
 
+	int i;
+	for (i = 0; i < nvr; i++)
+	{
+		comp->b[vr[i]] = value[i];
+	}
+	/*Generated: */
+		fmi2Boolean in_condition[_NR_OF_IN_CONDITIONS];
+		/*Condition checking:*/
+		// true
+		in_condition[0] = 1;
+
+		if(in_condition[0]){
+			comp->stored_windowsa_u = (fmi2Real) comp->b[_in_u];
+			comp->stored_windowsa_d = comp->b[_in_d];
+			/* If mealy do update_in and recursive call */
+		}
+		return fmi2OK;
+
+	//out_condition_executed := empty map
+	memset(comp->out_conditions_executed,0,sizeof(fmi2Boolean)*_NR_OF_OUT_CONDITIONS);
 	return fmi2OK;
 }