.ModelicaReference.Annotations.choices

Information

Define graphical layout of choices in a parameter menu

Description

A declaration can have an annotation choices containing modifiers on choice, where each of them indicates a suitable redeclaration or modifications of the element. This is a hint for users of the model, and can also be used by the user interface to suggest reasonable redeclaration, where the string comments on the choice declaration can be used as textual explanations of the choices. The annotation is not restricted to replaceable elements but can also be applied to non-replaceable elements, enumeration types, and simple variables.

For a Boolean variable, a choices annotation may contain the definition checkBox = true, meaning to display a checkbox to input the values false or true in the graphical user interface.

Examples

replaceable model MyResistor=Resistor
  annotation(choices(
              choice(redeclare MyResistor=lib2.Resistor(a={2}) "..."),
              choice(redeclare MyResistor=lib2.Resistor2 "...")));

replaceable Resistor Load(R=2) constrainedby TwoPin
  annotation(choices(
              choice(redeclare lib2.Resistor Load(a={2}) "..."),
              choice(redeclare Capacitor Load(L=3) "...")));

replaceable FrictionFunction a(func=exp) constrainedby Friction
  annotation(choices(
             choice(redeclare ConstantFriction a(c=1) "..."),
             choice(redeclare TableFriction a(table="...") "..."),
             choice(redeclare FunctionFriction a(func=exp) "..."))));

type KindOfController=Integer(min=1,max=3)
   annotation(choices(
                choice=1 "P",
                choice=2 "PI",
                choice=3 "PID"));

model A
  KindOfController x;
end A;
A a(x=3 "PID");

It can also be applied to Boolean variables to define a check box:

  parameter Boolean useHeatPort=false annotation(choices(checkBox=true));

Generated at 2024-03-28T19:15:55Z by OpenModelicaOpenModelica 1.22.3 using GenerateDoc.mos