ZeroOrderHold

block ZeroOrderHold "Zero order hold of a sampled-data system"
    extends Interfaces.DiscreteSISO;

    output Real ySample(start = 0, fixed = true);
equation
    when {sampleTrigger, initial()} then 
        ySample = u;
    end when;
    y = pre(ySample);

    annotation (
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {-78, -42}, 
                        {-52, -42}, 
                        {-52, 0}, 
                        {-26, 0}, 
                        {-26, 24}, 
                        {-6, 24}, 
                        {-6, 64}, 
                        {18, 64}, 
                        {18, 20}, 
                        {38, 20}, 
                        {38, 0}, 
                        {44, 0}, 
                        {44, 0}, 
                        {62, 0}},
                    color = {0, 0, 127})}),
        Documentation(info = "<html>\n<p>\nThe output is identical to the sampled input signal at sample\ntime instants and holds the output at the value of the last\nsample instant during the sample points.\n</p>\n</html>"));
end ZeroOrderHold;