Skip to content

Commit

Permalink
fixed docs for nonFMI spec fucs & notes to plot funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
0815Creeper committed Oct 18, 2023
1 parent cba5d87 commit b51568e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 62 deletions.
32 changes: 14 additions & 18 deletions src/FMI2/additional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ using FMIImport: fmi2CallbackFunctions, fmi2Component
import FMIImport: fmi2VariableNamingConventionFlat, fmi2VariableNamingConventionStructured

"""
Returns how a variable depends on another variable based on the model description.
fmi2VariableDependsOnVariable(fmu::FMU2, vr1::fmi2ValueReference, vr2::fmi2ValueReference)
Return the dependence of the variable described by `vr1` on another variable described by `vr2` based on the model description of the `fmu`.
See also [`fmi2GetDependencies`](@ref).
"""
function fmi2VariableDependsOnVariable(fmu::FMU2, vr1::fmi2ValueReference, vr2::fmi2ValueReference)
i1 = fmu.modelDescription.valueReferenceIndicies[vr1]
Expand All @@ -27,23 +30,16 @@ function fmi2VariableDependsOnVariable(fmu::FMU2, vr1::fmi2ValueReference, vr2::
end

"""
fmi2GetDependencies(fmu::FMU2)
Building dependency matrix `dim x dim` for fast look-ups on variable dependencies (`dim` is number of states).
# Arguments
- `fmu::FMU2`: Mutable Struct representing a FMU.
# Retruns
- `fmu.dependencies::Matrix{Union{fmi2DependencyKind, Nothing}}`: Returns the FMU's dependency-matrix for fast look-ups on dependencies between value references. Entries are from type fmi2DependencyKind.
Build dependency `Matrix{Union{fmi2DependencyKind, Nothing}}` of dimension `n x n` for fast look-ups on dependencies between value references (`n` is number of states of the `fmu`).
# Source
- FMISpec2.0.2 Link: [https://fmi-standard.org/](https://fmi-standard.org/)
- FMISpec2.0.2[p.22]: 2.1.4 Inquire Platform and Version Number of Header Files
- FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions
See also [`fmi2GetDependencies`](@ref).
See also [`fmi2PrintDependencies`](@ref), [`fmi2VariableDependsOnVariable`](@ref).
"""
function fmi2GetDependencies(fmu::FMU2)
if !isdefined(fmu, :dependencies)
Expand Down Expand Up @@ -85,6 +81,13 @@ function fmi2GetDependencies(fmu::FMU2)
fmu.dependencies
end

"""
fmi2PrintDependencies(fmu::FMU2)
Print the dependency matrix for `fmu` as returned by [`fmi2GetDependencies`](@ref).
See also [`fmi2GetDependencies`](@ref).
"""
function fmi2PrintDependencies(fmu::FMU2)
dep = fmi2GetDependencies(fmu)
ni, nj = size(dep)
Expand All @@ -99,16 +102,9 @@ function fmi2PrintDependencies(fmu::FMU2)
end

"""
fmi2Info(fmu::FMU2)
Prints FMU related information.
# Arguments
- `fmu::FMU2`: Mutable struct representing a FMU and all it instantiated instances in the FMI 2.0.2 Standard.
# Returns
- Prints FMU related information.
Print information about the `fmu`.
# Source
- FMISpec2.0.2 Link: [https://fmi-standard.org/](https://fmi-standard.org/)
Expand Down
37 changes: 6 additions & 31 deletions src/FMI2/extensions/Plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,17 @@ using FMIImport: FMU2Solution
import FMIImport.ForwardDiff

"""
fmiPlot(solution::FMU2Solution; states::Union{Bool, Nothing}=nothing,
values::Union{Bool, Nothing}=nothing,
stateEvents::Union{Bool, Nothing}=nothing,
timeEvents::Union{Bool, Nothing}=nothing,
stateIndices=nothing,
valueIndices=nothing,
maxLabelLength=64,
plotkwargs...)
Plots data from a ME-FMU.
Optional `t_in_solution` controls if the first state in the solution is interpreted as t(ime).
# Arguments
- `solution::FMU2Solution`: Struct contains information about the solution `value`, `success`, `state` and `events` of a specific FMU.
# Keywords
- `states::Union{Bool, Nothing}`: controls if states should be ploted (default = nothing)
- `values::Union{Bool, Nothing}`: controls if values should be ploted (default = nothing)
- `timeEvents::Union{Bool, Nothing}=nothing`: controls if timeEvents should be ploted (default = noting )
- `stateIndices=nothing`: controls the number of ploted states
- `valueIndices=nothing`: controls the number of ploted values
- `maxLabelLength=64`: controls the maximum length for legend labels (too long labels are cut from front)
# Returns
- `fig `: Returns a figure containing the plotted data from a ME-FMU.
function no longer here... (hopefully)
"""
function fmiPlot(solution::FMU2Solution; kwargs...)
fig = Plots.plot(; xlabel="t [s]")
fmiPlot!(fig, solution; kwargs...)
return fig
end

"""
function no longer here... (hopefully)
"""
function fmiPlot!(fig, solution::FMU2Solution;
states::Union{Bool, Nothing}=nothing,
values::Union{Bool, Nothing}=nothing,
Expand Down Expand Up @@ -196,9 +173,7 @@ function fmiPlot!(fig, solution::FMU2Solution;
end

"""
Extended the original plot-command by plotting FMUs.
For further information seek `?fmiPlot`.
function no longer here... (hopefully)
"""
function Plots.plot(solution::FMU2Solution, args...; kwargs...)
fmiPlot(solution, args...; kwargs...)
Expand Down
27 changes: 21 additions & 6 deletions src/FMI3/additional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ using FMIImport: fmi3DependencyKindDependent, fmi3DependencyKindFixed
using FMIImport: fmi3CallbackLogger, fmi3CallbackIntermediateUpdate, fmi3CallbackClockUpdate, fmi3Instance
import FMIImport: fmi3VariableNamingConventionFlat, fmi3VariableNamingConventionStructured

"""
Returns how a variable depends on another variable based on the model description.
"""
fmi3VariableDependsOnVariable(fmu::FMU3, vr1::fmi3ValueReference, vr2::fmi3ValueReference)
Return the dependence of the variable described by `vr1` on another variable described by `vr2` based on the model description of the `fmu`.
See also [`fmi3GetDependencies`](@ref).
"""
function fmi3VariableDependsOnVariable(fmu::FMU3, vr1::fmi3ValueReference, vr2::fmi3ValueReference)
i1 = fmu.modelDescription.valueReferenceIndicies[vr1]
Expand All @@ -26,9 +30,11 @@ function fmi3VariableDependsOnVariable(fmu::FMU3, vr1::fmi3ValueReference, vr2::
end

"""
Returns the FMU's dependency-matrix for fast look-ups on dependencies between value references.
fmi3GetDependencies(fmu::FMU3)
Entries are from type fmi3DependencyKind.
Build dependency `Matrix{Union{fmi3DependencyKind, Nothing}}` of dimension `n x n` for fast look-ups on dependencies between value references (`n` is number of states of the `fmu`).
See also [`fmi3PrintDependencies`](@ref), [`fmi3VariableDependsOnVariable`](@ref).
"""
function fmi3GetDependencies(fmu::FMU3)
if !isdefined(fmu, :dependencies)
Expand Down Expand Up @@ -70,7 +76,14 @@ function fmi3GetDependencies(fmu::FMU3)
fmu.dependencies
end

function fmi3PrintDependencies(fmu::FMU2)
"""
fmi3PrintDependencies(fmu::FMU3)
Print the dependency matrix for `fmu` as returned by [`fmi3GetDependencies`](@ref).
See also [`fmi3GetDependencies`](@ref).
"""
function fmi3PrintDependencies(fmu::FMU3)
dep = fmi3GetDependencies(fmu)
ni, nj = size(dep)

Expand All @@ -84,7 +97,9 @@ function fmi3PrintDependencies(fmu::FMU2)
end

"""
Prints FMU related information.
fmi3Info(fmu::FMU3)
Print information about the `fmu`.
"""
function fmi3Info(fmu::FMU3)
println("#################### Begin information for FMU ####################")
Expand Down
13 changes: 6 additions & 7 deletions src/FMI3/extensions/Plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ using FMIImport: FMU3Solution
import FMIImport.ForwardDiff

"""
Plots data from a ME-FMU.
Optional `t_in_solution` controls if the first state in the solution is interpreted as t(ime).
Optional keyword argument `maxLabelLength` controls the maximum length for legend labels (too long labels are cut from front).
function no longer here... (hopefully)
"""
function fmiPlot(solution::FMU3Solution; kwargs...)
fig = Plots.plot(; xlabel="t [s]")
fmiPlot!(fig, solution; kwargs...)
return fig
end

"""
function no longer here... (hopefully)
"""
function fmiPlot!(fig, solution::FMU3Solution;
states::Union{Bool, Nothing}=nothing,
values::Union{Bool, Nothing}=nothing,
Expand Down Expand Up @@ -168,9 +169,7 @@ function fmiPlot!(fig, solution::FMU3Solution;
end

"""
Extended the original plot-command by plotting FMUs.
For further information seek `?fmiPlot`.
function no longer here... (hopefully)
"""
function Plots.plot(solution::FMU3Solution, args...; kwargs...)
fmiPlot(solution, args...; kwargs...)
Expand Down

0 comments on commit b51568e

Please sign in to comment.