From 927d6bce47ceb4aa75a5730a2b0f84622c2a2d32 Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 17 Jan 2021 18:19:16 +0000 Subject: [PATCH] Fixed the log message to be returned from IsSlewing with the final state every time without exception. --- Meade.net.Telescope/Telescope.cs | 44 +++++++++++++++++--------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index b91325c..46298c2 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1982,29 +1982,33 @@ namespace ASCOM.Meade.net //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); + try + { + if (!isSlewing) + return false; - if (!isSlewing) - return false; + //classic LX200 return bar with 32 chars. FF is contained from left to right when slewing + byte[] ba = Encoding.Default.GetBytes(result); + //replace fill chars not belonging to a slew bar. Are there others? The bar character is a FF in hex. + var hexString = BitConverter.ToString(ba).Replace("-", "").Replace("20", ""); + LogMessage("IsSlewingToTarget", $"Resulthex = {hexString}"); + isSlewing = (hexString.Length > 0); + + if (!isSlewing) + return isSlewing; + + //classic LX200 got RA 0 DE 0 as Target Coordinates. If the RA DE is not 0 at switch on, the telescope will indicate slewing until + //the target coordinates are set and the telescope is slewed to that position. + //a 0 movement will solved that lock if the target coordinates are set to the current coordinates. + if (IsTargetCoordinateInitRequired()) + InitTargetCoordinates(); - //classic LX200 return bar with 32 chars. FF is contained from left to right when slewing - byte[] ba = Encoding.Default.GetBytes(result); - //replace fill chars not belonging to a slew bar. Are there others? The bar character is a FF in hex. - var hexString = BitConverter.ToString(ba).Replace("-", "").Replace("20", ""); - LogMessage("IsSlewingToTarget", $"Resulthex = {hexString}"); - isSlewing = (hexString.Length > 0); - - if (!isSlewing) return isSlewing; - - LogMessage("IsSlewingToTarget", $"Result = {isSlewing}"); - - //classic LX200 got RA 0 DE 0 as Target Coordinates. If the RA DE is not 0 at switch on, the telescope will indicate slewing until - //the target coordinates are set and the telescope is slewed to that position. - //a 0 movement will solved that lock if the target coordinates are set to the current coordinates. - if (IsTargetCoordinateInitRequired()) - InitTargetCoordinates(); - - return isSlewing; + } + finally + { + LogMessage("IsSlewingToTarget", $"Result = {isSlewing}"); + } } public void SyncToAltAz(double azimuth, double altitude)