-
Create a new library and give it the name
MyLib.
For information on how to create a library, see
Creating a Modelica Library or Dymola Behavior Library.
-
In that library, create two new empty models,
MyTankModel and
TestModel.
For information on how to create models, see
Create a New Class or Extend from an Existing Class Using the New Class Command.
-
Open
MyTankModel and define two parameters:
For information on how to define parameters, see
Defining Parameters and Editing Properties of Parameters.
-
A Real parameter
Level for the tank level
-
A Boolean parameter
PhError to indicate if the PH value in the
tank is too high
For result see the figure below.
-
From the
Diagram section of the
action bar,
click
Icon Layer
.
Note:
Actually graphics in the diagram layer can be controlled as
well, but mostly the icon layer is the relevant layer to use.
-
Draw a large rectangle to symbolize the tank level. Start drawing
from lower left corner.
-
From the
Behavior Authoring section of the
action bar,
click
Modelica Editor
.
-
In the
Modelica Editor, click the green
a to expand the annotations of the rectangle.
The code is displayed:
-
Edit the
extent to be like above; that uses the entire icon
space and simplifies the handling of the level value in the next step.
-
To animate the level of the tank, and to change the color of it if
the
PhError is
true , apply
DynamicSelect by editing the text:
The resulting code (after some formatting) is:
-
To test, do the following:, open the model and drag into it
-
Open the model
TestModel.
-
Drag
MyTankModel into it to instantiate it.
For information on how to instantiate, see
Instantiating a Component.
-
Double-click the instantiated component and change the
parameter values.
The level and color of the component should vary
accordingly.
Note:
This is just a simple example of control of graphical
annotations, a real tank needs more work.
|