@@ -52,17 +52,19 @@ function SymPy.Sym(sys::TransferFunction)
52
52
end
53
53
54
54
function Num (sys:: StateSpace{<:Any,Num} )
55
+ # ControlSystemsBase.issiso(sys) || throw(ArgumentError("Only SISO systems are supported"))
55
56
A, B, C, D = ControlSystemsBase. ssdata (sys)
56
57
λ = isdiscrete (sys) ? Symb. @variables (z) : Symb. @variables (s)
57
58
λ = λ[]
58
- ex = (C* inv (λ * I (size (A, 1 )) - A)* B+ D)[ 1 ]
59
+ ex = (C* inv (λ * I (size (A, 1 )) - A)* B+ D)
59
60
if sys. nx < 4
60
- ex = Symb. simplify (ex)
61
+ ex = Symb. simplify . (ex)
61
62
end
62
- ex
63
+ length (ex) == 1 ? ex[] : ex
63
64
end
64
65
65
66
function Num (sys:: TransferFunction )
67
+ ControlSystemsBase. issiso (sys) || (return Num (ss (sys)))
66
68
λ = isdiscrete (sys) ? Symb. @variables (z) : Symb. @variables (s)
67
69
λ = λ[]
68
70
num = sum (((i, t),) -> t * λ^ (i- 1 ), enumerate (reverse (numvec (sys)[]))) |> Symb. simplify
@@ -110,9 +112,22 @@ function ControlSystemsBase.minreal(sys::TransferFunction{<:Any,<:ControlSystems
110
112
Sym (sys) |> simplify |> tf
111
113
end
112
114
113
- function ControlSystemsBase. tf (sys:: StateSpace{<:Any ,<:Sym} )
115
+ function ControlSystemsBase. tf (sys:: StateSpace{TE ,<:Sym} ) where TE
114
116
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
116
131
end
117
132
118
133
0 commit comments