From 14b56517958893cf86b73905629785e0dd124e00 Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 9 Feb 2021 21:57:42 +0000 Subject: [PATCH] Made alteration to IsSlewing response when the LX200 returns a buffer of rubbish. --- .../TelescopeUnitTests.cs | 4 +-- Meade.net.Telescope/Telescope.cs | 34 ++++++++----------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 178e0d4..1afc3e7 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -2313,8 +2313,8 @@ namespace Meade.net.Telescope.UnitTests [TestCase(TelescopeList.LX200CLASSIC,"","|", true)] [TestCase(TelescopeList.LX200CLASSIC, "", "||||||||", true)] [TestCase(TelescopeList.LX200CLASSIC, "", "", false)] - //[TestCase(TelescopeList.LX200CLASSIC, "", "[FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF] [FF][FF][FF][FF][FF][FF]", false)] //The test case below is this same string encoded to return exactly what the telescope will return. - [TestCase(TelescopeList.LX200CLASSIC, "", "\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff \x00ff\x00ff\x00ff\x00ff\x00ff\x00ff", true)] + [TestCase(TelescopeList.LX200CLASSIC, "", "[FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF] [FF][FF][FF][FF][FF][FF]", false)] //The test case below is this same string encoded to return exactly what the telescope will return. + [TestCase(TelescopeList.LX200CLASSIC, "", "\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff \x00ff\x00ff\x00ff\x00ff\x00ff\x00ff", false)] [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "|", true)] [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "", false)] public void Slewing_WhenTelescopeNotSlewing_ThenReturnsFalse(string productName, string firmwareVersion, string response, bool isSlewing) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 39837d0..bf06b16 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1167,6 +1167,7 @@ namespace ASCOM.Meade.net { get { + //todo make this return false for non LX-200 GPS telescopes LogMessage("CanUnpark", "Get - " + true); return true; } @@ -1995,20 +1996,20 @@ namespace ASCOM.Meade.net //LX200's – a string of bar characters indicating the distance. //Autostars and Autostar II – a string containing one bar until a slew is complete, then a null string is returned. - bool isSlewing = !string.IsNullOrEmpty(result); + bool isSlewing = false; try { - //if (string.IsNullOrEmpty(result)) - //{ - // isSlewing = false; - // return isSlewing; - //} + if (string.IsNullOrWhiteSpace(result)) + { + isSlewing = false; + return isSlewing; + } - //if (result.Contains("|")) - //{ - // isSlewing = true; - // return isSlewing; - //} + if (result.Contains("|")) + { + isSlewing = true; + return isSlewing; + } ////classic LX200 return bar with 32 chars. FF is contained from left to right when slewing //byte[] ba = Encoding.Default.GetBytes(result); @@ -2030,7 +2031,7 @@ namespace ASCOM.Meade.net } finally { - LogMessage("IsSlewingToTarget", $"Result = {isSlewing}"); + LogMessage("IsSlewingToTarget", $"IsSlewing = {isSlewing} : result = {result ?? ""}"); } } @@ -2394,8 +2395,9 @@ namespace ASCOM.Meade.net public void Unpark() { - LogMessage("Unpark", "Parking telescope"); + LogMessage("Unpark", "Unparking telescope"); + //todo make this return only work for LX-200 GPS telescopes if (!AtPark) return; @@ -2403,12 +2405,6 @@ namespace ASCOM.Meade.net //: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;