Skip to content

Commit 137d5ae

Browse files
committed
refactor: Blocks/utils.jl (limited)
1 parent 76a0db4 commit 137d5ae

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/Blocks/Blocks.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module Blocks
55
using ModelingToolkit, Symbolics
66
using IfElse: ifelse
77
import ..@symcheck
8+
using ModelingToolkit: getdefault
89

910
@parameters t
1011
D = Differential(t)

src/Blocks/utils.jl

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,20 @@ Single input single output (SISO) continuous system block.
7373
- `u_start`: Initial value for the input
7474
- `y_start`: Initial value for the output
7575
"""
76-
@component function SISO(; name, u_start = 0.0, y_start = 0.0)
77-
@named input = RealInput(u_start = u_start)
78-
@named output = RealOutput(u_start = y_start)
79-
@variables(u(t)=u_start, [description = "Input of SISO system $name"],
80-
y(t)=y_start, [description = "Output of SISO system $name"],)
81-
eqs = [u ~ input.u
82-
y ~ output.u]
83-
return ODESystem(eqs, t, [u, y], []; name = name, systems = [input, output])
76+
@mtkmodel SISO begin
77+
@variables begin
78+
u(t) = 0.0, [description = "Input of SISO system"]
79+
y(t) = 0.0, [description = "Output of SISO system"]
80+
end
81+
@components begin
82+
input = RealInput(u_start = u)
83+
output = RealOutput(u_start = y)
84+
end
85+
@equations begin
86+
u ~ input.u
87+
y ~ output.u
88+
end
8489
end
85-
8690
"""
8791
MIMO(;name, nin=1, nout=1, u_start=zeros(nin), y_start=zeros(nout))
8892

0 commit comments

Comments
 (0)