UniformNoise

block UniformNoise "Noise generator with uniform distribution"
    import distribution = Modelica.Math.Distributions.Uniform.quantile;

    extends Modelica.Blocks.Interfaces.PartialNoise;

    parameter Real y_min(start = 0) "Lower limit of y"
        annotation (Dialog(enable = enableNoise));
    parameter Real y_max(start = 1) "Upper limit of y"
        annotation (Dialog(enable = enableNoise));
initial equation
    r = distribution(r_raw, y_min, y_max);
equation
    when generateNoise and sample(startTime, samplePeriod) then 
        r = distribution(r_raw, y_min, y_max);
    end when;

    annotation (
        Icon(
            coordinateSystem(
                preserveAspectRatio = false,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    visible = enableNoise,
                    points = {
                        {-76, 60}, 
                        {78, 60}},
                    color = {95, 95, 95},
                    pattern = LinePattern.Dot), 
                Line(
                    visible = enableNoise,
                    points = {
                        {-76, -60}, 
                        {78, -60}},
                    color = {95, 95, 95},
                    pattern = LinePattern.Dot), 
                Text(
                    visible = enableNoise,
                    extent = {
                        {-70, 94}, 
                        {95, 64}},
                    lineColor = {175, 175, 175},
                    textString = "%y_max"), 
                Text(
                    visible = enableNoise,
                    extent = {
                        {-70, -64}, 
                        {95, -94}},
                    lineColor = {175, 175, 175},
                    textString = "%y_min")}),
        Documentation(
            info = "<html>\n<p>\nA summary of the common properties of the noise blocks is provided in the documentation of package\n<a href=\"modelica://Modelica.Blocks.Noise\">Blocks.Noise</a>.\nThis UniformNoise block generates reproducible, random noise at its output according to a uniform distribution.\nThis means that random values are uniformly distributed within the range defined by parameters\ny_min and y_max (see example <a href=\"modelica://Modelica.Blocks.Examples.NoiseExamples.UniformNoiseProperties\">NoiseExamples.UniformNoiseProperties</a>).\nBy default, two or more instances produce different, uncorrelated noise at the same time instant.\nThe block can only be used if on the same or a higher hierarchical level,\nmodel <a href=\"modelica://Modelica.Blocks.Noise.GlobalSeed\">Blocks.Noise.GlobalSeed</a>\nis dragged to provide global settings for all instances.\n</p>\n</html>",
            revisions = "<html>\n<table border=1 cellspacing=0 cellpadding=2>\n<tr><th>Date</th> <th align=\"left\">Description</th></tr>\n\n<tr><td> June 22, 2015 </td>\n    <td>\n\n<table border=0>\n<tr><td>\n         <img src=\"modelica://Modelica/Resources/Images/Blocks/Noise/dlr_logo.png\">\n</td><td valign=\"bottom\">\n         Initial version implemented by\n         A. Kl&ouml;ckner, F. v.d. Linden, D. Zimmer, M. Otter.<br>\n         <a href=\"http://www.dlr.de/rmc/sr/en\">DLR Institute of System Dynamics and Control</a>\n</td></tr></table>\n</td></tr>\n\n</table>\n</html>"));
end UniformNoise;