- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Annotations, Tabs/Groups and...
Annotations, Tabs/Groups and dropdown menus?
Annotations, Tabs/Groups and dropdown menus?
Are tabs/groups annotations possible in OM? I have a parametrized "Components" and i want to have a dropdown menu for choosing the right component for my modeling. I want to implement this in OMEdit?
If this not possible? Any idea for an user friendly implementation. As far as i know this is possible using dymola.
Thank you in advance!
Cheers,
Filip
Re: Annotations, Tabs/Groups and dropdown menus?
Regarding the dropdown menu, do you mean the feature described in https://trac.modelica.org/Modelica/ticket/624 or something else? It's really hard to tell what you mean since we do not use Dymola (and the standard library is filled with Dymola-specific annotations).
- sjoelund.se
- 1700 Posts
Re: Annotations, Tabs/Groups and dropdown menus?
Hi, more or less the topic is discussed under the link you posted. It could be done by using the choicesAllMatching, but not necessary to use . In the Modelica Language Specification 3.1. on page 74 under 7.3.4 Annotation Choices for Suggested Redeclarations and Modifications
you can see a simple example:
replaceable model MyResistor=Resistor
annotation(choices(
choice(redeclare model MyResistor=lib2.Resistor(a={2}) "…"),
choice(redeclare model MyResistor=lib2.Resistor2 "…")));
Using this one can choose between the both "models". I think it's pretty nice feature where you can have your component database. Through the choice a dropdown menu in Dymola is generated , where one can choose which paramaterized component is to be used. It's a usefull thing especially for building templates.
The Tabs feature is that in the dialog window of the components under the properties custom tabs could be defined (not only General, Parameters, Modifiers).
Here an example:
model DialogDemo
parameter Boolean b = true "Boolean parameter";
parameter Modelica.SIunits.Length length "Real parameter with unit";
parameter Integer nInports=0 annotation(Dialog(connectorSizing=true));
parameter Real r1 "Real parameter in Group 1" annotation(Dialog(group="Group 1"));
parameter Real r2 "Disabled Real parameter in group 1"
annotation(Dialog(group="Group 1", enable = not b));
parameter Real r3 "Real parameter in Tab 1" annotation(Dialog(tab="Tab 1"));
parameter Real r4 "Real parameter in Tab 1 and Group 2"
annotation(Dialog(tab="Tab 1", group="Group 2"));
StepIn stepIn[nInports];
...
end DialogDemo; <== copied from the modelica specification
Filip
Re: Annotations, Tabs/Groups and dropdown menus?
Dymola also offers dropdown boxes for the following situation. Look at Modelica.Electrical.Digital.Examples.Multiplexer.
The MUX component has a q0 parameter with a dropdown box. The parameter is defined in Modelica.Electrical.Digital.Examples.Multiplexer as:
parameter D.Interfaces.Logic q0=L.'0' "initial value";
This is defined in Modelica.Electrical.Digital.Interfaces.Logic as:
type Logic = enumeration(
'U' "U Uninitialized",
'X' "X Forcing Unknown",
'0' "0 Forcing 0",
'1' "1 Forcing 1",
'Z' "Z High Impedance",
'W' "W Weak Unknown",
'L' "L Weak 0",
'H' "H Weak 1",
'-' "- Don't care")
"Logic values and their coding according to IEEE 1164 STD_ULOGIC type"
Those enumerations give the dropdown parameters.
Re: Annotations, Tabs/Groups and dropdown menus?
Here's a "deeper" example in Modelica.Thermal.FluidHeadFlow.Examples.SimpleCooling. It has a pump (Modelica.Thermal.FluidHeatFlow.Sources.VolumeFlow) with a parameter "medium" with a dropdown box.
Modelica.Thermal.FluidHeatFlow.Sources.VolumeFlow inherits from Modelica.Thermal.FluidHeatFlow.Interfaces.Partials.TwoPort where that parameter is defined as:
parameter FluidHeatFlow.Media.Medium medium=FluidHeatFlow.Media.Medium()
"Medium in the component"
annotation(__Dymola_choicesAllMatching=true);
Here's how Medium is defined:
record Medium "Record containing media properties"
extends Modelica.Icons.Record;
parameter Modelica.SIunits.Density rho = 1 "Density";
parameter Modelica.SIunits.SpecificHeatCapacity cp = 1
"Specific heat capacity at constant pressure";
parameter Modelica.SIunits.SpecificHeatCapacity cv = 1
"Specific heat capacity at constant volume";
parameter Modelica.SIunits.ThermalConductivity lamda = 1
"Thermal conductivity";
parameter Modelica.SIunits.KinematicViscosity nue = 1 "kinematic viscosity";
end Medium;
In addition to a dropdown box, you get a button next to the dropdown to specify the object's parameters.
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Annotations, Tabs/Groups and...