Skip to content

Commit 1a957c9

Browse files
committed
add show_construction for named systems
1 parent 87cff6e commit 1a957c9

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

src/RobustAndOptimalControl.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ using DescriptorSystems: dss
2828

2929
using ChainRulesCore
3030

31-
export show_construction, vec2sys
32-
include("utils.jl")
33-
3431
export dss, hinfnorm2, linfnorm2, h2norm, hankelnorm, nugap, νgap, baltrunc2, stab_unstab, baltrunc_unstab, baltrunc_coprime
3532
include("descriptor.jl")
3633

@@ -83,4 +80,7 @@ include("mimo_diskmargin.jl")
8380
export nu_reduction, nu_reduction_recursive
8481
include("mcm_nugap.jl")
8582

83+
export show_construction, vec2sys
84+
include("utils.jl")
85+
8686
end

src/utils.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,24 @@ function show_construction(io::IO, sys::LTISystem; name = "temp", letb = true)
4848
nothing
4949
end
5050

51+
function show_construction(io::IO, sys::NamedStateSpace; name = "temp", letb = true)
52+
# sys = StateSpace(sys)
53+
letb && println(io, "$name = let")
54+
prestr = letb ? " " : ""
55+
println(io, prestr*"$(name)A = ", sys.A)
56+
println(io, prestr*"$(name)B = ", sys.B)
57+
println(io, prestr*"$(name)C = ", sys.C)
58+
println(io, prestr*"$(name)D = ", sys.D)
59+
letb || print(io, "$name = ")
60+
if isdiscrete(sys)
61+
println(io, prestr*"named_ss(ss($(name)A, $(name)B, $(name)C, $(name)D), $(sys.Ts), x=$(sys.x), u=$(sys.u), y=$(sys.y))")
62+
else
63+
println(io, prestr*"named_ss(ss($(name)A, $(name)B, $(name)C, $(name)D), x=$(sys.x), u=$(sys.u), y=$(sys.y))")
64+
end
65+
letb && println(io, "end")
66+
nothing
67+
end
68+
5169
function Base.vec(sys::LTISystem)
5270
[vec(sys.A); vec(sys.B); vec(sys.C); vec(sys.D)]
5371
end

test/test_named_systems2.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ s_autoname = named_ss(G1, :G)
1616
@test s_autoname.y == [:Gy]
1717
@test s_autoname.u == [:Gu]
1818

19+
@test_nowarn RobustAndOptimalControl.show_construction(s_autoname)
20+
1921
@test ControlSystemsBase.state_names(s_autoname) == string.(s_autoname.x)
2022
@test ControlSystemsBase.input_names(s_autoname, 1) == string.(s_autoname.u[])
2123
@test_throws BoundsError ControlSystemsBase.output_names(s_autoname, 2)

0 commit comments

Comments
 (0)