diff --git a/src/ModelingToolkit.jl b/src/ModelingToolkit.jl index 0a785aca2e..766d9d7b2e 100644 --- a/src/ModelingToolkit.jl +++ b/src/ModelingToolkit.jl @@ -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 @@ -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 diff --git a/src/systems/abstractsystem.jl b/src/systems/abstractsystem.jl index 87a77436af..1b5c68bf19 100644 --- a/src/systems/abstractsystem.jl +++ b/src/systems/abstractsystem.jl @@ -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)