block TriggeredMax "Compute maximum, absolute value of continuous signal at trigger instants"
extends Modelica.Blocks.Icons.DiscreteBlock;
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 = 0;
equation
when trigger then
y = max(pre(y), abs(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}),
Text(
extent = {
{-86, 24},
{82, 82}},
color = {0, 0, 127},
textString = "max"),
Ellipse(
lineColor = {0, 0, 127},
fillColor = {255, 255, 255},
fillPattern = FillPattern.Solid,
extent = {
{-45, -10},
{-25, 10}})}),
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>). The maximum, absolute value of the input signal\nat the sampling point is provided as output signal.\n</p>\n</html>"));
end TriggeredMax;