From 5f55d9f28f4b0958c2635829e96dc1a59db2b0e8 Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 19 Jul 2019 20:25:32 +0100 Subject: [PATCH 01/25] Added MSIFilename to the nant output --- build.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.build b/build.build index e66f39f..b5a58e3 100644 --- a/build.build +++ b/build.build @@ -35,7 +35,11 @@ - + + + + + From d9e551707f2e48f87adcea7ac135a5fef4d75768 Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 19 Jul 2019 20:43:40 +0100 Subject: [PATCH 02/25] Removed the echo as it doesn't work in teamcity. --- build.build | 3 --- 1 file changed, 3 deletions(-) diff --git a/build.build b/build.build index b5a58e3..ff1de4f 100644 --- a/build.build +++ b/build.build @@ -35,10 +35,7 @@ - - - From e15537e6c38f6b8ff6fca754b8f0b61dd22c111d Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 19 Jul 2019 22:15:41 +0100 Subject: [PATCH 03/25] Added support for being able to have ASCOM see a value for guide rate. --- .../TelescopeUnitTests.cs | 50 ++++++++++++++++--- Meade.net.Telescope/Telescope.cs | 14 ++++-- 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 1f29a92..230a271 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -769,10 +769,9 @@ namespace Meade.net.Telescope.UnitTests [Test] public void GuideRateDeclination_Get_ThenThrowsException() { - var excpetion = Assert.Throws(() => { var result = _telescope.GuideRateDeclination; }); + var result = _telescope.GuideRateDeclination; - Assert.That(excpetion.Property, Is.EqualTo("GuideRateDeclination")); - Assert.That(excpetion.AccessorSet, Is.False); + Assert.That(result, Is.EqualTo(0.004178074616551509)); } [Test] @@ -787,10 +786,9 @@ namespace Meade.net.Telescope.UnitTests [Test] public void GuideRateRightAscension_Get_ThenThrowsException() { - var excpetion = Assert.Throws(() => { var result = _telescope.GuideRateRightAscension; }); + var result = _telescope.GuideRateRightAscension; - Assert.That(excpetion.Property, Is.EqualTo("GuideRateRightAscension")); - Assert.That(excpetion.AccessorSet, Is.False); + Assert.That(result, Is.EqualTo(0.004178074616551509)); } [Test] @@ -969,7 +967,7 @@ namespace Meade.net.Telescope.UnitTests var duration = 0; ConnectTelescope(); - _telescope.PulseGuide(direction, 0); + _telescope.PulseGuide(direction, duration); string d = string.Empty; switch (direction) @@ -1003,7 +1001,43 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => "31Ed"); _telescope.Connected = true; - _telescope.PulseGuide(direction, 0); + _telescope.PulseGuide(direction, duration); + + string d = string.Empty; + switch (direction) + { + case GuideDirections.guideEast: + d = "e"; + break; + case GuideDirections.guideWest: + d = "w"; + break; + case GuideDirections.guideNorth: + d = "n"; + break; + case GuideDirections.guideSouth: + d = "s"; + break; + } + + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":RG#")); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":M{d}#")); + _utilMock.Verify(x => x.WaitForMilliseconds(duration), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Q{d}#")); + } + + [TestCase(GuideDirections.guideEast)] + [TestCase(GuideDirections.guideWest)] + [TestCase(GuideDirections.guideNorth)] + [TestCase(GuideDirections.guideSouth)] + public void PulseGuide_WhenConnectedAndNewerPulseGuidingAvailableButDurationTooLong_ThenSendsOldCommandsAndWaits(GuideDirections direction) + { + var duration = 10000; + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497); + _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => "31Ed"); + _telescope.Connected = true; + + _telescope.PulseGuide(direction, duration); string d = string.Empty; switch (direction) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 0ce3b53..99c45ff 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -97,6 +97,10 @@ namespace ASCOM.Meade.net Initialise(); } + private double _guideRate; + + private const double SIDRATE = 0.9972695677; //synodic/solar seconds per sidereal second + private void Initialise() { //todo move the TraceLogger out to a factory class. @@ -107,6 +111,8 @@ namespace ASCOM.Meade.net IsConnected = false; // Initialise connected to false + _guideRate = 15.0 * (1.0 / 3600.0) / SIDRATE; + LogMessage("Telescope", "Completed initialisation"); } @@ -903,7 +909,7 @@ namespace ASCOM.Meade.net get { LogMessage("GuideRateDeclination Get", "Not implemented"); - throw new PropertyNotImplementedException("GuideRateDeclination", false); + return _guideRate; } set { @@ -917,7 +923,7 @@ namespace ASCOM.Meade.net get { LogMessage("GuideRateRightAscension Get", "Not implemented"); - throw new PropertyNotImplementedException("GuideRateRightAscension", false); + return _guideRate; } set { @@ -1075,7 +1081,7 @@ namespace ASCOM.Meade.net break; } - if (_userNewerPulseGuiding) + if (_userNewerPulseGuiding && duration < 10000) { _sharedResourcesWrapper.SendBlind($":Mg{d}{duration:0000}#"); //:MgnDDDD# @@ -1086,8 +1092,6 @@ namespace ASCOM.Meade.net //passed in the command.These commands support serial port driven guiding. //Returns – Nothing //LX200 – Not Supported - - //todo implement IsPulseGuiding if WaitForMilliseconds is not needed _utilities.WaitForMilliseconds(duration); //todo figure out if this is really needed } else From b6e12d687b69e0e057b561ecbea9bd29ac3122cb Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 19 Jul 2019 22:21:58 +0100 Subject: [PATCH 04/25] Reading the guide rate from any axis will now return a hard coded value for the default guide rate. --- Meade.net.Telescope/Telescope.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 99c45ff..5e8ec6a 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -914,8 +914,13 @@ namespace ASCOM.Meade.net set { LogMessage("GuideRateDeclination Set", "Not implemented"); - throw new PropertyNotImplementedException("GuideRateDeclination", true); - } + throw new PropertyNotImplementedException("GuideRateDeclination", true) + //: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 + //sidereal speed(approx 15.0417”/ sec)[Autostar II only] + //Returns: Nothing + } } public double GuideRateRightAscension @@ -929,6 +934,11 @@ namespace ASCOM.Meade.net { LogMessage("GuideRateRightAscension Set", "Not implemented"); throw new PropertyNotImplementedException("GuideRateRightAscension", true); + //: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 + //sidereal speed(approx 15.0417”/ sec)[Autostar II only] + //Returns: Nothing } } From 1c3eb9f3d7ffa9aaa65467de9c2c01bb3fa2ff90 Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 19 Jul 2019 22:25:17 +0100 Subject: [PATCH 05/25] Fixed a typo --- Meade.net.Telescope/Telescope.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 5e8ec6a..47389de 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -914,13 +914,13 @@ namespace ASCOM.Meade.net set { LogMessage("GuideRateDeclination Set", "Not implemented"); - throw new PropertyNotImplementedException("GuideRateDeclination", true) + throw new PropertyNotImplementedException("GuideRateDeclination", true); //: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 //sidereal speed(approx 15.0417”/ sec)[Autostar II only] //Returns: Nothing - } + } } public double GuideRateRightAscension From ce74e980fa827bb7d3b4e758d54aa10be086030c Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 19 Jul 2019 22:41:01 +0100 Subject: [PATCH 06/25] Returned the build.build file to the last known fully working version. --- build.build | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.build b/build.build index ff1de4f..e66f39f 100644 --- a/build.build +++ b/build.build @@ -35,8 +35,7 @@ - - + From c2ebe329c537069ae5b16a78ad848523ef6bb388 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 20 Jul 2019 16:53:09 +0100 Subject: [PATCH 07/25] Added support for the LX200GPS to use the newer pulse guiding commands. Added support for setting the guide rate on the LX200GPS (untested) --- .../TelescopeUnitTests.cs | 68 +++++++++++++------ Meade.net.Telescope/DoubleExtensions.cs | 14 ++++ .../Meade.net.Telescope.csproj | 1 + Meade.net.Telescope/Telescope.cs | 63 +++++++++++------ Meade.net/ClassFactory.cs | 1 - Meade.net/Meade.net.csproj | 1 + Meade.net/TelescopeList.cs | 30 ++++++++ Meade.net/Wrapper/SharedResourcesWrapper.cs | 14 ---- 8 files changed, 138 insertions(+), 54 deletions(-) create mode 100644 Meade.net.Telescope/DoubleExtensions.cs create mode 100644 Meade.net/TelescopeList.cs diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 230a271..02c3923 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -37,10 +37,7 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock = new Mock(); _sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MM’SS"); - _sharedResourcesWrapperMock.Setup(x => x.Autostar497).Returns(() => "AUTOSTAR"); - _sharedResourcesWrapperMock.Setup(x => x.Autostar49731Ee).Returns(() => "31Ee"); - _sharedResourcesWrapperMock.Setup(x => x.Autostar49743Eg) .Returns(() => "43Eg"); - + _sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny())).Callback(action => { action(); }); _sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny>())).Returns>( (func) => func()); _sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny>())).Returns>((func) => func()); @@ -56,8 +53,8 @@ namespace Meade.net.Telescope.UnitTests private void ConnectTelescope() { - _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497); - _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.Autostar49731Ee); + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497); + _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee); _telescope.Connected = true; } @@ -238,8 +235,8 @@ namespace Meade.net.Telescope.UnitTests [TestCase(false)] public void Connected_Get_ReturnsExpectedValue(bool expectedConnected) { - _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497); - _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.Autostar49731Ee); + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497); + _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee); _telescope.Connected = expectedConnected; Assert.That(_telescope.Connected, Is.EqualTo(expectedConnected)); @@ -275,8 +272,8 @@ namespace Meade.net.Telescope.UnitTests [Test] public void Connected_Set_WhenFailsToConnect_ThenDisconnects() { - _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497); - _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.Autostar49731Ee); + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497); + _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee); _sharedResourcesWrapperMock.Setup(x => x.SendString(It.IsAny())).Throws(new Exception("TestFailed")); @@ -287,10 +284,11 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Verify(x => x.Disconnect(It.IsAny()), Times.Once()); } - [TestCase("AUTOSTAR", "30Ab", false)] - [TestCase("AUTOSTAR","31Ee", true)] - [TestCase("AUTOSTAR", "43Eg", true)] - [TestCase("AUTOSTAR II", "", false)] + [TestCase("Autostar", "30Ab", false)] + [TestCase("Autostar", "31Ee", true)] + [TestCase("Autostar", "43Eg", true)] + [TestCase("Autostar II", "", false)] + [TestCase("LX2001", "", true)] public void IsNewPulseGuidingSupported_ThenIsSupported_ThenReturnsTrue(string productName, string firmware, bool isSupported) { _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName); @@ -777,12 +775,28 @@ namespace Meade.net.Telescope.UnitTests [Test] public void GuideRateDeclination_Set_ThenThrowsException() { + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497); + var excpetion = Assert.Throws(() => { _telescope.GuideRateDeclination = 0; }); Assert.That(excpetion.Property, Is.EqualTo("GuideRateDeclination")); Assert.That(excpetion.AccessorSet, Is.True); } + [Test] + public void GuideRateDeclination_Set_WhenIsSupported_ThenSetsNewGuideRate() + { + var newGuideRate = 10; + + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS); + + _telescope.GuideRateDeclination = newGuideRate; + + _sharedResourcesWrapperMock.Verify( x => x.SendBlind(":Rg10.0#"),Times.Once); + + Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate)); + } + [Test] public void GuideRateRightAscension_Get_ThenThrowsException() { @@ -794,12 +808,28 @@ namespace Meade.net.Telescope.UnitTests [Test] public void GuideRateRightAscension_Set_ThenThrowsException() { + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497); + var excpetion = Assert.Throws(() => { _telescope.GuideRateRightAscension = 0; }); Assert.That(excpetion.Property, Is.EqualTo("GuideRateRightAscension")); Assert.That(excpetion.AccessorSet, Is.True); } + [Test] + public void GuideRateRightAscension_Set_WhenIsSupported_ThenSetsNewGuideRate() + { + var newGuideRate = 10; + + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS); + + _telescope.GuideRateRightAscension = newGuideRate; + + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Rg10.0#"), Times.Once); + + Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate)); + } + [Test] public void IsPulseGuiding_Get_ReturnsFalse() { @@ -997,8 +1027,8 @@ namespace Meade.net.Telescope.UnitTests public void PulseGuide_WhenConnectedAndNewerPulseGuidingNotAvailable_ThenSendsOldCommandsAndWaits(GuideDirections direction) { var duration = 0; - _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497); - _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => "31Ed"); + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497); + _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_30Ee); _telescope.Connected = true; _telescope.PulseGuide(direction, duration); @@ -1033,8 +1063,8 @@ namespace Meade.net.Telescope.UnitTests public void PulseGuide_WhenConnectedAndNewerPulseGuidingAvailableButDurationTooLong_ThenSendsOldCommandsAndWaits(GuideDirections direction) { var duration = 10000; - _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497); - _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => "31Ed"); + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497); + _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_30Ee); _telescope.Connected = true; _telescope.PulseGuide(direction, duration); @@ -1328,8 +1358,6 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SyncToAltAz_WhenConnected_ThenSendsExpectedMessage() { - string expectedMessage = "test blind Message"; - ConnectTelescope(); var exception = Assert.Throws(() => { _telescope.SyncToAltAz(0,0); }); diff --git a/Meade.net.Telescope/DoubleExtensions.cs b/Meade.net.Telescope/DoubleExtensions.cs new file mode 100644 index 0000000..958400c --- /dev/null +++ b/Meade.net.Telescope/DoubleExtensions.cs @@ -0,0 +1,14 @@ +namespace ASCOM.Meade.net +{ + public static class DoubleExtensions + { + public static bool InRange(this double value, double low, double high) + { + if (value < low) + return false; + if (value > high) + return false; + return true; + } + } +} \ No newline at end of file diff --git a/Meade.net.Telescope/Meade.net.Telescope.csproj b/Meade.net.Telescope/Meade.net.Telescope.csproj index cf50efa..70efc87 100644 --- a/Meade.net.Telescope/Meade.net.Telescope.csproj +++ b/Meade.net.Telescope/Meade.net.Telescope.csproj @@ -118,6 +118,7 @@ + diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 47389de..166ddeb 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -344,11 +344,25 @@ namespace ASCOM.Meade.net public bool IsNewPulseGuidingSupported() { - if (_sharedResourcesWrapper.ProductName == _sharedResourcesWrapper.Autostar497) + if (_sharedResourcesWrapper.ProductName == TelescopeList.Autostar497) { - return FirmwareIsGreaterThan(_sharedResourcesWrapper.Autostar49731Ee); + return FirmwareIsGreaterThan(TelescopeList.Autostar497_31Ee); } + if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) + { + return true; + } + + return false; + } + + private bool IsGuideRateSettingSupported() + { + if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) + { + return true; + } return false; } @@ -495,7 +509,7 @@ namespace ASCOM.Meade.net //P If scope in Polar Mode //todo implement GW Command - Supported in Autostar 43Eg and above - //if FirmwareIsGreaterThan(_sharedResourcesWrapper.AUTOSTAR497_43EG) + //if FirmwareIsGreaterThan(TelescopeList.Autostar497_43EG) //{ //var alignmentString = SerialPort.CommandTerminated(":GW#", "#"); //:GW# Get Scope Alignment Status @@ -531,7 +545,7 @@ namespace ASCOM.Meade.net CheckConnected("AlignmentMode Set"); //todo tidy this up into a better solution that means can :GW#, :AL#, :AA#, & :AP# and checked for Autostar properly - if (!FirmwareIsGreaterThan(_sharedResourcesWrapper.Autostar49743Eg)) + if (!FirmwareIsGreaterThan(TelescopeList.Autostar497_43Eg)) throw new PropertyNotImplementedException("AlignmentMode",true ); //todo make this only try with Autostar 43Eg and above. @@ -904,6 +918,29 @@ namespace ASCOM.Meade.net } } + private void SetNewGuideRate(double value, string propertyName) + { + if (!IsGuideRateSettingSupported()) + { + LogMessage("GuideRateDeclination Set", "Not implemented"); + throw new PropertyNotImplementedException(propertyName, true); + } + + if (!value.InRange(0, 15.0417)) + { + throw new InvalidValueException(propertyName, value.ToString(), "0 to 15.0417”/sec"); + } + + _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 + //sidereal speed(approx 15.0417”/sec)[Autostar II only] + //Returns: Nothing + + _guideRate = value; + } + public double GuideRateDeclination { get @@ -913,16 +950,10 @@ namespace ASCOM.Meade.net } set { - LogMessage("GuideRateDeclination Set", "Not implemented"); - throw new PropertyNotImplementedException("GuideRateDeclination", true); - //: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 - //sidereal speed(approx 15.0417”/ sec)[Autostar II only] - //Returns: Nothing + SetNewGuideRate(value, "GuideRateDeclination"); } } - + public double GuideRateRightAscension { get @@ -932,13 +963,7 @@ namespace ASCOM.Meade.net } set { - LogMessage("GuideRateRightAscension Set", "Not implemented"); - throw new PropertyNotImplementedException("GuideRateRightAscension", true); - //: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 - //sidereal speed(approx 15.0417”/ sec)[Autostar II only] - //Returns: Nothing + SetNewGuideRate(value, "GuideRateRightAscension"); } } diff --git a/Meade.net/ClassFactory.cs b/Meade.net/ClassFactory.cs index 431e2d0..bbb5771 100644 --- a/Meade.net/ClassFactory.cs +++ b/Meade.net/ClassFactory.cs @@ -112,7 +112,6 @@ namespace ASCOM.Meade.net private readonly Type _mClassType; private Guid _mClassId; private readonly ArrayList _mInterfaceTypes; - private UInt32 _mLocked = 0; private uint _mCookie; private readonly string _mProgid; diff --git a/Meade.net/Meade.net.csproj b/Meade.net/Meade.net.csproj index 5eda70d..eb6cc79 100644 --- a/Meade.net/Meade.net.csproj +++ b/Meade.net/Meade.net.csproj @@ -133,6 +133,7 @@ + Designer diff --git a/Meade.net/TelescopeList.cs b/Meade.net/TelescopeList.cs new file mode 100644 index 0000000..7569e7a --- /dev/null +++ b/Meade.net/TelescopeList.cs @@ -0,0 +1,30 @@ +ο»Ώusing System; +using System.Collections.Generic; +using System.Linq; +using System.Net.NetworkInformation; +using System.Text; + +namespace ASCOM.Meade.net +{ + public static class TelescopeList + { + #region Autostar 497/Audiostar + + public readonly static string Autostar497 = "Autostar"; + + //Autostar/Audiostar firmware revisions + public readonly static string Autostar497_30Ee = "30Ee"; + public readonly static string Autostar497_31Ee = "31Ee"; + public readonly static string Autostar497_43Eg = "43Eg"; + + #endregion + + #region LX200GPS + + public readonly static string LX200GPS = "LX2001"; + + public readonly static string LX200GPS_42G = "4.2G"; + + #endregion + } +} diff --git a/Meade.net/Wrapper/SharedResourcesWrapper.cs b/Meade.net/Wrapper/SharedResourcesWrapper.cs index c49454c..e4df7f5 100644 --- a/Meade.net/Wrapper/SharedResourcesWrapper.cs +++ b/Meade.net/Wrapper/SharedResourcesWrapper.cs @@ -4,11 +4,6 @@ namespace ASCOM.Meade.net.Wrapper { public interface ISharedResourcesWrapper { - string Autostar497 { get; } - string Autostar49731Ee { get; } - - string Autostar49743Eg { get;} - void Connect(string deviceId); void Disconnect(string deviceId); @@ -32,15 +27,6 @@ namespace ASCOM.Meade.net.Wrapper public class SharedResourcesWrapper : ISharedResourcesWrapper { - #region AutostarProducts - - public string Autostar497 => "Autostar"; - - public string Autostar49731Ee => "31Ee"; - public string Autostar49743Eg => "43Eg"; - - #endregion - public void Connect(string deviceId) { SharedResources.Connect( deviceId); From 6d8702a0119c18acdf8f54cd83a2debed659f633 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 20 Jul 2019 21:11:58 +0100 Subject: [PATCH 08/25] Corrected trace log name to Meade.Generic. --- Meade.net.Telescope/Telescope.cs | 2 +- Meade.net.focuser/Focuser.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 166ddeb..4200c9f 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -104,7 +104,7 @@ namespace ASCOM.Meade.net private void Initialise() { //todo move the TraceLogger out to a factory class. - _tl = new TraceLogger("", "Meade.net.Telescope"); + _tl = new TraceLogger("", "Meade.Generic.Telescope"); LogMessage("Telescope", "Starting initialisation"); ReadProfile(); // Read device configuration from the ASCOM Profile store diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index bf3a891..7b99b39 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -74,7 +74,7 @@ namespace ASCOM.Meade.net private void Initialise() { - Tl = new TraceLogger("", "Meade.net.focusser"); + Tl = new TraceLogger("", "Meade.Generic.focusser"); Tl.LogMessage("Focuser", "Starting initialisation"); ReadProfile(); // Read device configuration from the ASCOM Profile store From 5d3688bde73ae9d64b817e9cf00938f96fde9d1b Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 20 Jul 2019 22:24:25 +0100 Subject: [PATCH 09/25] Added log messages so that it's known which pulse guiding commands have been used. --- Meade.net.Telescope/Telescope.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 4200c9f..11a1334 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1118,6 +1118,7 @@ namespace ASCOM.Meade.net if (_userNewerPulseGuiding && duration < 10000) { + LogMessage("PulseGuide", $"Using new pulse guiding technique"); _sharedResourcesWrapper.SendBlind($":Mg{d}{duration:0000}#"); //:MgnDDDD# //:MgsDDDD# @@ -1131,6 +1132,7 @@ namespace ASCOM.Meade.net } else { + LogMessage("PulseGuide", $"Using old pulse guiding technique"); _sharedResourcesWrapper.Lock(() => { _sharedResourcesWrapper.SendBlind(":RG#"); //Make sure we are at guide rate From 6b9eff2b86413109b224cba0cda03f4e082e2c26 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 20 Jul 2019 23:56:52 +0100 Subject: [PATCH 10/25] Implemented the select site custom action. --- .../TelescopeUnitTests.cs | 42 ++++++++++++++++++- Meade.net.Telescope/Telescope.cs | 21 +++++++++- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 02c3923..1c388a0 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -87,8 +87,9 @@ namespace Meade.net.Telescope.UnitTests var supportedActions = _telescope.SupportedActions; Assert.That(supportedActions, Is.Not.Null); - Assert.That(supportedActions.Count, Is.EqualTo(1)); + Assert.That(supportedActions.Count, Is.EqualTo(2)); Assert.That(supportedActions.Contains("handbox"), Is.True); + Assert.That(supportedActions.Contains("site"), Is.True); } [Test] @@ -132,7 +133,7 @@ namespace Meade.net.Telescope.UnitTests [TestCase("back", ":EK87#")] [TestCase("forward", ":EK69#")] [TestCase("?", ":EK63#")] - public void Action_Handbox_blindCommands(string action, string expectedString) + public void Action_Handbox_WhenCalling_ThenSendsAppropriateBlindCommands(string action, string expectedString) { ConnectTelescope(); @@ -141,6 +142,30 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Verify(x => x.SendBlind(expectedString), Times.Once); } + [TestCase("1")] + [TestCase("2")] + [TestCase("3")] + [TestCase("4")] + public void Action_Site_WhenCallingWithValidValues_ThenSelectsCorrectSite(string site) + { + ConnectTelescope(); + + _telescope.Action("site", site); + + _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":W{site}#"), Times.Once); + } + + [TestCase("0")] + [TestCase("5")] + public void Action_Site_WhenCallingWithInCorrectValues_ThenThrowsException(string site) + { + ConnectTelescope(); + + var exception = Assert.Throws(() => { _telescope.Action("site", site); }); + + Assert.That(exception.Message, Is.EqualTo($"Site {site} not allowed must be between 1 and 4")); + } + [Test] public void Action_Handbox_nonExistantAction() { @@ -335,9 +360,18 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":U#"), Times.Once); } + [Test] + public void SelectSite_Get_WhenNotConnected_ThrowsException() + { + var exception = Assert.Throws(() => { _telescope.SelectSite(1); }); + Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SelectSite")); + } + [Test] public void SelectSite_WhenNewSiteToLow_ThenThrowsException() { + ConnectTelescope(); + var site = 0; var result = Assert.Throws(() => { _telescope.SelectSite(site); }); @@ -347,6 +381,8 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SelectSite_WhenNewSiteToHigh_ThenThrowsException() { + ConnectTelescope(); + var site = 5; var result = Assert.Throws(() => { _telescope.SelectSite(site); }); @@ -359,6 +395,8 @@ namespace Meade.net.Telescope.UnitTests [TestCase(4)] public void SelectSite_WhenNewSiteToHigh_ThenThrowsException(int site) { + ConnectTelescope(); + _telescope.SelectSite(site); _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":W{site}#"), Times.Once); diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 11a1334..628c0cb 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -157,6 +157,7 @@ namespace ASCOM.Meade.net LogMessage("SupportedActions Get", "Returning empty arraylist"); var supportedActions = new ArrayList(); supportedActions.Add("handbox"); + supportedActions.Add("site"); return supportedActions; } } @@ -239,6 +240,23 @@ namespace ASCOM.Meade.net LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters); throw new ActionNotImplementedException($"{actionName}({actionParameters})"); } + + break; + case "site": + switch (actionParameters.ToLower()) + { + case "1": + case "2": + case "3": + case "4": + SelectSite(actionParameters.ToInteger()); + break; + default: + LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters); + throw new InvalidValueException($"Site {actionParameters} not allowed must be between 1 and 4"); + + } + break; default: LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters); @@ -396,9 +414,10 @@ namespace ASCOM.Meade.net }); } - //todo hook this up to a custom action public void SelectSite(int site) { + CheckConnected("SelectSite"); + if (site < 1) throw new ArgumentOutOfRangeException("site",site,"Site cannot be lower than 1"); else if (site > 4) From c4eb74b274f983fc061975cebe029df057b837d7 Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 21 Jul 2019 17:49:28 +0100 Subject: [PATCH 11/25] Added support for can get guide rates for the LX200GPS --- .../TelescopeUnitTests.cs | 25 +++++++++++++++++-- Meade.net.Telescope/Telescope.cs | 10 +++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 1c388a0..3c97754 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -163,7 +163,7 @@ namespace Meade.net.Telescope.UnitTests var exception = Assert.Throws(() => { _telescope.Action("site", site); }); - Assert.That(exception.Message, Is.EqualTo($"Site {site} not allowed must be between 1 and 4")); + Assert.That(exception.Message, Is.EqualTo($"Site {site} not allowed, must be between 1 and 4")); } [Test] @@ -618,13 +618,34 @@ namespace Meade.net.Telescope.UnitTests } [Test] - public void CanSetGuideRates_Get_ReturnsFalse() + public void CanSetGuideRates_Get_WhenNotConnected_ThenThrowsException() { + var exception = Assert.Throws(() => { var result = _telescope.CanSetGuideRates; }); + Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: CanSetGuideRates Get")); + } + + [Test] + public void CanSetGuideRates_Get_WhenConnectedToAutostar_ThenReturnsFalse() + { + ConnectTelescope(); + var result = _telescope.CanSetGuideRates; Assert.That(result, Is.False); } + [Test] + public void CanSetGuideRates_Get_WhenConnectedToLX200GPS_ThenReturnsTrue() + { + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS); + _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.LX200GPS_42G); + _telescope.Connected = true; + + var result = _telescope.CanSetGuideRates; + + Assert.That(result, Is.True); + } + [Test] public void CanSetPark_Get_ReturnsFalse() { diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 628c0cb..e78899c 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -253,7 +253,7 @@ namespace ASCOM.Meade.net break; default: LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters); - throw new InvalidValueException($"Site {actionParameters} not allowed must be between 1 and 4"); + throw new InvalidValueException($"Site {actionParameters} not allowed, must be between 1 and 4"); } @@ -755,8 +755,12 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanSetGuideRates", "Get - " + false.ToString()); - return false; + CheckConnected("CanSetGuideRates Get"); + + var canSetGuideRate = IsGuideRateSettingSupported(); + + LogMessage("CanSetGuideRates", "Get - " + canSetGuideRate.ToString()); + return canSetGuideRate; } } From e582761f530cd2f839cd5ce0a3ee08831aabf14d Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 21 Jul 2019 18:43:13 +0100 Subject: [PATCH 12/25] Taken out the ability to get or set the guide rates, as there doesn't appear to be a method to read the guide rates in the meade command set. --- .../TelescopeUnitTests.cs | 43 +++++++++-------- Meade.net.Telescope/Telescope.cs | 48 ++++++++++--------- 2 files changed, 47 insertions(+), 44 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 3c97754..bc217c2 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -643,7 +643,8 @@ namespace Meade.net.Telescope.UnitTests var result = _telescope.CanSetGuideRates; - Assert.That(result, Is.True); + //Assert.That(result, Is.True); + Assert.That(result, Is.False); } [Test] @@ -832,7 +833,7 @@ namespace Meade.net.Telescope.UnitTests } [Test] - public void GuideRateDeclination_Set_ThenThrowsException() + public void GuideRateDeclination_Set_WhenNotSupported_ThenThrowsException() { _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497); @@ -842,19 +843,19 @@ namespace Meade.net.Telescope.UnitTests Assert.That(excpetion.AccessorSet, Is.True); } - [Test] - public void GuideRateDeclination_Set_WhenIsSupported_ThenSetsNewGuideRate() - { - var newGuideRate = 10; + //[Test] + //public void GuideRateDeclination_Set_WhenIsSupported_ThenSetsNewGuideRate() + //{ + // var newGuideRate = 10; - _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS); + // _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS); - _telescope.GuideRateDeclination = newGuideRate; + // _telescope.GuideRateDeclination = newGuideRate; - _sharedResourcesWrapperMock.Verify( x => x.SendBlind(":Rg10.0#"),Times.Once); + // _sharedResourcesWrapperMock.Verify( x => x.SendBlind(":Rg10.0#"),Times.Once); - Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate)); - } + // Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate)); + //} [Test] public void GuideRateRightAscension_Get_ThenThrowsException() @@ -865,7 +866,7 @@ namespace Meade.net.Telescope.UnitTests } [Test] - public void GuideRateRightAscension_Set_ThenThrowsException() + public void GuideRateRightAscension_Set_WhenNotSupported_ThenThrowsException() { _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497); @@ -875,19 +876,19 @@ namespace Meade.net.Telescope.UnitTests Assert.That(excpetion.AccessorSet, Is.True); } - [Test] - public void GuideRateRightAscension_Set_WhenIsSupported_ThenSetsNewGuideRate() - { - var newGuideRate = 10; + //[Test] + //public void GuideRateRightAscension_Set_WhenIsSupported_ThenSetsNewGuideRate() + //{ + // var newGuideRate = 10; - _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS); + // _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS); - _telescope.GuideRateRightAscension = newGuideRate; + // _telescope.GuideRateRightAscension = newGuideRate; - _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Rg10.0#"), Times.Once); + // _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Rg10.0#"), Times.Once); - Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate)); - } + // Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate)); + //} [Test] public void IsPulseGuiding_Get_ReturnsFalse() diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index e78899c..6b62306 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -375,14 +375,15 @@ namespace ASCOM.Meade.net return false; } - private bool IsGuideRateSettingSupported() - { - if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) - { - return true; - } - return false; - } + //todo implement ability to read and write the guide rate from the telescope. + //private bool IsGuideRateSettingSupported() + //{ + // if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) + // { + // return true; + // } + // return false; + //} private bool FirmwareIsGreaterThan(string minVersion) { @@ -757,7 +758,8 @@ namespace ASCOM.Meade.net { CheckConnected("CanSetGuideRates Get"); - var canSetGuideRate = IsGuideRateSettingSupported(); + //var canSetGuideRate = IsGuideRateSettingSupported(); + var canSetGuideRate = false; LogMessage("CanSetGuideRates", "Get - " + canSetGuideRate.ToString()); return canSetGuideRate; @@ -943,25 +945,25 @@ namespace ASCOM.Meade.net private void SetNewGuideRate(double value, string propertyName) { - if (!IsGuideRateSettingSupported()) - { + //if (!IsGuideRateSettingSupported()) + //{ LogMessage("GuideRateDeclination Set", "Not implemented"); throw new PropertyNotImplementedException(propertyName, true); - } + //} - if (!value.InRange(0, 15.0417)) - { - throw new InvalidValueException(propertyName, value.ToString(), "0 to 15.0417”/sec"); - } + //if (!value.InRange(0, 15.0417)) + //{ + // throw new InvalidValueException(propertyName, value.ToString(), "0 to 15.0417”/sec"); + //} - _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 - //sidereal speed(approx 15.0417”/sec)[Autostar II only] - //Returns: Nothing + //_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 + ////sidereal speed(approx 15.0417”/sec)[Autostar II only] + ////Returns: Nothing - _guideRate = value; + // _guideRate = value; } public double GuideRateDeclination From 692e39771c02f0e4fb5aa6108564694ae32cd8d7 Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 22 Jul 2019 00:18:40 +0100 Subject: [PATCH 13/25] Added the driver version to the trace log. --- Meade.net.Telescope/Telescope.cs | 1 + Meade.net.focuser/Focuser.cs | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 6b62306..35f5a27 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -106,6 +106,7 @@ namespace ASCOM.Meade.net //todo move the TraceLogger out to a factory class. _tl = new TraceLogger("", "Meade.Generic.Telescope"); LogMessage("Telescope", "Starting initialisation"); + LogMessage("Telescope", $"Driver version: {DriverVersion}"); ReadProfile(); // Read device configuration from the ASCOM Profile store diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index 7b99b39..eb3eae2 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -74,14 +74,17 @@ namespace ASCOM.Meade.net private void Initialise() { + //todo move the TraceLogger out to a factory class. Tl = new TraceLogger("", "Meade.Generic.focusser"); - Tl.LogMessage("Focuser", "Starting initialisation"); + LogMessage("Focuser", "Starting initialisation"); + LogMessage("Focuser", $"Driver version: {DriverVersion}"); + ReadProfile(); // Read device configuration from the ASCOM Profile store IsConnected = false; // Initialise connected to false - Tl.LogMessage("Focuser", "Completed initialisation"); + LogMessage("Focuser", "Completed initialisation"); } From 37437b7c7cdb45a326367067bf0a8c931286bfcd Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 22 Jul 2019 15:06:03 +0100 Subject: [PATCH 14/25] Readded support for guide rate get and set. This will use a default value of 0.67 sidereal rate. But can be overridden by a user. --- .../TelescopeUnitTests.cs | 47 +++---- Meade.net.Telescope/StringExtensions.cs | 5 + Meade.net.Telescope/Telescope.cs | 91 ++++++++----- Meade.net/GarbageCollection.cs | 2 - Meade.net/ProfileProperties.cs | 1 + Meade.net/SetupDialogForm.cs | 13 ++ Meade.net/SetupDialogForm.designer.cs | 33 +++++ Meade.net/SetupDialogForm.resx | 123 ++++++++++++++++-- Meade.net/SharedResources.cs | 10 +- Meade.net/Wrapper/SharedResourcesWrapper.cs | 6 + .../TelescopeTestConsole.csproj | 2 +- 11 files changed, 261 insertions(+), 72 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index bc217c2..9fce5ed 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -30,6 +30,7 @@ namespace Meade.net.Telescope.UnitTests _profileProperties = new ProfileProperties(); _profileProperties.TraceLogger = false; _profileProperties.ComPort = "TestCom1"; + _profileProperties.GuideRateArcSecondsPerSecond = 1.23; _utilMock = new Mock(); _utilExtraMock = new Mock(); @@ -37,7 +38,8 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock = new Mock(); _sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MM’SS"); - + + _sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(_profileProperties); _sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny())).Callback(action => { action(); }); _sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny>())).Returns>( (func) => func()); _sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny>())).Returns>((func) => func()); @@ -643,8 +645,7 @@ namespace Meade.net.Telescope.UnitTests var result = _telescope.CanSetGuideRates; - //Assert.That(result, Is.True); - Assert.That(result, Is.False); + Assert.That(result, Is.True); } [Test] @@ -829,7 +830,7 @@ namespace Meade.net.Telescope.UnitTests { var result = _telescope.GuideRateDeclination; - Assert.That(result, Is.EqualTo(0.004178074616551509)); + Assert.That(result, Is.EqualTo(0.00034166666666666666)); } [Test] @@ -843,26 +844,26 @@ namespace Meade.net.Telescope.UnitTests Assert.That(excpetion.AccessorSet, Is.True); } - //[Test] - //public void GuideRateDeclination_Set_WhenIsSupported_ThenSetsNewGuideRate() - //{ - // var newGuideRate = 10; + [Test] + public void GuideRateDeclination_Set_WhenIsSupported_ThenSetsNewGuideRate() + { + var newGuideRate = 0.00034166666666666666; - // _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS); + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS); - // _telescope.GuideRateDeclination = newGuideRate; + _telescope.GuideRateDeclination = newGuideRate; - // _sharedResourcesWrapperMock.Verify( x => x.SendBlind(":Rg10.0#"),Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Rg01.2#"), Times.Once); - // Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate)); - //} + Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate)); + } [Test] public void GuideRateRightAscension_Get_ThenThrowsException() { var result = _telescope.GuideRateRightAscension; - Assert.That(result, Is.EqualTo(0.004178074616551509)); + Assert.That(result, Is.EqualTo(0.00034166666666666666)); } [Test] @@ -876,19 +877,19 @@ namespace Meade.net.Telescope.UnitTests Assert.That(excpetion.AccessorSet, Is.True); } - //[Test] - //public void GuideRateRightAscension_Set_WhenIsSupported_ThenSetsNewGuideRate() - //{ - // var newGuideRate = 10; + [Test] + public void GuideRateRightAscension_Set_WhenIsSupported_ThenSetsNewGuideRate() + { + var newGuideRate = 0.00034166666666666666; - // _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS); + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS); - // _telescope.GuideRateRightAscension = newGuideRate; + _telescope.GuideRateRightAscension = newGuideRate; - // _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Rg10.0#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Rg01.2#"), Times.Once); - // Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate)); - //} + Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate)); + } [Test] public void IsPulseGuiding_Get_ReturnsFalse() diff --git a/Meade.net.Telescope/StringExtensions.cs b/Meade.net.Telescope/StringExtensions.cs index 85341c5..14909c1 100644 --- a/Meade.net.Telescope/StringExtensions.cs +++ b/Meade.net.Telescope/StringExtensions.cs @@ -6,5 +6,10 @@ namespace ASCOM.Meade.net { return int.Parse(str); } + + public static double ToDouble(this string str) + { + return double.Parse(str); + } } } \ No newline at end of file diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 35f5a27..28dc3b4 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -111,9 +111,7 @@ namespace ASCOM.Meade.net ReadProfile(); // Read device configuration from the ASCOM Profile store IsConnected = false; // Initialise connected to false - - _guideRate = 15.0 * (1.0 / 3600.0) / SIDRATE; - + LogMessage("Telescope", "Completed initialisation"); } @@ -376,15 +374,14 @@ namespace ASCOM.Meade.net return false; } - //todo implement ability to read and write the guide rate from the telescope. - //private bool IsGuideRateSettingSupported() - //{ - // if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) - // { - // return true; - // } - // return false; - //} + private bool IsGuideRateSettingSupported() + { + if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) + { + return true; + } + return false; + } private bool FirmwareIsGreaterThan(string minVersion) { @@ -759,8 +756,7 @@ namespace ASCOM.Meade.net { CheckConnected("CanSetGuideRates Get"); - //var canSetGuideRate = IsGuideRateSettingSupported(); - var canSetGuideRate = false; + var canSetGuideRate = IsGuideRateSettingSupported(); LogMessage("CanSetGuideRates", "Get - " + canSetGuideRate.ToString()); return canSetGuideRate; @@ -946,33 +942,48 @@ namespace ASCOM.Meade.net private void SetNewGuideRate(double value, string propertyName) { - //if (!IsGuideRateSettingSupported()) - //{ + if (!IsGuideRateSettingSupported()) + { LogMessage("GuideRateDeclination Set", "Not implemented"); throw new PropertyNotImplementedException(propertyName, true); - //} + } - //if (!value.InRange(0, 15.0417)) - //{ - // throw new InvalidValueException(propertyName, value.ToString(), "0 to 15.0417”/sec"); - //} + var valueInArcSecondsPerSecond = DegreesPerSecondToArcSecondPerSecond(value); - //_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 - ////sidereal speed(approx 15.0417”/sec)[Autostar II only] - ////Returns: Nothing + if (!valueInArcSecondsPerSecond.InRange(0, 15.0417)) + { + throw new InvalidValueException(propertyName, valueInArcSecondsPerSecond.ToString(), "0 to 15.0417”/sec"); + } - // _guideRate = value; + _sharedResourcesWrapper.SendBlind($":Rg{valueInArcSecondsPerSecond: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 + //sidereal speed(approx 15.0417”/sec)[Autostar II only] + //Returns: Nothing + + _guideRate = valueInArcSecondsPerSecond; + + WriteProfile(); + } + + private double DegreesPerSecondToArcSecondPerSecond(double value) + { + return value * 3600.0; + } + + private double ArcSecondPerSecondToDegreesPerSecond(double value) + { + return value / 3600.0; } public double GuideRateDeclination { get { - LogMessage("GuideRateDeclination Get", "Not implemented"); - return _guideRate; + var degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_guideRate); + LogMessage("GuideRateDeclination Get", $"{_guideRate:00.0} arc seconds / second = {degreesPerSecond} degrees per second"); + return degreesPerSecond; } set { @@ -984,8 +995,9 @@ namespace ASCOM.Meade.net { get { - LogMessage("GuideRateRightAscension Get", "Not implemented"); - return _guideRate; + var degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_guideRate); + LogMessage("GuideRateRightAscension Get", $"{_guideRate:00.0} arc seconds / second = {degreesPerSecond} degrees per second"); + return degreesPerSecond; } set { @@ -2087,11 +2099,24 @@ namespace ASCOM.Meade.net /// internal void ReadProfile() { - var profileProperties = _sharedResourcesWrapper.ReadProfile(); + ProfileProperties profileProperties = _sharedResourcesWrapper.ReadProfile(); _tl.Enabled = profileProperties.TraceLogger; _comPort = profileProperties.ComPort; + _guideRate = profileProperties.GuideRateArcSecondsPerSecond; } + internal void WriteProfile() + { + var profileProperties = new ProfileProperties + { + TraceLogger = _tl.Enabled, + ComPort = _comPort, + GuideRateArcSecondsPerSecond = _guideRate + }; + + _sharedResourcesWrapper.WriteProfile(profileProperties); + } + /// /// Log helper function that takes formatted strings and arguments /// diff --git a/Meade.net/GarbageCollection.cs b/Meade.net/GarbageCollection.cs index f6d5e82..a68096f 100644 --- a/Meade.net/GarbageCollection.cs +++ b/Meade.net/GarbageCollection.cs @@ -9,14 +9,12 @@ namespace ASCOM.Meade.net class GarbageCollection { private bool _mbContinueThread; - private bool _mGcWatchStopped; private readonly int _miInterval; private readonly ManualResetEvent _mEventThreadEnded; public GarbageCollection(int iInterval) { _mbContinueThread = true; - _mGcWatchStopped = false; _miInterval = iInterval; _mEventThreadEnded = new ManualResetEvent(false); } diff --git a/Meade.net/ProfileProperties.cs b/Meade.net/ProfileProperties.cs index a445dd4..6614cc8 100644 --- a/Meade.net/ProfileProperties.cs +++ b/Meade.net/ProfileProperties.cs @@ -5,5 +5,6 @@ namespace ASCOM.Meade.net // properies that are part of the profile public string ComPort { get; set; } public bool TraceLogger { get; set; } + public double GuideRateArcSecondsPerSecond { get; set; } } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index c416f5d..433f63d 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -46,6 +46,8 @@ namespace ASCOM.Meade.net { comboBoxComPort.SelectedItem = profileProperties.ComPort; } + + txtGuideRate.Text = profileProperties.GuideRateArcSecondsPerSecond.ToString(); } public ProfileProperties GetProfile() @@ -63,5 +65,16 @@ namespace ASCOM.Meade.net { Activate(); } + + private void TextBox1_TextChanged(object sender, EventArgs e) + { + //const double SIDRATE = 0.9972695677; //synodic/solar seconds per sidereal second + var newGuideRate = double.Parse(txtGuideRate.Text); + + const double siderealArcSecondsPerSecond = 15.041; + var percentOfSideReal = (newGuideRate / siderealArcSecondsPerSecond * 100); + + lblPercentOfSiderealRate.Text = $"({percentOfSideReal:00.0}% of sidereal rate)"; + } } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.designer.cs b/Meade.net/SetupDialogForm.designer.cs index 11f868f..b09f711 100644 --- a/Meade.net/SetupDialogForm.designer.cs +++ b/Meade.net/SetupDialogForm.designer.cs @@ -36,6 +36,10 @@ namespace ASCOM.Meade.net this.label2 = new System.Windows.Forms.Label(); this.chkTrace = new System.Windows.Forms.CheckBox(); this.comboBoxComPort = new System.Windows.Forms.ComboBox(); + this.label3 = new System.Windows.Forms.Label(); + this.txtGuideRate = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.lblPercentOfSiderealRate = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit(); this.SuspendLayout(); // @@ -86,10 +90,35 @@ namespace ASCOM.Meade.net resources.ApplyResources(this.comboBoxComPort, "comboBoxComPort"); this.comboBoxComPort.Name = "comboBoxComPort"; // + // label3 + // + resources.ApplyResources(this.label3, "label3"); + this.label3.Name = "label3"; + // + // txtGuideRate + // + resources.ApplyResources(this.txtGuideRate, "txtGuideRate"); + this.txtGuideRate.Name = "txtGuideRate"; + this.txtGuideRate.TextChanged += new System.EventHandler(this.TextBox1_TextChanged); + // + // label4 + // + resources.ApplyResources(this.label4, "label4"); + this.label4.Name = "label4"; + // + // lblPercentOfSiderealRate + // + resources.ApplyResources(this.lblPercentOfSiderealRate, "lblPercentOfSiderealRate"); + this.lblPercentOfSiderealRate.Name = "lblPercentOfSiderealRate"; + // // SetupDialogForm // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lblPercentOfSiderealRate); + this.Controls.Add(this.label4); + this.Controls.Add(this.txtGuideRate); + this.Controls.Add(this.label3); this.Controls.Add(this.comboBoxComPort); this.Controls.Add(this.chkTrace); this.Controls.Add(this.label2); @@ -118,5 +147,9 @@ namespace ASCOM.Meade.net private System.Windows.Forms.Label label2; private System.Windows.Forms.CheckBox chkTrace; private System.Windows.Forms.ComboBox comboBoxComPort; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox txtGuideRate; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label lblPercentOfSiderealRate; } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.resx b/Meade.net/SetupDialogForm.resx index b050dfb..99399de 100644 --- a/Meade.net/SetupDialogForm.resx +++ b/Meade.net/SetupDialogForm.resx @@ -123,7 +123,7 @@ - 281, 112 + 281, 225 59, 24 @@ -145,13 +145,13 @@ $this - 6 + 10 Bottom, Right - 281, 142 + 281, 255 59, 25 @@ -172,7 +172,7 @@ $this - 5 + 9 12, 9 @@ -196,7 +196,7 @@ $this - 4 + 8 Top, Right @@ -223,7 +223,7 @@ $this - 3 + 7 True @@ -250,7 +250,7 @@ $this - 2 + 6 True @@ -277,7 +277,7 @@ $this - 1 + 5 77, 87 @@ -298,6 +298,111 @@ $this + 4 + + + True + + + 13, 225 + + + 61, 13 + + + 8 + + + Guide Rate + + + label3 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + 80, 222 + + + 46, 20 + + + 9 + + + 10.0 + + + txtGuideRate + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + True + + + 132, 225 + + + 122, 13 + + + 10 + + + Arc seconds per second + + + label4 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + 132, 238 + + + 105, 13 + + + 11 + + + (67% of sidereal rate) + + + lblPercentOfSiderealRate + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 @@ -307,7 +412,7 @@ 6, 13 - 350, 175 + 350, 288 CenterScreen diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 9068cf3..1e79de9 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -158,6 +158,7 @@ namespace ASCOM.Meade.net // Constants used for Profile persistence private const string ComPortProfileName = "COM Port"; private const string TraceStateProfileName = "Trace Level"; + private const string GuideRateProfileName = "Guide Rate Arc Seconds Per Second"; public static void WriteProfile(ProfileProperties profileProperties) { @@ -168,12 +169,14 @@ namespace ASCOM.Meade.net driverProfile.DeviceType = "Telescope"; driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString()); driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort); + driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString()); } } } private const string ComPortDefault = "COM1"; private const string TraceStateDefault = "false"; + private const string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate public static ProfileProperties ReadProfile() { @@ -183,10 +186,9 @@ namespace ASCOM.Meade.net using (Profile driverProfile = new Profile()) { driverProfile.DeviceType = "Telescope"; - profileProperties.ComPort = - driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault); - profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId, - TraceStateProfileName, string.Empty, TraceStateDefault)); + profileProperties.ComPort = driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault); + profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId, TraceStateProfileName, string.Empty, TraceStateDefault)); + profileProperties.GuideRateArcSecondsPerSecond = double.Parse(driverProfile.GetValue(DriverId, GuideRateProfileName, string.Empty, GuideRateProfileNameDefault)); } return profileProperties; diff --git a/Meade.net/Wrapper/SharedResourcesWrapper.cs b/Meade.net/Wrapper/SharedResourcesWrapper.cs index e4df7f5..c2fda79 100644 --- a/Meade.net/Wrapper/SharedResourcesWrapper.cs +++ b/Meade.net/Wrapper/SharedResourcesWrapper.cs @@ -23,6 +23,7 @@ namespace ASCOM.Meade.net.Wrapper ProfileProperties ReadProfile(); void SetupDialog(); + void WriteProfile(ProfileProperties profileProperties); } public class SharedResourcesWrapper : ISharedResourcesWrapper @@ -80,5 +81,10 @@ namespace ASCOM.Meade.net.Wrapper { SharedResources.SetupDialog(); } + + public void WriteProfile(ProfileProperties profileProperties) + { + SharedResources.WriteProfile(profileProperties); + } } } diff --git a/TelescopeTestConsole/TelescopeTestConsole.csproj b/TelescopeTestConsole/TelescopeTestConsole.csproj index 7fb2a6a..625da99 100644 --- a/TelescopeTestConsole/TelescopeTestConsole.csproj +++ b/TelescopeTestConsole/TelescopeTestConsole.csproj @@ -16,7 +16,7 @@ 512 - AnyCPU + x86 true full false From 64e2b9c6f9b2032f6e0003c188052eb2e05575b9 Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 22 Jul 2019 15:27:52 +0100 Subject: [PATCH 15/25] Set's the guide rate after connection if setting guide rate is supported. --- Meade.net.Telescope/Telescope.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 28dc3b4..ee1482d 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -338,6 +338,12 @@ namespace ASCOM.Meade.net LogMessage("Connected Set", $"New Pulse Guiding Supported: {_userNewerPulseGuiding}"); IsConnected = true; + + if (CanSetGuideRates) + { + SetNewGuideRate( _guideRate, "Connect" ); + } + } catch (Exception) { @@ -961,10 +967,12 @@ namespace ASCOM.Meade.net //Rates when the CCD guider or handbox guider buttons are pressed when the guide rate is selected.Rate shall not exceed //sidereal speed(approx 15.0417”/sec)[Autostar II only] //Returns: Nothing - - _guideRate = valueInArcSecondsPerSecond; + if (_guideRate != valueInArcSecondsPerSecond) + { + _guideRate = valueInArcSecondsPerSecond; - WriteProfile(); + WriteProfile(); + } } private double DegreesPerSecondToArcSecondPerSecond(double value) From 1452f3cf07bb2e5caa1efdc9c7dd16661c9569ec Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 22 Jul 2019 16:45:01 +0100 Subject: [PATCH 16/25] Re-designed the Site action so that you can now select a site, get a site name, or get a site name. --- .../TelescopeUnitTests.cs | 76 ++++++++- Meade.net.Telescope/StringExtensions.cs | 18 ++ Meade.net.Telescope/Telescope.cs | 155 +++++++++++++++++- 3 files changed, 237 insertions(+), 12 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 9fce5ed..198673b 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -152,7 +152,8 @@ namespace Meade.net.Telescope.UnitTests { ConnectTelescope(); - _telescope.Action("site", site); + string parameters = $"select {site}"; + _telescope.Action("site", parameters); _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":W{site}#"), Times.Once); } @@ -163,9 +164,78 @@ namespace Meade.net.Telescope.UnitTests { ConnectTelescope(); - var exception = Assert.Throws(() => { _telescope.Action("site", site); }); + string parameters = $"select {site}"; + var exception = Assert.Throws(() => { _telescope.Action("site", parameters); }); - Assert.That(exception.Message, Is.EqualTo($"Site {site} not allowed, must be between 1 and 4")); + Assert.That(exception.Message, Is.EqualTo($"Site {parameters} not allowed, must be between 1 and 4")); + } + + [TestCase("1", ":GM#", "Home")] + [TestCase("2", ":GN#", "Club")] + [TestCase("3", ":GO#", "GPS")] + [TestCase("4", ":GP#", "Parents")] + public void Action_Site_GetName_WhenCallingWithValidValues_ThenSelectsCorrectSite(string site, string telescopeCommand, string siteName) + { + ConnectTelescope(); + + _sharedResourcesWrapperMock.Setup(x => x.SendString(telescopeCommand)).Returns(siteName); + + string parameters = $"GetName {site}"; + var result = _telescope.Action("site", parameters); + + _sharedResourcesWrapperMock.Verify(x => x.SendString(telescopeCommand), Times.Once); + Assert.That(result, Is.EqualTo(siteName)); + } + + [TestCase("0")] + [TestCase("5")] + public void Action_Site_GetName_WhenCallingWithInCorrectValues_ThenThrowsException(string site) + { + ConnectTelescope(); + + string parameters = $"GetName {site}"; + var exception = Assert.Throws(() => { _telescope.Action("site", parameters); }); + + Assert.That(exception.Message, Is.EqualTo($"Site {parameters} not allowed, must be between 1 and 4")); + } + + [TestCase("1", ":SMHome#", "Home")] + [TestCase("2", ":SNClub#", "Club")] + [TestCase("3", ":SOGPS#", "GPS")] + [TestCase("4", ":SPParents#", "Parents")] + public void Action_Site_SetName_WhenCallingWithValidValues_ThenSelectsCorrectSite(string site, string telescopeCommand, string siteName) + { + ConnectTelescope(); + + _sharedResourcesWrapperMock.Setup(x => x.SendChar(telescopeCommand)).Returns("1"); + + string parameters = $"SetName {site} {siteName}"; + _telescope.Action("site", parameters); + + _sharedResourcesWrapperMock.Verify(x => x.SendChar(telescopeCommand), Times.Once); + } + + [TestCase("0")] + [TestCase("5")] + public void Action_Site_SetName_WhenCallingWithInCorrectValues_ThenThrowsException(string site) + { + ConnectTelescope(); + + string parameters = $"SetName {site}"; + var exception = Assert.Throws(() => { _telescope.Action("site", parameters); }); + + Assert.That(exception.Message, Is.EqualTo($"Site {parameters} not allowed, must be between 1 and 4")); + } + + [Test] + public void Action_Site_WhenCallingUnknownParam_ThenThrowsException() + { + ConnectTelescope(); + + string parameters = $"unknown"; + var exception = Assert.Throws(() => { _telescope.Action("site", parameters); }); + + Assert.That(exception.Message, Is.EqualTo($"Site parameters {parameters} not known")); } [Test] diff --git a/Meade.net.Telescope/StringExtensions.cs b/Meade.net.Telescope/StringExtensions.cs index 14909c1..2f2c089 100644 --- a/Meade.net.Telescope/StringExtensions.cs +++ b/Meade.net.Telescope/StringExtensions.cs @@ -11,5 +11,23 @@ namespace ASCOM.Meade.net { return double.Parse(str); } + + public static int Position(this string str, char find, int instance) + { + var currentInstance = 0; + for (var i = 0; i < str.Length; i++) + { + if (str[i] == find) + { + currentInstance++; + if (currentInstance == instance) + { + return i; + } + } + } + + return -1; + } } } \ No newline at end of file diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index ee1482d..6fac6ed 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -242,21 +242,68 @@ namespace ASCOM.Meade.net break; case "site": - switch (actionParameters.ToLower()) + var parames = actionParameters.ToLower().Split(' '); + switch (parames[0]) { - case "1": - case "2": - case "3": - case "4": - SelectSite(actionParameters.ToInteger()); + case "select": + switch (parames[1]) + { + case "1": + case "2": + case "3": + case "4": + SelectSite(parames[1].ToInteger()); + break; + default: + LogMessage("", "Action {0}, parameters {1} not implemented", actionName, + actionParameters); + throw new InvalidValueException( + $"Site {actionParameters} not allowed, must be between 1 and 4"); + + } + break; + case "getname": + switch (parames[1]) + { + case "1": + case "2": + case "3": + case "4": + return GetSiteName(parames[1].ToInteger()); + default: + LogMessage("", "Action {0}, parameters {1} not implemented", actionName, + actionParameters); + throw new InvalidValueException( + $"Site {actionParameters} not allowed, must be between 1 and 4"); + + } + break; + case "setname": + switch (parames[1]) + { + case "1": + case "2": + case "3": + case "4": + var sitename = actionParameters.Substring(actionParameters.Position(' ', 2)).Trim(); + + SetSiteName(parames[1].ToInteger(), sitename); + break; + default: + LogMessage("", "Action {0}, parameters {1} not implemented", actionName, + actionParameters); + throw new InvalidValueException( + $"Site {actionParameters} not allowed, must be between 1 and 4"); + + } break; default: - LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters); - throw new InvalidValueException($"Site {actionParameters} not allowed, must be between 1 and 4"); - + throw new InvalidValueException( + $"Site parameters {actionParameters} not known"); } break; + default: LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters); throw new ActionNotImplementedException($"{actionName}"); @@ -434,6 +481,96 @@ namespace ASCOM.Meade.net //Returns: Nothing } + private void SetSiteName(int site, string sitename) + { + CheckConnected("SetSiteName"); + + if (site < 1) + throw new ArgumentOutOfRangeException("site", site, "Site cannot be lower than 1"); + else if (site > 4) + throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4"); + + string command = String.Empty; + switch (site) + { + case 1: + command = $":SM{sitename}#"; + //:SM# + //Set site 1’s name to be.LX200s only accept 3 character strings. Other scopes accept up to 15 characters. + // Returns: + //0 – Invalid + //1 - Valid + break; + case 2: + command = $":SN{sitename}#"; + //:SN# + //Set site 2’s name to be.LX200s only accept 3 character strings. Other scopes accept up to 15 characters. + // Returns: + //0 – Invalid + //1 - Valid + break; + case 3: + command = $":SO{sitename}#"; + //:SO# + //Set site 3’s name to be.LX200s only accept 3 character strings. Other scopes accept up to 15 characters. + // Returns: + //0 – Invalid + //1 - Valid + break; + case 4: + command = $":SP{sitename}#"; + //:SP# + //Set site 4’s name to be.LX200s only accept 3 character strings. Other scopes accept up to 15 characters. + // Returns: + //0 – Invalid + //1 - Valid + break; + + } + + var result = _sharedResourcesWrapper.SendChar(command); + if (result != "1") + { + throw new InvalidOperationException("Failed to set site name."); + } + } + + private string GetSiteName(int site) + { + CheckConnected("GetSiteName"); + + if (site < 1) + throw new ArgumentOutOfRangeException("site", site, "Site cannot be lower than 1"); + else if (site > 4) + throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4"); + + switch (site) + { + case 1: + return _sharedResourcesWrapper.SendString(":GM#"); + //:GM# Get Site 1 Name + //Returns: # + //A ‘#’ terminated string with the name of the requested site. + case 2: + return _sharedResourcesWrapper.SendString(":GN#"); + //:GN# Get Site 2 Name + //Returns: # + //A ‘#’ terminated string with the name of the requested site. + case 3: + return _sharedResourcesWrapper.SendString(":GO#"); + //:GO# Get Site 3 Name + //Returns: # + //A ‘#’ terminated string with the name of the requested site. + case 4: + return _sharedResourcesWrapper.SendString(":GP#"); + //:GP# Get Site 4 Name + //Returns: # + //A ‘#’ terminated string with the name of the requested site. + } + + throw new ArgumentOutOfRangeException("site", site, "Site out of range"); + } + public string Description { // TODO customise this device description From e9d41a24121163af85906559a87df4d2f7ceb90b Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 23 Jul 2019 10:32:18 +0100 Subject: [PATCH 17/25] Moved the code that reports the driver version to the end of the initialisation. --- Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs | 2 +- Meade.net.Telescope/Telescope.cs | 4 +--- Meade.net.focuser/Focuser.cs | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 198673b..32645d3 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -201,7 +201,7 @@ namespace Meade.net.Telescope.UnitTests [TestCase("1", ":SMHome#", "Home")] [TestCase("2", ":SNClub#", "Club")] - [TestCase("3", ":SOGPS#", "GPS")] + [TestCase("3", ":SOGPS Site#", "GPS Site")] [TestCase("4", ":SPParents#", "Parents")] public void Action_Site_SetName_WhenCallingWithValidValues_ThenSelectsCorrectSite(string site, string telescopeCommand, string siteName) { diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 6fac6ed..600ef4e 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -105,14 +105,12 @@ namespace ASCOM.Meade.net { //todo move the TraceLogger out to a factory class. _tl = new TraceLogger("", "Meade.Generic.Telescope"); - LogMessage("Telescope", "Starting initialisation"); - LogMessage("Telescope", $"Driver version: {DriverVersion}"); - ReadProfile(); // Read device configuration from the ASCOM Profile store IsConnected = false; // Initialise connected to false LogMessage("Telescope", "Completed initialisation"); + LogMessage("Telescope", $"Driver version: {DriverVersion}"); } diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index eb3eae2..2e80def 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -77,14 +77,12 @@ namespace ASCOM.Meade.net //todo move the TraceLogger out to a factory class. Tl = new TraceLogger("", "Meade.Generic.focusser"); - LogMessage("Focuser", "Starting initialisation"); - LogMessage("Focuser", $"Driver version: {DriverVersion}"); - ReadProfile(); // Read device configuration from the ASCOM Profile store IsConnected = false; // Initialise connected to false LogMessage("Focuser", "Completed initialisation"); + LogMessage("Focuser", $"Driver version: {DriverVersion}"); } From cc05808542c95ebed64890a09741eb0305a9c330 Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 23 Jul 2019 10:41:19 +0100 Subject: [PATCH 18/25] Added extra logging when reading the profile into the driver. Added readprofile just before the connection is made to make sure that the latest values are used. --- Meade.net.Telescope/Telescope.cs | 8 +++++++- Meade.net.focuser/Focuser.cs | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 600ef4e..bcc866a 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -367,9 +367,11 @@ namespace ASCOM.Meade.net if (value) { - LogMessage("Connected Set", "Connecting to port {0}", _comPort); try { + ReadProfile(); + + LogMessage("Connected Set", "Connecting to port {0}", _comPort); _sharedResourcesWrapper.Connect("Serial"); try { @@ -2246,6 +2248,10 @@ namespace ASCOM.Meade.net _tl.Enabled = profileProperties.TraceLogger; _comPort = profileProperties.ComPort; _guideRate = profileProperties.GuideRateArcSecondsPerSecond; + + LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}"); + LogMessage("ReadProfile", $"Com Port: {_comPort}"); + LogMessage("ReadProfile", $"Guide Rate: {_guideRate}"); } internal void WriteProfile() diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index 2e80def..cbd9ad2 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -178,6 +178,7 @@ namespace ASCOM.Meade.net { try { + ReadProfile(); _sharedResourcesWrapper.Connect("Serial"); try { @@ -579,6 +580,9 @@ namespace ASCOM.Meade.net var profileProperties = _sharedResourcesWrapper.ReadProfile(); Tl.Enabled = profileProperties.TraceLogger; _comPort = profileProperties.ComPort; + + LogMessage("ReadProfile", $"Trace logger enabled: {Tl.Enabled}"); + LogMessage("ReadProfile", $"Com Port: {_comPort}"); } /// From 87c8457bf082fbea2082ba90c2a1f0aadb00bc1a Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 23 Jul 2019 14:12:33 +0100 Subject: [PATCH 19/25] All guide rate set commands now write the value to the telescope and to the internal variable, as well as saving to the profile. Set's also include a log message as well. --- Meade.net.Telescope/Telescope.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index bcc866a..40a97d9 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1087,7 +1087,7 @@ namespace ASCOM.Meade.net { if (!IsGuideRateSettingSupported()) { - LogMessage("GuideRateDeclination Set", "Not implemented"); + LogMessage($"{propertyName} Set", "Not implemented"); throw new PropertyNotImplementedException(propertyName, true); } @@ -1098,18 +1098,17 @@ namespace ASCOM.Meade.net throw new InvalidValueException(propertyName, valueInArcSecondsPerSecond.ToString(), "0 to 15.0417”/sec"); } + LogMessage($"{propertyName} Set", $"Setting new guiderate {valueInArcSecondsPerSecond} arc seconds/second ({value} degrees/second)"); _sharedResourcesWrapper.SendBlind($":Rg{valueInArcSecondsPerSecond: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 //sidereal speed(approx 15.0417”/sec)[Autostar II only] //Returns: Nothing - if (_guideRate != valueInArcSecondsPerSecond) - { - _guideRate = valueInArcSecondsPerSecond; - WriteProfile(); - } + _guideRate = valueInArcSecondsPerSecond; + + WriteProfile(); } private double DegreesPerSecondToArcSecondPerSecond(double value) @@ -1127,7 +1126,7 @@ namespace ASCOM.Meade.net get { var degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_guideRate); - LogMessage("GuideRateDeclination Get", $"{_guideRate:00.0} arc seconds / second = {degreesPerSecond} degrees per second"); + LogMessage("GuideRateDeclination Get", $"{_guideRate} arc seconds / second = {degreesPerSecond} degrees per second"); return degreesPerSecond; } set @@ -1140,8 +1139,8 @@ namespace ASCOM.Meade.net { get { - var degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_guideRate); - LogMessage("GuideRateRightAscension Get", $"{_guideRate:00.0} arc seconds / second = {degreesPerSecond} degrees per second"); + double degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_guideRate); + LogMessage("GuideRateRightAscension Get", $"{_guideRate} arc seconds / second = {degreesPerSecond} degrees per second"); return degreesPerSecond; } set From 355320a4badbbf8649ece8398c5d325d210cc646 Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 23 Jul 2019 19:11:27 +0100 Subject: [PATCH 20/25] trying to make sure that the output of the log message contains the full double. --- Meade.net.Telescope/Telescope.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 40a97d9..184a6d9 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1098,7 +1098,7 @@ namespace ASCOM.Meade.net throw new InvalidValueException(propertyName, valueInArcSecondsPerSecond.ToString(), "0 to 15.0417”/sec"); } - LogMessage($"{propertyName} Set", $"Setting new guiderate {valueInArcSecondsPerSecond} arc seconds/second ({value} degrees/second)"); + LogMessage($"{propertyName} Set", $"Setting new guiderate {valueInArcSecondsPerSecond.ToString()} arc seconds/second ({value.ToString()} degrees/second)"); _sharedResourcesWrapper.SendBlind($":Rg{valueInArcSecondsPerSecond: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 @@ -1106,6 +1106,8 @@ namespace ASCOM.Meade.net //sidereal speed(approx 15.0417”/sec)[Autostar II only] //Returns: Nothing + //info from RickB says that 15.04107 is a better value for + _guideRate = valueInArcSecondsPerSecond; WriteProfile(); From 93c63cc0144dfdf78cac6bf2772faf68552be8a1 Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 23 Jul 2019 21:00:30 +0100 Subject: [PATCH 21/25] Fixed defect where the guide rate wasn't being saved properly --- Meade.net/SetupDialogForm.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index 433f63d..6bf7613 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -55,7 +55,8 @@ namespace ASCOM.Meade.net var profileProperties = new ProfileProperties { TraceLogger = chkTrace.Checked, - ComPort = comboBoxComPort.SelectedItem.ToString() + ComPort = comboBoxComPort.SelectedItem.ToString(), + GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text) }; return profileProperties; From 027cb24d3f2a655f85b86cd0e19b6144abf0a92e Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 23 Jul 2019 23:42:14 +0100 Subject: [PATCH 22/25] Added validation to the setup dialog. --- Meade.net/SetupDialogForm.cs | 42 +++++++++++++++++++++------ Meade.net/SetupDialogForm.designer.cs | 1 + 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index 6bf7613..36c8dac 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -5,7 +5,7 @@ using System.Windows.Forms; namespace ASCOM.Meade.net { - [ComVisible(false)] // Form not registered for COM! + [ComVisible(false)] // Form not registered for COM! public partial class SetupDialogForm : Form { public SetupDialogForm() @@ -33,14 +33,15 @@ namespace ASCOM.Meade.net { MessageBox.Show(other.Message); } - } + } public void SetProfile(ProfileProperties profileProperties) { chkTrace.Checked = profileProperties.TraceLogger; // set the list of com ports to those that are currently available comboBoxComPort.Items.Clear(); - comboBoxComPort.Items.AddRange(System.IO.Ports.SerialPort.GetPortNames()); // use System.IO because it's static + comboBoxComPort.Items.AddRange(System.IO.Ports.SerialPort + .GetPortNames()); // use System.IO because it's static // select the current port if possible if (comboBoxComPort.Items.Contains(profileProperties.ComPort)) { @@ -56,7 +57,7 @@ namespace ASCOM.Meade.net { TraceLogger = chkTrace.Checked, ComPort = comboBoxComPort.SelectedItem.ToString(), - GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text) + GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text.Trim()) }; return profileProperties; @@ -67,15 +68,38 @@ namespace ASCOM.Meade.net Activate(); } + private bool _guideRateValid = true; + private void TextBox1_TextChanged(object sender, EventArgs e) { - //const double SIDRATE = 0.9972695677; //synodic/solar seconds per sidereal second - var newGuideRate = double.Parse(txtGuideRate.Text); + //const double SIDRATE = 0.9972695677; //synodic/solar seconds per sidereal second + try + { + double newGuideRate = double.Parse(txtGuideRate.Text.Trim()); - const double siderealArcSecondsPerSecond = 15.041; - var percentOfSideReal = (newGuideRate / siderealArcSecondsPerSecond * 100); + const double siderealArcSecondsPerSecond = 15.041; + var percentOfSideReal = (newGuideRate / siderealArcSecondsPerSecond * 100); - lblPercentOfSiderealRate.Text = $"({percentOfSideReal:00.0}% of sidereal rate)"; + lblPercentOfSiderealRate.Text = $"({percentOfSideReal:00.0}% of sidereal rate)"; + _guideRateValid = true; + } + catch (Exception exception) + { + //Surpressing this exception as if the value is not valid then it's not useful. + _guideRateValid = false; + } + + UpdateOKButton(); + } + + private void UpdateOKButton() + { + cmdOK.Enabled = _guideRateValid && (comboBoxComPort.SelectedItem != null); + } + + private void ComboBoxComPort_SelectedValueChanged(object sender, EventArgs e) + { + UpdateOKButton(); } } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.designer.cs b/Meade.net/SetupDialogForm.designer.cs index b09f711..a714e67 100644 --- a/Meade.net/SetupDialogForm.designer.cs +++ b/Meade.net/SetupDialogForm.designer.cs @@ -89,6 +89,7 @@ namespace ASCOM.Meade.net this.comboBoxComPort.FormattingEnabled = true; resources.ApplyResources(this.comboBoxComPort, "comboBoxComPort"); this.comboBoxComPort.Name = "comboBoxComPort"; + this.comboBoxComPort.SelectedValueChanged += new System.EventHandler(this.ComboBoxComPort_SelectedValueChanged); // // label3 // From a9e2ec952840e24cd9f1daf8cdc59e5b6d1b8b96 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 25 Jul 2019 00:15:34 +0100 Subject: [PATCH 23/25] 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"); } } From fa613ecc92e5d0ba9d5e1399d5d86197f779d68c Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 26 Jul 2019 11:38:26 +0100 Subject: [PATCH 24/25] Fixed issue where the driver version number is being reported incorrectly. --- Meade.net.Telescope/Telescope.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 683b7d8..a88b23d 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -597,7 +597,7 @@ namespace ASCOM.Meade.net get { Version version = Assembly.GetExecutingAssembly().GetName().Version; - string driverVersion = $"{version.Major}.{version.Minor}.{version.Revision}.{version.Build}"; + string driverVersion = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; LogMessage("DriverVersion Get", driverVersion); return driverVersion; } From 4568f49f5fdb520129ee6822e9dc61eacff44d55 Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 26 Jul 2019 11:42:59 +0100 Subject: [PATCH 25/25] Fixed broken unit test --- Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 15b7523..ec57f83 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -505,7 +505,7 @@ namespace Meade.net.Telescope.UnitTests { Version version = System.Reflection.Assembly.GetAssembly(typeof(ASCOM.Meade.net.Telescope)).GetName().Version; - string exptectedDriverInfo = $"{version.Major}.{version.Minor}.{version.Revision}.{version.Build}"; + string exptectedDriverInfo = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; var driverVersion = _telescope.DriverVersion;