diff --git a/examples/FMI2/BouncingBall/src/BouncingBall.jl b/examples/FMI2/BouncingBall/src/BouncingBall.jl index 96058fb..d97feeb 100644 --- a/examples/FMI2/BouncingBall/src/BouncingBall.jl +++ b/examples/FMI2/BouncingBall/src/BouncingBall.jl @@ -55,7 +55,6 @@ FMU_FCT_EVALUATE = function (t, x_c, ẋ_c, x_d, u, p, eventMode) v = 0.0 end end - end a = (m * -g) / m # the system's physical equation (a little longer than necessary) diff --git a/src/FMI2_simple.jl b/src/FMI2_simple.jl index a6d93da..94ba0a8 100644 --- a/src/FMI2_simple.jl +++ b/src/FMI2_simple.jl @@ -64,7 +64,7 @@ function evaluate(_component::fmi2Component, eventMode = false) if eventMode # overwrite state vector allowed component.eventInfo.valuesOfContinuousStatesChanged = - (xc != tmp_xc ? fmi2True : fmi2False) + (xc != tmp_xc ? fmi2True : component.eventInfo.valuesOfContinuousStatesChanged) #component.eventInfo.newDiscreteStatesNeeded = (xd != tmp_xd ? fmi2True : fmi2False) xc = tmp_xc @@ -508,6 +508,7 @@ function simple_fmi2SetContinuousStates( component, "fmi2SetContinuousStates: Model has $(length(component.fmu.modelDescription.stateValueReferences)) states, but `nx`=$(nx).", ) + return fmi2StatusWarning end x = unsafe_wrap(Array{fmi2Real}, _x, nx) @@ -555,8 +556,10 @@ function simple_fmi2NewDiscreteStates( component.eventInfo.valuesOfContinuousStatesChanged eventInfo.nextEventTimeDefined = fmi2False # [ToDo] eventInfo.nextEventTime = 0.0 # [ToDo] - unsafe_store!(_fmi2eventInfo, eventInfo) + unsafe_store!(_fmi2eventInfo, eventInfo); + # reset + eventInfo.valuesOfContinuousStatesChanged = fmi2False return fmi2StatusOK end @@ -597,6 +600,7 @@ function simple_fmi2GetDerivatives( component, "fmi2GetDerivatives: Model has $(length(component.fmu.modelDescription.derivativeValueReferences)) states, but `nx`=$(nx).", ) + return fmi2StatusWarning end derivatives = unsafe_wrap(Array{fmi2Real}, _derivatives, nx) @@ -621,6 +625,7 @@ function simple_fmi2GetEventIndicators( component, "fmi2GetEventIndicators: Model has $(length(component.eventIndicators)) states, but `ni`=$(ni).", ) + return fmi2StatusWarning end eventIndicators = unsafe_wrap(Array{fmi2Real}, _eventIndicators, ni) @@ -648,6 +653,7 @@ function simple_fmi2GetContinuousStates( component, "fmi2GetContinuousStates: Model has $(length(component.fmu.modelDescription.stateValueReferences)) states, but `nx`=$(nx).", ) + return fmi2StatusWarning end x = unsafe_wrap(Array{fmi2Real}, _x, nx) @@ -672,6 +678,7 @@ function simple_fmi2GetNominalsOfContinuousStates( component, "fmi2GetNominalsOfContinuousStates: Model has $(length(component.fmu.modelDescription.stateValueReferences)) states, but `nx`=$(nx).", ) + return fmi2StatusWarning end x_nominal = unsafe_wrap(Array{fmi2Real}, _x_nominal, nx)