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

Revision 550, 33.5 kB (checked in by otter, 15 months ago)

Library description string made in a standardized fashion for the top-level libraries
(Library of xxx)

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