Skip to content

Commit

Permalink
Don't present value of predefined type as having a name
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Mar 21, 2021
1 parent 6ead7bd commit 6d2c6c9
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions chapters/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,27 @@ \section{Predefined Types and Classes}\label{predefined-types-and-classes}
The \firstuse{attributes}\index{attribute} of the predefined variable types (\lstinline!Real!, \lstinline!Integer!, \lstinline!Boolean!, \lstinline!String!) and \lstinline!enumeration! types are described below with Modelica syntax although they are predefined.
All attributes are predefined and attribute values can only be defined using a modification, such as in \lstinline!Real x(unit = "kg")!.
Attributes cannot be accessed using dot notation, and are not constrained by equations and algorithm sections.
E.g.\ in \lstinline!Real x(unit = "kg") = y;! only the values of \lstinline!x! and \lstinline!y! are declared to be equal, but not their \lstinline!unit! attributes, nor any other attribute of \lstinline!x! and \lstinline!y!.

The $\langle$$\mbox{\emph{value}}$$\rangle$ in the definitions of the predefined types represents the value of an expresion of that type.
Unlike attributes, the $\langle$$\mbox{\emph{value}}$$\rangle$ of a component cannot be referred to by name; both access and modification of the value is made directly on the component.

\begin{example}
Accessing and modifying a variable value, using \lstinline!Real! as example of a predefined type:
\begin{lstlisting}[language=modelica]
model M
record R
Real u;
Real v;
end R;
Real x = sin(time); // Value modification.
Real y(unit = "kg") = x; // Access value of x, and modify value of y.
R r(u = y); // Value modification of r.u.
equation
r.v + x * x = 0; // Access values of r.v and x.
end M;
\end{lstlisting}
Note that only the values of \lstinline!x! and \lstinline!y! are declared to be equal, but not their \lstinline!unit! attributes, nor any other attribute of \lstinline!x! and \lstinline!y!
\end{example}

It is not possible to combine extends from the predefined types, enumeration types, or this \lstinline!Clock! type with other components.

Expand All @@ -1362,7 +1382,7 @@ \subsection{Real Type}\label{real-type}
The following is the predefined \lstinline!Real!\indexinline{Real} type:
\begin{lstlisting}[language=modelica]
type Real // Note: Defined with Modelica syntax although predefined
RealType value; // Accessed without dot-notation
RealType $\langle$$\mbox{\emph{value}}$$\rangle$; // Not an attribute; only accessed without dot-notation
parameter StringType quantity = "";
parameter StringType unit = "" "Unit used in equations";
parameter StringType displayUnit = "" "Default display unit";
Expand Down Expand Up @@ -1401,7 +1421,7 @@ \subsection{Integer Type}\label{integer-type}
The following is the predefined \lstinline!Integer!\indexinline{Integer} type:
\begin{lstlisting}[language=modelica]
type Integer // Note: Defined with Modelica syntax although predefined
IntegerType value; // Accessed without dot-notation
IntegerType $\langle$$\mbox{\emph{value}}$$\rangle$; // Not an attribute; only accessed without dot-notation
parameter StringType quantity = "";
parameter IntegerType min=-Inf, max=+Inf;
parameter IntegerType start = 0; // Initial value
Expand All @@ -1424,7 +1444,7 @@ \subsection{Boolean Type}\label{boolean-type}
The following is the predefined \lstinline!Boolean!\indexinline{Boolean} type:
\begin{lstlisting}[language=modelica]
type Boolean // Note: Defined with Modelica syntax although predefined
BooleanType value; // Accessed without dot-notation
BooleanType $\langle$$\mbox{\emph{value}}$$\rangle$; // Not an attribute; only accessed without dot-notation
parameter StringType quantity = "";
parameter BooleanType start = false; // Initial value
parameter BooleanType fixed = true, // default for parameter/constant;
Expand All @@ -1440,7 +1460,7 @@ \subsection{String Type}\label{string-type}
The following is the predefined \lstinline!String!\indexinline{String} type:
\begin{lstlisting}[language=modelica]
type String // Note: Defined with Modelica syntax although predefined
StringType value; // Accessed without dot-notation
StringType $\langle$$\mbox{\emph{value}}$$\rangle$; // Not an attribute; only accessed without dot-notation
parameter StringType quantity = "";
parameter StringType start = ""; // Initial value
parameter BooleanType fixed = true, // default for parameter/constant;
Expand Down Expand Up @@ -1559,7 +1579,7 @@ \subsubsection{Attributes of Enumeration Types}\label{attributes-of-enumeration-

\begin{lstlisting}[language=modelica]
type E // Note: Defined with Modelica syntax although predefined
EnumType value; // Accessed without dot-notation
EnumType $\langle$$\mbox{\emph{value}}$$\rangle$; // Not an attribute; only accessed without dot-notation
parameter StringType quantity = "";
parameter EnumType min=e1, max=en;
parameter EnumType start = e1; // Initial value
Expand Down

0 comments on commit 6d2c6c9

Please sign in to comment.