@@ -52,17 +52,19 @@ function SymPy.Sym(sys::TransferFunction)
5252end
5353
5454function Num (sys:: StateSpace{<:Any,Num} )
55+ # ControlSystemsBase.issiso(sys) || throw(ArgumentError("Only SISO systems are supported"))
5556 A, B, C, D = ControlSystemsBase. ssdata (sys)
5657 λ = isdiscrete (sys) ? Symb. @variables (z) : Symb. @variables (s)
5758 λ = λ[]
58- ex = (C* inv (λ * I (size (A, 1 )) - A)* B+ D)[ 1 ]
59+ ex = (C* inv (λ * I (size (A, 1 )) - A)* B+ D)
5960 if sys. nx < 4
60- ex = Symb. simplify (ex)
61+ ex = Symb. simplify . (ex)
6162 end
62- ex
63+ length (ex) == 1 ? ex[] : ex
6364end
6465
6566function Num (sys:: TransferFunction )
67+ ControlSystemsBase. issiso (sys) || (return Num (ss (sys)))
6668 λ = isdiscrete (sys) ? Symb. @variables (z) : Symb. @variables (s)
6769 λ = λ[]
6870 num = sum (((i, t),) -> t * λ^ (i- 1 ), enumerate (reverse (numvec (sys)[]))) |> Symb. simplify
@@ -110,9 +112,22 @@ function ControlSystemsBase.minreal(sys::TransferFunction{<:Any,<:ControlSystems
110112 Sym (sys) |> simplify |> tf
111113end
112114
113- function ControlSystemsBase. tf (sys:: StateSpace{<:Any ,<:Sym} )
115+ function ControlSystemsBase. tf (sys:: StateSpace{TE ,<:Sym} ) where TE
114116 n, p = simplify .(sp. Poly .(simplify .(sp. fraction (simplify (Sym (sys)))), s))
115- tf (simplify (n / p))
117+ tf (simplify (n / p), sys. timeevol)
118+ end
119+
120+ function Base.:(* )(A:: AbstractMatrix{Bool} , B:: AbstractMatrix{<:Sym} )
121+ # This is a hack to allow ROC.connect with named systems of Syms
122+ @show A
123+ @show B
124+ try
125+ @show Bb = convert .(Bool, B)
126+ return float .(A) * Bb
127+ catch
128+ @show (1.0 .* B)
129+ return float .(A) * (1.0 .* B)
130+ end
116131end
117132
118133
0 commit comments