<?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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>PowerfulMojo &#187; Software</title>
	<atom:link href="http://blog.powerfulmojo.com/category/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.powerfulmojo.com</link>
	<description>The burning sensation means it's working</description>
	<lastBuildDate>Fri, 11 Jun 2010 18:35:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.powerfulmojo.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>PowerfulMojo &#187; Software</title>
		<link>http://blog.powerfulmojo.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.powerfulmojo.com/osd.xml" title="PowerfulMojo" />
	<atom:link rel='hub' href='http://blog.powerfulmojo.com/?pushpress=hub'/>
		<item>
		<title>Win32::AmbientOrb</title>
		<link>http://blog.powerfulmojo.com/2009/06/15/win32ambientorb/</link>
		<comments>http://blog.powerfulmojo.com/2009/06/15/win32ambientorb/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 04:31:37 +0000</pubDate>
		<dc:creator>powerfulmojo</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://blog.powerfulmojo.com/?p=49</guid>
		<description><![CDATA[This page describes a Perl module I wrote to support a serial-port controlled Ambient Orb. See the Original Post for details. If you just want to get the package, you can download it directly or grab a PPD. Manipulate an Ambient Orb through a serial port NAME SYNOPSIS EXAMPLE DESCRIPTION EXPORTED HASHES METHODS AUTHOR NAME [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.powerfulmojo.com&amp;blog=7059214&amp;post=49&amp;subd=powerfulmojo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This page describes a Perl module I wrote to support a serial-port controlled Ambient Orb. See the <a href="http://blog.powerfulmojo.com/2009/06/22/setting-up-a-serial-controlled-ambient-orb/">Original Post</a> for details.</p>
<p>If you just want to get the package, you can <a href="http://powerfulmojo.com/tools/Win32-AmbientOrb.zip">download it</a> directly or <a href="http://powerfulmojo.com/tools/ppm/Win32-AmbientOrb.ppd">grab a PPD</a>.</p>
<h3>Manipulate an Ambient Orb through a serial port</h3>
<p><a name="__index__"></a></p>
<p><!-- INDEX BEGIN --></p>
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#example">EXAMPLE</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#exported_hashes">EXPORTED HASHES</a></li>
<li><a href="#methods">METHODS</a></li>
<li><a href="#author">AUTHOR</a></li>
</ul>
<p><!-- INDEX END --></p>
<h2><a name="name">NAME</a></h2>
<p>Win32::AmbientOrb &#8211; Manipulate an Ambient Orb through a serial port</p>
<h2><a name="synopsis">SYNOPSIS</a></h2>
<pre>  <span>use</span> <span>Win32::AmbientOrb</span><span>;</span></pre>
<h2><a name="example">EXAMPLE</a></h2>
<pre>  <span>use</span> <span>Win32::AmbientOrb</span> <span>qw(:ALL)</span><span>;</span>

  <span>my</span> <span>$port</span> <span>=</span> <span>"COM1:"</span><span>;</span>
  <span>Win32::AmbientOrb::Port</span><span>(</span><span>$port</span><span>);</span> <span>#set port to COM1</span>
  <span>InitializePort</span><span>();</span>               <span>#set serial port settings</span>
  <span>PagerIgnore</span><span>(</span><span>1</span><span>);</span>                 <span>#don't listen to the pager network</span>

  <span># go straight to red</span>
  <span>my</span> <span>@red</span> <span>=</span> <span>(</span><span>176</span><span>,</span> <span>0</span><span>,</span> <span>0</span><span>);</span>
  <span>DirectColor</span><span>(\</span><span>@red</span><span>);</span>

  <span># quick transition from blue to red</span>
  <span>my</span> <span>@blue</span> <span>=</span> <span>(</span><span>0</span><span>,</span> <span>0</span><span>,</span> <span>176</span><span>);</span>
  <span>TransitionColor</span><span>(\</span><span>@blue</span><span>,</span> <span>\</span><span>@red</span><span>,</span> <span>20</span><span>,</span> <span>5</span><span>);</span>

  <span># slow transition from red to blue</span>
  <span>TransitionColor</span><span>(\</span><span>@red</span><span>,</span> <span>\</span><span>@blue</span><span>,</span> <span>50</span><span>,</span> <span>100</span><span>);</span>

  <span># clean up</span>
  <span>CloseOrb</span><span>();</span></pre>
<h2><a name="description">DESCRIPTION</a></h2>
<p>The <em>Win32::AmbientOrb</em> module lets you manipulate an Ambient Orb connected to a Win32 machine through a serial port.</p>
<p>It uses <em>Win32::SerialPort</em> for serial port communication.</p>
<h2><a name="exported_hashes">EXPORTED HASHES</a></h2>
<p>Two hashes are exported by default, <a href="#item__orbcolor"><code>%OrbColor</code></a> and <a href="#item__orbrgb"><code>%OrbRGB</code></a>.</p>
<dl>
<dt><strong><a name="item__orbcolor"><code>%OrbColor</code></a></strong> </dt>
<dd>Maps from color names to Color IDs useful for <a href="#item_coloranim"><code>ColorAnim( )</code></a>.  Available color names are:</p>
</dd>
<dd>
<pre> • Red          =&gt; 0
 • LightRed     =&gt; 1
 • DarkOrange   =&gt; 2
 • Orange       =&gt; 3
 • LightOrange  =&gt; 4
 • DarkYellow   =&gt; 5
 • Yellow       =&gt; 6
 • LimeGreen    =&gt; 7
 • PaleGreen    =&gt; 8
 • GreenMinus3  =&gt; 9
 • GreenMinus2  =&gt; 10
 • GreenMinus1  =&gt; 11
 • Green        =&gt; 12
 • GreenPlus1   =&gt; 13
 • GreenPlus2   =&gt; 14
 • PaleAqua     =&gt; 15
 • Aqua         =&gt; 16
 • DarkAqua     =&gt; 17
 • Cyan         =&gt; 18
 • DarkCyan     =&gt; 19
 • LightBlue    =&gt; 20
 • SkyBlue      =&gt; 21
 • BlueMinus2   =&gt; 22
 • BlueMinus1   =&gt; 23
 • Blue         =&gt; 24
 • DeepBlue     =&gt; 25
 • VeryDeepBlue =&gt; 26
 • Violet       =&gt; 27
 • Purple       =&gt; 28
 • LightPurple  =&gt; 29
 • Magenta      =&gt; 30
 • MagentaPlus1 =&gt; 31
 • MagentaPlus2 =&gt; 32
 • MagentaPlus3 =&gt; 33
 • MagentaPlus4 =&gt; 34
 • MagentaPlus5 =&gt; 35
 • White        =&gt; 36</pre>
</dd>
<dt><strong><a name="item__orbrgb"><code>%OrbRGB</code></a></strong> </dt>
<dd>Contains the mapping of color ids to RGB arrays useful for <a href="#item_directcolor"><code>DirectColor( )</code></a>.</p>
</dd>
</dl>
<h2><a name="methods">METHODS</a></h2>
<dl>
<dt><strong><a name="item_port"><code>Port( [$port] )</code></a></strong> </dt>
<dd>Sets or returns the port that the Ambient Orb is connected to.  Default is COM1:</p>
</dd>
<dt><strong><a name="item_initializeport"><code>InitializePort( )</code></a></strong> </dt>
<dd>Initializes the serial port for communication with the Ambient Orb.  Settings are:</p>
</dd>
<dd>
<pre> • BAUD: 19200
 • PARITY: N
 • DATA: 8
 • STOP: 1</pre>
</dd>
<dt><strong><a name="item_closeport"><code>ClosePort( )</code></a></strong> </dt>
<dd>Cleans up the port object.</p>
</dd>
<dt><strong><a name="item_coloranim"><code>ColorAnim( [$color], [$animation] )</code></a></strong> </dt>
<dd>Changes the color of the Orb using the default color and animation settings. Colors are listed above in <a href="#item__orbcolor"><code>%OrbColor</code></a> Animations are 0-9</p>
</dd>
<dd>
<pre>        ANIMATION
 • 0 almost imperceptibly slow
        ...
 • 7 very fast
 • 8 crescendo effect
 • 9 heartbeat effect</pre>
</dd>
<dt><strong><a name="item_directcolor"><code>DirectColor( \@rgb )</code></a></strong> </dt>
<dd>Sets the orb instantly to the color specified in the 3-element array <code>@rgb</code>.  Red, green and blue values should be between 0 and 176.</p>
</dd>
<dt><strong><a name="item_transitioncolor"><code>TransitionColor( \@rgb0, \@rgb1, $steps, $wait )</code></a></strong> </dt>
<dd>Performs a slow transition from the color in <code>@rgb0</code> to the one in <code>@rgb1</code>.   Sets the orb instantly to the color specified in the 3-element array <code>@rgb0</code>,  then sends <code>$steps</code> updates, one update every <code>$wait</code> milliseconds until it reaches the color specified in <code>@rgb1</code>.  Red, green and blue values should be between 0 and 176.</p>
</dd>
<dt><strong><a name="item_pagerignore"><code>PagerIgnore( $ignore )</code></a></strong> </dt>
<dd>Instructs the orb not to listen to the pager network.  If you don&#8217;t call this, the orb will keep changing its color to reflect whatever channel it was  listening to before you plugged in the serial port.</p>
</dd>
</dl>
<h2><a name="author">AUTHOR</a></h2>
<p>Andy Allen</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/powerfulmojo.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/powerfulmojo.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/powerfulmojo.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/powerfulmojo.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/powerfulmojo.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/powerfulmojo.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/powerfulmojo.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/powerfulmojo.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/powerfulmojo.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/powerfulmojo.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/powerfulmojo.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/powerfulmojo.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/powerfulmojo.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/powerfulmojo.wordpress.com/49/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.powerfulmojo.com&amp;blog=7059214&amp;post=49&amp;subd=powerfulmojo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.powerfulmojo.com/2009/06/15/win32ambientorb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b991e40d944422d7c62bc482802f86a2?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">powerfulmojo</media:title>
		</media:content>
	</item>
		<item>
		<title>Orb Walkthrough</title>
		<link>http://blog.powerfulmojo.com/2009/06/08/win32-serial-controlled-orb-walkthrough/</link>
		<comments>http://blog.powerfulmojo.com/2009/06/08/win32-serial-controlled-orb-walkthrough/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 04:31:01 +0000</pubDate>
		<dc:creator>powerfulmojo</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://blog.powerfulmojo.com/?p=45</guid>
		<description><![CDATA[This page goes through how to set up your serial-controlled orb. The sections are: What You Will Need Connecting the Hardware Installing Perl and Required Packages Creating a Color Script Installing the Service Web-Connected Orbs Other Uses For the Orb You Will Need: HARDWARE A Windows XP or 2003 Server host An Ambient Orb (or [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.powerfulmojo.com&amp;blog=7059214&amp;post=45&amp;subd=powerfulmojo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This page goes through how to set up your <a href="http://blog.powerfulmojo.com/2009/06/22/setting-up-a-serial-controlled-ambient-orb/">serial-controlled orb</a>.  The sections are:</p>
<p><a href="#supplies">What You Will Need</a><br />
<a href="#connecting">Connecting the Hardware</a><br />
<a href="#installingperl">Installing Perl and Required Packages</a><br />
<a href="#creating">Creating a Color Script</a><br />
<a href="#installing">Installing the Service</a><br />
<a href="#weborbs">Web-Connected Orbs</a><br />
<a href="#other">Other Uses For the Orb</a></p>
<p><a name="supplies"></a></p>
<h3><a name="supplies">You Will Need:</a></h3>
<h4>HARDWARE</h4>
<ul>
<li>A Windows XP or 2003 Server host</li>
<li>An <a href="http://www.ambientdevices.com/">Ambient Orb</a> (or several)</li>
<li>A <a href="http://www.ambientdevices.com/developer/orbhdkorder.html">Hardware Developer&#8217;s Kit</a> from Ambient (one per orb)</li>
<li>Long enough serial cables to put the orb where you want.</li>
</ul>
<h4>SOFTWARE</h4>
<ul>
<li>Perl (I used <a href="http://activestate.com/store/languages/register.plex?id=ActivePerl">ActiveState</a>). I&#8217;ve included <tt>ppm</tt> commands below.</li>
<li> Aldo Calpini&#8217;s <a href="http://dada.perl.it/#api">Win32::API</a> package<br />
<tt>ppm install Win32-API</tt></li>
<li> Dave Roth&#8217;s <a href="http://roth.net/perl/packages/">Win32::Daemon</a> package<br />
<tt>ppm install http://roth.net/perl/packages/Win32-Daemon.ppd</tt></li>
<li> Bill Birthisel&#8217;s <a href="http://search.cpan.org/dist/Win32-SerialPort/">Win32::SerialPort</a> package<br />
I didn&#8217;t use a ppd, I installed it the old-fashioned way (as described in the README, but you could try finding a ppd with a <a href="http://www.google.com/search?q=Win32%3A%3ASerialPort+ppd">Google search</a></li>
<li> <a href="http://blog.powerfulmojo.com/2009/06/22/win32ambientorb/">Win32::AmbientOrb</a><br />
<tt>ppm install http://powerfulmojo.com/tools/ppm/Win32-AmbientOrb.ppd</tt></li>
<li> The service files in <a href="http://powerfulmojo.com/ext/AmbientOrbService.zip">AmbientOrbService.zip</a></li>
</ul>
<p><a name="connecting"></a></p>
<h3><a name="connecting">Connecting the Hardware</a></h3>
<ul>
<li>Plug the serial exension cable (if you&#8217;re using one) into your serial port.</li>
<li>Plug the HDK into the serial extension cable</li>
<li>Plug the Orb into the HDK.</li>
<li>Plug the Power adapter (supplied with the Orb) into the HDK.</li>
</ul>
<p>The orb will go through its regular power-up routine, then start displaying the DJIA channel (or whatever it was most recently tracking).</p>
<p><a name="installingperl"></a></p>
<h3><a name="installingperl">Installing Perl and Packages</a></h3>
<p>Install <a href="http://activestate.com/store/languages/register.plex?id=ActivePerl">Perl</a> and get all of the packages above installed in the order listed. If you use the <tt>ppm</tt> commands provided, it will link the modules&#8217; documentation right into your html documentation so you can see how to use everything. You will only be using <a href="http://blog.powerfulmojo.com/2009/06/22/win32ambientorb/">Win32::AmbientOrb</a> directly.  It depends on <a href="http://search.cpan.org/dist/Win32-SerialPort/">Win32::SerialPort</a> (which depends on <a href="http://dada.perl.it/#api">Win32::API</a>),  and we will need <a href="http://roth.net/perl/packages/">Win32::Daemon</a> to get it up and running as a service.</p>
<p><a name="creating"></a></p>
<h3><a name="creating">Creating a color script</a></h3>
<p>The service will need a script to tell it what color to turn the orb. A color script can be written in just about any language, it just has to print an integer to the console representing the correct color. Possible colors are:</p>
<div style="position:relative;left:28px;">
<table border="0" cellspacing="0" cellpadding="4">
<tbody>
<tr>
<td>0</td>
<td>Red</td>
<td style="background:red none repeat scroll 0 0;"><img src="http://powerfulmojo.com/Free/gmap/img/spacer.gif" alt="" width="20" /></td>
<td>24</td>
<td>Blue</td>
<td style="background:blue none repeat scroll 0 0;"><img src="http://powerfulmojo.com/Free/gmap/img/spacer.gif" alt="" width="20" /></td>
</tr>
<tr>
<td>3</td>
<td>Orange</td>
<td style="background:orange none repeat scroll 0 0;"><img src="http://powerfulmojo.com/Free/gmap/img/spacer.gif" alt="" width="20" /></td>
<td>27</td>
<td>Violet</td>
<td style="background:violet none repeat scroll 0 0;"><img src="http://powerfulmojo.com/Free/gmap/img/spacer.gif" alt="" width="20" /></td>
</tr>
<tr>
<td>6</td>
<td>Yellow</td>
<td style="background:yellow none repeat scroll 0 0;"><img src="http://powerfulmojo.com/Free/gmap/img/spacer.gif" alt="" width="20" /></td>
<td>30</td>
<td>Magenta</td>
<td style="background:magenta none repeat scroll 0 0;"><img src="http://powerfulmojo.com/Free/gmap/img/spacer.gif" alt="" width="20" /></td>
</tr>
<tr>
<td>12</td>
<td>Green</td>
<td style="background:green none repeat scroll 0 0;"><img src="http://powerfulmojo.com/Free/gmap/img/spacer.gif" alt="" width="20" /></td>
<td>35</td>
<td>Red-Magenta</td>
<td style="background:crimson none repeat scroll 0 0;"><img src="http://powerfulmojo.com/Free/gmap/img/spacer.gif" alt="" width="20" /></td>
</tr>
<tr>
<td>18</td>
<td>Cyan</td>
<td style="background:cyan none repeat scroll 0 0;"><img src="http://powerfulmojo.com/Free/gmap/img/spacer.gif" alt="" width="20" /></td>
<td>36</td>
<td>White</td>
<td style="background:white none repeat scroll 0 0;"><img src="http://powerfulmojo.com/Free/gmap/img/spacer.gif" alt="" width="20" /></td>
</tr>
</tbody>
</table>
</div>
<p>You can use any integer between 0 and 36. The ones I didn&#8217;t list work out about like you&#8217;d expect (i.e. 9 is yellowish-green). My color script is in Perl and is available <a href="#colorscript">below</a>. A blue orb means all builds are successful, a red orb means at least one build is failed, and a yellow orb means the CruiseControl server was unreachable.</p>
<p>Here is an example of a (very simple) batch file color script:</p>
<pre>    @echo 24</pre>
<p>It&#8217;s not very interesting, because it just returns the code for &#8220;blue.&#8221; The default script looks like this:</p>
<p><a name="colorscript"></a></p>
<pre> <span>1</span>   #!perl
 <span>2</span>   use strict;
 <span>3</span>   use LWP::Simple;
 <span>4</span>
 <span>5</span>   my $color = getColor();
 <span>6</span>   print $color;
 <span>7</span>
 <span>8</span>   sub getColor {
 <span>9</span>       my $color = 6;
 <span>10</span>      for (my $retry = 0; $retry &lt; 3; $retry++) {
 <span>11</span>          if ($color == 6) {
 <span>12</span>              sleep 1 if ($retry &gt; 0);
 <span>13</span>              $color = getColorRequest();
 <span>14</span>          }
 <span>15</span>      }
 <span>16</span>      return $color;
 <span>17</span>  }
 <span>18</span>
 <span>19</span>  sub getColorRequest  {
 <span>20</span>      my $color;
 <span>21</span>      my $dashboard = get('http://cchost/ccnet');
 <span>22</span>      if ($dashboard) {
 <span>23</span>          if ($dashboard =~ /&gt;Fail/) { $color = 0; }
 <span>24</span>          else { $color = 24; }
 <span>25</span>      }
 <span>26</span>      else {
 <span>27</span>          $color = 6;
 <span>28</span>      }
 <span>29</span>      return $color;
 <span>30</span>  }</pre>
<p>It is a little more interesting: it makes a request to a server named <tt>cchost</tt> and searches the response for the word &#8220;Fail.&#8221; If it finds it, at least one build is failed and the orb should be red. If no builds are failed, the orb should be blue. In the event that the server is unavailable, it will retry the request twice more, but if it still can&#8217;t reach <tt>cchost</tt> it will turn the orb yellow.</p>
<p><a name="installing"></a></p>
<h3><a name="installing">Installing the Service</a></h3>
<p>Now that the orb is hooked up and you&#8217;ve got your color script written, here&#8217;s how to install the service to make it go.</p>
<p><strong>Put the files in place</strong></p>
<p>Create a folder named <tt>C:\Program Files\AmbientOrb</tt> and copy everything in this .zip into it: <a href="http://powerfulmojo.com/ext/AmbientOrbService.zip">AmbientOrbService.zip</a>. Put your color script in the same folder.</p>
<p><strong>Install the Service</strong></p>
<p>You will need the script <tt>installOrbService.pl</tt> (or one like it) to install the AmbientBuild Windows Service on your host.</p>
<pre> <span>1</span>   #!perl
 <span>2</span>   ###########################
 <span>3</span>   # installOrbService.pl
 <span>4</span>   ###########################
 <span>5</span>   use Win32::Daemon;
 <span>6</span>   my $svcName = 'AmbientBuild';
 <span>7</span>   %Hash = (
 <span>8</span>       name    =&gt;  $svcName,
 <span>9</span>       display =&gt;  $svcName,
 <span>10</span>      description =&gt; 'Ambient Build Monitor',
 <span>11</span>      path    =&gt;  'c:\\perl\\bin\\perl.exe',
 <span>12</span>      user    =&gt;  '',
 <span>13</span>      pwd     =&gt;  '',
 <span>14</span>      parameters =&gt;'c:\\Progra~1\\AmbientOrb\\orbService.pl',
 <span>15</span>  );
 <span>16</span>
 <span>17</span>  my $action = $ARGV[0];
 <span>18</span>  if (lc($action) eq '-i') {
 <span>19</span>      if( Win32::Daemon::CreateService( \%Hash ) ) {
 <span>20</span>          print "Successfully added.\n";
 <span>21</span>      }
 <span>22</span>      else {
 <span>23</span>          print "Failed to add service: ",
 <span>24</span>           Win32::FormatMessage(Win32::Daemon::GetLastError()),
 <span>25</span>           "\n";
 <span>26</span>      }
 <span>27</span>  }
 <span>28</span>  elsif (lc($action) eq '-u') {
 <span>29</span>      if( Win32::Daemon::DeleteService( "", $svcName ) ) {
 <span>30</span>          print "Successfully removed.\n";
 <span>31</span>      }
 <span>32</span>      else {
 <span>33</span>          print "Failed to remove service: ",
 <span>34</span>           Win32::FormatMessage(Win32::Daemon::GetLastError()),
 <span>35</span>           "\n";
 <span>36</span>      }
 <span>37</span>  }
 <span>38</span>  else {
 <span>39</span>      print "Unknown action ",
 <span>40</span>      "(use -i for install, -u for uninstall).\n";
 <span>41</span>  }</pre>
<p>You only need to run this script once to install the service. It takes one argument: <tt>-i</tt> for install or <tt>-u</tt> for uninstall, then prints a short status message indicating whether the action was successful.</p>
<p>Line <tt>14</tt> points to the script that will be started when the Windows Service starts. That&#8217;s our <tt>orbService.pl</tt> script. If you write your own Windows Service, you would put its pathname here, using the short pathname (with no spaces).   If you fill out a username and password in lines <tt>12</tt>-<tt>13</tt>, the script will run as that account.   If you leave it blank, it will run as System.</p>
<p>Note that line <tt>14</tt> should contain the <tt>orbService.pl</tt> script as written, not your color script.</p>
<p><strong>Configure the Service</strong></p>
<p>The service looks for a file named orbService.config, which can have any of the following values. If a value is not specified, it will use the default listed.</p>
<table border="1" cellspacing="0" cellpadding="4">
<tbody>
<tr>
<th>KEY</th>
<th>Default Value</th>
<th>Description</th>
</tr>
<tr>
<td>colorScript</td>
<td>C:\Program Files\AmbientOrb\ccnetWeb.pl</td>
<td>prints orb color code to STDOUT</td>
</tr>
<tr>
<td>webOrbs</td>
<td>[n/a]</td>
<td>serial #s of other orbs,<br />
comma-separated, no trailing comma</td>
</tr>
<tr>
<td>port</td>
<td>COM1</td>
<td>serial port to use</td>
</tr>
<tr>
<td>logFile</td>
<td>C:\Program Files\AmbientOrb\orb.log</td>
<td></td>
</tr>
<tr>
<td>verbosity</td>
<td>1</td>
<td>0 = silent, &#8230;, 3 = garrulous</td>
</tr>
<tr>
<td>maxLogLines</td>
<td>10000</td>
<td>maximum lines to leave in log file</td>
</tr>
<tr>
<td>pollingInterval</td>
<td>30000</td>
<td>wait between updating the orb (ms)</td>
</tr>
<tr>
<td>sleepTime</td>
<td>2000</td>
<td>between processing service messages (ms)</td>
</tr>
<tr>
<td>waitForStop</td>
<td>20000</td>
<td>how long to expect service stop to take (ms)</td>
</tr>
<tr>
<td>errorColor</td>
<td>0</td>
<td>color to use on colorScript error (0-36)</td>
</tr>
<tr>
<td>errorAnim</td>
<td>5</td>
<td>animation on colorScript error (0-9)</td>
</tr>
</tbody>
</table>
<p>While the service is running, changes to this configuration file will be automatically loaded the next time the script checks its messages (within 2 seconds by default). If you leave the service configured as shown, it will run the <tt>ccnetWeb.pl</tt> script every 30 seconds.</p>
<p><a name="weborbs"></a></p>
<h3><a name="weborbs">Web Orbs</a></h3>
<p>In my environment, we have three orbs and only two HDKs. The service is installed on both hosts with HDKs attached, but that leaves one orb out of the loop. To update it, one of the servers is also configured to update the orb using its webOrbs configuration parameter. This orb is updated using Ambient&#8217;s Web Developer API.</p>
<p><a name="other"></a></p>
<h3><a name="other">Other uses</a></h3>
<p>This service was written to make it easy to monitor anything using an Ambient Orb. With a different color script and polling interval, you could make it monitor just about anything. During testing I had it monitor hockey scores, crude oil prices, and network traffic (not all at the same time). If you do something like that, I&#8217;d like to hear about it, so please let me know.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/powerfulmojo.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/powerfulmojo.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/powerfulmojo.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/powerfulmojo.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/powerfulmojo.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/powerfulmojo.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/powerfulmojo.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/powerfulmojo.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/powerfulmojo.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/powerfulmojo.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/powerfulmojo.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/powerfulmojo.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/powerfulmojo.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/powerfulmojo.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.powerfulmojo.com&amp;blog=7059214&amp;post=45&amp;subd=powerfulmojo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.powerfulmojo.com/2009/06/08/win32-serial-controlled-orb-walkthrough/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b991e40d944422d7c62bc482802f86a2?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">powerfulmojo</media:title>
		</media:content>

		<media:content url="http://powerfulmojo.com/Free/gmap/img/spacer.gif" medium="image" />

		<media:content url="http://powerfulmojo.com/Free/gmap/img/spacer.gif" medium="image" />

		<media:content url="http://powerfulmojo.com/Free/gmap/img/spacer.gif" medium="image" />

		<media:content url="http://powerfulmojo.com/Free/gmap/img/spacer.gif" medium="image" />

		<media:content url="http://powerfulmojo.com/Free/gmap/img/spacer.gif" medium="image" />

		<media:content url="http://powerfulmojo.com/Free/gmap/img/spacer.gif" medium="image" />

		<media:content url="http://powerfulmojo.com/Free/gmap/img/spacer.gif" medium="image" />

		<media:content url="http://powerfulmojo.com/Free/gmap/img/spacer.gif" medium="image" />

		<media:content url="http://powerfulmojo.com/Free/gmap/img/spacer.gif" medium="image" />

		<media:content url="http://powerfulmojo.com/Free/gmap/img/spacer.gif" medium="image" />
	</item>
		<item>
		<title>Ambient Orb Setup</title>
		<link>http://blog.powerfulmojo.com/2009/06/01/setting-up-a-serial-controlled-ambient-orb/</link>
		<comments>http://blog.powerfulmojo.com/2009/06/01/setting-up-a-serial-controlled-ambient-orb/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 04:29:57 +0000</pubDate>
		<dc:creator>powerfulmojo</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://blog.powerfulmojo.com/?p=42</guid>
		<description><![CDATA[This page describes the process of hooking an Ambient Orb up to show a real-time information using the Ambient Hardware Developer&#8217;s Kit. Previous Work The Orb provides a great, at-a-glance indication of build status for a continuously integrated software project. The subjects of Continuous Integration and its benefits are discussed in a number of other [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.powerfulmojo.com&amp;blog=7059214&amp;post=42&amp;subd=powerfulmojo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This page describes the process of hooking an <a href="http://www.ambientdevices.com/cat/orb/orborder.html">Ambient Orb</a> up to show a real-time information using the Ambient <a href="http://www.ambientdevices.com/developer/orbhdkorder.html">Hardware Developer&#8217;s Kit</a>.</p>
<h3>Previous Work</h3>
<p>The Orb provides a great, at-a-glance indication of build status for a continuously integrated software project. The subjects of Continuous Integration and its benefits are <a href="http://www.martinfowler.com/articles/continuousIntegration.html">discussed</a> in a <a href="http://en.wikipedia.org/wiki/Continuous_Integration">number</a> of <a href="http://www.stickyminds.com/BetterSoftware/magazine.asp?fn=cifea&amp;id=58">other</a> <a href="http://damagecontrol.codehaus.org/Continuous+Integration+Server+Feature+Matrix">places</a>, so I won&#8217;t cover them here. Likewise, the use of an Orb using the Ambient Web API is covered admirably by <a href="http://blogs.msdn.com/mswanson/articles/169058.aspx">Michael Swanson</a>, so you can read that there.</p>
<h3>Problems</h3>
<p>The two problems I found were:</p>
<ol>
<li>
<h4>Update lag</h4>
<p>The Ambient pager network does not change the color of an orb for 10 &#8211; 30 minutes. I can break a build in seconds. An ideal system would indicate the status of software builds in real time with no lag.</li>
<li>
<h4>Integration of multiple software projects</h4>
<p>I work in a shop that produces a lot of different projects at a time.  We currently have eleven builds managed by <a href="http://ccnet.thoughtworks.com/">CruiseControl.NET</a>. Using NAnt events as described elsewhere did not provide an easy way to measure how many builds were successful moment-by-moment.</li>
</ol>
<h3>Solution</h3>
<p>Lucky for me, the first problem can be solved with hardware. As a software guy, I love when that happens. Ambient produces a <a href="http://www.ambientdevices.com/developer/orbhdkorder.html">Hardware Developer&#8217;s Kit</a>. You put an Orb on one end and a serial port on the other, and you&#8217;re in business: you can update the orb instantly to any color you like.</p>
<p>Unfortunately, the cable is only 3 feet long, making the orb&#8217;s location a bit constrained. This was easily solved with a <a href="http://www.amazon.com/gp/product/B00006HXZV/sr=8-1/qid=1141678515/ref=sr_1_1/002-7412061-5256016?%5Fencoding=UTF8">cheap 50-foot serial cable</a>. As a bonus, the $45 (with shipping) HDK frees me from the $80/year subscription to Ambient&#8217;s developer channel, so the hardware investment will pay for itself within the first year.</p>
<p>To have the Orb reflect the status of multiple software projects all at once, I polled the <a href="http://ccnet.thoughtworks.com/">CruiseControl.NET</a> server. For now, I&#8217;m using a screen scrape of the CruiseControl dashboard. With a little gumption, I could probably poll the same port that CCTray uses.</p>
<p>Keeping in mind that I might not always use CruiseControl as my CI solution, and that I might change the way I poll it for build status, I thought it would be nice to keep those changes insulated from the core orb updating service.</p>
<p>I&#8217;m a native speaker of Perl, so that&#8217;s the language all of this is in. I used <a href="http://roth.net/perl/packages/">Win32::Daemon</a> by Dave Roth to create a Windows service in Perl. The service talks on the serial port using Bill Birthisel&#8217;s <a href="http://search.cpan.org/dist/Win32-SerialPort/">Win32::SerialPort</a> package and updates the colors using my <a href="http://blog.powerfulmojo.com/2009/06/22/win32ambientorb/">Win32::AmbientOrb</a> package.</p>
<h3>How to Do It Yourself</h3>
<p>This <a href="http://blog.powerfulmojo.com/2009/06/08/win32-serial-controlled-orb-walkthrough/">Walkthrough</a> describes how to set up the whole system.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/powerfulmojo.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/powerfulmojo.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/powerfulmojo.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/powerfulmojo.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/powerfulmojo.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/powerfulmojo.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/powerfulmojo.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/powerfulmojo.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/powerfulmojo.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/powerfulmojo.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/powerfulmojo.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/powerfulmojo.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/powerfulmojo.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/powerfulmojo.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.powerfulmojo.com&amp;blog=7059214&amp;post=42&amp;subd=powerfulmojo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.powerfulmojo.com/2009/06/01/setting-up-a-serial-controlled-ambient-orb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b991e40d944422d7c62bc482802f86a2?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">powerfulmojo</media:title>
		</media:content>
	</item>
	</channel>
</rss>
