Skip to content

Commit a7b581b

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

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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)