private void HandleGpsEvent(GpsEvent gpsEvent) { if (gpsEvent == null) { return; } if (GoogleSkyWebBrowser.InvokeRequired) { GoogleSkyWebBrowser.Invoke(new Action(() => HandleGpsEvent(gpsEvent))); return; } GoogleSkyCoordinate = new GoogleSkyCs(gpsEvent.Latitude, gpsEvent.Longitude); LogListBox("Got GPS coordinates \n Latitiude:{0} \n Longitude:{1}", GoogleSkyCoordinate.Latitude, GoogleSkyCoordinate.Longitude); var scriptArguements = new object[] { GoogleSkyCoordinate.Latitude, GoogleSkyCoordinate.Longitude, DefaultRange }; try { if (GoogleSkyWebBrowser.Document != null) { GoogleSkyWebBrowser.Document.InvokeScript("updateGoogleSkyCoordinates", scriptArguements); } } catch { UpdateGoogleSkyErrorUi("Unable to update sky coordinates"); } }
private void HandleConnectionEvent(ConnectionEvent connectionEvent) { if (connectionEvent == null) { return; } var result = connectionEvent.Connected; if (result) { UpdateTelescopeUi("Connection Established"); GoogleSkyCoordinate = new GoogleSkyCs(Double.MaxValue, Double.MaxValue); LogListBox("Retrieving GPS coordinates from current location..."); _hardwareHandler.GetGpsCoOrdinates(); } if (result) { return; } UpdateTelescopeErrorUi("Connection Failed"); _hardwareHandler.ConnectToArduino(); CurrentTask("Attempting to reconnect"); }
public static EquatorialCs GoogleSkyToEquatorial(GoogleSkyCs gcs) { var declination = gcs.Latitude; var rightAscension = (gcs.Longitude + 180) / 15; var hourAngle = LocalSiderealTime - rightAscension; return(new EquatorialCs(rightAscension, declination, hourAngle)); }
public void GoogleSkyToEquatorialAndBack() { var start = new GoogleSkyCs(5, 5); var middle = CoordinateConverter.GoogleSkyToEquatorial(start); var end = CoordinateConverter.EquatorialToGoogleSky(middle); Assert.AreEqual(start.Latitude, end.Latitude, DELTA); Assert.AreEqual(start.Longitude, start.Longitude, DELTA); }
public void GoogleSkyToGodKnowsAndBack() { var start = new GoogleSkyCs(180, -180); var a = CoordinateConverter.GoogleSkyToHorizonatal(start); var b = CoordinateConverter.HorizontalToGoogleSky(a); var c = CoordinateConverter.GoogleSkyToHorizonatal(b); var d = CoordinateConverter.HorizontalToGoogleSky(c); var e = CoordinateConverter.GoogleSkyToHorizonatal(d); var f = CoordinateConverter.HorizontalToGoogleSky(e); var g = CoordinateConverter.GoogleSkyToHorizonatal(f); var end = CoordinateConverter.HorizontalToGoogleSky(g); Assert.AreEqual(start.Latitude, end.Latitude, DELTA); Assert.AreEqual(start.Longitude, end.Longitude, DELTA); }
/// <summary> /// Converts horizontal coordinates to coordinates the Google Sky object can process /// </summary> /// <param name="azimuth"></param> /// <param name="altitude"></param> /// <returns> Returns the latitude, longitude, and the zoom to the Google Sky object</returns> private double[] HorizontalToGoogleSkyDouble(int azimuth, int altitude) { var horizontal = new HorizontalCs(azimuth, altitude); try { GoogleSkyCoordinate = CoordinateConverter.HorizontalToGoogleSky(horizontal); return(new[] { GoogleSkyCoordinate.Latitude, GoogleSkyCoordinate.Longitude, 9000 }); } catch (Exception ex) { LogListBox("Exception occured: {0}", ex.Message); return(null); } }
private void HandleOrientationEvent(OrientationEvent orientationEvent) { if (orientationEvent == null) { return; } if (GoogleSkyWebBrowser.InvokeRequired) { GoogleSkyWebBrowser.Invoke(new Action(() => HandleOrientationEvent(orientationEvent))); return; } GoogleSkyCoordinate = orientationEvent.Orientation; LogListBox("Update Google Sky coordinates \n Latitiude:{0} \n Longitude:{1}", GoogleSkyCoordinate.Latitude, GoogleSkyCoordinate.Longitude); GoogleSkyWebBrowser.Document.InvokeScript("updateGoogleSkyCoordinates", new object[] { new object[] { GoogleSkyCoordinate.Latitude, GoogleSkyCoordinate.Longitude, DefaultRange } }); }
private void btnMoveMap_Click(object sender, EventArgs e) { if (!isDECValid || !isRAValid) { MessageBox.Show("Invalid coordinates, please check your right ascencion and declination coordinates", "Invalid Inputs", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var RA = Array.ConvertAll(txtBoxCoordinateRA.Text.Split(':'), double.Parse); var DEC = Array.ConvertAll(txtBoxCoordinateDEC.Text.Split(':'), double.Parse); GoogleSkyCoordinate = CoordinateConverter.EquatorialToGoogleSky(new EquatorialCs(RA, DEC)); LogListBox("Update Google Sky coordinates \n Latitiude:{0} \n Longitude:{1}", GoogleSkyCoordinate.Latitude, GoogleSkyCoordinate.Longitude); GoogleSkyWebBrowser.Document.InvokeScript("updateGoogleSkyCoordinates", new object[] { new object[] { GoogleSkyCoordinate.Latitude, GoogleSkyCoordinate.Longitude, DefaultRange } }); }
private void btnSelectPOI_Click(object sender, EventArgs e) { var selectedPlacemark = (Placemark)comboBoxPOI.SelectedItem; if (comboBoxPOI.SelectedItem == null) { return; } var range = selectedPlacemark.Range; GoogleSkyCoordinate = new GoogleSkyCs(selectedPlacemark.Latitude, selectedPlacemark.Longitude); GoogleSkyWebBrowser.Document.InvokeScript("addPlacemark", new object[] { new object[] { selectedPlacemark.Latitude, selectedPlacemark.Longitude, selectedPlacemark.Name } }); LogListBox("Update Google Sky coordinates \n Latitiude:{0} \n Longitude:{1}", GoogleSkyCoordinate.Latitude, GoogleSkyCoordinate.Longitude); if (GoogleSkyWebBrowser.Document != null) { GoogleSkyWebBrowser.Document.InvokeScript("updateGoogleSkyCoordinates", new object[] { new object[] { GoogleSkyCoordinate.Latitude, GoogleSkyCoordinate.Longitude, range } }); } }
public static HorizontalCs GoogleSkyToHorizonatal(GoogleSkyCs gcs) { var ecs = GoogleSkyToEquatorial(gcs); return(EquatorialToHorizontal(ecs)); }
public OrientationEvent(GoogleSkyCs orientation) { Orientation = orientation; }
/// <summary> /// Request the AutoSky Telescope to point to a new direction. /// </summary> /// <param name="coordinate"> the GoogleSky coordinate you wish to use</param> /// <param name="telescopeUp"></param> /// <param name="telescopeDown"></param> public void RequestNewPosition(GoogleSkyCs coordinate) { //ArduinoMessageEvent += RetrieveOrientationEvent(); stop = false; if (!CheckConnection()) { return; } var destinationHcs = CoordinateConverter.GoogleSkyToHorizonatal(coordinate); var altitude = destinationHcs.Altitude; var azimuth = destinationHcs.Azimuth; //First, set the altitude using the 3axis data //Y arrow points towards front of telescope. Z arrow points straight up. (X axis not used.) const int maxIterations = 500; for (var i = 0; i < maxIterations; i++) { if (stop) { break; } ArduinoMessageEvent += OnArduinoMessageEvent; GetOrientation(); semi.WaitOne(800); ArduinoMessageEvent -= OnArduinoMessageEvent; if (or == null) { ArduinoMessageEvent(new ErrorEvent("Didn't get orientation Data!")); StopMotors(); continue; } var gcs = new GoogleSkyCs(or.Orientation.Latitude, or.Orientation.Longitude); or = null; var currentHcs = CoordinateConverter.GoogleSkyToHorizonatal(gcs); var currentAlt = currentHcs.Altitude; var currentHeading = currentHcs.Azimuth; ArduinoMessageEvent(new ErrorEvent(String.Format("Alt: {0},Azi: {1}", currentAlt, currentHeading))); //Too close to adjust var altComplete = false; if (Math.Abs(altitude - currentAlt) < 5) { if (Math.Abs(altitude - currentAlt) < 3) { UpDownStop(); altComplete = true; } else { altComplete = false; if (altitude > currentAlt) { telescopeUp(); } else { telescopeDown(); } } } else { altComplete = false; if (altitude > currentAlt) { telescopeUp(); } else { telescopeDown(); } } //Too close to adjust var aziComplete = false; if (Math.Abs(azimuth - currentHeading) < 40) { if (Math.Abs(azimuth - currentHeading) < 10) { LeftRightStop(); aziComplete = true; } else { aziComplete = false; var a = azimuth - currentHeading; var b = currentHeading - azimuth; if (a < 0) { a = a + 360; } if (b < 0) { b = b + 360; } if (a < b) { telescopeRightSlow(); } else { telescopeLeftSlow(); } } } else { aziComplete = false; var a = azimuth - currentHeading; var b = currentHeading - azimuth; if (a < b) { telescopeRight(); } else { telescopeLeft(); } } if (!aziComplete || !altComplete) { continue; } ArduinoMessageEvent(new ErrorEvent("Success! Pointing where we want to!")); StopMotors(); break; } StopMotors(); }
private void btnTelescopeToMap_Click(object sender, EventArgs e) { GoogleSkyCoordinate = new GoogleSkyCs(Double.MaxValue, Double.MaxValue); _hardwareHandler.GetOrientation(); }