Skip to content

Commit

Permalink
Merge branch 'v0.4.1' into formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
0815Creeper authored Dec 16, 2024
2 parents 33a61a2 + 700e1dd commit d60b8bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 0 additions & 1 deletion examples/FMI2/BouncingBall/src/BouncingBall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 9 additions & 2 deletions src/FMI2_simple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit d60b8bc

Please sign in to comment.