Open SudeepGhoshIN opened 4 months ago
Hi SudeepGhoshIN,
you retrieve the start value via fmi2_import_get_real_variable_start
, note that this will instead return the nominal if there is no start value, so you should still check if there is a start value first.
If this does not answer the question, please provide a minimal reproducer.
/Peter
Not able to get value for this 2
<ScalarVariable name="Constant4.Constant4" valueReference="50">
<Integer start="3"/>
</ScalarVariable>
<ScalarVariable name="Out1" valueReference="28" causality="output">
<Real start="1.0"/>
</ScalarVariable>
able to get value for
<ScalarVariable name="Parameters.FixPtConstant_Value_i" valueReference="16" causality="parameter" variability="tunable">
<Real start="1.0"/>
</ScalarVariable>
Can you provide the corresponding C code for retrieving the start values?
/Peter
fmi2_import_variable_t* var = fmi2_import_get_variable(varList, i);
baseType = fmi2_import_get_variable_base_type(var);
VariableType = fmi2_base_type_to_string(baseType);
if (VariableType == "Real")
{
fmi2_import_real_variable_t* rv = fmi2_import_get_variable_as_real(var);
fmi2_real_t StartValue = fmi2_import_get_real_variable_start(rv);
}
First off, there are couple of issues in your modelDescription.xml:
variability
and thus fmi-library defaults to continuous
. This conflicts with the variable being an Integer
. Are you missing a variability="constant" here?variability
or initial
. Again, variability
defaults to continuous
and we take the default initial calculated
(based on the variability
+ causality
combination, see specification). initial="calculated"
does not allow start
values. There are multiple possible choices for initial
here, but fmi-library does not perform checks to determine if any legal ones come without errors, it simply takes the default. You might want to specify a variability
and possibly initial="exact"
here?As for the code, you'll want to obtain the type via fmi2_base_type_enu_t base_type = fmi2_import_get_variable_base_type(var);
and use the enum for type checks and then pick the correct get_variable_as_*
and get_*_variable_start
functions based on the type.
/Peter
Hi Team,
I have a requirement of passing start value for Measurment and Outputs in FMI2.0. As part of this , I am trying to utilize fmi2_import_get_variable_has_start(fmi2_import_variable_t*) API to check if the variable contains start. But unfortunately, above mentioned API is not returning value , so I could not proceed further for retrieving the start value.
Though I am getting proper value for Calibration and Inport value while trying to read from Parameters and Inputs variable.
Many Thanks, Sudeepp