/// <summary> /// Slew to home based on TripPosition already being set /// </summary> /// <param name="axis"></param> private int SlewToHome(AxisId axis) { if (SkyServer.AutoHomeStop) { return(-3); //stop requested } //convert position to mount degrees var a = TripPosition -= 0x00800000; var skyCmd = new SkyGetStepToAngle(SkyQueue.NewId, axis, a); var b = (double)SkyQueue.GetCommandResult(skyCmd).Result; var c = Units.Rad2Deg1(b); var positions = Axes.MountAxis2Mount(); switch (axis) { case AxisId.Axis1: var d = Axes.AxesMountToApp(new[] { c, 0 }); // Convert to local if (SkyServer.SouthernHemisphere) { d[0] = d[0] + 180; } SkyServer.SlewAxes(d[0], positions[1], SlewType.SlewMoveAxis); break; case AxisId.Axis2: var e = Axes.AxesMountToApp(new[] { 0, c }); // Convert to local if (SkyServer.SouthernHemisphere) { e[1] = 180 - e[1]; } SkyServer.SlewAxes(positions[0], e[1], SlewType.SlewMoveAxis); break; default: throw new ArgumentOutOfRangeException(nameof(axis), axis, null); } while (SkyServer.IsSlewing) { //Console.WriteLine(@"slewing"); Thread.Sleep(300); } var _ = new SkyAxisStop(0, axis); //Thread.Sleep(1500); return(0); }