Redeclarations of Annotation Choices


The user interface can suggest reasonable redeclarations, where the string comment in the choice declaration can be used as a textual explanation of a choice. Based on the interactions with the user, the GUI then generates the appropriate Modelica code. The annotation can also be used as a hint to the user doing textual Modelica programming. In order to support this mode of operation, an
annotation called choices containing choice elements is predefined to be recognized with certain semantics in Modelica, including recognition of redeclaration statements in the annotation.


1 Resistor


2 MyResistor


If the user would choose the first alternative, the following code might be produced if MyResistor is part of the class MyCircuit and the chosen name of the instantiated component is x:


MyCircuit x(redeclare MyResistor=lib2.Resistor(a={2}))

Additional examples of replaceable class declarations with redeclaration choices are shown below.


3 Simulation of ReplResistor


4 Electrical Connectors




5 Electrical Components


6 Replaceable Resistor


7 Friction



8 KindOfController

The choices annotation is not restricted to replaceable elements. It is also applicable to nonreplaceable elements, simple variables and types used for enummerations. For example, consider the following Integer type called KindOfController used to represent a choice of controller in the modeling process out of the following enumeration of three recommended alternatives.




Assume that
KindOfController is used in a model KindOfControllerInst as below:




An interactive choice of the third alternative from a menu containing the alternatives {"P", "PI", "PID"} would result in the default value 3 for the instatiated variable x in the following code for an instance a2 of the model A.



9 Simulation of KindOfController