TrapezoidVoltage

model TrapezoidVoltage "Trapezoidal voltage source"
    parameter SI.Voltage V(start = 1) "Amplitude of trapezoid";
    parameter SI.Time rising(final min = 0, start = 0) "Rising duration of trapezoid";
    parameter SI.Time width(final min = 0, start = 0.5) "Width duration of trapezoid";
    parameter SI.Time falling(final min = 0, start = 0) "Falling duration of trapezoid";
    parameter SI.Time period(final min = Modelica.Constants.small, start = 1) "Time for one period";
    parameter Integer nperiod(start = -1) "Number of periods (< 0 means infinite number of periods)";

    extends Interfaces.VoltageSource(redeclare Modelica.Blocks.Sources.Trapezoid signalSource(final amplitude = V, final rising = rising, final width = width, final falling = falling, final period = period, final nperiod = nperiod));

    annotation (
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {-81, -70}, 
                        {-60, -70}, 
                        {-30, 70}, 
                        {1, 70}, 
                        {30, -70}, 
                        {51, -70}, 
                        {80, 70}},
                    color = {192, 192, 192})}),
        Diagram(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Polygon(
                    points = {
                        {-80, 90}, 
                        {-88, 68}, 
                        {-72, 68}, 
                        {-80, 90}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Line(
                    points = {
                        {-80, 68}, 
                        {-80, -80}},
                    color = {192, 192, 192}), 
                Line(
                    points = {
                        {-90, -70}, 
                        {82, -70}},
                    color = {192, 192, 192}), 
                Polygon(
                    points = {
                        {90, -70}, 
                        {68, -62}, 
                        {68, -78}, 
                        {90, -70}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {-45, -30}, 
                        {-47, -41}, 
                        {-43, -41}, 
                        {-45, -30}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Line(
                    points = {
                        {-45, -30}, 
                        {-45, -70}},
                    color = {192, 192, 192}), 
                Polygon(
                    points = {
                        {-45, -70}, 
                        {-47, -60}, 
                        {-43, -60}, 
                        {-45, -70}, 
                        {-45, -70}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Text(
                    extent = {
                        {-86, -43}, 
                        {-43, -55}},
                    lineColor = {160, 160, 164},
                    textString = "offset"), 
                Text(
                    extent = {
                        {-47, -69}, 
                        {-1, -87}},
                    lineColor = {160, 160, 164},
                    textString = "startTime"), 
                Text(
                    extent = {
                        {70, -80}, 
                        {94, -100}},
                    lineColor = {160, 160, 164},
                    textString = "time"), 
                Line(
                    points = {
                        {-30, 81}, 
                        {-30, -70}},
                    color = {192, 192, 192},
                    pattern = LinePattern.Dash), 
                Line(
                    points = {
                        {-10, 59}, 
                        {-10, 40}},
                    color = {192, 192, 192},
                    pattern = LinePattern.Dash), 
                Line(
                    points = {
                        {20, 59}, 
                        {20, 39}},
                    color = {160, 160, 164},
                    pattern = LinePattern.Dash), 
                Line(
                    points = {
                        {40, 59}, 
                        {40, -30}},
                    color = {192, 192, 192},
                    pattern = LinePattern.Dash), 
                Line(
                    points = {
                        {-30, 56}, 
                        {40, 56}},
                    color = {192, 192, 192}), 
                Text(
                    extent = {
                        {-8, 70}, 
                        {21, 60}},
                    lineColor = {160, 160, 164},
                    textString = "width"), 
                Line(
                    points = {
                        {-42, 40}, 
                        {-10, 40}},
                    color = {192, 192, 192},
                    pattern = LinePattern.Dash), 
                Line(
                    points = {
                        {-39, 40}, 
                        {-39, -30}},
                    color = {192, 192, 192}), 
                Text(
                    extent = {
                        {-71, 13}, 
                        {-34, -1}},
                    lineColor = {160, 160, 164},
                    textString = "V"), 
                Polygon(
                    points = {
                        {-30, 56}, 
                        {-23, 58}, 
                        {-23, 54}, 
                        {-30, 56}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {-10, 56}, 
                        {-17, 58}, 
                        {-17, 54}, 
                        {-10, 56}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Line(
                    points = {
                        {-80, -30}, 
                        {-30, -30}, 
                        {-10, 40}, 
                        {20, 40}, 
                        {40, -30}, 
                        {60, -30}, 
                        {80, 46}, 
                        {100, 46}},
                    thickness = 0.5), 
                Polygon(
                    points = {
                        {-39, 40}, 
                        {-41, 29}, 
                        {-37, 29}, 
                        {-39, 40}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {-39, -30}, 
                        {-41, -20}, 
                        {-37, -20}, 
                        {-39, -30}, 
                        {-39, -30}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Line(
                    points = {
                        {60, 81}, 
                        {60, -30}},
                    color = {192, 192, 192},
                    pattern = LinePattern.Dash), 
                Polygon(
                    points = {
                        {40, 56}, 
                        {33, 58}, 
                        {33, 54}, 
                        {40, 56}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {20, 56}, 
                        {27, 58}, 
                        {27, 54}, 
                        {20, 56}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {20, 56}, 
                        {13, 58}, 
                        {13, 54}, 
                        {20, 56}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {-10, 56}, 
                        {-3, 58}, 
                        {-3, 54}, 
                        {-10, 56}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Text(
                    extent = {
                        {-34, 70}, 
                        {-5, 60}},
                    lineColor = {160, 160, 164},
                    textString = "rising"), 
                Text(
                    extent = {
                        {16, 70}, 
                        {45, 60}},
                    lineColor = {160, 160, 164},
                    textString = "falling"), 
                Text(
                    extent = {
                        {-77, 103}, 
                        {-23, 91}},
                    lineColor = {160, 160, 164},
                    textString = "v = p.v - n.v"), 
                Line(
                    points = {
                        {-30, 76}, 
                        {60, 76}},
                    color = {192, 192, 192}), 
                Polygon(
                    points = {
                        {-30, 76}, 
                        {-21, 78}, 
                        {-21, 74}, 
                        {-30, 76}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {60, 76}, 
                        {52, 78}, 
                        {52, 74}, 
                        {60, 76}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Text(
                    extent = {
                        {-2, 86}, 
                        {25, 77}},
                    lineColor = {160, 160, 164},
                    textString = "period")}),
        Documentation(
            revisions = "<html>\n<ul>\n<li><em> 1998   </em>\n       by Christoph Clauss<br> initially implemented<br>\n       </li>\n</ul>\n</html>",
            info = "<html>\n<p>This voltage source uses the corresponding signal source of the Modelica.Blocks.Sources package. Care for the meaning of the parameters in the Blocks package. Furthermore, an offset parameter is introduced, which is added to the value calculated by the blocks source. The startTime parameter allows to shift the blocks source behavior on the time axis.</p>\n</html>"));
end TrapezoidVoltage;