SawToothVoltage

model SawToothVoltage "Saw tooth voltage source"
    parameter SI.Voltage V(start = 1) "Amplitude of saw tooth";
    parameter SI.Time period(start = 1) "Time for one period";

    extends Interfaces.VoltageSource(redeclare Modelica.Blocks.Sources.SawTooth signalSource(final amplitude = V, final period = period));

    annotation (
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {-85, -70}, 
                        {-65, -70}, 
                        {-5, 71}, 
                        {-5, -70}, 
                        {55, 71}, 
                        {55, -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 = {
                        {-34, -20}, 
                        {-37, -33}, 
                        {-31, -33}, 
                        {-34, -20}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Line(
                    points = {
                        {-34, -20}, 
                        {-34, -70}},
                    color = {192, 192, 192}), 
                Polygon(
                    points = {
                        {-34, -70}, 
                        {-37, -57}, 
                        {-31, -57}, 
                        {-34, -70}, 
                        {-34, -70}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Text(
                    extent = {
                        {-78, -24}, 
                        {-35, -36}},
                    lineColor = {160, 160, 164},
                    textString = "offset"), 
                Text(
                    extent = {
                        {-31, -69}, 
                        {15, -87}},
                    lineColor = {160, 160, 164},
                    textString = "startTime"), 
                Text(
                    extent = {
                        {70, -80}, 
                        {94, -100}},
                    lineColor = {160, 160, 164},
                    textString = "time"), 
                Line(
                    points = {
                        {-10, -20}, 
                        {-10, -70}},
                    color = {192, 192, 192},
                    pattern = LinePattern.Dash), 
                Line(
                    points = {
                        {-10, 88}, 
                        {-10, -20}},
                    color = {192, 192, 192},
                    pattern = LinePattern.Dash), 
                Line(
                    points = {
                        {30, 88}, 
                        {30, 59}},
                    color = {192, 192, 192},
                    pattern = LinePattern.Dash), 
                Line(
                    points = {
                        {-10, 83}, 
                        {30, 83}},
                    color = {192, 192, 192}), 
                Text(
                    extent = {
                        {-12, 97}, 
                        {34, 85}},
                    lineColor = {160, 160, 164},
                    textString = "period"), 
                Line(
                    points = {
                        {-44, 60}, 
                        {30, 60}},
                    color = {192, 192, 192},
                    pattern = LinePattern.Dash), 
                Line(
                    points = {
                        {-34, 47}, 
                        {-34, -20}},
                    color = {192, 192, 192}), 
                Text(
                    extent = {
                        {-78, 34}, 
                        {-37, 20}},
                    lineColor = {160, 160, 164},
                    textString = "V"), 
                Polygon(
                    points = {
                        {-34, 60}, 
                        {-37, 47}, 
                        {-30, 47}, 
                        {-34, 60}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {-34, -20}, 
                        {-37, -7}, 
                        {-31, -7}, 
                        {-34, -20}, 
                        {-34, -20}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {-10, 83}, 
                        {-1, 85}, 
                        {-1, 81}, 
                        {-10, 83}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {30, 83}, 
                        {22, 85}, 
                        {22, 81}, 
                        {30, 83}},
                    lineColor = {192, 192, 192},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Line(
                    points = {
                        {-80, -20}, 
                        {-10, -20}, 
                        {30, 60}, 
                        {30, -20}, 
                        {72, 60}, 
                        {72, -20}},
                    thickness = 0.5), 
                Text(
                    extent = {
                        {-77, 100}, 
                        {-27, 88}},
                    lineColor = {160, 160, 164},
                    textString = "v = p.v - n.v")}),
        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 SawToothVoltage;