<?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/"
	>

<channel>
	<title>Sky this Week &#187; Software</title>
	<atom:link href="http://www.skythisweek.com/category/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.skythisweek.com</link>
	<description>Occasional observations of an amateur astronomer</description>
	<lastBuildDate>Sun, 26 Sep 2010 23:05:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Blog theme updated</title>
		<link>http://www.skythisweek.com/2007/03/07/blog-theme-updated/</link>
		<comments>http://www.skythisweek.com/2007/03/07/blog-theme-updated/#comments</comments>
		<pubDate>Wed, 07 Mar 2007 18:59:35 +0000</pubDate>
		<dc:creator>Vern</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.raben.com/weblog/2007/03/07/blog-theme-updated/</guid>
		<description><![CDATA[I spent some time recently to create my own WordPress blog theme. I couldn&#8217;t resist using Dan Laszlo&#8217;s excellent mosaic of Long&#8217;s peak and comet McNaught from last January. Dan is a member of one of our local astronomy clubs  NCAS in Fort Collins, CO.  After the comet disappeared for us in the [...]]]></description>
			<content:encoded><![CDATA[<p>I spent some time recently to create my own WordPress blog theme. I couldn&#8217;t resist using Dan Laszlo&#8217;s excellent mosaic of Long&#8217;s peak and comet McNaught from last January. Dan is a member of one of our local astronomy clubs  <a href="http://www.ncastro.org/" title="Northern Colorado Astronomy Club">NCAS in Fort Collins, CO</a>.  After the comet disappeared for us in the northern hemisphere a member of the <a href="http://www.boulderastro.org">Boulder club</a>, Paul Robinson, determined that it might be possible to still observe the tail and in fact did so.  Dan was the first to photograph the <a href="http://www.spaceweather.com/comets/mcnaught/17jan07/lazlo1.jpg">comets tail extending above the horizon</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.skythisweek.com/2007/03/07/blog-theme-updated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aurora Add-on for World Wind Updated</title>
		<link>http://www.skythisweek.com/2007/03/06/aurora-add-on-for-world-wind-updated/</link>
		<comments>http://www.skythisweek.com/2007/03/06/aurora-add-on-for-world-wind-updated/#comments</comments>
		<pubDate>Tue, 06 Mar 2007 15:49:53 +0000</pubDate>
		<dc:creator>Vern</dc:creator>
				<category><![CDATA[Astronomy]]></category>
		<category><![CDATA[Aurora]]></category>
		<category><![CDATA[NASA World Wind]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.raben.com/weblog/2007/03/06/aurora-add-on-for-world-wind-updated/</guid>
		<description><![CDATA[I’ve updated the Aurora add-on for NASA’s World Wind. The recently released (Feb 14) version 1.4 of World Wind now monitors cache files and updates them if they are expired. The Aurora add-on needed only a minor change to expire the cache so it will retrieve the current Auroral PMAps from NOAA National Weather Service [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve updated the Aurora add-on for NASA’s World Wind. The recently released (Feb 14) version 1.4 of World Wind now monitors cache files and updates them if they are expired. The Aurora add-on needed only a minor change to expire the cache so it will retrieve the current Auroral PMAps from NOAA National Weather Service Space Environment Center. You can download the updated plugin from <a href="http://www.sec.noaa.gov/pmap/GEpmap/">http://www.sec.noaa.gov/pmap/GEpmap/</a></p>
<p>This works although the Earth/LayerSet.xsd that comes with WW-1.4 should technically disallow the markup within an ImageLayer. Apparently the LayerSet.xsd is not current.</p>
<p><img src="http://www.raben.com/aurora/Add-on-noaa-aurora.jpg" alt="Screen shot of Aurora plugin for NASA World Wind." /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skythisweek.com/2007/03/06/aurora-add-on-for-world-wind-updated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NASA World Wind &#8211; Aurora overlay</title>
		<link>http://www.skythisweek.com/2006/07/11/nasa-world-wind-aurora-overlay/</link>
		<comments>http://www.skythisweek.com/2006/07/11/nasa-world-wind-aurora-overlay/#comments</comments>
		<pubDate>Tue, 11 Jul 2006 20:31:40 +0000</pubDate>
		<dc:creator>Vern</dc:creator>
				<category><![CDATA[Astronomy]]></category>
		<category><![CDATA[Aurora]]></category>
		<category><![CDATA[NASA World Wind]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.raben.com/weblog/2006/07/11/nasa-world-wind-aurora-overlay/</guid>
		<description><![CDATA[If you haven&#8217;t given it a try yet, you might consider giving NASA World Wind a spin or two.  It is somewhat similar to GoogleEarth but doesn&#8217;t have the privacy issues involved with sending all your clicking habits to Google. World Wind is not Earthbound, you may visit other world&#8217;s such as Mars and [...]]]></description>
			<content:encoded><![CDATA[<p>If you haven&#8217;t given it a try yet, you might consider giving NASA World Wind a spin or two.  It is somewhat similar to GoogleEarth but doesn&#8217;t have the privacy issues involved with sending all your clicking habits to Google. World Wind is not Earthbound, you may visit other world&#8217;s such as Mars and the Moon.  Both GoogleEarth and WorldWind are great applications, each has their own advantages and disadvantages.</p>
<p>Earlier this morning, I completed an overlay for the folks at the National Weather Service&#8217;s Space Environment Center. The overlay displays the auroral power influx as measured by NOAA POES satellites, which gives some indication of auroral activity.  Current version doesn&#8217;t update automatically &#8212; I&#8217;ll add that shortly.</p>
<p>Information and links for downloading NASA World Wind is available from<a href="http://worldwind.arc.nasa.gov/" title="NASA World Wind" target="_blank"> http://worldwind.arc.nasa.gov/</a></p>
<p>After you get World Wind installed, you may download the Aurora overlay from the National Weather Service Space Environment Center at <a href="http://www.sec.noaa.gov/pmap/GEpmap/" title="NWS Space Environment Center World Wind Auroral overlay" target="_blank">http://www.sec.noaa.gov/pmap/GEpmap/</a></p>
<p>General information about auroras is available at <a href="http://www.sec.noaa.gov/pmap" title="Aurora information at NWS Space Environment Center">http://www.sec.noaa.gov/pmap</a></p>
<p><img src="http://www.raben.com/aurora/Add-on-noaa-aurora.jpg" title="NOAA Auroral image overlay" alt="NOAA Auroral image overlay" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skythisweek.com/2006/07/11/nasa-world-wind-aurora-overlay/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Connect to a GO-TO GPS telescope with JAVA™ applications</title>
		<link>http://www.skythisweek.com/2003/09/11/connect-to-a-go-to-gps-telescope-with-java%e2%84%a2-applications/</link>
		<comments>http://www.skythisweek.com/2003/09/11/connect-to-a-go-to-gps-telescope-with-java%e2%84%a2-applications/#comments</comments>
		<pubDate>Fri, 12 Sep 2003 00:47:28 +0000</pubDate>
		<dc:creator>Vern</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.raben.com/weblog/2003/09/11/connect-to-a-go-to-gps-telescope-with-java%e2%84%a2-applications/</guid>
		<description><![CDATA[The current generation of &#8220;go-to&#8221; GPS telescopes are an amazing technological innovation. They combine precise motor controls, position sensors, GPS receivers, and excellent optics into an telescopic instrument that can be enjoyed by both novice users and advanced amateur astronomers. The &#8220;go-to&#8221; telescope permits the user to view the moon, the planets, nebulas, galaxies, star [...]]]></description>
			<content:encoded><![CDATA[<p>The current generation of &#8220;go-to&#8221; GPS telescopes are an amazing technological innovation. They combine precise motor controls, position sensors, GPS receivers, and excellent optics into an telescopic instrument that can be enjoyed by both novice users and advanced amateur astronomers. The &#8220;go-to&#8221; telescope permits the user to view the moon, the planets, nebulas, galaxies, star clusters, and other celestial objects by simply pressing a few buttons. The functionality and ease of use of these telescopes can be futher extended by connecting them to your computer.</p>
<p><img src="http://www.raben.com/articles/TelescopeInterface/rs232connection.jpg" title="Telescope Interface connection" alt="Telescope Interface connection" height="300" width="400" /></p>
<p>The telescope interface presented here will permit Java applications to instruct the telescope to slew or &#8220;go to&#8221; specified coordinates, to query the telescope&#8217;s current position, and obtain other information such as slewing status, the GPS date and time, and the users geographic coordinate. The telescope interface is designed to be extensible, permitting connection from computers running various operating systems to telescopes from various manufactures. The telescope interface is a &#8220;pure&#8221; Java implementation. It utilizes the &#8220;javax.comm&#8221; api. (See the resources page at the end of this article for availability).</p>
<p>By using the telescope interface, applications such as star chart programs may be developed to control the telescope. More advanced applications such as augmented displays that combine digitized video output with graphic overlays are possible. Applications such as these will be the subject of future articles over the next several months.</p>
<p>To connect to the Nexstar GPS telescope an adapter cable is required (Celestron Part Number 93920 available from telescope dealers and online suppliers such as Astronomics, Anacortes, A2Z Cables.com, and several others). The cable costs about $20 (US) plus shipping. The cable has a telephone handset plug at one end and a DB-9 connector on the other. The DB-9 Connector is connected to a COM port on the computer and the other is plugged into the end of the telescope hand controller. The telescope interface provides the RS232 communication functions described in Celestron Instruction manuals and a few additional functions such as accessing the GPS as well.</p>
<p>escription of the Telescope Interface</p>
<p>The telescope interface consists of the classes: TelescopeInterface, TelescopeModel, TelescopeFactory, and SerialConnection. For each telescope manufacture, there is a concrete implementation of the TelescopeInterface and supporting classes. The diagram below shows classes to interface the Celestron telescope. (The complete Javadoc is available online as is a source code cross reference).</p>
<p>Class diagram of telescope interface</p>
<p>Figure 1. Class Diagram of the Telescope Interface</p>
<p>The TelescopeInterface class is an interface that defines all the methods that will be publicly available to an application.</p>
<p>The TelescopeModel class is a type-safe enumation of various telescope models. It permits different telescope models from different manufactures to be selected.</p>
<p>The TelescopeFactory class is used by an application to select which telescope commands are to be used.</p>
<p>The CelestronTelescope class is a concrete implementation of the telescope interface. It takes care of all details of setting up the serial port to communicate with the telescope. In addition, it sends commands to the telescope and receives responses.</p>
<p>The CelestronCommand class is a facade used by CelestronNexstar to select command strings that are to be used for a particular telescope model.</p>
<p>The CelestronCoordinateConverter class is used by the CelestronCommand class to convert coordinates for a telescope model.</p>
<p>Though not yet completely implemented or tested, there are equivalent classes for Meade telescopes: MeadeTelescope, MeadeCommand, and MeadeCoordinateConverter.</p>
<p>The SerialConnection class is used to send command strings and receive responses to the telescope through the computers comm port. It provides a buffer to help synchronize commands and responses. It used used to set up communication parameters such as the comm port to be used, the baud rate, stop bits, bits-per-character, and communication handshake to be used.</p>
<p>To use the telescope interface, the application developer needs to write code to do the following:</p>
<p>   1. Import the &#8220;com.raben.telescope.comm.TelescopeInterface&#8221;, &#8220;com.raben.telescope.comm.TelescopeModel&#8221; and &#8220;com.raben.telescope.comm.TelescopeFactory&#8221; classes<br />
   2. Call the &#8220;TelescopeFactory.newInstance&#8221; static method and pass the name of a TelescopeModel such as &#8220;TelescopeModel.CELSTRON_NEXSTAR_GPS&#8221;.<br />
   3. Create and instance of java.util.properties and set a key &#8220;com.raben.telescope.port&#8221; to &#8220;COM1&#8243;, &#8220;COM2&#8243;, or whatever comm port is to be used to connect to the telescope.<br />
   4. Call the telescope method &#8220;setProperties&#8221; and pass the comm properties as a parameter<br />
   5. Initialize communication to the telescope by calling the &#8220;initialize&#8221; method.<br />
   6. Test whether communication to the telescope has been established by calling the &#8220;isCommunicating&#8221; method.<br />
   7. Implement the application by sending various commands to the telescope such as &#8220;go-to&#8221; a given coordinate or read the telescopes current position.<br />
   8. Call the telescope method &#8220;close&#8221; to release the comm port connection to the telescope</p>
<p>View Javadoc<br />
<code><br />
</code><code><br />
1   /*<br />
2    * TestApp.java<br />
3    *<br />
4    * Copyright (c) 2003, Raben Systems, Inc.<br />
5    * All rights reserved.<br />
6    *<br />
7    * Redistribution and use in source and binary forms, with or without<br />
8    * modification, are permitted provided that the following conditions are met:<br />
9    *<br />
10   *    Redistributions of source code must retain the above copyright notice,<br />
11   *    this list of conditions and the following disclaimer.<br />
12   *<br />
13   *    Redistributions in binary form must reproduce the above copyright notice,<br />
14   *    this list of conditions and the following disclaimer in the documentation<br />
15   *    and/or other materials provided with the distribution.<br />
16   *<br />
17   *    Neither the name of Raben Systems, Inc. nor the names of its contributors<br />
18   *    may be used to endorse or promote products derived from this software<br />
19   *    without specific prior written permission.<br />
20   *<br />
21   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"<br />
22   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br />
23   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br />
24   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE<br />
25   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br />
26   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br />
27   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br />
28   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br />
29   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br />
30   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br />
31   * POSSIBILITY OF SUCH DAMAGE.<br />
32   */<br />
33<br />
34<br />
35  package com.raben.telescope.comm;<br />
36  import java.util.Iterator;<br />
37  import java.util.Calendar;<br />
38  import java.util.Properties;<br />
39  import java.util.TimeZone;<br />
40  import java.io.IOException;<br />
41  import java.io.BufferedReader;<br />
42  import java.io.InputStreamReader;<br />
43  import java.text.DateFormat;<br />
44  import java.awt.geom.Point2D;<br />
45<br />
46  /***<br />
47   * Simple test that connects to telescope and checks that it is communicating,<br />
48   * checks if it is aligned, if so reads altitude/azimuth, and right ascension<br />
49   * and declination.<br />
50   * @author  Vern Raben<br />
51   * @version $Revision: 1.2 $ $Date: 2003/09/08 16:29:53 $<br />
52   */<br />
53  public class TestApp {<br />
54      /*** UTC Time zone */<br />
55      private static final TimeZone TZ = TimeZone.getTimeZone("UTC");<br />
56<br />
57      /*** Date format to use */<br />
58      private DateFormat dateFormat<br />
59          = DateFormat.getDateTimeInstance();<br />
60<br />
61      /*** Telescope interface */<br />
62      private TelescopeInterface telescope;<br />
63<br />
64      /*** Creates a new instance of TestApp */<br />
65      public TestApp() {<br />
66           dateFormat.setTimeZone(TZ);<br />
67      }<br />
68<br />
69      /***<br />
70       * Test telescope interface<br />
71       * @param modelStr Name of telescope model<br />
72       * @param portName  Name of communication port<br />
73       */<br />
74      public void testTelescope(String modelStr, String portName) {<br />
75<br />
76          // First, show a solar hazard warning to user,  just in case they are<br />
77          // operating the telescope outside, during the daytime<br />
78  /*<br />
79          if (!isSolarHazardWarningAcknowledged()) {<br />
80              System.out.println("TestApp exit");<br />
81              System.exit(0);<br />
82          }<br />
83  */<br />
84          // Second, get telescope instance from TelescopeFactory<br />
85          if (modelStr != null) {<br />
86              telescope = TelescopeFactory.getInstance(modelStr);<br />
87          } else {<br />
88              telescope = TelescopeFactory.newInstance();<br />
89          }<br />
90<br />
91<br />
92          // Set debug to true to see commands sent and responses received<br />
93          // telescope.setDebug(true);<br />
94<br />
95          try {<br />
96<br />
97              if (telescope == null) {<br />
98                  throw new IOException("Telescope model not found");<br />
99              }<br />
100<br />
101             System.out.println("Testing telescope model "<br />
102                 + telescope.getTelescopeModel());<br />
103<br />
104             // Third, tell the interface which port to use by setting<br />
105             // property key "com.raben.telescope.port" Not necessary if using<br />
106             // port COM1 (the default)<br />
107             if (portName != null) {<br />
108                 Properties props = new Properties();<br />
109                 props.setProperty(ScopeKey.PORT, portName);<br />
110                 telescope.setProperties(props);<br />
111             }<br />
112<br />
113             // Fourth, initialize communications with telescope<br />
114             telescope.connect();<br />
115             /*<br />
116             // Fifth check if communications is established<br />
117             if ((telescope.isConnected()) &#038;&#038; (!telescope.isCommunicating())) {<br />
118                 System.out.println(<br />
119                     "Telescope is not communicating to computer port "<br />
120                     + portName);<br />
121             } else {<br />
122                 System.out.println("Telescope is communicating");<br />
123                 // If commuicating, check if aligned<br />
124<br />
125                 if (telescope.isAligned()) {<br />
126                     System.out.println("Telescope is aligned");<br />
127<br />
128                     // Test getting azimuth/altitude<br />
129                     Point2D azAlt = telescope.getAzimuthAltitude();<br />
130                     System.out.println("Telescope current azimuth="<br />
131                         + azAlt.getX() + " Altitude=" + azAlt.getY());<br />
132<br />
133                     // Test getting right ascension/declination<br />
134                     Point2D raDec = telescope.getRightAscensionDeclination();<br />
135                     System.out.println("Telescope current right ascension = "<br />
136                         + raDec.getX() + " Declination = " + raDec.getY());<br />
137<br />
138                     testAzimuthSlewing();<br />
139                     testRaSlewing();<br />
140                 } else {<br />
141                     System.out.println("Telescope is not aligned");<br />
142                 }<br />
143<br />
144                 testGps();<br />
145<br />
146             }<br />
147              */<br />
148                 testUpDown();<br />
149                 testLeftRight();<br />
150<br />
151         } catch (IOException e) {<br />
152             System.out.println("Error occurred communicating with telescope "<br />
153                 + " error = " + e.getMessage());<br />
154         } finally {<br />
155<br />
156             if (telescope != null) {<br />
157                 telescope.close();<br />
158             }<br />
159         }<br />
160<br />
161         System.out.println("Test completed");<br />
162     }<br />
163<br />
164     /***<br />
165      * Test azimuth/altitude slewing<br />
166      * @exception IOException may occur<br />
167      */<br />
168     private void testAzimuthSlewing()  throws IOException {<br />
169         // See if we can slew to az 0, alt 0.0<br />
170         System.out.println("Test slewing to azimuth 0, altitude 0");<br />
171         Point2D az = new Point2D.Double(0.0, 0.0);<br />
172         telescope.goToAzimuthAltitude(az);<br />
173         waitForSlew();<br />
174         Point2D az2 = telescope.getAzimuthAltitude();<br />
175         System.out.println("Telescope slewed to azimuth "<br />
176             + az2.getX() + " altitude=" + az2.getY());<br />
177<br />
178     }<br />
179<br />
180     /***<br />
181      * Test slew to right ascension/declination<br />
182      * @exception IOException may occur<br />
183      */<br />
184     private void testRaSlewing() throws IOException {<br />
185         System.out.println("Slew telescope to azimuth 0, altitude 45.0");<br />
186         telescope.goToAzimuthAltitude(new Point2D.Double(0.0, 45.0));<br />
187         waitForSlew();<br />
188         Point2D ra = telescope.getRightAscensionDeclination();<br />
189         ra.setLocation(ra.getX() + 6.0, ra.getY());<br />
190         System.out.println("Test slewing to ra " + ra.getX()<br />
191             + " decl=" + ra.getY());<br />
192<br />
193         telescope.goToRightAscensionDeclination(ra);<br />
194         waitForSlew();<br />
195         Point2D ra2 = telescope.getRightAscensionDeclination();<br />
196         System.out.println("Telescope slewed to ra "<br />
197             + ra2.getX() + " decl " + ra2.getY());<br />
198     }<br />
199<br />
200     /***<br />
201      * Test GPS commands<br />
202      * @exception IOException may occur<br />
203      */<br />
204     private void testGps() throws IOException {<br />
205         // Check if the GPS is linked<br />
206         boolean linked = telescope.isGpsLinked();<br />
207         System.out.println("Testing GPS ");<br />
208         System.out.println("  GPS linked = " + linked);<br />
209<br />
210         if (linked) {<br />
211             Calendar gpsDate = telescope.getGpsDateTime();<br />
212<br />
213             if (gpsDate != null) {<br />
214                 System.out.println("  GPS date is "<br />
215                     + dateFormat.format(gpsDate.getTime()) + " UTC");<br />
216             }<br />
217<br />
218             Point2D gpsCoord = telescope.getGpsCoordinate();<br />
219             System.out.println("  GPS longitude is " + gpsCoord.getX()<br />
220                 + " latitude is " + gpsCoord.getY());<br />
221         }<br />
222<br />
223         System.out.println("GPS test completed");<br />
224     }<br />
225<br />
226     /***<br />
227      * Wait for slew to complete<br />
228      */<br />
229     private void waitForSlew() {<br />
230         boolean slewing = true;<br />
231         System.out.print("Slewing ..");<br />
232<br />
233         try {<br />
234             do {<br />
235                 System.out.print(".");<br />
236                 System.out.flush();<br />
237                 Thread.sleep(2000L);<br />
238              } while (telescope.isSlewing());<br />
239<br />
240         } catch (InterruptedException e) {<br />
241             // Ignore<br />
242         } catch (IOException e) {<br />
243             // ignore<br />
244         }<br />
245         System.out.println();<br />
246     }<br />
247<br />
248<br />
249     /***<br />
250      * @param args the command line arguments<br />
251      * Usage: java -cp TestApp.jar "model" port<br />
252      *<br />
253      * Default telescope model is "Celestron Nexstar GPS", default port is COM1<br />
254      * If this is the case, you do not need to specify any command line args.<br />
255      *<br />
256      * To list available models and ports enter the following:<br />
257      * java -cp TestApp.jar; HELP<br />
258      */<br />
259     public static void main(String[] args) {<br />
260         TestApp testApp = new TestApp();<br />
261<br />
262         if ((args != null) &#038;&#038; (args.length > 0)) {<br />
263             String arg0 = args[0].toUpperCase();<br />
264<br />
265             if (("HELP".equals(arg0)) || ("?".equals(arg0))) {<br />
266                 showHelp();<br />
267             }<br />
268<br />
269             if (args.length > 1) {<br />
270                 testApp.testTelescope(args[0], args[1]);<br />
271             }<br />
272         } else {<br />
273             testApp.testTelescope(null, null);<br />
274         }<br />
275<br />
276         System.out.println("TestApp exit");<br />
277<br />
278     }<br />
279<br />
280     /***<br />
281      * Show how to start the Test application<br />
282      */<br />
283     public static void showHelp() {<br />
284         System.out.println("Usage: java -cp telescope.jar com.raben.telescope.comm.TestApp \"model\" port");<br />
285         System.out.println("Where model is one of:");<br />
286<br />
287         Iterator iter = TelescopeModel.VALUES.iterator();<br />
288<br />
289         while (iter.hasNext()) {<br />
290             System.out.print("  ");<br />
291             System.out.println((TelescopeModel) iter.next());<br />
292         }<br />
293<br />
294         System.out.println(<br />
295             "  Be sure to place double quotes (\") around model name");<br />
296<br />
297         String[] ports = SerialConnection.getAvailablePorts();<br />
298<br />
299         if (ports != null) {<br />
300             System.out.println("And where port is one of ");<br />
301<br />
302             for (int i = 0; i < ports.length; i++) {<br />
303                 System.out.println("  " + ports[i]);<br />
304             }<br />
305<br />
306             System.out.println();<br />
307         }<br />
308<br />
309     }<br />
310<br />
311     /***<br />
312      * Display warning informing user of the hazards of operating telescope<br />
313      * outside during the daytime<br />
314      * Ask user to acknowledge the warning<br />
315      * @return True if user enter "Y", false otherwise<br />
316      */<br />
317     public boolean isSolarHazardWarningAcknowledged() {<br />
318        boolean acknowledge = false;<br />
319        System.out.println("*************************************************");<br />
320        System.out.println("*              !! WARNING !!                    *");<br />
321        System.out.println("* If you are using a telescope during daytime   *");<br />
322        System.out.println("* be sure that you have adequate solar          *");<br />
323        System.out.println("* filters securely and properly in place.       *");<br />
324        System.out.println("* Failure to do so may result in blindness,     *");<br />
325        System.out.println("* severe injuries to yourself, other persons,   *");<br />
326        System.out.println("* or other property and equipment.              *");<br />
327        System.out.println("* The telescope may slew and point directly at  *");<br />
328        System.out.println("* the SUN at anytime, without warning either in *");<br />
329        System.out.println("* response to a command, accidentally or        *");<br />
330        System.out.println("* otherwise.                                    *");<br />
331        System.out.println("* Type \"Y\" at the prompt to acknowledge         *");<br />
332        System.out.println("* warning.                                      *");<br />
333        System.out.println("*************************************************\n");<br />
334        System.out.print("Do you acknowledge this warning? : ");<br />
335        System.out.flush();<br />
336        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));<br />
337<br />
338         try {<br />
339             String str = br.readLine();<br />
340<br />
341             if (str != null) {<br />
342<br />
343                 if ("Y".equals(str.toUpperCase())) {<br />
344                     acknowledge = true;<br />
345                 }<br />
346             }<br />
347         } catch (IOException e) {<br />
348             // Shouldn't occur<br />
349         }<br />
350<br />
351         return acknowledge;<br />
352<br />
353     }<br />
354<br />
355     /*** Test moving telescope left and right in azimuth */<br />
356     public void testUpDown() throws IOException {<br />
357         System.out.println("Testing moving telescope up");<br />
358         telescope.moveInAltitude(true, 9);<br />
359         try {<br />
360             Thread.sleep(3000L);<br />
361         } catch (InterruptedException e) {}<br />
362         System.out.println("send stop command");<br />
363         telescope.moveInAltitude(true, 0);<br />
364<br />
365         System.out.println("Testing moving telescope down");<br />
366         telescope.moveInAltitude(false, 9);<br />
367         try {<br />
368             Thread.sleep(3000L);<br />
369         } catch (InterruptedException e) {}<br />
370         System.out.println("send stop command");<br />
371         telescope.moveInAltitude(false, 0);<br />
372     }<br />
373<br />
374     /*** Test moving telescope up and down in altitude */<br />
375     public void testLeftRight() throws IOException {<br />
376         System.out.println("Testing moving telescope right");<br />
377         telescope.moveInAzimuth(true, 9);<br />
378         try {<br />
379             Thread.sleep(3000L);<br />
380         } catch (InterruptedException e) {}<br />
381         telescope.moveInAzimuth(true, 0);<br />
382<br />
383         System.out.println("Testing moving telescope left");<br />
384         telescope.moveInAzimuth(false, 9);<br />
385         try {<br />
386             Thread.sleep(3000L);<br />
387         } catch (InterruptedException e) {}<br />
388         telescope.moveInAzimuth(false, 0);<br />
389<br />
390<br />
391<br />
392     }<br />
393<br />
394<br />
</code></p>
<p>View Javadoc</p>
<p> /*<br />
2    * PositionDialog.java<br />
3    *<br />
4    * Copyright (c) 2003, Raben Systems, Inc.<br />
5    * All rights reserved.<br />
6    *<br />
7    * Redistribution and use in source and binary forms, with or without<br />
8    * modification, are permitted provided that the following conditions are met:<br />
9    *<br />
10   *    Redistributions of source code must retain the above copyright notice,<br />
11   *    this list of conditions and the following disclaimer.<br />
12   *<br />
13   *    Redistributions in binary form must reproduce the above copyright notice,<br />
14   *    this list of conditions and the following disclaimer in the documentation<br />
15   *    and/or other materials provided with the distribution.<br />
16   *<br />
17   *    Neither the name of Raben Systems, Inc. nor the names of its contributors<br />
18   *    may be used to endorse or promote products derived from this software<br />
19   *    without specific prior written permission.<br />
20   *<br />
21   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"<br />
22   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br />
23   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br />
24   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE<br />
25   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br />
26   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br />
27   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br />
28   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br />
29   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br />
30   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br />
31   * POSSIBILITY OF SUCH DAMAGE.<br />
32   */<br />
33<br />
34  package com.raben.telescope.comm;<br />
35  import java.util.TimerTask;<br />
36  import java.util.Timer;<br />
37  import java.util.Properties;<br />
38  import java.util.ResourceBundle;<br />
39  import java.util.TimeZone;<br />
40  import java.util.Calendar;<br />
41  import java.util.GregorianCalendar;<br />
42  import java.awt.EventQueue;<br />
43  import java.awt.geom.Point2D;<br />
44  import java.io.IOException;<br />
45  import java.text.MessageFormat;<br />
46  import java.text.DateFormat;<br />
47<br />
48<br />
49  /***<br />
50   *<br />
51   * Display telescope position as local horizontal coordinates and equatorial and<br />
52   * GPS date/time and geographic coordinate<br />
53   * coordinates<br />
54   * @author  Vern Raben<br />
55   * @version $Revision: 1.1.1.1 $ $Date: 2003/06/13 04:51:05 $<br />
56   */<br />
57  public class PositionDialog extends javax.swing.JDialog {<br />
58<br />
59      /*** Creates new formPositionDialog<br />
60       * @param parent Reference to parent frame<br />
61       * @param telescope The telescope interface<br />
62       */<br />
63      public PositionDialog(java.awt.Frame parent, TelescopeInterface telescope) {<br />
64          super(parent, false);<br />
65          this.telescope = telescope;<br />
66          initComponents();<br />
67          dateTimeFormat.setTimeZone(TZ);<br />
68<br />
69          // Set connect toggle to current state<br />
70          if (telescope != null) {<br />
71              connectToggle.setSelected(telescope.isConnected());<br />
72          }<br />
73<br />
74          startTelescopeUpdate();<br />
75      }<br />
76<br />
77      /*** This method is called from within the constructor to<br />
78       * initialize the form.<br />
79       * WARNING: Do NOT modify this code. The content of this method is<br />
80       * always regenerated by the Form Editor.<br />
81       */<br />
82      private void initComponents() {//GEN-BEGIN:initComponents<br />
83          jPanel3 = new javax.swing.JPanel();<br />
84          jPanel4 = new javax.swing.JPanel();<br />
85          jLabel5 = new javax.swing.JLabel();<br />
86          gpsDateTimeTextField = new javax.swing.JTextField();<br />
87          jPanel41 = new javax.swing.JPanel();<br />
88          jLabel51 = new javax.swing.JLabel();<br />
89          gpsLongitudeTextField = new javax.swing.JTextField();<br />
90          jLabel511 = new javax.swing.JLabel();<br />
91          gpsLatitudeTextfield = new javax.swing.JTextField();<br />
92          jPanel5 = new javax.swing.JPanel();<br />
93          jPanel6 = new javax.swing.JPanel();<br />
94          jLabel6 = new javax.swing.JLabel();<br />
95          raTextField = new javax.swing.JTextField();<br />
96          jLabel61 = new javax.swing.JLabel();<br />
97          decTextField = new javax.swing.JTextField();<br />
98          jPanel61 = new javax.swing.JPanel();<br />
99          jLabel62 = new javax.swing.JLabel();<br />
100         azmTextField = new javax.swing.JTextField();<br />
101         jLabel611 = new javax.swing.JLabel();<br />
102         altTextField = new javax.swing.JTextField();<br />
103         jPanel8 = new javax.swing.JPanel();<br />
104         cancelButton = new javax.swing.JButton();<br />
105         connectToggle = new javax.swing.JToggleButton();<br />
106<br />
107         getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));<br />
108<br />
109         setTitle(java.util.ResourceBundle.getBundle("resources/comm/Telescope").getString("TELESCOPE_POSITION"));<br />
110         addWindowListener(new java.awt.event.WindowAdapter() {<br />
111             public void windowClosing(java.awt.event.WindowEvent evt) {<br />
112                 closeDialog(evt);<br />
113             }<br />
114         });<br />
115<br />
116         jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.Y_AXIS));<br />
117<br />
118         jPanel3.setBorder(new javax.swing.border.TitledBorder(null, java.util.ResourceBundle.getBundle("resources/comm/Telescope").getString("GPS"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 11), new java.awt.Color(0, 0, 0)));<br />
119         jPanel4.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));<br />
120<br />
121         jLabel5.setText(java.util.ResourceBundle.getBundle("resources/comm/Telescope").getString("DATE_TIME"));<br />
122         jPanel4.add(jLabel5);<br />
123<br />
124         gpsDateTimeTextField.setColumns(18);</p>
<p>125         gpsDateTimeTextField.setEditable(false);<br />
126         gpsDateTimeTextField.setEnabled(false);<br />
127         jPanel4.add(gpsDateTimeTextField);<br />
128<br />
129         jPanel3.add(jPanel4);<br />
130<br />
131         jPanel41.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));<br />
132<br />
133         jLabel51.setText(java.util.ResourceBundle.getBundle("resources/comm/Telescope").getString("LONGITUDE"));<br />
134         jPanel41.add(jLabel51);<br />
135<br />
136         gpsLongitudeTextField.setColumns(10);<br />
137         gpsLongitudeTextField.setEditable(false);<br />
138         gpsLongitudeTextField.setEnabled(false);<br />
139         jPanel41.add(gpsLongitudeTextField);<br />
140<br />
141         jLabel511.setText(java.util.ResourceBundle.getBundle("resources/comm/Telescope").getString("LATITUDE"));<br />
142         jPanel41.add(jLabel511);<br />
143<br />
144         gpsLatitudeTextfield.setColumns(10);<br />
145         gpsLatitudeTextfield.setEditable(false);<br />
146         gpsLatitudeTextfield.setEnabled(false);<br />
147         jPanel41.add(gpsLatitudeTextfield);<br />
148<br />
149         jPanel3.add(jPanel41);<br />
150<br />
151         getContentPane().add(jPanel3);<br />
152<br />
153         jPanel5.setLayout(new javax.swing.BoxLayout(jPanel5, javax.swing.BoxLayout.Y_AXIS));<br />
154<br />
155         jPanel5.setBorder(new javax.swing.border.TitledBorder(null, java.util.ResourceBundle.getBundle("resources/comm/Telescope").getString("TELESCOPE_POSITION"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 11), new java.awt.Color(0, 0, 0)));<br />
156         jPanel6.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));<br />
157<br />
158         jPanel6.setBackground(new java.awt.Color(204, 204, 204));<br />
159         jLabel6.setText(java.util.ResourceBundle.getBundle("resources/comm/Telescope").getString("RA"));<br />
160         jLabel6.setLabelFor(raTextField);<br />
161         jPanel6.add(jLabel6);<br />
162<br />
163         raTextField.setColumns(10);<br />
164         raTextField.setEditable(false);<br />
165         raTextField.setEnabled(false);<br />
166         jPanel6.add(raTextField);<br />
167<br />
168         jLabel61.setText(java.util.ResourceBundle.getBundle("resources/comm/Telescope").getString("DEC"));<br />
169         jPanel6.add(jLabel61);<br />
170<br />
171         decTextField.setColumns(10);<br />
172         decTextField.setEditable(false);<br />
173         decTextField.setEnabled(false);<br />
174         jPanel6.add(decTextField);<br />
175<br />
176         jPanel5.add(jPanel6);<br />
177<br />
178         jPanel61.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));<br />
179<br />
180         jLabel62.setText(java.util.ResourceBundle.getBundle("resources/comm/Telescope").getString("AZM"));<br />
181         jPanel61.add(jLabel62);<br />
182<br />
183         azmTextField.setColumns(9);<br />
184         azmTextField.setEditable(false);<br />
185         azmTextField.setEnabled(false);<br />
186         jPanel61.add(azmTextField);<br />
187<br />
188         jLabel611.setText(java.util.ResourceBundle.getBundle("resources/comm/Telescope").getString("ALT"));<br />
189         jPanel61.add(jLabel611);<br />
190<br />
191         altTextField.setColumns(9);<br />
192         altTextField.setEditable(false);<br />
193         altTextField.setEnabled(false);<br />
194         jPanel61.add(altTextField);<br />
195<br />
196         jPanel5.add(jPanel61);<br />
197<br />
198         getContentPane().add(jPanel5);<br />
199<br />
200         jPanel8.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));<br />
201<br />
202         cancelButton.setText(java.util.ResourceBundle.getBundle("resources/comm/Telescope").getString("CANCEL"));<br />
203         cancelButton.addActionListener(new java.awt.event.ActionListener() {<br />
204             public void actionPerformed(java.awt.event.ActionEvent evt) {<br />
205                 cancelButtonActionPerformed(evt);<br />
206             }<br />
207         });<br />
208<br />
209         jPanel8.add(cancelButton);<br />
210<br />
211         connectToggle.setText(java.util.ResourceBundle.getBundle("resources/comm/Telescope").getString("CONNECT"));<br />
212         connectToggle.setMargin(new java.awt.Insets(2, 2, 2, 2));<br />
213         connectToggle.addActionListener(new java.awt.event.ActionListener() {<br />
214             public void actionPerformed(java.awt.event.ActionEvent evt) {<br />
215                 connectToggleActionPerformed(evt);<br />
216             }<br />
217         });<br />
218<br />
219         jPanel8.add(connectToggle);<br />
220<br />
221         getContentPane().add(jPanel8);<br />
222<br />
223         pack();<br />
224     }//GEN-END:initComponents<br />
225<br />
226     /***<br />
227      * Handle cancel button being pressed<br />
228      * @param evt Not used<br />
229      */<br />
230     private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed<br />
231         closeDialog(null);<br />
232     }//GEN-LAST:event_cancelButtonActionPerformed<br />
233<br />
234     /*** Handle connection toggle button being pressed<br />
235      * @param evt Not used<br />
236      */<br />
237     private void connectToggleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectToggleActionPerformed<br />
238         if (connectToggle.isSelected()) {<br />
239             if (showSolarHazardWarning()) {<br />
240                 try {<br />
241                     if (telescope != null) {<br />
242                         telescope.connect();<br />
243                         startTelescopeUpdate();<br />
244                     }<br />
245                 } catch (IOException e) {<br />
246<br />
247                     // Show connect error dialog<br />
248                     System.out.println(e);<br />
249                 }<br />
250             }<br />
251<br />
252<br />
253         } else {<br />
254             stopTelescopeUpdate();<br />
255             telescope.close();<br />
256             connectToggle.setSelected(telescope.isConnected());<br />
257<br />
258         }<br />
259     }//GEN-LAST:event_connectToggleActionPerformed<br />
260<br />
261     /*** Closes the dialog<br />
262       * @param evt (Not used)<br />
263       */<br />
264     private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog<br />
265         setVisible(false);<br />
266         dispose();<br />
267         stopTelescopeUpdate();<br />
268<br />
269         if (isStandalone()) {<br />
270             System.exit(0);<br />
271         }<br />
272     }//GEN-LAST:event_closeDialog<br />
273<br />
274     /***<br />
275      * Called when PositionDialog run as standalone program<br />
276      * @param args the command line arguments<br />
277      */<br />
278     public static void main(String args[]) {<br />
279<br />
280         TelescopeInterface telescope = TelescopeFactory.newInstance();<br />
281         PositionDialog positionDialog =<br />
282             new PositionDialog(new javax.swing.JFrame(), telescope);<br />
283         positionDialog.setStandalone(true);<br />
284         positionDialog.show();<br />
285     }<br />
286<br />
287<br />
288     /***<br />
289      * Cancel telescope update info and display tasks and timers<br />
290      */<br />
291     private void stopTelescopeUpdate() {<br />
292         if (telescopeInfoTask != null) {<br />
293             telescopeInfoTask.cancel();<br />
294             telescopeInfoTask = null;<br />
295         }<br />
296<br />
297         if (telescopeInfoTimer != null) {<br />
298             telescopeInfoTimer.cancel();<br />
299             telescopeInfoTimer = null;<br />
300         }<br />
301<br />
302         if (updateDisplayTask != null) {<br />
303             updateDisplayTask.cancel();<br />
304             updateDisplayTask = null;<br />
305         }<br />
306<br />
307         if (updateDisplayTimer != null) {<br />
308             updateDisplayTimer.cancel();<br />
309             updateDisplayTimer = null;<br />
310         }<br />
311     }<br />
312<br />
313     /***<br />
314      * Start update info and display timers and tasks<br />
315      */<br />
316     private void startTelescopeUpdate() {<br />
317         if ((telescope != null) &#038;&#038; (telescope.isConnected())) {<br />
318             stopTelescopeUpdate();<br />
319             updateDisplayTask = new UpdateDisplayTask();<br />
320             updateDisplayTimer = new Timer(true);<br />
321             updateDisplayTimer.schedule(updateDisplayTask, 4000L,<br />
322                 updateDisplayInterval);<br />
323             telescopeInfoTask = new TelescopeInfoTask();<br />
324             telescopeInfoTimer = new Timer(true);<br />
325             telescopeInfoTimer.schedule(telescopeInfoTask, 200L,<br />
326                 telescopeInfoInterval);<br />
327<br />
328         }<br />
329     }<br />
330<br />
331     /***<br />
332      * Display solar hazard warning dialog<br />
333      * @return true if user acknowledges solar hazard<br />
334      */<br />
335     private boolean showSolarHazardWarning() {<br />
336         if (!solarHazardDialog.isAccepted()) {<br />
337             solarHazardDialog.show();<br />
338             connectToggle.setSelected(solarHazardDialog.isAccepted());<br />
339         }<br />
340<br />
341         return solarHazardDialog.isAccepted();<br />
342     }<br />
343<br />
344     /*** Getter for property standalone.<br />
345      * @return Value of property standalone.<br />
346      */<br />
347     public boolean isStandalone() {<br />
348         return this.standalone;<br />
349     }<br />
350<br />
351     /*** Setter for property standalone.<br />
352      * @param standalone New value of property standalone.<br />
353      */<br />
354     public void setStandalone(boolean standalone) {<br />
355         this.standalone = standalone;<br />
356     }<br />
357<br />
358     /***<br />
359      * Get angle as Integer array containg degrees, minues, and seconds<br />
360      * @param angle Angle in degrees<br />
361      * @return An int array containing degres, minutes, and seconds<br />
362      */<br />
363     private Integer[] getDegreesMinutesSeconds(double angle) {<br />
364         Integer[] dms = new Integer[3];<br />
365         dms[0] = new Integer((int) angle);<br />
366         double dmin = 60.0 * (Math.abs(angle) - Math.abs(dms[0].intValue()));<br />
367         dms[1] = new Integer((int) dmin);<br />
368         double dsec = 60.0 * (dmin - dms[1].intValue());<br />
369         dms[2] = new Integer((int) Math.round(dsec));<br />
370         return dms;<br />
371     }<br />
372<br />
373     // Variables declaration - do not modify//GEN-BEGIN:variables<br />
374     private javax.swing.JPanel jPanel8;<br />
375     private javax.swing.JPanel jPanel6;<br />
376     private javax.swing.JPanel jPanel5;<br />
377     private javax.swing.JPanel jPanel4;<br />
378     private javax.swing.JPanel jPanel3;<br />
379     private javax.swing.JPanel jPanel41;<br />
380     private javax.swing.JPanel jPanel61;<br />
381     private javax.swing.JLabel jLabel611;<br />
382     private javax.swing.JTextField decTextField;<br />
383     private javax.swing.JLabel jLabel511;<br />
384     private javax.swing.JTextField gpsLongitudeTextField;<br />
385     private javax.swing.JTextField gpsDateTimeTextField;<br />
386     private javax.swing.JLabel jLabel62;<br />
387     private javax.swing.JLabel jLabel61;<br />
388     private javax.swing.JTextField altTextField;<br />
389     private javax.swing.JToggleButton connectToggle;<br />
390     private javax.swing.JTextField raTextField;<br />
391     private javax.swing.JTextField azmTextField;<br />
392     private javax.swing.JTextField gpsLatitudeTextfield;<br />
393     private javax.swing.JButton cancelButton;<br />
394     private javax.swing.JLabel jLabel6;<br />
395     private javax.swing.JLabel jLabel5;<br />
396     private javax.swing.JLabel jLabel51;<br />
397     // End of variables declaration//GEN-END:variables<br />
398<br />
399     /*** Timer to periodically run DisplayUpdateTask */<br />
400     private Timer updateDisplayTimer = null;<br />
401<br />
402     /*** Task to update telescope status display */<br />
403     private UpdateDisplayTask updateDisplayTask = null;<br />
404<br />
405     /*** Telescope display update interval */<br />
406     private long updateDisplayInterval = 2000L;<br />
407<br />
408     /*** Timer to periodically run TelescopeInfoTask */<br />
409     private Timer telescopeInfoTimer = null;<br />
410<br />
411     /*** Task to retrieve info from telescope */<br />
412     private TelescopeInfoTask telescopeInfoTask = null;<br />
413<br />
414     /*** Telescope information interval */<br />
415     private long telescopeInfoInterval = 4000L;<br />
416<br />
417     /*** Telescope interface */<br />
418     private TelescopeInterface telescope = null;<br />
419<br />
420<br />
421     /*** Telescope properties */<br />
422     private Properties telescopeProperties = new Properties();<br />
423<br />
424     /*** Holds value of property standalone. */<br />
425     private boolean standalone;<br />
426<br />
427     /*** MessageFormat for degrees/minutes/seconds */<br />
428     private MessageFormat dmsFmt = new MessageFormat(<br />
429         ResourceBundle.getBundle("resources/comm/Telescope").getString(<br />
430             "DMS_FORMAT"));<br />
431<br />
432         /*** MessageFormat for hours/minutes/seconds */<br />
433     private MessageFormat hmsFmt = new MessageFormat(<br />
434         ResourceBundle.getBundle("resources/comm/Telescope").getString(<br />
435             "HMS_FORMAT"));<br />
436     /*** Time zone for UTC */<br />
437     private static final TimeZone TZ = TimeZone.getTimeZone("UTC");<br />
438<br />
439     /*** Date/Time Format */<br />
440     private DateFormat dateTimeFormat<br />
441         = DateFormat.getDateTimeInstance();<br />
442<br />
443     /*** Local horizontal coordinate */<br />
444     private Point2D horizCoord = new Point2D.Double(0.0, 0.0);<br />
445<br />
446     /*** Equatorial coordinate */<br />
447     private Point2D eqCoord = new Point2D.Double(0.0, 0.0);<br />
448<br />
449     /*** GSP geographic coordinate */<br />
450     private Point2D gpsCoordinate = new Point2D.Double(0.0, 0.0);<br />
451<br />
452     /*** Flag that indicates whether or not scope is aligned */<br />
453     private boolean aligned = false;<br />
454<br />
455     /*** Flag that indicates whether or not scope is communicating */<br />
456     private boolean communicating = false;<br />
457<br />
458     /*** Flag that indicates whether or not GPS is linked */<br />
459     private boolean gpsLinked = false;<br />
460     /*** GPS Date/Time */<br />
461     private Calendar gpsDateTime = GregorianCalendar.getInstance(TZ);<br />
462     /*** Define longest time that task can be late */<br />
463     private static final long MAX_TARDINESS = 2000L;<br />
464<br />
465     /*** Dialog showing solar hazard warning */<br />
466     private SolarHazardDialog solarHazardDialog<br />
467         = new SolarHazardDialog(null, true);<br />
468<br />
469     /*** Inner class to retrieve information from telescope */<br />
470     class TelescopeInfoTask extends TimerTask {<br />
471         /*** Flag to indicate ok to keep getting info */<br />
472         private boolean ok = true;<br />
473<br />
474         /*** Counter to check status */<br />
475         private int checkCount = 0;<br />
476<br />
477         /*** Called when task is scheduled */<br />
478         public void run() {<br />
479            try {<br />
480                 if (System.currentTimeMillis() - scheduledExecutionTime() >=<br />
481                     MAX_TARDINESS) {<br />
482                         return;  // Too late; skip this execution.<br />
483                 }<br />
484<br />
485                 if ((ok) &#038;&#038; (!communicating)) {<br />
486                     communicating = telescope.isCommunicating();<br />
487                 }<br />
488<br />
489                 if ((ok) &#038;&#038; (communicating) &#038;&#038; (!aligned)) {<br />
490                     aligned = telescope.isAligned();<br />
491                     gpsLinked = telescope.isGpsLinked();<br />
492                 }<br />
493<br />
494                 if ((ok) &#038;&#038; (aligned)) {<br />
495                     synchronized (horizCoord) {<br />
496                         horizCoord.setLocation(telescope.getAzimuthAltitude());<br />
497                     }<br />
498<br />
499                     synchronized (eqCoord) {<br />
500                         eqCoord.setLocation(telescope.getRightAscensionDeclination());<br />
501                     }<br />
502                 }<br />
503<br />
504                 if ((ok) &#038;&#038; (gpsLinked) &#038;&#038; (communicating)) {<br />
505                     Calendar cal = telescope.getGpsDateTime();<br />
506<br />
507                     synchronized (gpsDateTime) {<br />
508                         gpsDateTime.setTime(cal.getTime());<br />
509                     }<br />
510<br />
511                     synchronized (gpsCoordinate) {<br />
512                         gpsCoordinate.setLocation(telescope.getGpsCoordinate());<br />
513                     }<br />
514                 }<br />
515<br />
516                 // Periodically check communications and gps<br />
517                 if (ok) {<br />
518                     checkCount++;<br />
519<br />
520                     if (checkCount > 5) {<br />
521                         checkCount = 0;<br />
522                         gpsLinked = telescope.isGpsLinked();<br />
523                     }<br />
524                 }<br />
525<br />
526            } catch (IOException e) {<br />
527                System.out.println(e);<br />
528            }<br />
529         }<br />
530<br />
531         /*** Cancel task<br />
532          @return True when canceled<br />
533          */<br />
534         public boolean cancel() {<br />
535             ok = false;<br />
536             return super.cancel();<br />
537         }<br />
538<br />
539     }<br />
540<br />
541     /*** Inner class to update the display */<br />
542     class UpdateDisplayTask extends TimerTask {<br />
543         /*** Flag to control whether its ok to continue update */<br />
544         private boolean ok = true;<br />
545<br />
546         /*** Called when timer starts task */<br />
547         public void run() {<br />
548             if (!EventQueue.isDispatchThread()) {<br />
549                 EventQueue.invokeLater(this);<br />
550             } else {<br />
551                 if (ok) {<br />
552                     updateDisplay();<br />
553                 }<br />
554             }<br />
555         }<br />
556<br />
557         /*** Update the display */<br />
558         private void updateDisplay() {<br />
559             updateGpsTextFieldEnabled();<br />
560             updatePositionTextFieldEnabled();<br />
561<br />
562             if ((ok) &#038;&#038; (communicating) &#038;&#038; (aligned)) {<br />
563                 updateHorizontalCoordinates();<br />
564                 updateEquatorialCoordinates();<br />
565             }<br />
566<br />
567             if (gpsLinked) {<br />
568                 updateGps();<br />
569             }<br />
570<br />
571         }<br />
572<br />
573         /***<br />
574          * Cancel update<br />
575          * @return True when canceled<br />
576          */<br />
577         public boolean cancel() {<br />
578             ok = false;<br />
579             azmTextField.setEnabled(ok);<br />
580             altTextField.setEnabled(ok);<br />
581             raTextField.setEnabled(ok);<br />
582             decTextField.setEnabled(ok);<br />
583             communicating = false;<br />
584             gpsLinked = false;<br />
585             updateGpsTextFieldEnabled();<br />
586             aligned = false;<br />
587             return super.cancel();<br />
588         }<br />
589<br />
590         /***<br />
591          * Update local horizontal coordinates (azimuth, altitude) display<br />
592          */<br />
593         private void updateHorizontalCoordinates() {<br />
594<br />
595             if (ok) {<br />
596                 Integer[] azm = getDegreesMinutesSeconds(horizCoord.getX());<br />
597                 azmTextField.setText(dmsFmt.format(<br />
598                     ResourceBundle.getBundle("resources/comm/Telescope").getString("DMS_FORMAT"),<br />
599                     azm));<br />
600             }<br />
601<br />
602             if (ok) {<br />
603                 Integer[] alt = getDegreesMinutesSeconds(horizCoord.getY());<br />
604                 altTextField.setText(dmsFmt.format(<br />
605                     ResourceBundle.getBundle(<br />
606                       "com/raben/telescope/Telescope").getString("DMS_FORMAT"),<br />
607                     alt));<br />
608             }<br />
609<br />
610         }<br />
611<br />
612         /***<br />
613          * Update equatorial coordinates (right ascension, declination) display<br />
614          */<br />
615         private void updateEquatorialCoordinates() {<br />
616             if (ok) {<br />
617<br />
618                 Integer[] ra = getDegreesMinutesSeconds(eqCoord.getX());<br />
619                 raTextField.setText(hmsFmt.format(<br />
620                     ResourceBundle.getBundle(<br />
621                        "com/raben/telescope/Telescope").getString("HMS_FORMAT"),<br />
622                     ra));<br />
623             }<br />
624<br />
625             if (ok) {<br />
626                 Integer[] dec = getDegreesMinutesSeconds(eqCoord.getY());<br />
627                 decTextField.setText(dmsFmt.format(<br />
628                     ResourceBundle.getBundle(<br />
629                       "com/raben/telescope/Telescope").getString("DMS_FORMAT"),<br />
630                     dec));<br />
631             }<br />
632         }<br />
633<br />
634         /***<br />
635          * Update GPS date/time and geographical coordinate<br />
636          */<br />
637         private void updateGps() {<br />
638             // Update date/time<br />
639             if (ok) {<br />
640                 synchronized (gpsDateTime) {<br />
641                     gpsDateTimeTextField.setText(dateTimeFormat.format(<br />
642                         gpsDateTime.getTime()));<br />
643                 }<br />
644             }<br />
645<br />
646             // Update GPS longitude<br />
647             if (ok) {<br />
648                 double lat = 0.0;<br />
649                 double lon = 0.0;<br />
650<br />
651                 synchronized (gpsCoordinate) {<br />
652                     lon = gpsCoordinate.getX();<br />
653                     lat = gpsCoordinate.getY();<br />
654                 }<br />
655<br />
656                 Integer[] longitude = getDegreesMinutesSeconds(lon);<br />
657                 gpsLongitudeTextField.setText(dmsFmt.format(<br />
658                     ResourceBundle.getBundle(<br />
659                     "com/raben/telescope/Telescope").getString("DMS_FORMAT"),<br />
660                         longitude));<br />
661<br />
662                 Integer[] latitude = getDegreesMinutesSeconds(lat);<br />
663                 gpsLatitudeTextfield.setText(dmsFmt.format(<br />
664                     ResourceBundle.getBundle(<br />
665                     "com/raben/telescope/Telescope").getString("DMS_FORMAT"),<br />
666                         latitude));<br />
667             }<br />
668<br />
669         }<br />
670<br />
671         /*** Update GPS date/time, latitude, and longitude text field enable */<br />
672         private void updateGpsTextFieldEnabled() {<br />
673             gpsDateTimeTextField.setEnabled(gpsLinked);<br />
674             gpsLongitudeTextField.setEnabled(gpsLinked);<br />
675             gpsLatitudeTextfield.setEnabled(gpsLinked);<br />
676         }<br />
677<br />
678         /*** Update telescope position text field enable */<br />
679         private void updatePositionTextFieldEnabled() {<br />
680             azmTextField.setEnabled(aligned);<br />
681             altTextField.setEnabled(aligned);<br />
682             raTextField.setEnabled(aligned);<br />
683             decTextField.setEnabled(aligned);<br />
684         }<br />
685<br />
686     }<br />
687 }<br />
</code></p>
<p>Resources</p>
<p>Since the interface uses the Java comm api, you will need to download a copy for your computer platform. Follow the instructions included with the download for installation on your platform. The following list are possible sources for the comm api. The only one tested by us so far is the one from Sun Microsystems.</p>
<p>MS Windows and Sun Solaris: http://java.sun.com/products/javacomm</p>
<p>Linux, MS Windows, Mac OS/X: http://www.rxtx.org</p>
<p>Commercial versions for various platforms: http://www.serialio.com</p>
<p>Documentation for the javax api is available from http://java.sun.com/products/javacomm/javadocs/index.html.</p>
<p>Documentation of the &#8220;official&#8221; Celestron RS232 command sets are available from http://www.celestron.com/telescopes.htm. Product manual can be found by selecting the particlular telescope product.</p>
<p>The &#8220;unofficial&#8221; auxillary command set is documented at http://www.paquettefamily.ca/nexstar/.</p>
<p>Information regarding the computer interface to the Nexstar is available at http://www.nexstarsite.com/PCControl.htm. There is lots of other useful information about using Nexstar telescopes on this site as well.</p>
<p>Online documentation of the Telescope API is available from http://www.raben.com/articles/TelescopeInterface/apidocs/.</p>
<p>Source code for the example application and interface classes may be viewed in html form in this source xref listing.</p>
<p>Mars Aug 27, 2003 06:50 UTC</p>
<p>Source code and Installation</p>
<p>This project has joined the java.net open source community and is now available at telescope.dev.java.net which is hosted by Sun Microsystems and Oreilly Associates, Inc. From that site you may checkout the source code using CVS, join the development team, and contribute to the future development of the project! The telescope.dev.java.net CVS will be the most recent version of the source code. Instructions on how to use CVS are available at that site. Note &#8212; The site does not appear to support anonymous or guest CVS access. You need to register with java.net first and use your registered name to retrieve the code.</p>
<p>The source code may be also be downloaded from http://www.raben.com/downloads/telescope-1.4.1-src.zip</p>
<p>Unzip the zip file in a convenient directory. After unzipping the file you will find a directory called &#8220;Telescope-1.4&#8243;.</p>
<p>Under that directory you will find the following:</p>
<p>    * &#8220;License.txt&#8221; Text file containing the &#8220;BSD&#8221; style license. By downloading the zip file you are agreeing to its terms.<br />
    * &#8220;src&#8221; directory containing the source code<br />
    * &#8220;classes&#8221; directory to contain the Java class files produced by compilation<br />
    * &#8220;dist&#8221; directory containing the telescope.jar file<br />
    * &#8220;build.xml&#8221; file to be used by the &#8220;Ant&#8221; tool</p>
