Skip to content

Adding inputs and outputs functions #1209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/ModelingToolkit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ function states end
"""
$(TYPEDSIGNATURES)

Get the set of states decorated as inputs for the given system.
"""
function inputs end

"""
$(TYPEDSIGNATURES)

Get the set of states decorated as outputs for the given system.
"""
function outputs end

"""
$(TYPEDSIGNATURES)

Get the set of parameters variables for the given system.
"""
function parameters end
Expand Down Expand Up @@ -173,7 +187,7 @@ export Differential, expand_derivatives, @derivatives
export Equation, ConstrainedEquation
export Term, Sym
export SymScope, LocalScope, ParentScope, GlobalScope
export independent_variables, independent_variable, states, parameters, equations, controls, observed, structure
export independent_variables, independent_variable, states, parameters, equations, controls, observed, structure, inputs, outputs
export structural_simplify
export DiscreteSystem, DiscreteProblem

Expand Down
9 changes: 9 additions & 0 deletions src/systems/abstractsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,15 @@ function states(sys::AbstractSystem)
[sts; reduce(vcat,namespace_variables.(systems))])
end

function inputs(sys::AbstractSystem)
[st for st in states(sys) if isinput(st)]
end

function outputs(sys::AbstractSystem)
sts = vcat(states(sys), map(x->x.lhs, observed(sys)))
[st for st in sts if isoutput(st)]
end

function parameters(sys::AbstractSystem)
ps = get_ps(sys)
systems = get_systems(sys)
Expand Down