From a9e2ec952840e24cd9f1daf8cdc59e5b6d1b8b96 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 25 Jul 2019 00:15:34 +0100 Subject: [PATCH] Fixed issue when connecting, that the first attempt to set the guide rate was not in the right scale. --- .../TelescopeUnitTests.cs | 16 ++++++++++++++++ Meade.net.Telescope/Telescope.cs | 18 +++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 32645d3..15b7523 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -339,6 +339,22 @@ namespace Meade.net.Telescope.UnitTests Assert.That(_telescope.Connected, Is.EqualTo(expectedConnected)); } + [Test] + public void Connected_Set_WhenConnecting_Then() + { + var productName = "LX2001"; + var firmware = string.Empty; + + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName); + _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware); + _telescope.Connected = true; + + _sharedResourcesWrapperMock.Verify( x => x.Connect("Serial"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendString(":GZ#"), Times.Once); + + _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"),Times.Once); + } + [Test] public void Connected_Set_SettingTrueWhenTrue_ThenDoesNothing() diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 184a6d9..683b7d8 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1091,15 +1091,13 @@ namespace ASCOM.Meade.net throw new PropertyNotImplementedException(propertyName, true); } - var valueInArcSecondsPerSecond = DegreesPerSecondToArcSecondPerSecond(value); - - if (!valueInArcSecondsPerSecond.InRange(0, 15.0417)) + if (!value.InRange(0, 15.0417)) { - throw new InvalidValueException(propertyName, valueInArcSecondsPerSecond.ToString(), "0 to 15.0417”/sec"); + throw new InvalidValueException(propertyName, value.ToString(), "0 to 15.0417”/sec"); } - LogMessage($"{propertyName} Set", $"Setting new guiderate {valueInArcSecondsPerSecond.ToString()} arc seconds/second ({value.ToString()} degrees/second)"); - _sharedResourcesWrapper.SendBlind($":Rg{valueInArcSecondsPerSecond:00.0}#"); + LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString()} arc seconds/second ({value.ToString()} degrees/second)"); + _sharedResourcesWrapper.SendBlind($":Rg{value:00.0}#"); //:RgSS.S# //Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking //Rates when the CCD guider or handbox guider buttons are pressed when the guide rate is selected.Rate shall not exceed @@ -1108,7 +1106,7 @@ namespace ASCOM.Meade.net //info from RickB says that 15.04107 is a better value for - _guideRate = valueInArcSecondsPerSecond; + _guideRate = value; WriteProfile(); } @@ -1133,7 +1131,8 @@ namespace ASCOM.Meade.net } set { - SetNewGuideRate(value, "GuideRateDeclination"); + var newValue = DegreesPerSecondToArcSecondPerSecond(value); + SetNewGuideRate(newValue, "GuideRateDeclination"); } } @@ -1147,7 +1146,8 @@ namespace ASCOM.Meade.net } set { - SetNewGuideRate(value, "GuideRateRightAscension"); + var newValue = DegreesPerSecondToArcSecondPerSecond(value); + SetNewGuideRate(newValue, "GuideRateRightAscension"); } }