ExtractSignal

block ExtractSignal "Extract signals from an input signal vector"
    extends Modelica.Blocks.Interfaces.MIMO;

    parameter Integer extract[nout] = 1:nout "Extracting vector";
equation
    for i in 1:nout loop
        y[i] = u[extract[i]];
    end for;

    annotation (
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Rectangle(
                    extent = {
                        {-90, 51}, 
                        {-50, -49}},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid,
                    lineColor = {0, 0, 127}), 
                Rectangle(
                    extent = {
                        {50, 50}, 
                        {90, -50}},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid,
                    lineColor = {0, 0, 127}), 
                Polygon(
                    points = {
                        {-94.4104, 1.90792}, 
                        {-94.4104, -2.09208}, 
                        {-90.4104, -0.0920762}, 
                        {-94.4104, 1.90792}},
                    fillColor = {0, 0, 127},
                    fillPattern = FillPattern.Solid,
                    lineColor = {0, 0, 127}), 
                Line(
                    points = {
                        {-72, 2}, 
                        {-60.1395, 12.907}, 
                        {-49.1395, 12.907}},
                    color = {0, 0, 127}), 
                Line(
                    points = {
                        {-73, 4}, 
                        {-59, 40}, 
                        {-49, 40}},
                    color = {0, 0, 127}), 
                Line(
                    points = {
                        {-113, 0}, 
                        {-76.0373, -0.0180176}},
                    color = {0, 0, 127}), 
                Ellipse(
                    extent = {
                        {-81.0437, 4.59255}, 
                        {-71.0437, -4.90745}},
                    fillColor = {0, 0, 127},
                    fillPattern = FillPattern.Solid,
                    lineColor = {0, 0, 127}), 
                Line(
                    points = {
                        {-73, -5}, 
                        {-60, -40}, 
                        {-49, -40}},
                    color = {0, 0, 127}), 
                Line(
                    points = {
                        {-72, -2}, 
                        {-60.0698, -12.907}, 
                        {-49.0698, -12.907}},
                    color = {0, 0, 127}), 
                Polygon(
                    points = {
                        {-48.8808, -11}, 
                        {-48.8808, -15}, 
                        {-44.8808, -13}, 
                        {-48.8808, -11}},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid,
                    lineColor = {0, 0, 127}), 
                Line(
                    points = {
                        {-46, 13}, 
                        {-35, 13}, 
                        {35, -30}, 
                        {45, -30}},
                    color = {0, 0, 127}), 
                Line(
                    points = {
                        {-45, 40}, 
                        {-35, 40}, 
                        {35, 0}, 
                        {44, 0}},
                    color = {0, 0, 127}), 
                Line(
                    points = {
                        {-45, -40}, 
                        {-34, -40}, 
                        {35, 30}, 
                        {44, 30}},
                    color = {0, 0, 127}), 
                Polygon(
                    points = {
                        {-49, 42}, 
                        {-49, 38}, 
                        {-45, 40}, 
                        {-49, 42}},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid,
                    lineColor = {0, 0, 127}), 
                Polygon(
                    points = {
                        {-48.8728, -38.0295}, 
                        {-48.8728, -42.0295}, 
                        {-44.8728, -40.0295}, 
                        {-48.8728, -38.0295}},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid,
                    lineColor = {0, 0, 127}), 
                Polygon(
                    points = {
                        {-48.9983, 14.8801}, 
                        {-48.9983, 10.8801}, 
                        {-44.9983, 12.8801}, 
                        {-48.9983, 14.8801}},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid,
                    lineColor = {0, 0, 127}), 
                Ellipse(
                    extent = {
                        {69.3052, 4.12743}, 
                        {79.3052, -5.37257}},
                    fillColor = {0, 0, 127},
                    fillPattern = FillPattern.Solid,
                    lineColor = {0, 0, 127}), 
                Line(
                    points = {
                        {80, 0}, 
                        {100, 0}},
                    color = {0, 0, 127}), 
                Polygon(
                    points = {
                        {43.1618, 32.3085}, 
                        {43.1618, 28.3085}, 
                        {47.1618, 30.3085}, 
                        {43.1618, 32.3085}},
                    fillColor = {0, 0, 127},
                    fillPattern = FillPattern.Solid,
                    lineColor = {0, 0, 127}), 
                Polygon(
                    points = {
                        {43.2575, 1.80443}, 
                        {43.2575, -2.19557}, 
                        {47.2575, -0.195573}, 
                        {43.2575, 1.80443}},
                    fillColor = {0, 0, 127},
                    fillPattern = FillPattern.Solid,
                    lineColor = {0, 0, 127}), 
                Polygon(
                    points = {
                        {43.8805, -28.1745}, 
                        {43.8805, -32.1745}, 
                        {47.8805, -30.1745}, 
                        {43.8805, -28.1745}},
                    fillColor = {0, 0, 127},
                    fillPattern = FillPattern.Solid,
                    lineColor = {0, 0, 127}), 
                Line(
                    points = {
                        {48, 0}, 
                        {70, 0}},
                    color = {0, 0, 127}), 
                Line(
                    points = {
                        {47, 30}, 
                        {60, 30}, 
                        {73, 3}},
                    color = {0, 0, 127}), 
                Line(
                    points = {
                        {49, -30}, 
                        {60, -30}, 
                        {74, -4}},
                    color = {0, 0, 127}), 
                Text(
                    extent = {
                        {-150, -150}, 
                        {150, -110}},
                    textString = "extract=%extract")}),
        Diagram(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Rectangle(
                    extent = {
                        {-90, 50}, 
                        {-50, -50}},
                    lineColor = {0, 0, 255},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid), 
                Rectangle(
                    extent = {
                        {50, 50}, 
                        {90, -50}},
                    lineColor = {0, 0, 255},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {-94.4104, 1.90792}, 
                        {-94.4104, -2.09208}, 
                        {-90.4104, -0.0920762}, 
                        {-94.4104, 1.90792}},
                    lineColor = {0, 0, 255},
                    fillPattern = FillPattern.Solid), 
                Line(
                    points = {
                        {-72, 2}, 
                        {-60.1395, 12.907}, 
                        {-49.1395, 12.907}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {-73, 4}, 
                        {-59, 40}, 
                        {-49, 40}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {-112, 0}, 
                        {-75.0373, -0.0180176}},
                    color = {0, 0, 255}), 
                Ellipse(
                    extent = {
                        {-80.0437, 4.59255}, 
                        {-70.0437, -4.90745}},
                    lineColor = {0, 0, 255},
                    fillColor = {0, 0, 255},
                    fillPattern = FillPattern.Solid), 
                Line(
                    points = {
                        {-73, -5}, 
                        {-60, -40}, 
                        {-49, -40}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {-72, -2}, 
                        {-60.0698, -12.907}, 
                        {-49.0698, -12.907}},
                    color = {0, 0, 255}), 
                Polygon(
                    points = {
                        {-48.8808, -11}, 
                        {-48.8808, -15}, 
                        {-44.8808, -13}, 
                        {-48.8808, -11}},
                    lineColor = {0, 0, 255},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid), 
                Line(
                    points = {
                        {-46, 13}, 
                        {-35, 13}, 
                        {35, -30}, 
                        {45, -30}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {-45, 40}, 
                        {-35, 40}, 
                        {35, 0}, 
                        {44, 0}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {-45, -40}, 
                        {-34, -40}, 
                        {35, 30}, 
                        {44, 30}},
                    color = {0, 0, 255}), 
                Polygon(
                    points = {
                        {-49, 42}, 
                        {-49, 38}, 
                        {-45, 40}, 
                        {-49, 42}},
                    lineColor = {0, 0, 255},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {-48.8728, -38.0295}, 
                        {-48.8728, -42.0295}, 
                        {-44.8728, -40.0295}, 
                        {-48.8728, -38.0295}},
                    lineColor = {0, 0, 255},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {-48.9983, 14.8801}, 
                        {-48.9983, 10.8801}, 
                        {-44.9983, 12.8801}, 
                        {-48.9983, 14.8801}},
                    lineColor = {0, 0, 255},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid), 
                Ellipse(
                    extent = {
                        {70.3052, 4.12743}, 
                        {80.3052, -5.37257}},
                    lineColor = {0, 0, 255},
                    fillColor = {0, 0, 255},
                    fillPattern = FillPattern.Solid), 
                Line(
                    points = {
                        {80, 0}, 
                        {105, 0}},
                    color = {0, 0, 255}), 
                Polygon(
                    points = {
                        {44.1618, 32.3085}, 
                        {44.1618, 28.3085}, 
                        {48.1618, 30.3085}, 
                        {44.1618, 32.3085}},
                    lineColor = {0, 0, 255},
                    fillColor = {0, 0, 255},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {44.2575, 1.80443}, 
                        {44.2575, -2.19557}, 
                        {48.2575, -0.195573}, 
                        {44.2575, 1.80443}},
                    lineColor = {0, 0, 255},
                    fillColor = {0, 0, 255},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {44.8805, -28.1745}, 
                        {44.8805, -32.1745}, 
                        {48.8805, -30.1745}, 
                        {44.8805, -28.1745}},
                    lineColor = {0, 0, 255},
                    fillColor = {0, 0, 255},
                    fillPattern = FillPattern.Solid), 
                Line(
                    points = {
                        {48, 0}, 
                        {70, 0}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {47, 30}, 
                        {60, 30}, 
                        {73, 3}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {49, -30}, 
                        {60, -30}, 
                        {74, -4}},
                    color = {0, 0, 255}), 
                Rectangle(
                    extent = {
                        {-100, 80}, 
                        {100, -81}},
                    lineColor = {0, 0, 255})}),
        Documentation(info = "<html>\n<p>Extract signals from the input connector and transfer them\nto the output connector.</p>\n<p>The extracting scheme is given by the integer vector 'extract'.\nThis vector specifies, which input signals are taken and in which\norder they are transferred to the output vector. Note, that the\ndimension of 'extract' has to match the number of outputs.\nAdditionally, the dimensions of the input connector signals and\nthe output connector signals have to be explicitly defined via the\nparameters 'nin' and 'nout'.</p>\n<p>Example:</p>\n<pre>     nin = 7 \"Number of inputs\";\n     nout = 4 \"Number of outputs\";\n     extract[nout] = {6,3,3,2} \"Extracting vector\";\n</pre>\n<p>extracts four output signals (nout=4) from the seven elements of the\ninput vector (nin=7):</p>\n<pre>   output no. 1 is set equal to input no. 6\n   output no. 2 is set equal to input no. 3\n   output no. 3 is set equal to input no. 3\n   output no. 4 is set equal to input no. 2\n</pre>\n</html>"));
end ExtractSignal;