Skip to content

Commit

Permalink
v1.0.6 (#126)
Browse files Browse the repository at this point in the history
* minor bug fixes

* forcing FMIBase v1.0.8
  • Loading branch information
ThummeTo authored Sep 10, 2024
1 parent 7947fc1 commit 8001d8b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FMIImport"
uuid = "9fcbc62e-52a0-44e9-a616-1359a0008194"
authors = ["TT <[email protected]>", "LM <[email protected]>", "JK <[email protected]>"]
version = "1.0.5"
version = "1.0.6"

[deps]
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Expand All @@ -17,7 +17,7 @@ FMIZooExt = ["FMIZoo"]

[compat]
Downloads = "1"
FMIBase = "1.0.0"
FMIBase = "1.0.8"
Libdl = "1"
RelocatableFolders = "1"
julia = "1.6"
22 changes: 17 additions & 5 deletions src/FMI2/prep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ function prepareSolveFMU(

ignore_derivatives() do

autoInstantiated = false

# instantiate (hard)
if instantiate
# remove old one if we missed it (callback)
Expand All @@ -58,13 +60,15 @@ function prepareSolveFMU(
end

c = fmi2Instantiate!(fmu; type = type, instantiateKwargs...)

else # use existing instance
if c === nothing
if hasCurrentInstance(fmu)
c = getCurrentInstance(fmu)
else
@warn "Found no FMU instance, but executionConfig doesn't force allocation. Allocating one.\nUse `fmi2Instantiate(fmu)` to prevent this message."
c = fmi2Instantiate!(fmu; type = type, instantiateKwargs...)
autoInstantiated = true
end
end
end
Expand Down Expand Up @@ -183,11 +187,19 @@ function prepareSolveFMU(
x0 = fmi2GetContinuousStates(c)
end

if instantiate || reset # we have a fresh instance
@debug "[NEW INST]"
if instantiate || reset # autoInstantiated

if !setup
@debug "[AUTO] setup"

fmi2SetupExperiment(c, t_start, t_stop; tolerance = tolerance)
fmi2EnterInitializationMode(c)
fmi2ExitInitializationMode(c)
end

handleEvents(c)
end

c.fmu.hasStateEvents = (c.fmu.modelDescription.numberOfEventIndicators > 0)
c.fmu.hasTimeEvents = isTrue(c.eventInfo.nextEventTimeDefined)
end
Expand All @@ -208,7 +220,7 @@ function prepareSolveFMU(
elseif type == :SE
@assert false "FMU type `SE` is not supported in FMI2!"
else
@assert false "Unknwon FMU type `$(type)`"
@assert false "Unknown FMU type `$(type)`"
end
end

Expand Down Expand Up @@ -241,7 +253,7 @@ function finishSolveFMU(

# freeInstance (hard)
if freeInstance
fmi2FreeInstance!(c; popComponent = popComponent) # , doccall=freeInstance
fmi2FreeInstance!(c; popComponent = popComponent)
c = nothing
end
end
Expand Down
21 changes: 16 additions & 5 deletions src/FMI3/prep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ function prepareSolveFMU(

ignore_derivatives() do

autoInstantiated = false

c = nothing

# instantiate (hard)
Expand All @@ -53,7 +55,7 @@ function prepareSolveFMU(
elseif type == fmi3TypeScheduledExecution
c = fmi3InstantiateScheduledExecution!(fmu; instantiateKwargs...)
else
@assert false "Unknwon fmi3Type `$(type)`"
@assert false "Unknown fmi3Type `$(type)`"
end
else
if c === nothing
Expand All @@ -63,12 +65,15 @@ function prepareSolveFMU(
@warn "Found no FMU instance, but executionConfig doesn't force allocation. Allocating one. Use `fmi3Instantiate[TYPE](fmu)` to prevent this message."
if type == fmi3TypeCoSimulation
c = fmi3InstantiateCoSimulation!(fmu; instantiateKwargs...)
autoInstantiated = true
elseif type == fmi3TypeModelExchange
c = fmi3InstantiateModelExchange!(fmu; instantiateKwargs...)
autoInstantiated = true
elseif type == fmi3TypeScheduledExecution
c = fmi3InstantiateScheduledExecution!(fmu; instantiateKwargs...)
autoInstantiated = true
else
@assert false "Unknwon FMU type `$(type)`."
@assert false "Unknown FMU type `$(type)`."
end
end
end
Expand Down Expand Up @@ -181,8 +186,14 @@ function prepareSolveFMU(
x0 = fmi3GetContinuousStates(c)
end

if instantiate || reset # we have a fresh instance
@debug "[NEW INST]"
if instantiate || reset # autoInstantiated
@debug "[AUTO] setup"

if !setup
fmi3EnterInitializationMode(c, t_start, t_stop; tolerance = tolerance)
fmi3ExitInitializationMode(c)
end

handleEvents(c)
end

Expand All @@ -202,7 +213,7 @@ function prepareSolveFMU(fmu::FMU3, c::Union{Nothing,FMU3Instance}, type::Symbol
elseif type == :SE
return prepareSolveFMU(fmu, c, fmi3TypeScheduledExecution; kwargs...)
else
@assert false "Unknwon FMU type `$(type)`"
@assert false "Unknown FMU type `$(type)`"
end
end

Expand Down

2 comments on commit 8001d8b

@ThummeTo
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/114909

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.6 -m "<description of version>" 8001d8bc4d34ba21d768c8bed85deca8c2575817
git push origin v1.0.6

Please sign in to comment.