Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 16c107e

Browse files
lochelOpenModelica-Hudson
authored andcommitted
[FMI2] Calculate real values if needed
1 parent 0047730 commit 16c107e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

SimulationRuntime/fmi/export/fmi2/fmu2_model_interface.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,15 +592,29 @@ fmi2Status fmi2Reset(fmi2Component c)
592592
fmi2Status fmi2GetReal(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Real value[])
593593
{
594594
int i;
595-
ModelInstance *comp = (ModelInstance *)c;
595+
ModelInstance *comp = (ModelInstance*)c;
596+
596597
if (invalidState(comp, "fmi2GetReal", modelInitializationMode|modelEventMode|modelContinuousTimeMode|modelTerminated|modelError, ~0))
597598
return fmi2Error;
598599
if (nvr > 0 && nullPointer(comp, "fmi2GetReal", "vr[]", vr))
599600
return fmi2Error;
600601
if (nvr > 0 && nullPointer(comp, "fmi2GetReal", "value[]", value))
601602
return fmi2Error;
603+
602604
#if NUMBER_OF_REALS > 0
603-
for (i = 0; i < nvr; i++) {
605+
if (comp->_need_update)
606+
{
607+
comp->fmuData->callback->functionODE(comp->fmuData, comp->threadData);
608+
overwriteOldSimulationData(comp->fmuData);
609+
comp->fmuData->callback->functionAlgebraics(comp->fmuData, comp->threadData);
610+
comp->fmuData->callback->output_function(comp->fmuData, comp->threadData);
611+
comp->fmuData->callback->function_storeDelayed(comp->fmuData, comp->threadData);
612+
storePreValues(comp->fmuData);
613+
comp->_need_update = 0;
614+
}
615+
616+
for (i = 0; i < nvr; i++)
617+
{
604618
if (vrOutOfRange(comp, "fmi2GetReal", vr[i], NUMBER_OF_REALS))
605619
return fmi2Error;
606620
value[i] = getReal(comp, vr[i]); // to be implemented by the includer of this file

0 commit comments

Comments
 (0)