block TriggeredSampler "Triggered sampling of continuous signals"
extends Modelica.Blocks.Icons.DiscreteBlock;
parameter Real y_start = 0 "initial value of output signal";
Modelica.Blocks.Interfaces.RealInput u "Connector with a Real input signal"
annotation (Placement(transformation(extent = {
{-140, -20},
{-100, 20}})));
Modelica.Blocks.Interfaces.RealOutput y "Connector with a Real output signal"
annotation (Placement(transformation(extent = {
{100, -10},
{120, 10}})));
Modelica.Blocks.Interfaces.BooleanInput trigger annotation (Placement(transformation(
origin = {0, -118},
extent = {
{-20, -20},
{20, 20}},
rotation = 90)));
initial equation
y = y_start;
equation
when trigger then
y = u;
end when;
annotation (
Icon(
coordinateSystem(
preserveAspectRatio = true,
extent = {
{-100, -100},
{100, 100}}),
graphics = {
Ellipse(
lineColor = {0, 0, 127},
fillColor = {255, 255, 255},
fillPattern = FillPattern.Solid,
extent = {
{25, -10},
{45, 10}}),
Line(
points = {
{-100, 0},
{-45, 0}},
color = {0, 0, 127}),
Line(
points = {
{45, 0},
{100, 0}},
color = {0, 0, 127}),
Line(
points = {
{0, -100},
{0, -26}},
color = {255, 0, 255}),
Line(
points = {
{-35, 0},
{28, -48}},
color = {0, 0, 127}),
Ellipse(
lineColor = {0, 0, 127},
fillColor = {255, 255, 255},
fillPattern = FillPattern.Solid,
extent = {
{-45, -10},
{-25, 10}})}),
Diagram(
coordinateSystem(
preserveAspectRatio = true,
extent = {
{-100, -100},
{100, 100}}),
graphics = {
Ellipse(
extent = {
{-25, -10},
{-45, 10}},
lineColor = {0, 0, 255},
fillColor = {255, 255, 255},
fillPattern = FillPattern.Solid),
Ellipse(
extent = {
{45, -10},
{25, 10}},
lineColor = {0, 0, 255},
fillColor = {255, 255, 255},
fillPattern = FillPattern.Solid),
Line(
points = {
{-100, 0},
{-45, 0}},
color = {0, 0, 255}),
Line(
points = {
{45, 0},
{100, 0}},
color = {0, 0, 255}),
Line(
points = {
{-35, 0},
{28, -48}},
color = {0, 0, 255}),
Line(
points = {
{0, -100},
{0, -26}},
color = {255, 0, 255})}),
Documentation(info = "<html>\n<p>\nSamples the continuous input signal whenever the trigger input\nsignal is rising (i.e., trigger changes from <strong>false</strong> to\n<strong>true</strong>) and provides the sampled input signal as output.\nBefore the first sampling, the output signal is equal to\nthe initial value defined via parameter <strong>y0</strong>.\n</p>\n</html>"));
end TriggeredSampler;