From cc5eabdfab0e04cc5dac40a8ca0f2c55b00887f8 Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 6 May 2019 23:10:05 +0100 Subject: [PATCH] Implemented slew to target --- MeadeAutostar497/AscomClasses/Telescope.cs | 8 ++++---- .../Controller/ITelescopeController.cs | 2 ++ .../Controller/TelescopeController.cs | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/MeadeAutostar497/AscomClasses/Telescope.cs b/MeadeAutostar497/AscomClasses/Telescope.cs index b584e82..f3a966d 100644 --- a/MeadeAutostar497/AscomClasses/Telescope.cs +++ b/MeadeAutostar497/AscomClasses/Telescope.cs @@ -804,14 +804,14 @@ namespace ASCOM.MeadeAutostar497 public void SlewToTarget() { - tl.LogMessage("SlewToTarget", "Not implemented"); - throw new ASCOM.MethodNotImplementedException("SlewToTarget"); + tl.LogMessage("SlewToTarget", "Executing"); + _telescopeController.SlewToTarget(); } public void SlewToTargetAsync() { - tl.LogMessage("SlewToTargetAsync", "Not implemented"); - throw new ASCOM.MethodNotImplementedException("SlewToTargetAsync"); + tl.LogMessage("SlewToTargetAsync", "Executing"); + _telescopeController.SlewToTargetAsync(); } public bool Slewing diff --git a/MeadeAutostar497/Controller/ITelescopeController.cs b/MeadeAutostar497/Controller/ITelescopeController.cs index 2e7b7b4..10c792d 100644 --- a/MeadeAutostar497/Controller/ITelescopeController.cs +++ b/MeadeAutostar497/Controller/ITelescopeController.cs @@ -28,5 +28,7 @@ namespace ASCOM.MeadeAutostar497.Controller void SlewToAltAz(double azimuth, double altitude); void SlewToAltAzAsync(double azimuth, double altitude); void SyncToTarget(); + void SlewToTarget(); + void SlewToTargetAsync(); } } \ No newline at end of file diff --git a/MeadeAutostar497/Controller/TelescopeController.cs b/MeadeAutostar497/Controller/TelescopeController.cs index f79bc7a..ed8e5b1 100644 --- a/MeadeAutostar497/Controller/TelescopeController.cs +++ b/MeadeAutostar497/Controller/TelescopeController.cs @@ -633,6 +633,24 @@ namespace ASCOM.MeadeAutostar497.Controller throw new ASCOM.InvalidOperationException("Unable to perform sync"); } + public void SlewToTarget() + { + SlewToTargetAsync(); + + while (Slewing) + { + Util.WaitForMilliseconds(200); + } + } + + public void SlewToTargetAsync() + { + if (TargetDeclination == INVALID_PARAMETER || TargetRightAscension == INVALID_PARAMETER ) + throw new ASCOM.InvalidOperationException("No target selected to slew to."); + + DoSlewAsync(true); + } + //todo remove the polar parameter and split method into two. private void DoSlewAsync( bool polar) {