Skip to content

Commit

Permalink
Sample application to base-clock conversion operators
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Sep 14, 2020
1 parent 4a73e8f commit 7c47ce9
Showing 1 changed file with 30 additions and 45 deletions.
75 changes: 30 additions & 45 deletions chapters/synchronous.tex
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ \section{Clocked State Variables}\label{clocked-state-variables}
The previous value of a clocked variable can be accessed with the \lstinline!previous! operator. A variable to which \lstinline!previous! has been applied is called a \firstuse{clocked state variable}.

\begin{operatordefinition}[previous]
\begin{synopsis}\begin{lstlisting}[language=synopsis]
\begin{synopsis}\begin{lstlisting}
previous(u)
\end{lstlisting}\end{synopsis}
\begin{semantics}
Expand All @@ -573,50 +573,35 @@ \section{Partitioning Operators}\label{partitioning-operators}
\subsection{Base-clock conversion operators}\label{base-clock-conversion-operators}

The following operators convert between a continuous-time and a
clocked-time representation and vice versa:
\begin{longtable}[]{|l|p{12cm}|}
\hline \endhead
\lstinline!sample(u, clock)! &
Input argument u is a continuous-time expression according to
\cref{continuous-time-expressions}. The optional input argument clock is of type Clock, and can in a call be given as a named argument (with the name clock),
or as positional argument.
The operator
returns a clocked variable that has clock as associated clock and has the
value of the left limit of u when clock is active (that is the value of u
just before the event of c is triggered). If argument clock is not provided,
it is inferred, see \cref{sub-clock-inferencing}.
\par
\begin{nonnormative*}
Since the operator returns the left limit of u, it introduces
an infinitesimal small delay between the continuous-time and the clocked
partition. This corresponds to the reality, where a sampled data system
cannot act infinitely fast and even for a very idealized simulation, an
infinitesimal small delay is present. The consequences for the sorting
are discussed below.

Input argument u can be a general expression, because the argument
is continuous-time and therefore has always a value. It can also be a
constant, a parameter or a piecewise constant expression.

Note that \lstinline!sample! is an overloaded function: If
\lstinline!sample! has two positional input arguments and the second argument is
of type Real, it is the operator from \cref{event-related-operators-with-function-syntax}. If
\lstinline!sample! has one input argument, or it has two input
arguments and the second argument if of type Clock, it is the base-clock
conversion operator from this section.
\end{nonnormative*}
\\ \hline
\lstinline!hold(u)! &
Input argument \lstinline!u! is a clocked Component Expression (see \cref{argument-restrictions-component-expression}) or a parameter expression. The operator returns a piecewise constant
signal of the same type of \lstinline!u!. When the clock of \lstinline!u! ticks, the operator returns \lstinline!u! and otherwise returns the value of \lstinline!u! from the last clock activation.
Before the first clock activation of \lstinline!u!, the operator returns the start value of \lstinline!u!, see \cref{initialization-of-clocked-partitions}.
\par
\begin{nonnormative*}
Since the input argument is not defined before the first tick of the clock of u, the restriction is present, that it must be a Component Expression (or a parameter expression),
in order that the initial value of u can be used in such a case.
\end{nonnormative*}
\\ \hline
\end{longtable}
clocked-time representation and vice versa.

\begin{operatordefinition}[sample]
\begin{synopsis}\begin{lstlisting}
sample(u, clock)
\end{lstlisting}\end{synopsis}
\begin{semantics}
Input argument \lstinline!u! is a continuous-time expression according to \cref{continuous-time-expressions}. The optional input argument \lstinline!clock! is of type \lstinline!Clock!, and can in a call be given as a named argument (with the name \lstinline!clock!), or as positional argument. The operator returns a clocked variable that has \lstinline!clock! as associated clock and has the value of the left limit of \lstinline!u! when \lstinline!clock! is active (that is the value of \lstinline!u! just before the event of \lstinline!c! is triggered). If argument \lstinline!clock! is not provided, it is inferred, see \cref{sub-clock-inferencing}.
\begin{nonnormative}
Since the operator returns the left limit of \lstinline!u!, it introduces an infinitesimal small delay between the continuous-time and the clocked partition. This corresponds to the reality, where a sampled data system cannot act infinitely fast and even for a very idealized simulation, an infinitesimal small delay is present. The consequences for the sorting are discussed below.

Input argument \lstinline!u! can be a general expression, because the argument is continuous-time and therefore has always a value. It can also be a constant, a parameter or a piecewise constant expression.

Note that \lstinline!sample! is an overloaded function: If \lstinline!sample! has two positional input arguments and the second argument is of type \lstinline!Real!, it is the operator from \cref{event-related-operators-with-function-syntax}. If \lstinline!sample! has one input argument, or it has two input arguments and the second argument if of type \lstinline!Clock!, it is the base-clock conversion operator from this section.
\end{nonnormative}
\end{semantics}
\end{operatordefinition}

\begin{operatordefinition}[hold]
\begin{synopsis}\begin{lstlisting}
hold(u)
\end{lstlisting}\end{synopsis}
\begin{semantics}
Input argument \lstinline!u! is a clocked Component Expression (see \cref{argument-restrictions-component-expression}) or a parameter expression. The operator returns a piecewise constant signal of the same type of \lstinline!u!. When the clock of \lstinline!u! ticks, the operator returns \lstinline!u! and otherwise returns the value of \lstinline!u! from the last clock activation. Before the first clock activation of \lstinline!u!, the operator returns the start value of \lstinline!u!, see \cref{initialization-of-clocked-partitions}.
\begin{nonnormative}
Since the input argument is not defined before the first tick of the clock of \lstinline!u!, the restriction is present, that it must be a \emph{component expression} (or a parameter expression), in order that the initial value of \lstinline!u! can be used in such a case.
\end{nonnormative}
\end{semantics}
\end{operatordefinition}

\begin{example}
Assume there is the following model:
Expand Down

0 comments on commit 7c47ce9

Please sign in to comment.