From cd8330196eae0729f75979a5ea76bed043eb9e49 Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 17 Jan 2021 17:30:29 +0000 Subject: [PATCH] Made a few minor tweaks whilst reviewing. --- Meade.net.Telescope/Telescope.cs | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index b7b7df3..af77cb1 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -515,7 +515,6 @@ namespace ASCOM.Meade.net /// private bool IsTargetCoordinateInitRequired() { - const double eps = 0.00001d; if (!_isTargetCoordinateInitRequired) return _isTargetCoordinateInitRequired; @@ -528,28 +527,24 @@ namespace ASCOM.Meade.net return _isTargetCoordinateInitRequired; } - var result = SharedResourcesWrapper.SendString(":Gr#"); - - double rightTargetAscension = HMToHours(result); + const double eps = 0.00001d; + double rightTargetAscension = RightAscension; //target RA == 0 - if(Math.Abs(rightTargetAscension) > eps) + if (Math.Abs(rightTargetAscension) > eps) { _isTargetCoordinateInitRequired = false; return _isTargetCoordinateInitRequired; } - result = SharedResourcesWrapper.SendString(":Gd#"); - - double targetDeclination = _utilities.DMSToDegrees(result); + double targetDeclination = Declination; //target DE == 0 - if(Math.Abs(targetDeclination) > eps) + if (Math.Abs(targetDeclination) > eps) { _isTargetCoordinateInitRequired = false; return _isTargetCoordinateInitRequired; } - - + //target coordinates are equal current coordinates if((Math.Abs(RightAscension - rightTargetAscension ) <= eps) && (Math.Abs(Declination - targetDeclination) <= eps)) @@ -565,26 +560,23 @@ namespace ASCOM.Meade.net private void InitTargetCoordinates() { - try { var raAndDec = GetTelescopeRaAndDec(); - //when connection the first time the telescop target coordinates should be the current ones. + //when connection the first time the telescope target coordinates should be the current ones. //for the classic LX200 at least this is not the case, target ra and dec are 0, when switched on. LogMessage("InitTargetCoordinates", "sync telescope target"); SyncToCoordinates(raAndDec.RightAscension, raAndDec.Declination); - //doit only once + //do it only once _isTargetCoordinateInitRequired = false; - - } catch (Exception ex) { LogMessage("InitTargetCoordinates", $"Error sync telescope position", ex.Message); } - } + public void SetLongFormat(bool setLongFormat) { IsLongFormat = false; @@ -1989,7 +1981,7 @@ 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 = result != null && result != string.Empty; + bool isSlewing = !string.IsNullOrEmpty(result); if (!isSlewing) return false;