diff --git a/BouncingBall/FMI2.xml b/BouncingBall/FMI2.xml index 01ef5691..e9c0f391 100644 --- a/BouncingBall/FMI2.xml +++ b/BouncingBall/FMI2.xml @@ -64,7 +64,7 @@ - + diff --git a/BouncingBall/FMI3.xml b/BouncingBall/FMI3.xml index 915db887..a462bdae 100644 --- a/BouncingBall/FMI3.xml +++ b/BouncingBall/FMI3.xml @@ -49,7 +49,7 @@ - + diff --git a/BouncingBall/model.c b/BouncingBall/model.c index 8f6a8558..518a1921 100644 --- a/BouncingBall/model.c +++ b/BouncingBall/model.c @@ -58,10 +58,26 @@ Status setFloat64(ModelInstance* comp, ValueReference vr, const double value[], switch (vr) { case vr_h: +#if FMI_VERSION > 1 + if (comp->state != Instantiated && + comp->state != InitializationMode && + comp->state != ContinuousTimeMode) { + logError(comp, "Variable \"h\" can only be set in Instantiated Mode, Initialization Mode, and Continuous Time Mode."); + return Error; + } +#endif M(h) = value[(*index)++]; return OK; case vr_v: +#if FMI_VERSION > 1 + if (comp->state != Instantiated && + comp->state != InitializationMode && + comp->state != ContinuousTimeMode) { + logError(comp, "Variable \"v\" can only be set in Instantiated Mode, Initialization Mode, and Continuous Time Mode."); + return Error; + } +#endif M(v) = value[(*index)++]; return OK;