From d0406b32dd2c4b312a80a092a16ce6157044baef Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 21 Sep 2020 23:04:58 +0100 Subject: [PATCH] Added ability to unpark telescope Added extra logging information to the "isslewing test" --- .../TelescopeUnitTests.cs | 8 ++--- Meade.net.Telescope/Telescope.cs | 36 +++++++++++++++---- Meade.net/MeadeTelescopeBase.cs | 2 +- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 9ccb9e2..e483868 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -947,7 +947,7 @@ namespace Meade.net.Telescope.UnitTests { var result = _telescope.CanUnpark; - Assert.That(result, Is.False); + Assert.That(result, Is.True); } [Test] @@ -1581,11 +1581,9 @@ namespace Meade.net.Telescope.UnitTests } [Test] - public void Unpark_ThenThrowsException() + public void Unpark_ThenDoesNotThrowException() { - var excpetion = Assert.Throws(() => { _telescope.Unpark(); }); - - Assert.That(excpetion.Method, Is.EqualTo("Unpark")); + Assert.DoesNotThrow(() => { _telescope.Unpark(); }); } [Test] diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 090ac9c..9bad4f3 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1073,8 +1073,8 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanUnpark", "Get - " + false); - return false; + LogMessage("CanUnpark", "Get - " + true); + return true; } } @@ -1877,7 +1877,7 @@ namespace ASCOM.Meade.net bool isSlewing = result.Trim() != string.Empty; - LogMessage("Slewing Get", $"Result = {isSlewing}"); + LogMessage("Slewing Get", $"Result = {isSlewing} ({result.Trim()}"); return isSlewing; } @@ -2212,9 +2212,33 @@ namespace ASCOM.Meade.net public void Unpark() { - //todo heard a rumour that it's possible to unpark an LX200GPS. - LogMessage("Unpark", "Not implemented"); - throw new MethodNotImplementedException("Unpark"); + LogMessage("Unpark", "Parking telescope"); + + if (!AtPark) + return; + + SharedResourcesWrapper.SendChar(":I#"); + //:I# LX200 GPS Only - Causes the telescope to cease current operations and restart at its power on initialization. + //Returns: X once the handset restart has completed + + //todo implement the + //todo make sure that the telescope has the correct date and time. + //UTCDate = DateTime.UtcNow; + + + + var utcCorrection = GetUtcCorrection(); + var localDateTime = DateTime.UtcNow - utcCorrection; + + //localDateTime: HH: mm: ss + SharedResourcesWrapper.SendBlind($":hI{localDateTime:yyMMddhhmmss}#"); + //:hIYYMMDDHHMMSS# + //Bypass handbox entry of daylight savings, date and time.Use the values supplied in this command.This feature is + //intended to allow use of the Autostar II from permanent installations where GPS reception is not possible, such as within + //metal domes. This command must be issued while the telescope is waiting at the initial daylight savings prompt. + //Returns: 1 – if command was accepted. + + AtPark = false; } #endregion diff --git a/Meade.net/MeadeTelescopeBase.cs b/Meade.net/MeadeTelescopeBase.cs index a3728da..8728524 100644 --- a/Meade.net/MeadeTelescopeBase.cs +++ b/Meade.net/MeadeTelescopeBase.cs @@ -83,7 +83,7 @@ namespace ASCOM.Meade.net /// public static void LogMessage(string identifier, string message, params object[] args) { - var msg = String.Format(message, args); + var msg = string.Format(message, args); Tl.LogMessage(identifier, msg); }