Add3

block Add3 "Output the sum of the three inputs"
    extends Modelica.Blocks.Icons.Block;

    parameter Real k1 = 1 "Gain of input signal 1";
    parameter Real k2 = 1 "Gain of input signal 2";
    parameter Real k3 = 1 "Gain of input signal 3";
    Interfaces.RealInput u1 "Connector of Real input signal 1"
        annotation (Placement(transformation(extent = {
            {-140, 60}, 
            {-100, 100}})));
    Interfaces.RealInput u2 "Connector of Real input signal 2"
        annotation (Placement(transformation(extent = {
            {-140, -20}, 
            {-100, 20}})));
    Interfaces.RealInput u3 "Connector of Real input signal 3"
        annotation (Placement(transformation(extent = {
            {-140, -100}, 
            {-100, -60}})));
    Interfaces.RealOutput y "Connector of Real output signal"
        annotation (Placement(transformation(extent = {
            {100, -10}, 
            {120, 10}})));
equation
    y = k1 * u1 + k2 * u2 + k3 * u3;

    annotation (
        Documentation(info = "<html>\n<p>\nThis blocks computes output <strong>y</strong> as <em>sum</em> of the\nthree input signals <strong>u1</strong>, <strong>u2</strong> and <strong>u3</strong>:\n</p>\n<pre>\n    <strong>y</strong> = k1*<strong>u1</strong> + k2*<strong>u2</strong> + k3*<strong>u3</strong>;\n</pre>\n<p>\nExample:\n</p>\n<pre>\n     parameter:   k1= +2, k2= -3, k3=1;\n\n  results in the following equations:\n\n     y = 2 * u1 - 3 * u2 + u3;\n</pre>\n\n</html>"),
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Text(
                    extent = {
                        {-100, 50}, 
                        {5, 90}},
                    textString = "%k1"), 
                Text(
                    extent = {
                        {-100, -20}, 
                        {5, 20}},
                    textString = "%k2"), 
                Text(
                    extent = {
                        {-100, -50}, 
                        {5, -90}},
                    textString = "%k3"), 
                Text(
                    extent = {
                        {2, 36}, 
                        {100, -44}},
                    textString = "+")}),
        Diagram(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Rectangle(
                    extent = {
                        {-100, -100}, 
                        {100, 100}},
                    lineColor = {0, 0, 255},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid), 
                Text(
                    extent = {
                        {-100, 50}, 
                        {5, 90}},
                    textString = "k1"), 
                Text(
                    extent = {
                        {-100, -20}, 
                        {5, 20}},
                    textString = "k2"), 
                Text(
                    extent = {
                        {-100, -50}, 
                        {5, -90}},
                    textString = "k3"), 
                Text(
                    extent = {
                        {2, 46}, 
                        {100, -34}},
                    textString = "+")}));
end Add3;