/usr/share/mozart/doc/base/time.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>10.3 Time</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="loop.html#section.control.loops"><< Prev</A></TD><TD><A href="node12.html">- Up -</A></TD><TD><A href="exception.html#section.control.exceptions">Next >></A></TD></TR></TABLE><DIV id="section.control.time"><H2><A name="section.control.time">10.3 Time</A></H2><P> The module <A name="label707"></A><SPAN class="index"><CODE>Time</CODE></SPAN> contains procedures for real-time applications. </P><DL><DT><A name="label708"></A><SPAN class="index"><CODE>Alarm</CODE></SPAN> <A name="label709"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>{Time<SPAN class="keyword">.</SPAN>alarm </CODE><CODE>+<I>I</I></CODE><CODE> </CODE><CODE>?<I>U</I></CODE><CODE>}</CODE> </P></BLOCKQUOTE></DD><DD><P>returns <CODE><SPAN class="keyword">unit</SPAN></CODE> after <CODE><I>I</I></CODE> milliseconds. This is done asynchronously in that it is evaluated on its own thread. </P></DD><DT><A name="label710"></A><SPAN class="index"><CODE>Delay</CODE></SPAN> <A name="label711"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>{Time<SPAN class="keyword">.</SPAN>delay </CODE><CODE>+<I>I</I></CODE><CODE>}</CODE> </P></BLOCKQUOTE></DD><DD><P>reduces to <CODE><SPAN class="keyword">skip</SPAN></CODE> after <CODE><I>I</I></CODE> milliseconds. Whenever <CODE><I>I</I></CODE><CODE> <SPAN class="keyword">=<</SPAN> 0</CODE>, <CODE>{Delay </CODE><CODE><I>I</I></CODE><CODE>}</CODE> reduces immediately. </P></DD><DT><CODE>time</CODE> <A name="label713"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>{Time<SPAN class="keyword">.</SPAN>time </CODE><CODE>?<I>T</I></CODE><CODE>}</CODE> </P></BLOCKQUOTE></DD><DD><P>binds <CODE><I>T</I></CODE> to the number of seconds elapsed since January, 1st of the current year. </P></DD></DL><P> </P><DIV class="unnumbered"><H3><A name="label714">The Repeater Class</A></H3><P> </P><DL><DT><CODE>repeat</CODE> <A name="label716"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>Time<SPAN class="keyword">.</SPAN>repeat</CODE> </P></BLOCKQUOTE></DD><DD><P>is a class which allows to </P><UL><LI><P>repeat an action infinitely often, or a fixed number of times and perform some final action thereafter, </P></LI><LI><P>with a fixed delay between iterations (or, alternatively, a delay specified by a unary procedure), </P></LI><LI><P>stop and resume the iteration. </P></LI></UL><P> There are default values for any of the iteration parameters. These are set on creation of an object inheriting from <CODE>Time<SPAN class="keyword">.</SPAN>repeat</CODE> and can be changed by inheritance. The functionality is controlled by the following methods. </P><DL><DT><CODE>setRepAll</CODE> <A name="label717"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P></P><BLOCKQUOTE class="code"><CODE>setRepAll(action: </CODE><CODE>+<I>ActionPR</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> dummyRep<BR> final: </CODE><CODE>+<I>FinalPR</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> finalRep<BR> delay: </CODE><CODE>+<I>DelayI</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> 1000<BR> delayFun: </CODE><CODE>+<I>DelayFunP</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>} 1000 <SPAN class="keyword">end</SPAN> <BR> number: </CODE><CODE>+<I>NumI</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> <SPAN class="keyword">~</SPAN>1)</CODE></BLOCKQUOTE><P> </P></BLOCKQUOTE></DD><DD><P>initializes the loop with the action <CODE><I>ActionPR</I></CODE> to iterate (default: message <CODE>dummyRep</CODE>), the action <CODE><I>FinalPR</I></CODE> to finalize a finite iteration (default: message <CODE>finalRep</CODE>), the delay <CODE><I>DelayI</I></CODE> between iterations (default: one second), the function <CODE><I>DelayFunP</I></CODE> yielding the delay between iterations (default: constant <CODE>1000</CODE>), and the maximal number <CODE><I>NumI</I></CODE> of iterations (default: infinitely many). </P><P> The methods <CODE>dummyRep</CODE> and <CODE>finalRep</CODE> do nothing. Only one of the <CODE>delay</CODE> and <CODE>delayFun</CODE> parameters can be given. The default actions <CODE><I>ActionPR</I></CODE> and <CODE><I>FinalPR</I></CODE> can be changed by inheritance. </P><P> The loop is started on the calling thread. </P><P> For example, try the following: </P><BLOCKQUOTE class="code"><CODE><SPAN class="keyword">local</SPAN> <BR> O = {New Time<SPAN class="keyword">.</SPAN>repeat<BR> setRepAll(action: <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>} {OS<SPAN class="keyword">.</SPAN>system <SPAN class="string">'fortune'</SPAN> _} <SPAN class="keyword">end</SPAN> <BR> number: 10)}<BR><SPAN class="keyword">in</SPAN> <BR> {O go()}<BR><SPAN class="keyword">end</SPAN></CODE></BLOCKQUOTE><P> </P></DD><DT><CODE>getRep</CODE> <A name="label718"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P></P><BLOCKQUOTE class="code"><CODE>getRep(action: </CODE><CODE>?<I>ActionPR</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> _<BR> final: </CODE><CODE>?<I>FinalPR</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> _<BR> delay: </CODE><CODE>?<I>DelayI</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> _<BR> delayFun: </CODE><CODE>?<I>DelayFunP</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> _<BR> number: </CODE><CODE>?<I>LimitI</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> _<BR> actual: </CODE><CODE>?<I>NumI</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> _)</CODE></BLOCKQUOTE><P> </P></BLOCKQUOTE></DD><DD><P>returns the current loop parameters: <CODE><I>LimitI</I></CODE> returns the current limit of the iteration, and <CODE><I>NumI</I></CODE> the number of iterations left to be done. If the delay was specified via <CODE><I>DelayFunP</I></CODE> (which need not be constant), then <CODE><I>DelayI</I></CODE> returns the <EM>last</EM> delay used. If <CODE><I>DelayI</I></CODE> is requested before the start of the iteration, then <CODE><SPAN class="keyword">~</SPAN>1</CODE> is returned. The other values correspond to the fields of the method <CODE>setRepAll</CODE>. </P><P> For example try: </P><BLOCKQUOTE class="code"><CODE><SPAN class="keyword">local</SPAN> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Counter</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> Time.repeat</SPAN> <BR> <SPAN class="keyword">attr</SPAN> a: 0<BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">inc</SPAN>() a <SPAN class="keyword">:=</SPAN> <SPAN class="keyword">@</SPAN>a <SPAN class="keyword">+</SPAN> 1 <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">get</SPAN>(?A) A = <SPAN class="keyword">@</SPAN>a <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">finalRep</SPAN>() a <SPAN class="keyword">:=</SPAN> 0 <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> C = {New Counter setRepAll(action: inc number: 1000)}<BR><SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">thread</SPAN> {C go()} <SPAN class="keyword">end</SPAN> <BR> {C getRep(final: {Browse}<BR> action: {Browse}<BR> actual: {Browse})}<BR> {C get({Browse})}<BR><SPAN class="keyword">end</SPAN></CODE></BLOCKQUOTE><P> This will show the atoms <CODE><SPAN class="string">'finalRep'</SPAN></CODE> and <CODE><SPAN class="string">'inc'</SPAN></CODE> in the Browser, as well as a number between <CODE>1</CODE> and <CODE>1000</CODE>. After termination of the loop, the value of <CODE><SPAN class="keyword">@</SPAN>a</CODE> will be reset to <CODE>0</CODE>. </P></DD><DT><CODE>setRepDelay</CODE> <A name="label719"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>setRepDelay(</CODE><CODE>+<I>DelayI</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> 1000}</CODE> </P></BLOCKQUOTE></DD><DT><CODE>setRepNum</CODE> <A name="label720"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>setRepNum(</CODE><CODE>+<I>NumI</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> <SPAN class="keyword">~</SPAN>1)}</CODE> </P></BLOCKQUOTE></DD><DT><CODE>setRepAction</CODE> <A name="label721"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>setRepAction(</CODE><CODE>+<I>ActionPR</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> dummyRep)</CODE> </P></BLOCKQUOTE></DD><DT><CODE>setRepFinal</CODE> <A name="label722"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>setRepFinal(</CODE><CODE>+<I>FinalPR</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> finalRep)}</CODE> </P></BLOCKQUOTE></DD><DT><CODE>setRepDelayFun</CODE> <A name="label723"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>setRepDelayFun(</CODE><CODE>+<I>DelayFunP</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>} 1000 <SPAN class="keyword">end</SPAN>)</CODE> </P></BLOCKQUOTE></DD><DD><P>allow to set the numeric parameters of the iteration. </P><P> <CODE><I>DelayI</I></CODE> and <CODE><I>NumI</I></CODE> must be integers. The iteration limit <CODE><I>NumI</I></CODE> is stored and subsequent loop instances (triggered by <CODE>go</CODE>) also obey it, unless the limit is reset to <CODE><SPAN class="keyword">~</SPAN>1</CODE>. </P><P> <CODE><I>ActionPR</I></CODE> and <CODE><I>FinalPR</I></CODE> may be nullary procedures or records. If they are procedures they are called as is. If they are records, they are interpreted as messages to be sent to <CODE><SPAN class="keyword">self</SPAN></CODE>. </P><P> <CODE><I>DelayFunP</I></CODE> must be a unary procedure which returns an integer value on application. </P></DD><DT><CODE>go</CODE> <A name="label724"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>go()</CODE> </P></BLOCKQUOTE></DD><DD><P>starts the loop if it is not currently running. </P></DD><DT><CODE>stop</CODE> <A name="label725"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>stop()</CODE> </P></BLOCKQUOTE></DD><DD><P>halts the loop and resets the iteration index. The loop may be restarted with <CODE>go</CODE>. </P></DD></DL><P> </P></DD></DL><P> </P></DIV></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="loop.html#section.control.loops"><< Prev</A></TD><TD><A href="node12.html">- Up -</A></TD><TD><A href="exception.html#section.control.exceptions">Next >></A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~duchier/">Denys Duchier</A>, <A href="http://www.ps.uni-sb.de/~kornstae/">Leif Kornstaedt</A> and <A href="http://www.ps.uni-sb.de/~schulte/">Christian Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|