UnitDelay

block UnitDelay "Unit Delay Block"
    parameter Real y_start = 0 "Initial value of output signal";

    extends Interfaces.DiscreteSISO;
initial equation
    y = y_start;
equation
    when sampleTrigger then 
        y = pre(u);
    end when;

    annotation (
        Documentation(info = "<html>\n<p>\nThis block describes a unit delay:\n</p>\n<blockquote><pre>\n     1\ny = --- * u\n     z\n</pre></blockquote>\n<p>\nthat is, the output signal y is the input signal u of the\nprevious sample instant. Before the second sample instant,\nthe output y is identical to parameter yStart.\n</p>\n\n</html>"),
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {-30, 0}, 
                        {30, 0}},
                    color = {0, 0, 127}), 
                Text(
                    textColor = {0, 0, 127},
                    extent = {
                        {-90, 10}, 
                        {90, 90}},
                    textString = "1"), 
                Text(
                    textColor = {0, 0, 127},
                    extent = {
                        {-90, -90}, 
                        {90, -10}},
                    textString = "z")}));
end UnitDelay;