-
Notifications
You must be signed in to change notification settings - Fork 164
/
Extractor.mo
105 lines (97 loc) · 4.03 KB
/
Extractor.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
within Modelica.ComplexBlocks.Routing;
block Extractor
"Extract scalar signal out of signal vector dependent on IntegerRealInput index"
extends Modelica.ComplexBlocks.Interfaces.ComplexMISO;
parameter Boolean allowOutOfRange=false "Index may be out of range";
parameter Complex outOfRangeValue=Complex(1e10,0) "Output signal if index is out of range";
Modelica.Blocks.Interfaces.IntegerInput index annotation (Placement(
transformation(
origin={0,-120},
extent={{-20,-20},{20,20}},
rotation=90)));
protected
Complex k[nin];
equation
when {initial(),change(index)} then
for i in 1:nin loop
k[i] = if index == i then Complex(1,0) else Complex(0,0);
end for;
end when;
y = if not allowOutOfRange or index > 0 and index <= nin then
k*u else outOfRangeValue;
annotation (Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Rectangle(
extent={{-80,50},{-40,-50}},
lineColor={85,170,255},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Polygon(
points={{-84.4104,1.9079},{-84.4104,-2.09208},{-80.4104,-0.09208},{
-84.4104,1.9079}},
lineColor={85,170,255},
fillColor={85,170,255},
fillPattern=FillPattern.Solid),
Line(points={{-62,2},{-50.1395,12.907},{-39.1395,12.907}}, color={85,
170,255}),
Line(points={{-63,4},{-49,40},{-39,40}}, color={85,170,255}),
Line(points={{-102,0},{-65.0373,-0.01802}}, color={85,170,255}),
Ellipse(
extent={{-70.0437,4.5925},{-60.0437,-4.90745}},
lineColor={85,170,255},
fillColor={85,170,255},
fillPattern=FillPattern.Solid),
Line(points={{-63,-5},{-50,-40},{-39,-40}}, color={85,170,255}),
Line(points={{-62,-2},{-50.0698,-12.907},{-39.0698,-12.907}}, color={85,
170,255}),
Polygon(
points={{-38.8808,-11},{-38.8808,-15},{-34.8808,-13},{-38.8808,-11}},
lineColor={85,170,255},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Polygon(
points={{-39,42},{-39,38},{-35,40},{-39,42}},
lineColor={85,170,255},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Polygon(
points={{-38.8728,-38.0295},{-38.8728,-42.0295},{-34.8728,-40.0295},
{-38.8728,-38.0295}},
lineColor={85,170,255},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Polygon(
points={{-38.9983,14.8801},{-38.9983,10.8801},{-34.9983,12.8801},{-38.9983,
14.8801}},
lineColor={85,170,255},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{-30,50},{30,-50}},
fillColor={235,235,235},
fillPattern=FillPattern.Solid,
lineColor={85,170,255}),
Line(points={{100,0},{0,0}}, color={85,170,255}),
Line(points={{0,2},{0,-104}}, color={255,128,0}),
Line(points={{-35,40},{-20,40}}, color={85,170,255}),
Line(points={{-35,13},{-20,13}}, color={85,170,255}),
Line(points={{-35,-13},{-20,-13}}, color={85,170,255}),
Line(points={{-35,-40},{-20,-40}}, color={85,170,255}),
Polygon(points={{0,0},{-20,13},{-20,13},{0,0},{0,0}}, lineColor={85,
170,255}),
Ellipse(
extent={{-6,6},{6,-6}},
lineColor={255,128,0},
fillColor={255,128,0},
fillPattern=FillPattern.Solid)}),
Documentation(info="<html>
<p>This block extracts a scalar output signal out the
vector of input signals dependent on the Integer
value of the additional u index:</p>
<blockquote><pre>
y = u [ index ] ;
</pre></blockquote>
<p>where index is an additional Integer input signal.</p>
</html>"));
end Extractor;