You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I simulate a FMU generated from the Modelica Standard Library I get a bounds error.
How to reproduce
Consider the following minimal example with a CS-ME 2.0 FMU Modelica.Mechanics.Translational.Examples.Damper.fmu generatet from OpenModelica (OMCompiler v1.19.0-dev.505+ga499198eb3):
using FMI
myFMU =fmiLoad("Modelica.Mechanics.Translational.Examples.Damper.fmu")
fmiInstantiate!(myFMU)
success, simData =fmiSimulate(myFMU, 0.0, 1.0)
The error message:
julia> success, simData =fmiSimulate(myFMU, 0.0, 1.0)
ERROR: BoundsError: attempt to access Bool at index [2]
Stacktrace:
[1] indexed_iterate(I::Bool, i::Int64, state::Nothing)
@ Base ./tuple.jl:98
[2] top-level scope
@ REPL[4]:1
OMSimulator can simulate the FMU fine, so I guess it is not an issue with the FMU. But I didn't test a non-OpenModelica tool on it.
but when I remove recordValues from the call the return value will change and only return one bool success. And that is the reason for the error.
Is this a good idea to have the function interface change on a optional argument? I expected it to save all variables when I don't specifically tell fmiSimulate what I want to save, but instead it saved nothing.
Believe it or not: We already had this discussion internally :-D
Should a function always return the same pattern? There are pros and cons, but we decided to don't return "dummy"-values if they are not needed/used. On the other hand many languages don't support this return feature, so for developers from these languages this behaviour is a bit unexpected. We decided to use the language features of Julia in this case. (you can call ?fmi2Simulate, the keyword arguments and return values are explained there)
Activity
AnHeuermann commentedon Jan 11, 2022
Okay, I just called the
simulatefunction wrong. From the README I got that I can call it likebut when I remove
recordValuesfrom the call the return value will change and only return one boolsuccess. And that is the reason for the error.Is this a good idea to have the function interface change on a optional argument? I expected it to save all variables when I don't specifically tell fmiSimulate what I want to save, but instead it saved nothing.
ThummeTo commentedon Jan 11, 2022
Believe it or not: We already had this discussion internally :-D
Should a function always return the same pattern? There are pros and cons, but we decided to don't return "dummy"-values if they are not needed/used. On the other hand many languages don't support this return feature, so for developers from these languages this behaviour is a bit unexpected. We decided to use the language features of Julia in this case. (you can call
?fmi2Simulate, the keyword arguments and return values are explained there)But I am open for other opinions of course!
BTW: I will move this to discussions.