Skip to content

Commit

Permalink
Merge pull request #2606 from henrikt-ma/cleanup/expandable
Browse files Browse the repository at this point in the history
Cleanup related to expandable connectors
  • Loading branch information
HansOlsson committed Jun 26, 2020
2 parents 8e71d0c + 0ea63e7 commit 7de7439
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 48 deletions.
2 changes: 1 addition & 1 deletion chapters/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ \section{Specialized Classes}\doublelabel{specialized-classes}
end '*';
end Complex;
record MyComplex
extends Complex; // not allowed, since extending from enclosing scope
extends Complex; // Error; extending from enclosing scope.
Real k;
end MyComplex;
operator record ComplexVoltage = Complex(re(unit="V"),im(unit="V")); // allowed
Expand Down
69 changes: 28 additions & 41 deletions chapters/connectors.tex
Original file line number Diff line number Diff line change
Expand Up @@ -130,26 +130,23 @@ \subsection{Expandable Connectors}\doublelabel{expandable-connectors}
component, and if the other connector is an undeclared element in a
declared expandable connector it is handled as follows (elements that
are only potentially present are not seen as declared):
\begin{itemize}
\item
The expandable connector instance is automatically augmented with a
new component having the used name and corresponding type.
\item
If the undeclared component is subscripted, an array variable is
created, and a connection to the specific array element is performed.
Introducing elements in an array gives an array with at least the
specified elements, other elements are either not created or have a
default value (i.e.\ as if they were only potentially present).
\item
If the variable on the other side of the connect-equation is input or
output the new component will be either input or output to satisfy the
restrictions in \autoref{restrictions-of-connections-and-connectors} for a non-expandable connector.
\begin{nonnormative}
If the existing side refers to an inside connector (i.e.\ a connector of a component) the new variable will copy its causality, i.e.\ input
if input and output if output, since the expandable connector must be an outside connector.
\end{nonnormative}
For an array the input/output property can be deduced separately for each array element.
\end{itemize}
\begin{itemize}
\item
The expandable connector instance is automatically augmented with a
new component having the used name and corresponding type.
\item
If the undeclared component is subscripted, an array variable is created, and a connection to the specific array element is performed. Introducing elements in an
array gives an array with at least the specified elements, other elements are either not created or have a default value (i.e.\ as if they were only potentially present).
\item
If the variable on the other side of the connect-equation is input or output the new component will be either input or output to satisfy the restrictions in
\autoref{restrictions-of-connections-and-connectors} for a non-expandable connector.
\begin{nonnormative}
If the existing side refers to an inside connector (i.e.\ a connector of a component) the new variable will copy its causality, i.e.\ input
if input and output if output, since the expandable connector must be an outside connector.
\end{nonnormative}
For an array the input/output property can be deduced separately for each array element.
\end{itemize}

\item
When two expandable connectors are connected, each is augmented with
the variables that are only declared in the other expandable connector
Expand All @@ -159,16 +156,17 @@ \subsection{Expandable Connectors}\doublelabel{expandable-connectors}
\begin{nonnormative}
I.e.\ each of the connector instances is expanded to be the union of all connector variables.
\end{nonnormative}

\item
The variables introduced in the elaboration follow additional rules
for generating connection sets (given in \autoref{generation-of-connection-equations}).

\item
If a variable appears as an input in one expandable connector, it
should appear as a non-input in at least one other expandable
connector instance in the same augmentation set. An augmentation set
is defined as the set of connected expandable connector instances that
through the elaboration will have matching variables.

\begin{example}
\begin{lstlisting}[language=modelica]
expandable connector EngineBus
Expand Down Expand Up @@ -198,7 +196,6 @@ \subsection{Expandable Connectors}\doublelabel{expandable-connectors}
\begin{nonnormative}
I.e.\ it is possible to connect to e.g.\ a \lstinline!Real! variable.
\end{nonnormative}

\begin{example}
\begin{lstlisting}[language=modelica]
expandable connector EngineBus // has predefined signals
Expand Down Expand Up @@ -226,13 +223,12 @@ \subsection{Expandable Connectors}\doublelabel{expandable-connectors}
An expandable connector may not contain a component declared with the
prefix \lstinline!flow!, but may contain non-expandable connector components with
\lstinline!flow! components.

\begin{example}
\begin{lstlisting}[language=modelica]
import Interfaces=Modelica.Electrical.Analog.Interfaces;
expandable connector ElectricalBus
Interfaces.PositivePin p12, n12; // OK
flow Modelica.Units.SI.Current i; // not allowed
flow Modelica.Units.SI.Current i; // Error
end ElectricalBus;

model Battery
Expand All @@ -246,16 +242,12 @@ \subsection{Expandable Connectors}\doublelabel{expandable-connectors}
\end{example}

\item
expandable connectors can only be connected to other expandable
connectors.
expandable connectors can only be connected to other expandable connectors.
\end{itemize}
If a connect equation references a potentially present variable, or
variable element, in an expandable connector the variable or variable
element is marked as being present, and due to the paragraphs above it
is possible to deduce whether the bus variable shall be treated as
input, or shall be treated as output in the connect equation. That
input or output prefix is added if no input/output prefix is present
on the declaration

If a connect equation references a potentially present variable, or variable element, in an expandable connector the variable or variable element is marked as being present, and due to the
paragraphs above it is possible to deduce whether the bus variable shall be treated as input, or shall be treated as output in the connect equation. That \lstinline!input! or \lstinline!output!
prefix is added if no \lstinline!input!/\lstinline!output! prefix is present on the declaration.

\begin{example}
\begin{lstlisting}[language=modelica]
Expand All @@ -267,14 +259,9 @@ \subsection{Expandable Connectors}\doublelabel{expandable-connectors}
EmptyBus bus2;
RealInput speed;
equation
connect(speed, bus1.speed); // ok, only one undeclared
// and it is unsubscripted

connect(bus1.pressure, bus2.pressure);
// not allowed, both undeclared

connect(speed, bus2.speed[2]);
// introduces speed array (with element [2]).
connect(speed, bus1.speed); // OK; only one undeclared and not subscripted.
connect(bus1.pressure, bus2.pressure); // Error; both undeclared.
connect(speed, bus2.speed[2]); // Introduces speed array (with element [2]).
end Controller;
\end{lstlisting}
\end{example}
Expand Down
9 changes: 3 additions & 6 deletions chapters/operatorsandexpressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1323,17 +1323,14 @@ \subsection{Parameter Expressions}\doublelabel{parameter-expressions}
\lstinline!edge!, \lstinline!change!, \lstinline!sample!, and \lstinline!pre!, a function or operator with parameter
subexpressions is a parameter expression.
\item
Some function calls are parameter expressions even if the arguments
are not:

Some function calls are parameter expressions even if the arguments are not:
\begin{itemize}
\item
\lstinline!cardinality(c)!, see restrictions for use in \autoref{cardinality-deprecated}.
\item
\lstinline!end! in \lstinline!A[...end... ]! if \lstinline!A! is variable declared in a non-function class.
\lstinline!end! in \lstinline!A[$\ldots$ end $\ldots$]! if \lstinline!A! is variable declared in a non-function class.
\item
\lstinline!size(A)! (including \lstinline!size(A, j)! where \lstinline!j! is parameter expression) if \lstinline!A!
is variable declared in a non-function class
\lstinline!size(A)! (including \lstinline!size(A, j)! where \lstinline!j! is parameter expression) if \lstinline!A! is variable declared in a non-function class.
\item
\lstinline!Connections.isRoot(A.R)!
\item
Expand Down

0 comments on commit 7de7439

Please sign in to comment.