Modelica knows few macros to display values of variables or names of components on the diagram, documented in the language specification: https://specification.modelica.org/v3.4/Ch18.html#text
The below model displays the value of a Real variable and String variable as expected, but it fails to display the String from the replaceable package. Is that not possible?
model StringVisual
replaceable package Medium = Modelica.Media.R134a.R134a_ph;
parameter String medname=Medium.mediumName;
parameter String teststringA = "Hello World";
parameter String teststringB = teststringA;
parameter Real myreal=3.14;
equation
when initial() then
Modelica.Utilities.Streams.print(medname);
end when;
annotation (Diagram(graphics={
Text(
extent={{0,-50},{100,-100}},
textColor={30,100,200},
textString="%{myreal}"),
Text(
extent={{-100,60},{-10,0}},
textColor={30,100,200},
textString="%{medname}"),
Text(
extent={{-100,100},{-20,40}},
textColor={30,100,200},
textString="%{Medium.mediumName}"),
Text(
extent={{0,100},{100,40}},
textColor={30,100,200},
textString="%{teststringA}"),
Text(
extent={{0,50},{100,0}},
textColor={30,100,200},
textString="{%teststringB}")}));
end StringVisual;
TL;DR: Currently not.
The simplest interpretation of "value" is to show the parameter-setting, and for parameter String medname=Medium.mediumName;
that means that the "value" is Medium.mediumName
.
In Dymola (since 2017) that is extended to show the value by evaluating the parameter-settings when possible. However, that cannot currently handle package-variables (directly or indirectly) and external functions are deliberately excluded.
Clarified: Thus neither medname
norMedium.mediumName
will work since they are both package-variables.
Note that:
Using "%p"
only works for non-hierarchical names, the safer alternative is "%{p}"
.
Thus the last one should be rewritten as "%{Medium.mediumName}"
- and even that is not fully according to the specification as it isn't a component-reference.