Comments and annotations should start with a capital letter, for example:
parameter Real a = 1 "Arbitrary factor";
.
For Boolean parameters, the description string should start with "= true, …", for example:
parameter Boolean useHeatPort = false "= true, if heatPort is enabled";
.
The annotations "tab" and "group" define the placement of component or of variables in a dialog.
Using the group annotation, the following rules shall be followed:
Using the tab annotation, the following rules shall be followed:
Imagine you define a controlled electric drive being composed of a controller and an electrical machine. The latter has parameters number of pole pairs p, nominal frequency fnom, rotor's moment of inertia Jrotor and others. The controller itself is divided into several sub-controllers – such as the one for speed control with parameters like gain k or time constant T. Then, the above parameters of your electrical drive model could be sorted using tabs and groups as follows: p, fnom and Jrotor grouped in the "Electrical machine" group in the "general" tab; k and T in the group "Speed control" under tab "Controller".
In the Modelica code, for example the parameter k will then be defined like:
parameter Real k=1 "Gain" annotation( Dialog( tab="Controller", group="Speed control"));
Trailing white-space (i.e., white-space at the end of the lines) shall not be used. The tab-character shall not be used, since the tab-stops are not standardized.
The code in a class shall be indented relative to the class in steps of two spaces;
except that the headings public
, protected
, equation
,
algorithm
, and end
of class marker shall not be indented.
The keywords public
and protected
are headings for a group
of declarations.
Long modifier lists shall be split into several indented lines with at most one modifier per line.
Full class definitions shall be separated by an empty line.
package MyPackage partial model BaseModel parameter Real p; input Real u(unit="m/s"); protected Real y; Real x( start=1, unit="m", nominal=10); equation der(x) = u; y = 2*x; end BaseModel; model ModelP2 extends BaseModel(p=2); end ModelP2; end MyPackage;