From 4266139429acbd386ed0ebcafd8359c9c67d1e39 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 18:35:40 +0100 Subject: [PATCH] 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;