Skip to content

Commit

Permalink
Restrict uses of sizeless array components of expandable connectors
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Jun 23, 2020
1 parent 7e7da24 commit 1edb1d2
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions chapters/connectors.tex
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,35 @@ \subsection{Expandable Connectors}\doublelabel{expandable-connectors}
\end{lstlisting}
\end{example}

An expandable connector array component for which \lstinline!size! is not defined (see \autoref{array-dimension-and-size-functions}) is referred to as a \emph{sizeless array component}. Such a
component may not be used without subscripts, and the subscripts must slice the array so that the sizeless dimensions are removed.

\begin{example}
Valid and invalid uses of sizeless array components:
\begin{lstlisting}[language=modelica]
expandable connector EngineBus
end EngineBus;

block Sensor
RealOutput speed;
end Sensor;

model Engine
parameter Integer n=1;
EngineBus bus;
Sensor sensor;
RealOutput sensorSpeeds[:];
equation
/* Comments below refer to the use of sizeless array bus.speed. */
connect(bus.speed[n], sensor.speed) ; // OK; subscript to scalar component.
connect(bus.speed, sensorSpeeds); // Error; missing subscripts.
public
Real s[:] = bus.speed; // Error; missing subscripts.
Real s[2] = bus.speed[{1, 3}]; // OK; subscript selects fixed size sub-array.
end Engine;
\end{lstlisting}
\end{example}

After this elaboration the expandable connectors are treated as normal
connector instances, and the connections as normal connections, and all
potentially present variables and array elements that are not actually
Expand Down

0 comments on commit 1edb1d2

Please sign in to comment.