static public Coordinates AltAzm2RaDec(AltAzm altAzm, LatLon location, DateTime time, double elevation) { var JDdate = JDtime(time); var tfm = new ASCOM.Astrometry.Transform.Transform(); var jdtt = tfm.JulianDateTT; //tfm.JulianDateTT = JDdate; tfm.SiteElevation = elevation * 1000; tfm.SiteLatitude = location.Lat; tfm.SiteLongitude = location.Lon; tfm.SiteTemperature = 0; tfm.SetAzimuthElevation(altAzm.Azm, altAzm.Alt); tfm.Refresh(); // var res = new Coordinates(tfm.RAJ2000, tfm.DecJ2000); // var res = new Coordinates(tfm.RAApparent, tfm.DECApparent); var res = new Coordinates(tfm.RATopocentric, tfm.DECTopocentric); return(res); }
static public RaDec AltAz2RaDec(AltAz altAzm, LatLon location, DateTime time, double elevation) { var utils = new ASCOM.Astrometry.AstroUtils.AstroUtils(); var MJDdate = utils.CalendarToMJD(time.Day, time.Month, time.Year); MJDdate += time.TimeOfDay.TotalDays; var tfm = new ASCOM.Astrometry.Transform.Transform(); tfm.JulianDateTT = MJDdate; tfm.SiteElevation = elevation * 1000; tfm.SiteLatitude = location.Lat; tfm.SiteLongitude = location.Lon; tfm.SiteTemperature = 0; tfm.SetAzimuthElevation(altAzm.Az, altAzm.Alt); tfm.Refresh(); var res = new RaDec(tfm.RAJ2000, tfm.DecJ2000); return(res); }
public static Coordinates AltAzm2RaDec(AltAzm altAzm, LatLon location, DateTime time, double elevation) { var utils = new ASCOM.Astrometry.AstroUtils.AstroUtils(); var MJDdate = utils.CalendarToMJD(time.Day, time.Month, time.Year); MJDdate += time.TimeOfDay.TotalDays; var tfm = new ASCOM.Astrometry.Transform.Transform(); tfm.JulianDateTT = MJDdate; tfm.SiteElevation = elevation * 1000; tfm.SiteLatitude = location.Lat; tfm.SiteLongitude = location.Lon; tfm.SiteTemperature = 0; tfm.SetAzimuthElevation(altAzm.Azm, altAzm.Alt); tfm.Refresh(); var res = new Coordinates(tfm.RAJ2000, tfm.DecJ2000); return res; }
public static Coordinates AltAzm2RaDec(AltAzm altAzm, LatLon location, DateTime time, double elevation) { var JDdate = JDtime(time); var tfm = new ASCOM.Astrometry.Transform.Transform(); var jdtt = tfm.JulianDateTT; //tfm.JulianDateTT = JDdate; tfm.SiteElevation = elevation * 1000; tfm.SiteLatitude = location.Lat; tfm.SiteLongitude = location.Lon; tfm.SiteTemperature = 0; tfm.SetAzimuthElevation(altAzm.Azm, altAzm.Alt); tfm.Refresh(); // var res = new Coordinates(tfm.RAJ2000, tfm.DecJ2000); // var res = new Coordinates(tfm.RAApparent, tfm.DECApparent); var res = new Coordinates(tfm.RATopocentric, tfm.DECTopocentric); return res; }
private async void OnConnectToTelescope() { if (MountConnected) { MountConnected = false; _commHandler.Disconnect(); ScopeName = string.Empty; ScopeHardware = string.Empty; _oatMount = null; _commHandler = null; RequeryCommands(); } else { RequeryCommands(); Log.WriteLine("Mount: Connect to OAT requested"); if (await this.ChooseTelescope()) { try { //await +.WaitAsync(); Log.WriteLine("Mount: Request OAT Firmware version"); var result = await _oatMount.SendCommand("GVP#,#"); if (!result.Success) { Log.WriteLine("Mount: Unable to communicate with OAT. {0}", result.StatusMessage); throw new AccessViolationException("Cannot connect. " + result.StatusMessage); } Log.WriteLine("Mount: Connected to OAT. Requesting firmware version.."); var resultNr = await _oatMount.SendCommand("GVN#,#"); ScopeName = $"{result.Data} {resultNr.Data}"; var hardware = await _oatMount.SendCommand("XGM#,#"); Log.WriteLine("Mount: Hardware is {0}", hardware); var hwParts = hardware.Data.Split(','); var raParts = hwParts[1].Split('|'); var decParts = hwParts[2].Split('|'); ScopeHardware = $"{hwParts[0]} board RA {raParts[0]}, {raParts[1]}T DEC {decParts[0]}, {decParts[1]}T"; _transform.SiteElevation = 0; // _oatMount.SiteElevation; Log.WriteLine("Mount: Getting OAT Latitude"); _transform.SiteLatitude = await _oatMount.GetSiteLatitude(); Log.WriteLine("Mount: Received Latitude {0}. Getting OAT Longitude...", _util.HoursToHMS(_transform.SiteLatitude, ":", ":", ":")); _transform.SiteLongitude = await _oatMount.GetSiteLongitude(); Log.WriteLine("Mount: Received Longitude {0}.", _util.HoursToHMS(_transform.SiteLongitude, ":", ":", ":")); _transform.SetAzimuthElevation(0, 90); var lst = _transform.RATopocentric; var lstS = _util.HoursToHMS(lst, "", "", ""); Log.WriteLine("Mount: Current LST is {0}. Sending to OAT.", _util.HoursToHMS(lst, "h", "m", "s")); var stringResult = await RunCustomOATCommandAsync(string.Format(":SHL{0}#,n", _util.HoursToHMS(lst, "", "", ""))); Log.WriteLine("Mount: Getting current OAT position"); await UpdateCurrentCoordinates(); TargetDECDegree = CurrentDECDegree; TargetDECMinute = CurrentDECMinute; TargetDECSecond = CurrentDECSecond; TargetRAHour = CurrentRAHour; TargetRAMinute = CurrentRAMinute; TargetRASecond = CurrentRASecond; Log.WriteLine("Mount: Current OAT position is RA: {0:00}:{1:00}:{2:00} and DEC: {3:000}*{4:00}'{5:00}", CurrentRAHour, CurrentRAMinute, CurrentRASecond, CurrentDECDegree, CurrentDECMinute, CurrentDECSecond); Log.WriteLine("Mount: Getting current OAT RA steps/degree..."); string steps = await RunCustomOATCommandAsync(string.Format(":XGR#,#")); Log.WriteLine("Mount: Current RA steps/degree is {0}. Getting current DEC steps/degree...", steps); _raStepsPerDegree = int.Parse(steps); steps = await RunCustomOATCommandAsync(string.Format(":XGD#,#")); Log.WriteLine("Mount: Current DEC steps/degree is {0}. Getting current Speed factor...", steps); _decStepsPerDegree = int.Parse(steps); OnPropertyChanged("RAStepsPerDegree"); OnPropertyChanged("DECStepsPerDegree"); steps = await RunCustomOATCommandAsync(string.Format(":XGS#,#")); Log.WriteLine("Mount: Current Speed factor is {0}...", steps); SpeedCalibrationFactor = float.Parse(steps, _oatCulture); //Log.WriteLine("Mount: Get OAT Tracking speed..."); //TrackingSpeed = await GetTrackingSpeed(); //Log.WriteLine("Mount: Tracking speed is {0:0.0000}.", TrackingSpeed); Log.WriteLine("Mount: Reading Current OAT HA..."); await ReadHA(); MountConnected = true; Log.WriteLine("Mount: Successfully connected and configured!"); } catch (Exception ex) { Log.WriteLine("Mount: Failed to connect and configure OAT! {0}", ex.Message); MessageBox.Show("Error trying to connect to OpenAstroTracker. " + ex.Message, "Connection Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { //exclusiveAccess.Release(); } } } }
private async void OnConnectToTelescope() { if (MountConnected) { MountConnected = false; _commHandler.Disconnect(); _oatMount = null; _commHandler = null; RequeryCommands(); } else { RequeryCommands(); if (await this.ChooseTelescope()) { try { //await +.WaitAsync(); var result = await _oatMount.SendCommand("GVP#,#"); if (!result.Success) { throw new AccessViolationException("Cannot connect. " + result.StatusMessage); } var resultNr = await _oatMount.SendCommand("GVN#,#"); ScopeName = $"{result.Data} {resultNr.Data}"; _transform.SiteElevation = 0; // _oatMount.SiteElevation; _transform.SiteLatitude = await _oatMount.GetSiteLatitude(); _transform.SiteLongitude = await _oatMount.GetSiteLongitude(); _transform.SetAzimuthElevation(0, 90); var lst = _transform.RATopocentric; var lstS = _util.HoursToHMS(lst, "", "", ""); Log("LST: {0}", _util.HoursToHMS(lst, "h", "m", "s")); var stringResult = await RunCustomOATCommandAsync(string.Format(":SHL{0}#,n", _util.HoursToHMS(lst, "", "", ""))); lst -= _util.HMSToHours("02:58:51"); Log("HA: {0}", _util.HoursToHMS(lst, "h", "m", "s")); await UpdateCurrentCoordinates(); TargetDECDegree = CurrentDECDegree; TargetDECMinute = CurrentDECMinute; TargetDECSecond = CurrentDECSecond; TargetRAHour = CurrentRAHour; TargetRAMinute = CurrentRAMinute; TargetRASecond = CurrentRASecond; string steps = await RunCustomOATCommandAsync(string.Format(":XGR#,#")); _raStepsPerDegree = int.Parse(steps); steps = await RunCustomOATCommandAsync(string.Format(":XGD#,#")); _decStepsPerDegree = int.Parse(steps); OnPropertyChanged("RAStepsPerDegree"); OnPropertyChanged("DECStepsPerDegree"); steps = await RunCustomOATCommandAsync(string.Format(":XGS#,#")); SpeedCalibrationFactor = float.Parse(steps, _oatCulture); await ReadHA(); MountConnected = true; } catch (Exception ex) { MessageBox.Show("Error trying to connect to OpenAstroTracker. " + ex.Message, "Connection Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { //exclusiveAccess.Release(); } } } }