public static AltAzm RaDec2AltAzm(Coordinates coord, 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.SetJ2000(coord.Ra, coord.Dec); tfm.Refresh(); var res = new AltAzm(tfm.ElevationTopocentric, tfm.AzimuthTopocentric); 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 override void GoToPosition(AltAzm pos) { var buf = this.DoubleToBytes(pos.Alt); if (pos.Azm < 10 || pos.Azm > 170)//Unsafe Azm position { if (pos.Alt < 90 || pos.Alt > 270) throw new InvalidValueException("Azimuth position is out of safety range"); // Move Alt axis to safe position before moving Azm axis to unsafe position this.SendCommandToDevice(DeviceID.DecAltMotor, DeviceCommands.MC_GOTO_FAST, 0, buf); var tBeginMove = Environment.TickCount; while (true) { Thread.Sleep(100); if (this.IsSlewDone(DeviceID.DecAltMotor)) break; if (tBeginMove + 60000 < Environment.TickCount) throw new DriverException("Can not move Alt axis to save position"); } } else { this.SendCommandToDevice(DeviceID.DecAltMotor, DeviceCommands.MC_GOTO_FAST, 0, buf); } buf = this.DoubleToBytes(pos.Azm); this.SendCommandToDevice(DeviceID.RaAzmMotor, DeviceCommands.MC_GOTO_FAST, 0, buf); }
private void ProcessAltAzm(AltAzm newVal, AltAzm oldVal, int time) { if (this.lastAltAzm > 0) { var RaRate = this.GetRateRa(this.tp.TrackingRate, this.tp.TrackingMode); var dT = time - this.lastAltAzm; var azm = /*Const.TRACKRATE_SIDEREAL -*/ (newVal.Azm - oldVal.Azm)*1000/dT; var dec = (newVal.Alt - oldVal.Alt)*1000/dT; this.AzmValues.Add(azm, Const.TRACKRATE_SIDEREAL - RaRate); // var azmf = kfilt.Correct(azm); if (azm.Equals(0d)) this.setTrackingRate(this.tp.TrackingRate, this.tp.TrackingMode); Debug.WriteLine(string.Format("[{0}] azm={1,-12} azmVal={2,9:f6} sco={3,9:f6} sMed={4,9:f6} sSco={5,9:f6} med={6,9:f6}", DateTime.Now, DMS.FromDeg(newVal.Azm).ToString(":"), azm, this.AzmValues.sco, this.AzmValues.cMed, this.AzmValues.cSco , this.AzmValues.Median)); } else { //kfilt.SetState(newVal.Azm, 0.0); } this.lastAltAzm = time; }
public void Sync(AltAzm coord) { lock (_sync) { ti.SyncAltAz(coord); } }
public bool Slew(AltAzm coord) { this.CheckPark(); if (this.telescopeMode != TelescopeMode.Normal) return false; this.tp.IsAtHome = false; lock (_sync) { SlewWaitHandle.Reset(); this.ti.AltAzm = coord; this.telescopeMode = TelescopeMode.Slewing; Thread.Sleep(300); } return true; }