Skip to content

Commit 6c8d7f3

Browse files
author
Sathvik Bhagavan
committed
refactor(Blocks): add isarray kwarg in RealInput/Output to have the option of creating 1 element symbolic vector
1 parent 02a134c commit 6c8d7f3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Blocks/utils.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@connector function RealInput(; name, nin = 1, u_start = nin > 1 ? zeros(nin) : 0.0)
2-
if nin == 1
1+
@connector function RealInput(; name, nin = 1, isarray = false, u_start = isarray ? zeros(nin) : 0.0)
2+
if nin == 1 && !isarray
33
@variables u(t)=u_start [
44
input = true,
55
description = "Inner variable in RealInput $name"
@@ -21,13 +21,14 @@ Connector with one input signal of type Real.
2121
# Parameters:
2222
- `nin=1`: Number of inputs
2323
- `u_start=0`: Initial value for `u`
24+
- `isarray=false`: This is only applicable for `nin=1`. Boolean flag to use a scalar or a one element symbolic vector
2425
2526
# States:
2627
- `u`: Value of the connector; if nin=1 this is a scalar
2728
""" RealInput
2829

29-
@connector function RealOutput(; name, nout = 1, u_start = nout > 1 ? zeros(nout) : 0.0)
30-
if nout == 1
30+
@connector function RealOutput(; name, nout = 1, isarray = true, u_start = isarray ? zeros(nout) : 0.0)
31+
if nout == 1 && !isarray
3132
@variables u(t)=u_start [
3233
output = true,
3334
description = "Inner variable in RealOutput $name"
@@ -49,6 +50,7 @@ Connector with one output signal of type Real.
4950
# Parameters:
5051
- `nout=1`: Number of outputs
5152
- `u_start=0`: Initial value for `u`
53+
- `isarray=false`: This is only applicable for `nout=1`. Boolean flag to use a scalar or a one element symbolic vector
5254
5355
# States:
5456
- `u`: Value of the connector; if nout=1 this is a scalar

0 commit comments

Comments
 (0)