<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>Branch Conditionally</title>
	<atom:link href="http://www.djshaw.ca/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.djshaw.ca/blog</link>
	<description>Addressing Capabilities</description>
	<pubDate>Fri, 26 Jun 2009 00:59:18 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>man rtfm</title>
		<link>http://www.djshaw.ca/blog/?p=312</link>
		<comments>http://www.djshaw.ca/blog/?p=312#comments</comments>
		<pubDate>Wed, 22 Apr 2009 15:09:04 +0000</pubDate>
		<dc:creator>Derek Shaw</dc:creator>
		
		<category><![CDATA[Opcodes (misc)]]></category>

		<guid isPermaLink="false">http://www.djshaw.ca/blog/?p=312</guid>
		<description><![CDATA[Waterloo actually has a manual entry for RTFM!

djshaw@cpu22:~$ man rtfm
RTFM(I)&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;UW Information&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;RTFM(I)
Name:
&#160;&#160;&#160;&#160;&#160;rtfm - Read The Famous Manual
Description:
&#160;&#160;&#160;&#160;&#160;You might see the expression &#8220;RTFM&#8221; in response to a ques-
&#160;&#160;&#160;&#160;&#160;tion or a gripe.
&#160;&#160;&#160;&#160;&#160;This means that whatever you asked or complained about is
&#160;&#160;&#160;&#160;&#160;already documented in the man page.  It usually is intended
&#160;&#160;&#160;&#160;&#160;to indicate that you should have read the [...]]]></description>
			<content:encoded><![CDATA[<p>Waterloo actually has a manual entry for RTFM!</p>
<blockquote><p>
djshaw@cpu22:~$ man rtfm</p>
<p>RTFM(I)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UW Information&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RTFM(I)</p>
<p>Name:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rtfm - Read The Famous Manual</p>
<p>Description:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;You might see the expression &#8220;RTFM&#8221; in response to a ques-<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tion or a gripe.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This means that whatever you asked or complained about is<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;already documented in the man page.  It usually is intended<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to indicate that you should have read the appropriate manual<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;before bothering, and wasting the time of, the person using<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the expression.</p>
<p>See Also:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;man(1), gripe(1), consultant(I), operations(I)</p>
<p>Bugs:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The &#8220;F&#8221; doesn&#8217;t really stand for &#8220;Famous&#8221;.</p>
<p>Copyright:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(c) 1986, MFCF, University of Waterloo.</p>
<p>Formatted 87/05/05&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UW&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1
</p></blockquote>
<p>Unfortunately, Waterloo does not have a manual entry for woman.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djshaw.ca/blog/?feed=rss2&amp;p=312</wfw:commentRss>
		</item>
		<item>
		<title>How Much Time Have You Spent Listening To Music?</title>
		<link>http://www.djshaw.ca/blog/?p=308</link>
		<comments>http://www.djshaw.ca/blog/?p=308#comments</comments>
		<pubDate>Fri, 10 Apr 2009 19:46:07 +0000</pubDate>
		<dc:creator>Derek Shaw</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.djshaw.ca/blog/?p=308</guid>
		<description><![CDATA[I am procrastinating; I do not want to write my work term report. I started to wonder how long iTunes has been playing music for.  I wanted to use python to do the calculation. Unfortunately, the Cygwin version of python does not come with the win32 extension binaries, so I had to use Java. Luckily, [...]]]></description>
			<content:encoded><![CDATA[<p>I am procrastinating; I do not want to write my work term report. I started to wonder how long iTunes has been playing music for.  I wanted to use python to do the calculation. Unfortunately, the Cygwin version of python does not come with the win32 extension binaries, so I had to use Java. Luckily, someone has created a <a href="http://dot-totally.co.uk/software/itunescon/">jar</a> to do all the heavy lifting for me.</p>
<p><code><br />
import com.dt.iTunesController.*;<br />
import java.math.BigInteger;</p>
<p>class Main<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;public static void main (String[] args)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iTunes itc = new iTunes();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ITTrack itt = itc.getCurrentTrack();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ITPlaylist playlist = itc.getLibraryPlaylist ();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ITTrackCollection tracks = playlist.getTracks ();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int sum = 0;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (int i = 1; i <= tracks.getCount (); i += 1)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ITTrack track = tracks.getItem (i);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sum += track.getPlayedCount () * track.getDuration ();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int seconds = sum % 60;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sum /= 60;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int minutes = sum % 60;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sum /= 60;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int hours = sum;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println (hours + ":" + minutes + ":" + seconds);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
</code></p>
<p>I have listed to 868 hours, 18 minutes, and 40 seconds of music.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djshaw.ca/blog/?feed=rss2&amp;p=308</wfw:commentRss>
		</item>
		<item>
		<title>R Brothers</title>
		<link>http://www.djshaw.ca/blog/?p=305</link>
		<comments>http://www.djshaw.ca/blog/?p=305#comments</comments>
		<pubDate>Tue, 31 Mar 2009 20:58:12 +0000</pubDate>
		<dc:creator>Derek Shaw</dc:creator>
		
		<category><![CDATA[Opcodes (misc)]]></category>

		<guid isPermaLink="false">http://www.djshaw.ca/blog/?p=305</guid>
		<description><![CDATA[I got an interesting email yesterday. Someone from &#8220;R Brothers Concrete, Inc&#8221; thought that I was this &#8220;Derek Shaw&#8221; character. While it is true that I am indeed a &#8220;Derek Shaw&#8221;, I am not the Derek Shaw they were looking for. At first, I thought that the email was spam, but the inclusion of a [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-large wp-image-304" title="Other Derek Shaw" src="http://www.djshaw.ca/blog/wp-content/uploads/2009/03/dj-791x1024.jpg" border="1" alt="Other Derek Shaw" width="398" height="515" />I got an interesting email yesterday. Someone from &#8220;R Brothers Concrete, Inc&#8221; thought that I was this &#8220;Derek Shaw&#8221; character. While it is true that I am indeed a &#8220;Derek Shaw&#8221;, I am not the Derek Shaw they were looking for. At first, I thought that the email was spam, but the inclusion of a telephone and fax number made be curious. 2150 Elkins Way is a real location, so I decided to call and see if they were legit. I called late last night, after 6:00pm California time; a machine picked up, and identified itself as R Brothers Concrete.</p>
<p>I called R Brothers earlier today. A secretary connected me with accounting. As soon as I identified myself as Derek Shaw, the man on the other end recognized the name and started to describe the state of the project. Interrupting him I told him that I was Derek Shaw, but not the one he thought I was. I could hear the confusion. It took a few minutes, but I eventually convinced him that there were more than one Derek Shaws in North America. Personally, I was supprised that this is not spam.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djshaw.ca/blog/?feed=rss2&amp;p=305</wfw:commentRss>
		</item>
		<item>
		<title>Prevent the school&#8217;s imacs from auto logout</title>
		<link>http://www.djshaw.ca/blog/?p=303</link>
		<comments>http://www.djshaw.ca/blog/?p=303#comments</comments>
		<pubDate>Wed, 28 Jan 2009 14:58:02 +0000</pubDate>
		<dc:creator>Derek Shaw</dc:creator>
		
		<category><![CDATA[SE 2010]]></category>

		<guid isPermaLink="false">http://www.djshaw.ca/blog/?p=303</guid>
		<description><![CDATA[After about 90 minutes of inactivity, Waterloo&#8217;s imacs will automatically log out the inactive user. I have my own office in Waterloo, complete with imac. The auto log out behavior is rather annoying, I like to log in once and then not think about it again. A visible messagebox will prevent the auto logoff process. [...]]]></description>
			<content:encoded><![CDATA[<p>After about 90 minutes of inactivity, Waterloo&#8217;s imacs will automatically log out the inactive user. I have my own office in Waterloo, complete with imac. The auto log out behavior is rather annoying, I like to log in once and then not think about it again. A visible messagebox will prevent the auto logoff process. To prevent the auto logoff, open Firefox and enter <code>javascript:alert('');</code> into the address bar (and hit enter). This should open a message box, preventing logoff; do not close this message box until you plan on resuming work.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djshaw.ca/blog/?feed=rss2&amp;p=303</wfw:commentRss>
		</item>
		<item>
		<title>Gnu tools on Waterloo&#8217;s student.cs environment</title>
		<link>http://www.djshaw.ca/blog/?p=302</link>
		<comments>http://www.djshaw.ca/blog/?p=302#comments</comments>
		<pubDate>Fri, 23 Jan 2009 17:09:53 +0000</pubDate>
		<dc:creator>Derek Shaw</dc:creator>
		
		<category><![CDATA[SE 2010]]></category>

		<guid isPermaLink="false">http://www.djshaw.ca/blog/?p=302</guid>
		<description><![CDATA[I like my gnu coreutils. Unfortunately, Waterloo is running Solaris 5 with some old coreutils binaries. Fortunately, someone in IST has put some of the coreutils on student.cs. You can use showpath to get the gnu coreutils in your path.
To get gnu&#8217;s core utils in your path, add the following to your .bashrc file:

if [ [...]]]></description>
			<content:encoded><![CDATA[<p>I like my gnu coreutils. Unfortunately, Waterloo is running Solaris 5 with some old coreutils binaries. Fortunately, someone in IST has put some of the coreutils on student.cs. You can use <code>showpath</code> to get the gnu coreutils in your path.</p>
<p>To get gnu&#8217;s core utils in your path, add the following to your <code>.bashrc</code> file:</p>
<pre><code>
if [ `uname -s` = "Linux" ]; then
        PATH=$PATH:~/bin

        alias ll='ls -l --color=auto'
        alias dir='ls -ba --color=auto'
        alias lla='ls -la --color=auto'
        alias ls='ls --color=auto'
elif [ `uname -s` = "SunOS" ]; then
        PATH=`/bin/showpath gnu current standard man $HOME/bin`

        alias ll='ls -l --color=auto'
        alias dir='ls -ba --color=auto'
        alias lla='ls -la --color=auto'
        alias ls='ls --color=auto'
elif [ `uname -s` = "Darwin" ]; then
        alias ll='ls -lG'
        alias dir='ls -baG'
        alias lla='ls -laG'
        alias ls='ls -G'
else
        PATH=`/bin/showpath current standard man $HOME/bin`
        alias ll='ls -l'
        alias dir='ls -ba'
        alias lla='ls -la'
fi

</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.djshaw.ca/blog/?feed=rss2&amp;p=302</wfw:commentRss>
		</item>
		<item>
		<title>Automating Ihcp1d</title>
		<link>http://www.djshaw.ca/blog/?p=301</link>
		<comments>http://www.djshaw.ca/blog/?p=301#comments</comments>
		<pubDate>Fri, 02 Jan 2009 22:48:19 +0000</pubDate>
		<dc:creator>Derek Shaw</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.djshaw.ca/blog/?p=301</guid>
		<description><![CDATA[Back when I was in high school, I took a coop job with Prof. Beth Weckman in the mechanical engineering department at the University of Waterloo. As a coop, I was given a a large collection of files: a set of data generated from temperature and pressure transducers that needed to be processed through Beck [...]]]></description>
			<content:encoded><![CDATA[<p>Back when I was in high school, I took a coop job with Prof. Beth Weckman in the mechanical engineering department at the University of Waterloo. As a coop, I was given a a large collection of files: a set of data generated from temperature and pressure transducers that needed to be processed through Beck Engineering Consultants Company&#8217;s <a href="http://home.comcast.net/~jamesverebeck/page4.htm">Ihcp1d</a>. Because it was very monotonous, I quickly wrote a script to do it for me. Because I was back in high school, the script was horrible. It sent mouse clicks and keystrokes to Ihcp1d.</p>
<p>Back in 2007, I was looking at the script. There were a few notes that I needed to look at; I noticed that ihcp1d.exe generated an ini file and invoked sub.exe (an undocumented program that was installed at the same time as ihcp1d). I also noticed that ihcp1d only generated a configuration file. So I quickly wrote my own ihcp1d, something more friendly to scripting. It wasn&#8217;t very pretty. I took five minutes to make it just as a proof of concept which I then promptly forgot about.</p>
<p>I was going through some old code today and thought that it might be useful to someone else, so I have decided to post it here.</p>
<pre><code>
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace NewIhcp
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length &lt; 3)
            {
                Console.Error.WriteLine("NewIhcp.exe OutputFileName InputFileName &lt;Directory of Sub.exe&gt;");
                return;
            }

            String outputFileName = args[0];
            String inputFileName = args[1];
            String subDir = args[2];

            try
            {
                FileInfo f = new FileInfo(outputFileName);
                StreamWriter w = f.CreateText();
                w.WriteLine("");
                w.WriteLine("Beck Engineering Consultants Company");
                w.WriteLine("1935 Danbury West");
                w.WriteLine("Okemos, MI 48864");
                w.WriteLine("");
                w.WriteLine("Program output file name:");
                w.WriteLine(f.FullName);
                w.WriteLine("");
                w.WriteLine("Temperature measurement input file name:");
                w.WriteLine((new FileInfo (inputFileName)).FullName);
                w.WriteLine("");
                w.WriteLine("Date: 09/11/2007 ");
                w.WriteLine("Time: 12:48:54 PM ");
                w.WriteLine("");
                w.WriteLine("Heading: ");
                w.WriteLine("This is example problem number 1.");
                w.WriteLine("");
                w.WriteLine("**** Step1: Define the GEOMETRY of the experiment. *******************");
                w.WriteLine("Main Geometry");
                w.WriteLine("Flat plate     Cylindrical radial     Spherical radial");
                w.WriteLine("         (*)                ( )                   ( )");
                w.WriteLine("Units");
                w.WriteLine("     W-kg-m-sec-°C     cal-gm-cm-sec-°C     BTU-lb-ft-hr-°F");
                w.WriteLine("         (*)               ( )                   ( )");
                w.WriteLine("Number of regions");
                w.WriteLine(" 1 ");
                w.WriteLine("Region material number");
                w.WriteLine(" 1       ");
                w.WriteLine("Thickness of region (m)");
                w.WriteLine(" 1       ");
                w.WriteLine("Number of nodes per region");
                w.WriteLine(" 50      ");
                w.WriteLine("");
                w.WriteLine("**** Step 2: Define QUANTITIES for time steps and regions. ***********");
                w.WriteLine("Number of calculated time steps per measured time step");
                w.WriteLine(" 10 ");
                w.WriteLine("Number of time intervals with various future time steps");
                w.WriteLine(" 1 ");
                w.WriteLine("Time at end of interval");
                w.WriteLine(" 1.32    ");
                w.WriteLine("Number of future time steps");
                w.WriteLine(" 2       ");
                w.WriteLine("");
                w.WriteLine("**** Step 3: Define BOUNDARY conditions. *****************************");
                w.WriteLine("Unknown boundary location");
                w.WriteLine("   x=0             x=L        Both x=0 and x=L");
                w.WriteLine("   (*)             ( )             ( )");
                w.WriteLine("Known boundary type");
                w.WriteLine(" Insulated   Prescribed non-zero heat flux   Prescribed temperature history");
                w.WriteLine("   (*)                      ( )                        ( )");
                w.WriteLine("");
                w.WriteLine("**** Step 4: Describe input DATA file structure. *********************");
                w.WriteLine("Number of columns of data");
                w.WriteLine(" 1 ");
                w.WriteLine("( ) Print the data for each sensor");
                w.WriteLine("Interface number for input file column");
                w.WriteLine(" 1       ");
                w.WriteLine("");
                w.WriteLine("**** Step 5: Define temperature-dependent thermal PROPERTIES. *******");
                w.WriteLine("");
                w.WriteLine("        MATERIAL NUMBER 1 ");
                w.WriteLine("Number of components of the thermal conductivity table");
                w.WriteLine(" 1 ");
                w.WriteLine("Number of components of the volumetric heat capacity");
                w.WriteLine(" 1 ");
                w.WriteLine("Thermal conductivity table");
                w.WriteLine("Temperatures for thermal conductivity (°C)");
                w.WriteLine(" 0       ");
                w.WriteLine("Components of thermal conductivity (W/m-°C)");
                w.WriteLine(" 1       ");
                w.WriteLine("Volumetric heat capacity table");
                w.WriteLine("Temperatures for volumetric heat capacity (°C)");
                w.WriteLine(" 0       ");
                w.WriteLine("Components of volumetric heat capacity (J/m³-°C)");
                w.WriteLine(" 1       ");
                w.WriteLine("**** Step 6: Define ADVANCED features. ******************************");
                w.WriteLine("( ) Calculate unknown heat transfer coefficient");
                w.WriteLine("Fin effect");
                w.WriteLine(" Insulated sides    Side heat loss/gain");
                w.WriteLine("       (*)                ( )");
                w.WriteLine("");
                w.Flush();
                w.Close();
            }
            catch (System.IO.IOException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine();
                Console.WriteLine(e.Source);
            }

            try
            {
                FileInfo f = new FileInfo(subDir + "\ihcp_temporaryfile.ini");
                StreamWriter w = f.CreateText();

                w.WriteLine((new FileInfo(outputFileName)).FullName);
                w.WriteLine();
                w.Flush();
                w.Close();
            }
            catch (System.IO.IOException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine();
                Console.WriteLine(e.Source);
            }
        }
    }
}
</code></pre>
<p>Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djshaw.ca/blog/?feed=rss2&amp;p=301</wfw:commentRss>
		</item>
		<item>
		<title>Daniel Berry is not a Historian</title>
		<link>http://www.djshaw.ca/blog/?p=298</link>
		<comments>http://www.djshaw.ca/blog/?p=298#comments</comments>
		<pubDate>Sun, 07 Dec 2008 19:58:35 +0000</pubDate>
		<dc:creator>Derek Shaw</dc:creator>
		
		<category><![CDATA[SE 2010]]></category>

		<guid isPermaLink="false">http://www.djshaw.ca/blog/?p=298</guid>
		<description><![CDATA[I have always enjoyed logic: I am not a great logician, I enjoy logic because I am fascinated with the idea that so much information can be encoded unambiguously in so few symbols.
Prof. Berry has introduced us only a small set of temporal connectives:


Eventually



Henceforth



Unless



Until



Next state



It is interesting to all of these connectives deal with the [...]]]></description>
			<content:encoded><![CDATA[<p>I have always enjoyed logic: I am not a great logician, I enjoy logic because I am fascinated with the idea that so much information can be encoded unambiguously in so few symbols.</p>
<p>Prof. Berry has introduced us only a small set of temporal connectives:</p>
<table>
<tr>
<td>Eventually</td>
<td><img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=$\lozenge$" /></td>
</tr>
<tr>
<td>Henceforth</td>
<td><img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=$\square$" /></td>
</tr>
<tr>
<td>Unless</td>
<td><img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=${\cal%20W}$" /></td>
</tr>
<tr>
<td>Until</td>
<td><img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=${\cal%20U}$" /></td>
</tr>
<tr>
<td>Next state</td>
<td><img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=$\circ$" /></td>
</tr>
</table>
<p>It is interesting to all of these connectives deal with the current state, or the future. What about the past? Certainly, someone could construct an example where information about a certain point in time is discovered only after that point in time has pasted.</p>
<p>The full specification for linear temporal logic adds history based connectives:</p>
<table>
<tr>
<td>Some time in the past</td>
<td><img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=$\blacklozenge$" /></td>
</tr>
<tr>
<td>Always in the past</td>
<td><img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=$\blacksquare$" /></td>
</tr>
<tr>
<td>Always in the past back to</td>
<td><img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=${\cal%20B}$" /></td>
</tr>
<tr>
<td>Always in the past since</td>
<td><img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=${\cal%20S}$" /></td>
</tr>
<tr>
<td>Previous state</td>
<td><img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=$\bullet$" /></td>
</tr>
</table>
<p>Now we can say something like <img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=$\blacklozenge$P" /> meaning &#8220;<img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=P" /> did hold in some past state&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djshaw.ca/blog/?feed=rss2&amp;p=298</wfw:commentRss>
		</item>
		<item>
		<title>Coldfire Registers</title>
		<link>http://www.djshaw.ca/blog/?p=296</link>
		<comments>http://www.djshaw.ca/blog/?p=296#comments</comments>
		<pubDate>Wed, 03 Dec 2008 21:03:07 +0000</pubDate>
		<dc:creator>Derek Shaw</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[SE 2010]]></category>

		<guid isPermaLink="false">http://www.djshaw.ca/blog/?p=296</guid>
		<description><![CDATA[Every once and awhile, when I was working on Operating Systems, someone would ask me to take a look at their code and assist with debugging. While debugging a different code bases, I have noticed that not everyone uses structs and unions to represent the registers. For instance, in timer.c from the example code we [...]]]></description>
			<content:encoded><![CDATA[<p>Every once and awhile, when I was working on Operating Systems, someone would ask me to take a look at their code and assist with debugging. While debugging a different code bases, I have noticed that not everyone uses structs and unions to represent the registers. For instance, in timer.c from the example code we see &#8220;<code>TIMER0_TMR = 0xFF1B;</code>&#8220;. To understand this value, I needed to breakout the users manual. <code>0xFF1B</code> sets the timer prescaler to <code>FF</code>, disables interrupt on capture event, sets the output mode to active-low , enables interrupt upon reaching the reference value, sets the timer to restart immediately after reaching the reference value, divides the system bus by 1 for the input source, and enables the timer.</p>
<p>A better way would be to use a union to represent the register</p>
<pre><code>// Timer Mode Register (TMRn) (p. 13-4)
typedef struct
{
    unsigned ps : 8; // prescaler value

    unsigned ce : 2; // capture edge and enable interrupt
    unsigned om : 1; // output mode
    unsigned ori : 1; // output reference interrupt enable

    unsigned frr : 1; // free run/restart
    unsigned clk : 2; // input clock source for the timer

    unsigned rst : 1; // reset timer; 0 - reset timer (software reset), 1 - enable timer
} TMRData;

typedef union
{
    TMRData bit;
    UINT16 value;
} TMR;
</code></pre>
<p>Using this union, we can configure the TMR register with the same setting as described above:</p>
<pre><code>TMR tmr;
tmr.value = 0;
tmr.bit.ps = 0xFF;
tmr.bit.ori = 1;
tmr.bit.frr = 1;
tmr.bit.clk = 1;
tmr.bit.rst = 1;

TIMER0_TMR = tmr.value;
</code></pre>
<p>The full set of registers I used can be downloaded <a href="http://www.djshaw.ca/blog/wp-content/uploads/2008/12/register.h" title="register.h">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djshaw.ca/blog/?feed=rss2&amp;p=296</wfw:commentRss>
		</item>
		<item>
		<title>Automated setup of Waterloo&#8217;s Coldfire boards</title>
		<link>http://www.djshaw.ca/blog/?p=295</link>
		<comments>http://www.djshaw.ca/blog/?p=295#comments</comments>
		<pubDate>Tue, 02 Dec 2008 22:38:45 +0000</pubDate>
		<dc:creator>Derek Shaw</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[SE 2010]]></category>

		<guid isPermaLink="false">http://www.djshaw.ca/blog/?p=295</guid>
		<description><![CDATA[We all know then drill when it comes to setting up the coldfire boards:
cfcp rtx.s19 djshaw.s19
telnet cf-server
1
tftp -f djshaw.s19

Granted, this is only four lines, but it gets really annoying to type them in again and again. Early in the development cycle, I tryed to automate the loading by compressing the 4 lines into 1 line [...]]]></description>
			<content:encoded><![CDATA[<p>We all know then drill when it comes to setting up the coldfire boards:</p>
<pre><code>cfcp rtx.s19 djshaw.s19
telnet cf-server
1
tftp -f djshaw.s19
</code></pre>
<p>Granted, this is only four lines, but it gets really annoying to type them in again and again. Early in the development cycle, I tryed to automate the loading by compressing the 4 lines into 1 line that I could copy and paste</p>
<pre><code>$ cfcp rtx.s19 djshaw.s19 &amp;&amp; echo "1tftp -f djshaw.s19" | telnet cf-server</code></pre>
<p>While cfcp worked properly, telnet did not:</p>
<pre><code>Trying 129.97.56.37...
Connected to cf-server.uwaterloo.ca.
Escape character is '^]'.
Connection closed by foreign host.
</code></pre>
<p>I assume that telnet was sending &#8220;1tftp -f djshaw.19&#8243; before the board was ready.</p>
<p>Unfortunately, only after the demo did I find an affective way to automate the load: <a href="http://en.wikipedia.org/wiki/Expect">expect</a>. The following script launches telnet, loads the janusROM, then tftps the object file into memory (object file name is specified by a command line parameter).</p>
<pre><code>#!/software/.admin/bins/bin/expect -f

proc rx {rx} {
    expect {
        timeout {puts "FAIL"; exit -1}
        $rx
    }
}

set timeout 10
spawn telnet cf-server
sleep 1

# todo:
# capture the port of the second serial port for easy reading

# wait for the "Please Pick [1-3]: " line
# dont know how to properly escape "[1-3]" in tcl
rx "Please Pick"
rx ": "

send "1"

# wait for the first instance of the prompt
rx "janusROM&gt;"

send "tftp -f $argv.s19\r"
# wait for the file to load

rx "RAM Address:"
rx "Processing S-Record Data..."
rx "Finished. Start Address is 0x10100000."

# let the user interact with the coldfire board
interact
</code></pre>
<p>Using a bash script to perform cfcp and start the expect script, the whole process can be started with just one line</p>
<pre><code>
#!/bin/bash

me=`whoami`
# ftp the binary to the coldfire server

cfcp rtx.s19 $me.s19
#launch the expect script

./tcfs $me
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.djshaw.ca/blog/?feed=rss2&amp;p=295</wfw:commentRss>
		</item>
		<item>
		<title>The Ultimate Planar Hull Algorithm?</title>
		<link>http://www.djshaw.ca/blog/?p=294</link>
		<comments>http://www.djshaw.ca/blog/?p=294#comments</comments>
		<pubDate>Sun, 19 Oct 2008 19:40:30 +0000</pubDate>
		<dc:creator>Derek Shaw</dc:creator>
		
		<category><![CDATA[SE 2010]]></category>

		<guid isPermaLink="false">http://www.djshaw.ca/blog/?p=294</guid>
		<description><![CDATA[Way back in September, during the very first class of the second section of CS 341: Algorithms, Prof. Lubiw introduced everyone to the convex hull problem. The problem stated simply: given n points in a plane, find their convex hull (the smallest convex set containing all the points). Alternatively defined: the convex hull is a [...]]]></description>
			<content:encoded><![CDATA[<p>Way back in September, during the very first class of the second section of CS 341: Algorithms, Prof. Lubiw introduced everyone to the <a href="http://en.wikipedia.org/wiki/Convex_hull">convex hull</a> problem. The problem stated simply: given <em>n</em> points in a plane, find their convex hull (the smallest <a href="http://en.wikipedia.org/wiki/Convex_set">convex set</a> containing all the points). Alternatively defined: the convex hull is a polygon whose sides are formed lines <em>l</em> that go through 2 or more points and have all other points on one side of the line.</p>
<p><span id="more-294"></span>As a good CS prof. ought to do, she presented a naive <em>O(n<sup>3</sup>)</em>. Followed by an improvement to the <em>O(n<sup>3</sup>)</em> algorithm to make an <em>O(n<sup>2</sup>)</em> solution. Then, she blew all of our minds and showed us how to turn the convex hull problem into a sorting problem and gave us a <em>O(n log n)</em> solution.</p>
<p>But just as the lecture was about to conclude, she did what all great professors do. She just very quickly mentioned that there is a better solution. She simply stated the name of the paper that it was presented in: &#8220;<a href="http://portal.acm.org/citation.cfm?id=13555">The ultimate Planar Conve Hull Algorithm?</a>&#8220;; and she mentioned the run time <em>O(n log h)</em>. Giving something so mysterious, I felt the need to seek out this paper and see if I could make heads or tails of it.</p>
<p>The algorithm is easy to find: a quick Google search will send you in the direction of the ACM&#8217;s portal. Unfortunately, I was unable to find a free copy of the paper, but I was able to access it through Waterloo&#8217;s library&#8217;s proxy.</p>
<p>The algorithm isn&#8217;t difficult to read, but it is longer than what I expected.</p>
<blockquote><p> Procedure UPPER-HULL(S)<br />
1. Initialization<br />
Let min and max be the indicies of two points in S that form the left and right endpoint of the upper hull of S respectively, i.e.<br />
x(p<sub>min</sub>) &lt;= x(p<sub>i</sub>) &lt;= x(p<sub>max</sub>) and<br />
y(p<sub>min</sub>) &gt;= y(p<sub>i</sub>) if x(p<sub>min</sub>) = x(p<sub>i</sub>),<br />
y(p<sub>max</sub>) &gt;= y(p<sub>i</sub>) if x(p<sub>max</sub>) = x(p<sub>i</sub>) for i = 1, &#8230;, n.<br />
If min = max then print min and stop.<br />
Let T:= {p<sub>min</sub>,p<sub>max</sub>} <img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=$\cup$" />{p <img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=$\in$" /> S | x(p<sub>min</sub>) &lt; x(p) &lt; x(p<sub>max</sub>)}.<br />
2. CONNECT (min, max, T)<br />
where CONNECT (k, m, S)is<br />
begin</p>
<p>2.1 Find a real number a such that<br />
x(p<sub>i</sub>) &lt;= a for <img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=\lceil" />|s|/2<img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=\rceil" /> points in S and<br />
x(p<sub>i</sub>) &gt;= a for <img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=\lfloor" />|s|/2<img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=\rfloor" /> points in S.</p>
<p>2.2 Find the &#8220;bridge&#8221; over the vertical line L = {(x,y) | x = a}, i.e.<br />
(i, j) := BRIDGE (S, a).<br />
2.3 Let S<sub>left</sub> := {p<sub>i</sub>} <img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=$\cup$" /> {p <img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=$\in$" /> S | x(p) &lt; x(pi)}.<br />
Let S<sub>right</sub> := {p<sub>j</sub>} <img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=$\cup$" /> {p <img src="http://www.student.cs.uwaterloo.ca/~djshaw/yobjex/latex.php?tex=$\in$" /> S | x(p) &gt; x(p<sub>j</sub>)}.<br />
2.4 If i = k then print (i)<br />
else CONNECT (k, i, S<sub>left</sub>).<br />
If j = m then print (j)<br />
else CONNECT (j, m, S<sub>right</sub>).<br />
end</p></blockquote>
<p>Obviously, there is a little more to the algorithm (the definition of CONNECT and BRIDGE, for instance), and there is a big proof to go with it too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djshaw.ca/blog/?feed=rss2&amp;p=294</wfw:commentRss>
		</item>
	</channel>
</rss>

