diff --git a/chapters/synchronous.tex b/chapters/synchronous.tex index a77298270..d0600a6a8 100644 --- a/chapters/synchronous.tex +++ b/chapters/synchronous.tex @@ -184,70 +184,60 @@ \section{Definitions}\doublelabel{definitions} \subsection{Clocks and Clocked Variables}\doublelabel{clocks-and-clocked-variables} -In \autoref{discrete-time-expressions} the term \emph{discrete-time} Modelica expression and in -\autoref{continuous-time-expressions} the term \emph{continuous-time} Modelica expression is -defined. In this chapter, two additional kinds of discrete-time -expressions/variables are defined that are associated to clocks and are -therefore called \firstuse{clocked discrete-time} expressions: -% henrikt-ma: Misusing \tablehead inside the table below to act as some sort of table title. -% Similarly, while this table is actually a list of definitions, the styling of the terms being described -% should probably use something else than \firstuse, perhaps more like a 'description' environment. -% This is all different than how things are done elsewhere, but fixing this is considered a topic for issue #2562. -\begin{longtable}[]{|p{7.3cm}|p{7.3cm}|} -\hline -\multicolumn{2}{|p{14.6cm}|}{\tablehead{The different kinds of discrete-time variables in Modelica}}\\ \hline -\endhead -\begin{tabular}{p{7cm}} -\includegraphics[width=3in,height=1.875in]{piecewise} -\end{tabular}&\begin{tabular}{p{7cm}}\firstuse{Piecewise-constant variables}\\ -(See \autoref{discrete-time-expressions}.) Variables \lstinline!m(t)! of base type \lstinline!Real!, \lstinline!Integer!, \lstinline!Boolean!, -enumeration, and \lstinline!String! that are \emph{constant} inside each interval -t\textsubscript{i} $\le$ t \textless{} t\textsubscript{i+1} (= piecewise -constant continuous-time variables). In other words, \lstinline!m(t)! -\emph{changes} value \emph{only at events}. This means, \lstinline!m($t$)! = -\lstinline!m($t_{i}$)!, for $t_{i} \leq t < t_{i+1}$. Such variables depend continuously on time and -they are discrete-time variables. -\end{tabular}\\ \hline -\begin{tabular}{p{7cm}} -\includegraphics[width=3in,height=1.875in]{clock} -\end{tabular}& -\begin{tabular}{p{7cm}}\firstuse{Clock variables}\\ -Clock variables \lstinline!c($t_{i}$)! are of base type \lstinline!Clock!. A -clock is either defined by a constructor (such as \lstinline!Clock(3)!) -that defines when the clock ticks (is active) at a particular time -instant, or it is defined with clock operators relatively to other -clocks, see \autoref{base-clock-conversion-operators}. -\par -\begin{example*} +In \autoref{discrete-time-expressions} the term \emph{discrete-time} Modelica expression and in \autoref{continuous-time-expressions} the term \emph{continuous-time} Modelica expression is defined. +In this chapter, two additional kinds of discrete-time expressions/variables are defined that are associated to clocks and are therefore called \firstuse{clocked discrete-time} expressions. The +different kinds of discrete-time variables in Modelica are defined below. + +\begin{definition}[Piecewise-constant variable] +(See \autoref{discrete-time-expressions}.) Variables \lstinline!m(t)! of base type \lstinline!Real!, \lstinline!Integer!, \lstinline!Boolean!, enumeration, and \lstinline!String! that are +\emph{constant} inside each interval t\textsubscript{i} $\le$ t \textless{} t\textsubscript{i+1} (= piecewise constant continuous-time variables). In other words, \lstinline!m(t)! \emph{changes} +value \emph{only at events}. This means, \lstinline!m($t$)! = \lstinline!m($t_{i}$)!, for $t_{i} \leq t < t_{i+1}$. Such variables depend continuously on time and they are discrete-time variables. +See \autoref{fig:piecewise-constant-variable}. +\end{definition} + +\begin{figure}[H] + \begin{center} + \includegraphics[width=3in]{piecewise} + \end{center} + \caption{A piecewise-constant variable.}\doublelabel{fig:piecewise-constant-variable} +\end{figure} + +\begin{definition}[Clock variable] +Clock variables \lstinline!c($t_{i}$)! are of base type \lstinline!Clock!. A clock is either defined by a constructor (such as \lstinline!Clock(3)!) that defines when the clock ticks (is active) at +a particular time instant, or it is defined with clock operators relatively to other clocks, see \autoref{base-clock-conversion-operators}. See \autoref{fig:clock-variable}. +\end{definition} + +\begin{example} +Clock variables: \begin{lstlisting}[language=modelica] - Clock c1 = Clock($\ldots$); - Clock c2 = c1; - Clock c3 = subSample(c2, 4); +Clock c1 = Clock($\ldots$); +Clock c2 = c1; +Clock c3 = subSample(c2, 4); \end{lstlisting} -\end{example*} -\end{tabular}\\ \hline -\begin{tabular}{p{7cm}} -\includegraphics[width=3in,height=1.875in]{clocked} -\end{tabular}& -\begin{tabular}{p{7cm}}\firstuse{Clocked variables}\\ -The elements of clocked variables \lstinline!r($t_{i}$)! are of -base type \lstinline!Real!, \lstinline!Integer!, \lstinline!Boolean!, enumeration, \lstinline!String! that are -associated uniquely with a clock \lstinline!c($t_{i}$)!. A -clocked variable can only be directly accessed at the event instant -where the associated clock is active. A constant and a -parameter can always be used at a place where a clocked variable is -required. - -At time instants where the associated clock is not active, the value of -a clocked variable can be inquired by using an explicit cast operator, -see below. In such a case \lstinline!hold! semantics is used, in other words -the value of the clocked variable from the last event instant is used. -\par -\begin{nonnormative*} -This is visualized in the left figure with the dashed green lines. -\end{nonnormative*} -\end{tabular}\\ \hline -\end{longtable} +\end{example} + +\begin{figure}[H] + \begin{center} + \includegraphics[width=3in]{clock} + \end{center} + \caption{A clock variable.}\doublelabel{fig:clock-variable} +\end{figure} + +\begin{definition}[Clocked variable] +The elements of clocked variables \lstinline!r($t_{i}$)! are of base type \lstinline!Real!, \lstinline!Integer!, \lstinline!Boolean!, enumeration, \lstinline!String! that are associated uniquely with +a clock \lstinline!c($t_{i}$)!. A clocked variable can only be directly accessed at the event instant where the associated clock is active. A constant and a parameter can always be used at a place +where a clocked variable is required. + +At time instants where the associated clock is not active, the value of a clocked variable can be inquired by using an explicit cast operator, see below. In such a case \lstinline!hold! semantics is +used, in other words the value of the clocked variable from the last event instant is used. See \autoref{fig:clocked-variable}. +\end{definition} + +\begin{figure}[H] + \begin{center} + \includegraphics[width=3in]{clocked} + \end{center} + \caption{A clocked variable. The constant extrapolation of the value at the last event instant is illustrated with dashed green lines.}\doublelabel{fig:clocked-variable} +\end{figure} \subsection{Base-Clock and Sub-Clock Partitions}\doublelabel{base-clock-and-sub-clock-partitions}