View Javadoc
1 /* 2 * CelestronCommand.java 3 * 4 * Created on Sept 9, 2003, 12:34 PM 5 * 6 * Copyright (c) 2003, Raben Systems, Inc. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions are met: 11 * 12 * Redistributions of source code must retain the above copyright notice, 13 * this list of conditions and the following disclaimer. 14 * 15 * Redistributions in binary form must reproduce the above copyright notice, 16 * this list of conditions and the following disclaimer in the documentation 17 * and/or other materials provided with the distribution. 18 * 19 * Neither the name of Raben Systems, Inc. nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE.* 34 */ 35 36 package com.raben.telescope.comm; 37 import java.awt.geom.Point2D; 38 import java.util.Calendar; 39 40 /*** 41 * Facade to generate command string for various Celestron telescope models 42 * @author Vern Raben 43 */ 44 public class MeadeCommand { 45 46 /*** Telescope model selected */ 47 private TelescopeModel telescopeModel = 48 TelescopeModel.MEADE_LX200; 49 50 /*** Adapter to encode/decode telescope commands */ 51 private MeadeCoordinateConverter coordinateConverter = 52 new MeadeCoordinateConverter(); 53 54 /*** Define null char */ 55 private static final char NULL_CHAR = Character.MIN_VALUE; 56 57 /*** Creates a new instance of CelestronCommandAdapter */ 58 public MeadeCommand() { 59 } 60 61 /*** 62 * Set telescope model 63 * @param model Telescope model 64 */ 65 public void setTelescopeModel(TelescopeModel model) { 66 this.telescopeModel = model; 67 coordinateConverter.setTelescopeModel(model); 68 } 69 70 /*** 71 * Get telescope model 72 * @return The telescope model 73 */ 74 public TelescopeModel getTelescopeModel() { 75 return this.telescopeModel; 76 } 77 78 /*** 79 * Set whether high precision mode should be used 80 * @param highPrecision True if high precision coordinates 81 * ISSUE - what if high precision not available ?? 82 * ISSUE - maybe this should be protected and set indirectly 83 * by telescope model, not user 84 */ 85 public void setHighPrecision(boolean highPrecision) { 86 coordinateConverter.setHighPrecision(highPrecision); 87 } 88 89 /*** 90 * Check if high precision coordinates are set 91 * @return true if high precision (24 bit) mode 92 */ 93 public boolean isHighPrecision() { 94 return coordinateConverter.isHighPrecision(); 95 } 96 97 /*** 98 * Get goto azimuth and altitude command string 99 * @param azimuth in degress (0 to 360) 100 * @param altitude in degrees (0 to 90) 101 * @return Command string for selected telescope model 102 */ 103 public String goToAzimuthAltitude(double azimuth, double altitude) { 104 String cmdStr = ""; 105 106 if ((!Double.isNaN(azimuth)) && (!Double.isNaN(altitude))) { 107 } 108 109 return cmdStr; 110 111 } 112 113 /*** 114 * Right ascension target command string 115 * @param ra Right ascension in hours (0 to 24) 116 * @return Command string 117 */ 118 public String rightAscensionTarget(double ra) { 119 return ":Sr" +coordinateConverter.encodeRightAscensionAsString(ra) + "#"; 120 } 121 122 /*** 123 * Declination target command string 124 * @param decl Delination in degrees (-90 to 90) 125 * @return command string 126 */ 127 public String declinationTarget(double decl) { 128 return ":Sd" + coordinateConverter.encodeDeclinationAsString(decl) + "#"; 129 } 130 /*** 131 * Get azimuth command 132 * @return Command to get azimuth 133 */ 134 public String getAzimuth() { 135 return ":GZ#"; 136 } 137 138 /*** 139 * Get altitude command 140 * @return Command to get altitude 141 */ 142 public String getAltitude() { 143 return ":GA#"; 144 } 145 146 /*** 147 * Get right ascension command 148 * @return Command string 149 */ 150 public String getRightAscension() { 151 return ":GR#"; 152 } 153 154 /*** 155 * Get declination command 156 * @return Command string 157 */ 158 public String getDeclination() { 159 return ":GD#"; 160 } 161 162 163 /*** 164 * Get hand control version command 165 * @return Command to get hand control version 166 */ 167 public String handControlVersion() { 168 String cmdStr = "V"; 169 return cmdStr; 170 } 171 172 /*** 173 * Get cancel goto command 174 * @return Command to cancel goto 175 */ 176 public String cancelGoTo() { 177 return ":Q#"; 178 } 179 180 /*** Get alignment complete command 181 * @return Command to check if alignment complete 182 */ 183 public String alignmentComplete() { 184 String cmdStr = "J"; 185 return cmdStr; 186 } 187 188 /*** 189 * Tracking mode command string 190 * @param mode 0=off,1=altaz,2=eq-n,3=eq-s 191 * @return command string 192 */ 193 public String trackingMode(int mode) { 194 String cmd = null; 195 196 switch(mode) { 197 case 0: 198 cmd = ":AL#"; 199 break; 200 case 1: 201 cmd = ":AA#"; 202 break; 203 case 2: 204 cmd = ":AP#"; 205 break; 206 case 3: 207 cmd = ":AP#"; 208 break; 209 } 210 211 return cmd; 212 } 213 214 /*** 215 * Turn on GPS and check if it links 216 * @return command string 217 */ 218 public String gpsLinked() { 219 return ":gT#"; 220 } 221 222 /*** Command to get GPS NEMA string 223 * @return command string 224 */ 225 public String nema() { 226 return ":gps#"; 227 } 228 229 /*** 230 * Slew rate command 231 * @param direction 232 * @param rate 233 * @return command string 234 */ 235 public String slewRate(int rate) { 236 String cmd = null; 237 238 switch(rate) { 239 case 0: 240 cmd = ":Q#"; 241 break; 242 case 1: 243 case 2: 244 cmd = ":RG#"; 245 break; 246 case 3: 247 case 4: 248 cmd = ":RC#"; 249 break; 250 case 5: 251 case 6: 252 case 7: 253 cmd = ":RM#"; 254 break; 255 256 case 8: 257 case 9: 258 cmd = ":RS#"; 259 break; 260 261 } 262 263 return cmd; 264 } 265 266 public String slewNorth() { 267 return ":Mn#"; 268 } 269 270 public String slewSouth() { 271 return ":Ms#"; 272 } 273 274 public String slewEast() { 275 return ":Me#"; 276 } 277 278 public String slewWest() { 279 return ":Mw#"; 280 } 281 282 public double decodeAzimuthString(String azimuthString) { 283 return coordinateConverter.decodeAzimuthString(azimuthString); 284 } 285 286 public double decodeAltitudeString(String altitudeString) { 287 return coordinateConverter.decodeAltitudeString(altitudeString); 288 } 289 290 public double decodeRightAscensionString(String raStr) { 291 return coordinateConverter.decodeRightAscensionString(raStr); 292 } 293 294 public Point2D decodeCoordinatesFromNemaString(String nemaStr) { 295 return coordinateConverter.decodeCoordinatesFromNemaString(nemaStr); 296 } 297 298 public Calendar decodeTimeFromNemaString(String nemaStr) { 299 return coordinateConverter.decodeTimeFromNemaString(nemaStr); 300 } 301 302 }

This page was automatically generated by Maven