Skip to content

Commit 3901046

Browse files
fix: syntax bug fix
1 parent b54c7b1 commit 3901046

File tree

1 file changed

+41
-21
lines changed

1 file changed

+41
-21
lines changed

src/Blocks/utils.jl

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -115,53 +115,73 @@ Connector with an array of output signals of type Real.
115115
""" RealOutputArray
116116

117117
"""
118-
SISO(;name, u_start = 0.0, y_start = 0.0)
118+
SISO(;name, u_guess = 0.0, y_guess = 0.0)
119119
120120
Single input single output (SISO) continuous system block.
121121
122122
# Parameters:
123123
124-
- `u_start`: Initial value for the input
125-
- `y_start`: Initial value for the output
124+
- `u_guess`: Initial value for the input
125+
- `y_guess`: Initial value for the output
126126
"""
127-
@component function SISO(; name, u_start = 0.0, y_start = 0.0)
127+
@component function SISO(; name, u_start = nothing, y_start = nothing, u_guess = 0.0, y_guess = 0.0)
128+
if u_start !== nothing
129+
Base.depwarn(
130+
"The keyword argument `u_start` is deprecated. Use `u_guess` instead.", :u_start)
131+
u_guess = u_start
132+
end
133+
if y_start !== nothing
134+
Base.depwarn(
135+
"The keyword argument `y_start` is deprecated. Use `u_guess` instead.", :y_start)
136+
y_guess = y_start
137+
end
128138
pars = @parameters begin
129-
u_start = u_start
130-
y_start = y_start
139+
u_guess = u_guess
140+
y_guess = y_guess
131141
end
132142
vars = @variables begin
133-
u(t), [guess = u_start, description = "Input of SISO system"]
134-
y(t), [guess = y_start, description = "Output of SISO system"]
143+
u(t), [guess = u_guess, description = "Input of SISO system"]
144+
y(t), [guess = y_guess, description = "Output of SISO system"]
135145
end
136-
@components begin
137-
input = RealInput(guess = u_start)
138-
output = RealOutput(guess = y_start)
139-
end
140-
@equations begin
146+
147+
@named input = RealInput(guess = u_guess)
148+
@named output = RealOutput(guess = y_guess)
149+
150+
eqs = [
141151
u ~ input.u
142152
y ~ output.u
153+
]
143154
return ODESystem(eqs, t, vars, pars; name = name, systems = [input, output])
144155
end
145156

146157
"""
147-
MIMO(; name, nin = 1, nout = 1, u_start = zeros(nin), y_start = zeros(nout))
158+
MIMO(; name, nin = 1, nout = 1, u_guess = zeros(nin), y_guess = zeros(nout))
148159
149160
Base class for a multiple input multiple output (MIMO) continuous system block.
150161
151162
# Parameters:
152163
153164
- `nin`: Input dimension
154165
- `nout`: Output dimension
155-
- `u_start`: Initial value for the input
166+
- `u_guess`: Initial value for the input
156167
- `y_start`: Initial value for the output
157168
"""
158-
@component function MIMO(; name, nin = 1, nout = 1, u_start = zeros(nin),
159-
y_start = zeros(nout))
160-
@named input = RealInput(nin = nin, u_start = u_start)
161-
@named output = RealOutput(nout = nout, u_start = y_start)
169+
@component function MIMO(; name, nin = 1, nout = 1, u_start = nothing, y_start = nothing, u_guess = zeros(nin), y_guess = zeros(nout))
170+
if u_start !== nothing
171+
Base.depwarn(
172+
"The keyword argument `u_start` is deprecated. Use `u_guess` instead.", :u_start)
173+
u_guess = u_start
174+
end
175+
if y_start !== nothing
176+
Base.depwarn(
177+
"The keyword argument `y_start` is deprecated. Use `u_guess` instead.", :y_start)
178+
y_guess = y_start
179+
end
180+
@named input = RealInput(nin = nin, guess = u_guess)
181+
@named output = RealOutput(nout = nout, guess = y_guess)
162182
@variables begin
163-
u(t)[1:nin], [guess = u_start, description = "Input of MIMO system $name"]
164-
y(t)[1:nout], [guess = y_start, description = "Output of MIMO system $name"]
183+
u(t)[1:nin], [guess = u_guess, description = "Input of MIMO system $name"]
184+
y(t)[1:nout], [guess = y_guess, description = "Output of MIMO system $name"]
165185
end
166186
eqs = [
167187
[u[i] ~ input.u[i] for i in 1:nin]...,

0 commit comments

Comments
 (0)