Skip to content

Commit

Permalink
minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThummeTo committed Sep 3, 2024
1 parent 2152154 commit 6d5fca0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FMIBase"
uuid = "900ee838-d029-460e-b485-d98a826ceef2"
authors = ["TT <[email protected]>", "LM <[email protected]>"]
version = "1.0.6"
version = "1.0.7"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
2 changes: 1 addition & 1 deletion ext/DataFramesExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function DataFrames.DataFrame(solution::FMUSolution)
df[
!,
Symbol(
valueReferenceToString(solution.component.fmu, solution.valueReferences[i]),
valueReferenceToString(solution.instance.fmu, solution.valueReferences[i]),
),
] = [val[i] for val in solution.values.saveval]
end
Expand Down
25 changes: 23 additions & 2 deletions src/snapshot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function snapshot!(c::FMUInstance)
return s
end
function snapshot!(sol::FMUSolution)
s = snapshot!(sol.component)
s = snapshot!(sol.instance)
push!(sol.snapshots, s)
return s
end
Expand Down Expand Up @@ -57,7 +57,28 @@ function getSnapshot(c::Union{FMU,FMUSolution}, t::Float64; exact::Bool = false,
# [Note] only take exact fit if we are at 0, otherwise take the next left,
# because we are saving snapshots for the right root of events.

@assert t (-Inf, Inf) "t = $(t), this is not allowed for snapshot search!"
#@assert t ∉ (-Inf, Inf) "t = $(t), this is not allowed for snapshot search!"
# if t == Inf
# if length(c.snapshots) > 0
# @warn "t = $(t), this is not allowed for snapshot search!\nFallback to left-most snapshot!"
# left = snapshots[1]
# for snapshot in c.snapshots
# if snapshot.t < left.t
# left = snapshot
# end
# end
# return left
# else
# @warn "t = $(t), this is not allowed for snapshot search!\nNo snapshots available, returning nothing!"
# return nothing
# end
# end

if t (-Inf, Inf)
@warn "t = $(t), this is not allowed for snapshot search! Returning nothing!"
return nothing
end

@assert length(c.snapshots) > 0 "No snapshots available!"

left = c.snapshots[1]
Expand Down
2 changes: 1 addition & 1 deletion src/struct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ Overload the Base.show() function for custom printing of the FMU2.
function Base.show(io::IO, sol::FMUSolution)
print(
io,
"Model name:\n\t$(sol.component.fmu.modelDescription.modelName)\nSuccess:\n\t$(sol.success)\n",
"Model name:\n\t$(sol.instance.fmu.modelDescription.modelName)\nSuccess:\n\t$(sol.success)\n",
)

print(io, "f(x)-Evaluations:\n")
Expand Down

0 comments on commit 6d5fca0

Please sign in to comment.