From a61915a3b56ca6adc145b63faad9df30bbc2f9da Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 30 Sep 2019 22:10:00 +0100 Subject: [PATCH] Adding some experimental support for the LX-200 EMC --- .../TelescopeUnitTests.cs | 28 +++++++++++++++++-- Meade.net.Telescope/Telescope.cs | 20 +++++++++++-- Meade.net/TelescopeList.cs | 3 ++ 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 820561c..0d6264b 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -349,12 +349,18 @@ namespace Meade.net.Telescope.UnitTests _telescope.Connected = expectedConnected; Assert.That(_telescope.Connected, Is.EqualTo(expectedConnected)); - } + if (expectedConnected) + { + _sharedResourcesWrapperMock.Verify(x => x.SendString(":GZ#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"), Times.Never); + } + } + [Test] - public void Connected_Set_WhenConnecting_Then_ConnectsToSerialDevice() + public void Connected_Set_WhenConnectingLX200GPS_Then_ConnectsToSerialDevice() { - var productName = "LX2001"; + var productName = TelescopeList.LX200GPS; var firmware = string.Empty; _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName); @@ -367,6 +373,21 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"),Times.Once); } + [Test] + public void Connected_Set_WhenConnectingToLX200EMC_Then_ConnectsToSerialDevice() + { + var productName = TelescopeList.LX200CLASSIC; + 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", It.IsAny()), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendString(":GZ#"), Times.Never); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"), Times.Never); + } + [Test] public void Connected_Set_SettingTrueWhenTrue_ThenDoesNothing() @@ -414,6 +435,7 @@ namespace Meade.net.Telescope.UnitTests [TestCase("Autostar", "43Eg", true)] [TestCase("Autostar II", "", false)] [TestCase("LX2001", "", true)] + [TestCase(":GVP", "", false)] //LX200 Classic public void IsNewPulseGuidingSupported_ThenIsSupported_ThenReturnsTrue(string productName, string firmware, bool isSupported) { _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName); diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 90c49c4..9e9c358 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -456,6 +456,15 @@ namespace ASCOM.Meade.net return false; } + private bool IsLongFormatSupported() + { + if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200CLASSIC) + { + return false; + } + return true; + } + private bool IsGuideRateSettingSupported() { if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) @@ -472,8 +481,15 @@ namespace ASCOM.Meade.net return comparison >= 0; } + public bool IsLongFormat { get; private set; } + public void SetLongFormat(bool setLongFormat) { + IsLongFormat = false; + + if (!IsLongFormatSupported()) + return; + _sharedResourcesWrapper.Lock(() => { var result = _sharedResourcesWrapper.SendString(":GZ#"); @@ -481,9 +497,9 @@ namespace ASCOM.Meade.net //Returns: DDD*MM# or DDD*MM’SS# //The current telescope Azimuth depending on the selected precision. - bool isLongFormat = result.Length > 6; + IsLongFormat = result.Length > 6; - if (isLongFormat != setLongFormat) + if (IsLongFormat != setLongFormat) { _utilities.WaitForMilliseconds(500); _sharedResourcesWrapper.SendBlind(":U#"); diff --git a/Meade.net/TelescopeList.cs b/Meade.net/TelescopeList.cs index 29bcdf9..32b6bf5 100644 --- a/Meade.net/TelescopeList.cs +++ b/Meade.net/TelescopeList.cs @@ -23,7 +23,10 @@ // ReSharper disable once InconsistentNaming public static readonly string LX200GPS_42G = "4.2G"; + #endregion + #region LX200EMC + public static readonly string LX200CLASSIC = ":GVP"; //GVP command is not supported! #endregion } }