Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force FMI functions to be executed in the correct order/ FMU state #66

Closed
AnHeuermann opened this issue Jan 11, 2022 · 4 comments
Closed

Comments

@AnHeuermann
Copy link

Similar to #64.

The FMI interface functions are only allowed to b executed in a certain order or FMU state. Currently I get errors when I call them in the wrong order. E.g. when calling fmiSimulate before calling fmiInstantiate!:

julia> using FMI
julia> myFMU = fmiLoad("Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum.fmu")
julia> fmiSimulate(myFMU, 0.0, 1.0; recordValues=["rev.w"])
ERROR: BoundsError: attempt to access 0-element Vector{fmi2Component} at index [0]
Stacktrace:
 [1] getindex(A::Vector{fmi2Component}, i1::Int64)
   @ Base ./array.jl:861
 [2] fmi2Simulate(fmu::FMU2, t_start::Float64, t_stop::Float64; kwargs::Base.Pairs{Symbol, Vector{String}, Tuple{Symbol}, NamedTuple{(:recordValues,), Tuple{Vector{String}}}})
   @ FMI ~/.julia/packages/FMI/K8UGW/src/FMI2.jl:585
 [3] #fmiSimulate#57
   @ ~/.julia/packages/FMI/K8UGW/src/FMI.jl:249 [inlined]
 [4] top-level scope
   @ REPL[5]:1
@ThummeTo
Copy link
Owner

So in this case, the suggestion would be a better error message?
Best regards!

@AnHeuermann
Copy link
Author

Basically yes. For this example I would like an error that tells the user to first call fmiInstantiate!.

For the fmi2XXX functions the error of 3.2.3 State Machine of C Calling Sequence should be checked before calling a function. The FMU itself should issue errors as well, maybe that is already enough.

@ThummeTo
Copy link
Owner

Issue solved in version 0.3.7

@ThummeTo
Copy link
Owner

Further, I added checks against the FMI-spec state-machine in 0.3.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants