Skip to content

Commit

Permalink
Added event triggered print block (closes #289)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhard-thiele committed May 23, 2019
1 parent 13bd25b commit 4b373b0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Modelica_DeviceDrivers/Utilities/package.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,39 @@ package Utilities "Collection of utility elements used within the library"
extends Modelica.Icons.UtilitiesPackage;
constant String RootDir = Modelica.Utilities.Files.loadResource("modelica://Modelica_DeviceDrivers/")
"Deprecated package constant. Use loadResource(..) directly in concerned models.";

block TriggeredPrint
"Block for debugging purposes. Prints a message at trigger instants."
output String message= getInstanceName() annotation (Dialog(enable=true));

This comment has been minimized.

Copy link
@beutlich

beutlich May 24, 2019

Contributor

A description would have been nice.

Modelica.Blocks.Interfaces.BooleanInput trigger annotation (Placement(
transformation(
extent={{-20,-20},{20,20}},
rotation=90,
origin={0,-60})));
equation
when trigger then
Modelica.Utilities.Streams.print(String(time) + " s: " + message);
end when;
annotation (Icon(coordinateSystem(
preserveAspectRatio=false,
extent={{-100,-100},{100,100}}), graphics={
Rectangle(
extent={{-100,40},{100,-40}},
lineColor={0,0,0},
lineThickness=5.0,
fillColor={235,235,235},
fillPattern=FillPattern.Solid,
borderPattern=BorderPattern.Raised),
Text(
extent={{-88,16},{82,-14}},
lineColor={0,0,0},
textString="%message"),
Text(
extent={{-150,90},{140,50}},
textString="%name",
lineColor={0,0,255})}));
end TriggeredPrint;

annotation (
preferredView="info",
Documentation(info="<html>
Expand Down
1 change: 1 addition & 0 deletions Modelica_DeviceDrivers/Utilities/package.order
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Functions
Icons
Types
StringExpression
TriggeredPrint

0 comments on commit 4b373b0

Please sign in to comment.