root/branches/maintenance/3.0/Modelica/Blocks/Routing.mo

Revision 1044, 44.5 kB (checked in by otter, 9 months ago)

Removed "Windows(..)" annotation (an "old" Dymola 4 annotation that was not used anymore and is not part of the Modelica 3 graphical annotations)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1within Modelica.Blocks;
2package Routing "Library of blocks to combine and extract signals"
3  extends Icons.Library;
4
5block ExtractSignal "Extract signals from an input signal vector"
6  extends Modelica.Blocks.Interfaces.MIMO;
7  parameter Integer extract[nout]=1:nout "Extracting vector";
8  annotation (
9   
10    Icon(coordinateSystem(
11          preserveAspectRatio=true,
12          extent={{-100,-100},{100,100}},
13          grid={1,1}), graphics={
14          Rectangle(
15            extent={{-90,51},{-50,-49}},
16            fillColor={255,255,255},
17            fillPattern=FillPattern.Solid,
18            lineColor={0,0,127}),
19          Rectangle(
20            extent={{50,50},{90,-50}},
21            fillColor={255,255,255},
22            fillPattern=FillPattern.Solid,
23            lineColor={0,0,127}),
24          Polygon(
25            points={{-94.4104,1.90792},{-94.4104,-2.09208},{-90.4104,-0.0920762},
26                {-94.4104,1.90792}},
27            fillColor={0,0,127},
28            fillPattern=FillPattern.Solid,
29            lineColor={0,0,127}),
30          Line(points={{-72,2},{-60.1395,12.907},{-49.1395,12.907}}, color={0,0,
31                127}),
32          Line(points={{-73,4},{-59,40},{-49,40}}, color={0,0,127}),
33          Line(points={{-113,0},{-76.0373,-0.0180176}}, color={0,0,127}),
34          Ellipse(
35            extent={{-81.0437,4.59255},{-71.0437,-4.90745}},
36            fillColor={0,0,127},
37            fillPattern=FillPattern.Solid,
38            lineColor={0,0,127}),
39          Line(points={{-73,-5},{-60,-40},{-49,-40}}, color={0,0,127}),
40          Line(points={{-72,-2},{-60.0698,-12.907},{-49.0698,-12.907}}, color={
41                0,0,127}),
42          Polygon(
43            points={{-48.8808,-11},{-48.8808,-15},{-44.8808,-13},{-48.8808,-11}},
44            fillColor={255,255,255},
45            fillPattern=FillPattern.Solid,
46            lineColor={0,0,127}),
47          Line(points={{-46,13},{-35,13},{35,-30},{45,-30}}, color={0,0,127}),
48          Line(points={{-45,40},{-35,40},{35,0},{44,0}}, color={0,0,127}),
49          Line(points={{-45,-40},{-34,-40},{35,30},{44,30}}, color={0,0,127}),
50          Polygon(
51            points={{-49,42},{-49,38},{-45,40},{-49,42}},
52            fillColor={255,255,255},
53            fillPattern=FillPattern.Solid,
54            lineColor={0,0,127}),
55          Polygon(
56            points={{-48.8728,-38.0295},{-48.8728,-42.0295},{-44.8728,-40.0295},
57                {-48.8728,-38.0295}},
58            fillColor={255,255,255},
59            fillPattern=FillPattern.Solid,
60            lineColor={0,0,127}),
61          Polygon(
62            points={{-48.9983,14.8801},{-48.9983,10.8801},{-44.9983,12.8801},{-48.9983,
63                14.8801}},
64            fillColor={255,255,255},
65            fillPattern=FillPattern.Solid,
66            lineColor={0,0,127}),
67          Ellipse(
68            extent={{69.3052,4.12743},{79.3052,-5.37257}},
69            fillColor={0,0,127},
70            fillPattern=FillPattern.Solid,
71            lineColor={0,0,127}),
72          Line(points={{80,0},{100,0}}, color={0,0,127}),
73          Polygon(
74            points={{43.1618,32.3085},{43.1618,28.3085},{47.1618,30.3085},{
75                43.1618,32.3085}},
76            fillColor={0,0,127},
77            fillPattern=FillPattern.Solid,
78            lineColor={0,0,127}),
79          Polygon(
80            points={{43.2575,1.80443},{43.2575,-2.19557},{47.2575,-0.195573},{
81                43.2575,1.80443}},
82            fillColor={0,0,127},
83            fillPattern=FillPattern.Solid,
84            lineColor={0,0,127}),
85          Polygon(
86            points={{43.8805,-28.1745},{43.8805,-32.1745},{47.8805,-30.1745},{
87                43.8805,-28.1745}},
88            fillColor={0,0,127},
89            fillPattern=FillPattern.Solid,
90            lineColor={0,0,127}),
91          Line(points={{48,0},{70,0}}, color={0,0,127}),
92          Line(points={{47,30},{60,30},{73,3}}, color={0,0,127}),
93          Line(points={{49,-30},{60,-30},{74,-4}}, color={0,0,127}),
94          Text(
95            extent={{-150,-150},{150,-110}},
96            lineColor={0,0,0},
97            textString="extract=%extract")}),
98    Diagram(coordinateSystem(
99          preserveAspectRatio=true,
100          extent={{-100,-100},{100,100}},
101          grid={1,1}), graphics={
102          Rectangle(
103            extent={{-90,50},{-50,-50}},
104            lineColor={0,0,255},
105            fillColor={255,255,255},
106            fillPattern=FillPattern.Solid),
107          Rectangle(
108            extent={{50,50},{90,-50}},
109            lineColor={0,0,255},
110            fillColor={255,255,255},
111            fillPattern=FillPattern.Solid),
112          Polygon(
113            points={{-94.4104,1.90792},{-94.4104,-2.09208},{-90.4104,-0.0920762},
114                {-94.4104,1.90792}},
115            lineColor={0,0,255},
116            fillColor={0,0,0},
117            fillPattern=FillPattern.Solid),
118          Line(points={{-72,2},{-60.1395,12.907},{-49.1395,12.907}}, color={0,0,
119                255}),
120          Line(points={{-73,4},{-59,40},{-49,40}}, color={0,0,255}),
121          Line(points={{-112,0},{-75.0373,-0.0180176}}, color={0,0,255}),
122          Ellipse(
123            extent={{-80.0437,4.59255},{-70.0437,-4.90745}},
124            lineColor={0,0,255},
125            fillColor={0,0,255},
126            fillPattern=FillPattern.Solid),
127          Line(points={{-73,-5},{-60,-40},{-49,-40}}, color={0,0,255}),
128          Line(points={{-72,-2},{-60.0698,-12.907},{-49.0698,-12.907}}, color={
129                0,0,255}),
130          Polygon(
131            points={{-48.8808,-11},{-48.8808,-15},{-44.8808,-13},{-48.8808,-11}},
132            lineColor={0,0,255},
133            fillColor={255,255,255},
134            fillPattern=FillPattern.Solid),
135          Line(points={{-46,13},{-35,13},{35,-30},{45,-30}}, color={0,0,255}),
136          Line(points={{-45,40},{-35,40},{35,0},{44,0}}, color={0,0,255}),
137          Line(points={{-45,-40},{-34,-40},{35,30},{44,30}}, color={0,0,255}),
138          Polygon(
139            points={{-49,42},{-49,38},{-45,40},{-49,42}},
140            lineColor={0,0,255},
141            fillColor={255,255,255},
142            fillPattern=FillPattern.Solid),
143          Polygon(
144            points={{-48.8728,-38.0295},{-48.8728,-42.0295},{-44.8728,-40.0295},
145                {-48.8728,-38.0295}},
146            lineColor={0,0,255},
147            fillColor={255,255,255},
148            fillPattern=FillPattern.Solid),
149          Polygon(
150            points={{-48.9983,14.8801},{-48.9983,10.8801},{-44.9983,12.8801},{-48.9983,
151                14.8801}},
152            lineColor={0,0,255},
153            fillColor={255,255,255},
154            fillPattern=FillPattern.Solid),
155          Ellipse(
156            extent={{70.3052,4.12743},{80.3052,-5.37257}},
157            lineColor={0,0,255},
158            fillColor={0,0,255},
159            fillPattern=FillPattern.Solid),
160          Line(points={{80,0},{105,0}}, color={0,0,255}),
161          Polygon(
162            points={{44.1618,32.3085},{44.1618,28.3085},{48.1618,30.3085},{
163                44.1618,32.3085}},
164            lineColor={0,0,255},
165            fillColor={0,0,255},
166            fillPattern=FillPattern.Solid),
167          Polygon(
168            points={{44.2575,1.80443},{44.2575,-2.19557},{48.2575,-0.195573},{
169                44.2575,1.80443}},
170            lineColor={0,0,255},
171            fillColor={0,0,255},
172            fillPattern=FillPattern.Solid),
173          Polygon(
174            points={{44.8805,-28.1745},{44.8805,-32.1745},{48.8805,-30.1745},{
175                44.8805,-28.1745}},
176            lineColor={0,0,255},
177            fillColor={0,0,255},
178            fillPattern=FillPattern.Solid),
179          Line(points={{48,0},{70,0}}, color={0,0,255}),
180          Line(points={{47,30},{60,30},{73,3}}, color={0,0,255}),
181          Line(points={{49,-30},{60,-30},{74,-4}}, color={0,0,255}),
182          Rectangle(extent={{-100,80},{100,-81}}, lineColor={0,0,255})}),
183    Documentation(info="<HTML>
184<p>Extract signals from the input connector and transfer them
185to the output connector.</p>
186<p>The extracting scheme is given by the integer vector 'extract'.
187This vector specifies, which input signals are taken and in which
188order they are transfered to the output vector. Note, that the
189dimension of 'extract' has to match the number of outputs.
190Additionally, the dimensions of the input connector signals and
191the output connector signals have to be explicitly defined via the
192parameters 'nin' and 'nout'.</p>
193<p>Example:</p>
194<pre>     nin = 7 \"Number of inputs\";
195     nout = 4 \"Number of outputs\";
196     extract[nout] = {6,3,3,2} \"Extracting vector\";
197</pre>
198<p>extracts four output signals (nout=4) from the seven elements of the
199input vector (nin=7):</p>
200<pre>   output no. 1 is set equal to input no. 6
201   output no. 2 is set equal to input no. 3
202   output no. 3 is set equal to input no. 3
203   output no. 4 is set equal to input no. 2
204</pre>
205</HTML>
206"));
207
208equation
209  for i in 1:nout loop
210    y[i] = u[extract[i]];
211
212  end for;
213end ExtractSignal;
214
215block Extractor
216    "Extract scalar signal out of signal vector dependent on IntegerRealInput index"
217
218  extends Modelica.Blocks.Interfaces.MISO;
219
220  parameter Boolean allowOutOfRange=false "Index may be out of range";
221  parameter Real outOfRangeValue=1e10 "Output signal if index is out of range";
222
223  annotation (Icon(coordinateSystem(
224          preserveAspectRatio=true,
225          extent={{-100,-100},{100,100}},
226          grid={1,1}), graphics={
227          Rectangle(
228            extent={{-80,50},{-40,-50}},
229            lineColor={0,0,127},
230            fillColor={255,255,255},
231            fillPattern=FillPattern.Solid),
232          Polygon(
233            points={{-84.4104,1.9079},{-84.4104,-2.09208},{-80.4104,-0.09208},{
234                -84.4104,1.9079}},
235            lineColor={0,0,127},
236            fillColor={0,0,0},
237            fillPattern=FillPattern.Solid),
238          Line(points={{-62,2},{-50.1395,12.907},{-39.1395,12.907}}, color={0,0,
239                127}),
240          Line(points={{-63,4},{-49,40},{-39,40}}, color={0,0,127}),
241          Line(points={{-102,0},{-65.0373,-0.01802}}, color={0,0,127}),
242          Ellipse(
243            extent={{-70.0437,4.5925},{-60.0437,-4.90745}},
244            lineColor={0,0,127},
245            fillColor={0,0,127},
246            fillPattern=FillPattern.Solid),
247          Line(points={{-63,-5},{-50,-40},{-39,-40}}, color={0,0,127}),
248          Line(points={{-62,-2},{-50.0698,-12.907},{-39.0698,-12.907}}, color={
249                0,0,127}),
250          Polygon(
251            points={{-38.8808,-11},{-38.8808,-15},{-34.8808,-13},{-38.8808,-11}},
252            lineColor={0,0,127},
253            fillColor={255,255,255},
254            fillPattern=FillPattern.Solid),
255          Polygon(
256            points={{-39,42},{-39,38},{-35,40},{-39,42}},
257            lineColor={0,0,127},
258            fillColor={255,255,255},
259            fillPattern=FillPattern.Solid),
260          Polygon(
261            points={{-38.8728,-38.0295},{-38.8728,-42.0295},{-34.8728,-40.0295},
262                {-38.8728,-38.0295}},
263            lineColor={0,0,127},
264            fillColor={255,255,255},
265            fillPattern=FillPattern.Solid),
266          Polygon(
267            points={{-38.9983,14.8801},{-38.9983,10.8801},{-34.9983,12.8801},{-38.9983,
268                14.8801}},
269            lineColor={0,0,127},
270            fillColor={255,255,255},
271            fillPattern=FillPattern.Solid),
272          Rectangle(
273            extent={{-30,50},{30,-50}},
274            fillColor={235,235,235},
275            fillPattern=FillPattern.Solid,
276            lineColor={0,0,127}),
277          Line(points={{100,0},{0,0}}, color={0,0,127}),
278          Line(points={{0,2},{0,-104}}, color={255,128,0}),
279          Line(points={{-35,40},{-20,40}}, color={0,0,127}),
280          Line(points={{-35,13},{-20,13}}, color={0,0,127}),
281          Line(points={{-35,-13},{-20,-13}}, color={0,0,127}),
282          Line(points={{-35,-40},{-20,-40}}, color={0,0,127}),
283          Polygon(points={{0,0},{-20,13},{-20,13},{0,0},{0,0}}, lineColor={0,0,
284                127}),
285          Ellipse(
286            extent={{-6,6},{6,-6}},
287            lineColor={255,128,0},
288            fillColor={255,128,0},
289            fillPattern=FillPattern.Solid)}),
290                            Documentation(info="<html>
291<p>This block extracts a scalar output signal out the
292vector of input signals dependent on the Integer
293value of the additional u index:</p>
294<pre>    y = u [ index ] ;
295</pre>
296<p>where index is an additional Integer input signal.</p>
297</html>"),
298      Diagram(coordinateSystem(
299          preserveAspectRatio=true,
300          extent={{-100,-100},{100,100}},
301          grid={1,1})));
302
303  Modelica.Blocks.Interfaces.IntegerInput index             annotation (Placement(
304          transformation(
305          origin={0,-120},
306          extent={{-20,-20},{20,20}},
307          rotation=90)));
308  protected
309  Real k[nin];
310equation
311
312  when {initial(),change(index)} then
313
314    for i in 1:nin loop
315      k[i] = if index == i then 1 else 0;
316
317    end for;
318
319  end when;
320
321  y = if not allowOutOfRange or index > 0 and index <= nin then 
322              k*u else outOfRangeValue;
323end Extractor;
324
325  block Multiplex2 "Multiplexer block for two input connectors"
326    extends Modelica.Blocks.Interfaces.BlockIcon;
327    parameter Integer n1=1 "dimension of input signal connector 1";
328    parameter Integer n2=1 "dimension of input signal connector 2";
329    Modelica.Blocks.Interfaces.RealInput u1[n1]
330      "Connector of Real input signals 1" annotation (Placement(transformation(
331            extent={{-140,40},{-100,80}}, rotation=0)));
332    Modelica.Blocks.Interfaces.RealInput u2[n2]
333      "Connector of Real input signals 2" annotation (Placement(transformation(
334            extent={{-140,-80},{-100,-40}}, rotation=0)));
335    Modelica.Blocks.Interfaces.RealOutput y[n1 + n2]
336      "Connector of Real output signals" annotation (Placement(transformation(
337            extent={{100,-10},{120,10}}, rotation=0)));
338    annotation (
339     
340      Documentation(info="<HTML>
341<p>
342The output connector is the <b>concatenation</b> of the two input connectors.
343Note, that the dimensions of the input connector signals have to be
344explicitly defined via parameters n1 and n2.
345</p>
346</HTML>
347"),   Icon(coordinateSystem(
348          preserveAspectRatio=true,
349          extent={{-100,-100},{100,100}},
350          grid={2,2}), graphics={
351          Line(points={{8,0},{102,0}}, color={0,0,127}),
352          Ellipse(
353            extent={{-14,16},{16,-14}},
354            fillColor={0,0,127},
355            fillPattern=FillPattern.Solid,
356            lineColor={0,0,127}),
357          Line(points={{-98,60},{-60,60},{-4,6}}, color={0,0,127}),
358          Line(points={{-98,-60},{-60,-60},{-4,-4}}, color={0,0,127})}),
359      Diagram(coordinateSystem(
360          preserveAspectRatio=true,
361          extent={{-100,-100},{100,100}},
362          grid={2,2}), graphics={
363          Line(points={{-98,60},{-60,60},{-4,6}}, color={0,0,255}),
364          Line(points={{-98,-60},{-60,-60},{-4,-4}}, color={0,0,255}),
365          Line(points={{8,0},{102,0}}, color={0,0,255}),
366          Ellipse(
367            extent={{-14,16},{16,-14}},
368            fillColor={0,0,255},
369            fillPattern=FillPattern.Solid,
370            lineColor={0,0,255})}));
371  equation
372    [y] = [u1; u2];
373  end Multiplex2;
374
375  block Multiplex3 "Multiplexer block for three input connectors"
376    extends Modelica.Blocks.Interfaces.BlockIcon;
377    parameter Integer n1=1 "dimension of input signal connector 1";
378    parameter Integer n2=1 "dimension of input signal connector 2";
379    parameter Integer n3=1 "dimension of input signal connector 3";
380    Modelica.Blocks.Interfaces.RealInput u1[n1]
381      "Connector of Real input signals 1" annotation (Placement(transformation(
382            extent={{-140,50},{-100,90}}, rotation=0)));
383    Modelica.Blocks.Interfaces.RealInput u2[n2]
384      "Connector of Real input signals 2" annotation (Placement(transformation(
385            extent={{-140,-20},{-100,20}}, rotation=0)));
386    Modelica.Blocks.Interfaces.RealInput u3[n3]
387      "Connector of Real input signals 3" annotation (Placement(transformation(
388            extent={{-140,-90},{-100,-50}}, rotation=0)));
389    Modelica.Blocks.Interfaces.RealOutput y[n1 + n2 + n3]
390      "Connector of Real output signals" annotation (Placement(transformation(
391            extent={{100,-10},{120,10}}, rotation=0)));
392    annotation (
393     
394      Documentation(info="<HTML>
395<p>
396The output connector is the <b>concatenation</b> of the three input connectors.
397Note, that the dimensions of the input connector signals have to be
398explicitly defined via parameters n1, n2 and n3.
399</HTML>
400"),   Icon(coordinateSystem(
401          preserveAspectRatio=true,
402          extent={{-100,-100},{100,100}},
403          grid={2,2}), graphics={
404          Line(points={{8,0},{102,0}}, color={0,0,127}),
405          Line(points={{-100,70},{-60,70},{-4,6}}, color={0,0,127}),
406          Line(points={{-100,0},{-12,0}}, color={0,0,127}),
407          Line(points={{-100,-70},{-62,-70},{-4,-4}}, color={0,0,127}),
408          Ellipse(
409            extent={{-14,16},{16,-14}},
410            fillColor={0,0,127},
411            fillPattern=FillPattern.Solid,
412            lineColor={0,0,127})}),
413      Diagram(coordinateSystem(
414          preserveAspectRatio=true,
415          extent={{-100,-100},{100,100}},
416          grid={2,2}), graphics={
417          Line(points={{-100,70},{-60,70},{-4,6}}, color={0,0,255}),
418          Line(points={{-100,-70},{-62,-70},{-4,-4}}, color={0,0,255}),
419          Line(points={{8,0},{102,0}}, color={0,0,255}),
420          Ellipse(
421            extent={{-14,16},{16,-14}},
422            fillColor={0,0,255},
423            fillPattern=FillPattern.Solid,
424            lineColor={0,0,255}),
425          Line(points={{-100,0},{-12,0}}, color={0,0,255})}));
426  equation
427    [y] = [u1; u2; u3];
428  end Multiplex3;
429
430  block Multiplex4 "Multiplexer block for f