From d7ada660aad982653cd15a602ccecb795bf51e66 Mon Sep 17 00:00:00 2001 From: HOS Date: Tue, 30 Sep 2025 16:42:29 +0200 Subject: [PATCH 1/4] Make real interval clock similar to rational interval clock. In particular continue example. --- chapters/synchronous.tex | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/chapters/synchronous.tex b/chapters/synchronous.tex index 5ac54c91c..4eb1d6956 100644 --- a/chapters/synchronous.tex +++ b/chapters/synchronous.tex @@ -388,17 +388,29 @@ \section{Clock Constructors}\label{clock-constructors} The $\mathit{interval}$ must be strictly positive ($\mathit{interval} > 0$) of type \lstinline!Real! with \lstinline!unit = "s"!. The result is of base type \lstinline!Clock! that ticks when \lstinline!time! becomes $t_{\mathrm{start}}$, $t_{\mathrm{start}} + \mathit{interval}_{1}$, $t_{\mathit{start}} + \mathit{interval}_{1} + \mathit{interval}_{2}$, \@\ldots{} The clock starts at the start of the simulation $t_{\mathrm{start}}$ or when the controller is switched on. -Here the next clock tick is scheduled at $\mathit{interval}_{1}$ = \lstinline!previous($\mathit{interval}$)! = \lstinline!$\mathit{interval}$.start!. -At the second clock tick at time $t_{\mathrm{start}} + \mathit{interval}_{1}$, the next clock tick is scheduled at $\mathit{interval}_{2}$ = \lstinline!previous($\mathit{interval}$)!, and so on. +Here the next clock tick is scheduled at $\mathit{interval}_{1}$ = \lstinline!$\mathit{interval}$!. +At the second clock tick at time $t_{\mathrm{start}} + \mathit{interval}_{1}$, the next clock tick is scheduled at $\mathit{interval}_{2}$ = \lstinline!$\mathit{interval}$!, and so on. If $\mathit{interval}$ is a parameter expression, the clock defines a periodic clock. \begin{nonnormative} -Note, the clock is defined with \lstinline!previous($\mathit{interval}$)!. -Therefore, for sorting the input argument is treated as known. The given interval and time shift can be modified by using the \lstinline!subSample!, \lstinline!superSample!, \lstinline!shiftSample! and \lstinline!backSample! operators on the returned clock, see \cref{sub-clock-conversion-operators}. There are restrictions where this operator can be used, see \lstinline!Clock! expressions below. Note that $\mathit{interval}$ does not have to an evaluable expression, since different real interval clocks are never compared. \end{nonnormative} + +\begin{example} +\begin{lstlisting}[language=modelica] + // first clock tick: previous(realNextInterval) = 0.002 + Real realNextInterval(start = 0.002); + Real y3(start = 0); +equation + when Clock(realNextInterval) then + // interval clock that ticks at 0, 0.003, 0.007, 0.012, $\ldots$ + realNextInterval = previous(realNextInterval) + 1e-3; + y3 = previous(y3) + 1; + end when; +\end{lstlisting} +\end{example} \end{semantics} \end{operatordefinition*} From 3bbc9b2ce198a7df7c0f30a8fe1ac63eb434dfb2 Mon Sep 17 00:00:00 2001 From: Hans Olsson Date: Fri, 3 Oct 2025 11:07:37 +0200 Subject: [PATCH 2/4] Update chapters/synchronous.tex Co-authored-by: Henrik Tidefelt --- chapters/synchronous.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/synchronous.tex b/chapters/synchronous.tex index 4eb1d6956..3a04b1353 100644 --- a/chapters/synchronous.tex +++ b/chapters/synchronous.tex @@ -405,7 +405,7 @@ \section{Clock Constructors}\label{clock-constructors} Real y3(start = 0); equation when Clock(realNextInterval) then - // interval clock that ticks at 0, 0.003, 0.007, 0.012, $\ldots$ + // Real interval clock that ticks at 0, 0.003, 0.007, 0.012, $\ldots$ realNextInterval = previous(realNextInterval) + 1e-3; y3 = previous(y3) + 1; end when; From 8307d44d84d00237ddf92a77e822756dde8c27d6 Mon Sep 17 00:00:00 2001 From: HOS Date: Fri, 3 Oct 2025 17:08:44 +0200 Subject: [PATCH 3/4] BasedOnFeedback --- chapters/synchronous.tex | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/chapters/synchronous.tex b/chapters/synchronous.tex index 3a04b1353..c4e958d0f 100644 --- a/chapters/synchronous.tex +++ b/chapters/synchronous.tex @@ -355,8 +355,8 @@ \section{Clock Constructors}\label{clock-constructors} \begin{example} \begin{lstlisting}[language=modelica] - // first clock tick: previous(nextInterval) = 2 - Integer nextInterval(start = 2); + // first clock tick: previous(intervalCounter) = 2 + Integer intervalCounter(start = 2); Real y1(start = 0); Real y2(start = 0); equation @@ -365,15 +365,15 @@ \section{Clock Constructors}\label{clock-constructors} y1 = previous(y1) + 1; end when; - when Clock(nextInterval, 1000) then + when Clock(intervalCounter, 1000) then // interval clock that ticks at 0, 0.003, 0.007, 0.012, $\ldots$ - nextInterval = previous(nextInterval) + 1; + intervalCounter = previous(intervalCounter) + 1; y2 = previous(y2) + 1; end when; \end{lstlisting} \end{example} -Note that operator \lstinline!interval(c)! of \lstinline!Clock c = Clock(nextInterval, $\mathit{resolution}$)! returns:\newline +Note that operator \lstinline!interval(c)! of \lstinline!Clock c = Clock(intervalCounter, $\mathit{resolution}$)! returns:\newline \lstinline!previous($\mathit{intervalCounter}$) / $\mathit{resolution}$! (in seconds) \end{semantics} \end{operatordefinition*} @@ -400,14 +400,14 @@ \section{Clock Constructors}\label{clock-constructors} \begin{example} \begin{lstlisting}[language=modelica] - // first clock tick: previous(realNextInterval) = 0.002 - Real realNextInterval(start = 0.002); - Real y3(start = 0); + // first clock tick: previous(nextInterval) = 0.002 + Real nextInterval(start = 0.002); + Real y(start = 0); equation - when Clock(realNextInterval) then + when Clock(nextInterval) then // Real interval clock that ticks at 0, 0.003, 0.007, 0.012, $\ldots$ - realNextInterval = previous(realNextInterval) + 1e-3; - y3 = previous(y3) + 1; + nextInterval = previous(nextInterval) + 1e-3; + y = previous(y) + 1; end when; \end{lstlisting} \end{example} From 35f9675f8a599d487c4e77cf56e0ef76f3ae1ac7 Mon Sep 17 00:00:00 2001 From: Hans Olsson Date: Fri, 17 Oct 2025 16:51:58 +0200 Subject: [PATCH 4/4] Update chapters/synchronous.tex Co-authored-by: Henrik Tidefelt --- chapters/synchronous.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/synchronous.tex b/chapters/synchronous.tex index c4e958d0f..31e830c8d 100644 --- a/chapters/synchronous.tex +++ b/chapters/synchronous.tex @@ -389,7 +389,7 @@ \section{Clock Constructors}\label{clock-constructors} The result is of base type \lstinline!Clock! that ticks when \lstinline!time! becomes $t_{\mathrm{start}}$, $t_{\mathrm{start}} + \mathit{interval}_{1}$, $t_{\mathit{start}} + \mathit{interval}_{1} + \mathit{interval}_{2}$, \@\ldots{} The clock starts at the start of the simulation $t_{\mathrm{start}}$ or when the controller is switched on. Here the next clock tick is scheduled at $\mathit{interval}_{1}$ = \lstinline!$\mathit{interval}$!. -At the second clock tick at time $t_{\mathrm{start}} + \mathit{interval}_{1}$, the next clock tick is scheduled at $\mathit{interval}_{2}$ = \lstinline!$\mathit{interval}$!, and so on. +At the second clock tick at time $t_{\mathrm{start}} + \mathit{interval}_{1}$, the next clock tick is scheduled $\mathit{interval}_{2}$ = \lstinline!$\mathit{interval}$! into the future, and so on. If $\mathit{interval}$ is a parameter expression, the clock defines a periodic clock. \begin{nonnormative}