From 3e00398af011e8d127d30ae71d520e9e653db57c Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 24 May 2020 15:56:24 +0100 Subject: [PATCH 01/55] Modified the puleguide method to make sure that the _isGuiding property is set correctly regardless of the old or new guiding method. Added log message for when PulseGuide fails with an error for any reason --- Meade.net.Telescope/Telescope.cs | 157 +++++++++++++++++-------------- 1 file changed, 84 insertions(+), 73 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 4cec2f4..5cec335 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -47,7 +47,6 @@ namespace ASCOM.Meade.net //internal static string driverID = "ASCOM.Meade.net.Telescope"; private static readonly string DriverId = Marshal.GenerateProgIdForType(MethodBase.GetCurrentMethod().DeclaringType ?? throw new System.InvalidOperationException()); - // TODO Change the descriptive string for your driver then remove this line /// /// Driver description that displays in the ASCOM Chooser. /// @@ -707,7 +706,6 @@ namespace ASCOM.Meade.net public string Description { - // TODO customise this device description get { LogMessage("Description Get", DriverDescription); @@ -719,7 +717,6 @@ namespace ASCOM.Meade.net { get { - // TODO customise this driver description string driverInfo = $"{Description} .net driver. Version: {DriverVersion}"; LogMessage("DriverInfo Get", driverInfo); return driverInfo; @@ -1423,89 +1420,103 @@ namespace ASCOM.Meade.net public void PulseGuide(GuideDirections direction, int duration) { LogMessage("PulseGuide", $"pulse guide direction {direction} duration {duration}"); - CheckConnected("PulseGuide"); - - if (IsSlewingToTarget()) - throw new InvalidOperationException("Unable to PulseGuide whilst slewing to target."); - - if (_movingPrimary && (direction == GuideDirections.guideEast || direction == GuideDirections.guideWest)) - throw new InvalidOperationException("Unable to PulseGuide while moving same axis."); - - if (_movingSecondary && (direction == GuideDirections.guideNorth || direction == GuideDirections.guideSouth)) - throw new InvalidOperationException("Unable to PulseGuide while moving same axis."); - - var coordinatesBeforeMove = GetTelescopeRaAndDec(); - - if (_userNewerPulseGuiding && duration < 10000) + try { - string d = string.Empty; - switch (direction) - { - case GuideDirections.guideEast: - d = "e"; - break; - case GuideDirections.guideNorth: - d = "n"; - break; - case GuideDirections.guideSouth: - d = "s"; - break; - case GuideDirections.guideWest: - d = "w"; - break; - } + CheckConnected("PulseGuide"); + if (IsSlewingToTarget()) + throw new InvalidOperationException("Unable to PulseGuide whilst slewing to target."); - LogMessage("PulseGuide", "Using new pulse guiding technique"); - _sharedResourcesWrapper.SendBlind($"#:Mg{d}{duration:0000}#"); - //:MgnDDDD# - //:MgsDDDD# - //:MgeDDDD# - //:MgwDDDD# - //Guide telescope in the commanded direction(nsew) for the number of milliseconds indicated by the unsigned number - //passed in the command.These commands support serial port driven guiding. - //Returns – Nothing - //LX200 – Not Supported - _utilities.WaitForMilliseconds(duration); //todo figure out if this is really needed - } - else - { _isGuiding = true; try { - switch (direction) + if (_movingPrimary && + (direction == GuideDirections.guideEast || direction == GuideDirections.guideWest)) + throw new InvalidOperationException("Unable to PulseGuide while moving same axis."); + + if (_movingSecondary && + (direction == GuideDirections.guideNorth || direction == GuideDirections.guideSouth)) + throw new InvalidOperationException("Unable to PulseGuide while moving same axis."); + + var coordinatesBeforeMove = GetTelescopeRaAndDec(); + + if (_userNewerPulseGuiding && duration < 10000) { - case GuideDirections.guideEast: - MoveAxis(TelescopeAxes.axisPrimary, 1); - _utilities.WaitForMilliseconds(duration); - MoveAxis(TelescopeAxes.axisPrimary, 0); - break; - case GuideDirections.guideNorth: - MoveAxis(TelescopeAxes.axisSecondary, 1); - _utilities.WaitForMilliseconds(duration); - MoveAxis(TelescopeAxes.axisSecondary, 0); - break; - case GuideDirections.guideSouth: - MoveAxis(TelescopeAxes.axisSecondary, -1); - _utilities.WaitForMilliseconds(duration); - MoveAxis(TelescopeAxes.axisSecondary, 0); - break; - case GuideDirections.guideWest: - MoveAxis(TelescopeAxes.axisPrimary, -1); - _utilities.WaitForMilliseconds(duration); - MoveAxis(TelescopeAxes.axisPrimary, 0); - break; + string d = string.Empty; + switch (direction) + { + case GuideDirections.guideEast: + d = "e"; + break; + case GuideDirections.guideNorth: + d = "n"; + break; + case GuideDirections.guideSouth: + d = "s"; + break; + case GuideDirections.guideWest: + d = "w"; + break; + } + + LogMessage("PulseGuide", "Using new pulse guiding technique"); + _sharedResourcesWrapper.SendBlind($"#:Mg{d}{duration:0000}#"); + //:MgnDDDD# + //:MgsDDDD# + //:MgeDDDD# + //:MgwDDDD# + //Guide telescope in the commanded direction(nsew) for the number of milliseconds indicated by the unsigned number + //passed in the command.These commands support serial port driven guiding. + //Returns – Nothing + //LX200 – Not Supported + _utilities.WaitForMilliseconds(duration); //todo figure out if this is really needed } + else + { + LogMessage("PulseGuide", "Using old pulse guiding technique"); + switch (direction) + { + case GuideDirections.guideEast: + MoveAxis(TelescopeAxes.axisPrimary, 1); + _utilities.WaitForMilliseconds(duration); + MoveAxis(TelescopeAxes.axisPrimary, 0); + break; + case GuideDirections.guideNorth: + MoveAxis(TelescopeAxes.axisSecondary, 1); + _utilities.WaitForMilliseconds(duration); + MoveAxis(TelescopeAxes.axisSecondary, 0); + break; + case GuideDirections.guideSouth: + MoveAxis(TelescopeAxes.axisSecondary, -1); + _utilities.WaitForMilliseconds(duration); + MoveAxis(TelescopeAxes.axisSecondary, 0); + break; + case GuideDirections.guideWest: + MoveAxis(TelescopeAxes.axisPrimary, -1); + _utilities.WaitForMilliseconds(duration); + MoveAxis(TelescopeAxes.axisPrimary, 0); + break; + } + + LogMessage("PulseGuide", "Using old pulse guiding technique complete"); + } + + var coordinatesAfterMove = GetTelescopeRaAndDec(); + + LogMessage("PulseGuide", + $"Complete Before RA: {_utilitiesExtra.HoursToHMS(coordinatesBeforeMove.RightAscension)} Dec:{_utilitiesExtra.DegreesToDMS(coordinatesBeforeMove.Declination)}"); + LogMessage("PulseGuide", + $"Complete After RA: {_utilitiesExtra.HoursToHMS(coordinatesAfterMove.RightAscension)} Dec:{_utilitiesExtra.DegreesToDMS(coordinatesAfterMove.Declination)}"); } finally { _isGuiding = false; } } - - var coordinatesAfterMove = GetTelescopeRaAndDec(); - - LogMessage("PulseGuide", $"Complete Before RA: {_utilitiesExtra.HoursToHMS(coordinatesBeforeMove.RightAscension)} Dec:{_utilitiesExtra.DegreesToDMS(coordinatesBeforeMove.Declination)}"); - LogMessage("PulseGuide", $"Complete Before RA: {_utilitiesExtra.HoursToHMS(coordinatesAfterMove.RightAscension)} Dec:{_utilitiesExtra.DegreesToDMS(coordinatesAfterMove.Declination)}"); + catch (Exception ex) + { + LogMessage("PulseGuide", $"Error performing pulse guide: {ex.Message}"); + throw; + } } public double RightAscension From bd8476e11ab693f0943b942ead8a33dbc1680fba Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 24 May 2020 16:38:30 +0100 Subject: [PATCH 02/55] Added support for a warning when the telescope could hit the mount. (older command used by the Meade CSD prior to the LX200 command set.) --- Meade.net.Telescope/Telescope.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 5cec335..3b6439d 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1868,10 +1868,15 @@ namespace ASCOM.Meade.net LogMessage("DoSlewAsync", $"Slew failed \"{belowHorizonMessage}\""); throw new InvalidOperationException(belowHorizonMessage); case "2": - //Below Horizon + //Below minimum elevation string belowMinimumElevationMessage = _sharedResourcesWrapper.ReadTerminated(); LogMessage("DoSlewAsync", $"Slew failed \"{belowMinimumElevationMessage}\""); throw new InvalidOperationException(belowMinimumElevationMessage); + case "3": + //Telescope can hit the mount + string canHistMountMessage = _sharedResourcesWrapper.ReadTerminated(); + LogMessage("DoSlewAsync", $"Slew failed \"{canHistMountMessage}\""); + throw new InvalidOperationException(canHistMountMessage); default: LogMessage("DoSlewAsync", $"Slew failed - unknown response \"{response}\""); throw new DriverException("This error should not happen"); From 1e59d5610ea5de3d60dcf49efadbec5f7b19870a Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 24 May 2020 16:39:09 +0100 Subject: [PATCH 03/55] Fixed spelling mistake --- Meade.net.Telescope/Telescope.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 3b6439d..42525fa 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1874,9 +1874,9 @@ namespace ASCOM.Meade.net throw new InvalidOperationException(belowMinimumElevationMessage); case "3": //Telescope can hit the mount - string canHistMountMessage = _sharedResourcesWrapper.ReadTerminated(); - LogMessage("DoSlewAsync", $"Slew failed \"{canHistMountMessage}\""); - throw new InvalidOperationException(canHistMountMessage); + string canHitMountMessage = _sharedResourcesWrapper.ReadTerminated(); + LogMessage("DoSlewAsync", $"Slew failed \"{canHitMountMessage}\""); + throw new InvalidOperationException(canHitMountMessage); default: LogMessage("DoSlewAsync", $"Slew failed - unknown response \"{response}\""); throw new DriverException("This error should not happen"); From 2c7de157e8ee6bfb781f02c38d4dd7c0aea84eaf Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 24 May 2020 16:40:47 +0100 Subject: [PATCH 04/55] Added unit test for telescope hitting tripod. --- .../TelescopeUnitTests.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 7d5f056..e2e7796 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -2291,6 +2291,21 @@ namespace Meade.net.Telescope.UnitTests Assert.That(exception.Message, Is.EqualTo("Above below elevation")); } + [Test] + public void SlewToTargetAsync_WhenTelescopeCanHitTripod_ThenThrowsException() + { + _sharedResourcesWrapperMock.Setup(x => x.SendChar("#:MS#")).Returns("3"); + _sharedResourcesWrapperMock.Setup(x => x.ReadTerminated()).Returns("the telescope can hit the tripod"); + + ConnectTelescope(); + + _telescope.TargetRightAscension = 2; + _telescope.TargetDeclination = 1; + + var exception = Assert.Throws(() => { _telescope.SlewToTargetAsync(); }); + Assert.That(exception.Message, Is.EqualTo("the telescope can hit the tripod")); + } + [Test] public void SlewToTarget_WhenNotConnected_ThenThrowsException() { From 855a21122a40366a72be53e6c4cc3b5709cc8dd4 Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 24 May 2020 18:30:46 +0100 Subject: [PATCH 05/55] Added a trim, so that whitespace is ignored when seeing the result of is slewing to target. --- 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 42525fa..99131c7 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1996,7 +1996,7 @@ namespace ASCOM.Meade.net return false; } - bool isSlewing = result != string.Empty; + bool isSlewing = result.Trim() != string.Empty; LogMessage("Slewing Get", $"Result = {isSlewing}"); return isSlewing; From 3d47e03240dd985e1697f52de42918b953764355 Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 24 May 2020 22:02:21 +0100 Subject: [PATCH 06/55] Added a post connect check to see if the serial port is functioning correctly. --- .../SharedResourcesUnitTests.cs | 62 +++++++++++++++++-- Meade.net/SharedResources.cs | 28 ++++++++- 2 files changed, 83 insertions(+), 7 deletions(-) diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs index 03d9e46..6eada17 100644 --- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs +++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs @@ -1,6 +1,7 @@  using System; using System.Globalization; +using System.Runtime.Remoting.Contexts; using ASCOM.Meade.net; using ASCOM.Meade.net.Wrapper; using ASCOM.Utilities.Interfaces; @@ -214,7 +215,8 @@ namespace Meade.net.UnitTests string serialPortReturn = string.Empty; - _serialMock.Setup(x => x.Transmit(":GVP#")).Callback(() => { serialPortReturn = ":GVP#"; }); + _serialMock.Setup(x => x.Transmit("#:GVP#")).Callback(() => { serialPortReturn = ":GVP#"; }); + _serialMock.Setup(x => x.Transmit("#:GG#")).Callback(() => { serialPortReturn = "0"; }); _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns( () => serialPortReturn); var result = Assert.Throws(() => { SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object); }); @@ -251,8 +253,14 @@ namespace Meade.net.UnitTests SharedResources.ProfileFactory = profileFactoryMock.Object; - _serialMock.Setup(x => x.Transmit(":GVP#")).Callback(() => { }); - _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => throw new Exception("Testerror")); + string serialPortReturn = string.Empty; + + _serialMock.Setup(x => x.Transmit("#:GVP#")).Callback(() => { + serialPortReturn = string.Empty; + throw new Exception("Testerror"); + }); + _serialMock.Setup(x => x.Transmit("#:GG#")).Callback(() => { serialPortReturn = "0"; }); + _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn); var connectionResult = SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object); try @@ -300,8 +308,9 @@ namespace Meade.net.UnitTests string serialPortReturn = string.Empty; - _serialMock.Setup(x => x.Transmit(":GVP#")).Callback(() => { serialPortReturn = TelescopeList.Autostar497; }); - _serialMock.Setup(x => x.Transmit(":GVN#")).Callback(() => { serialPortReturn = TelescopeList.Autostar497_43Eg; }); + _serialMock.Setup(x => x.Transmit("#:GVP#")).Callback(() => { serialPortReturn = TelescopeList.Autostar497; }); + _serialMock.Setup(x => x.Transmit("#:GVN#")).Callback(() => { serialPortReturn = TelescopeList.Autostar497_43Eg; }); + _serialMock.Setup(x => x.Transmit("#:GG#")).Callback(() => { serialPortReturn = "0"; }); _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn); var connectionResult = SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object); @@ -316,5 +325,48 @@ namespace Meade.net.UnitTests SharedResources.Disconnect(deviceId, String.Empty); } } + + [Test] + public void Connect_WhenSerialPortIsNotRespondingCorrectly_ThenExceptionThrown() + { + string deviceId = "Serial"; + + string driverDriverId = "ASCOM.MeadeGeneric.Telescope"; + + string ComPortDefault = "COM1"; + string TraceStateDefault = "false"; + string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate + string PrecisionDefault = "Unchanged"; + + Mock profileWrapperMock = new Mock(); + profileWrapperMock.SetupAllProperties(); + + profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Trace Level", string.Empty, TraceStateDefault)) + .Returns(TraceStateDefault); + profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "COM Port", string.Empty, ComPortDefault)) + .Returns(ComPortDefault); + profileWrapperMock + .Setup(x => x.GetValue(driverDriverId, "Guide Rate Arc Seconds Per Second", string.Empty, + GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault); + profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Precision", string.Empty, PrecisionDefault)) + .Returns(PrecisionDefault); + + Mock profileFactoryMock = new Mock(); + profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); + + SharedResources.ProfileFactory = profileFactoryMock.Object; + + string serialPortReturn = string.Empty; + + _serialMock.Setup(x => x.Transmit("#:GVP#")).Callback(() => { serialPortReturn = TelescopeList.Autostar497; }); + _serialMock.Setup(x => x.Transmit("#:GVN#")).Callback(() => { serialPortReturn = TelescopeList.Autostar497_43Eg; }); + _serialMock.Setup(x => x.Transmit("#:GG#")).Callback(() => { serialPortReturn = ""; }); + _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn); + + var result = Assert.Throws(() => { var connectionResult = SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object); }); + Assert.That(result.Message, Is.EqualTo("Input string was not in a correct format.")); + + _traceLoggerMock.Verify( x => x.LogIssue("Connect", "Unable to decode response from the telescope, This is likely a hardware serial communications error."), Times.Once); + } } } diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index dbe28f5..b6b60d8 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -271,8 +271,8 @@ namespace ASCOM.Meade.net try { - ProductName = SendString(":GVP#"); - FirmwareVersion = SendString(":GVN#"); + ProductName = SendString("#:GVP#"); + FirmwareVersion = SendString("#:GVN#"); } catch (Exception ex) { @@ -289,6 +289,30 @@ namespace ASCOM.Meade.net throw new Exception("Serial port is looping back data, something is wrong with the hardware."); } + + try + { + string utcOffSet = SendString("#:GG#"); + //:GG# Get UTC offset time + //Returns: sHH# or sHH.H# + //The number of decimal hours to add to local time to convert it to UTC. If the number is a whole number the + //sHH# form is returned, otherwise the longer form is returned. + try + { + double utcOffsetHours = double.Parse(utcOffSet); + } + catch (Exception ex) + { + traceLogger.LogIssue("Connect", "Unable to decode response from the telescope, This is likely a hardware serial communications error."); + throw; + } + + } + catch (Exception ex) + { + SharedSerial.Connected = false; + throw; + } } } else From 946fb4b141678dd3cbb6c890b562dafe3ecd4a10 Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 2 Jun 2020 23:52:25 +0100 Subject: [PATCH 07/55] Implementation of backlash compensation feature --- .../FocuserUnitTests.cs | 41 ++- .../SharedResourcesUnitTests.cs | 4 + Meade.net.focuser/Focuser.cs | 84 ++++--- Meade.net/ProfileProperties.cs | 1 + Meade.net/SetupDialogForm.cs | 4 +- Meade.net/SetupDialogForm.designer.cs | 48 ++++ Meade.net/SetupDialogForm.resx | 236 +++++++++++++++--- Meade.net/SharedResources.cs | 7 +- 8 files changed, 352 insertions(+), 73 deletions(-) diff --git a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs index 4fab074..e326b64 100644 --- a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs +++ b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs @@ -313,7 +313,6 @@ namespace Meade.net.Focuser.UnitTests _focuser.Halt(); _sharedResourcesWrapperMock.Verify( x => x.SendBlind(":FQ#"), Times.AtLeastOnce); - _utilMock.Verify( x => x.WaitForMilliseconds(250), Times.AtLeastOnce); } [Test] @@ -395,29 +394,61 @@ namespace Meade.net.Focuser.UnitTests [TestCase(-200)] public void Move_WhenIncrementIsNot0_ThenMovesFocuserAndStopsFocuser( int position) { + _profileProperties.BacklashCompensation = 0; + ConnectFocuser(); _focuser.Move(position); if (position < 0) { - _sharedResourcesWrapperMock.Verify( x => x.SendBlind("#:F-#"), Times.AtLeastOnce); + _sharedResourcesWrapperMock.Verify( x => x.SendBlind("#:F-#"), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F+#"), Times.Never); } else { _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F-#"), Times.Never); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F+#"), Times.AtLeastOnce); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F+#"), Times.Once); } _sharedResourcesWrapperMock.Verify( x => x.Lock(It.IsAny()), Times.Once); - _utilMock.Verify(x => x.WaitForMilliseconds(250), Times.AtLeastOnce); - + _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once); + _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(_profileProperties.BacklashCompensation)), Times.Never); _utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Once()); _utilMock.Verify(x => x.WaitForMilliseconds(1000), Times.Once()); } + [TestCase(200, 3, 3)] + [TestCase(-200, 1, 0)] + public void Move_WhenIncrementIsNot0_ThenMovesFocuserAndStopsFocuserWithBacklashCompensation(int position, int hundredMsWaitCount, int backlashCompensaionCount) + { + _profileProperties.BacklashCompensation = 3000; + + ConnectFocuser(); + + _focuser.Move(position); + + if (position < 0) + { + _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F-#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F+#"), Times.Never); + } + else + { + _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F-#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F+#"), Times.Exactly(2)); + } + + _sharedResourcesWrapperMock.Verify(x => x.Lock(It.IsAny()), Times.Once); + + _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once); + _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(_profileProperties.BacklashCompensation)), Times.Exactly(backlashCompensaionCount)); + + _utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(hundredMsWaitCount)); + _utilMock.Verify(x => x.WaitForMilliseconds(1000), Times.Once); + } + [Test] public void Position_WhenCalled_ThenThrowsException() { diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs index 6eada17..d70d163 100644 --- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs +++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs @@ -140,6 +140,7 @@ namespace Meade.net.UnitTests string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate string PrecisionDefault = "Unchanged"; string GuidingStyleDefault = "Auto"; + string BacklashCompensationDefault = "3000"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -155,6 +156,8 @@ namespace Meade.net.UnitTests .Returns(PrecisionDefault); profileWrapperMock.Setup(x => x.GetValue(DriverId, "Guiding Style", string.Empty, GuidingStyleDefault)) .Returns(GuidingStyleDefault); + profileWrapperMock.Setup(x => x.GetValue(DriverId, "Backlash Compensation", string.Empty, BacklashCompensationDefault)) + .Returns(BacklashCompensationDefault); IProfileWrapper profeWrapper = profileWrapperMock.Object; @@ -172,6 +175,7 @@ namespace Meade.net.UnitTests Assert.That(profileProperties.TraceLogger, Is.EqualTo(bool.Parse(TraceStateDefault))); Assert.That(profileProperties.Precision, Is.EqualTo(PrecisionDefault)); Assert.That(profileProperties.GuidingStyle, Is.EqualTo(GuidingStyleDefault)); + Assert.That(profileProperties.BacklashCompensation, Is.EqualTo(int.Parse(BacklashCompensationDefault))); } [TestCase("TCP")] diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index 33ac3e4..f00ee64 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -47,6 +47,7 @@ namespace ASCOM.Meade.net private static string _comPort; // Variables to hold the currrent device configuration + private static int _backlashCompensation; /// /// Private variable to hold an ASCOM Utilities object /// @@ -286,17 +287,11 @@ namespace ASCOM.Meade.net CheckConnected("Halt"); - //A single halt command is sometimes missed by the #909 apm, so let's do it a few times to be safe. - //todo make this mockable - Stopwatch stopwatch = Stopwatch.StartNew(); - while (stopwatch.ElapsedMilliseconds < 1000) - { - _sharedResourcesWrapper.SendBlind(":FQ#"); - //:FQ# Halt Focuser Motion - //Returns: Nothing + //todo fix this issue: A single halt command is sometimes missed by the #909 apm, so let's do it a few times to be safe. - _utilities.WaitForMilliseconds(250); - } + _sharedResourcesWrapper.SendBlind(":FQ#"); + //:FQ# Halt Focuser Motion + //Returns: Nothing } public bool IsMoving @@ -359,45 +354,56 @@ namespace ASCOM.Meade.net if (position == 0) return; - MoveFocuser(position > 0, Math.Abs(position)); + _sharedResourcesWrapper.Lock(() => + { + MoveFocuser(position > 0, Math.Abs(position)); + ApplyBacklashCompensation(position > 0); + //This gives the focuser time to physically stop. + _utilities.WaitForMilliseconds(1000); + }); + } + + private void ApplyBacklashCompensation(bool directionOut) + { + if (_backlashCompensation == 0) + return; + + _tl.LogMessage("Move", "Applying backlash compensation"); + + if (directionOut) + { + MoveFocuser(directionOut, Math.Abs(_backlashCompensation)); + _utilities.WaitForMilliseconds(Math.Abs(_backlashCompensation)); + MoveFocuser(!directionOut, Math.Abs(_backlashCompensation)); + } } private void MoveFocuser(bool directionOut, int steps) { - _sharedResourcesWrapper.Lock(() => - { - //_sharedResourcesWrapper.SendBlind("#:FF#"); - //:FF# Set Focus speed to fastest setting - //Returns: Nothing + //_sharedResourcesWrapper.SendBlind("#:FF#"); + //:FF# Set Focus speed to fastest setting + //Returns: Nothing - //:FS# Set Focus speed to slowest setting - //Returns: Nothing + //:FS# Set Focus speed to slowest setting + //Returns: Nothing - //:F# Autostar, Autostar II – set focuser speed to where is an ASCII digit 1..4 - //Returns: Nothing - //All others – Not Supported - _utilities.WaitForMilliseconds(100); + //:F# Autostar, Autostar II – set focuser speed to where is an ASCII digit 1..4 + //Returns: Nothing + //All others – Not Supported + _utilities.WaitForMilliseconds(100); - //A Single focus command sometimes gets lost on the #909, so sending lots of them solves the issue. - //todo make this mockable - Stopwatch stopwatch = Stopwatch.StartNew(); - while (stopwatch.ElapsedMilliseconds < steps) - { - _sharedResourcesWrapper.SendBlind(directionOut ? "#:F+#" : "#:F-#"); - //:F+# Start Focuser moving inward (toward objective) - //Returns: None + //Todo fix this issue. A Single focus command sometimes gets lost on the #909, so sending lots of them solves the issue. - //:F-# Start Focuser moving outward (away from objective) - //Returns: None + _sharedResourcesWrapper.SendBlind(directionOut ? "#:F+#" : "#:F-#"); + //:F+# Start Focuser moving inward (toward objective) + //Returns: None - _utilities.WaitForMilliseconds(250); - } + //:F-# Start Focuser moving outward (away from objective) + //Returns: None - Halt(); + _utilities.WaitForMilliseconds(steps); - //This gives the focuser time to physically stop. - _utilities.WaitForMilliseconds(1000); - }); + Halt(); } public int Position => throw new PropertyNotImplementedException("Position", false); @@ -556,9 +562,11 @@ namespace ASCOM.Meade.net var profileProperties = _sharedResourcesWrapper.ReadProfile(); _tl.Enabled = profileProperties.TraceLogger; _comPort = profileProperties.ComPort; + _backlashCompensation = profileProperties.BacklashCompensation; LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}"); LogMessage("ReadProfile", $"Com Port: {_comPort}"); + LogMessage("ReadProfile", $"Backlash Steps: {_backlashCompensation}"); } /// diff --git a/Meade.net/ProfileProperties.cs b/Meade.net/ProfileProperties.cs index 56ee4a5..a469d6f 100644 --- a/Meade.net/ProfileProperties.cs +++ b/Meade.net/ProfileProperties.cs @@ -8,5 +8,6 @@ namespace ASCOM.Meade.net public double GuideRateArcSecondsPerSecond { get; set; } public string Precision { get; set; } public string GuidingStyle { get; set; } + public int BacklashCompensation { get; set; } } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index 851b048..2366268 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -81,6 +81,7 @@ namespace ASCOM.Meade.net cboGuidingStyle.SelectedItem = "Auto"; } + txtBacklashSteps.Text = profileProperties.BacklashCompensation.ToString(CultureInfo.CurrentCulture); } public ProfileProperties GetProfile() @@ -91,7 +92,8 @@ namespace ASCOM.Meade.net ComPort = comboBoxComPort.SelectedItem.ToString(), GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text.Trim()), Precision = cboPrecision.SelectedItem.ToString(), - GuidingStyle = cboGuidingStyle.SelectedItem.ToString() + GuidingStyle = cboGuidingStyle.SelectedItem.ToString(), + BacklashCompensation = int.Parse(txtBacklashSteps.Text) }; return profileProperties; diff --git a/Meade.net/SetupDialogForm.designer.cs b/Meade.net/SetupDialogForm.designer.cs index 4b40bb9..38678e2 100644 --- a/Meade.net/SetupDialogForm.designer.cs +++ b/Meade.net/SetupDialogForm.designer.cs @@ -47,6 +47,12 @@ namespace ASCOM.Meade.net this.cboPrecision = new System.Windows.Forms.ComboBox(); this.label6 = new System.Windows.Forms.Label(); this.cboGuidingStyle = new System.Windows.Forms.ComboBox(); + this.label7 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.txtBacklashSteps = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.label11 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit(); this.SuspendLayout(); // @@ -151,10 +157,46 @@ namespace ASCOM.Meade.net resources.ApplyResources(this.cboGuidingStyle, "cboGuidingStyle"); this.cboGuidingStyle.Name = "cboGuidingStyle"; // + // label7 + // + resources.ApplyResources(this.label7, "label7"); + this.label7.Name = "label7"; + // + // label8 + // + resources.ApplyResources(this.label8, "label8"); + this.label8.Name = "label8"; + // + // txtBacklashSteps + // + resources.ApplyResources(this.txtBacklashSteps, "txtBacklashSteps"); + this.txtBacklashSteps.Name = "txtBacklashSteps"; + // + // label9 + // + resources.ApplyResources(this.label9, "label9"); + this.label9.Name = "label9"; + // + // label10 + // + resources.ApplyResources(this.label10, "label10"); + this.label10.Name = "label10"; + // + // label11 + // + resources.ApplyResources(this.label11, "label11"); + this.label11.Name = "label11"; + // // SetupDialogForm // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label11); + this.Controls.Add(this.label10); + this.Controls.Add(this.txtBacklashSteps); + this.Controls.Add(this.label9); + this.Controls.Add(this.label8); + this.Controls.Add(this.label7); this.Controls.Add(this.cboGuidingStyle); this.Controls.Add(this.label6); this.Controls.Add(this.cboPrecision); @@ -200,5 +242,11 @@ namespace ASCOM.Meade.net private ComboBox cboPrecision; private Label label6; private ComboBox cboGuidingStyle; + private Label label7; + private Label label8; + private TextBox txtBacklashSteps; + private Label label9; + private Label label10; + private Label label11; } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.resx b/Meade.net/SetupDialogForm.resx index 4bb64fd..40dc2b0 100644 --- a/Meade.net/SetupDialogForm.resx +++ b/Meade.net/SetupDialogForm.resx @@ -123,7 +123,7 @@ - 281, 250 + 281, 387 59, 24 @@ -145,13 +145,13 @@ $this - 14 + 20 Bottom, Right - 281, 280 + 281, 417 59, 25 @@ -172,7 +172,7 @@ $this - 13 + 19 12, 9 @@ -196,7 +196,7 @@ $this - 12 + 18 Top, Right @@ -223,13 +223,13 @@ $this - 11 + 17 True - 13, 90 + 12, 90 58, 13 @@ -250,13 +250,13 @@ $this - 10 + 16 True - 86, 136 + 97, 114 69, 17 @@ -277,10 +277,10 @@ $this - 9 + 15 - 86, 87 + 97, 87 90, 21 @@ -298,13 +298,13 @@ $this - 8 + 14 True - 10, 162 + 12, 202 61, 13 @@ -325,10 +325,10 @@ $this - 7 + 13 - 86, 159 + 97, 199 46, 20 @@ -349,13 +349,13 @@ $this - 6 + 12 True - 138, 162 + 149, 202 122, 13 @@ -376,13 +376,13 @@ $this - 5 + 11 True - 138, 175 + 149, 215 105, 13 @@ -403,13 +403,13 @@ $this - 4 + 10 True - 13, 194 + 12, 234 50, 13 @@ -430,7 +430,7 @@ $this - 3 + 9 Unchanged @@ -442,7 +442,7 @@ High - 86, 191 + 97, 231 90, 21 @@ -460,7 +460,7 @@ $this - 2 + 8 True @@ -469,7 +469,7 @@ NoControl - 13, 221 + 12, 261 67, 13 @@ -490,7 +490,7 @@ $this - 1 + 7 Auto @@ -502,7 +502,7 @@ Pulse guiding - 86, 218 + 97, 258 90, 21 @@ -520,6 +520,186 @@ $this + 6 + + + True + + + Microsoft Sans Serif, 8.25pt, style=Bold + + + 12, 176 + + + 66, 13 + + + 16 + + + Telescope + + + label7 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 5 + + + True + + + Microsoft Sans Serif, 8.25pt, style=Bold + + + NoControl + + + 12, 317 + + + 52, 13 + + + 17 + + + Focuser + + + label8 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 4 + + + 97, 335 + + + 46, 20 + + + 19 + + + 3000 + + + txtBacklashSteps + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + True + + + NoControl + + + 12, 338 + + + 79, 13 + + + 18 + + + Backlash steps + + + label9 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + True + + + NoControl + + + 149, 338 + + + 20, 13 + + + 20 + + + ms + + + label10 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + Microsoft Sans Serif, 8.25pt, style=Bold + + + NoControl + + + 12, 67 + + + 71, 13 + + + 21 + + + Connection + + + label11 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 @@ -529,7 +709,7 @@ 6, 13 - 350, 313 + 350, 450 CenterScreen diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index b6b60d8..9089ce2 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -140,6 +140,7 @@ namespace ASCOM.Meade.net private const string GuideRateProfileName = "Guide Rate Arc Seconds Per Second"; private const string PrecisionProfileName = "Precision"; private const string GuidingStyleProfileName = "Guiding Style"; + private const string BacklashCompensationName = "Backlash Compensation"; public static void WriteProfile(ProfileProperties profileProperties) { @@ -153,6 +154,7 @@ namespace ASCOM.Meade.net driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.InvariantCulture)); driverProfile.WriteValue(DriverId, PrecisionProfileName, profileProperties.Precision); driverProfile.WriteValue(DriverId, GuidingStyleProfileName, profileProperties.GuidingStyle); + driverProfile.WriteValue(DriverId, BacklashCompensationName, profileProperties.BacklashCompensation.ToString()); } } } @@ -162,7 +164,9 @@ namespace ASCOM.Meade.net private const string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate private const string PrecisionDefault = "Unchanged"; private const string GuidingStyleDefault = "Auto"; - + private const string BacklashCompensationDefault = "3000"; + + public static ProfileProperties ReadProfile() { @@ -177,6 +181,7 @@ namespace ASCOM.Meade.net 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); + profileProperties.BacklashCompensation = Convert.ToInt32(driverProfile.GetValue(DriverId, BacklashCompensationName, string.Empty, BacklashCompensationDefault)); } return profileProperties; From 139191a1ce9564080d618a5ae75d8910ac070921 Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 2 Jun 2020 23:54:19 +0100 Subject: [PATCH 08/55] Unneeded code --- Meade.net/SharedResources.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 9089ce2..887b734 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -306,14 +306,14 @@ namespace ASCOM.Meade.net { double utcOffsetHours = double.Parse(utcOffSet); } - catch (Exception ex) + catch (Exception) { traceLogger.LogIssue("Connect", "Unable to decode response from the telescope, This is likely a hardware serial communications error."); throw; } } - catch (Exception ex) + catch (Exception) { SharedSerial.Connected = false; throw; From d6cec4d63e297b55984d18b24c0bbb968960e28f Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 3 Jun 2020 00:10:27 +0100 Subject: [PATCH 09/55] Checked and removed completed todo tasks --- .../TelescopeUnitTests.cs | 1 - .../Properties/AssemblyInfo.cs | 2 - Meade.net.Telescope/Rates.cs | 6 +- Meade.net.Telescope/Telescope.cs | 68 ++----------------- Meade.net.focuser/Focuser.cs | 8 +-- Meade.net.focuser/Properties/AssemblyInfo.cs | 2 - Meade.net/LocalServer.cs | 4 +- Meade.net/SharedResources.cs | 1 + 8 files changed, 12 insertions(+), 80 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index e2e7796..b775951 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -1680,7 +1680,6 @@ namespace Meade.net.Telescope.UnitTests } - //todo figure out if this is right. don't feel right to me [TestCase("5", 5, -5)] [TestCase("-5", -5, 5)] [TestCase("185", 185, 175)] diff --git a/Meade.net.Telescope/Properties/AssemblyInfo.cs b/Meade.net.Telescope/Properties/AssemblyInfo.cs index 4604c64..ce5b559 100644 --- a/Meade.net.Telescope/Properties/AssemblyInfo.cs +++ b/Meade.net.Telescope/Properties/AssemblyInfo.cs @@ -5,7 +5,6 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. // -// TODO - Add your authorship information here [assembly: AssemblyTitle("ASCOM.Meade.net.Telescope")] [assembly: AssemblyDescription("ASCOM Telescope driver for Meade.net")] [assembly: AssemblyConfiguration("")] @@ -33,6 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: // -// TODO - Set your driver's version here [assembly: AssemblyVersion("0.0.0.0")] [assembly: AssemblyFileVersion("0.0.0.0")] diff --git a/Meade.net.Telescope/Rates.cs b/Meade.net.Telescope/Rates.cs index c59641a..6022c64 100644 --- a/Meade.net.Telescope/Rates.cs +++ b/Meade.net.Telescope/Rates.cs @@ -33,7 +33,7 @@ namespace ASCOM.Meade.net public void Dispose() { - // TODO Add any required object cleanup here + // Add any required object cleanup here } public double Maximum { get; set; } @@ -106,7 +106,7 @@ namespace ASCOM.Meade.net public void Dispose() { - // TODO Add any required object cleanup here + // Add any required object cleanup here } public IEnumerator GetEnumerator() @@ -176,7 +176,7 @@ namespace ASCOM.Meade.net public void Dispose() { - // TODO Add any required object cleanup here + // Add any required object cleanup here } public DriveRates this[int index] => _trackingRates[index - 1]; diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 99131c7..4727742 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -26,7 +26,7 @@ namespace ASCOM.Meade.net // The ClassInterface/None addribute prevents an empty interface called // _Meade.net from being created and used as the [default] interface // - // TODO Replace the not implemented exceptions with code to implement the function or + // Replace the not implemented exceptions with code to implement the function or // throw the appropriate ASCOM exception. // @@ -840,9 +840,7 @@ namespace ASCOM.Meade.net if (!FirmwareIsGreaterThan(TelescopeList.Autostar497_43Eg)) throw new PropertyNotImplementedException("AlignmentMode",true ); - //todo make this only try with Autostar 43Eg and above. - - switch (value) + switch (value) { case AlignmentModes.algAltAz: _sharedResourcesWrapper.SendBlind("#:AA#"); @@ -1468,7 +1466,7 @@ namespace ASCOM.Meade.net //passed in the command.These commands support serial port driven guiding. //Returns – Nothing //LX200 – Not Supported - _utilities.WaitForMilliseconds(duration); //todo figure out if this is really needed + _utilities.WaitForMilliseconds(duration); } else { @@ -1741,65 +1739,7 @@ namespace ASCOM.Meade.net _utilities.WaitForMilliseconds(200); //be responsive to AbortSlew(); } } - - //private double TargetAltitude - //{ - // set - // { - // if (value > 90) - // throw new InvalidValueException("Altitude cannot be greater than 90."); - - // if (value < 0) - // throw new InvalidValueException("Altitide cannot be less than 0."); - - // CheckConnected("TargetAltitude Set"); - - // //todo this serial string does not work. Calculate the EQ version instead. - - // var dms = _utilities.DegreesToDMS(value, "*", "'", "",0); - // var s = value < 0 ? string.Empty : "+"; - - // var result = _sharedResourcesWrapper.SendChar($"#:Sa{s}{dms}#"); - // //:SasDD*MM# - // //Set target object altitude to sDD*MM# or sDD*MM’SS# [LX 16”, Autostar, Autostar II] - // //Returns: - // //1 Object within slew range - // //0 Object out of slew range - - // if (result == "0") - // throw new InvalidOperationException("Target altitude out of slew range"); - // } - //} - - //private double TargetAzimuth - //{ - // set - // { - // if (value >= 360) - // throw new InvalidValueException("Azimuth cannot be 360 or higher."); - - // if (value < 0) - // throw new InvalidValueException("Azimuth cannot be less than 0."); - - // CheckConnected("TargetAzimuth Set"); - - // //todo this serial string does not work. Calculate the EQ version instead. - - // var dms = _utilitiesExtra.DegreesToDM(value, "*" ); - - // var result = _sharedResourcesWrapper.SendChar($"#:Sz{dms}#"); - // //:SzDDD*MM# - // //Sets the target Object Azimuth[LX 16” and Autostar II only] - // //Returns: - // //0 – Invalid - // //1 - Valid - - // if (result == "0") - // throw new InvalidOperationException("Target Azimuth out of slew range"); - - // } - //} - + public void SlewToAltAzAsync(double azimuth, double altitude) { CheckConnected("SlewToAltAzAsync"); diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index f00ee64..9cbc786 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -2,7 +2,6 @@ using System; using System.Collections; -using System.Diagnostics; using System.Reflection; using System.Runtime.InteropServices; using ASCOM.DeviceInterface; @@ -19,7 +18,7 @@ namespace ASCOM.Meade.net // The ClassInterface/None addribute prevents an empty interface called // _Meade.net from being created and used as the [default] interface // - // TODO Replace the not implemented exceptions with code to implement the function or + // Replace the not implemented exceptions with code to implement the function or // throw the appropriate ASCOM exception. // @@ -146,7 +145,7 @@ namespace ASCOM.Meade.net { CheckConnected("CommandBool"); //string ret = CommandString(command, raw); - // TODO decode the return string and return true or false + // decode the return string and return true or false // or throw new MethodNotImplementedException("CommandBool"); // DO NOT have both these sections! One or the other @@ -215,7 +214,6 @@ namespace ASCOM.Meade.net public string Description { - // TODO customise this device description get { _tl.LogMessage("Description Get", DriverDescription); @@ -227,7 +225,6 @@ namespace ASCOM.Meade.net { get { - // TODO customise this driver description string driverInfo = $"{Description} .net driver. Version: {DriverVersion}"; LogMessage("DriverInfo Get", driverInfo); return driverInfo; @@ -342,7 +339,6 @@ namespace ASCOM.Meade.net _tl.LogMessage("Move", position.ToString()); CheckConnected("Move"); - //todo implement backlash compensation //todo implement direction reverse //todo implement dynamic braking diff --git a/Meade.net.focuser/Properties/AssemblyInfo.cs b/Meade.net.focuser/Properties/AssemblyInfo.cs index d77e77d..44f749c 100644 --- a/Meade.net.focuser/Properties/AssemblyInfo.cs +++ b/Meade.net.focuser/Properties/AssemblyInfo.cs @@ -5,7 +5,6 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. // -// TODO - Add your authorship information here [assembly: AssemblyTitle("ASCOM.Meade.net.Focuser")] [assembly: AssemblyDescription("ASCOM Focuser driver for Meade.net")] [assembly: AssemblyConfiguration("")] @@ -33,6 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: // -// TODO - Set your driver's version here [assembly: AssemblyVersion("0.0.0.0")] [assembly: AssemblyFileVersion("0.0.0.0")] diff --git a/Meade.net/LocalServer.cs b/Meade.net/LocalServer.cs index e0916f4..2a719af 100644 --- a/Meade.net/LocalServer.cs +++ b/Meade.net/LocalServer.cs @@ -390,7 +390,7 @@ namespace ASCOM.Meade.net // // Remove all traces of this from the registry. // - // **TODO** If the above does AppID/DCOM stuff, this would have + // If the above does AppID/DCOM stuff, this would have // to remove that stuff too. // private static void UnregisterObjects() @@ -494,7 +494,7 @@ namespace ASCOM.Meade.net bool bRet = true; // - //**TODO** -Embedding is "ActiveX start". Prohibit non_AX starting? + // -Embedding is "ActiveX start". Prohibit non_AX starting? // if (args.Length > 0) { diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 887b734..731d491 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -75,6 +75,7 @@ namespace ASCOM.Meade.net set => _profileFactory = value; } + //todo add code to ensure that there is a minimum gap between commands. 5ms as default. public static void SendBlind(string message) { lock (LockObject) From 71ed5cc58bd9f5886b605c872e965e170be2639c Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 3 Jun 2020 12:44:23 +0100 Subject: [PATCH 10/55] removed redundant using --- Meade.net.UnitTests/SharedResourcesUnitTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs index d70d163..472d80c 100644 --- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs +++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs @@ -1,7 +1,6 @@  using System; using System.Globalization; -using System.Runtime.Remoting.Contexts; using ASCOM.Meade.net; using ASCOM.Meade.net.Wrapper; using ASCOM.Utilities.Interfaces; From 8d097fefe114cf4e528c3d7d9543b3a59e2e242a Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 4 Jun 2020 23:31:41 +0100 Subject: [PATCH 11/55] Added reverse direction feature --- .../SharedResourcesUnitTests.cs | 13 +++- Meade.net.focuser/Focuser.cs | 13 +++- Meade.net/ProfileProperties.cs | 1 + Meade.net/SetupDialogForm.cs | 5 +- Meade.net/SetupDialogForm.designer.cs | 9 +++ Meade.net/SetupDialogForm.resx | 67 +++++++++++++------ Meade.net/SharedResources.cs | 6 +- 7 files changed, 86 insertions(+), 28 deletions(-) diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs index 472d80c..7a803b8 100644 --- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs +++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs @@ -127,6 +127,8 @@ namespace Meade.net.UnitTests 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); + profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Backlash Compensation", profileProperties.BacklashCompensation.ToString(CultureInfo.CurrentCulture)), Times.Once); + profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Reverse Focuser Direction", profileProperties.ReverseFocusDirection.ToString()), Times.Once); } [Test] @@ -140,12 +142,14 @@ namespace Meade.net.UnitTests string PrecisionDefault = "Unchanged"; string GuidingStyleDefault = "Auto"; string BacklashCompensationDefault = "3000"; + string ReverseFocuserDiectionDefault = "true"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault)) - .Returns(TraceStateDefault); + .Returns(() => + TraceStateDefault); profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault)) .Returns(ComPortDefault); profileWrapperMock @@ -155,8 +159,12 @@ namespace Meade.net.UnitTests .Returns(PrecisionDefault); profileWrapperMock.Setup(x => x.GetValue(DriverId, "Guiding Style", string.Empty, GuidingStyleDefault)) .Returns(GuidingStyleDefault); - profileWrapperMock.Setup(x => x.GetValue(DriverId, "Backlash Compensation", string.Empty, BacklashCompensationDefault)) + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Backlash Compensation", string.Empty, BacklashCompensationDefault)) .Returns(BacklashCompensationDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Reverse Focuser Direction", string.Empty, ReverseFocuserDiectionDefault)) + .Returns(() => ReverseFocuserDiectionDefault); IProfileWrapper profeWrapper = profileWrapperMock.Object; @@ -175,6 +183,7 @@ namespace Meade.net.UnitTests Assert.That(profileProperties.Precision, Is.EqualTo(PrecisionDefault)); Assert.That(profileProperties.GuidingStyle, Is.EqualTo(GuidingStyleDefault)); Assert.That(profileProperties.BacklashCompensation, Is.EqualTo(int.Parse(BacklashCompensationDefault))); + Assert.That(profileProperties.ReverseFocusDirection, Is.EqualTo(bool.Parse(ReverseFocuserDiectionDefault))); } [TestCase("TCP")] diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index 9cbc786..224e4c6 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -47,6 +47,9 @@ namespace ASCOM.Meade.net private static string _comPort; // Variables to hold the currrent device configuration private static int _backlashCompensation; + + private static bool _reverseFocusDirection; + /// /// Private variable to hold an ASCOM Utilities object /// @@ -339,7 +342,6 @@ namespace ASCOM.Meade.net _tl.LogMessage("Move", position.ToString()); CheckConnected("Move"); - //todo implement direction reverse //todo implement dynamic braking if (position < -MaxIncrement || position > MaxIncrement) @@ -350,10 +352,14 @@ namespace ASCOM.Meade.net if (position == 0) return; + var direction = position > 0; + if (_reverseFocusDirection) + direction = !direction; + _sharedResourcesWrapper.Lock(() => { - MoveFocuser(position > 0, Math.Abs(position)); - ApplyBacklashCompensation(position > 0); + MoveFocuser(direction, Math.Abs(position)); + ApplyBacklashCompensation(direction); //This gives the focuser time to physically stop. _utilities.WaitForMilliseconds(1000); }); @@ -559,6 +565,7 @@ namespace ASCOM.Meade.net _tl.Enabled = profileProperties.TraceLogger; _comPort = profileProperties.ComPort; _backlashCompensation = profileProperties.BacklashCompensation; + _reverseFocusDirection = profileProperties.ReverseFocusDirection; LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}"); LogMessage("ReadProfile", $"Com Port: {_comPort}"); diff --git a/Meade.net/ProfileProperties.cs b/Meade.net/ProfileProperties.cs index a469d6f..91ec357 100644 --- a/Meade.net/ProfileProperties.cs +++ b/Meade.net/ProfileProperties.cs @@ -9,5 +9,6 @@ namespace ASCOM.Meade.net public string Precision { get; set; } public string GuidingStyle { get; set; } public int BacklashCompensation { get; set; } + public bool ReverseFocusDirection { get; set; } } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index 2366268..3e46acd 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -82,6 +82,8 @@ namespace ASCOM.Meade.net } txtBacklashSteps.Text = profileProperties.BacklashCompensation.ToString(CultureInfo.CurrentCulture); + + cbxReverseDirection.Checked = profileProperties.ReverseFocusDirection; } public ProfileProperties GetProfile() @@ -93,7 +95,8 @@ namespace ASCOM.Meade.net GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text.Trim()), Precision = cboPrecision.SelectedItem.ToString(), GuidingStyle = cboGuidingStyle.SelectedItem.ToString(), - BacklashCompensation = int.Parse(txtBacklashSteps.Text) + BacklashCompensation = int.Parse(txtBacklashSteps.Text), + ReverseFocusDirection = cbxReverseDirection.Checked }; return profileProperties; diff --git a/Meade.net/SetupDialogForm.designer.cs b/Meade.net/SetupDialogForm.designer.cs index 38678e2..fec612a 100644 --- a/Meade.net/SetupDialogForm.designer.cs +++ b/Meade.net/SetupDialogForm.designer.cs @@ -53,6 +53,7 @@ namespace ASCOM.Meade.net this.label9 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label(); + this.cbxReverseDirection = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit(); this.SuspendLayout(); // @@ -187,10 +188,17 @@ namespace ASCOM.Meade.net resources.ApplyResources(this.label11, "label11"); this.label11.Name = "label11"; // + // cbxReverseDirection + // + resources.ApplyResources(this.cbxReverseDirection, "cbxReverseDirection"); + this.cbxReverseDirection.Name = "cbxReverseDirection"; + this.cbxReverseDirection.UseVisualStyleBackColor = true; + // // SetupDialogForm // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.cbxReverseDirection); this.Controls.Add(this.label11); this.Controls.Add(this.label10); this.Controls.Add(this.txtBacklashSteps); @@ -248,5 +256,6 @@ namespace ASCOM.Meade.net private Label label9; private Label label10; private Label label11; + private CheckBox cbxReverseDirection; } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.resx b/Meade.net/SetupDialogForm.resx index 40dc2b0..6618668 100644 --- a/Meade.net/SetupDialogForm.resx +++ b/Meade.net/SetupDialogForm.resx @@ -145,7 +145,7 @@ $this - 20 + 21 Bottom, Right @@ -172,7 +172,7 @@ $this - 19 + 20 12, 9 @@ -196,7 +196,7 @@ $this - 18 + 19 Top, Right @@ -223,7 +223,7 @@ $this - 17 + 18 True @@ -250,7 +250,7 @@ $this - 16 + 17 True @@ -277,7 +277,7 @@ $this - 15 + 16 97, 87 @@ -298,7 +298,7 @@ $this - 14 + 15 True @@ -325,7 +325,7 @@ $this - 13 + 14 97, 199 @@ -349,7 +349,7 @@ $this - 12 + 13 True @@ -376,7 +376,7 @@ $this - 11 + 12 True @@ -403,7 +403,7 @@ $this - 10 + 11 True @@ -430,7 +430,7 @@ $this - 9 + 10 Unchanged @@ -460,7 +460,7 @@ $this - 8 + 9 True @@ -490,7 +490,7 @@ $this - 7 + 8 Auto @@ -520,7 +520,7 @@ $this - 6 + 7 True @@ -550,7 +550,7 @@ $this - 5 + 6 True @@ -583,7 +583,7 @@ $this - 4 + 5 97, 335 @@ -607,7 +607,7 @@ $this - 2 + 3 True @@ -637,7 +637,7 @@ $this - 3 + 4 True @@ -667,7 +667,7 @@ $this - 1 + 2 True @@ -700,6 +700,33 @@ $this + 1 + + + True + + + 97, 361 + + + 109, 17 + + + 22 + + + Reverse direction + + + cbxReverseDirection + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 731d491..e7e89a8 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -142,6 +142,7 @@ namespace ASCOM.Meade.net private const string PrecisionProfileName = "Precision"; private const string GuidingStyleProfileName = "Guiding Style"; private const string BacklashCompensationName = "Backlash Compensation"; + private const string ReverseFocusDirectionName = "Reverse Focuser Direction"; public static void WriteProfile(ProfileProperties profileProperties) { @@ -156,6 +157,7 @@ namespace ASCOM.Meade.net driverProfile.WriteValue(DriverId, PrecisionProfileName, profileProperties.Precision); driverProfile.WriteValue(DriverId, GuidingStyleProfileName, profileProperties.GuidingStyle); driverProfile.WriteValue(DriverId, BacklashCompensationName, profileProperties.BacklashCompensation.ToString()); + driverProfile.WriteValue(DriverId, ReverseFocusDirectionName, profileProperties.ReverseFocusDirection.ToString()); } } } @@ -166,8 +168,7 @@ namespace ASCOM.Meade.net private const string PrecisionDefault = "Unchanged"; private const string GuidingStyleDefault = "Auto"; private const string BacklashCompensationDefault = "3000"; - - + private const string ReverseFocuserDiectionDefault = "true"; public static ProfileProperties ReadProfile() { @@ -183,6 +184,7 @@ namespace ASCOM.Meade.net profileProperties.Precision = driverProfile.GetValue(DriverId, PrecisionProfileName, string.Empty, PrecisionDefault); profileProperties.GuidingStyle = driverProfile.GetValue(DriverId, GuidingStyleProfileName, string.Empty, GuidingStyleDefault); profileProperties.BacklashCompensation = Convert.ToInt32(driverProfile.GetValue(DriverId, BacklashCompensationName, string.Empty, BacklashCompensationDefault)); + profileProperties.ReverseFocusDirection = Convert.ToBoolean(driverProfile.GetValue(DriverId, ReverseFocusDirectionName, string.Empty, ReverseFocuserDiectionDefault)); } return profileProperties; From f9792b22bc19dd0ffb1bf4316139bb32dcfcaabb Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 13:11:47 +0100 Subject: [PATCH 12/55] Implemenated a few todo notes --- AstroMath.UnitTests/AstroMathsUnitTests.cs | 12 +- Meade.net.Telescope/AstroMaths/AstroMaths.cs | 104 +++--------------- .../Meade.net.Telescope.csproj | 1 + Meade.net.Telescope/Telescope.cs | 2 +- 4 files changed, 22 insertions(+), 97 deletions(-) diff --git a/AstroMath.UnitTests/AstroMathsUnitTests.cs b/AstroMath.UnitTests/AstroMathsUnitTests.cs index 489c873..2e4e37c 100644 --- a/AstroMath.UnitTests/AstroMathsUnitTests.cs +++ b/AstroMath.UnitTests/AstroMathsUnitTests.cs @@ -18,14 +18,14 @@ namespace AstroMath.UnitTests [Test] public void DegreesToRadians() { - var radians = _astroMath.DegreesToRadians(90); + var radians = 90.0.DegreesToRadians(); Assert.That(radians, Is.EqualTo(1.5707963267948966)); } [Test] public void RadiansToDegrees() { - var degrees = _astroMath.RadiansToDegrees(1.5707963267948966); + var degrees = 1.5707963267948966.RadiansToDegrees(); Assert.That(degrees, Is.EqualTo(90)); } @@ -34,7 +34,7 @@ namespace AstroMath.UnitTests public void DateTimeToDecimalHours_book() { DateTime dateTime = new DateTime(2019, 05, 18, 18, 31, 27, DateTimeKind.Utc); - var decimalHours = _astroMath.DateTimeToDecimalHours(dateTime); + var decimalHours = dateTime.DateTimeToDecimalHours(); Assert.That(decimalHours, Is.EqualTo(18.524166666666666)); } @@ -43,7 +43,7 @@ namespace AstroMath.UnitTests public void DateTimeToDecimalHours() { DateTime dateTime = new DateTime(2019, 05, 18, 22, 26, 15, DateTimeKind.Utc); - var decimalHours = _astroMath.DateTimeToDecimalHours(dateTime); + var decimalHours = dateTime.DateTimeToDecimalHours(); Assert.That(decimalHours, Is.EqualTo(22.4375)); } @@ -52,7 +52,7 @@ namespace AstroMath.UnitTests public void UTtoGST_book() { DateTime dateTime = new DateTime(1980, 04, 22, 14, 36, 51, 670, DateTimeKind.Utc); - double gst = _astroMath.UTtoGst(dateTime); + double gst = dateTime.UTtoGst(); Assert.That(gst, Is.EqualTo(4.667932706211154)); } @@ -61,7 +61,7 @@ namespace AstroMath.UnitTests public void UTtoGst() { DateTime dateTime = new DateTime(2019, 05, 18, 22, 26, 15, DateTimeKind.Utc); - double gst = _astroMath.UTtoGst(dateTime); + double gst = dateTime.UTtoGst(); Assert.That(gst, Is.EqualTo(14.191879687876451)); } diff --git a/Meade.net.Telescope/AstroMaths/AstroMaths.cs b/Meade.net.Telescope/AstroMaths/AstroMaths.cs index f8d7e77..efe0ae8 100644 --- a/Meade.net.Telescope/AstroMaths/AstroMaths.cs +++ b/Meade.net.Telescope/AstroMaths/AstroMaths.cs @@ -1,5 +1,4 @@ using System; -using ASCOM.Utilities; namespace ASCOM.Meade.net.AstroMaths { @@ -10,7 +9,7 @@ namespace ASCOM.Meade.net.AstroMaths public double RightAscensionToHourAngle(DateTime utcDateTime, double longitude, double rightAscension) { //var ut = DateTimeToDecimalHours( utcDateTime); - var gst = UTtoGst( utcDateTime); + var gst = utcDateTime.UTtoGst(); var lst = GsTtoLst( gst, longitude); var raHours = rightAscension; var h1 = lst - raHours; @@ -24,7 +23,7 @@ namespace ASCOM.Meade.net.AstroMaths private double HourAngleToRightAscension(DateTime utcDateTime, double longitude, double hourAngle ) { - var gst = UTtoGst(utcDateTime); + var gst = utcDateTime.UTtoGst(); var lst = GsTtoLst( gst, longitude); var raHours = hourAngle; var h1 = lst - raHours; @@ -39,17 +38,17 @@ namespace ASCOM.Meade.net.AstroMaths public EquatorialCoordinates ConvertHozToEq( DateTime utcDateTime, double latitude, double longitude, HorizonCoordinates altAz) { - var az = DegreesToRadians(altAz.Azimuth); - var alt = DegreesToRadians(altAz.Altitude); - var lat = DegreesToRadians(latitude); + var az = altAz.Azimuth.DegreesToRadians(); + var alt = altAz.Altitude.DegreesToRadians(); + var lat = latitude.DegreesToRadians(); var sinDec = Math.Sin(alt) * Math.Sin(lat) + Math.Cos(alt) * Math.Cos(lat) * Math.Cos(az); - var dec = RadiansToDegrees(Math.Asin(sinDec)); + var dec = Math.Asin(sinDec).RadiansToDegrees(); var y = -Math.Cos(alt) * Math.Cos(lat) * Math.Sin(az); var x = Math.Sin(alt) - Math.Sin(lat) * sinDec; var upperA = Math.Atan2(y,x); - var upperB = RadiansToDegrees(upperA); + var upperB = upperA.RadiansToDegrees(); var ha = upperB; @@ -72,19 +71,20 @@ namespace ASCOM.Meade.net.AstroMaths public HorizonCoordinates ConvertEqToHoz(double hourAngle, double latitude, EquatorialCoordinates raDec) { var h = hourAngle * 15; - var h1 = DegreesToRadians(h); - var d = DegreesToRadians(raDec.Declination); - var lat = DegreesToRadians(latitude); + var h1 = h.DegreesToRadians(); + var d = raDec.Declination.DegreesToRadians(); + var lat = latitude.DegreesToRadians(); var sinA = Math.Sin(d) * Math.Sin(lat) + Math.Cos(d) * Math.Cos(lat) * Math.Cos(h1); var y = -Math.Cos(d) * Math.Cos(lat) * Math.Sin(h1); var x = Math.Sin(d) - Math.Sin(lat) * sinA; var upperA = Math.Atan2(y, x); - var upperB = RadiansToDegrees(upperA); + var upperB = upperA.RadiansToDegrees(); var horizonCoordinates = new HorizonCoordinates { - Altitude = RadiansToDegrees(Math.Asin(sinA)), Azimuth = upperB + Altitude = Math.Asin(sinA).RadiansToDegrees(), + Azimuth = upperB }; @@ -96,82 +96,6 @@ namespace ASCOM.Meade.net.AstroMaths return horizonCoordinates; } - - //todo convert to extension method - public double DegreesToRadians(double degrees) - { - return (Math.PI / 180) * degrees; - } - - //todo convert to extension method - public double RadiansToDegrees(double radians) - { - double degrees = (180 / Math.PI) * radians; - return degrees; - } - - //todo convert to extension method - public double DateTimeToDecimalHours( DateTime utcDateTime) - { - double sec = utcDateTime.Second; - double min = utcDateTime.Minute; - double hour = utcDateTime.Hour; - - var a = Math.Abs(sec) / 60; - var b = (Math.Abs(min) + a) / 60; - var c = Math.Abs(hour) + b; - - var d = c; - - if ((hour < 0) || (min < 0) || (sec < 0)) - d = -c; - - return d; - } - - //todo convert to extension method - public double UTtoGst(DateTime utcDateTime) - { - Util util = new Util(); - - var jd = util.DateUTCToJulian(utcDateTime) - 0.5; - if ((jd % 1) <= 0.5 ) - jd = Math.Floor( jd ); - else - jd = Math.Floor( jd ) + 0.5; - - var s = jd - 2451545.0; - var t = s / 36525.0; - var t0 = 6.697374558 + (2400.051336 * t ) +(0.000025862 * (t * t) ); - - while (t0 < 0) - { - t0 += 24; - } - - while (t0 >= 24) - { - t0 -= 24; - } - - var ut = DateTimeToDecimalHours(utcDateTime); - var a = ut * 1.002737909; - - var t1 = t0 + a; - - while (t1 < 0) - { - t1 += 24; - } - - while (t1 >= 24) - { - t1 -= 24; - } - - return t1; - } - public double GsTtoLst(double gst, double longitude) { var l = longitude/ 15; @@ -189,4 +113,4 @@ namespace ASCOM.Meade.net.AstroMaths return lst; } } -} +} \ 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 cc2feb8..9553298 100644 --- a/Meade.net.Telescope/Meade.net.Telescope.csproj +++ b/Meade.net.Telescope/Meade.net.Telescope.csproj @@ -116,6 +116,7 @@ + diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 4727742..5cc639c 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -872,7 +872,7 @@ namespace ASCOM.Meade.net LogMessage("Altitude", $"{altAz.Altitude}"); return altAz.Altitude; - ////todo firmware bug in 44Eg, :GA# is returning the dec, not the altitude! + //firmware bug in 44Eg, :GA# is returning the dec, not the altitude! //var result = _sharedResourcesWrapper.SendString("#:GA#"); ////:GA# Get Telescope Altitude ////Returns: sDD* MM# or sDD*MM’SS# From a563a7755420d25770742be89f4ec8f90284d554 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 13:12:06 +0100 Subject: [PATCH 13/55] Implemenated a few todo notes --- .../AstroMaths/AstroMathExtensions.cs | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Meade.net.Telescope/AstroMaths/AstroMathExtensions.cs diff --git a/Meade.net.Telescope/AstroMaths/AstroMathExtensions.cs b/Meade.net.Telescope/AstroMaths/AstroMathExtensions.cs new file mode 100644 index 0000000..9254007 --- /dev/null +++ b/Meade.net.Telescope/AstroMaths/AstroMathExtensions.cs @@ -0,0 +1,79 @@ +using System; +using ASCOM.Utilities; + +namespace ASCOM.Meade.net.AstroMaths +{ + public static class AstroMathExtensions + { + public static double DegreesToRadians(this double degrees) + { + return (Math.PI / 180) * degrees; + } + + public static double RadiansToDegrees(this double radians) + { + double degrees = (180 / Math.PI) * radians; + return degrees; + } + + public static double DateTimeToDecimalHours(this DateTime utcDateTime) + { + double sec = utcDateTime.Second; + double min = utcDateTime.Minute; + double hour = utcDateTime.Hour; + + var a = Math.Abs(sec) / 60; + var b = (Math.Abs(min) + a) / 60; + var c = Math.Abs(hour) + b; + + var d = c; + + if ((hour < 0) || (min < 0) || (sec < 0)) + d = -c; + + return d; + } + + public static double UTtoGst( this DateTime utcDateTime) + { + Util util = new Util(); + + var jd = util.DateUTCToJulian(utcDateTime) - 0.5; + if ((jd % 1) <= 0.5) + jd = Math.Floor(jd); + else + jd = Math.Floor(jd) + 0.5; + + var s = jd - 2451545.0; + var t = s / 36525.0; + var t0 = 6.697374558 + (2400.051336 * t) + (0.000025862 * (t * t)); + + while (t0 < 0) + { + t0 += 24; + } + + while (t0 >= 24) + { + t0 -= 24; + } + + var ut = DateTimeToDecimalHours(utcDateTime); + var a = ut * 1.002737909; + + var t1 = t0 + a; + + while (t1 < 0) + { + t1 += 24; + } + + while (t1 >= 24) + { + t1 -= 24; + } + + return t1; + } + } +} \ No newline at end of file From 9c4329deed9b9537f603859f45a2e862a589ac05 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 13:20:44 +0100 Subject: [PATCH 14/55] Nuget packages updated to latest versions --- .../AstroMath.UnitTests.csproj | 12 +++---- AstroMath.UnitTests/app.config | 2 +- AstroMath.UnitTests/packages.config | 8 ++--- .../Meade.net.Focuser.UnitTests.csproj | 34 +++++++++---------- Meade.net.Focuser.UnitTests/app.config | 2 +- Meade.net.Focuser.UnitTests/packages.config | 10 +++--- .../Meade.net.Telescope.UnitTests.csproj | 34 +++++++++---------- Meade.net.Telescope.UnitTests/app.config | 2 +- Meade.net.Telescope.UnitTests/packages.config | 10 +++--- .../Meade.net.Telescope.csproj | 22 ++++++------ Meade.net.Telescope/Telescope.cs | 1 + Meade.net.Telescope/packages.config | 2 +- .../Meade.net.UnitTests.csproj | 34 +++++++++---------- Meade.net.UnitTests/app.config | 2 +- Meade.net.UnitTests/packages.config | 10 +++--- Meade.net.focuser/Meade.net.focuser.csproj | 22 ++++++------ Meade.net.focuser/packages.config | 2 +- Meade.net/Meade.net.csproj | 22 ++++++------ Meade.net/packages.config | 2 +- 19 files changed, 117 insertions(+), 116 deletions(-) diff --git a/AstroMath.UnitTests/AstroMath.UnitTests.csproj b/AstroMath.UnitTests/AstroMath.UnitTests.csproj index 9f778de..e2e0ac5 100644 --- a/AstroMath.UnitTests/AstroMath.UnitTests.csproj +++ b/AstroMath.UnitTests/AstroMath.UnitTests.csproj @@ -54,10 +54,10 @@ - ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll + ..\packages\Castle.Core.4.4.1\lib\net45\Castle.Core.dll - - ..\packages\Moq.4.13.0\lib\net45\Moq.dll + + ..\packages\Moq.4.14.5\lib\net45\Moq.dll ..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll @@ -65,11 +65,11 @@ - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.6.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll - ..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll diff --git a/AstroMath.UnitTests/app.config b/AstroMath.UnitTests/app.config index 319783c..d0d658a 100644 --- a/AstroMath.UnitTests/app.config +++ b/AstroMath.UnitTests/app.config @@ -8,7 +8,7 @@ - + diff --git a/AstroMath.UnitTests/packages.config b/AstroMath.UnitTests/packages.config index 2b99214..2c67311 100644 --- a/AstroMath.UnitTests/packages.config +++ b/AstroMath.UnitTests/packages.config @@ -1,8 +1,8 @@  - - + + - - + + \ No newline at end of file diff --git a/Meade.net.Focuser.UnitTests/Meade.net.Focuser.UnitTests.csproj b/Meade.net.Focuser.UnitTests/Meade.net.Focuser.UnitTests.csproj index be4f91f..954329b 100644 --- a/Meade.net.Focuser.UnitTests/Meade.net.Focuser.UnitTests.csproj +++ b/Meade.net.Focuser.UnitTests/Meade.net.Focuser.UnitTests.csproj @@ -36,43 +36,43 @@ - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Astrometry.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Astrometry.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Attributes.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Attributes.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Cache.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Cache.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Controls.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Controls.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.DeviceInterfaces.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.DeviceInterfaces.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.DriverAccess.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.DriverAccess.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Exceptions.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Exceptions.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Internal.Extensions.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Internal.Extensions.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.SettingsProvider.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.SettingsProvider.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Utilities.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Utilities.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Utilities.Video.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Utilities.Video.dll - ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll + ..\packages\Castle.Core.4.4.1\lib\net45\Castle.Core.dll - - ..\packages\Moq.4.13.0\lib\net45\Moq.dll + + ..\packages\Moq.4.14.5\lib\net45\Moq.dll ..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll @@ -80,11 +80,11 @@ - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.6.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll - ..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll diff --git a/Meade.net.Focuser.UnitTests/app.config b/Meade.net.Focuser.UnitTests/app.config index 319783c..d0d658a 100644 --- a/Meade.net.Focuser.UnitTests/app.config +++ b/Meade.net.Focuser.UnitTests/app.config @@ -8,7 +8,7 @@ - + diff --git a/Meade.net.Focuser.UnitTests/packages.config b/Meade.net.Focuser.UnitTests/packages.config index cad1be5..b8f88ee 100644 --- a/Meade.net.Focuser.UnitTests/packages.config +++ b/Meade.net.Focuser.UnitTests/packages.config @@ -1,9 +1,9 @@  - - - + + + - - + + \ No newline at end of file diff --git a/Meade.net.Telescope.UnitTests/Meade.net.Telescope.UnitTests.csproj b/Meade.net.Telescope.UnitTests/Meade.net.Telescope.UnitTests.csproj index 9484bd1..7e89847 100644 --- a/Meade.net.Telescope.UnitTests/Meade.net.Telescope.UnitTests.csproj +++ b/Meade.net.Telescope.UnitTests/Meade.net.Telescope.UnitTests.csproj @@ -57,43 +57,43 @@ - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Astrometry.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Astrometry.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Attributes.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Attributes.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Cache.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Cache.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Controls.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Controls.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.DeviceInterfaces.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.DeviceInterfaces.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.DriverAccess.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.DriverAccess.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Exceptions.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Exceptions.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Internal.Extensions.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Internal.Extensions.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.SettingsProvider.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.SettingsProvider.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Utilities.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Utilities.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Utilities.Video.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Utilities.Video.dll - ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll + ..\packages\Castle.Core.4.4.1\lib\net45\Castle.Core.dll - - ..\packages\Moq.4.13.0\lib\net45\Moq.dll + + ..\packages\Moq.4.14.5\lib\net45\Moq.dll ..\packages\NUnit.3.12.0\lib\net40\nunit.framework.dll @@ -101,11 +101,11 @@ - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.6.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll - ..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll diff --git a/Meade.net.Telescope.UnitTests/app.config b/Meade.net.Telescope.UnitTests/app.config index 487342b..13b843b 100644 --- a/Meade.net.Telescope.UnitTests/app.config +++ b/Meade.net.Telescope.UnitTests/app.config @@ -4,7 +4,7 @@ - + diff --git a/Meade.net.Telescope.UnitTests/packages.config b/Meade.net.Telescope.UnitTests/packages.config index 688d530..a95c54f 100644 --- a/Meade.net.Telescope.UnitTests/packages.config +++ b/Meade.net.Telescope.UnitTests/packages.config @@ -1,9 +1,9 @@  - - - + + + - - + + \ 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 9553298..d7431b6 100644 --- a/Meade.net.Telescope/Meade.net.Telescope.csproj +++ b/Meade.net.Telescope/Meade.net.Telescope.csproj @@ -71,37 +71,37 @@ - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Astrometry.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Astrometry.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Attributes.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Attributes.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Cache.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Cache.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Controls.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Controls.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.DeviceInterfaces.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.DeviceInterfaces.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.DriverAccess.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.DriverAccess.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Exceptions.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Exceptions.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Internal.Extensions.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Internal.Extensions.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.SettingsProvider.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.SettingsProvider.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Utilities.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Utilities.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Utilities.Video.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Utilities.Video.dll diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 5cc639c..cd93a44 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -2275,6 +2275,7 @@ namespace ASCOM.Meade.net public void Unpark() { + //todo heard a rumour that it's possible to unpark an LX200GPS. LogMessage("Unpark", "Not implemented"); throw new MethodNotImplementedException("Unpark"); } diff --git a/Meade.net.Telescope/packages.config b/Meade.net.Telescope/packages.config index a842451..b0191dd 100644 --- a/Meade.net.Telescope/packages.config +++ b/Meade.net.Telescope/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Meade.net.UnitTests/Meade.net.UnitTests.csproj b/Meade.net.UnitTests/Meade.net.UnitTests.csproj index 1889ad4..ca53286 100644 --- a/Meade.net.UnitTests/Meade.net.UnitTests.csproj +++ b/Meade.net.UnitTests/Meade.net.UnitTests.csproj @@ -35,43 +35,43 @@ - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Astrometry.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Astrometry.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Attributes.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Attributes.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Cache.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Cache.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Controls.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Controls.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.DeviceInterfaces.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.DeviceInterfaces.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.DriverAccess.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.DriverAccess.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Exceptions.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Exceptions.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Internal.Extensions.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Internal.Extensions.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.SettingsProvider.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.SettingsProvider.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Utilities.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Utilities.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Utilities.Video.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Utilities.Video.dll - ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll + ..\packages\Castle.Core.4.4.1\lib\net45\Castle.Core.dll - - ..\packages\Moq.4.13.0\lib\net45\Moq.dll + + ..\packages\Moq.4.14.5\lib\net45\Moq.dll ..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll @@ -79,11 +79,11 @@ - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.6.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll - ..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll diff --git a/Meade.net.UnitTests/app.config b/Meade.net.UnitTests/app.config index 319783c..d0d658a 100644 --- a/Meade.net.UnitTests/app.config +++ b/Meade.net.UnitTests/app.config @@ -8,7 +8,7 @@ - + diff --git a/Meade.net.UnitTests/packages.config b/Meade.net.UnitTests/packages.config index cad1be5..b8f88ee 100644 --- a/Meade.net.UnitTests/packages.config +++ b/Meade.net.UnitTests/packages.config @@ -1,9 +1,9 @@  - - - + + + - - + + \ No newline at end of file diff --git a/Meade.net.focuser/Meade.net.focuser.csproj b/Meade.net.focuser/Meade.net.focuser.csproj index 1074681..9bf14ad 100644 --- a/Meade.net.focuser/Meade.net.focuser.csproj +++ b/Meade.net.focuser/Meade.net.focuser.csproj @@ -83,37 +83,37 @@ - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Astrometry.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Astrometry.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Attributes.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Attributes.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Cache.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Cache.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Controls.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Controls.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.DeviceInterfaces.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.DeviceInterfaces.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.DriverAccess.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.DriverAccess.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Exceptions.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Exceptions.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Internal.Extensions.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Internal.Extensions.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.SettingsProvider.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.SettingsProvider.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Utilities.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Utilities.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Utilities.Video.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Utilities.Video.dll diff --git a/Meade.net.focuser/packages.config b/Meade.net.focuser/packages.config index a842451..b0191dd 100644 --- a/Meade.net.focuser/packages.config +++ b/Meade.net.focuser/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Meade.net/Meade.net.csproj b/Meade.net/Meade.net.csproj index dbc67d3..18ea8c1 100644 --- a/Meade.net/Meade.net.csproj +++ b/Meade.net/Meade.net.csproj @@ -86,37 +86,37 @@ - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Astrometry.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Astrometry.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Attributes.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Attributes.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Cache.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Cache.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Controls.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Controls.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.DeviceInterfaces.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.DeviceInterfaces.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.DriverAccess.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.DriverAccess.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Exceptions.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Exceptions.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Internal.Extensions.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Internal.Extensions.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.SettingsProvider.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.SettingsProvider.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Utilities.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Utilities.dll - ..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Utilities.Video.dll + ..\packages\ASCOM.Platform.6.5.0\lib\net40\ASCOM.Utilities.Video.dll diff --git a/Meade.net/packages.config b/Meade.net/packages.config index a842451..b0191dd 100644 --- a/Meade.net/packages.config +++ b/Meade.net/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file From c19115f25239c0218947eb6f89c314641a2dcbab Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 13:32:08 +0100 Subject: [PATCH 15/55] Added nuget.config file --- nuget.config | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 nuget.config diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000..554c2f6 --- /dev/null +++ b/nuget.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From 6c25373d7fae5a7f7c461b75e72732dba448133f Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 13:39:36 +0100 Subject: [PATCH 16/55] Trying older version of nuget api --- nuget.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuget.config b/nuget.config index 554c2f6..43a0574 100644 --- a/nuget.config +++ b/nuget.config @@ -1,6 +1,6 @@ - + \ No newline at end of file From b9f1dd9d612f638ba9832b6a4b382291bf1b4b87 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 14:07:41 +0100 Subject: [PATCH 17/55] Another try --- nuget.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuget.config b/nuget.config index 43a0574..554c2f6 100644 --- a/nuget.config +++ b/nuget.config @@ -1,6 +1,6 @@ - + \ No newline at end of file From 1dc7d7142a0240ecb131dcd97d6d6267266a804d Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 17:06:16 +0100 Subject: [PATCH 18/55] Refactored the backlash compensation so that less move commands are issued. --- .../FocuserUnitTests.cs | 21 ++++---- Meade.net.focuser/Focuser.cs | 48 +++++++++---------- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs index e326b64..d4742a3 100644 --- a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs +++ b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs @@ -416,12 +416,11 @@ namespace Meade.net.Focuser.UnitTests _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once); _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(_profileProperties.BacklashCompensation)), Times.Never); _utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Once()); - _utilMock.Verify(x => x.WaitForMilliseconds(1000), Times.Once()); } - [TestCase(200, 3, 3)] - [TestCase(-200, 1, 0)] - public void Move_WhenIncrementIsNot0_ThenMovesFocuserAndStopsFocuserWithBacklashCompensation(int position, int hundredMsWaitCount, int backlashCompensaionCount) + [TestCase(200)] + [TestCase(-200)] + public void Move_WhenIncrementIsNot0_ThenMovesFocuserAndStopsFocuserWithBacklashCompensation(int position) { _profileProperties.BacklashCompensation = 3000; @@ -433,20 +432,20 @@ namespace Meade.net.Focuser.UnitTests { _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F-#"), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F+#"), Times.Never); + _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once); + _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(_profileProperties.BacklashCompensation)), Times.Never); + _utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(1)); } else { _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F-#"), Times.Once); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F+#"), Times.Exactly(2)); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F+#"), Times.Once); + _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position) + _profileProperties.BacklashCompensation), Times.Once); + _utilMock.Verify(x => x.WaitForMilliseconds(_profileProperties.BacklashCompensation), Times.Once); + _utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(2)); } _sharedResourcesWrapperMock.Verify(x => x.Lock(It.IsAny()), Times.Once); - - _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once); - _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(_profileProperties.BacklashCompensation)), Times.Exactly(backlashCompensaionCount)); - - _utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(hundredMsWaitCount)); - _utilMock.Verify(x => x.WaitForMilliseconds(1000), Times.Once); } [Test] diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index 224e4c6..31c2a78 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -342,8 +342,6 @@ namespace ASCOM.Meade.net _tl.LogMessage("Move", position.ToString()); CheckConnected("Move"); - //todo implement dynamic braking - if (position < -MaxIncrement || position > MaxIncrement) { throw new InvalidValueException($"position out of range {-MaxIncrement} < {position} < {MaxIncrement}"); @@ -358,28 +356,32 @@ namespace ASCOM.Meade.net _sharedResourcesWrapper.Lock(() => { - MoveFocuser(direction, Math.Abs(position)); - ApplyBacklashCompensation(direction); - //This gives the focuser time to physically stop. - _utilities.WaitForMilliseconds(1000); + //backlash compensation. + var backlashCompensationSteps = direction ? Math.Abs(_backlashCompensation) : 0; + + var steps = Math.Abs(position) + backlashCompensationSteps; + + + MoveFocuser(direction, steps); + + + //todo refactor the backlash compensation to combine the commands into as few moves as practicle. + //ApplyBacklashCompensation(direction); + if (direction & backlashCompensationSteps != 0) + { + _tl.LogMessage("Move", "Applying backlash compensation"); + MoveFocuser(!direction, backlashCompensationSteps); + } + + //This gives the focuser time to physically stop. Not sure if this is really needed. + //_utilities.WaitForMilliseconds(1000); + + + //todo implement dynamic braking + //dynamic breaking is sending the command to move in the opposite direction immediatly followed by the command to stop. }); } - private void ApplyBacklashCompensation(bool directionOut) - { - if (_backlashCompensation == 0) - return; - - _tl.LogMessage("Move", "Applying backlash compensation"); - - if (directionOut) - { - MoveFocuser(directionOut, Math.Abs(_backlashCompensation)); - _utilities.WaitForMilliseconds(Math.Abs(_backlashCompensation)); - MoveFocuser(!directionOut, Math.Abs(_backlashCompensation)); - } - } - private void MoveFocuser(bool directionOut, int steps) { //_sharedResourcesWrapper.SendBlind("#:FF#"); @@ -393,9 +395,7 @@ namespace ASCOM.Meade.net //Returns: Nothing //All others – Not Supported _utilities.WaitForMilliseconds(100); - - //Todo fix this issue. A Single focus command sometimes gets lost on the #909, so sending lots of them solves the issue. - + _sharedResourcesWrapper.SendBlind(directionOut ? "#:F+#" : "#:F-#"); //:F+# Start Focuser moving inward (toward objective) //Returns: None From 4266139429acbd386ed0ebcafd8359c9c67d1e39 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 18:35:40 +0100 Subject: [PATCH 19/55] Removed all # symbols from before the commands, as they're not really needed. --- .../FocuserUnitTests.cs | 16 +- .../TelescopeUnitTests.cs | 352 +++++++++--------- Meade.net.Telescope/Telescope.cs | 156 ++++---- Meade.net.focuser/Focuser.cs | 37 +- Meade.net.v3.ncrunchsolution.user | 2 +- Meade.net/ProfileProperties.cs | 1 + Meade.net/SetupDialogForm.cs | 6 +- Meade.net/SetupDialogForm.designer.cs | 9 + Meade.net/SetupDialogForm.resx | 75 ++-- Meade.net/SharedResources.cs | 4 + 10 files changed, 359 insertions(+), 299 deletions(-) diff --git a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs index d4742a3..1056378 100644 --- a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs +++ b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs @@ -402,13 +402,13 @@ namespace Meade.net.Focuser.UnitTests if (position < 0) { - _sharedResourcesWrapperMock.Verify( x => x.SendBlind("#:F-#"), Times.Once); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F+#"), Times.Never); + _sharedResourcesWrapperMock.Verify( x => x.SendBlind(":F-#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F+#"), Times.Never); } else { - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F-#"), Times.Never); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F+#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F-#"), Times.Never); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F+#"), Times.Once); } _sharedResourcesWrapperMock.Verify( x => x.Lock(It.IsAny()), Times.Once); @@ -430,16 +430,16 @@ namespace Meade.net.Focuser.UnitTests if (position < 0) { - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F-#"), Times.Once); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F+#"), Times.Never); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F-#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F+#"), Times.Never); _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once); _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(_profileProperties.BacklashCompensation)), Times.Never); _utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(1)); } else { - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F-#"), Times.Once); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F+#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F-#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F+#"), Times.Once); _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position) + _profileProperties.BacklashCompensation), Times.Once); _utilMock.Verify(x => x.WaitForMilliseconds(_profileProperties.BacklashCompensation), Times.Once); _utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(2)); diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index b775951..9ccb9e2 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -43,7 +43,7 @@ namespace Meade.net.Telescope.UnitTests _astroUtilsMock = new Mock(); _sharedResourcesWrapperMock = new Mock(); - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GZ#")).Returns("DDD*MM’SS"); + _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(); }); @@ -122,36 +122,36 @@ namespace Meade.net.Telescope.UnitTests public void Action_Handbox_ReadDisplay() { string expectedResult = "test result string"; - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:ED#")).Returns(expectedResult); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":ED#")).Returns(expectedResult); _telescope.Connected = true; var actualResult = _telescope.Action("handbox", "readdisplay"); - _sharedResourcesWrapperMock.Verify(x => x.SendString("#:ED#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendString(":ED#"), Times.Once); Assert.That(actualResult, Is.EqualTo(expectedResult)); } - [TestCase("enter", "#:EK13#")] - [TestCase("mode", "#:EK9#")] - [TestCase("longMode", "#:EK11#")] - [TestCase("goto", "#:EK24#")] - [TestCase("0", "#:EK48#")] - [TestCase("1", "#:EK49#")] - [TestCase("2", "#:EK50#")] - [TestCase("3", "#:EK51#")] - [TestCase("4", "#:EK52#")] - [TestCase("5", "#:EK53#")] - [TestCase("6", "#:EK54#")] - [TestCase("7", "#:EK55#")] - [TestCase("8", "#:EK56#")] - [TestCase("9", "#:EK57#")] - [TestCase("up", "#:EK94#")] - [TestCase("down", "#:EK118#")] - [TestCase("back", "#:EK87#")] - [TestCase("forward", "#:EK69#")] - [TestCase("?", "#:EK63#")] + [TestCase("enter", ":EK13#")] + [TestCase("mode", ":EK9#")] + [TestCase("longMode", ":EK11#")] + [TestCase("goto", ":EK24#")] + [TestCase("0", ":EK48#")] + [TestCase("1", ":EK49#")] + [TestCase("2", ":EK50#")] + [TestCase("3", ":EK51#")] + [TestCase("4", ":EK52#")] + [TestCase("5", ":EK53#")] + [TestCase("6", ":EK54#")] + [TestCase("7", ":EK55#")] + [TestCase("8", ":EK56#")] + [TestCase("9", ":EK57#")] + [TestCase("up", ":EK94#")] + [TestCase("down", ":EK118#")] + [TestCase("back", ":EK87#")] + [TestCase("forward", ":EK69#")] + [TestCase("?", ":EK63#")] public void Action_Handbox_WhenCalling_ThenSendsAppropriateBlindCommands(string action, string expectedString) { ConnectTelescope(); @@ -172,7 +172,7 @@ namespace Meade.net.Telescope.UnitTests string parameters = $"select {site}"; _telescope.Action("site", parameters); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind($"#:W{site}#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":W{site}#"), Times.Once); } [TestCase("0")] @@ -187,10 +187,10 @@ namespace Meade.net.Telescope.UnitTests 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")] + [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) { _sharedResourcesWrapperMock.Setup(x => x.SendString(telescopeCommand)).Returns(siteName); @@ -227,10 +227,10 @@ namespace Meade.net.Telescope.UnitTests Assert.That(result, Is.EqualTo("4")); } - [TestCase("1", "#:SMHome#", "Home")] - [TestCase("2", "#:SNClub#", "Club")] - [TestCase("3", "#:SOGPS Site#", "GPS Site")] - [TestCase("4", "#:SPParents#", "Parents")] + [TestCase("1", ":SMHome#", "Home")] + [TestCase("2", ":SNClub#", "Club")] + [TestCase("3", ":SOGPS Site#", "GPS Site")] + [TestCase("4", ":SPParents#", "Parents")] public void Action_Site_SetName_WhenCallingWithValidValues_ThenSelectsCorrectSite(string site, string telescopeCommand, string siteName) { @@ -369,8 +369,8 @@ namespace Meade.net.Telescope.UnitTests if (expectedConnected) { - _sharedResourcesWrapperMock.Verify(x => x.SendString("#:GZ#"), Times.Once); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind($"#:Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"), Times.Never); + _sharedResourcesWrapperMock.Verify(x => x.SendString(":GZ#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"), Times.Never); } } @@ -385,9 +385,9 @@ namespace Meade.net.Telescope.UnitTests _telescope.Connected = true; _sharedResourcesWrapperMock.Verify( x => x.Connect("Serial", It.IsAny(), It.IsAny()), Times.Once); - _sharedResourcesWrapperMock.Verify(x => x.SendString("#:GZ#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendString(":GZ#"), Times.Once); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind($"#:Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"),Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"),Times.Once); } [Test] @@ -401,8 +401,8 @@ namespace Meade.net.Telescope.UnitTests _telescope.Connected = true; _sharedResourcesWrapperMock.Verify(x => x.Connect("Serial", It.IsAny(), It.IsAny()), Times.Once); - _sharedResourcesWrapperMock.Verify(x => x.SendString("#:GZ#"), Times.Never); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind($"#:Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"), Times.Never); + _sharedResourcesWrapperMock.Verify(x => x.SendString(":GZ#"), Times.Never); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"), Times.Never); } @@ -473,37 +473,37 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SetLongFormatFalse_WhenTelescopeReturnsShortFormat_ThenDoesNothing() { - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GZ#")).Returns("DDD*MM"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MM"); _telescope.SetLongFormat(false); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:U#"),Times.Never); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":U#"),Times.Never); } [Test] public void SetLongFormatFalse_WhenTelescopeReturnsLongFormat_ThenTogglesPrecision() { - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GZ#")).Returns("DDD*MM’SS"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MM’SS"); _telescope.SetLongFormat(false); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:U#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":U#"), Times.Once); } [Test] public void SetLongFormatTrue_WhenTelescopeReturnsLongFormat_ThenDoesNothing() { - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GZ#")).Returns("DDD*MM’SS"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MM’SS"); _telescope.SetLongFormat(true); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:U#"), Times.Never); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":U#"), Times.Never); } [Test] public void SetLongFormatTrue_WhenTelescopeReturnsShortFormat_ThenTogglesPrecision() { - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GZ#")).Returns("DDD*MM"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MM"); _telescope.SetLongFormat(true); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:U#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":U#"), Times.Once); } [Test] @@ -545,7 +545,7 @@ namespace Meade.net.Telescope.UnitTests _telescope.SelectSite(site); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind($"#:W{site}#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":W{site}#"), Times.Once); } [Test] @@ -645,9 +645,9 @@ namespace Meade.net.Telescope.UnitTests Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: AlignmentMode Set")); } - [TestCase("AUTOSTAR", "43Eg", AlignmentModes.algAltAz, "#:AA#")] - [TestCase("AUTOSTAR", "43Eg", AlignmentModes.algPolar, "#:AP#")] - [TestCase("AUTOSTAR", "43Eg", AlignmentModes.algGermanPolar, "#:AP#")] + [TestCase("AUTOSTAR", "43Eg", AlignmentModes.algAltAz, ":AA#")] + [TestCase("AUTOSTAR", "43Eg", AlignmentModes.algPolar, ":AP#")] + [TestCase("AUTOSTAR", "43Eg", AlignmentModes.algGermanPolar, ":AP#")] public void AlignmentMode_Set_WhenConnected_ThenSendsExpectedCommand(string productName, string firmware, AlignmentModes alignmentMode, string expectedCommand) { _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName); @@ -815,7 +815,7 @@ namespace Meade.net.Telescope.UnitTests { _telescope.Connected = true; - _sharedResourcesWrapperMock.Verify( x => x.SendString("#:P#"), Times.Never); + _sharedResourcesWrapperMock.Verify( x => x.SendString(":P#"), Times.Never); } [TestCase("High", false, true)] @@ -827,7 +827,7 @@ namespace Meade.net.Telescope.UnitTests _profileProperties.Precision = desiredPresision; var currentPrecision = telescopePrecision; - _sharedResourcesWrapperMock.Setup(x => x.SendChar("#:P#")).Returns(() => + _sharedResourcesWrapperMock.Setup(x => x.SendChar(":P#")).Returns(() => { currentPrecision = !currentPrecision; @@ -843,7 +843,7 @@ namespace Meade.net.Telescope.UnitTests _telescope.Connected = true; Assert.That(currentPrecision, Is.EqualTo(finalPrecision)); - _sharedResourcesWrapperMock.Verify(x => x.SendChar("#:P#"), Times.AtLeastOnce); + _sharedResourcesWrapperMock.Verify(x => x.SendChar(":P#"), Times.AtLeastOnce); } [TestCase("High", false, true)] @@ -859,7 +859,7 @@ namespace Meade.net.Telescope.UnitTests _telescope.Connected = true; - _sharedResourcesWrapperMock.Verify(x => x.SendChar("#:P#"), Times.Never); + _sharedResourcesWrapperMock.Verify(x => x.SendChar(":P#"), Times.Never); } [Test] @@ -966,7 +966,7 @@ namespace Meade.net.Telescope.UnitTests public void Declination_Get_WhenConnected_ThenReadsValueFromScope(string declincationString) { var expectedResult = 12.34; - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GD#")).Returns(declincationString); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#")).Returns(declincationString); _utilMock.Setup(x => x.DMSToDegrees(declincationString)).Returns(expectedResult); ConnectTelescope(); @@ -981,14 +981,14 @@ namespace Meade.net.Telescope.UnitTests var telescopeRaResult = "s12*34’56"; var dmsResult = 1.2; - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GD#")).Returns(telescopeRaResult); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#")).Returns(telescopeRaResult); _utilMock.Setup(x => x.DMSToDegrees(telescopeRaResult)).Returns(dmsResult); ConnectTelescope(); var result = _telescope.Declination; - _sharedResourcesWrapperMock.Verify(x => x.SendString("#:GD#"), Times.Exactly(2)); + _sharedResourcesWrapperMock.Verify(x => x.SendString(":GD#"), Times.Exactly(2)); _utilMock.Verify(x => x.DMSToDegrees(telescopeRaResult), Times.Exactly(2)); Assert.That(result, Is.EqualTo(dmsResult)); @@ -1102,7 +1102,7 @@ namespace Meade.net.Telescope.UnitTests _telescope.GuideRateDeclination = newGuideRate; - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:Rg01.2#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Rg01.2#"), Times.Once); Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate)); } @@ -1135,7 +1135,7 @@ namespace Meade.net.Telescope.UnitTests _telescope.GuideRateRightAscension = newGuideRate; - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:Rg01.2#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Rg01.2#"), Times.Once); Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate)); } @@ -1157,23 +1157,23 @@ namespace Meade.net.Telescope.UnitTests } [TestCase( 0, "", TelescopeAxes.axisPrimary)] - [TestCase( 1, "#:RG#", TelescopeAxes.axisPrimary)] - [TestCase(-1, "#:RG#", TelescopeAxes.axisPrimary)] - [TestCase( 2, "#:RC#", TelescopeAxes.axisPrimary)] - [TestCase(-2, "#:RC#", TelescopeAxes.axisPrimary)] - [TestCase( 3, "#:RM#", TelescopeAxes.axisPrimary)] - [TestCase(-3, "#:RM#", TelescopeAxes.axisPrimary)] - [TestCase( 4, "#:RS#", TelescopeAxes.axisPrimary)] - [TestCase(-4, "#:RS#", TelescopeAxes.axisPrimary)] + [TestCase( 1, ":RG#", TelescopeAxes.axisPrimary)] + [TestCase(-1, ":RG#", TelescopeAxes.axisPrimary)] + [TestCase( 2, ":RC#", TelescopeAxes.axisPrimary)] + [TestCase(-2, ":RC#", TelescopeAxes.axisPrimary)] + [TestCase( 3, ":RM#", TelescopeAxes.axisPrimary)] + [TestCase(-3, ":RM#", TelescopeAxes.axisPrimary)] + [TestCase( 4, ":RS#", TelescopeAxes.axisPrimary)] + [TestCase(-4, ":RS#", TelescopeAxes.axisPrimary)] [TestCase(0, "", TelescopeAxes.axisSecondary)] - [TestCase(1, "#:RG#", TelescopeAxes.axisSecondary)] - [TestCase(-1, "#:RG#", TelescopeAxes.axisSecondary)] - [TestCase(2, "#:RC#", TelescopeAxes.axisSecondary)] - [TestCase(-2, "#:RC#", TelescopeAxes.axisSecondary)] - [TestCase(3, "#:RM#", TelescopeAxes.axisSecondary)] - [TestCase(-3, "#:RM#", TelescopeAxes.axisSecondary)] - [TestCase(4, "#:RS#", TelescopeAxes.axisSecondary)] - [TestCase(-4, "#:RS#", TelescopeAxes.axisSecondary)] + [TestCase(1, ":RG#", TelescopeAxes.axisSecondary)] + [TestCase(-1, ":RG#", TelescopeAxes.axisSecondary)] + [TestCase(2, ":RC#", TelescopeAxes.axisSecondary)] + [TestCase(-2, ":RC#", TelescopeAxes.axisSecondary)] + [TestCase(3, ":RM#", TelescopeAxes.axisSecondary)] + [TestCase(-3, ":RM#", TelescopeAxes.axisSecondary)] + [TestCase(4, ":RS#", TelescopeAxes.axisSecondary)] + [TestCase(-4, ":RS#", TelescopeAxes.axisSecondary)] public void MoveAxis_WhenConnected_ThenExecutesCorrectCommandSequence(double rate, string slewRateCommand, TelescopeAxes axis) { ConnectTelescope(); @@ -1184,10 +1184,10 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Verify( x => x.SendBlind(slewRateCommand), Times.Once); else { - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:RG#"), Times.Never); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:RC#"), Times.Never); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:RM#"), Times.Never); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:RS#"), Times.Never); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":RG#"), Times.Never); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":RC#"), Times.Never); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":RM#"), Times.Never); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":RS#"), Times.Never); } switch (axis) @@ -1196,14 +1196,14 @@ namespace Meade.net.Telescope.UnitTests switch (rate.Compare(0)) { case ComparisonResult.Equals: - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:Qe#"), Times.Once); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:Qw#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Qe#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Qw#"), Times.Once); break; case ComparisonResult.Greater: - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:Me#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Me#"), Times.Once); break; case ComparisonResult.Lower: - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:Mw#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Mw#"), Times.Once); break; } break; @@ -1211,14 +1211,14 @@ namespace Meade.net.Telescope.UnitTests switch (rate.Compare(0)) { case ComparisonResult.Equals: - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:Qn#"), Times.Once); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:Qs#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Qn#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Qs#"), Times.Once); break; case ComparisonResult.Greater: - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:Mn#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Mn#"), Times.Once); break; case ComparisonResult.Lower: - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:Ms#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Ms#"), Times.Once); break; } break; @@ -1264,11 +1264,11 @@ namespace Meade.net.Telescope.UnitTests { ConnectTelescope(); Assert.That(_telescope.AtPark, Is.False); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:hP#"), Times.Never); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":hP#"), Times.Never); _telescope.Park(); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:hP#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":hP#"), Times.Once); Assert.That(_telescope.AtPark, Is.True); } @@ -1279,7 +1279,7 @@ namespace Meade.net.Telescope.UnitTests _telescope.Park(); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:hP#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":hP#"), Times.Once); Assert.That(_telescope.AtPark, Is.True); @@ -1287,7 +1287,7 @@ namespace Meade.net.Telescope.UnitTests _telescope.Park(); //no change from previous state. - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:hP#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind(":hP#"), Times.Once); Assert.That(_telescope.AtPark, Is.True); } @@ -1326,7 +1326,7 @@ namespace Meade.net.Telescope.UnitTests break; } - _sharedResourcesWrapperMock.Verify(x => x.SendBlind($"#:Mg{d}{duration:0000}#")); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Mg{d}{duration:0000}#")); _utilMock.Verify( x => x.WaitForMilliseconds(duration), Times.Once); } @@ -1336,7 +1336,7 @@ namespace Meade.net.Telescope.UnitTests [TestCase(GuideDirections.guideSouth)] public void PulseGuide_WhenSlewingAndPulseGuideAttempted_ThenThrowsExpectedException(GuideDirections direction) { - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:D#")).Returns("|"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":D#")).Returns("|"); var duration = 0; ConnectTelescope(); @@ -1352,7 +1352,7 @@ namespace Meade.net.Telescope.UnitTests [TestCase(GuideDirections.guideSouth, TelescopeAxes.axisSecondary)] public void PulseGuide_WhenMovingAxisAndPulseGuideAttempted_ThenThrowsExpectedException(GuideDirections direction, TelescopeAxes axes) { - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:D#")).Returns(""); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":D#")).Returns(""); var duration = 0; ConnectTelescope(); @@ -1417,10 +1417,10 @@ namespace Meade.net.Telescope.UnitTests break; } - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:RG#")); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind($"#:M{d}#")); + _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}#")); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Q{d}#")); } [TestCase(GuideDirections.guideEast)] @@ -1453,10 +1453,10 @@ namespace Meade.net.Telescope.UnitTests break; } - _sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:RG#")); - _sharedResourcesWrapperMock.Verify(x => x.SendBlind($"#:M{d}#")); + _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}#")); + _sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Q{d}#")); } [Test] @@ -1476,14 +1476,14 @@ namespace Meade.net.Telescope.UnitTests var telescopeRaResult = "HH:MM:SS"; var hmsResult = 1.2; - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GR#")).Returns(telescopeRaResult); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeRaResult); _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(hmsResult); ConnectTelescope(); var result = _telescope.RightAscension; - _sharedResourcesWrapperMock.Verify( x => x.SendString("#:GR#"), Times.Exactly(2)); + _sharedResourcesWrapperMock.Verify( x => x.SendString(":GR#"), Times.Exactly(2)); _utilMock.Verify( x => x.HMSToHours(telescopeRaResult), Times.Exactly(2)); Assert.That(result,Is.EqualTo(hmsResult)); @@ -1605,14 +1605,14 @@ namespace Meade.net.Telescope.UnitTests var siteLatitudeString = "testLatString"; var siteLatitudeValue = 123.45; - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:Gt#")).Returns(siteLatitudeString); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":Gt#")).Returns(siteLatitudeString); _utilMock.Setup(x => x.DMSToDegrees(siteLatitudeString)).Returns(siteLatitudeValue); ConnectTelescope(); var result = _telescope.SiteLatitude; - _sharedResourcesWrapperMock.Verify( x => x.SendString("#:Gt#"), Times.Once); + _sharedResourcesWrapperMock.Verify( x => x.SendString(":Gt#"), Times.Once); Assert.That(result,Is.EqualTo(siteLatitudeValue)); } @@ -1655,8 +1655,8 @@ namespace Meade.net.Telescope.UnitTests Assert.That(exception.Message, Is.EqualTo("Failed to set site latitude.")); } - [TestCase(-10.5, "#:St-10*30#")] - [TestCase(20.75, "#:St+20*45#")] + [TestCase(-10.5, ":St-10*30#")] + [TestCase(20.75, ":St+20*45#")] public void SiteLatitude_Set_WhenValidValues_ThenValueSentToTelescope(double siteLatitude, string expectedCommand) { _sharedResourcesWrapperMock.Setup(x => x.SendChar(expectedCommand)).Returns("1"); @@ -1688,7 +1688,7 @@ namespace Meade.net.Telescope.UnitTests { var telescopeLongitude = "testLongitude"; - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:Gg#")).Returns(telescopeLongitude); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":Gg#")).Returns(telescopeLongitude); _utilMock.Setup(x => x.DMSToDegrees(telescopeLongitude)).Returns(telescopeLongitudeValue); ConnectTelescope(); @@ -1735,7 +1735,7 @@ namespace Meade.net.Telescope.UnitTests Assert.That(exception.Message, Is.EqualTo("Failed to set site longitude.")); } - [TestCase(10, "#:Sg350*00#")] + [TestCase(10, ":Sg350*00#")] public void SiteLongitude_Set_WhenConnectedAndTelescopeFails_ThenThrowsException(double longitude, string expectedCommand) { _sharedResourcesWrapperMock.Setup(x => x.SendChar(expectedCommand)).Returns("1"); @@ -1767,26 +1767,26 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SyncToTarget_WhenSyncToTargetFails_ThenThrowsException() { - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:CM#")).Returns(string.Empty); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":CM#")).Returns(string.Empty); ConnectTelescope(); var exception = Assert.Throws(() => { _telescope.SyncToTarget(); } ); Assert.That(exception.Message, Is.EqualTo("Unable to perform sync")); - _sharedResourcesWrapperMock.Verify(x => x.SendString("#:CM#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendString(":CM#"), Times.Once); } [Test] public void SyncToTarget_WhenSyncToTargetWorks_ThennoExceptionThrown() { - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:CM#")).Returns(" M31 EX GAL MAG 3.5 SZ178.0'#"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":CM#")).Returns(" M31 EX GAL MAG 3.5 SZ178.0'#"); ConnectTelescope(); Assert.DoesNotThrow(() => { _telescope.SyncToTarget(); }); - _sharedResourcesWrapperMock.Verify(x => x.SendString("#:CM#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendString(":CM#"), Times.Once); } [Test] @@ -1825,10 +1825,10 @@ namespace Meade.net.Telescope.UnitTests Assert.That(exception.Message, Is.EqualTo("Target declination invalid")); } - [TestCase(-30.5, "-30*30:00", "#:Sd-30*30:00#")] - [TestCase(30.5, "30*30:00", "#:Sd+30*30:00#")] - [TestCase(-75.25, "-75*15:00", "#:Sd-75*15:00#")] - [TestCase(50, "50*00:00", "#:Sd+50*00:00#")] + [TestCase(-30.5, "-30*30:00", ":Sd-30*30:00#")] + [TestCase(30.5, "30*30:00", ":Sd+30*30:00#")] + [TestCase(-75.25, "-75*15:00", ":Sd-75*15:00#")] + [TestCase(50, "50*00:00", ":Sd+50*00:00#")] public void TargetDeclination_Set_WhenValueOK_ThenSetsNewTargetDeclination( double declination,string decstring, string commandString) { @@ -1855,7 +1855,7 @@ namespace Meade.net.Telescope.UnitTests Assert.That(exception.Message, Is.EqualTo("Target not set")); } - [TestCase(50, "50*00:00", "#:Sd+50*00:00#")] + [TestCase(50, "50*00:00", ":Sd+50*00:00#")] public void TargetDeclination_Get_WhenValueOK_ThenSetsNewTargetDeclination(double declination, string decstring, string commandString) { _utilMock.Setup(x => x.DegreesToDMS(declination, "*", ":", ":", 2)).Returns(decstring); @@ -1906,8 +1906,8 @@ namespace Meade.net.Telescope.UnitTests Assert.That(exception.Message, Is.EqualTo("Failed to set TargetRightAscension.")); } - [TestCase(5.5, "05:30:00", "#:Sr05:30:00#")] - [TestCase(10, "10:00:00", "#:Sr10:00:00#")] + [TestCase(5.5, "05:30:00", ":Sr05:30:00#")] + [TestCase(10, "10:00:00", ":Sr10:00:00#")] public void TargetRightAscension_Set_WhenValueOK_ThenSetsNewTargetDeclination(double rightAscension, string hms, string commandString) { _utilMock.Setup(x => x.HoursToHMS(rightAscension, ":", ":", ":", 2)).Returns(hms); @@ -1933,7 +1933,7 @@ namespace Meade.net.Telescope.UnitTests Assert.That(exception.Message, Is.EqualTo("Target not set")); } - [TestCase(15, "15:00:00", "#:Sr15:00:00#")] + [TestCase(15, "15:00:00", ":Sr15:00:00#")] public void TargetRightAscension_Get_WhenValueOK_ThenSetsNewTargetDeclination(double rightAscension, string hms, string commandString) { _utilMock.Setup(x => x.HoursToHMS(rightAscension, ":", ":", ":", 2)).Returns(hms); @@ -1970,8 +1970,8 @@ namespace Meade.net.Telescope.UnitTests Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: TrackingRate Set")); } - [TestCase(DriveRates.driveSidereal, "#:TQ#")] - [TestCase(DriveRates.driveLunar, "#:TL#")] + [TestCase(DriveRates.driveSidereal, ":TQ#")] + [TestCase(DriveRates.driveLunar, ":TL#")] public void TrackingRate_Set_WhenConnected_ThenSendsCommandToTelescope(DriveRates rate, string commandString) { ConnectTelescope(); @@ -2039,9 +2039,9 @@ namespace Meade.net.Telescope.UnitTests public void UTCDate_Get_WhenConnected_ThenReturnsUTCDateTime(string telescopeDate, string telescopeTime, string telescopeUtcCorrection, int year, int month, int day, int hour, int min, int second) { - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GC#")).Returns(telescopeDate); - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GL#")).Returns(telescopeTime); - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GG#")).Returns(telescopeUtcCorrection); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GC#")).Returns(telescopeDate); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GL#")).Returns(telescopeTime); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GG#")).Returns(telescopeUtcCorrection); ConnectTelescope(); @@ -2074,8 +2074,8 @@ namespace Meade.net.Telescope.UnitTests var newDate = new DateTime(year, month, day, hour, min, second, DateTimeKind.Local) + utcCorrection; - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GG#")).Returns(telescopeUtcCorrection); - _sharedResourcesWrapperMock.Setup(x => x.SendChar($"#:SL{telescopeTime}#")).Returns("0"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GG#")).Returns(telescopeUtcCorrection); + _sharedResourcesWrapperMock.Setup(x => x.SendChar($":SL{telescopeTime}#")).Returns("0"); ConnectTelescope(); @@ -2093,9 +2093,9 @@ namespace Meade.net.Telescope.UnitTests var newDate = new DateTime(year, month, day, hour, min, second, DateTimeKind.Local) + utcCorrection; - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GG#")).Returns(telescopeUtcCorrection); - _sharedResourcesWrapperMock.Setup(x => x.SendChar($"#:SL{telescopeTime}#")).Returns("1"); - _sharedResourcesWrapperMock.Setup(x => x.SendChar($"#:SC{newDate:MM/dd/yy}#")).Returns("0"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GG#")).Returns(telescopeUtcCorrection); + _sharedResourcesWrapperMock.Setup(x => x.SendChar($":SL{telescopeTime}#")).Returns("1"); + _sharedResourcesWrapperMock.Setup(x => x.SendChar($":SC{newDate:MM/dd/yy}#")).Returns("0"); ConnectTelescope(); @@ -2115,9 +2115,9 @@ namespace Meade.net.Telescope.UnitTests var newDate = new DateTime(year, month, day, hour, min, second, DateTimeKind.Local) + utcCorrection; - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GG#")).Returns(telescopeUtcCorrection); - _sharedResourcesWrapperMock.Setup(x => x.SendChar($"#:SL{telescopeTime}#")).Returns("1"); - _sharedResourcesWrapperMock.Setup(x => x.SendChar($"#:SC{telescopeDate}#")).Returns("1"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GG#")).Returns(telescopeUtcCorrection); + _sharedResourcesWrapperMock.Setup(x => x.SendChar($":SL{telescopeTime}#")).Returns("1"); + _sharedResourcesWrapperMock.Setup(x => x.SendChar($":SC{telescopeDate}#")).Returns("1"); ConnectTelescope(); @@ -2136,16 +2136,16 @@ namespace Meade.net.Telescope.UnitTests string dec = "-30*30:00"; _utilMock.Setup(x => x.HoursToHMS(rightAscension, ":", ":", ":", 2)).Returns(hms); - _sharedResourcesWrapperMock.Setup(x => x.SendChar($"#:Sr{hms}#")).Returns("1"); + _sharedResourcesWrapperMock.Setup(x => x.SendChar($":Sr{hms}#")).Returns("1"); _utilMock.Setup(x => x.DegreesToDMS(declination, "*", ":", ":", 2)).Returns(dec); - _sharedResourcesWrapperMock.Setup(x => x.SendChar($"#:Sd{dec}#")).Returns("1"); + _sharedResourcesWrapperMock.Setup(x => x.SendChar($":Sd{dec}#")).Returns("1"); ConnectTelescope(); _telescope.SyncToCoordinates(rightAscension, declination); - _sharedResourcesWrapperMock.Verify( x => x.SendString("#:CM#"), Times.Once); + _sharedResourcesWrapperMock.Verify( x => x.SendString(":CM#"), Times.Once); Assert.That(_telescope.TargetRightAscension, Is.EqualTo(rightAscension)); Assert.That(_telescope.TargetDeclination, Is.EqualTo(declination)); } @@ -2157,7 +2157,7 @@ namespace Meade.net.Telescope.UnitTests Assert.That(result, Is.False); - _sharedResourcesWrapperMock.Verify(x => x.SendString("#:D#"), Times.Never); + _sharedResourcesWrapperMock.Verify(x => x.SendString(":D#"), Times.Never); } [Test] @@ -2169,13 +2169,13 @@ namespace Meade.net.Telescope.UnitTests Assert.That(result, Is.False); - _sharedResourcesWrapperMock.Verify(x => x.SendString("#:D#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendString(":D#"), Times.Once); } [Test] public void Slewing_WhenTelescopeIsSlewing_ThenReturnsTrue() { - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:D#")).Returns("|"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":D#")).Returns("|"); ConnectTelescope(); @@ -2183,7 +2183,7 @@ namespace Meade.net.Telescope.UnitTests Assert.That(result, Is.True); - _sharedResourcesWrapperMock.Verify(x => x.SendString("#:D#"),Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendString(":D#"),Times.Once); } [TestCase(1, TelescopeAxes.axisPrimary)] @@ -2199,7 +2199,7 @@ namespace Meade.net.Telescope.UnitTests var result = _telescope.Slewing; Assert.That(result, Is.True); - _sharedResourcesWrapperMock.Verify(x => x.SendString("#:D#"), Times.Never); + _sharedResourcesWrapperMock.Verify(x => x.SendString(":D#"), Times.Never); } @@ -2247,7 +2247,7 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SlewToTargetAsync_WhenTargetSetAndSlewIsPossible_ThenAttemptsSlew() { - _sharedResourcesWrapperMock.Setup(x => x.SendChar("#:MS#")).Returns("0"); + _sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("0"); ConnectTelescope(); @@ -2257,13 +2257,13 @@ namespace Meade.net.Telescope.UnitTests _telescope.SlewToTargetAsync(); - _sharedResourcesWrapperMock.Verify(x => x.SendChar("#:MS#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendChar(":MS#"), Times.Once); } [Test] public void SlewToTargetAsync_WhenTargetBelowHorizon_ThenThrowsException() { - _sharedResourcesWrapperMock.Setup(x => x.SendChar("#:MS#")).Returns("1"); + _sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("1"); _sharedResourcesWrapperMock.Setup(x => x.ReadTerminated()).Returns("Below horizon"); ConnectTelescope(); @@ -2278,7 +2278,7 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SlewToTargetAsync_WhenTargetBelowElevation_ThenThrowsException() { - _sharedResourcesWrapperMock.Setup(x => x.SendChar("#:MS#")).Returns("2"); + _sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("2"); _sharedResourcesWrapperMock.Setup(x => x.ReadTerminated()).Returns("Above below elevation"); ConnectTelescope(); @@ -2293,7 +2293,7 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SlewToTargetAsync_WhenTelescopeCanHitTripod_ThenThrowsException() { - _sharedResourcesWrapperMock.Setup(x => x.SendChar("#:MS#")).Returns("3"); + _sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("3"); _sharedResourcesWrapperMock.Setup(x => x.ReadTerminated()).Returns("the telescope can hit the tripod"); ConnectTelescope(); @@ -2315,11 +2315,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SlewToTarget_WhenSlewing_ThenWaitsForTheSlewToComplete() { - _sharedResourcesWrapperMock.Setup(x => x.SendChar("#:MS#")).Returns("0"); + _sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("0"); var slewCounter = 0; var iterations = 10; - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:D#")).Returns(() => + _sharedResourcesWrapperMock.Setup(x => x.SendString(":D#")).Returns(() => { slewCounter++; if (slewCounter <= iterations) @@ -2350,11 +2350,11 @@ namespace Meade.net.Telescope.UnitTests var rightAscension = 1; var declination = 2; - _sharedResourcesWrapperMock.Setup(x => x.SendChar("#:MS#")).Returns("0"); + _sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("0"); //var slewCounter = 0; //var iterations = 10; - //_sharedResourcesWrapperMock.Setup(x => x.SendString("#:D#")).Returns(() => + //_sharedResourcesWrapperMock.Setup(x => x.SendString(":D#")).Returns(() => //{ // slewCounter++; // if (slewCounter <= iterations) @@ -2370,7 +2370,7 @@ namespace Meade.net.Telescope.UnitTests //_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny()), Times.Exactly(iterations)); Assert.That(_telescope.TargetRightAscension, Is.EqualTo(rightAscension)); Assert.That(_telescope.TargetDeclination, Is.EqualTo(declination)); - _sharedResourcesWrapperMock.Verify( x => x.SendChar("#:MS#"), Times.Once); + _sharedResourcesWrapperMock.Verify( x => x.SendChar(":MS#"), Times.Once); } [Test] @@ -2386,11 +2386,11 @@ namespace Meade.net.Telescope.UnitTests var rightAscension = 1; var declination = 2; - _sharedResourcesWrapperMock.Setup(x => x.SendChar("#:MS#")).Returns("0"); + _sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("0"); var slewCounter = 0; var iterations = 10; - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:D#")).Returns(() => + _sharedResourcesWrapperMock.Setup(x => x.SendString(":D#")).Returns(() => { slewCounter++; if (slewCounter <= iterations) @@ -2403,7 +2403,7 @@ namespace Meade.net.Telescope.UnitTests _telescope.SlewToCoordinates(rightAscension, declination); Assert.That(_telescope.TargetRightAscension, Is.EqualTo(rightAscension)); Assert.That(_telescope.TargetDeclination, Is.EqualTo(declination)); - _sharedResourcesWrapperMock.Verify(x => x.SendChar("#:MS#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendChar(":MS#"), Times.Once); _utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny()), Times.Exactly(iterations)); } @@ -2459,15 +2459,15 @@ namespace Meade.net.Telescope.UnitTests var rightAscension = 20; var declination = 10; - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GC#")).Returns("10/15/20"); - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GL#")).Returns("20:15:10"); - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GG#")).Returns("-1.0"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GC#")).Returns("10/15/20"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GL#")).Returns("20:15:10"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GG#")).Returns("-1.0"); _astroMathsMock .Setup(x => x.ConvertHozToEq(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).Returns(new EquatorialCoordinates { Declination = declination, RightAscension = rightAscension }); - _sharedResourcesWrapperMock.Setup(x => x.SendChar("#:MS#")).Returns("0"); + _sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("0"); ConnectTelescope(); @@ -2475,7 +2475,7 @@ namespace Meade.net.Telescope.UnitTests Assert.That(_telescope.TargetRightAscension, Is.EqualTo(rightAscension)); Assert.That(_telescope.TargetDeclination, Is.EqualTo(declination)); - _sharedResourcesWrapperMock.Verify(x => x.SendChar("#:MS#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendChar(":MS#"), Times.Once); } [Test] @@ -2493,19 +2493,19 @@ namespace Meade.net.Telescope.UnitTests var azimuth = 30; var altitude = 40; - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GC#")).Returns("10/15/20"); - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GL#")).Returns("20:15:10"); - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GG#")).Returns("-1.0"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GC#")).Returns("10/15/20"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GL#")).Returns("20:15:10"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GG#")).Returns("-1.0"); _astroMathsMock .Setup(x => x.ConvertHozToEq(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).Returns(new EquatorialCoordinates { Declination = declination, RightAscension = rightAscension }); - _sharedResourcesWrapperMock.Setup(x => x.SendChar("#:MS#")).Returns("0"); + _sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("0"); var slewCounter = 0; var iterations = 10; - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:D#")).Returns(() => + _sharedResourcesWrapperMock.Setup(x => x.SendString(":D#")).Returns(() => { slewCounter++; if (slewCounter <= iterations) @@ -2519,7 +2519,7 @@ namespace Meade.net.Telescope.UnitTests Assert.That(_telescope.TargetRightAscension, Is.EqualTo(rightAscension)); Assert.That(_telescope.TargetDeclination, Is.EqualTo(declination)); - _sharedResourcesWrapperMock.Verify(x => x.SendChar("#:MS#"), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendChar(":MS#"), Times.Once); _utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny()), Times.Exactly(iterations)); } @@ -2547,14 +2547,14 @@ namespace Meade.net.Telescope.UnitTests var mockHourAngle = 3; - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GC#")).Returns("10/15/20"); - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GL#")).Returns("20:15:10"); - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GG#")).Returns("-1.0"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GC#")).Returns("10/15/20"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GL#")).Returns("20:15:10"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GG#")).Returns("-1.0"); - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:Gg#")).Returns(telescopeLongitude); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":Gg#")).Returns(telescopeLongitude); _utilMock.Setup(x => x.DMSToDegrees(telescopeLongitude)).Returns(telescopeLongitudeValue); - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GR#")).Returns(telescopeLatitude); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeLatitude); _utilMock.Setup(x => x.HMSToHours(telescopeLatitude)).Returns(telescopeLatitudeValue); _astroMathsMock.Setup(x => x.RightAscensionToHourAngle(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockHourAngle); @@ -2592,14 +2592,14 @@ namespace Meade.net.Telescope.UnitTests var mockHourAngle = 3; - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GC#")).Returns("10/15/20"); - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GL#")).Returns("20:15:10"); - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GG#")).Returns("-1.0"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GC#")).Returns("10/15/20"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GL#")).Returns("20:15:10"); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GG#")).Returns("-1.0"); - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:Gg#")).Returns(telescopeLongitude); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":Gg#")).Returns(telescopeLongitude); _utilMock.Setup(x => x.DMSToDegrees(telescopeLongitude)).Returns(telescopeLongitudeValue); - _sharedResourcesWrapperMock.Setup(x => x.SendString("#:GR#")).Returns(telescopeLatitude); + _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeLatitude); _utilMock.Setup(x => x.HMSToHours(telescopeLatitude)).Returns(telescopeLatitudeValue); _astroMathsMock.Setup(x => x.RightAscensionToHourAngle(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockHourAngle); @@ -2627,12 +2627,12 @@ namespace Meade.net.Telescope.UnitTests _telescope.AbortSlew(); - _sharedResourcesWrapperMock.Verify( x => x.SendBlind("#:Q#"),Times.Once); + _sharedResourcesWrapperMock.Verify( x => x.SendBlind(":Q#"),Times.Once); var isSloSlewing = _telescope.Slewing; Assert.That(isSloSlewing, Is.False); - _sharedResourcesWrapperMock.Verify( x => x.SendString("#:D#"), Times.Once); + _sharedResourcesWrapperMock.Verify( x => x.SendString(":D#"), Times.Once); } } } \ No newline at end of file diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index cd93a44..3d79ae1 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -202,68 +202,68 @@ namespace ASCOM.Meade.net { //Read the screen case "readdisplay": - var output = _sharedResourcesWrapper.SendString("#:ED#"); + var output = _sharedResourcesWrapper.SendString(":ED#"); return output; //top row of buttons case "enter": - _sharedResourcesWrapper.SendBlind("#:EK13#"); + _sharedResourcesWrapper.SendBlind(":EK13#"); break; case "mode": - _sharedResourcesWrapper.SendBlind("#:EK9#"); + _sharedResourcesWrapper.SendBlind(":EK9#"); break; case "longmode": - _sharedResourcesWrapper.SendBlind("#:EK11#"); + _sharedResourcesWrapper.SendBlind(":EK11#"); break; case "goto": - _sharedResourcesWrapper.SendBlind("#:EK24#"); + _sharedResourcesWrapper.SendBlind(":EK24#"); break; case "0": //light and 0 - _sharedResourcesWrapper.SendBlind("#:EK48#"); + _sharedResourcesWrapper.SendBlind(":EK48#"); break; case "1": - _sharedResourcesWrapper.SendBlind("#:EK49#"); + _sharedResourcesWrapper.SendBlind(":EK49#"); break; case "2": - _sharedResourcesWrapper.SendBlind("#:EK50#"); + _sharedResourcesWrapper.SendBlind(":EK50#"); break; case "3": - _sharedResourcesWrapper.SendBlind("#:EK51#"); + _sharedResourcesWrapper.SendBlind(":EK51#"); break; case "4": - _sharedResourcesWrapper.SendBlind("#:EK52#"); + _sharedResourcesWrapper.SendBlind(":EK52#"); break; case "5": - _sharedResourcesWrapper.SendBlind("#:EK53#"); + _sharedResourcesWrapper.SendBlind(":EK53#"); break; case "6": - _sharedResourcesWrapper.SendBlind("#:EK54#"); + _sharedResourcesWrapper.SendBlind(":EK54#"); break; case "7": - _sharedResourcesWrapper.SendBlind("#:EK55#"); + _sharedResourcesWrapper.SendBlind(":EK55#"); break; case "8": - _sharedResourcesWrapper.SendBlind("#:EK56#"); + _sharedResourcesWrapper.SendBlind(":EK56#"); break; case "9": - _sharedResourcesWrapper.SendBlind("#:EK57#"); + _sharedResourcesWrapper.SendBlind(":EK57#"); break; case "up": - _sharedResourcesWrapper.SendBlind("#:EK94#"); + _sharedResourcesWrapper.SendBlind(":EK94#"); break; case "down": - _sharedResourcesWrapper.SendBlind("#:EK118#"); + _sharedResourcesWrapper.SendBlind(":EK118#"); break; case "back": - _sharedResourcesWrapper.SendBlind("#:EK87#"); + _sharedResourcesWrapper.SendBlind(":EK87#"); break; case "forward": - _sharedResourcesWrapper.SendBlind("#:EK69#"); + _sharedResourcesWrapper.SendBlind(":EK69#"); break; case "?": - _sharedResourcesWrapper.SendBlind("#:EK63#"); + _sharedResourcesWrapper.SendBlind(":EK63#"); break; default: LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters); @@ -541,7 +541,7 @@ namespace ASCOM.Meade.net _sharedResourcesWrapper.Lock(() => { - var result = _sharedResourcesWrapper.SendString("#:GZ#"); + var result = _sharedResourcesWrapper.SendString(":GZ#"); //:GZ# Get telescope azimuth //Returns: DDD*MM# or DDD*MM’SS# //The current telescope Azimuth depending on the selected precision. @@ -551,7 +551,7 @@ namespace ASCOM.Meade.net if (IsLongFormat != setLongFormat) { _utilities.WaitForMilliseconds(500); - _sharedResourcesWrapper.SendBlind("#:U#"); + _sharedResourcesWrapper.SendBlind(":U#"); //:U# Toggle between low/hi precision positions //Low - RA displays and messages HH:MM.T sDD*MM //High - Dec / Az / El displays and messages HH:MM: SS sDD*MM:SS @@ -565,7 +565,7 @@ namespace ASCOM.Meade.net private bool TogglePrecision() { LogMessage("TogglePrecision", "Toggling slewing precision"); - var result = _sharedResourcesWrapper.SendChar("#:P#"); + var result = _sharedResourcesWrapper.SendChar(":P#"); //:P# Toggles High Precsion Pointing. When High precision pointing is enabled scope will first allow the operator to center a nearby bright star before moving to the actual target. //Returns: //“HIGH PRECISION” Current setting after this command. @@ -605,7 +605,7 @@ namespace ASCOM.Meade.net { CheckConnectedAndValidateSite(site, "SelectSite"); - _sharedResourcesWrapper.SendBlind($"#:W{site}#"); + _sharedResourcesWrapper.SendBlind($":W{site}#"); //:W# //Set current site to, an ASCII digit in the range 1..4 //Returns: Nothing @@ -631,7 +631,7 @@ namespace ASCOM.Meade.net switch (site) { case 1: - command = $"#:SM{sitename}#"; + 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: @@ -639,7 +639,7 @@ namespace ASCOM.Meade.net //1 - Valid break; case 2: - command = $"#:SN{sitename}#"; + 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: @@ -647,7 +647,7 @@ namespace ASCOM.Meade.net //1 - Valid break; case 3: - command = $"#:SO{sitename}#"; + 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: @@ -655,7 +655,7 @@ namespace ASCOM.Meade.net //1 - Valid break; case 4: - command = $"#:SP{sitename}#"; + 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: @@ -680,22 +680,22 @@ namespace ASCOM.Meade.net switch (site) { case 1: - return _sharedResourcesWrapper.SendString("#:GM#"); + 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#"); + 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#"); + 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#"); + return _sharedResourcesWrapper.SendString(":GP#"); //:GP# Get Site 4 Name //Returns: # //A ‘#’ terminated string with the name of the requested site. @@ -750,11 +750,11 @@ namespace ASCOM.Meade.net { //string name = "Short driver name - please customise"; - //var telescopeProduceName = _sharedResourcesWrapper.SendString("#:GVP#"); + //var telescopeProduceName = _sharedResourcesWrapper.SendString(":GVP#"); ////:GVP# Get Telescope Product Name ////Returns: # - //var firmwareVersion = _sharedResourcesWrapper.SendString("#:GVN#"); + //var firmwareVersion = _sharedResourcesWrapper.SendString(":GVN#"); ////:GVN# Get Telescope Firmware Number ////Returns: dd.d# @@ -774,7 +774,7 @@ namespace ASCOM.Meade.net CheckConnected("AbortSlew"); LogMessage("AbortSlew", "Aborting slew"); - _sharedResourcesWrapper.SendBlind("#:Q#"); + _sharedResourcesWrapper.SendBlind(":Q#"); //:Q# Halt all current slewing //Returns:Nothing @@ -803,7 +803,7 @@ namespace ASCOM.Meade.net //todo implement GW Command - Supported in Autostar 43Eg and above //if FirmwareIsGreaterThan(TelescopeList.Autostar497_43EG) //{ - //var alignmentString = SerialPort.CommandTerminated("#:GW#", "#"); + //var alignmentString = SerialPort.CommandTerminated(":GW#", "#"); //:GW# Get Scope Alignment Status //Returns: # // where: @@ -843,13 +843,13 @@ namespace ASCOM.Meade.net switch (value) { case AlignmentModes.algAltAz: - _sharedResourcesWrapper.SendBlind("#:AA#"); + _sharedResourcesWrapper.SendBlind(":AA#"); //:AA# Sets telescope the AltAz alignment mode //Returns: nothing break; case AlignmentModes.algPolar: case AlignmentModes.algGermanPolar: - _sharedResourcesWrapper.SendBlind("#:AP#"); + _sharedResourcesWrapper.SendBlind(":AP#"); //:AP# Sets telescope to Polar alignment mode //Returns: nothing break; @@ -873,7 +873,7 @@ namespace ASCOM.Meade.net return altAz.Altitude; //firmware bug in 44Eg, :GA# is returning the dec, not the altitude! - //var result = _sharedResourcesWrapper.SendString("#:GA#"); + //var result = _sharedResourcesWrapper.SendString(":GA#"); ////:GA# Get Telescope Altitude ////Returns: sDD* MM# or sDD*MM’SS# ////The current scope altitude. The returned format depending on the current precision setting. @@ -963,7 +963,7 @@ namespace ASCOM.Meade.net { CheckConnected("Azimuth Get"); - //var result = _sharedResourcesWrapper.SendString("#:GZ#"); + //var result = _sharedResourcesWrapper.SendString(":GZ#"); //:GZ# Get telescope azimuth //Returns: DDD*MM#T or DDD*MM’SS# //The current telescope Azimuth depending on the selected precision. @@ -1145,7 +1145,7 @@ namespace ASCOM.Meade.net { CheckConnected("Declination Get"); - var result = _sharedResourcesWrapper.SendString("#:GD#"); + var result = _sharedResourcesWrapper.SendString(":GD#"); //:GD# Get Telescope Declination. //Returns: sDD*MM# or sDD*MM’SS# //Depending upon the current precision setting for the telescope. @@ -1233,7 +1233,7 @@ namespace ASCOM.Meade.net } LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString(CultureInfo.CurrentCulture)} arc seconds/second ({value.ToString(CultureInfo.CurrentCulture)} degrees/second)"); - _sharedResourcesWrapper.SendBlind($"#:Rg{value:00.0}#"); + _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 @@ -1314,22 +1314,22 @@ namespace ASCOM.Meade.net //do nothing, it's ok this time as we're halting the slew. break; case 1: - _sharedResourcesWrapper.SendBlind("#:RG#"); + _sharedResourcesWrapper.SendBlind(":RG#"); //:RG# Set Slew rate to Guiding Rate (slowest) //Returns: Nothing break; case 2: - _sharedResourcesWrapper.SendBlind("#:RC#"); + _sharedResourcesWrapper.SendBlind(":RC#"); //:RC# Set Slew rate to Centering rate (2nd slowest) //Returns: Nothing break; case 3: - _sharedResourcesWrapper.SendBlind("#:RM#"); + _sharedResourcesWrapper.SendBlind(":RM#"); //:RM# Set Slew rate to Find Rate (2nd Fastest) //Returns: Nothing break; case 4: - _sharedResourcesWrapper.SendBlind("#:RS#"); + _sharedResourcesWrapper.SendBlind(":RS#"); //:RS# Set Slew rate to max (fastest) //Returns: Nothing break; @@ -1344,22 +1344,22 @@ namespace ASCOM.Meade.net { case ComparisonResult.Equals: _movingPrimary = false; - _sharedResourcesWrapper.SendBlind("#:Qe#"); + _sharedResourcesWrapper.SendBlind(":Qe#"); //:Qe# Halt eastward Slews //Returns: Nothing - _sharedResourcesWrapper.SendBlind("#:Qw#"); + _sharedResourcesWrapper.SendBlind(":Qw#"); //:Qw# Halt westward Slews //Returns: Nothing break; case ComparisonResult.Greater: - _sharedResourcesWrapper.SendBlind("#:Me#"); + _sharedResourcesWrapper.SendBlind(":Me#"); //:Me# Move Telescope East at current slew rate //Returns: Nothing _movingPrimary = true; break; case ComparisonResult.Lower: - _sharedResourcesWrapper.SendBlind("#:Mw#"); + _sharedResourcesWrapper.SendBlind(":Mw#"); //:Mw# Move Telescope West at current slew rate //Returns: Nothing _movingPrimary = true; @@ -1371,21 +1371,21 @@ namespace ASCOM.Meade.net { case ComparisonResult.Equals: _movingSecondary = false; - _sharedResourcesWrapper.SendBlind("#:Qn#"); + _sharedResourcesWrapper.SendBlind(":Qn#"); //:Qn# Halt northward Slews //Returns: Nothing - _sharedResourcesWrapper.SendBlind("#:Qs#"); + _sharedResourcesWrapper.SendBlind(":Qs#"); //:Qs# Halt southward Slews //Returns: Nothing break; case ComparisonResult.Greater: - _sharedResourcesWrapper.SendBlind("#:Mn#"); + _sharedResourcesWrapper.SendBlind(":Mn#"); //:Mn# Move Telescope North at current slew rate //Returns: Nothing _movingSecondary = true; break; case ComparisonResult.Lower: - _sharedResourcesWrapper.SendBlind("#:Ms#"); + _sharedResourcesWrapper.SendBlind(":Ms#"); //:Ms# Move Telescope South at current slew rate //Returns: Nothing _movingSecondary = true; @@ -1407,7 +1407,7 @@ namespace ASCOM.Meade.net if (AtPark) return; - _sharedResourcesWrapper.SendBlind("#:hP#"); + _sharedResourcesWrapper.SendBlind(":hP#"); //:hP# Autostar, Autostar II and LX 16”Slew to Park Position //Returns: Nothing AtPark = true; @@ -1457,7 +1457,7 @@ namespace ASCOM.Meade.net } LogMessage("PulseGuide", "Using new pulse guiding technique"); - _sharedResourcesWrapper.SendBlind($"#:Mg{d}{duration:0000}#"); + _sharedResourcesWrapper.SendBlind($":Mg{d}{duration:0000}#"); //:MgnDDDD# //:MgsDDDD# //:MgeDDDD# @@ -1522,7 +1522,7 @@ namespace ASCOM.Meade.net get { CheckConnected("RightAscension Get"); - var result = _sharedResourcesWrapper.SendString("#:GR#"); + var result = _sharedResourcesWrapper.SendString(":GR#"); //:GR# Get Telescope RA //Returns: HH:MM.T# or HH:MM:SS# //Depending which precision is set for the telescope @@ -1618,7 +1618,7 @@ namespace ASCOM.Meade.net { CheckConnected("SiteLatitude Get"); - var latitude = _sharedResourcesWrapper.SendString("#:Gt#"); + var latitude = _sharedResourcesWrapper.SendString(":Gt#"); //:Gt# Get Current Site Latitude //Returns: sDD* MM# //The latitude of the current site. Positive inplies North latitude. @@ -1644,7 +1644,7 @@ namespace ASCOM.Meade.net var absValue = Math.Abs(value); int d = Convert.ToInt32(Math.Floor(absValue)); int m = Convert.ToInt32(60 * (absValue - d)); - var commandString = $"#:St{sign}{d:00}*{m:00}#"; + var commandString = $":St{sign}{d:00}*{m:00}#"; var result = _sharedResourcesWrapper.SendChar(commandString); //:StsDD*MM# @@ -1663,7 +1663,7 @@ namespace ASCOM.Meade.net { CheckConnected("SiteLongitude Get"); - var longitude = _sharedResourcesWrapper.SendString("#:Gg#"); + var longitude = _sharedResourcesWrapper.SendString(":Gg#"); //:Gg# Get Current Site Longitude //Returns: sDDD*MM# //The current site Longitude. East Longitudes are expressed as negative @@ -1699,7 +1699,7 @@ namespace ASCOM.Meade.net int d = Convert.ToInt32(Math.Floor(newLongitude)); int m = Convert.ToInt32(60 * (newLongitude - d)); - var commandstring = $"#:Sg{d:000}*{m:00}#"; + var commandstring = $":Sg{d:000}*{m:00}#"; var result = _sharedResourcesWrapper.SendChar(commandstring); //:SgDDD*MM# @@ -1789,7 +1789,7 @@ namespace ASCOM.Meade.net switch (polar) { case true: - var response = _sharedResourcesWrapper.SendChar("#:MS#"); + var response = _sharedResourcesWrapper.SendChar(":MS#"); //:MS# Slew to Target Object //Returns: //0 Slew is Possible @@ -1825,7 +1825,7 @@ namespace ASCOM.Meade.net break; case false: - var maResponse = _sharedResourcesWrapper.SendChar("#:MA#"); + var maResponse = _sharedResourcesWrapper.SendChar(":MA#"); //:MA# Autostar, LX 16”, Autostar II – Slew to target Alt and Az //Returns: //0 - No fault @@ -1925,7 +1925,7 @@ namespace ASCOM.Meade.net if (_isGuiding) return false; - var result = _sharedResourcesWrapper.SendString("#:D#"); + var result = _sharedResourcesWrapper.SendString(":D#"); //:D# Requests a string of bars indicating the distance to the current target location. //Returns: //LX200's – a string of bar characters indicating the distance. @@ -1967,7 +1967,7 @@ namespace ASCOM.Meade.net LogMessage("SyncToTarget", "Executing"); CheckConnected("SyncToTarget"); - var result = _sharedResourcesWrapper.SendString("#:CM#"); + var result = _sharedResourcesWrapper.SendString(":CM#"); //:CM# Synchronizes the telescope's position with the currently selected database object's coordinates. //Returns: //LX200's - a "#" terminated string with the name of the object that was synced. @@ -1985,7 +1985,7 @@ namespace ASCOM.Meade.net if (_targetDeclination.Equals(InvalidParameter)) throw new InvalidOperationException("Target not set"); - //var result = SerialPort.CommandTerminated("#:Gd#", "#"); + //var result = SerialPort.CommandTerminated(":Gd#", "#"); ////:Gd# Get Currently Selected Object/Target Declination ////Returns: sDD* MM# or sDD*MM’SS# ////Depending upon the current precision setting for the telescope. @@ -2013,7 +2013,7 @@ namespace ASCOM.Meade.net var dms = _utilities.DegreesToDMS(value, "*", ":", ":", 2); var s = value < 0 ? string.Empty : "+"; - var command = $"#:Sd{s}{dms}#"; + var command = $":Sd{s}{dms}#"; LogMessage("TargetDeclination Set", $"{command}"); var result = _sharedResourcesWrapper.SendChar(command); @@ -2040,7 +2040,7 @@ namespace ASCOM.Meade.net if (_targetRightAscension.Equals(InvalidParameter)) throw new InvalidOperationException("Target not set"); - //var result = SerialPort.CommandTerminated("#:Gr#", "#"); + //var result = SerialPort.CommandTerminated(":Gr#", "#"); ////:Gr# Get current/target object RA ////Returns: HH: MM.T# or HH:MM:SS ////Depending upon which precision is set for the telescope @@ -2064,7 +2064,7 @@ namespace ASCOM.Meade.net //todo implement the low precision version var hms = _utilities.HoursToHMS(value, ":", ":", ":", 2); - var response = _sharedResourcesWrapper.SendChar($"#:Sr{hms}#"); + var response = _sharedResourcesWrapper.SendChar($":Sr{hms}#"); //:SrHH:MM.T# //:SrHH:MM:SS# //Set target object RA to HH:MM.T or HH: MM: SS depending on the current precision setting. @@ -2103,7 +2103,7 @@ namespace ASCOM.Meade.net get { //todo implement this with the GW command - //var result = SerialPort.CommandTerminated("#:GT#", "#"); + //var result = SerialPort.CommandTerminated(":GT#", "#"); //double rate = double.Parse(result); @@ -2125,17 +2125,17 @@ namespace ASCOM.Meade.net switch (value) { case DriveRates.driveSidereal: - _sharedResourcesWrapper.SendBlind("#:TQ#"); + _sharedResourcesWrapper.SendBlind(":TQ#"); //:TQ# Selects sidereal tracking rate //Returns: Nothing break; case DriveRates.driveLunar: - _sharedResourcesWrapper.SendBlind("#:TL#"); + _sharedResourcesWrapper.SendBlind(":TL#"); //:TL# Set Lunar Tracking Rage //Returns: Nothing break; //case DriveRates.driveSolar: - // SerialPort.Command("#:TS#"); + // SerialPort.Command(":TS#"); // //:TS# Select Solar tracking rate. [LS Only] // //Returns: Nothing // break; @@ -2167,7 +2167,7 @@ namespace ASCOM.Meade.net private TimeSpan GetUtcCorrection() { - string utcOffSet = _sharedResourcesWrapper.SendString("#:GG#"); + string utcOffSet = _sharedResourcesWrapper.SendString(":GG#"); //:GG# Get UTC offset time //Returns: sHH# or sHH.H# //The number of decimal hours to add to local time to convert it to UTC. If the number is a whole number the @@ -2196,11 +2196,11 @@ namespace ASCOM.Meade.net { var tdd = new TelescopeDateDetails { - TelescopeDate = _sharedResourcesWrapper.SendString("#:GC#"), + TelescopeDate = _sharedResourcesWrapper.SendString(":GC#"), //:GC# Get current date. //Returns: MM/DD/YY# //The current local calendar date for the telescope. - TelescopeTime = _sharedResourcesWrapper.SendString("#:GL#"), + TelescopeTime = _sharedResourcesWrapper.SendString(":GL#"), //:GL# Get Local Time in 24 hour format //Returns: HH:MM:SS# //The Local Time in 24 - hour Format @@ -2241,7 +2241,7 @@ namespace ASCOM.Meade.net var utcCorrection = GetUtcCorrection(); var localDateTime = value - utcCorrection; - string localStingCommand = $"#:SL{localDateTime:HH:mm:ss}#"; + string localStingCommand = $":SL{localDateTime:HH:mm:ss}#"; var timeResult = _sharedResourcesWrapper.SendChar(localStingCommand); //:SLHH:MM:SS# //Set the local Time @@ -2253,7 +2253,7 @@ namespace ASCOM.Meade.net throw new InvalidOperationException("Failed to set local time"); } - string localDateCommand = $"#:SC{localDateTime:MM/dd/yy}#"; + string localDateCommand = $":SC{localDateTime:MM/dd/yy}#"; var dateResult = _sharedResourcesWrapper.SendChar(localDateCommand); //:SCMM/DD/YY# //Change Handbox Date to MM/DD/YY diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index 31c2a78..e02b527 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -50,6 +50,8 @@ namespace ASCOM.Meade.net private static bool _reverseFocusDirection; + private static bool _useDynamicBreaking; + /// /// Private variable to hold an ASCOM Utilities object /// @@ -372,19 +374,27 @@ namespace ASCOM.Meade.net _tl.LogMessage("Move", "Applying backlash compensation"); MoveFocuser(!direction, backlashCompensationSteps); } - - //This gives the focuser time to physically stop. Not sure if this is really needed. - //_utilities.WaitForMilliseconds(1000); - + DynamicBreaking(direction); //todo implement dynamic braking //dynamic breaking is sending the command to move in the opposite direction immediatly followed by the command to stop. }); } + private void DynamicBreaking(bool directionOut) + { + if (!_useDynamicBreaking) + return; + + _tl.LogMessage("Move", "Applying dynamic breaking"); + + PerformFocuserMove(directionOut); + Halt(); + } + private void MoveFocuser(bool directionOut, int steps) { - //_sharedResourcesWrapper.SendBlind("#:FF#"); + //_sharedResourcesWrapper.SendBlind(":FF#"); //:FF# Set Focus speed to fastest setting //Returns: Nothing @@ -396,16 +406,21 @@ namespace ASCOM.Meade.net //All others – Not Supported _utilities.WaitForMilliseconds(100); - _sharedResourcesWrapper.SendBlind(directionOut ? "#:F+#" : "#:F-#"); + PerformFocuserMove(directionOut); + + _utilities.WaitForMilliseconds(steps); + + Halt(); + } + + private void PerformFocuserMove(bool directionOut) + { + _sharedResourcesWrapper.SendBlind(directionOut ? ":F+#" : ":F-#"); //:F+# Start Focuser moving inward (toward objective) //Returns: None //:F-# Start Focuser moving outward (away from objective) //Returns: None - - _utilities.WaitForMilliseconds(steps); - - Halt(); } public int Position => throw new PropertyNotImplementedException("Position", false); @@ -566,10 +581,12 @@ namespace ASCOM.Meade.net _comPort = profileProperties.ComPort; _backlashCompensation = profileProperties.BacklashCompensation; _reverseFocusDirection = profileProperties.ReverseFocusDirection; + _useDynamicBreaking = profileProperties.DynamicBreaking; LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}"); LogMessage("ReadProfile", $"Com Port: {_comPort}"); LogMessage("ReadProfile", $"Backlash Steps: {_backlashCompensation}"); + LogMessage("ReadProfile", $"Dynamic breaking: {_useDynamicBreaking}"); } /// diff --git a/Meade.net.v3.ncrunchsolution.user b/Meade.net.v3.ncrunchsolution.user index cd10274..9b1f351 100644 --- a/Meade.net.v3.ncrunchsolution.user +++ b/Meade.net.v3.ncrunchsolution.user @@ -3,7 +3,7 @@ True Run all tests automatically [Global] False - 25 + 80 false false diff --git a/Meade.net/ProfileProperties.cs b/Meade.net/ProfileProperties.cs index 91ec357..fe57a13 100644 --- a/Meade.net/ProfileProperties.cs +++ b/Meade.net/ProfileProperties.cs @@ -10,5 +10,6 @@ namespace ASCOM.Meade.net public string GuidingStyle { get; set; } public int BacklashCompensation { get; set; } public bool ReverseFocusDirection { get; set; } + public bool DynamicBreaking { get; set; } } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index 3e46acd..fa705c2 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -84,6 +84,7 @@ namespace ASCOM.Meade.net txtBacklashSteps.Text = profileProperties.BacklashCompensation.ToString(CultureInfo.CurrentCulture); cbxReverseDirection.Checked = profileProperties.ReverseFocusDirection; + cbxDynamicBreaking.Checked = profileProperties.DynamicBreaking; } public ProfileProperties GetProfile() @@ -96,8 +97,9 @@ namespace ASCOM.Meade.net Precision = cboPrecision.SelectedItem.ToString(), GuidingStyle = cboGuidingStyle.SelectedItem.ToString(), BacklashCompensation = int.Parse(txtBacklashSteps.Text), - ReverseFocusDirection = cbxReverseDirection.Checked - }; + ReverseFocusDirection = cbxReverseDirection.Checked, + DynamicBreaking = cbxDynamicBreaking.Checked + }; return profileProperties; } diff --git a/Meade.net/SetupDialogForm.designer.cs b/Meade.net/SetupDialogForm.designer.cs index fec612a..b4c618a 100644 --- a/Meade.net/SetupDialogForm.designer.cs +++ b/Meade.net/SetupDialogForm.designer.cs @@ -54,6 +54,7 @@ namespace ASCOM.Meade.net this.label10 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label(); this.cbxReverseDirection = new System.Windows.Forms.CheckBox(); + this.cbxDynamicBreaking = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit(); this.SuspendLayout(); // @@ -194,10 +195,17 @@ namespace ASCOM.Meade.net this.cbxReverseDirection.Name = "cbxReverseDirection"; this.cbxReverseDirection.UseVisualStyleBackColor = true; // + // cbxDynamicBreaking + // + resources.ApplyResources(this.cbxDynamicBreaking, "cbxDynamicBreaking"); + this.cbxDynamicBreaking.Name = "cbxDynamicBreaking"; + this.cbxDynamicBreaking.UseVisualStyleBackColor = true; + // // SetupDialogForm // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.cbxDynamicBreaking); this.Controls.Add(this.cbxReverseDirection); this.Controls.Add(this.label11); this.Controls.Add(this.label10); @@ -257,5 +265,6 @@ namespace ASCOM.Meade.net private Label label10; private Label label11; private CheckBox cbxReverseDirection; + private CheckBox cbxDynamicBreaking; } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.resx b/Meade.net/SetupDialogForm.resx index 6618668..3366ceb 100644 --- a/Meade.net/SetupDialogForm.resx +++ b/Meade.net/SetupDialogForm.resx @@ -123,7 +123,7 @@ - 281, 387 + 281, 413 59, 24 @@ -145,13 +145,13 @@ $this - 21 + 22 Bottom, Right - 281, 417 + 281, 443 59, 25 @@ -172,7 +172,7 @@ $this - 20 + 21 12, 9 @@ -196,7 +196,7 @@ $this - 19 + 20 Top, Right @@ -223,7 +223,7 @@ $this - 18 + 19 True @@ -250,7 +250,7 @@ $this - 17 + 18 True @@ -277,7 +277,7 @@ $this - 16 + 17 97, 87 @@ -298,7 +298,7 @@ $this - 15 + 16 True @@ -325,7 +325,7 @@ $this - 14 + 15 97, 199 @@ -349,7 +349,7 @@ $this - 13 + 14 True @@ -376,7 +376,7 @@ $this - 12 + 13 True @@ -403,7 +403,7 @@ $this - 11 + 12 True @@ -430,7 +430,7 @@ $this - 10 + 11 Unchanged @@ -460,7 +460,7 @@ $this - 9 + 10 True @@ -490,7 +490,7 @@ $this - 8 + 9 Auto @@ -520,7 +520,7 @@ $this - 7 + 8 True @@ -550,7 +550,7 @@ $this - 6 + 7 True @@ -583,7 +583,7 @@ $this - 5 + 6 97, 335 @@ -607,7 +607,7 @@ $this - 3 + 4 True @@ -637,7 +637,7 @@ $this - 4 + 5 True @@ -667,7 +667,7 @@ $this - 2 + 3 True @@ -700,7 +700,7 @@ $this - 1 + 2 True @@ -727,6 +727,33 @@ $this + 1 + + + True + + + 97, 384 + + + 112, 17 + + + 23 + + + Dynamic Breaking + + + cbxDynamicBreaking + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 @@ -736,7 +763,7 @@ 6, 13 - 350, 450 + 350, 476 CenterScreen diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index e7e89a8..33724fd 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -143,6 +143,7 @@ namespace ASCOM.Meade.net private const string GuidingStyleProfileName = "Guiding Style"; private const string BacklashCompensationName = "Backlash Compensation"; private const string ReverseFocusDirectionName = "Reverse Focuser Direction"; + private const string DynamicBreakingName = "Dynamic Breaking"; public static void WriteProfile(ProfileProperties profileProperties) { @@ -158,6 +159,7 @@ namespace ASCOM.Meade.net driverProfile.WriteValue(DriverId, GuidingStyleProfileName, profileProperties.GuidingStyle); driverProfile.WriteValue(DriverId, BacklashCompensationName, profileProperties.BacklashCompensation.ToString()); driverProfile.WriteValue(DriverId, ReverseFocusDirectionName, profileProperties.ReverseFocusDirection.ToString()); + driverProfile.WriteValue(DriverId, DynamicBreakingName, profileProperties.DynamicBreaking.ToString()); } } } @@ -169,6 +171,7 @@ namespace ASCOM.Meade.net private const string GuidingStyleDefault = "Auto"; private const string BacklashCompensationDefault = "3000"; private const string ReverseFocuserDiectionDefault = "true"; + private const string DynamicBreakingDefault = "true"; public static ProfileProperties ReadProfile() { @@ -185,6 +188,7 @@ namespace ASCOM.Meade.net profileProperties.GuidingStyle = driverProfile.GetValue(DriverId, GuidingStyleProfileName, string.Empty, GuidingStyleDefault); profileProperties.BacklashCompensation = Convert.ToInt32(driverProfile.GetValue(DriverId, BacklashCompensationName, string.Empty, BacklashCompensationDefault)); profileProperties.ReverseFocusDirection = Convert.ToBoolean(driverProfile.GetValue(DriverId, ReverseFocusDirectionName, string.Empty, ReverseFocuserDiectionDefault)); + profileProperties.DynamicBreaking = Convert.ToBoolean(driverProfile.GetValue(DriverId, DynamicBreakingName, string.Empty, DynamicBreakingDefault)); } return profileProperties; From da4e4fd81a614f20630c3a33ac76ac0111a2950e Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 19:05:01 +0100 Subject: [PATCH 20/55] Refactored code to reduce duplication. --- .../FocuserUnitTests.cs | 3 +- Meade.net.Telescope/Telescope.cs | 107 +-------------- Meade.net.focuser/Focuser.cs | 114 +--------------- Meade.net/Meade.net.csproj | 1 + Meade.net/MeadeTelescopeBase.cs | 127 ++++++++++++++++++ 5 files changed, 141 insertions(+), 211 deletions(-) create mode 100644 Meade.net/MeadeTelescopeBase.cs diff --git a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs index 1056378..2ba4e76 100644 --- a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs +++ b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs @@ -28,7 +28,8 @@ namespace Meade.net.Focuser.UnitTests TraceLogger = false, ComPort = "TestCom1", GuideRateArcSecondsPerSecond = 1.23, - Precision = "Unchanged" + Precision = "Unchanged", + GuidingStyle = "Auto" }; _utilMock = new Mock(); diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 3d79ae1..a0ccfe8 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -38,7 +38,7 @@ namespace ASCOM.Meade.net [ServedClassName("Meade Generic")] [ClassInterface(ClassInterfaceType.None)] [ComVisible(true)] - public class Telescope : ReferenceCountedObjectBase, ITelescopeV3 + public class Telescope : MeadeTelescopeBase, ITelescopeV3 { /// /// ASCOM DeviceID (COM ProgID) for this driver. @@ -47,13 +47,6 @@ namespace ASCOM.Meade.net //internal static string driverID = "ASCOM.Meade.net.Telescope"; private static readonly string DriverId = Marshal.GenerateProgIdForType(MethodBase.GetCurrentMethod().DeclaringType ?? throw new System.InvalidOperationException()); - /// - /// Driver description that displays in the ASCOM Chooser. - /// - private static readonly string DriverDescription = "Meade Generic"; - - private static string _comPort; // Variables to hold the currrent device configuration - /// /// Private variable to hold an ASCOM Utilities object /// @@ -66,19 +59,12 @@ namespace ASCOM.Meade.net private readonly IAstroUtils _astroUtilities; private readonly IAstroMaths _astroMaths; - - /// - /// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify) - /// - private TraceLogger _tl; - - private readonly ISharedResourcesWrapper _sharedResourcesWrapper; - + /// /// Initializes a new instance of the class. /// Must be public for COM registration. /// - public Telescope() + public Telescope() : base() { try { @@ -87,7 +73,6 @@ namespace ASCOM.Meade.net _utilities = util; _utilitiesExtra = util; //Initialise util object _astroUtilities = new AstroUtils(); // Initialise astro utilities object - _sharedResourcesWrapper = new SharedResourcesWrapper(); _astroMaths = new AstroMaths.AstroMaths(); Initialise(); @@ -121,33 +106,17 @@ namespace ASCOM.Meade.net sb.AppendLine(); } - public Telescope( IUtil util, IUtilExtra utilExtra, IAstroUtils astroUtilities, ISharedResourcesWrapper sharedResourcesWrapper, IAstroMaths astroMaths) + public Telescope( IUtil util, IUtilExtra utilExtra, IAstroUtils astroUtilities, ISharedResourcesWrapper sharedResourcesWrapper, IAstroMaths astroMaths) : base(sharedResourcesWrapper) { _utilities = util; //Initialise util object _utilitiesExtra = utilExtra; //Initialise util object _astroUtilities = astroUtilities; // Initialise astro utilities object - _sharedResourcesWrapper = sharedResourcesWrapper; _astroMaths = astroMaths; Initialise(); } - private double _guideRate; private bool _isGuiding; - - private void Initialise() - { - //todo move the TraceLogger out to a factory class. - _tl = new TraceLogger("", "Meade.Generic.Telescope"); - ReadProfile(); // Read device configuration from the ASCOM Profile store - - IsConnected = false; // Initialise connected to false - - LogMessage("Telescope", "Completed initialisation"); - LogMessage("Telescope", $"Driver version: {DriverVersion}"); - } - - // // PUBLIC COM INTERFACE ITelescopeV3 IMPLEMENTATION // @@ -704,36 +673,6 @@ namespace ASCOM.Meade.net } } - public string Description - { - get - { - LogMessage("Description Get", DriverDescription); - return DriverDescription; - } - } - - public string DriverInfo - { - get - { - string driverInfo = $"{Description} .net driver. Version: {DriverVersion}"; - LogMessage("DriverInfo Get", driverInfo); - return driverInfo; - } - } - - public string DriverVersion - { - get - { - Version version = Assembly.GetExecutingAssembly().GetName().Version; - string driverVersion = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; - LogMessage("DriverVersion Get", driverVersion); - return driverVersion; - } - } - public short InterfaceVersion { // set by the driver wizard @@ -2095,8 +2034,6 @@ namespace ASCOM.Meade.net } private DriveRates _trackingRate = DriveRates.driveSidereal; - private string _precision; - private string _guidingStyle; public DriveRates TrackingRate { @@ -2367,11 +2304,6 @@ namespace ASCOM.Meade.net #endregion - /// - /// Returns true if there is a valid connection to the driver hardware - /// - private bool IsConnected { get; set; } - /// /// Use this function to throw an exception if we aren't connected to the hardware /// @@ -2384,25 +2316,6 @@ namespace ASCOM.Meade.net } } - /// - /// Read the device configuration from the ASCOM Profile store - /// - private void ReadProfile() - { - ProfileProperties profileProperties = _sharedResourcesWrapper.ReadProfile(); - _tl.Enabled = profileProperties.TraceLogger; - _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() { var profileProperties = new ProfileProperties @@ -2414,18 +2327,6 @@ namespace ASCOM.Meade.net _sharedResourcesWrapper.WriteProfile(profileProperties); } - - /// - /// Log helper function that takes formatted strings and arguments - /// - /// - /// - /// - private void LogMessage(string identifier, string message, params object[] args) - { - var msg = string.Format(message, args); - _tl.LogMessage(identifier, msg); - } #endregion } } diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index e02b527..5e9f23e 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -30,7 +30,7 @@ namespace ASCOM.Meade.net [ServedClassName("Meade Generic")] [ClassInterface(ClassInterfaceType.None)] [ComVisible(true)] - public class Focuser : ReferenceCountedObjectBase, IFocuserV3 + public class Focuser : MeadeTelescopeBase, IFocuserV3 { /// /// ASCOM DeviceID (COM ProgID) for this driver. @@ -38,68 +38,32 @@ namespace ASCOM.Meade.net /// //internal static string driverID = "ASCOM.Meade.net.Focuser"; private static readonly string DriverId = Marshal.GenerateProgIdForType(MethodBase.GetCurrentMethod().DeclaringType ?? throw new System.InvalidOperationException()); - // TODO Change the descriptive string for your driver then remove this line - /// - /// Driver description that displays in the ASCOM Chooser. - /// - private static readonly string DriverDescription = "Meade Generic"; - - private static string _comPort; // Variables to hold the currrent device configuration - - private static int _backlashCompensation; - - private static bool _reverseFocusDirection; - - private static bool _useDynamicBreaking; /// /// Private variable to hold an ASCOM Utilities object /// private readonly IUtil _utilities; - - /// - /// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify) - /// - private static TraceLogger _tl; - - private readonly ISharedResourcesWrapper _sharedResourcesWrapper; - + /// /// Initializes a new instance of the class. /// Must be public for COM registration. /// - public Focuser() + public Focuser() : base() { //todo move this out to IOC var util = new Util(); //Initialise util object _utilities = util; - _sharedResourcesWrapper = new SharedResourcesWrapper(); Initialise(); } - public Focuser(IUtil util, ISharedResourcesWrapper sharedResourcesWrapper) + public Focuser(IUtil util, ISharedResourcesWrapper sharedResourcesWrapper) : base(sharedResourcesWrapper) { _utilities = util; - _sharedResourcesWrapper = sharedResourcesWrapper; Initialise(); } - - private void Initialise() - { - //todo move the TraceLogger out to a factory class. - _tl = new TraceLogger("", "Meade.Generic.focusser"); - - ReadProfile(); // Read device configuration from the ASCOM Profile store - - IsConnected = false; // Initialise connected to false - - LogMessage("Focuser", "Completed initialisation"); - LogMessage("Focuser", $"Driver version: {DriverVersion}"); - } - - + // // PUBLIC COM INTERFACE IFocuserV3 IMPLEMENTATION // @@ -217,36 +181,6 @@ namespace ASCOM.Meade.net } } - public string Description - { - get - { - _tl.LogMessage("Description Get", DriverDescription); - return DriverDescription; - } - } - - public string DriverInfo - { - get - { - string driverInfo = $"{Description} .net driver. Version: {DriverVersion}"; - LogMessage("DriverInfo Get", driverInfo); - return driverInfo; - } - } - - public string DriverVersion - { - get - { - Version version = Assembly.GetExecutingAssembly().GetName().Version; - string driverVersion = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; - LogMessage("DriverVersion Get", driverVersion); - return driverVersion; - } - } - public short InterfaceVersion { // set by the driver wizard @@ -476,6 +410,7 @@ namespace ASCOM.Meade.net #region ASCOM Registration private static IProfileFactory _profileFactory; + public static IProfileFactory ProfileFactory { get => _profileFactory ?? (_profileFactory = new ProfileFactory()); @@ -553,12 +488,7 @@ namespace ASCOM.Meade.net } #endregion - - /// - /// Returns true if there is a valid connection to the driver hardware - /// - private bool IsConnected { get; set; } - + /// /// Use this function to throw an exception if we aren't connected to the hardware /// @@ -570,36 +500,6 @@ namespace ASCOM.Meade.net throw new NotConnectedException($"Not connected to focuser when trying to execute: {message}"); } } - - /// - /// Read the device configuration from the ASCOM Profile store - /// - private void ReadProfile() - { - var profileProperties = _sharedResourcesWrapper.ReadProfile(); - _tl.Enabled = profileProperties.TraceLogger; - _comPort = profileProperties.ComPort; - _backlashCompensation = profileProperties.BacklashCompensation; - _reverseFocusDirection = profileProperties.ReverseFocusDirection; - _useDynamicBreaking = profileProperties.DynamicBreaking; - - LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}"); - LogMessage("ReadProfile", $"Com Port: {_comPort}"); - LogMessage("ReadProfile", $"Backlash Steps: {_backlashCompensation}"); - LogMessage("ReadProfile", $"Dynamic breaking: {_useDynamicBreaking}"); - } - - /// - /// Log helper function that takes formatted strings and arguments - /// - /// - /// - /// - private static void LogMessage(string identifier, string message, params object[] args) - { - var msg = string.Format(message, args); - _tl.LogMessage(identifier, msg); - } #endregion } } diff --git a/Meade.net/Meade.net.csproj b/Meade.net/Meade.net.csproj index 18ea8c1..f3a6c03 100644 --- a/Meade.net/Meade.net.csproj +++ b/Meade.net/Meade.net.csproj @@ -134,6 +134,7 @@ + diff --git a/Meade.net/MeadeTelescopeBase.cs b/Meade.net/MeadeTelescopeBase.cs new file mode 100644 index 0000000..43b0b59 --- /dev/null +++ b/Meade.net/MeadeTelescopeBase.cs @@ -0,0 +1,127 @@ +using System; +using System.Reflection; +using System.Runtime.InteropServices; +using ASCOM.Meade.net.Wrapper; +using ASCOM.Utilities; + +namespace ASCOM.Meade.net +{ + [ComVisible(false)] + public class MeadeTelescopeBase : ReferenceCountedObjectBase + { + /// + /// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify) + /// + protected static TraceLogger _tl; + + /// + /// Driver description that displays in the ASCOM Chooser. + /// + protected static readonly string DriverDescription = "Meade Generic"; + + protected static string _comPort; // Variables to hold the currrent device configuration + protected static int _backlashCompensation; + protected static bool _reverseFocusDirection; + protected static bool _useDynamicBreaking; + protected double _guideRate; + protected string _precision; + protected string _guidingStyle; + + protected readonly ISharedResourcesWrapper _sharedResourcesWrapper; + + public MeadeTelescopeBase() + { + _sharedResourcesWrapper = new SharedResourcesWrapper(); + } + + public MeadeTelescopeBase(ISharedResourcesWrapper sharedResourcesWrapper) + { + _sharedResourcesWrapper = sharedResourcesWrapper; + } + + protected void Initialise() + { + var typeName = GetType().Name; + + _tl = new TraceLogger("", $"Meade.Generic.{typeName}"); + + ReadProfile(); // Read device configuration from the ASCOM Profile store + + IsConnected = false; // Initialise connected to false + + LogMessage(typeName, "Completed initialisation"); + LogMessage(typeName, $"Driver version: {DriverVersion}"); + } + + /// + /// Read the device configuration from the ASCOM Profile store + /// + protected void ReadProfile() + { + var profileProperties = _sharedResourcesWrapper.ReadProfile(); + _tl.Enabled = profileProperties.TraceLogger; + _comPort = profileProperties.ComPort; + _backlashCompensation = profileProperties.BacklashCompensation; + _reverseFocusDirection = profileProperties.ReverseFocusDirection; + _useDynamicBreaking = profileProperties.DynamicBreaking; + _guideRate = profileProperties.GuideRateArcSecondsPerSecond; + _precision = profileProperties.Precision; + _guidingStyle = profileProperties.GuidingStyle.ToLower(); + + LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}"); + LogMessage("ReadProfile", $"Com Port: {_comPort}"); + LogMessage("ReadProfile", $"Backlash Steps: {_backlashCompensation}"); + LogMessage("ReadProfile", $"Dynamic breaking: {_useDynamicBreaking}"); + LogMessage("ReadProfile", $"Guide Rate: {_guideRate}"); + LogMessage("ReadProfile", $"Precision: {_precision}"); + LogMessage("ReadProfile", $"Guiding Style: {_guidingStyle}"); + } + + /// + /// Log helper function that takes formatted strings and arguments + /// + /// + /// + /// + public static void LogMessage(string identifier, string message, params object[] args) + { + var msg = String.Format(message, args); + _tl.LogMessage(identifier, msg); + } + + /// + /// Returns true if there is a valid connection to the driver hardware + /// + protected bool IsConnected { get; set; } + + public string Description + { + get + { + _tl.LogMessage("Description Get", DriverDescription); + return DriverDescription; + } + } + + public string DriverInfo + { + get + { + string driverInfo = $"{Description} .net driver. Version: {DriverVersion}"; + LogMessage("DriverInfo Get", driverInfo); + return driverInfo; + } + } + + public string DriverVersion + { + get + { + Version version = Assembly.GetExecutingAssembly().GetName().Version; + string driverVersion = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; + LogMessage("DriverVersion Get", driverVersion); + return driverVersion; + } + } + } +} \ No newline at end of file From a2fcaac2a90a8f1640a7c51fe7dc235d3a845f94 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 20:28:32 +0100 Subject: [PATCH 21/55] Code inspections --- Meade.net.Telescope/Telescope.cs | 30 ++++++++++++------------ Meade.net.focuser/Focuser.cs | 12 +++++----- Meade.net/MeadeTelescopeBase.cs | 40 ++++++++++++++++---------------- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index a0ccfe8..6feade6 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -64,7 +64,7 @@ namespace ASCOM.Meade.net /// Initializes a new instance of the class. /// Must be public for COM registration. /// - public Telescope() : base() + public Telescope() { try { @@ -373,11 +373,11 @@ namespace ASCOM.Meade.net { ReadProfile(); - LogMessage("Connected Set", "Connecting to port {0}", _comPort); + LogMessage("Connected Set", "Connecting to port {0}", ComPort); var connectionInfo = _sharedResourcesWrapper.Connect("Serial", DriverId, _tl); try { - LogMessage("Connected Set", $"Connected to port {_comPort}. Product: {_sharedResourcesWrapper.ProductName} Version:{_sharedResourcesWrapper.FirmwareVersion}"); + LogMessage("Connected Set", $"Connected to port {ComPort}. Product: {_sharedResourcesWrapper.ProductName} Version:{_sharedResourcesWrapper.FirmwareVersion}"); _userNewerPulseGuiding = IsNewPulseGuidingSupported(); _targetDeclination = InvalidParameter; @@ -396,7 +396,7 @@ namespace ASCOM.Meade.net if (CanSetGuideRates) { - SetNewGuideRate(_guideRate, "Connect"); + SetNewGuideRate(GuideRate, "Connect"); } SetTelescopePrecision("Connect"); @@ -417,12 +417,12 @@ namespace ASCOM.Meade.net } catch (Exception ex) { - LogMessage("Connected Set", "Error connecting to port {0} - {1}", _comPort, ex.Message); + LogMessage("Connected Set", "Error connecting to port {0} - {1}", ComPort, ex.Message); } } else { - LogMessage("Connected Set", "Disconnecting from port {0}", _comPort); + LogMessage("Connected Set", "Disconnecting from port {0}", ComPort); _sharedResourcesWrapper.Disconnect("Serial", DriverId); IsConnected = false; } @@ -431,7 +431,7 @@ namespace ASCOM.Meade.net private void SetTelescopePrecision(string propertyName) { - switch (_precision.ToLower()) + switch (Precision.ToLower()) { case "high": TelescopePointingPrecision(true); @@ -449,7 +449,7 @@ namespace ASCOM.Meade.net public bool IsNewPulseGuidingSupported() { - switch (_guidingStyle) + switch (GuidingStyle) { case "guide rate slew": return false; @@ -1181,7 +1181,7 @@ namespace ASCOM.Meade.net //info from RickB says that 15.04107 is a better value for - _guideRate = value; + GuideRate = value; WriteProfile(); } @@ -1200,8 +1200,8 @@ namespace ASCOM.Meade.net { get { - var degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_guideRate); - LogMessage("GuideRateDeclination Get", $"{_guideRate} arc seconds / second = {degreesPerSecond} degrees per second"); + var degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(GuideRate); + LogMessage("GuideRateDeclination Get", $"{GuideRate} arc seconds / second = {degreesPerSecond} degrees per second"); return degreesPerSecond; } set @@ -1215,8 +1215,8 @@ namespace ASCOM.Meade.net { get { - double degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_guideRate); - LogMessage("GuideRateRightAscension Get", $"{_guideRate} 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 @@ -2321,8 +2321,8 @@ namespace ASCOM.Meade.net var profileProperties = new ProfileProperties { TraceLogger = _tl.Enabled, - ComPort = _comPort, - GuideRateArcSecondsPerSecond = _guideRate + ComPort = ComPort, + GuideRateArcSecondsPerSecond = GuideRate }; _sharedResourcesWrapper.WriteProfile(profileProperties); diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index 5e9f23e..b797dcd 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -48,7 +48,7 @@ namespace ASCOM.Meade.net /// Initializes a new instance of the class. /// Must be public for COM registration. /// - public Focuser() : base() + public Focuser() { //todo move this out to IOC var util = new Util(); //Initialise util object @@ -169,12 +169,12 @@ namespace ASCOM.Meade.net } catch (Exception ex) { - LogMessage("Connected Set", "Error connecting to port {0} - {1}", _comPort, ex.Message); + LogMessage("Connected Set", "Error connecting to port {0} - {1}", ComPort, ex.Message); } } else { - LogMessage("Connected Set", "Disconnecting from port {0}", _comPort); + LogMessage("Connected Set", "Disconnecting from port {0}", ComPort); _sharedResourcesWrapper.Disconnect("Serial", DriverId); IsConnected = false; } @@ -287,13 +287,13 @@ namespace ASCOM.Meade.net return; var direction = position > 0; - if (_reverseFocusDirection) + if (ReverseFocusDirection) direction = !direction; _sharedResourcesWrapper.Lock(() => { //backlash compensation. - var backlashCompensationSteps = direction ? Math.Abs(_backlashCompensation) : 0; + var backlashCompensationSteps = direction ? Math.Abs(BacklashCompensation) : 0; var steps = Math.Abs(position) + backlashCompensationSteps; @@ -317,7 +317,7 @@ namespace ASCOM.Meade.net private void DynamicBreaking(bool directionOut) { - if (!_useDynamicBreaking) + if (!UseDynamicBreaking) return; _tl.LogMessage("Move", "Applying dynamic breaking"); diff --git a/Meade.net/MeadeTelescopeBase.cs b/Meade.net/MeadeTelescopeBase.cs index 43b0b59..f34ac52 100644 --- a/Meade.net/MeadeTelescopeBase.cs +++ b/Meade.net/MeadeTelescopeBase.cs @@ -19,13 +19,13 @@ namespace ASCOM.Meade.net /// protected static readonly string DriverDescription = "Meade Generic"; - protected static string _comPort; // Variables to hold the currrent device configuration - protected static int _backlashCompensation; - protected static bool _reverseFocusDirection; - protected static bool _useDynamicBreaking; - protected double _guideRate; - protected string _precision; - protected string _guidingStyle; + protected static string ComPort; // Variables to hold the currrent device configuration + protected static int BacklashCompensation; + protected static bool ReverseFocusDirection; + protected static bool UseDynamicBreaking; + protected double GuideRate; + protected string Precision; + protected string GuidingStyle; protected readonly ISharedResourcesWrapper _sharedResourcesWrapper; @@ -60,21 +60,21 @@ namespace ASCOM.Meade.net { var profileProperties = _sharedResourcesWrapper.ReadProfile(); _tl.Enabled = profileProperties.TraceLogger; - _comPort = profileProperties.ComPort; - _backlashCompensation = profileProperties.BacklashCompensation; - _reverseFocusDirection = profileProperties.ReverseFocusDirection; - _useDynamicBreaking = profileProperties.DynamicBreaking; - _guideRate = profileProperties.GuideRateArcSecondsPerSecond; - _precision = profileProperties.Precision; - _guidingStyle = profileProperties.GuidingStyle.ToLower(); + ComPort = profileProperties.ComPort; + BacklashCompensation = profileProperties.BacklashCompensation; + ReverseFocusDirection = profileProperties.ReverseFocusDirection; + UseDynamicBreaking = profileProperties.DynamicBreaking; + GuideRate = profileProperties.GuideRateArcSecondsPerSecond; + Precision = profileProperties.Precision; + GuidingStyle = profileProperties.GuidingStyle.ToLower(); LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}"); - LogMessage("ReadProfile", $"Com Port: {_comPort}"); - LogMessage("ReadProfile", $"Backlash Steps: {_backlashCompensation}"); - LogMessage("ReadProfile", $"Dynamic breaking: {_useDynamicBreaking}"); - LogMessage("ReadProfile", $"Guide Rate: {_guideRate}"); - LogMessage("ReadProfile", $"Precision: {_precision}"); - LogMessage("ReadProfile", $"Guiding Style: {_guidingStyle}"); + LogMessage("ReadProfile", $"Com Port: {ComPort}"); + LogMessage("ReadProfile", $"Backlash Steps: {BacklashCompensation}"); + LogMessage("ReadProfile", $"Dynamic breaking: {UseDynamicBreaking}"); + LogMessage("ReadProfile", $"Guide Rate: {GuideRate}"); + LogMessage("ReadProfile", $"Precision: {Precision}"); + LogMessage("ReadProfile", $"Guiding Style: {GuidingStyle}"); } /// From 92ab807eaed84f4d3adb559537488346e4812ee0 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 20:35:37 +0100 Subject: [PATCH 22/55] Code inspections --- Meade.net.Telescope/Telescope.cs | 198 +++++++++--------- .../SharedResourcesUnitTests.cs | 5 +- Meade.net.focuser/Focuser.cs | 64 +++--- Meade.net/MeadeTelescopeBase.cs | 20 +- 4 files changed, 145 insertions(+), 142 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 6feade6..d3e4bc3 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -132,7 +132,7 @@ namespace ASCOM.Meade.net public void SetupDialog() { LogMessage("SetupDialog", "Opening setup dialog"); - _sharedResourcesWrapper.SetupDialog(); + SharedResourcesWrapper.SetupDialog(); ReadProfile(); LogMessage("SetupDialog", "complete"); //// consider only showing the setup dialog if not connected @@ -171,68 +171,68 @@ namespace ASCOM.Meade.net { //Read the screen case "readdisplay": - var output = _sharedResourcesWrapper.SendString(":ED#"); + var output = SharedResourcesWrapper.SendString(":ED#"); return output; //top row of buttons case "enter": - _sharedResourcesWrapper.SendBlind(":EK13#"); + SharedResourcesWrapper.SendBlind(":EK13#"); break; case "mode": - _sharedResourcesWrapper.SendBlind(":EK9#"); + SharedResourcesWrapper.SendBlind(":EK9#"); break; case "longmode": - _sharedResourcesWrapper.SendBlind(":EK11#"); + SharedResourcesWrapper.SendBlind(":EK11#"); break; case "goto": - _sharedResourcesWrapper.SendBlind(":EK24#"); + SharedResourcesWrapper.SendBlind(":EK24#"); break; case "0": //light and 0 - _sharedResourcesWrapper.SendBlind(":EK48#"); + SharedResourcesWrapper.SendBlind(":EK48#"); break; case "1": - _sharedResourcesWrapper.SendBlind(":EK49#"); + SharedResourcesWrapper.SendBlind(":EK49#"); break; case "2": - _sharedResourcesWrapper.SendBlind(":EK50#"); + SharedResourcesWrapper.SendBlind(":EK50#"); break; case "3": - _sharedResourcesWrapper.SendBlind(":EK51#"); + SharedResourcesWrapper.SendBlind(":EK51#"); break; case "4": - _sharedResourcesWrapper.SendBlind(":EK52#"); + SharedResourcesWrapper.SendBlind(":EK52#"); break; case "5": - _sharedResourcesWrapper.SendBlind(":EK53#"); + SharedResourcesWrapper.SendBlind(":EK53#"); break; case "6": - _sharedResourcesWrapper.SendBlind(":EK54#"); + SharedResourcesWrapper.SendBlind(":EK54#"); break; case "7": - _sharedResourcesWrapper.SendBlind(":EK55#"); + SharedResourcesWrapper.SendBlind(":EK55#"); break; case "8": - _sharedResourcesWrapper.SendBlind(":EK56#"); + SharedResourcesWrapper.SendBlind(":EK56#"); break; case "9": - _sharedResourcesWrapper.SendBlind(":EK57#"); + SharedResourcesWrapper.SendBlind(":EK57#"); break; case "up": - _sharedResourcesWrapper.SendBlind(":EK94#"); + SharedResourcesWrapper.SendBlind(":EK94#"); break; case "down": - _sharedResourcesWrapper.SendBlind(":EK118#"); + SharedResourcesWrapper.SendBlind(":EK118#"); break; case "back": - _sharedResourcesWrapper.SendBlind(":EK87#"); + SharedResourcesWrapper.SendBlind(":EK87#"); break; case "forward": - _sharedResourcesWrapper.SendBlind(":EK69#"); + SharedResourcesWrapper.SendBlind(":EK69#"); break; case "?": - _sharedResourcesWrapper.SendBlind(":EK63#"); + SharedResourcesWrapper.SendBlind(":EK63#"); break; default: LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters); @@ -317,7 +317,7 @@ namespace ASCOM.Meade.net CheckConnected("CommandBlind"); // Call CommandString and return as soon as it finishes //this.CommandString(command, raw); - _sharedResourcesWrapper.SendBlind(command); + SharedResourcesWrapper.SendBlind(command); // or //throw new ASCOM.MethodNotImplementedException("CommandBlind"); // DO NOT have both these sections! One or the other @@ -339,7 +339,7 @@ namespace ASCOM.Meade.net // it's a good idea to put all the low level communication with the device here, // then all communication calls this function // you need something to ensure that only one command is in progress at a time - return _sharedResourcesWrapper.SendString(command); + return SharedResourcesWrapper.SendString(command); //throw new ASCOM.MethodNotImplementedException("CommandString"); } @@ -349,9 +349,9 @@ namespace ASCOM.Meade.net Connected = false; // Clean up the tracelogger and util objects - _tl.Enabled = false; - _tl.Dispose(); - _tl = null; + Tl.Enabled = false; + Tl.Dispose(); + Tl = null; } public bool Connected @@ -374,10 +374,10 @@ namespace ASCOM.Meade.net ReadProfile(); LogMessage("Connected Set", "Connecting to port {0}", ComPort); - var connectionInfo = _sharedResourcesWrapper.Connect("Serial", DriverId, _tl); + var connectionInfo = SharedResourcesWrapper.Connect("Serial", DriverId, Tl); try { - LogMessage("Connected Set", $"Connected to port {ComPort}. Product: {_sharedResourcesWrapper.ProductName} Version:{_sharedResourcesWrapper.FirmwareVersion}"); + LogMessage("Connected Set", $"Connected to port {ComPort}. Product: {SharedResourcesWrapper.ProductName} Version:{SharedResourcesWrapper.FirmwareVersion}"); _userNewerPulseGuiding = IsNewPulseGuidingSupported(); _targetDeclination = InvalidParameter; @@ -411,7 +411,7 @@ namespace ASCOM.Meade.net } catch (Exception) { - _sharedResourcesWrapper.Disconnect("Serial", DriverId); + SharedResourcesWrapper.Disconnect("Serial", DriverId); throw; } } @@ -423,7 +423,7 @@ namespace ASCOM.Meade.net else { LogMessage("Connected Set", "Disconnecting from port {0}", ComPort); - _sharedResourcesWrapper.Disconnect("Serial", DriverId); + SharedResourcesWrapper.Disconnect("Serial", DriverId); IsConnected = false; } } @@ -457,12 +457,12 @@ namespace ASCOM.Meade.net return true; default: - if (_sharedResourcesWrapper.ProductName == TelescopeList.Autostar497) + if (SharedResourcesWrapper.ProductName == TelescopeList.Autostar497) { return FirmwareIsGreaterThan(TelescopeList.Autostar497_31Ee); } - if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) + if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) { return true; } @@ -473,7 +473,7 @@ namespace ASCOM.Meade.net private bool IsLongFormatSupported() { - if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200CLASSIC) + if (SharedResourcesWrapper.ProductName == TelescopeList.LX200CLASSIC) { return false; } @@ -482,7 +482,7 @@ namespace ASCOM.Meade.net private bool IsGuideRateSettingSupported() { - if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) + if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) { return true; } @@ -491,7 +491,7 @@ namespace ASCOM.Meade.net private bool FirmwareIsGreaterThan(string minVersion) { - var currentVersion = _sharedResourcesWrapper.FirmwareVersion; + var currentVersion = SharedResourcesWrapper.FirmwareVersion; var comparison = String.Compare(currentVersion, minVersion, StringComparison.Ordinal); return comparison >= 0; } @@ -508,9 +508,9 @@ namespace ASCOM.Meade.net return; } - _sharedResourcesWrapper.Lock(() => + SharedResourcesWrapper.Lock(() => { - var result = _sharedResourcesWrapper.SendString(":GZ#"); + var result = SharedResourcesWrapper.SendString(":GZ#"); //:GZ# Get telescope azimuth //Returns: DDD*MM# or DDD*MM’SS# //The current telescope Azimuth depending on the selected precision. @@ -520,7 +520,7 @@ namespace ASCOM.Meade.net if (IsLongFormat != setLongFormat) { _utilities.WaitForMilliseconds(500); - _sharedResourcesWrapper.SendBlind(":U#"); + SharedResourcesWrapper.SendBlind(":U#"); //:U# Toggle between low/hi precision positions //Low - RA displays and messages HH:MM.T sDD*MM //High - Dec / Az / El displays and messages HH:MM: SS sDD*MM:SS @@ -534,7 +534,7 @@ namespace ASCOM.Meade.net private bool TogglePrecision() { LogMessage("TogglePrecision", "Toggling slewing precision"); - var result = _sharedResourcesWrapper.SendChar(":P#"); + var result = SharedResourcesWrapper.SendChar(":P#"); //:P# Toggles High Precsion Pointing. When High precision pointing is enabled scope will first allow the operator to center a nearby bright star before moving to the actual target. //Returns: //“HIGH PRECISION” Current setting after this command. @@ -552,10 +552,10 @@ namespace ASCOM.Meade.net break; } - _sharedResourcesWrapper.ReadCharacters(throwAwayCharacters); + SharedResourcesWrapper.ReadCharacters(throwAwayCharacters); //Make sure that the buffers are cleared out. - _sharedResourcesWrapper.SendBlind("#"); + SharedResourcesWrapper.SendBlind("#"); return highPrecision; } @@ -574,7 +574,7 @@ namespace ASCOM.Meade.net { CheckConnectedAndValidateSite(site, "SelectSite"); - _sharedResourcesWrapper.SendBlind($":W{site}#"); + SharedResourcesWrapper.SendBlind($":W{site}#"); //:W# //Set current site to, an ASCII digit in the range 1..4 //Returns: Nothing @@ -635,7 +635,7 @@ namespace ASCOM.Meade.net throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_GetSiteName_Site_out_of_range); } - var result = _sharedResourcesWrapper.SendChar(command); + var result = SharedResourcesWrapper.SendChar(command); if (result != "1") { throw new InvalidOperationException("Failed to set site name."); @@ -649,22 +649,22 @@ namespace ASCOM.Meade.net switch (site) { case 1: - return _sharedResourcesWrapper.SendString(":GM#"); + 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#"); + 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#"); + 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#"); + return SharedResourcesWrapper.SendString(":GP#"); //:GP# Get Site 4 Name //Returns: # //A ‘#’ terminated string with the name of the requested site. @@ -713,7 +713,7 @@ namespace ASCOM.Meade.net CheckConnected("AbortSlew"); LogMessage("AbortSlew", "Aborting slew"); - _sharedResourcesWrapper.SendBlind(":Q#"); + SharedResourcesWrapper.SendBlind(":Q#"); //:Q# Halt all current slewing //Returns:Nothing @@ -731,7 +731,7 @@ namespace ASCOM.Meade.net const char ack = (char) 6; - var alignmentString = _sharedResourcesWrapper.SendChar(ack.ToString()); + var alignmentString = SharedResourcesWrapper.SendChar(ack.ToString()); //ACK <0x06> Query of alignment mounting mode. //Returns: //A If scope in AltAz Mode @@ -782,13 +782,13 @@ namespace ASCOM.Meade.net switch (value) { case AlignmentModes.algAltAz: - _sharedResourcesWrapper.SendBlind(":AA#"); + SharedResourcesWrapper.SendBlind(":AA#"); //:AA# Sets telescope the AltAz alignment mode //Returns: nothing break; case AlignmentModes.algPolar: case AlignmentModes.algGermanPolar: - _sharedResourcesWrapper.SendBlind(":AP#"); + SharedResourcesWrapper.SendBlind(":AP#"); //:AP# Sets telescope to Polar alignment mode //Returns: nothing break; @@ -828,7 +828,7 @@ namespace ASCOM.Meade.net private HorizonCoordinates CalcAltAzFromTelescopeEqData() { - var altitudeData = _sharedResourcesWrapper.Lock(() => new AltitudeData + var altitudeData = SharedResourcesWrapper.Lock(() => new AltitudeData { UtcDateTime = UTCDate, SiteLongitude = SiteLongitude, @@ -1084,7 +1084,7 @@ namespace ASCOM.Meade.net { CheckConnected("Declination Get"); - var result = _sharedResourcesWrapper.SendString(":GD#"); + var result = SharedResourcesWrapper.SendString(":GD#"); //:GD# Get Telescope Declination. //Returns: sDD*MM# or sDD*MM’SS# //Depending upon the current precision setting for the telescope. @@ -1172,7 +1172,7 @@ namespace ASCOM.Meade.net } LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString(CultureInfo.CurrentCulture)} arc seconds/second ({value.ToString(CultureInfo.CurrentCulture)} degrees/second)"); - _sharedResourcesWrapper.SendBlind($":Rg{value:00.0}#"); + 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 @@ -1253,22 +1253,22 @@ namespace ASCOM.Meade.net //do nothing, it's ok this time as we're halting the slew. break; case 1: - _sharedResourcesWrapper.SendBlind(":RG#"); + SharedResourcesWrapper.SendBlind(":RG#"); //:RG# Set Slew rate to Guiding Rate (slowest) //Returns: Nothing break; case 2: - _sharedResourcesWrapper.SendBlind(":RC#"); + SharedResourcesWrapper.SendBlind(":RC#"); //:RC# Set Slew rate to Centering rate (2nd slowest) //Returns: Nothing break; case 3: - _sharedResourcesWrapper.SendBlind(":RM#"); + SharedResourcesWrapper.SendBlind(":RM#"); //:RM# Set Slew rate to Find Rate (2nd Fastest) //Returns: Nothing break; case 4: - _sharedResourcesWrapper.SendBlind(":RS#"); + SharedResourcesWrapper.SendBlind(":RS#"); //:RS# Set Slew rate to max (fastest) //Returns: Nothing break; @@ -1283,22 +1283,22 @@ namespace ASCOM.Meade.net { case ComparisonResult.Equals: _movingPrimary = false; - _sharedResourcesWrapper.SendBlind(":Qe#"); + SharedResourcesWrapper.SendBlind(":Qe#"); //:Qe# Halt eastward Slews //Returns: Nothing - _sharedResourcesWrapper.SendBlind(":Qw#"); + SharedResourcesWrapper.SendBlind(":Qw#"); //:Qw# Halt westward Slews //Returns: Nothing break; case ComparisonResult.Greater: - _sharedResourcesWrapper.SendBlind(":Me#"); + SharedResourcesWrapper.SendBlind(":Me#"); //:Me# Move Telescope East at current slew rate //Returns: Nothing _movingPrimary = true; break; case ComparisonResult.Lower: - _sharedResourcesWrapper.SendBlind(":Mw#"); + SharedResourcesWrapper.SendBlind(":Mw#"); //:Mw# Move Telescope West at current slew rate //Returns: Nothing _movingPrimary = true; @@ -1310,21 +1310,21 @@ namespace ASCOM.Meade.net { case ComparisonResult.Equals: _movingSecondary = false; - _sharedResourcesWrapper.SendBlind(":Qn#"); + SharedResourcesWrapper.SendBlind(":Qn#"); //:Qn# Halt northward Slews //Returns: Nothing - _sharedResourcesWrapper.SendBlind(":Qs#"); + SharedResourcesWrapper.SendBlind(":Qs#"); //:Qs# Halt southward Slews //Returns: Nothing break; case ComparisonResult.Greater: - _sharedResourcesWrapper.SendBlind(":Mn#"); + SharedResourcesWrapper.SendBlind(":Mn#"); //:Mn# Move Telescope North at current slew rate //Returns: Nothing _movingSecondary = true; break; case ComparisonResult.Lower: - _sharedResourcesWrapper.SendBlind(":Ms#"); + SharedResourcesWrapper.SendBlind(":Ms#"); //:Ms# Move Telescope South at current slew rate //Returns: Nothing _movingSecondary = true; @@ -1346,7 +1346,7 @@ namespace ASCOM.Meade.net if (AtPark) return; - _sharedResourcesWrapper.SendBlind(":hP#"); + SharedResourcesWrapper.SendBlind(":hP#"); //:hP# Autostar, Autostar II and LX 16”Slew to Park Position //Returns: Nothing AtPark = true; @@ -1396,7 +1396,7 @@ namespace ASCOM.Meade.net } LogMessage("PulseGuide", "Using new pulse guiding technique"); - _sharedResourcesWrapper.SendBlind($":Mg{d}{duration:0000}#"); + SharedResourcesWrapper.SendBlind($":Mg{d}{duration:0000}#"); //:MgnDDDD# //:MgsDDDD# //:MgeDDDD# @@ -1461,7 +1461,7 @@ namespace ASCOM.Meade.net get { CheckConnected("RightAscension Get"); - var result = _sharedResourcesWrapper.SendString(":GR#"); + var result = SharedResourcesWrapper.SendString(":GR#"); //:GR# Get Telescope RA //Returns: HH:MM.T# or HH:MM:SS# //Depending which precision is set for the telescope @@ -1557,7 +1557,7 @@ namespace ASCOM.Meade.net { CheckConnected("SiteLatitude Get"); - var latitude = _sharedResourcesWrapper.SendString(":Gt#"); + var latitude = SharedResourcesWrapper.SendString(":Gt#"); //:Gt# Get Current Site Latitude //Returns: sDD* MM# //The latitude of the current site. Positive inplies North latitude. @@ -1585,7 +1585,7 @@ namespace ASCOM.Meade.net int m = Convert.ToInt32(60 * (absValue - d)); var commandString = $":St{sign}{d:00}*{m:00}#"; - var result = _sharedResourcesWrapper.SendChar(commandString); + var result = SharedResourcesWrapper.SendChar(commandString); //:StsDD*MM# //Sets the current site latitude to sDD* MM# //Returns: @@ -1602,7 +1602,7 @@ namespace ASCOM.Meade.net { CheckConnected("SiteLongitude Get"); - var longitude = _sharedResourcesWrapper.SendString(":Gg#"); + var longitude = SharedResourcesWrapper.SendString(":Gg#"); //:Gg# Get Current Site Longitude //Returns: sDDD*MM# //The current site Longitude. East Longitudes are expressed as negative @@ -1640,7 +1640,7 @@ namespace ASCOM.Meade.net var commandstring = $":Sg{d:000}*{m:00}#"; - var result = _sharedResourcesWrapper.SendChar(commandstring); + var result = SharedResourcesWrapper.SendChar(commandstring); //:SgDDD*MM# //Set current site’s longitude to DDD*MM an ASCII position string //Returns: @@ -1703,7 +1703,7 @@ namespace ASCOM.Meade.net var latitude = SiteLatitude; var longitude = SiteLongitude; - _sharedResourcesWrapper.Lock(() => + SharedResourcesWrapper.Lock(() => { var raDec = _astroMaths.ConvertHozToEq(utcDateTime, latitude, longitude, altAz); @@ -1723,12 +1723,12 @@ namespace ASCOM.Meade.net { CheckConnected("DoSlewAsync"); - _sharedResourcesWrapper.Lock(() => + SharedResourcesWrapper.Lock(() => { switch (polar) { case true: - var response = _sharedResourcesWrapper.SendChar(":MS#"); + var response = SharedResourcesWrapper.SendChar(":MS#"); //:MS# Slew to Target Object //Returns: //0 Slew is Possible @@ -1743,17 +1743,17 @@ namespace ASCOM.Meade.net break; case "1": //Below Horizon - string belowHorizonMessage = _sharedResourcesWrapper.ReadTerminated(); + string belowHorizonMessage = SharedResourcesWrapper.ReadTerminated(); LogMessage("DoSlewAsync", $"Slew failed \"{belowHorizonMessage}\""); throw new InvalidOperationException(belowHorizonMessage); case "2": //Below minimum elevation - string belowMinimumElevationMessage = _sharedResourcesWrapper.ReadTerminated(); + string belowMinimumElevationMessage = SharedResourcesWrapper.ReadTerminated(); LogMessage("DoSlewAsync", $"Slew failed \"{belowMinimumElevationMessage}\""); throw new InvalidOperationException(belowMinimumElevationMessage); case "3": //Telescope can hit the mount - string canHitMountMessage = _sharedResourcesWrapper.ReadTerminated(); + string canHitMountMessage = SharedResourcesWrapper.ReadTerminated(); LogMessage("DoSlewAsync", $"Slew failed \"{canHitMountMessage}\""); throw new InvalidOperationException(canHitMountMessage); default: @@ -1764,7 +1764,7 @@ namespace ASCOM.Meade.net break; case false: - var maResponse = _sharedResourcesWrapper.SendChar(":MA#"); + var maResponse = SharedResourcesWrapper.SendChar(":MA#"); //:MA# Autostar, LX 16”, Autostar II – Slew to target Alt and Az //Returns: //0 - No fault @@ -1801,7 +1801,7 @@ namespace ASCOM.Meade.net LogMessage("SlewToCoordinatesAsync", $"Ra={rightAscension}, Dec={declination}"); CheckConnected("SlewToCoordinatesAsync"); - _sharedResourcesWrapper.Lock(() => + SharedResourcesWrapper.Lock(() => { TargetRightAscension = rightAscension; TargetDeclination = declination; @@ -1864,7 +1864,7 @@ namespace ASCOM.Meade.net if (_isGuiding) return false; - var result = _sharedResourcesWrapper.SendString(":D#"); + var result = SharedResourcesWrapper.SendString(":D#"); //:D# Requests a string of bars indicating the distance to the current target location. //Returns: //LX200's – a string of bar characters indicating the distance. @@ -1892,7 +1892,7 @@ namespace ASCOM.Meade.net LogMessage("SyncToCoordinates", $"RA={rightAscension} Dec={declination}"); CheckConnected("SyncToCoordinates"); - _sharedResourcesWrapper.Lock(() => + SharedResourcesWrapper.Lock(() => { TargetRightAscension = rightAscension; TargetDeclination = declination; @@ -1906,7 +1906,7 @@ namespace ASCOM.Meade.net LogMessage("SyncToTarget", "Executing"); CheckConnected("SyncToTarget"); - var result = _sharedResourcesWrapper.SendString(":CM#"); + var result = SharedResourcesWrapper.SendString(":CM#"); //:CM# Synchronizes the telescope's position with the currently selected database object's coordinates. //Returns: //LX200's - a "#" terminated string with the name of the object that was synced. @@ -1955,7 +1955,7 @@ namespace ASCOM.Meade.net var command = $":Sd{s}{dms}#"; LogMessage("TargetDeclination Set", $"{command}"); - var result = _sharedResourcesWrapper.SendChar(command); + var result = SharedResourcesWrapper.SendChar(command); //:SdsDD*MM# //Set target object declination to sDD*MM or sDD*MM:SS depending on the current precision setting //Returns: @@ -2003,7 +2003,7 @@ namespace ASCOM.Meade.net //todo implement the low precision version var hms = _utilities.HoursToHMS(value, ":", ":", ":", 2); - var response = _sharedResourcesWrapper.SendChar($":Sr{hms}#"); + var response = SharedResourcesWrapper.SendChar($":Sr{hms}#"); //:SrHH:MM.T# //:SrHH:MM:SS# //Set target object RA to HH:MM.T or HH: MM: SS depending on the current precision setting. @@ -2062,12 +2062,12 @@ namespace ASCOM.Meade.net switch (value) { case DriveRates.driveSidereal: - _sharedResourcesWrapper.SendBlind(":TQ#"); + SharedResourcesWrapper.SendBlind(":TQ#"); //:TQ# Selects sidereal tracking rate //Returns: Nothing break; case DriveRates.driveLunar: - _sharedResourcesWrapper.SendBlind(":TL#"); + SharedResourcesWrapper.SendBlind(":TL#"); //:TL# Set Lunar Tracking Rage //Returns: Nothing break; @@ -2104,7 +2104,7 @@ namespace ASCOM.Meade.net private TimeSpan GetUtcCorrection() { - string utcOffSet = _sharedResourcesWrapper.SendString(":GG#"); + string utcOffSet = SharedResourcesWrapper.SendString(":GG#"); //:GG# Get UTC offset time //Returns: sHH# or sHH.H# //The number of decimal hours to add to local time to convert it to UTC. If the number is a whole number the @@ -2129,15 +2129,15 @@ namespace ASCOM.Meade.net LogMessage("UTCDate", "Get started"); - var telescopeDateDetails = _sharedResourcesWrapper.Lock(() => + var telescopeDateDetails = SharedResourcesWrapper.Lock(() => { var tdd = new TelescopeDateDetails { - TelescopeDate = _sharedResourcesWrapper.SendString(":GC#"), + TelescopeDate = SharedResourcesWrapper.SendString(":GC#"), //:GC# Get current date. //Returns: MM/DD/YY# //The current local calendar date for the telescope. - TelescopeTime = _sharedResourcesWrapper.SendString(":GL#"), + TelescopeTime = SharedResourcesWrapper.SendString(":GL#"), //:GL# Get Local Time in 24 hour format //Returns: HH:MM:SS# //The Local Time in 24 - hour Format @@ -2173,13 +2173,13 @@ namespace ASCOM.Meade.net CheckConnected("UTCDate Set"); - _sharedResourcesWrapper.Lock(() => + SharedResourcesWrapper.Lock(() => { var utcCorrection = GetUtcCorrection(); var localDateTime = value - utcCorrection; string localStingCommand = $":SL{localDateTime:HH:mm:ss}#"; - var timeResult = _sharedResourcesWrapper.SendChar(localStingCommand); + var timeResult = SharedResourcesWrapper.SendChar(localStingCommand); //:SLHH:MM:SS# //Set the local Time //Returns: @@ -2191,7 +2191,7 @@ namespace ASCOM.Meade.net } string localDateCommand = $":SC{localDateTime:MM/dd/yy}#"; - var dateResult = _sharedResourcesWrapper.SendChar(localDateCommand); + var dateResult = SharedResourcesWrapper.SendChar(localDateCommand); //:SCMM/DD/YY# //Change Handbox Date to MM/DD/YY //Returns: @@ -2204,8 +2204,8 @@ namespace ASCOM.Meade.net } //throwing away these two strings which represent - _sharedResourcesWrapper.ReadTerminated(); //Updating Planetary Data# - _sharedResourcesWrapper.ReadTerminated(); // # + SharedResourcesWrapper.ReadTerminated(); //Updating Planetary Data# + SharedResourcesWrapper.ReadTerminated(); // # }); } } @@ -2320,12 +2320,12 @@ namespace ASCOM.Meade.net { var profileProperties = new ProfileProperties { - TraceLogger = _tl.Enabled, + TraceLogger = Tl.Enabled, ComPort = ComPort, GuideRateArcSecondsPerSecond = GuideRate }; - _sharedResourcesWrapper.WriteProfile(profileProperties); + SharedResourcesWrapper.WriteProfile(profileProperties); } #endregion } diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs index 7a803b8..1b95ab2 100644 --- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs +++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs @@ -375,7 +375,10 @@ namespace Meade.net.UnitTests _serialMock.Setup(x => x.Transmit("#:GG#")).Callback(() => { serialPortReturn = ""; }); _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn); - var result = Assert.Throws(() => { var connectionResult = SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object); }); + var result = Assert.Throws(() => + { + SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object); + }); Assert.That(result.Message, Is.EqualTo("Input string was not in a correct format.")); _traceLoggerMock.Verify( x => x.LogIssue("Connect", "Unable to decode response from the telescope, This is likely a hardware serial communications error."), Times.Once); diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index b797dcd..5b68fba 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -78,17 +78,17 @@ namespace ASCOM.Meade.net /// public void SetupDialog() { - _tl.LogMessage("SetupDialog", "Opening setup dialog"); - _sharedResourcesWrapper.SetupDialog(); + Tl.LogMessage("SetupDialog", "Opening setup dialog"); + SharedResourcesWrapper.SetupDialog(); ReadProfile(); - _tl.LogMessage("SetupDialog", "complete"); + Tl.LogMessage("SetupDialog", "complete"); } public ArrayList SupportedActions { get { - _tl.LogMessage("SupportedActions Get", "Returning empty arraylist"); + Tl.LogMessage("SupportedActions Get", "Returning empty arraylist"); return new ArrayList(); } } @@ -104,7 +104,7 @@ namespace ASCOM.Meade.net CheckConnected("CommandBlind"); // Call CommandString and return as soon as it finishes //this.CommandString(command, raw); - _sharedResourcesWrapper.SendBlind(command); + SharedResourcesWrapper.SendBlind(command); // or //throw new ASCOM.MethodNotImplementedException("CommandBlind"); // DO NOT have both these sections! One or the other @@ -126,16 +126,16 @@ namespace ASCOM.Meade.net // it's a good idea to put all the low level communication with the device here, // then all communication calls this function // you need something to ensure that only one command is in progress at a time - return _sharedResourcesWrapper.SendString(command); + return SharedResourcesWrapper.SendString(command); //throw new ASCOM.MethodNotImplementedException("CommandString"); } public void Dispose() { // Clean up the tracelogger and util objects - _tl.Enabled = false; - _tl.Dispose(); - _tl = null; + Tl.Enabled = false; + Tl.Dispose(); + Tl = null; } public bool Connected @@ -147,7 +147,7 @@ namespace ASCOM.Meade.net } set { - _tl.LogMessage("Connected", "Set {0}", value); + Tl.LogMessage("Connected", "Set {0}", value); if (value == IsConnected) return; @@ -156,14 +156,14 @@ namespace ASCOM.Meade.net try { ReadProfile(); - _sharedResourcesWrapper.Connect("Serial", DriverId, _tl); + SharedResourcesWrapper.Connect("Serial", DriverId, Tl); try { IsConnected = true; } catch (Exception) { - _sharedResourcesWrapper.Disconnect("Serial", DriverId); + SharedResourcesWrapper.Disconnect("Serial", DriverId); throw; } } @@ -175,7 +175,7 @@ namespace ASCOM.Meade.net else { LogMessage("Connected Set", "Disconnecting from port {0}", ComPort); - _sharedResourcesWrapper.Disconnect("Serial", DriverId); + SharedResourcesWrapper.Disconnect("Serial", DriverId); IsConnected = false; } } @@ -197,7 +197,7 @@ namespace ASCOM.Meade.net { //string name = "Short driver name - please customise"; string name = DriverDescription; - _tl.LogMessage("Name Get", name); + Tl.LogMessage("Name Get", name); return name; } } @@ -212,20 +212,20 @@ namespace ASCOM.Meade.net { CheckConnected("Absolute Get"); - _tl.LogMessage("Absolute Get", false.ToString()); + Tl.LogMessage("Absolute Get", false.ToString()); return false; // This is a relative focuser } } public void Halt() { - _tl.LogMessage("Halt", "Halting"); + Tl.LogMessage("Halt", "Halting"); CheckConnected("Halt"); //todo fix this issue: A single halt command is sometimes missed by the #909 apm, so let's do it a few times to be safe. - _sharedResourcesWrapper.SendBlind(":FQ#"); + SharedResourcesWrapper.SendBlind(":FQ#"); //:FQ# Halt Focuser Motion //Returns: Nothing } @@ -234,7 +234,7 @@ namespace ASCOM.Meade.net { get { - _tl.LogMessage("IsMoving Get", false.ToString()); + Tl.LogMessage("IsMoving Get", false.ToString()); return false; // This focuser always moves instantaneously so no need for IsMoving ever to be True } } @@ -243,12 +243,12 @@ namespace ASCOM.Meade.net { get { - _tl.LogMessage("Link Get", Connected.ToString()); + Tl.LogMessage("Link Get", Connected.ToString()); return Connected; // Direct function to the connected method, the Link method is just here for backwards compatibility } set { - _tl.LogMessage("Link Set", value.ToString()); + Tl.LogMessage("Link Set", value.ToString()); Connected = value; // Direct function to the connected method, the Link method is just here for backwards compatibility } } @@ -258,7 +258,7 @@ namespace ASCOM.Meade.net { get { - _tl.LogMessage("MaxIncrement Get", _maxIncrement.ToString()); + Tl.LogMessage("MaxIncrement Get", _maxIncrement.ToString()); return _maxIncrement; // Maximum change in one move } } @@ -268,14 +268,14 @@ namespace ASCOM.Meade.net { get { - _tl.LogMessage("MaxStep Get", _maxStep.ToString()); + Tl.LogMessage("MaxStep Get", _maxStep.ToString()); return _maxStep; } } public void Move(int position) { - _tl.LogMessage("Move", position.ToString()); + Tl.LogMessage("Move", position.ToString()); CheckConnected("Move"); if (position < -MaxIncrement || position > MaxIncrement) @@ -290,7 +290,7 @@ namespace ASCOM.Meade.net if (ReverseFocusDirection) direction = !direction; - _sharedResourcesWrapper.Lock(() => + SharedResourcesWrapper.Lock(() => { //backlash compensation. var backlashCompensationSteps = direction ? Math.Abs(BacklashCompensation) : 0; @@ -305,7 +305,7 @@ namespace ASCOM.Meade.net //ApplyBacklashCompensation(direction); if (direction & backlashCompensationSteps != 0) { - _tl.LogMessage("Move", "Applying backlash compensation"); + Tl.LogMessage("Move", "Applying backlash compensation"); MoveFocuser(!direction, backlashCompensationSteps); } @@ -320,7 +320,7 @@ namespace ASCOM.Meade.net if (!UseDynamicBreaking) return; - _tl.LogMessage("Move", "Applying dynamic breaking"); + Tl.LogMessage("Move", "Applying dynamic breaking"); PerformFocuserMove(directionOut); Halt(); @@ -349,7 +349,7 @@ namespace ASCOM.Meade.net private void PerformFocuserMove(bool directionOut) { - _sharedResourcesWrapper.SendBlind(directionOut ? ":F+#" : ":F-#"); + SharedResourcesWrapper.SendBlind(directionOut ? ":F+#" : ":F-#"); //:F+# Start Focuser moving inward (toward objective) //Returns: None @@ -363,7 +363,7 @@ namespace ASCOM.Meade.net { get { - _tl.LogMessage("StepSize Get", "Not implemented"); + Tl.LogMessage("StepSize Get", "Not implemented"); throw new PropertyNotImplementedException("StepSize", false); } } @@ -372,13 +372,13 @@ namespace ASCOM.Meade.net { get { - _tl.LogMessage("TempComp Get", false.ToString()); + Tl.LogMessage("TempComp Get", false.ToString()); return false; } // ReSharper disable once ValueParameterNotUsed set { - _tl.LogMessage("TempComp Set", "Not implemented"); + Tl.LogMessage("TempComp Set", "Not implemented"); throw new PropertyNotImplementedException("TempComp", false); } } @@ -387,7 +387,7 @@ namespace ASCOM.Meade.net { get { - _tl.LogMessage("TempCompAvailable Get", false.ToString()); + Tl.LogMessage("TempCompAvailable Get", false.ToString()); return false; // Temperature compensation is not available in this driver } } @@ -396,7 +396,7 @@ namespace ASCOM.Meade.net { get { - _tl.LogMessage("Temperature Get", "Not implemented"); + Tl.LogMessage("Temperature Get", "Not implemented"); throw new PropertyNotImplementedException("Temperature", false); } } diff --git a/Meade.net/MeadeTelescopeBase.cs b/Meade.net/MeadeTelescopeBase.cs index f34ac52..c9a9e4e 100644 --- a/Meade.net/MeadeTelescopeBase.cs +++ b/Meade.net/MeadeTelescopeBase.cs @@ -12,7 +12,7 @@ namespace ASCOM.Meade.net /// /// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify) /// - protected static TraceLogger _tl; + protected static TraceLogger Tl; /// /// Driver description that displays in the ASCOM Chooser. @@ -27,23 +27,23 @@ namespace ASCOM.Meade.net protected string Precision; protected string GuidingStyle; - protected readonly ISharedResourcesWrapper _sharedResourcesWrapper; + protected readonly ISharedResourcesWrapper SharedResourcesWrapper; public MeadeTelescopeBase() { - _sharedResourcesWrapper = new SharedResourcesWrapper(); + SharedResourcesWrapper = new SharedResourcesWrapper(); } public MeadeTelescopeBase(ISharedResourcesWrapper sharedResourcesWrapper) { - _sharedResourcesWrapper = sharedResourcesWrapper; + SharedResourcesWrapper = sharedResourcesWrapper; } protected void Initialise() { var typeName = GetType().Name; - _tl = new TraceLogger("", $"Meade.Generic.{typeName}"); + Tl = new TraceLogger("", $"Meade.Generic.{typeName}"); ReadProfile(); // Read device configuration from the ASCOM Profile store @@ -58,8 +58,8 @@ namespace ASCOM.Meade.net /// protected void ReadProfile() { - var profileProperties = _sharedResourcesWrapper.ReadProfile(); - _tl.Enabled = profileProperties.TraceLogger; + var profileProperties = SharedResourcesWrapper.ReadProfile(); + Tl.Enabled = profileProperties.TraceLogger; ComPort = profileProperties.ComPort; BacklashCompensation = profileProperties.BacklashCompensation; ReverseFocusDirection = profileProperties.ReverseFocusDirection; @@ -68,7 +68,7 @@ namespace ASCOM.Meade.net Precision = profileProperties.Precision; GuidingStyle = profileProperties.GuidingStyle.ToLower(); - LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}"); + LogMessage("ReadProfile", $"Trace logger enabled: {Tl.Enabled}"); LogMessage("ReadProfile", $"Com Port: {ComPort}"); LogMessage("ReadProfile", $"Backlash Steps: {BacklashCompensation}"); LogMessage("ReadProfile", $"Dynamic breaking: {UseDynamicBreaking}"); @@ -86,7 +86,7 @@ namespace ASCOM.Meade.net public static void LogMessage(string identifier, string message, params object[] args) { var msg = String.Format(message, args); - _tl.LogMessage(identifier, msg); + Tl.LogMessage(identifier, msg); } /// @@ -98,7 +98,7 @@ namespace ASCOM.Meade.net { get { - _tl.LogMessage("Description Get", DriverDescription); + Tl.LogMessage("Description Get", DriverDescription); return DriverDescription; } } From 89600c463b9391530c1fb9df63658a163d507173 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 20:53:11 +0100 Subject: [PATCH 23/55] Removed unneeded variable --- Meade.net/SharedResources.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 33724fd..0087300 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -311,7 +311,7 @@ namespace ASCOM.Meade.net //sHH# form is returned, otherwise the longer form is returned. try { - double utcOffsetHours = double.Parse(utcOffSet); + double.Parse(utcOffSet); } catch (Exception) { From 03f2022f2fb0dd4f0a2a4e533c5deae5302fbdac Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 21:04:28 +0100 Subject: [PATCH 24/55] Refactored the error message --- .../SharedResourcesUnitTests.cs | 4 ++-- Meade.net/SharedResources.cs | 18 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs index 1b95ab2..025bfb5 100644 --- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs +++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs @@ -375,11 +375,11 @@ namespace Meade.net.UnitTests _serialMock.Setup(x => x.Transmit("#:GG#")).Callback(() => { serialPortReturn = ""; }); _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn); - var result = Assert.Throws(() => + var result = Assert.Throws(() => { SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object); }); - Assert.That(result.Message, Is.EqualTo("Input string was not in a correct format.")); + Assert.That(result.Message, Is.EqualTo("Unable to decode response from the telescope, This is likely a hardware serial communications error.")); _traceLoggerMock.Verify( x => x.LogIssue("Connect", "Unable to decode response from the telescope, This is likely a hardware serial communications error."), Times.Once); } diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 0087300..b0fed12 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -16,6 +16,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Globalization; using System.Windows.Forms; using ASCOM.Meade.net.Wrapper; @@ -309,16 +310,13 @@ namespace ASCOM.Meade.net //Returns: sHH# or sHH.H# //The number of decimal hours to add to local time to convert it to UTC. If the number is a whole number the //sHH# form is returned, otherwise the longer form is returned. - try - { - double.Parse(utcOffSet); - } - catch (Exception) - { - traceLogger.LogIssue("Connect", "Unable to decode response from the telescope, This is likely a hardware serial communications error."); - throw; - } - + double utcOffsetHours; + if (!double.TryParse(utcOffSet, out utcOffsetHours)) + { + var message = "Unable to decode response from the telescope, This is likely a hardware serial communications error."; + traceLogger.LogIssue("Connect", message); + throw new Exception(message); + } } catch (Exception) { From 83dd7d87f0698f1baa27793385fc5aa1ba52a472 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 22:52:02 +0100 Subject: [PATCH 25/55] Code Inspections --- Meade.net/SharedResources.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index b0fed12..23ca66e 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -16,7 +16,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; using System.Windows.Forms; using ASCOM.Meade.net.Wrapper; @@ -310,13 +309,15 @@ namespace ASCOM.Meade.net //Returns: sHH# or sHH.H# //The number of decimal hours to add to local time to convert it to UTC. If the number is a whole number the //sHH# form is returned, otherwise the longer form is returned. - double utcOffsetHours; - if (!double.TryParse(utcOffSet, out utcOffsetHours)) - { - var message = "Unable to decode response from the telescope, This is likely a hardware serial communications error."; - traceLogger.LogIssue("Connect", message); - throw new Exception(message); - } + double utcOffsetHours; + if (!double.TryParse(utcOffSet, out utcOffsetHours)) + { + var message = "Unable to decode response from the telescope, This is likely a hardware serial communications error."; + traceLogger.LogIssue("Connect", message); + throw new Exception(message); + } + + traceLogger.LogMessage("Connect", $"Offset from UTC: {utcOffSet}", false); } catch (Exception) { From 47d0a047a56edbab607704c46cdf446018621101 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 23:07:54 +0100 Subject: [PATCH 26/55] Code inspection --- Meade.net/SharedResources.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 23ca66e..5df1a29 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -317,7 +317,7 @@ namespace ASCOM.Meade.net throw new Exception(message); } - traceLogger.LogMessage("Connect", $"Offset from UTC: {utcOffSet}", false); + traceLogger.LogMessage("Connect", $"Offset from UTC: {utcOffsetHours}", false); } catch (Exception) { From d728dbe2723c49ccc469ac547e426805596f4d70 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 23:34:04 +0100 Subject: [PATCH 27/55] Trying to reduce code duplication --- Meade.net.Telescope/Telescope.cs | 12 +++++------- Meade.net.focuser/Focuser.cs | 16 +++++++--------- Meade.net/MeadeTelescopeBase.cs | 27 ++++++++++++++++++++++----- Meade.net/SharedResources.cs | 3 +-- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index d3e4bc3..fc0ca39 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -40,6 +40,11 @@ namespace ASCOM.Meade.net [ComVisible(true)] public class Telescope : MeadeTelescopeBase, ITelescopeV3 { + static Telescope() + { + ClassName = nameof(Telescope); + } + /// /// ASCOM DeviceID (COM ProgID) for this driver. /// The DeviceID is used by ASCOM applications to load the driver at runtime. @@ -2225,13 +2230,6 @@ namespace ASCOM.Meade.net #region ASCOM Registration - private static IProfileFactory _profileFactory; - public static IProfileFactory ProfileFactory - { - get => _profileFactory ?? (_profileFactory = new ProfileFactory()); - set => _profileFactory = value; - } - // Register or unregister driver for ASCOM. This is harmless if already // registered or unregistered. // diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index 5b68fba..9f9c9f6 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -32,6 +32,11 @@ namespace ASCOM.Meade.net [ComVisible(true)] public class Focuser : MeadeTelescopeBase, IFocuserV3 { + static Focuser() + { + ClassName = nameof(Focuser); + } + /// /// ASCOM DeviceID (COM ProgID) for this driver. /// The DeviceID is used by ASCOM applications to load the driver at runtime. @@ -264,6 +269,7 @@ namespace ASCOM.Meade.net } private readonly int _maxStep = 7000; + public int MaxStep { get @@ -409,14 +415,6 @@ namespace ASCOM.Meade.net #region ASCOM Registration - private static IProfileFactory _profileFactory; - - public static IProfileFactory ProfileFactory - { - get => _profileFactory ?? (_profileFactory = new ProfileFactory()); - set => _profileFactory = value; - } - // Register or unregister driver for ASCOM. This is harmless if already // registered or unregistered. // @@ -429,7 +427,7 @@ namespace ASCOM.Meade.net { using (IProfileWrapper p = ProfileFactory.Create()) { - p.DeviceType = "Focuser"; + p.DeviceType = ClassName; if (bRegister) { p.Register(DriverId, DriverDescription); diff --git a/Meade.net/MeadeTelescopeBase.cs b/Meade.net/MeadeTelescopeBase.cs index c9a9e4e..c8dc5b0 100644 --- a/Meade.net/MeadeTelescopeBase.cs +++ b/Meade.net/MeadeTelescopeBase.cs @@ -9,6 +9,13 @@ namespace ASCOM.Meade.net [ComVisible(false)] public class MeadeTelescopeBase : ReferenceCountedObjectBase { + static MeadeTelescopeBase() + { + ClassName = nameof(MeadeTelescopeBase); + } + + public static string ClassName { get; protected set; } + /// /// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify) /// @@ -41,16 +48,14 @@ namespace ASCOM.Meade.net protected void Initialise() { - var typeName = GetType().Name; - - Tl = new TraceLogger("", $"Meade.Generic.{typeName}"); + Tl = new TraceLogger("", $"Meade.Generic.{ClassName}"); ReadProfile(); // Read device configuration from the ASCOM Profile store IsConnected = false; // Initialise connected to false - LogMessage(typeName, "Completed initialisation"); - LogMessage(typeName, $"Driver version: {DriverVersion}"); + LogMessage(ClassName, "Completed initialisation"); + LogMessage(ClassName, $"Driver version: {DriverVersion}"); } /// @@ -123,5 +128,17 @@ namespace ASCOM.Meade.net return driverVersion; } } + + #region ASCOM Registration + + private static IProfileFactory _profileFactory; + + public static IProfileFactory ProfileFactory + { + get => _profileFactory ?? (_profileFactory = new ProfileFactory()); + set => _profileFactory = value; + } + + #endregion } } \ No newline at end of file diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 5df1a29..b7b5e4a 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -309,8 +309,7 @@ namespace ASCOM.Meade.net //Returns: sHH# or sHH.H# //The number of decimal hours to add to local time to convert it to UTC. If the number is a whole number the //sHH# form is returned, otherwise the longer form is returned. - double utcOffsetHours; - if (!double.TryParse(utcOffSet, out utcOffsetHours)) + if (!double.TryParse(utcOffSet, out var utcOffsetHours)) { var message = "Unable to decode response from the telescope, This is likely a hardware serial communications error."; traceLogger.LogIssue("Connect", message); From b33d1741c4e959ad9601af73b8fb0b92cd81d44b Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 4 Sep 2020 15:23:46 +0100 Subject: [PATCH 28/55] Removed the Classname static as it doesn't work as desired. Replace with a parameter on the initialise method instead. --- Meade.net.Telescope/Telescope.cs | 9 ++------- Meade.net.focuser/Focuser.cs | 13 ++++--------- Meade.net/MeadeTelescopeBase.cs | 15 ++++----------- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index fc0ca39..090ac9c 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -40,11 +40,6 @@ namespace ASCOM.Meade.net [ComVisible(true)] public class Telescope : MeadeTelescopeBase, ITelescopeV3 { - static Telescope() - { - ClassName = nameof(Telescope); - } - /// /// ASCOM DeviceID (COM ProgID) for this driver. /// The DeviceID is used by ASCOM applications to load the driver at runtime. @@ -80,7 +75,7 @@ namespace ASCOM.Meade.net _astroUtilities = new AstroUtils(); // Initialise astro utilities object _astroMaths = new AstroMaths.AstroMaths(); - Initialise(); + Initialise(nameof(Telescope)); } catch (Exception e) { @@ -118,7 +113,7 @@ namespace ASCOM.Meade.net _astroUtilities = astroUtilities; // Initialise astro utilities object _astroMaths = astroMaths; - Initialise(); + Initialise(nameof(Telescope)); } private bool _isGuiding; diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index 9f9c9f6..ab8220a 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -32,11 +32,6 @@ namespace ASCOM.Meade.net [ComVisible(true)] public class Focuser : MeadeTelescopeBase, IFocuserV3 { - static Focuser() - { - ClassName = nameof(Focuser); - } - /// /// ASCOM DeviceID (COM ProgID) for this driver. /// The DeviceID is used by ASCOM applications to load the driver at runtime. @@ -59,16 +54,16 @@ namespace ASCOM.Meade.net var util = new Util(); //Initialise util object _utilities = util; - Initialise(); + Initialise(nameof(Focuser)); } public Focuser(IUtil util, ISharedResourcesWrapper sharedResourcesWrapper) : base(sharedResourcesWrapper) { _utilities = util; - Initialise(); + Initialise(nameof(Focuser)); } - + // // PUBLIC COM INTERFACE IFocuserV3 IMPLEMENTATION // @@ -427,7 +422,7 @@ namespace ASCOM.Meade.net { using (IProfileWrapper p = ProfileFactory.Create()) { - p.DeviceType = ClassName; + p.DeviceType = nameof(Focuser); if (bRegister) { p.Register(DriverId, DriverDescription); diff --git a/Meade.net/MeadeTelescopeBase.cs b/Meade.net/MeadeTelescopeBase.cs index c8dc5b0..a3728da 100644 --- a/Meade.net/MeadeTelescopeBase.cs +++ b/Meade.net/MeadeTelescopeBase.cs @@ -9,13 +9,6 @@ namespace ASCOM.Meade.net [ComVisible(false)] public class MeadeTelescopeBase : ReferenceCountedObjectBase { - static MeadeTelescopeBase() - { - ClassName = nameof(MeadeTelescopeBase); - } - - public static string ClassName { get; protected set; } - /// /// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify) /// @@ -46,16 +39,16 @@ namespace ASCOM.Meade.net SharedResourcesWrapper = sharedResourcesWrapper; } - protected void Initialise() + protected void Initialise(string className) { - Tl = new TraceLogger("", $"Meade.Generic.{ClassName}"); + Tl = new TraceLogger("", $"Meade.Generic.{className}"); ReadProfile(); // Read device configuration from the ASCOM Profile store IsConnected = false; // Initialise connected to false - LogMessage(ClassName, "Completed initialisation"); - LogMessage(ClassName, $"Driver version: {DriverVersion}"); + LogMessage(className, "Completed initialisation"); + LogMessage(className, $"Driver version: {DriverVersion}"); } /// From d0406b32dd2c4b312a80a092a16ce6157044baef Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 21 Sep 2020 23:04:58 +0100 Subject: [PATCH 29/55] Added ability to unpark telescope Added extra logging information to the "isslewing test" --- .../TelescopeUnitTests.cs | 8 ++--- Meade.net.Telescope/Telescope.cs | 36 +++++++++++++++---- Meade.net/MeadeTelescopeBase.cs | 2 +- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 9ccb9e2..e483868 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -947,7 +947,7 @@ namespace Meade.net.Telescope.UnitTests { var result = _telescope.CanUnpark; - Assert.That(result, Is.False); + Assert.That(result, Is.True); } [Test] @@ -1581,11 +1581,9 @@ namespace Meade.net.Telescope.UnitTests } [Test] - public void Unpark_ThenThrowsException() + public void Unpark_ThenDoesNotThrowException() { - var excpetion = Assert.Throws(() => { _telescope.Unpark(); }); - - Assert.That(excpetion.Method, Is.EqualTo("Unpark")); + Assert.DoesNotThrow(() => { _telescope.Unpark(); }); } [Test] diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 090ac9c..9bad4f3 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1073,8 +1073,8 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanUnpark", "Get - " + false); - return false; + LogMessage("CanUnpark", "Get - " + true); + return true; } } @@ -1877,7 +1877,7 @@ namespace ASCOM.Meade.net bool isSlewing = result.Trim() != string.Empty; - LogMessage("Slewing Get", $"Result = {isSlewing}"); + LogMessage("Slewing Get", $"Result = {isSlewing} ({result.Trim()}"); return isSlewing; } @@ -2212,9 +2212,33 @@ namespace ASCOM.Meade.net public void Unpark() { - //todo heard a rumour that it's possible to unpark an LX200GPS. - LogMessage("Unpark", "Not implemented"); - throw new MethodNotImplementedException("Unpark"); + LogMessage("Unpark", "Parking telescope"); + + if (!AtPark) + return; + + SharedResourcesWrapper.SendChar(":I#"); + //:I# LX200 GPS Only - Causes the telescope to cease current operations and restart at its power on initialization. + //Returns: X once the handset restart has completed + + //todo implement the + //todo make sure that the telescope has the correct date and time. + //UTCDate = DateTime.UtcNow; + + + + var utcCorrection = GetUtcCorrection(); + var localDateTime = DateTime.UtcNow - utcCorrection; + + //localDateTime: HH: mm: ss + SharedResourcesWrapper.SendBlind($":hI{localDateTime:yyMMddhhmmss}#"); + //:hIYYMMDDHHMMSS# + //Bypass handbox entry of daylight savings, date and time.Use the values supplied in this command.This feature is + //intended to allow use of the Autostar II from permanent installations where GPS reception is not possible, such as within + //metal domes. This command must be issued while the telescope is waiting at the initial daylight savings prompt. + //Returns: 1 – if command was accepted. + + AtPark = false; } #endregion diff --git a/Meade.net/MeadeTelescopeBase.cs b/Meade.net/MeadeTelescopeBase.cs index a3728da..8728524 100644 --- a/Meade.net/MeadeTelescopeBase.cs +++ b/Meade.net/MeadeTelescopeBase.cs @@ -83,7 +83,7 @@ namespace ASCOM.Meade.net /// public static void LogMessage(string identifier, string message, params object[] args) { - var msg = String.Format(message, args); + var msg = string.Format(message, args); Tl.LogMessage(identifier, msg); } From c34ed41ddf25324b3de2cbd4e6eed3a8baebedb9 Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 22 Sep 2020 17:34:57 +0100 Subject: [PATCH 30/55] Added check to ensure that the LX-200 classic return value is sanitised when it's not slewing. --- Meade.net.Telescope/Telescope.cs | 38 +++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 9bad4f3..08d21f0 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1847,19 +1847,26 @@ namespace ASCOM.Meade.net { get { - if (!Connected) return false; - - - if (MovingAxis()) - return true; - - return IsSlewingToTarget(); + var isSlewing = GetSlewing(); + LogMessage("Slewing", $"Result = {isSlewing}"); + return isSlewing; } } + private bool GetSlewing() + { + if (!Connected) return false; + + + if (MovingAxis()) + return true; + + return IsSlewingToTarget(); + } + private bool IsSlewingToTarget() { - CheckConnected("Slewing Get"); + CheckConnected("IsSlewingToTarget"); if (_isGuiding) return false; @@ -1875,9 +1882,20 @@ namespace ASCOM.Meade.net return false; } - bool isSlewing = result.Trim() != string.Empty; + var trimmedResult = result.Trim(); + var isResultEmpty = trimmedResult != string.Empty; - LogMessage("Slewing Get", $"Result = {isSlewing} ({result.Trim()}"); + var isSlewing = isResultEmpty; + + if (!isResultEmpty) //the LX-200 can return crap from the buffer when it's not slewing so let's try to filter that out. + { + if (!trimmedResult.Contains("|")) + { + isSlewing = false; + } + } + + LogMessage("IsSlewingToTarget", $"Result = {isSlewing} ({trimmedResult})"); return isSlewing; } From 1b73bb62b6fdf1287eec232a59e1a61ddc10d620 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 24 Sep 2020 22:01:52 +0100 Subject: [PATCH 31/55] Fixed logic for LX200 Classic is slewing test --- .../TelescopeUnitTests.cs | 25 ++++++++++++++++--- Meade.net.Telescope/Telescope.cs | 4 +-- Meade.net/TelescopeList.cs | 14 +++++------ 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index e483868..2a0403c 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -67,10 +67,10 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Object, _astroMathsMock.Object); } - private void ConnectTelescope() + private void ConnectTelescope(string productName = TelescopeList.Autostar497, string firmwareVersion = TelescopeList.Autostar497_31Ee) { - _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497); - _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee); + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => productName); + _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => firmwareVersion); _telescope.Connected = true; } @@ -2184,6 +2184,25 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Verify(x => x.SendString(":D#"),Times.Once); } + [TestCase(TelescopeList.LX200CLASSIC,"","|", true)] + [TestCase(TelescopeList.LX200CLASSIC, "", "||||||||", true)] + [TestCase(TelescopeList.LX200CLASSIC, "", "", false)] + [TestCase(TelescopeList.LX200CLASSIC, "", "[FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF] [FF][FF][FF][FF][FF][FF]", false)] + [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "|", true)] + [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "", false)] + public void Slewing_WhenTelescopeNotSlewing_ThenReturnsFalse(string productName, string firmwareVersion, string response, bool isSlewing) + { + _sharedResourcesWrapperMock.Setup(x => x.SendString(":D#")).Returns(response); + + ConnectTelescope(productName, firmwareVersion); + + var result = _telescope.Slewing; + + Assert.That(result, Is.EqualTo(isSlewing)); + + _sharedResourcesWrapperMock.Verify(x => x.SendString(":D#"), Times.Once); + } + [TestCase(1, TelescopeAxes.axisPrimary)] [TestCase(-1, TelescopeAxes.axisPrimary)] [TestCase(1, TelescopeAxes.axisSecondary)] diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 08d21f0..c208cc9 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1883,9 +1883,9 @@ namespace ASCOM.Meade.net } var trimmedResult = result.Trim(); - var isResultEmpty = trimmedResult != string.Empty; + var isResultEmpty = trimmedResult == string.Empty; - var isSlewing = isResultEmpty; + var isSlewing = !isResultEmpty; if (!isResultEmpty) //the LX-200 can return crap from the buffer when it's not slewing so let's try to filter that out. { diff --git a/Meade.net/TelescopeList.cs b/Meade.net/TelescopeList.cs index 61e4293..440c4bd 100644 --- a/Meade.net/TelescopeList.cs +++ b/Meade.net/TelescopeList.cs @@ -4,30 +4,30 @@ { #region Autostar 497/Audiostar - public static readonly string Autostar497 = "Autostar"; + public const string Autostar497 = "Autostar"; //Autostar/Audiostar firmware revisions // ReSharper disable once InconsistentNaming - public static readonly string Autostar497_30Ee = "30Ee"; + public const string Autostar497_30Ee = "30Ee"; // ReSharper disable once InconsistentNaming - public static readonly string Autostar497_31Ee = "31Ee"; + public const string Autostar497_31Ee = "31Ee"; // ReSharper disable once InconsistentNaming - public static readonly string Autostar497_43Eg = "43Eg"; + public const string Autostar497_43Eg = "43Eg"; #endregion #region LX200GPS // ReSharper disable once InconsistentNaming - public static readonly string LX200GPS = "LX2001"; + public const string LX200GPS = "LX2001"; // ReSharper disable once InconsistentNaming - public static readonly string LX200GPS_42G = "4.2G"; + public const string LX200GPS_42G = "4.2G"; #endregion #region LX200EMC // ReSharper disable once InconsistentNaming - public static readonly string LX200CLASSIC = "LX200 Classic"; //GVP command is not supported! + public const string LX200CLASSIC = "LX200 Classic"; //GVP command is not supported! #endregion } } From a59ecaf21dfe462db98409fa48594c710b66d9e7 Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 13 Oct 2020 10:30:43 +0100 Subject: [PATCH 32/55] Added support for being able to enable the Rts/Dtr signals which is needed to Meade LS series scopes --- Meade.net/ProfileProperties.cs | 1 + Meade.net/SetupDialogForm.cs | 5 +- Meade.net/SetupDialogForm.designer.cs | 13 ++++ Meade.net/SetupDialogForm.resx | 104 ++++++++++++++++++-------- Meade.net/SharedResources.cs | 8 +- 5 files changed, 97 insertions(+), 34 deletions(-) diff --git a/Meade.net/ProfileProperties.cs b/Meade.net/ProfileProperties.cs index fe57a13..520b05f 100644 --- a/Meade.net/ProfileProperties.cs +++ b/Meade.net/ProfileProperties.cs @@ -11,5 +11,6 @@ namespace ASCOM.Meade.net public int BacklashCompensation { get; set; } public bool ReverseFocusDirection { get; set; } public bool DynamicBreaking { get; set; } + public bool RtsDtrEnabled { get; set; } } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index fa705c2..1f4f699 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -62,6 +62,8 @@ namespace ASCOM.Meade.net comboBoxComPort.SelectedItem = profileProperties.ComPort; } + cbxRtsDtr.Checked = profileProperties.RtsDtrEnabled; + txtGuideRate.Text = profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.CurrentCulture); try { @@ -93,13 +95,14 @@ namespace ASCOM.Meade.net { TraceLogger = chkTrace.Checked, ComPort = comboBoxComPort.SelectedItem.ToString(), + RtsDtrEnabled = cbxRtsDtr.Checked, GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text.Trim()), Precision = cboPrecision.SelectedItem.ToString(), GuidingStyle = cboGuidingStyle.SelectedItem.ToString(), BacklashCompensation = int.Parse(txtBacklashSteps.Text), ReverseFocusDirection = cbxReverseDirection.Checked, DynamicBreaking = cbxDynamicBreaking.Checked - }; + }; return profileProperties; } diff --git a/Meade.net/SetupDialogForm.designer.cs b/Meade.net/SetupDialogForm.designer.cs index b4c618a..c970e28 100644 --- a/Meade.net/SetupDialogForm.designer.cs +++ b/Meade.net/SetupDialogForm.designer.cs @@ -31,6 +31,7 @@ namespace ASCOM.Meade.net /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SetupDialogForm)); this.cmdOK = new System.Windows.Forms.Button(); this.cmdCancel = new System.Windows.Forms.Button(); @@ -55,6 +56,8 @@ namespace ASCOM.Meade.net this.label11 = new System.Windows.Forms.Label(); this.cbxReverseDirection = new System.Windows.Forms.CheckBox(); this.cbxDynamicBreaking = new System.Windows.Forms.CheckBox(); + this.cbxRtsDtr = new System.Windows.Forms.CheckBox(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); ((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit(); this.SuspendLayout(); // @@ -201,10 +204,18 @@ namespace ASCOM.Meade.net this.cbxDynamicBreaking.Name = "cbxDynamicBreaking"; this.cbxDynamicBreaking.UseVisualStyleBackColor = true; // + // cbxRtsDtr + // + resources.ApplyResources(this.cbxRtsDtr, "cbxRtsDtr"); + this.cbxRtsDtr.Name = "cbxRtsDtr"; + this.toolTip1.SetToolTip(this.cbxRtsDtr, resources.GetString("cbxRtsDtr.ToolTip")); + this.cbxRtsDtr.UseVisualStyleBackColor = true; + // // SetupDialogForm // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.cbxRtsDtr); this.Controls.Add(this.cbxDynamicBreaking); this.Controls.Add(this.cbxReverseDirection); this.Controls.Add(this.label11); @@ -266,5 +277,7 @@ namespace ASCOM.Meade.net private Label label11; private CheckBox cbxReverseDirection; private CheckBox cbxDynamicBreaking; + private CheckBox cbxRtsDtr; + private ToolTip toolTip1; } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.resx b/Meade.net/SetupDialogForm.resx index 3366ceb..ca12791 100644 --- a/Meade.net/SetupDialogForm.resx +++ b/Meade.net/SetupDialogForm.resx @@ -145,7 +145,7 @@ $this - 22 + 23 Bottom, Right @@ -172,7 +172,7 @@ $this - 21 + 22 12, 9 @@ -196,7 +196,7 @@ $this - 20 + 21 Top, Right @@ -223,7 +223,7 @@ $this - 19 + 20 True @@ -250,19 +250,19 @@ $this - 18 + 19 True - 97, 114 + 97, 137 69, 17 - 6 + 2 Trace on @@ -277,7 +277,7 @@ $this - 17 + 18 97, 87 @@ -286,7 +286,7 @@ 90, 21 - 7 + 0 comboBoxComPort @@ -298,7 +298,7 @@ $this - 16 + 17 True @@ -325,7 +325,7 @@ $this - 15 + 16 97, 199 @@ -334,7 +334,7 @@ 46, 20 - 9 + 3 10.0 @@ -349,7 +349,7 @@ $this - 14 + 15 True @@ -376,7 +376,7 @@ $this - 13 + 14 True @@ -403,7 +403,7 @@ $this - 12 + 13 True @@ -430,7 +430,7 @@ $this - 11 + 12 Unchanged @@ -448,7 +448,7 @@ 90, 21 - 13 + 4 cboPrecision @@ -460,7 +460,7 @@ $this - 10 + 11 True @@ -490,7 +490,7 @@ $this - 9 + 10 Auto @@ -508,7 +508,7 @@ 90, 21 - 15 + 5 cboGuidingStyle @@ -520,7 +520,7 @@ $this - 8 + 9 True @@ -550,7 +550,7 @@ $this - 7 + 8 True @@ -583,7 +583,7 @@ $this - 6 + 7 97, 335 @@ -592,7 +592,7 @@ 46, 20 - 19 + 6 3000 @@ -607,7 +607,7 @@ $this - 4 + 5 True @@ -637,7 +637,7 @@ $this - 5 + 6 True @@ -667,7 +667,7 @@ $this - 3 + 4 True @@ -700,7 +700,7 @@ $this - 2 + 3 True @@ -712,7 +712,7 @@ 109, 17 - 22 + 7 Reverse direction @@ -727,7 +727,7 @@ $this - 1 + 2 True @@ -739,7 +739,7 @@ 112, 17 - 23 + 8 Dynamic Breaking @@ -754,6 +754,42 @@ $this + 1 + + + True + + + NoControl + + + 97, 114 + + + 112, 17 + + + 1 + + + Enable RTS/DTR + + + 17, 17 + + + Useful for Meade LS scopes + + + cbxRtsDtr + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 @@ -771,6 +807,12 @@ Meade.net Setup + + toolTip1 + + + System.Windows.Forms.ToolTip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + SetupDialogForm diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index b7b5e4a..df7fcae 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -137,6 +137,7 @@ namespace ASCOM.Meade.net // Constants used for Profile persistence private const string ComPortProfileName = "COM Port"; + private const string RtsDtrProfileName = "Rts / Dtr"; private const string TraceStateProfileName = "Trace Level"; private const string GuideRateProfileName = "Guide Rate Arc Seconds Per Second"; private const string PrecisionProfileName = "Precision"; @@ -154,6 +155,7 @@ namespace ASCOM.Meade.net driverProfile.DeviceType = "Telescope"; driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString()); driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort); + driverProfile.WriteValue(DriverId, RtsDtrProfileName, profileProperties.RtsDtrEnabled.ToString()); driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.InvariantCulture)); driverProfile.WriteValue(DriverId, PrecisionProfileName, profileProperties.Precision); driverProfile.WriteValue(DriverId, GuidingStyleProfileName, profileProperties.GuidingStyle); @@ -165,6 +167,7 @@ namespace ASCOM.Meade.net } private const string ComPortDefault = "COM1"; + private const string RtsDtrDefault = "false"; private const string TraceStateDefault = "false"; private const string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate private const string PrecisionDefault = "Unchanged"; @@ -182,6 +185,7 @@ namespace ASCOM.Meade.net { driverProfile.DeviceType = "Telescope"; profileProperties.ComPort = driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault); + profileProperties.RtsDtrEnabled = Convert.ToBoolean(driverProfile.GetValue(DriverId, RtsDtrProfileName, string.Empty, RtsDtrDefault)); 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); @@ -272,8 +276,8 @@ namespace ASCOM.Meade.net { var profileProperties = ReadProfile(); SharedSerial.PortName = profileProperties.ComPort; - SharedSerial.DTREnable = false; - SharedSerial.RTSEnable = false; + SharedSerial.DTREnable = profileProperties.RtsDtrEnabled; + SharedSerial.RTSEnable = profileProperties.RtsDtrEnabled; SharedSerial.DataBits = 8; SharedSerial.StopBits = SerialStopBits.One; SharedSerial.Parity = SerialParity.None; From ca0028f08dc67aa694d2b5ad73bb7695f79767bf Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 7 Jan 2021 19:28:46 +0000 Subject: [PATCH 33/55] Upgraded to .net 4.7.2, and fixed issue with the site location being set wrongly --- Meade.net.Telescope/Meade.net.Telescope.csproj | 2 +- Meade.net.Telescope/Properties/Settings.Designer.cs | 2 +- Meade.net.Telescope/Telescope.cs | 10 ++++------ Meade.net.Telescope/app.config | 2 +- Meade.net.focuser/Meade.net.focuser.csproj | 2 +- Meade.net.focuser/Properties/Settings.Designer.cs | 2 +- Meade.net.focuser/app.config | 2 +- Meade.net/Meade.net.csproj | 2 +- Meade.net/app.config | 2 +- 9 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Meade.net.Telescope/Meade.net.Telescope.csproj b/Meade.net.Telescope/Meade.net.Telescope.csproj index d7431b6..e6eecaa 100644 --- a/Meade.net.Telescope/Meade.net.Telescope.csproj +++ b/Meade.net.Telescope/Meade.net.Telescope.csproj @@ -15,7 +15,7 @@ 3.5 - v4.5 + v4.7.2 ASCOM.ico true ASCOMDriverTemplate.snk diff --git a/Meade.net.Telescope/Properties/Settings.Designer.cs b/Meade.net.Telescope/Properties/Settings.Designer.cs index 67ea42d..c23ba31 100644 --- a/Meade.net.Telescope/Properties/Settings.Designer.cs +++ b/Meade.net.Telescope/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace ASCOM.Meade.net.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index c208cc9..d0716fb 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1606,13 +1606,11 @@ namespace ASCOM.Meade.net //:Gg# Get Current Site Longitude //Returns: sDDD*MM# //The current site Longitude. East Longitudes are expressed as negative - double siteLongitude = _utilities.DMSToDegrees(longitude); - - if (siteLongitude > 180) - siteLongitude = siteLongitude - 360; - - siteLongitude = -siteLongitude; + double siteLongitude = -_utilities.DMSToDegrees(longitude); + if (siteLongitude < -180) + siteLongitude = siteLongitude + 360; + LogMessage("SiteLongitude Get", $"{_utilitiesExtra.DegreesToDMS(siteLongitude)}"); return siteLongitude; } diff --git a/Meade.net.Telescope/app.config b/Meade.net.Telescope/app.config index 66e0395..c8fc52c 100644 --- a/Meade.net.Telescope/app.config +++ b/Meade.net.Telescope/app.config @@ -5,4 +5,4 @@
- + diff --git a/Meade.net.focuser/Meade.net.focuser.csproj b/Meade.net.focuser/Meade.net.focuser.csproj index 9bf14ad..80083ce 100644 --- a/Meade.net.focuser/Meade.net.focuser.csproj +++ b/Meade.net.focuser/Meade.net.focuser.csproj @@ -15,7 +15,7 @@ 3.5 - v4.5 + v4.7.2 ASCOM.ico true ASCOMDriverTemplate.snk diff --git a/Meade.net.focuser/Properties/Settings.Designer.cs b/Meade.net.focuser/Properties/Settings.Designer.cs index 67ea42d..c23ba31 100644 --- a/Meade.net.focuser/Properties/Settings.Designer.cs +++ b/Meade.net.focuser/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace ASCOM.Meade.net.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/Meade.net.focuser/app.config b/Meade.net.focuser/app.config index 66e0395..c8fc52c 100644 --- a/Meade.net.focuser/app.config +++ b/Meade.net.focuser/app.config @@ -5,4 +5,4 @@
- + diff --git a/Meade.net/Meade.net.csproj b/Meade.net/Meade.net.csproj index f3a6c03..e733b60 100644 --- a/Meade.net/Meade.net.csproj +++ b/Meade.net/Meade.net.csproj @@ -10,7 +10,7 @@ Properties ASCOM.Meade.net ASCOM.Meade.net.Server - v4.5 + v4.7.2 2.0 diff --git a/Meade.net/app.config b/Meade.net/app.config index c5e1dae..5c22b42 100644 --- a/Meade.net/app.config +++ b/Meade.net/app.config @@ -1,3 +1,3 @@ - + From 4126b2ee449b8f0aa3fad6b0b899f76725121e58 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 7 Jan 2021 20:07:00 +0000 Subject: [PATCH 34/55] Added JetBrains.Annotations --- .../AstroMath.UnitTests.csproj | 19 +++++---- AstroMath.UnitTests/app.config | 2 +- AstroMath.UnitTests/packages.config | 7 ++-- FocuserTestConsole/FocuserTestConsole.csproj | 4 ++ FocuserTestConsole/packages.config | 4 ++ .../Meade.net.Focuser.UnitTests.csproj | 41 ++++++++++--------- Meade.net.Focuser.UnitTests/app.config | 2 +- Meade.net.Focuser.UnitTests/packages.config | 9 ++-- .../Meade.net.Telescope.UnitTests.csproj | 41 ++++++++++--------- Meade.net.Telescope.UnitTests/app.config | 2 +- Meade.net.Telescope.UnitTests/packages.config | 9 ++-- .../Meade.net.Telescope.csproj | 25 ++++++----- Meade.net.Telescope/packages.config | 3 +- .../Meade.net.UnitTests.csproj | 41 ++++++++++--------- Meade.net.UnitTests/app.config | 2 +- Meade.net.UnitTests/packages.config | 9 ++-- Meade.net.focuser/Meade.net.focuser.csproj | 25 ++++++----- Meade.net.focuser/packages.config | 3 +- Meade.net/Meade.net.csproj | 25 ++++++----- Meade.net/packages.config | 3 +- .../TelescopeTestConsole.csproj | 4 ++ TelescopeTestConsole/packages.config | 4 ++ 22 files changed, 164 insertions(+), 120 deletions(-) create mode 100644 FocuserTestConsole/packages.config create mode 100644 TelescopeTestConsole/packages.config diff --git a/AstroMath.UnitTests/AstroMath.UnitTests.csproj b/AstroMath.UnitTests/AstroMath.UnitTests.csproj index e2e0ac5..9457f57 100644 --- a/AstroMath.UnitTests/AstroMath.UnitTests.csproj +++ b/AstroMath.UnitTests/AstroMath.UnitTests.csproj @@ -1,6 +1,6 @@  - + Debug @@ -56,17 +56,20 @@ ..\packages\Castle.Core.4.4.1\lib\net45\Castle.Core.dll - - ..\packages\Moq.4.14.5\lib\net45\Moq.dll + + ..\packages\JetBrains.Annotations.2020.3.0\lib\net20\JetBrains.Annotations.dll - - ..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll + + ..\packages\Moq.4.15.2\lib\net45\Moq.dll + + + ..\packages\NUnit.3.13.0\lib\net45\nunit.framework.dll - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll @@ -97,6 +100,6 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/AstroMath.UnitTests/app.config b/AstroMath.UnitTests/app.config index d0d658a..fe20587 100644 --- a/AstroMath.UnitTests/app.config +++ b/AstroMath.UnitTests/app.config @@ -8,7 +8,7 @@ - + diff --git a/AstroMath.UnitTests/packages.config b/AstroMath.UnitTests/packages.config index 2c67311..2bd4fbf 100644 --- a/AstroMath.UnitTests/packages.config +++ b/AstroMath.UnitTests/packages.config @@ -1,8 +1,9 @@  - - - + + + + \ No newline at end of file diff --git a/FocuserTestConsole/FocuserTestConsole.csproj b/FocuserTestConsole/FocuserTestConsole.csproj index 8818966..a0e33a3 100644 --- a/FocuserTestConsole/FocuserTestConsole.csproj +++ b/FocuserTestConsole/FocuserTestConsole.csproj @@ -59,6 +59,9 @@ + + ..\packages\JetBrains.Annotations.2020.3.0\lib\net20\JetBrains.Annotations.dll + @@ -72,6 +75,7 @@ +