Skip to content

Commit 8001d8b

Browse files
authored
v1.0.6 (#126)
* minor bug fixes * forcing FMIBase v1.0.8
1 parent 7947fc1 commit 8001d8b

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "FMIImport"
22
uuid = "9fcbc62e-52a0-44e9-a616-1359a0008194"
33
authors = ["TT <tobias.thummerer@informatik.uni-augsburg.de>", "LM <lars.mikelsons@informatik.uni-augsburg.de>", "JK <josef.kircher@student.uni-augsburg.de>"]
4-
version = "1.0.5"
4+
version = "1.0.6"
55

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

1818
[compat]
1919
Downloads = "1"
20-
FMIBase = "1.0.0"
20+
FMIBase = "1.0.8"
2121
Libdl = "1"
2222
RelocatableFolders = "1"
2323
julia = "1.6"

src/FMI2/prep.jl

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ function prepareSolveFMU(
4545

4646
ignore_derivatives() do
4747

48+
autoInstantiated = false
49+
4850
# instantiate (hard)
4951
if instantiate
5052
# remove old one if we missed it (callback)
@@ -58,13 +60,15 @@ function prepareSolveFMU(
5860
end
5961

6062
c = fmi2Instantiate!(fmu; type = type, instantiateKwargs...)
63+
6164
else # use existing instance
6265
if c === nothing
6366
if hasCurrentInstance(fmu)
6467
c = getCurrentInstance(fmu)
6568
else
6669
@warn "Found no FMU instance, but executionConfig doesn't force allocation. Allocating one.\nUse `fmi2Instantiate(fmu)` to prevent this message."
6770
c = fmi2Instantiate!(fmu; type = type, instantiateKwargs...)
71+
autoInstantiated = true
6872
end
6973
end
7074
end
@@ -183,11 +187,19 @@ function prepareSolveFMU(
183187
x0 = fmi2GetContinuousStates(c)
184188
end
185189

186-
if instantiate || reset # we have a fresh instance
187-
@debug "[NEW INST]"
190+
if instantiate || reset # autoInstantiated
191+
192+
if !setup
193+
@debug "[AUTO] setup"
194+
195+
fmi2SetupExperiment(c, t_start, t_stop; tolerance = tolerance)
196+
fmi2EnterInitializationMode(c)
197+
fmi2ExitInitializationMode(c)
198+
end
199+
188200
handleEvents(c)
189201
end
190-
202+
191203
c.fmu.hasStateEvents = (c.fmu.modelDescription.numberOfEventIndicators > 0)
192204
c.fmu.hasTimeEvents = isTrue(c.eventInfo.nextEventTimeDefined)
193205
end
@@ -208,7 +220,7 @@ function prepareSolveFMU(
208220
elseif type == :SE
209221
@assert false "FMU type `SE` is not supported in FMI2!"
210222
else
211-
@assert false "Unknwon FMU type `$(type)`"
223+
@assert false "Unknown FMU type `$(type)`"
212224
end
213225
end
214226

@@ -241,7 +253,7 @@ function finishSolveFMU(
241253

242254
# freeInstance (hard)
243255
if freeInstance
244-
fmi2FreeInstance!(c; popComponent = popComponent) # , doccall=freeInstance
256+
fmi2FreeInstance!(c; popComponent = popComponent)
245257
c = nothing
246258
end
247259
end

src/FMI3/prep.jl

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ function prepareSolveFMU(
4242

4343
ignore_derivatives() do
4444

45+
autoInstantiated = false
46+
4547
c = nothing
4648

4749
# instantiate (hard)
@@ -53,7 +55,7 @@ function prepareSolveFMU(
5355
elseif type == fmi3TypeScheduledExecution
5456
c = fmi3InstantiateScheduledExecution!(fmu; instantiateKwargs...)
5557
else
56-
@assert false "Unknwon fmi3Type `$(type)`"
58+
@assert false "Unknown fmi3Type `$(type)`"
5759
end
5860
else
5961
if c === nothing
@@ -63,12 +65,15 @@ function prepareSolveFMU(
6365
@warn "Found no FMU instance, but executionConfig doesn't force allocation. Allocating one. Use `fmi3Instantiate[TYPE](fmu)` to prevent this message."
6466
if type == fmi3TypeCoSimulation
6567
c = fmi3InstantiateCoSimulation!(fmu; instantiateKwargs...)
68+
autoInstantiated = true
6669
elseif type == fmi3TypeModelExchange
6770
c = fmi3InstantiateModelExchange!(fmu; instantiateKwargs...)
71+
autoInstantiated = true
6872
elseif type == fmi3TypeScheduledExecution
6973
c = fmi3InstantiateScheduledExecution!(fmu; instantiateKwargs...)
74+
autoInstantiated = true
7075
else
71-
@assert false "Unknwon FMU type `$(type)`."
76+
@assert false "Unknown FMU type `$(type)`."
7277
end
7378
end
7479
end
@@ -181,8 +186,14 @@ function prepareSolveFMU(
181186
x0 = fmi3GetContinuousStates(c)
182187
end
183188

184-
if instantiate || reset # we have a fresh instance
185-
@debug "[NEW INST]"
189+
if instantiate || reset # autoInstantiated
190+
@debug "[AUTO] setup"
191+
192+
if !setup
193+
fmi3EnterInitializationMode(c, t_start, t_stop; tolerance = tolerance)
194+
fmi3ExitInitializationMode(c)
195+
end
196+
186197
handleEvents(c)
187198
end
188199

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

0 commit comments

Comments
 (0)