<p>The Java SDK or Java runtime and the java.comm api must already be installed on your system.</p>
<p>If Apache Jakarta Ant has been installed on your computer system, you may re-compile the source code by simply changing to the &#8220;Telescope-1.4.1&#8243; directory and executing the command:</p>
<p>ant telescope</p>
<p>The system variable &#8220;ANT_HOME&#8221; must point to the ant directory. The system variable &#8220;JAVA_HOME&#8221; must point to the J2SDK directory. Both &#8220;java&#8221; and &#8220;ant&#8221; must be in the command line path.</p>
<p>The example applications may be executed by changing to the &#8220;dist&#8221; directory and executing the following on a MS Windows command line:<br />
The ConfigureDialog may be run as a stand-alone application as (on one line):</p>
<p>java -cp telescope.jar;%COMM_HOME%\comm.jar com.raben.telescope.comm.ConfigureDialog</p>
<p>java -cp telescope.jar;%COMM_HOME%\comm.jar com.raben.telescope.comm.SimplisticTest</p>
<p>java -cp telescope.jar;%COMM_HOME%\comm.jar com.raben.telescope.comm.PositionDialog</p>
<p>On MS Windows XP the variable %COMM_HOME% needs to set to location of the javax.comm distribution. (For reasons not understood &#8212; by me at least, the comm.jar doesn&#8217;t load automatically as it should from the jre/lib/ext directory &#8212; maybe because its is compiled from the old jdk1.6. Even more bizarre, %COMM_HOME% cannot point to the jre/lib/ext/comm.jar either &#8212; it must be point elsewhere!! &#8212; then it runs fine).</p>
<p>On LINUX and other UNIX platforms, the command is the same except for the classpath (-cp switch) for example:</p>
<p>java -cp telescope.jar:$COMM_HOME/comm.jar com.raben.telescope.comm.PositionDialog</p>
<p>Please send any questions, comments, or suggestions for enhancements to support@raben.com</p>
]]></content:encoded>
			<wfw:commentRss>http://www.skythisweek.com/2003/09/11/connect-to-a-go-to-gps-telescope-with-java%e2%84%a2-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An introduction to the JulianDay Utility</title>
		<link>http://www.skythisweek.com/2002/04/11/an-introduction-to-the-julianday-utility/</link>
		<comments>http://www.skythisweek.com/2002/04/11/an-introduction-to-the-julianday-utility/#comments</comments>
		<pubDate>Fri, 12 Apr 2002 00:39:55 +0000</pubDate>
		<dc:creator>Vern</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.raben.com/weblog/2002/04/11/an-introduction-to-the-julianday-utility/</guid>
		<description><![CDATA[The Julian Day utility provides routines that are useful when performing astronomical ephemeris computations or simple date arithmetic. The Julian Day or Julian Day Number is the continuous count of days since the year -4712. The JulianDay class implements the algorithms presented by Jean Meeus, Astronomical Algorithms, Willmann-Bell, Inc., 1998, pp 59-66. The following code [...]]]></description>
			<content:encoded><![CDATA[<p>The Julian Day utility provides routines that are useful when performing astronomical ephemeris computations or simple date arithmetic. The Julian Day or Julian Day Number is the continuous count of days since the year -4712. The JulianDay class implements the algorithms presented by Jean Meeus, Astronomical Algorithms, Willmann-Bell, Inc., 1998, pp 59-66. The following code example shows how to use JulianDay class to compute the Julian Day Number for a given date, compute the Gregorian calendar date for a given Julian Day Number, perform simple date arithmetic, calculate day of week from Julian Day Number, and use the utility to format a date for output.</p>
<p>The source code may be downloaded from JulianDay.zip. Simply unzip the file in your favorite directory and review the JulianDayExample.java located in the src/com/raben/examples directory. The JavaDoc for the JulianDay class and the source cross reference are available. If you have installed ant on your system, you can can compile the source and example by changing to the src directory and entering the command:<br />
ant all.</p>
<p>To run the example, change to the dist directory and enter the command:<br />
java -jar JulianDay.jar.<br />
<code><br />
/*<br />
* JulianDayExample.java<br />
*<br />
* Created on March 29, 2002, 12:57 PM<br />
*/</code></p>
<p>package com.raben.example;<br />
import com.raben.util.JulianDay;<br />
/**<br />
*<br />
* @author  Vern Raben<br />
* @version 1.0<br />
*/<br />
public final class JulianDayExample {</p>
<p>public static void main(String[] args) {<br />
/**<br />
* To get the Julian Day for the current<br />
* time, just call the constructor with<br />
* no arguments<br />
*/<br />
JulianDay julianDay=new JulianDay();</p>
<p>// Print out the current JDN<br />
System.out.println(&#8220;Current jdn is &#8220;+julianDay.getJDN());</p>
<p>// Calculate the Julian Day one week ago<br />
julianDay.add(JulianDay.DATE,-7);<br />
System.out.println(&#8220;JulianDay one week ago was &#8221;<br />
+julianDay.getJDN());</p>
<p>// Calculate Julian Day when Sputnik-1 was<br />
// launched (Oct 4, 1957 at 19:26 UTC)<br />
JulianDay sputJD=new JulianDay(1957,JulianDay.OCTOBER,4,19,26);<br />
System.out.println(&#8220;Sputnik-1 was launched at JD &#8221;<br />
+sputJD.getJDN());</p>
<p>// What day of the week was it (0=SUNDAY,1=MONDAY,etc)<br />
System.out.println(&#8220;Day of week was &#8221;<br />
+sputJD.get(JulianDay.DAY_OF_WEEK));</p>
<p>/**<br />
* You may also specify the output date format according to<br />
* java.text.SimpleDateFormat<br />
* Note that this only works for dates after Jan 1970, prior to that<br />
* the date will be printed in sql date format by default<br />
* Also, the date is always UTC<br />
*/<br />
julianDay.setDateFormat(&#8220;yyyy-MM-dd HH:mm:ss&#8221;);<br />
System.out.println(&#8220;Today is &#8220;+julianDay.getDateTimeStr()+&#8221; UTC&#8221;);</p>
<p>}</p>
<p>}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.skythisweek.com/2002/04/11/an-introduction-to-the-julianday-utility/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

