diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 1bd772b..26b0bc5 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -34,7 +34,8 @@ namespace Meade.net.Telescope.UnitTests TraceLogger = false, ComPort = "TestCom1", GuideRateArcSecondsPerSecond = 1.23, - Precision = "Unchanged" + Precision = "Unchanged", + GuidingStyle = "Auto" }; _utilMock = new Mock(); @@ -446,17 +447,24 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Verify(x => x.Disconnect(It.IsAny(), It.IsAny()), Times.Once()); } - [TestCase("Autostar", "30Ab", false)] - [TestCase("Autostar", "31Ee", true)] - [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) + [TestCase("Auto", "Autostar", "30Ab", false)] + [TestCase("Auto","Autostar", "31Ee", true)] + [TestCase("Auto","Autostar", "43Eg", true)] + [TestCase("Auto","Autostar II", "", false)] + [TestCase("Auto","LX2001", "", true)] + [TestCase("Auto",":GVP", "", false)] //LX200 Classic + [TestCase("Guide Rate Slew", "LX2001", "", false)] //force old style + [TestCase("Pulse Guiding", ":GVP", "", true)] //force new style + + public void IsNewPulseGuidingSupported_ThenIsSupported_ThenReturnsTrue(string guidingStyle, string productName, string firmware, bool isSupported) { _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName); _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware); + _profileProperties.GuidingStyle = guidingStyle; + + _telescope.Connected = true; + var result = _telescope.IsNewPulseGuidingSupported(); Assert.That(result, Is.EqualTo(isSupported)); diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 8a41f33..a5f6141 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -481,17 +481,26 @@ namespace ASCOM.Meade.net public bool IsNewPulseGuidingSupported() { - if (_sharedResourcesWrapper.ProductName == TelescopeList.Autostar497) + switch (_guidingStyle) { - return FirmwareIsGreaterThan(TelescopeList.Autostar497_31Ee); - } + case "guide rate slew": + return false; + case "pulse guiding": + return true; - if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) - { - return true; - } + default: + if (_sharedResourcesWrapper.ProductName == TelescopeList.Autostar497) + { + return FirmwareIsGreaterThan(TelescopeList.Autostar497_31Ee); + } - return false; + if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) + { + return true; + } + + return false; + } } private bool IsLongFormatSupported() @@ -2131,6 +2140,7 @@ namespace ASCOM.Meade.net private DriveRates _trackingRate = DriveRates.driveSidereal; private string _precision; + private string _guidingStyle; public DriveRates TrackingRate { @@ -2427,11 +2437,13 @@ namespace ASCOM.Meade.net _comPort = profileProperties.ComPort; _guideRate = profileProperties.GuideRateArcSecondsPerSecond; _precision = profileProperties.Precision; + _guidingStyle = profileProperties.GuidingStyle.ToLower(); LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}"); LogMessage("ReadProfile", $"Com Port: {_comPort}"); LogMessage("ReadProfile", $"Guide Rate: {_guideRate}"); LogMessage("ReadProfile", $"Precision: {_precision}"); + LogMessage("ReadProfile", $"Guiding Style: {_guidingStyle}"); } private void WriteProfile() diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs index 1551ad2..27c6bd7 100644 --- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs +++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs @@ -123,6 +123,7 @@ namespace Meade.net.UnitTests profileWrapperMock.Verify(x => x.WriteValue(DriverId, "COM Port", profileProperties.ComPort), Times.Once); profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Guide Rate Arc Seconds Per Second", profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.CurrentCulture)), Times.Once); profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Precision", profileProperties.Precision), Times.Once); + profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Guiding Style", profileProperties.GuidingStyle), Times.Once); } [Test] @@ -134,6 +135,7 @@ namespace Meade.net.UnitTests string TraceStateDefault = "false"; string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate string PrecisionDefault = "Unchanged"; + string GuidingStyleDefault = "Auto"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -147,6 +149,8 @@ namespace Meade.net.UnitTests GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault); profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault)) .Returns(PrecisionDefault); + profileWrapperMock.Setup(x => x.GetValue(DriverId, "Guiding Style", string.Empty, GuidingStyleDefault)) + .Returns(GuidingStyleDefault); IProfileWrapper profeWrapper = profileWrapperMock.Object; @@ -163,6 +167,7 @@ namespace Meade.net.UnitTests Is.EqualTo(double.Parse(GuideRateProfileNameDefault))); Assert.That(profileProperties.TraceLogger, Is.EqualTo(bool.Parse(TraceStateDefault))); Assert.That(profileProperties.Precision, Is.EqualTo(PrecisionDefault)); + Assert.That(profileProperties.GuidingStyle, Is.EqualTo(GuidingStyleDefault)); } [TestCase("TCP")] @@ -247,11 +252,17 @@ namespace Meade.net.UnitTests _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => throw new Exception("Testerror")); var connectionResult = SharedResources.Connect(deviceId, string.Empty); - - Assert.That(connectionResult.SameDevice, Is.EqualTo(1)); - Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.LX200CLASSIC)); + try + { - SharedResources.Disconnect(deviceId, String.Empty); + + Assert.That(connectionResult.SameDevice, Is.EqualTo(1)); + Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.LX200CLASSIC)); + } + finally + { + SharedResources.Disconnect(deviceId, String.Empty); + } } [Test] @@ -291,12 +302,16 @@ namespace Meade.net.UnitTests _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn); var connectionResult = SharedResources.Connect(deviceId, string.Empty); - - Assert.That(connectionResult.SameDevice, Is.EqualTo(1)); - Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.Autostar497)); - Assert.That(SharedResources.FirmwareVersion, Is.EqualTo(TelescopeList.Autostar497_43Eg)); - - SharedResources.Disconnect(deviceId, String.Empty); + try + { + Assert.That(connectionResult.SameDevice, Is.EqualTo(1)); + Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.Autostar497)); + Assert.That(SharedResources.FirmwareVersion, Is.EqualTo(TelescopeList.Autostar497_43Eg)); + } + finally + { + SharedResources.Disconnect(deviceId, String.Empty); + } } } } diff --git a/Meade.net/ProfileProperties.cs b/Meade.net/ProfileProperties.cs index 02f047a..56ee4a5 100644 --- a/Meade.net/ProfileProperties.cs +++ b/Meade.net/ProfileProperties.cs @@ -7,5 +7,6 @@ namespace ASCOM.Meade.net public bool TraceLogger { get; set; } public double GuideRateArcSecondsPerSecond { get; set; } public string Precision { get; set; } + public string GuidingStyle { get; set; } } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index 0a26df9..8c7c814 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -71,6 +71,16 @@ namespace ASCOM.Meade.net { cboPrecision.SelectedItem = "Unchanged"; } + + try + { + cboGuidingStyle.SelectedItem = profileProperties.GuidingStyle; + } + catch (Exception e) + { + cboGuidingStyle.SelectedItem = "Auto"; + } + } public ProfileProperties GetProfile() @@ -80,7 +90,8 @@ namespace ASCOM.Meade.net TraceLogger = chkTrace.Checked, ComPort = comboBoxComPort.SelectedItem.ToString(), GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text.Trim()), - Precision = cboPrecision.SelectedItem.ToString() + Precision = cboPrecision.SelectedItem.ToString(), + GuidingStyle = cboGuidingStyle.SelectedItem.ToString() }; return profileProperties; diff --git a/Meade.net/SetupDialogForm.designer.cs b/Meade.net/SetupDialogForm.designer.cs index 10e1f06..4b40bb9 100644 --- a/Meade.net/SetupDialogForm.designer.cs +++ b/Meade.net/SetupDialogForm.designer.cs @@ -45,6 +45,8 @@ namespace ASCOM.Meade.net this.lblPercentOfSiderealRate = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.cboPrecision = new System.Windows.Forms.ComboBox(); + this.label6 = new System.Windows.Forms.Label(); + this.cboGuidingStyle = new System.Windows.Forms.ComboBox(); ((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit(); this.SuspendLayout(); // @@ -133,10 +135,28 @@ namespace ASCOM.Meade.net resources.ApplyResources(this.cboPrecision, "cboPrecision"); this.cboPrecision.Name = "cboPrecision"; // + // label6 + // + resources.ApplyResources(this.label6, "label6"); + this.label6.Name = "label6"; + // + // cboGuidingStyle + // + this.cboGuidingStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cboGuidingStyle.FormattingEnabled = true; + this.cboGuidingStyle.Items.AddRange(new object[] { + resources.GetString("cboGuidingStyle.Items"), + resources.GetString("cboGuidingStyle.Items1"), + resources.GetString("cboGuidingStyle.Items2")}); + resources.ApplyResources(this.cboGuidingStyle, "cboGuidingStyle"); + this.cboGuidingStyle.Name = "cboGuidingStyle"; + // // SetupDialogForm // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.cboGuidingStyle); + this.Controls.Add(this.label6); this.Controls.Add(this.cboPrecision); this.Controls.Add(this.label5); this.Controls.Add(this.lblPercentOfSiderealRate); @@ -178,5 +198,7 @@ namespace ASCOM.Meade.net private Label lblPercentOfSiderealRate; private Label label5; private ComboBox cboPrecision; + private Label label6; + private ComboBox cboGuidingStyle; } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.resx b/Meade.net/SetupDialogForm.resx index 84d89dc..4bb64fd 100644 --- a/Meade.net/SetupDialogForm.resx +++ b/Meade.net/SetupDialogForm.resx @@ -123,7 +123,7 @@ - 281, 225 + 281, 250 59, 24 @@ -145,13 +145,13 @@ $this - 12 + 14 Bottom, Right - 281, 255 + 281, 280 59, 25 @@ -172,7 +172,7 @@ $this - 11 + 13 12, 9 @@ -196,7 +196,7 @@ $this - 10 + 12 Top, Right @@ -223,7 +223,7 @@ $this - 9 + 11 True @@ -250,13 +250,13 @@ $this - 8 + 10 True - 77, 136 + 86, 136 69, 17 @@ -277,10 +277,10 @@ $this - 7 + 9 - 77, 87 + 86, 87 90, 21 @@ -298,7 +298,7 @@ $this - 6 + 8 True @@ -325,10 +325,10 @@ $this - 5 + 7 - 77, 159 + 86, 159 46, 20 @@ -349,13 +349,13 @@ $this - 4 + 6 True - 129, 162 + 138, 162 122, 13 @@ -376,13 +376,13 @@ $this - 3 + 5 True - 129, 175 + 138, 175 105, 13 @@ -403,7 +403,7 @@ $this - 2 + 4 True @@ -430,7 +430,7 @@ $this - 1 + 3 Unchanged @@ -442,7 +442,7 @@ High - 77, 191 + 86, 191 90, 21 @@ -460,6 +460,66 @@ $this + 2 + + + True + + + NoControl + + + 13, 221 + + + 67, 13 + + + 14 + + + Guiding style + + + label6 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + Auto + + + Guide rate slew + + + Pulse guiding + + + 86, 218 + + + 90, 21 + + + 15 + + + cboGuidingStyle + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 @@ -469,7 +529,7 @@ 6, 13 - 350, 288 + 350, 313 CenterScreen diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index b391c15..5b5b23b 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -139,7 +139,8 @@ namespace ASCOM.Meade.net private const string TraceStateProfileName = "Trace Level"; private const string GuideRateProfileName = "Guide Rate Arc Seconds Per Second"; private const string PrecisionProfileName = "Precision"; - + private const string GuidingStyleProfileName = "Guiding Style"; + public static void WriteProfile(ProfileProperties profileProperties) { lock (LockObject) @@ -151,6 +152,7 @@ namespace ASCOM.Meade.net driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort); driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.InvariantCulture)); driverProfile.WriteValue(DriverId, PrecisionProfileName, profileProperties.Precision); + driverProfile.WriteValue(DriverId, GuidingStyleProfileName, profileProperties.GuidingStyle); } } } @@ -159,6 +161,8 @@ namespace ASCOM.Meade.net private const string TraceStateDefault = "false"; private const string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate private const string PrecisionDefault = "Unchanged"; + private const string GuidingStyleDefault = "Auto"; + public static ProfileProperties ReadProfile() { @@ -172,6 +176,7 @@ namespace ASCOM.Meade.net profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId, TraceStateProfileName, string.Empty, TraceStateDefault)); profileProperties.GuideRateArcSecondsPerSecond = double.Parse(driverProfile.GetValue(DriverId, GuideRateProfileName, string.Empty, GuideRateProfileNameDefault), NumberFormatInfo.InvariantInfo); profileProperties.Precision = driverProfile.GetValue(DriverId, PrecisionProfileName, string.Empty, PrecisionDefault); + profileProperties.GuidingStyle = driverProfile.GetValue(DriverId, GuidingStyleProfileName, string.Empty, GuidingStyleDefault); } return profileProperties;