Skip to content

Commit

Permalink
Keyword and non-keyword definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
CasBex committed Aug 17, 2023
1 parent b66511b commit ebb7610
Showing 1 changed file with 43 additions and 18 deletions.
61 changes: 43 additions & 18 deletions src/FMI2/sens.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ Not all options are available for any FMU type, e.g. setting state is not suppor
- `y::Union{AbstractVector{<:Real}, Nothing}`: The system output `y` (if requested, otherwise `nothing`).
- `dx::Union{AbstractVector{<:Real}, Nothing}`: The system state-derivaitve (if ME-FMU, otherwise `nothing`).
"""
function (fmu::FMU2)(;dx::AbstractVector{<:Real}=Vector{fmi2Real}(),
y::AbstractVector{<:Real}=Vector{fmi2Real}(),
y_refs::AbstractVector{<:fmi2ValueReference}=Vector{fmi2ValueReference}(),
x::AbstractVector{<:Real}=Vector{fmi2Real}(),
u::AbstractVector{<:Real}=Vector{fmi2Real}(),
u_refs::AbstractVector{<:fmi2ValueReference}=Vector{fmi2ValueReference}(),
p::AbstractVector{<:Real}=fmu.optim_p,
p_refs::AbstractVector{<:fmi2ValueReference}=fmu.optim_p_refs,
t::Real=-1.0)
function (fmu::FMU2)(dx::AbstractVector{<:Real},
y::AbstractVector{<:Real},
y_refs::AbstractVector{<:fmi2ValueReference},
x::AbstractVector{<:Real},
u::AbstractVector{<:Real},
u_refs::AbstractVector{<:fmi2ValueReference},
p::AbstractVector{<:Real},
p_refs::AbstractVector{<:fmi2ValueReference},
t::Real)

if hasCurrentComponent(fmu)
c = getCurrentComponent(fmu)
Expand All @@ -95,6 +95,18 @@ function (fmu::FMU2)(;dx::AbstractVector{<:Real}=Vector{fmi2Real}(),
c(;dx=dx, y=y, y_refs=y_refs, x=x, u=u, u_refs=u_refs, p=p, p_refs=p_refs, t=t)
end

function (fmu::FMU2)(;dx::AbstractVector{<:Real}=Vector{fmi2Real}(),
y::AbstractVector{<:Real}=Vector{fmi2Real}(),
y_refs::AbstractVector{<:fmi2ValueReference}=Vector{fmi2ValueReference}(),
x::AbstractVector{<:Real}=Vector{fmi2Real}(),
u::AbstractVector{<:Real}=Vector{fmi2Real}(),
u_refs::AbstractVector{<:fmi2ValueReference}=Vector{fmi2ValueReference}(),
p::AbstractVector{<:Real}=fmu.optim_p,
p_refs::AbstractVector{<:fmi2ValueReference}=fmu.optim_p_refs,
t::Real=-1.0)
(fmu)(dx, y, y_refs, x, u, u_refs, p, p_refs, t)
end

"""
(c::FMU2Component)(;dx::Union{AbstractVector{<:Real}, Nothing}=nothing,
Expand Down Expand Up @@ -123,15 +135,16 @@ Not all options are available for any FMU type, e.g. setting state is not suppor
- `y::Union{AbstractVector{<:Real}, Nothing}`: The system output `y` (if requested, otherwise `nothing`).
- `dx::Union{AbstractVector{<:Real}, Nothing}`: The system state-derivaitve (if ME-FMU, otherwise `nothing`).
"""
function (c::FMU2Component)(;dx::AbstractVector{<:Real}=Vector{fmi2Real}(),
y::AbstractVector{<:Real}=Vector{fmi2Real}(),
y_refs::AbstractVector{<:fmi2ValueReference}=Vector{fmi2ValueReference}(),
x::AbstractVector{<:Real}=Vector{fmi2Real}(),
u::AbstractVector{<:Real}=Vector{fmi2Real}(),
u_refs::AbstractVector{<:fmi2ValueReference}=Vector{fmi2ValueReference}(),
p::AbstractVector{<:Real}=c.fmu.optim_p,
p_refs::AbstractVector{<:fmi2ValueReference}=c.fmu.optim_p_refs,
t::Real=c.next_t)
function (c::FMU2Component)(dx::AbstractVector{<:Real},
y::AbstractVector{<:Real},
y_refs::AbstractVector{<:fmi2ValueReference},
x::AbstractVector{<:Real},
u::AbstractVector{<:Real},
u_refs::AbstractVector{<:fmi2ValueReference},
p::AbstractVector{<:Real},
p_refs::AbstractVector{<:fmi2ValueReference},
t::Real)


if length(y_refs) > 0
if length(y) <= 0
Expand Down Expand Up @@ -170,6 +183,18 @@ function (c::FMU2Component)(;dx::AbstractVector{<:Real}=Vector{fmi2Real}(),
return eval!(cRef, dx, y, y_refs, x, u, u_refs, p, p_refs, t)
end

function (c::FMU2Component)(;dx::AbstractVector{<:Real}=Vector{fmi2Real}(),
y::AbstractVector{<:Real}=Vector{fmi2Real}(),
y_refs::AbstractVector{<:fmi2ValueReference}=Vector{fmi2ValueReference}(),
x::AbstractVector{<:Real}=Vector{fmi2Real}(),
u::AbstractVector{<:Real}=Vector{fmi2Real}(),
u_refs::AbstractVector{<:fmi2ValueReference}=Vector{fmi2ValueReference}(),
p::AbstractVector{<:Real}=c.fmu.optim_p,
p_refs::AbstractVector{<:fmi2ValueReference}=c.fmu.optim_p_refs,
t::Real=c.next_t)
(c)(dx, y, y_refs, x, u, u_refs, p, p_refs, t)
end

function eval!(cRef::UInt64,
dx::AbstractVector{<:Real},
y::AbstractVector{<:Real},
Expand Down

0 comments on commit ebb7610

Please sign in to comment.