SampleTrigger

block SampleTrigger "Generate sample trigger signal"
    parameter SI.Time period(final min = Modelica.Constants.small, start = 0.01) "Sample period"
        annotation (Dialog(groupImage = "modelica://Modelica/Resources/Images/Blocks/Sources/SampleTrigger.png"));
    parameter SI.Time startTime = 0 "Time instant of first sample trigger";

    extends Interfaces.partialBooleanSource;
equation
    y = sample(startTime, period);

    annotation (
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(points = {
                    {-60, -70}, 
                    {-60, 70}}), 
                Line(points = {
                    {-20, -70}, 
                    {-20, 70}}), 
                Line(points = {
                    {20, -70}, 
                    {20, 70}}), 
                Line(points = {
                    {60, -70}, 
                    {60, 70}}), 
                Text(
                    extent = {
                        {-150, -140}, 
                        {150, -110}},
                    textString = "%period")}),
        Documentation(info = "<html>\n<p>\nThe Boolean output y is a trigger signal where the output y is only <strong>true</strong>\nat sample times (defined by parameter <strong>period</strong>) and is otherwise\n<strong>false</strong>.\n</p>\n\n<p>\n<img src=\"modelica://Modelica/Resources/Images/Blocks/Sources/SampleTrigger.png\"\n     alt=\"SampleTrigger.png\">\n</p>\n</html>"));
end SampleTrigger;