[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] SF.net SVN: quarks:[2664] DayTimer



Revision: 2664
          http://sourceforge.net/p/quarks/code/2664
Author:   decampo
Date:     2013-12-19 22:55:25 +0000 (Thu, 19 Dec 2013)
Log Message:
-----------
convert to schelp.

Added Paths:
-----------
    DayTimer/HelpSource/
    DayTimer/HelpSource/Classes/
    DayTimer/HelpSource/Classes/DayTimer.schelp

Removed Paths:
-------------
    DayTimer/DayTimer.html

Deleted: DayTimer/DayTimer.html
===================================================================
--- DayTimer/DayTimer.html	2013-12-13 23:44:59 UTC (rev 2663)
+++ DayTimer/DayTimer.html	2013-12-19 22:55:25 UTC (rev 2664)
@@ -1,120 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd";>
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<meta http-equiv="Content-Style-Type" content="text/css">
-<title></title>
-<meta name="Generator" content="Cocoa HTML Writer">
-<meta name="CocoaVersion" content="949.35">
-<style type="text/css">
-p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}
-p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px}
-p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #001db9}
-p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica; min-height: 16.0px}
-p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #961e1e}
-p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #001db9; min-height: 14.0px}
-p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #6c2a2a}
-p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #0a2cb0; min-height: 14.0px}
-p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #0014bc}
-p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco}
-p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #a91616}
-p.p12 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #606060}
-span.s1 {font: 19.0px Helvetica}
-span.s2 {font: 10.0px Monaco}
-span.s3 {color: #000000}
-span.s4 {color: #426f0e}
-span.s5 {color: #001db9}
-span.s6 {font: 13.0px Helvetica; color: #000000}
-span.s7 {color: #307109}
-span.s8 {color: #0a2cb0}
-span.s9 {color: #5a6a1b}
-span.s10 {color: #606060}
-span.s11 {color: #0014bc}
-span.Apple-tab-span {white-space:pre}
-</style>
-</head>
-<body>
-<p class="p1"><span class="s1"><b>DayTimer</b></span><span class="s2"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span><b>make things happen at specific times of the day/hour/minute</b></p>
-<p class="p2"><br></p>
-<p class="p2"><br></p>
-<p class="p1"><b>class methods</b></p>
-<p class="p2"><br></p>
-<p class="p1"><b>*new(name, id, test, func);</b></p>
-<p class="p1"><span class="Apple-tab-span">	</span>access or make a new DayTimer for the given name;</p>
-<p class="p1"><span class="Apple-tab-span">	</span>optionally give it an id underwhich to store a daytime task.</p>
-<p class="p2"><br></p>
-<p class="p3">DayTimer<span class="s3">(</span><span class="s4">\otto</span><span class="s3">);</span></p>
-<p class="p4"><br></p>
-<p class="p1"><b>*all</b></p>
-<p class="p5"><span class="s5">DayTimer</span><span class="s3">.all;<span class="Apple-tab-span">	</span></span>// all daytimers are stored here.</p>
-<p class="p6"><br></p>
-<p class="p1"><b>*top<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></b>// top is a class variable; this daytimer is for general tasks.</p>
-<p class="p1"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>// for only one global control of daytime-bound tasks, this is simplest.</p>
-<p class="p1"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>// when one wants to turn groups of date/tasks on and off,</p>
-<p class="p1"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>// it is easiest to put them in separate named daytimers.</p>
-<p class="p3">DayTimer<span class="s3">.top;<span class="Apple-tab-span">	</span></span></p>
-<p class="p4"><br></p>
-<p class="p1"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>// many class methods are redirected as instance methods to DayTimer.top;</p>
-<p class="p1"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>// for details, see below.</p>
-<p class="p7"><span class="s6"><b>*start</b></span><span class="s3"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>// actually does DayTimer.top.start;</p>
-<p class="p1"><b>*stop</b><span class="s2"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span></p>
-<p class="p7"><span class="s6"><b>*putDate(id, test, func)<span class="Apple-tab-span">	</span></b></span><span class="s3"><span class="Apple-tab-span">	</span></span>// add a task to DayTimer.top.</p>
-<p class="p7"><span class="s6"><b>*removeAt(key)</b></span><span class="s3"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>// remove a task from DayTimer.top</p>
-<p class="p8"><br></p>
-<p class="p8"><br></p>
-<p class="p8"><br></p>
-<p class="p8"><br></p>
-<p class="p8"><br></p>
-<p class="p1"><b>instance methods:</b></p>
-<p class="p8"><br></p>
-<p class="p9"><span class="s3">d = </span>DayTimer<span class="s3">(</span><span class="s7">\otto</span><span class="s3">);</span></p>
-<p class="p2"><br></p>
-<p class="p1"><b>stop, start</b></p>
-<p class="p10">d.stop;<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>// stop watching for dates</p>
-<p class="p10">d.start;<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>// start watching for dates</p>
-<p class="p4"><br></p>
-<p class="p1"><b>putDate(id, test, func);</b></p>
-<p class="p1"><span class="Apple-tab-span">	</span>put in a date with a task:</p>
-<p class="p1"><span class="Apple-tab-span">	</span>id is a symbol (used for ID when removing or overwriting a date),</p>
-<p class="p1"><span class="Apple-tab-span">	</span>test is either a time in [&lt;hour&gt;, &lt;min&gt;, &lt;sec&gt;],</p>
-<p class="p1"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>or a function that tests a date object with the time now (Date.getDate).</p>
-<p class="p1"><span class="Apple-tab-span">	</span>func is the task to do when test == true.</p>
-<p class="p2"><span class="Apple-tab-span">	</span></p>
-<p class="p7"><span class="s3"><span class="Apple-tab-span">	</span></span>// do this every full minute - id so you can remove it again</p>
-<p class="p10"><span class="s8">d</span>.putDate(<span class="s9">\perMin</span>, { <span class="s8">|date|</span> <span class="s8">date</span>.second == 0 }, { <span class="s10">"full minute!"</span>.postln });</p>
-<p class="p2"><br></p>
-<p class="p7"><span class="s3"><span class="Apple-tab-span">	</span></span>// do this every minute at seconds 25 and 35</p>
-<p class="p10"><span class="s8">d</span>.putDate(<span class="s9">\min2</span>, { <span class="s8">|date|</span> [25, 35].includes(<span class="s8">date</span>.second) }, { <span class="s10">"twice a min"</span>.postln });</p>
-<p class="p2"><br></p>
-<p class="p2"><br></p>
-<p class="p11"><span class="s3">(<span class="Apple-tab-span">	</span></span>// do this every third minute</p>
-<p class="p10"><span class="s11">d</span>.putDate(<span class="s7">\min3</span>,</p>
-<p class="p10"><span class="Apple-tab-span">	</span>{ <span class="s11">|date|</span> (date.minute * 60 + date.second) % 180 == 60 },</p>
-<p class="p12"><span class="s3"><span class="Apple-tab-span">	</span>{ </span>"every 3 minutes"<span class="s3">.postln });</span></p>
-<p class="p10">)</p>
-<p class="p2"><br></p>
-<p class="p7"><span class="s3"><span class="Apple-tab-span">	</span></span>// once a day at a specific time [h, m, s] -</p>
-<p class="p7"><span class="Apple-tab-span">	</span>// maybe set this to the next full minute for testing</p>
-<p class="p10"><span class="s8">d</span>.putDate(<span class="s9">\onceT</span>, [12, 35, 40], { <span class="s10">"once a day only!"</span>.postln } );</p>
-<p class="p2"><br></p>
-<p class="p2"><br></p>
-<p class="p7"><span class="s3"><span class="Apple-tab-span">	</span></span>// daytimer tests and posts when a function fails,</p>
-<p class="p7"><span class="Apple-tab-span">	</span>// but continues watching.</p>
-<p class="p10"><span class="s8">d</span>.putDate(<span class="s9">\failZ</span>, { <span class="s8">|d|</span> [20, 40].includes(d.second) }, { 1.blork });</p>
-<p class="p2"><br></p>
-<p class="p1"><b>removeAt(id);</b></p>
-<p class="p7"><span class="s3"><span class="Apple-tab-span">	</span></span>// remove a date, here the failing date/task</p>
-<p class="p10"><span class="s8">d</span>.removeAt(<span class="s9">\failZ</span>);</p>
-<p class="p2"><br></p>
-<p class="p1"><b>dates</b></p>
-<p class="p7"><span class="s3"><span class="Apple-tab-span">	</span></span>// show all dates</p>
-<p class="p10"><span class="s8">DayTimer</span>.top.dates.postcs;</p>
-<p class="p10">d.dates.postcs;</p>
-<p class="p2"><br></p>
-<p class="p1"><b>skip</b></p>
-<p class="p10">d.skip;<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>// the skipjack that does the watching</p>
-<p class="p2"><br></p>
-<p class="p1"><b>name<span class="Apple-tab-span">	</span></b></p>
-<p class="p10">d.name;<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>// the daytimer's name</p>
-</body>
-</html>

Added: DayTimer/HelpSource/Classes/DayTimer.schelp
===================================================================
--- DayTimer/HelpSource/Classes/DayTimer.schelp	                        (rev 0)
+++ DayTimer/HelpSource/Classes/DayTimer.schelp	2013-12-19 22:55:25 UTC (rev 2664)
@@ -0,0 +1,181 @@
+TITLE:: DayTimer
+summary:: make actions happen at specific times of the day - hour/minute/second
+categories:: Utilities
+related:: SkipJack
+
+DESCRIPTION::
+DayTimer allows scheduling actions to happen at specific times of day. This can be useful for installations that run unattended in museum or gallery situations. A DayTimer is stored by name, and can keep multiple actions to run at different times of day.
+There is a global DayTimer instance which may suffice for simple uses.
+
+code::
+
+// Use the global top DayTimer
+// put an action in - at every full 10 seconds, post.
+DayTimer.putDate(\ten, { |date| date.second % 10 == 0 }, { "10 sec.".postln });
+
+DayTimer.start; // now do it.
+// post every three seconds
+DayTimer.putDate(\three, { |date| date.second % 3 == 0 }, { "3 sec.".postln });
+// remove
+DayTimer.removeAt(\ten);
+DayTimer.putDate(\two, { |date| date.second % 2 == 0 }, { "2 sec.".postln });
+DayTimer.removeAt(\three);
+
+DayTimer.stop;
+
+// Make a daytimer and use it
+d = DayTimer(\otto);
+d.start;
+	// do this every full minute - id so you can remove it again
+d.putDate(\perMin, { |date| date.second == 0 }, { "full minute!".postln });
+
+	// do this every minute at seconds 25 and 35
+d.putDate(\min2, { |date| [25, 35].includes(date.second) }, { "twice a min".postln });
+    // once a day at a specific time [h, m, s] -
+d.putDate(\onceT, [12, 35, 40], { "once a day only!".postln } );
+
+d.stop;
+::
+
+CLASSMETHODS::
+
+METHOD:: all
+a global dictionary where all DayTimers are stored.
+
+METHOD:: at
+look up a DayTimer in DayTimer.all by name.
+
+
+METHOD:: top
+A global instance of DayTimer provided for convenience.
+
+METHOD:: putDate
+add an action at <id> to the top DayTimer dates.
+
+ARGUMENT:: id
+a symbol for the action to add to it.
+
+ARGUMENT:: test
+a test whether to do the action at the current date/time.
+can be a function that looks at current date, or a list of
+[hour, minute, second] values.
+
+ARGUMENT:: func
+the action to do when the time is right (test is true)
+
+METHOD:: removeAt
+remove the action at <id> in the top DayTimer.
+
+METHOD:: start
+start the top DayTimer.
+
+METHOD:: stop
+stop the top DayTimer.
+
+
+METHOD:: new
+store a new DayTimer or access an existing instance at the given name;
+optionally give it an id, a test whether the time of day is right, and the corresponding action.
+
+ARGUMENT:: name
+a symbol for the DayTimer instance name.
+
+ARGUMENT:: id
+a symbol for the action to add to it.
+
+ARGUMENT:: test
+a test whether to do the action at the current date/time.
+can be a function that looks at current date, or a list of
+[hour, minute, second] values.
+
+ARGUMENT:: func
+the action to do when the time is right (test is true)
+
+returns:: A new or existing DayTimer.
+
+
+
+
+INSTANCEMETHODS::
+
+METHOD:: name
+get the DayTimer name
+
+returns:: a Symbol
+
+METHOD:: dates
+a dict of the named actions to do
+
+METHOD:: putDate
+add an action at <id> to the DayTimer dates.
+
+ARGUMENT:: id
+a symbol for the action to add to it.
+
+ARGUMENT:: test
+a test whether to do the action at the current date/time.
+can be a function that looks at current date, or a list of
+[hour, minute, second] values.
+
+ARGUMENT:: func
+the action to do when the time is right (test is true)
+
+METHOD:: removeAt
+remove an action from dates by id
+
+ARGUMENT:: id
+
+METHOD:: start
+start the DayTimer.
+
+METHOD:: stop
+stop the DayTimer.
+
+
+METHOD:: skip
+internal - a SkipJack that runs when DayTimer is active.
+
+METHOD:: checkList
+internal - checks which time tests for actions match the current time,
+and performs the actions if any.
+
+EXAMPLES::
+
+code::
+d = DayTimer(\otto);
+d.name;
+d.skip;		// the skipjack that does the watching
+d.dates;
+
+	// do this every full minute - id so you can remove it again
+d.putDate(\perMin, { |date| date.second == 0 }, { "full minute!".postln });
+
+	// do this every minute at seconds 25 and 35
+d.putDate(\min2, { |date| [25, 35].includes(date.second) }, { "twice a min".postln });
+
+d.dates;
+
+(	// do this every third minute
+d.putDate(\min3,
+	{ |date| (date.minute * 60 + date.second) % 180 == 60 },
+	{ "every 3 minutes".postln });
+)
+
+d.start;
+
+	// once a day at a specific time [h, m, s] -
+	// maybe set this to the next full minute for testing
+d.putDate(\onceT, [12, 35, 40], { "once a day only!".postln } );
+
+
+	// daytimer tests and posts when a function fails,
+	// but continues watching.
+d.putDate(\failZ, { |d| [20, 40].includes(d.second) }, { 1.blork });
+
+	// remove a date, here the failing date/task
+d.removeAt(\failZ);
+
+d.dates.postcs;
+
+d.stop;
+::
\ No newline at end of file

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


_______________________________________________
sc-dev mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-dev/
search: https://listarc.bham.ac.uk/lists/sc-dev/search/