diff --git a/AstroMath.UnitTests/AstroMath.UnitTests.csproj b/AstroMath.UnitTests/AstroMath.UnitTests.csproj
index 9457f57..cffc483 100644
--- a/AstroMath.UnitTests/AstroMath.UnitTests.csproj
+++ b/AstroMath.UnitTests/AstroMath.UnitTests.csproj
@@ -90,6 +90,10 @@
{64308775-bd4a-469c-bcab-3ed830b811af}
Meade.net.Telescope
+
+ {3689a2cb-94c5-4012-a5cf-7e7d1dd27143}
+ Meade.net
+
diff --git a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs
index 2ba4e76..9f945d2 100644
--- a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs
+++ b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs
@@ -27,6 +27,12 @@ namespace Meade.net.Focuser.UnitTests
{
TraceLogger = false,
ComPort = "TestCom1",
+ Speed = 9600,
+ Parity = "None",
+ Handshake = "None",
+ StopBits = "One",
+ DataBits = 8,
+
GuideRateArcSecondsPerSecond = 1.23,
Precision = "Unchanged",
GuidingStyle = "Auto"
@@ -153,11 +159,11 @@ namespace Meade.net.Focuser.UnitTests
ConnectFocuser();
- _sharedResourcesWrapperMock.Setup(x => x.SendString(sendMessage)).Returns(() => expectedMessage);
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(sendMessage, true)).Returns(() => expectedMessage);
var actualMessage = _focuser.CommandString(sendMessage, true);
- _sharedResourcesWrapperMock.Verify(x => x.SendString(sendMessage), Times.Once);
+ _sharedResourcesWrapperMock.Verify(x => x.SendString(sendMessage, true), Times.Once);
Assert.That(actualMessage, Is.EqualTo(expectedMessage));
}
diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs
index 16b330d..d3f3f03 100644
--- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs
+++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs
@@ -14,6 +14,16 @@ using InvalidOperationException = ASCOM.InvalidOperationException;
namespace Meade.net.Telescope.UnitTests
{
+ public class TestProperties
+ {
+ internal string telescopeRaResult = "HH:MM:SS";
+ internal double rightAscension = 1.2; //todo rename to RightAscension;
+
+ internal string SiteLatitudeString = "testLatString";
+ internal double SiteLatitudeValue = 123.45;
+
+ }
+
[TestFixture]
public class TelescopeUnitTests
{
@@ -28,16 +38,31 @@ namespace Meade.net.Telescope.UnitTests
private ProfileProperties _profileProperties;
private ConnectionInfo _connectionInfo;
+ private TestProperties _testProperties;
+
[SetUp]
public void Setup()
{
+ _testProperties = new TestProperties();
+
_profileProperties = new ProfileProperties
{
TraceLogger = false,
ComPort = "TestCom1",
+ Speed = 9600,
+ Parity = "None",
+ Handshake = "None",
+ StopBits = "One",
+ DataBits = 8,
+
GuideRateArcSecondsPerSecond = 1.23,
- Precision = "Unchanged",
- GuidingStyle = "Auto"
+ Precision = "Unchanged",
+ GuidingStyle = "Auto",
+
+ SendDateTime = false,
+ ParkedBehaviour = ParkedBehaviour.NoCoordinates,
+ ParkedAlt = 0,
+ ParkedAz = 180
};
_utilMock = new Mock();
@@ -45,7 +70,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#", true)).Returns("DDD*MM’SS");
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(() =>_profileProperties);
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny())).Callback(action => { action(); });
@@ -73,6 +98,12 @@ namespace Meade.net.Telescope.UnitTests
private void ConnectTelescope(string productName = TelescopeList.Autostar497, string firmwareVersion = TelescopeList.Autostar497_31Ee)
{
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":Gt#", true)).Returns(_testProperties.SiteLatitudeString);
+ _utilMock.Setup(x => x.DMSToDegrees(_testProperties.SiteLatitudeString)).Returns(_testProperties.SiteLatitudeValue);
+
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#", true)).Returns(_testProperties.telescopeRaResult);
+ _utilMock.Setup(x => x.HMSToHours(_testProperties.telescopeRaResult)).Returns(_testProperties.rightAscension);
+
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => productName);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => firmwareVersion);
_telescope.Connected = true;
@@ -126,14 +157,14 @@ 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#", true)).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#", true), Times.Once);
Assert.That(actualResult, Is.EqualTo(expectedResult));
}
@@ -197,14 +228,14 @@ namespace Meade.net.Telescope.UnitTests
[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);
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(telescopeCommand, true)).Returns(siteName);
ConnectTelescope();
string parameters = $"GetName {site}";
var result = _telescope.Action("site", parameters);
- _sharedResourcesWrapperMock.Verify(x => x.SendString(telescopeCommand), Times.Once);
+ _sharedResourcesWrapperMock.Verify(x => x.SendString(telescopeCommand, true), Times.Once);
Assert.That(result, Is.EqualTo(siteName));
}
@@ -351,13 +382,13 @@ namespace Meade.net.Telescope.UnitTests
string expectedMessage = "expected result message";
string sendMessage = "test blind Message";
- _sharedResourcesWrapperMock.Setup(x => x.SendString(sendMessage)).Returns(() => expectedMessage);
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(sendMessage, true)).Returns(() => expectedMessage);
ConnectTelescope();
var actualMessage = _telescope.CommandString(sendMessage, true);
- _sharedResourcesWrapperMock.Verify(x => x.SendString(sendMessage), Times.Once);
+ _sharedResourcesWrapperMock.Verify(x => x.SendString(sendMessage, true), Times.Once);
Assert.That(actualMessage, Is.EqualTo(expectedMessage));
}
@@ -367,13 +398,15 @@ namespace Meade.net.Telescope.UnitTests
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee);
- _telescope.Connected = expectedConnected;
+ if (expectedConnected)
+ ConnectTelescope();
+
Assert.That(_telescope.Connected, Is.EqualTo(expectedConnected));
if (expectedConnected)
{
- _sharedResourcesWrapperMock.Verify(x => x.SendString(":GZ#"), Times.Once);
+ _sharedResourcesWrapperMock.Verify(x => x.SendString(":GZ#", true), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"), Times.Never);
}
}
@@ -381,19 +414,95 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void Connected_Set_WhenConnectingLX200GPS_Then_ConnectsToSerialDevice()
{
- var productName = TelescopeList.LX200GPS;
- var firmware = string.Empty;
-
- _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName);
- _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware);
- _telescope.Connected = true;
+ ConnectTelescope(TelescopeList.LX200GPS, string.Empty);
_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#", true), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"),Times.Once);
}
+ [Test]
+ public void Connected_WhenConnectingLX200GPSAndSendDateTimeIsTrue_Then_SpecialStartupInstructionSendOnFirstConnect()
+ {
+ _profileProperties.SendDateTime = true;
+
+ DateTime testNow = DateTime.ParseExact("2021-10-03T20:36:25", "yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture);
+
+ _clockMock.Setup(x => x.UtcNow).Returns(() => { return testNow; });
+
+ string setDateCommand = $":hI{testNow:yyMMddHHmmss}#";
+
+ string expectedResult = "Daylight Savings Time:";
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":ED#", true)).Returns(expectedResult);
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GG#", true)).Returns("0");
+ _sharedResourcesWrapperMock.Setup(x => x.SendChar(setDateCommand)).Returns("1");
+
+ ConnectTelescope(TelescopeList.LX200GPS, string.Empty);
+
+ _sharedResourcesWrapperMock.Verify(x => x.SendChar(setDateCommand), Times.Once);
+ }
+
+ [Test]
+ public void Connected_WhenConnectingLX200GPSAndSendDateTimeIsTrue_Then_ByPassDisplaysWhenNotOnDaylightScreen()
+ {
+ _profileProperties.SendDateTime = true;
+
+ string telescopeTime = "20:36:25";
+ string telescopeDate = "10/03/21";
+ DateTime endSlewingDatetime = DateTime.ParseExact("2021-10-03T20:36:25", "yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture);
+
+ _clockMock.Setup(x => x.UtcNow).Returns(() =>
+ {
+ return endSlewingDatetime;
+ });
+
+ string setDateCommand = $":hI{endSlewingDatetime:yyMMddHHmmss}#";
+
+ string expectedResult = "Align";
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":ED#", true)).Returns(expectedResult);
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GG#", true)).Returns("0");
+
+
+ _sharedResourcesWrapperMock.Setup(x => x.SendChar($":SL{telescopeTime}#")).Returns("1");
+ _sharedResourcesWrapperMock.Setup(x => x.SendChar($":SC{telescopeDate}#")).Returns("1");
+
+ ConnectTelescope(TelescopeList.LX200GPS, string.Empty);
+
+ _sharedResourcesWrapperMock.Verify(x => x.SendChar(setDateCommand), Times.Never);
+ _sharedResourcesWrapperMock.Verify(x => x.ReadTerminated(), Times.Exactly(2));
+ }
+
+ [Test]
+ public void Connected_WhenConnectingAutostarAndSendDateTimeIsTrue_Then_ByPassDisplaysWhenNotOnDaylightScreen()
+ {
+ _profileProperties.SendDateTime = true;
+
+ string telescopeTime = "20:36:25";
+ string telescopeDate = "10/03/21";
+ DateTime endSlewingDatetime = DateTime.ParseExact("2021-10-03T20:36:25", "yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture);
+
+ _clockMock.Setup(x => x.UtcNow).Returns(() =>
+ {
+ return endSlewingDatetime;
+ });
+
+ string setDateCommand = $":hI{endSlewingDatetime:yyMMddHHmmss}#";
+
+ string expectedResult = "Align";
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":ED#", true)).Returns(expectedResult);
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GG#", true)).Returns("0");
+
+
+ _sharedResourcesWrapperMock.Setup(x => x.SendChar($":SL{telescopeTime}#")).Returns("1");
+ _sharedResourcesWrapperMock.Setup(x => x.SendChar($":SC{telescopeDate}#")).Returns("1");
+
+ ConnectTelescope();
+
+ _sharedResourcesWrapperMock.Verify(x => x.SendChar(setDateCommand), Times.Never);
+ _sharedResourcesWrapperMock.Verify(x => x.ReadTerminated(), Times.Exactly(2));
+ }
+
[Test]
public void Connected_Set_WhenConnectingToLX200EMC_Then_ConnectsToSerialDevice()
{
@@ -405,7 +514,7 @@ 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.SendString(":GZ#", true), Times.Never);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"), Times.Never);
}
@@ -426,12 +535,6 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void Connected_Set_SettingFalseWhenTrue_ThenDisconnects()
{
- var telescopeRaResult = "HH:MM:SS";
- var hmsResult = 1.2;
-
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeRaResult);
- _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(hmsResult);
-
ConnectTelescope();
_sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once);
@@ -448,7 +551,7 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee);
- _sharedResourcesWrapperMock.Setup(x => x.SendString(It.IsAny())).Throws(new Exception("TestFailed"));
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(It.IsAny(), It.IsAny())).Throws(new Exception("TestFailed"));
//act
_telescope.Connected = true;
@@ -460,6 +563,7 @@ namespace Meade.net.Telescope.UnitTests
[TestCase("Auto", "Autostar", "30Ab", false)]
[TestCase("Auto","Autostar", "31Ee", true)]
[TestCase("Auto","Autostar", "43Eg", true)]
+ [TestCase("Auto","Autostar", "A4S4", true)]
[TestCase("Auto","Autostar II", "", false)]
[TestCase("Auto","LX2001", "", true)]
[TestCase("Auto",":GVP", "", false)] //LX200 Classic
@@ -483,7 +587,7 @@ 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#", true)).Returns("DDD*MM");
_telescope.SetLongFormat(false);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":U#"),Times.Never);
@@ -492,7 +596,7 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void SetLongFormatFalse_WhenTelescopeReturnsLongFormat_ThenTogglesPrecision()
{
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MM’SS");
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#", true)).Returns("DDD*MM’SS");
_telescope.SetLongFormat(false);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":U#"), Times.Once);
@@ -501,7 +605,7 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void SetLongFormatTrue_WhenTelescopeReturnsLongFormat_ThenDoesNothing()
{
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MM’SS");
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#", true)).Returns("DDD*MM’SS");
_telescope.SetLongFormat(true);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":U#"), Times.Never);
@@ -510,7 +614,7 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void SetLongFormatTrue_WhenTelescopeReturnsShortFormat_ThenTogglesPrecision()
{
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MM");
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#", true)).Returns("DDD*MM");
_telescope.SetLongFormat(true);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":U#"), Times.Once);
@@ -825,7 +929,7 @@ namespace Meade.net.Telescope.UnitTests
{
_telescope.Connected = true;
- _sharedResourcesWrapperMock.Verify( x => x.SendString(":P#"), Times.Never);
+ _sharedResourcesWrapperMock.Verify( x => x.SendString(":P#", true), Times.Never);
}
[TestCase("High", false, true)]
@@ -850,7 +954,7 @@ namespace Meade.net.Telescope.UnitTests
}
});
- _telescope.Connected = true;
+ ConnectTelescope();
Assert.That(currentPrecision, Is.EqualTo(finalPrecision));
_sharedResourcesWrapperMock.Verify(x => x.SendChar(":P#"), Times.AtLeastOnce);
@@ -953,11 +1057,52 @@ namespace Meade.net.Telescope.UnitTests
}
[Test]
- public void CanUnpark_Get_ReturnsFalse()
+ public void CanUnpark_NotConnected_ThrowsException()
{
+ var exception = Assert.Throws(() =>
+ {
+ var result = _telescope.CanUnpark;
+ });
+
+ Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: CanUnpark"));
+ }
+
+ [TestCase(TelescopeList.LX200GPS, TelescopeList.LX200GPS_42G, true)]
+ [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, false)]
+ public void CanUnpark_Get_ReturnsExpectedValue(string productVersion, string firmware, bool expectedResult)
+ {
+ ConnectTelescope(productVersion, firmware);
+
var result = _telescope.CanUnpark;
- Assert.That(result, Is.True);
+ Assert.That(result, Is.EqualTo(expectedResult));
+ }
+
+ [Test]
+ public void Unpark_NotConnect_ThrowsException()
+ {
+ var exception = Assert.Throws(() =>
+ {
+ _telescope.Unpark();
+ });
+
+ Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: Unpark"));
+ }
+
+ [TestCase(TelescopeList.LX200GPS, TelescopeList.LX200GPS_42G, true)]
+ [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, false)]
+ public void Unpark_ThenDoesNotThrowException(string productVersion, string firmware, bool canUnPark)
+ {
+ ConnectTelescope(productVersion, firmware);
+
+ if (canUnPark)
+ Assert.DoesNotThrow(() => { _telescope.Unpark(); });
+ else
+ {
+ var exception = Assert.Throws(() => { _telescope.Unpark(); });
+
+ Assert.That(exception.Message, Is.EqualTo("Unable to unpark this telescope type"));
+ }
}
[Test]
@@ -976,7 +1121,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#", true)).Returns(declincationString);
_utilMock.Setup(x => x.DMSToDegrees(declincationString)).Returns(expectedResult);
ConnectTelescope();
@@ -990,19 +1135,15 @@ namespace Meade.net.Telescope.UnitTests
{
var telescopeDecResult = "s12*34’56";
var dmsResult = 1.2;
- var telescopeRaResult = "HH:MM:SS";
- var hmsResult = 1.3;
-
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#")).Returns(telescopeDecResult);
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeRaResult);
+
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#", true)).Returns(telescopeDecResult);
_utilMock.Setup(x => x.DMSToDegrees(telescopeDecResult)).Returns(dmsResult);
- _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(hmsResult);
ConnectTelescope();
var result = _telescope.Declination;
- _sharedResourcesWrapperMock.Verify(x => x.SendString(":GD#"), Times.Exactly(2));
+ _sharedResourcesWrapperMock.Verify(x => x.SendString(":GD#", true), Times.Exactly(2));
_utilMock.Verify(x => x.DMSToDegrees(telescopeDecResult), Times.Exactly(2));
Assert.That(result, Is.EqualTo(dmsResult));
@@ -1318,12 +1459,6 @@ namespace Meade.net.Telescope.UnitTests
[TestCase(GuideDirections.guideSouth)]
public void PulseGuide_WhenConnectedAndNewerPulseGuidingAvailable_ThenSendsNewCommandsAndWaits(GuideDirections direction)
{
- var telescopeRaResult = "HH:MM:SS";
- var hmsResult = 1.2;
-
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeRaResult);
- _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(hmsResult);
-
var duration = 0;
ConnectTelescope();
@@ -1356,7 +1491,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#", true)).Returns("|");
var duration = 0;
ConnectTelescope();
@@ -1372,7 +1507,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#", true)).Returns("");
var duration = 0;
ConnectTelescope();
@@ -1392,13 +1527,11 @@ namespace Meade.net.Telescope.UnitTests
{
var telescopeDecResult = "s12*34’56";
var dmsResult = 1.2;
- var telescopeRaResult = "HH:MM:SS";
- var hmsResult = 1.3;
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#")).Returns(telescopeDecResult);
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeRaResult);
+ _testProperties.rightAscension = 1.3;
+
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#", true)).Returns(telescopeDecResult);
_utilMock.Setup(x => x.DMSToDegrees(telescopeDecResult)).Returns(dmsResult);
- _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(hmsResult);
var duration = 0;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
@@ -1410,7 +1543,7 @@ namespace Meade.net.Telescope.UnitTests
isSlewing = _telescope.Slewing;
});
- _telescope.Connected = true;
+ ConnectTelescope();
_telescope.PulseGuide(direction, duration);
@@ -1425,18 +1558,12 @@ namespace Meade.net.Telescope.UnitTests
{
var telescopeDecResult = "s12*34’56";
var dmsResult = 1.2;
- var telescopeRaResult = "HH:MM:SS";
- var hmsResult = 1.3;
-
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#")).Returns(telescopeDecResult);
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeRaResult);
- _utilMock.Setup(x => x.DMSToDegrees(telescopeDecResult)).Returns(dmsResult);
- _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(hmsResult);
-
var duration = 0;
- _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
- _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_30Ee);
- _telescope.Connected = true;
+
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#", true)).Returns(telescopeDecResult);
+ _utilMock.Setup(x => x.DMSToDegrees(telescopeDecResult)).Returns(dmsResult);
+
+ ConnectTelescope(TelescopeList.Autostar497, TelescopeList.Autostar497_30Ee);
_telescope.PulseGuide(direction, duration);
@@ -1472,21 +1599,14 @@ namespace Meade.net.Telescope.UnitTests
short slewSettleTime = 10;
_profileProperties.SettleTime = slewSettleTime;
+ var duration = 0;
var telescopeDecResult = "s12*34’56";
var dmsResult = 1.2;
- var telescopeRaResult = "HH:MM:SS";
- var hmsResult = 1.3;
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#")).Returns(telescopeDecResult);
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeRaResult);
- _utilMock.Setup(x => x.DMSToDegrees(telescopeDecResult)).Returns(dmsResult);
- _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(hmsResult);
-
- var duration = 0;
- _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
- _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_30Ee);
-
- _telescope.Connected = true;
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#", true)).Returns(telescopeDecResult);
+ _utilMock.Setup(x => x.DMSToDegrees(telescopeDecResult)).Returns(dmsResult);
+
+ ConnectTelescope(TelescopeList.Autostar497, TelescopeList.Autostar497_30Ee);
_telescope.PulseGuide(direction, duration);
@@ -1516,16 +1636,8 @@ namespace Meade.net.Telescope.UnitTests
[TestCase(GuideDirections.guideSouth)]
public void PulseGuide_WhenConnectedAndNewerPulseGuidingAvailableButDurationTooLong_ThenSendsOldCommandsAndWaits(GuideDirections direction)
{
- var telescopeRaResult = "HH:MM:SS";
- var hmsResult = 1.2;
-
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeRaResult);
- _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(hmsResult);
-
var duration = 10000;
- _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
- _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_30Ee);
- _telescope.Connected = true;
+ ConnectTelescope(TelescopeList.Autostar497, TelescopeList.Autostar497_30Ee);
_telescope.PulseGuide(direction, duration);
@@ -1566,20 +1678,11 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void RightAscension_Get_WhenConnected_ThenReturnsExpectedResult()
{
- var telescopeRaResult = "HH:MM:SS";
- var hmsResult = 1.2;
-
- _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));
- _utilMock.Verify( x => x.HMSToHours(telescopeRaResult), Times.Exactly(2));
-
- Assert.That(result,Is.EqualTo(hmsResult));
+ Assert.That(result,Is.EqualTo(_testProperties.rightAscension));
}
[Test]
@@ -1731,12 +1834,6 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(result, Is.EqualTo(settleTime));
}
- [Test]
- public void Unpark_ThenDoesNotThrowException()
- {
- Assert.DoesNotThrow(() => { _telescope.Unpark(); });
- }
-
[Test]
public void SiteLatitude_Get_WhenNotConnected_ThenThrowsException()
{
@@ -1751,19 +1848,13 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void SiteLatitude_Get_WhenConnected_ThenRetrievesAndReturnsExpectedValue()
{
- var siteLatitudeString = "testLatString";
- var siteLatitudeValue = 123.45;
-
- _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#", true), Times.AtLeastOnce);
- Assert.That(result,Is.EqualTo(siteLatitudeValue));
+ Assert.That(result,Is.EqualTo(_testProperties.SiteLatitudeValue));
}
[Test]
@@ -1837,7 +1928,7 @@ namespace Meade.net.Telescope.UnitTests
{
var telescopeLongitude = "testLongitude";
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":Gg#")).Returns(telescopeLongitude);
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":Gg#", true)).Returns(telescopeLongitude);
_utilMock.Setup(x => x.DMSToDegrees(telescopeLongitude)).Returns(telescopeLongitudeValue);
ConnectTelescope();
@@ -1916,32 +2007,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#", true)).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#", true), Times.Once);
}
[Test]
public void SyncToTarget_WhenSyncToTargetWorks_ThennoExceptionThrown()
{
- var telescopeRaResult = "HH:MM:SS";
- var hmsResult = 1.2;
-
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeRaResult);
- _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(hmsResult);
-
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":CM#")).Returns(" M31 EX GAL MAG 3.5 SZ178.0'#");
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":CM#", true)).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#", true), Times.Once);
}
[Test]
@@ -2204,9 +2289,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#", true)).Returns(telescopeDate);
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GL#", true)).Returns(telescopeTime);
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GG#", true)).Returns(telescopeUtcCorrection);
ConnectTelescope();
@@ -2239,7 +2324,7 @@ 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.SendString(":GG#", true)).Returns(telescopeUtcCorrection);
_sharedResourcesWrapperMock.Setup(x => x.SendChar($":SL{telescopeTime}#")).Returns("0");
ConnectTelescope();
@@ -2258,7 +2343,7 @@ 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.SendString(":GG#", true)).Returns(telescopeUtcCorrection);
_sharedResourcesWrapperMock.Setup(x => x.SendChar($":SL{telescopeTime}#")).Returns("1");
_sharedResourcesWrapperMock.Setup(x => x.SendChar($":SC{newDate:MM/dd/yy}#")).Returns("0");
@@ -2280,7 +2365,7 @@ 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.SendString(":GG#", true)).Returns(telescopeUtcCorrection);
_sharedResourcesWrapperMock.Setup(x => x.SendChar($":SL{telescopeTime}#")).Returns("1");
_sharedResourcesWrapperMock.Setup(x => x.SendChar($":SC{telescopeDate}#")).Returns("1");
@@ -2309,45 +2394,39 @@ namespace Meade.net.Telescope.UnitTests
public void SyncToCoordinates_WhenConnected_ThenReturnsExpectedResult()
{
var telescopeDecResult = "s12*34’56";
- var telescopeRaResult = "HH:MM:SS";
- //var hmsResult = 1.2;
- double rightAscension = 5.5;
string hms = "05:30:00";
+ _testProperties.rightAscension = 5.5;
double declination = -30.5;
string dec = "-30*30:00";
var digitsRA = 2;
- _sharedResourcesWrapperMock.Setup(x => x.SendChar($":Sr{telescopeRaResult}#")).Returns("1");
+ _sharedResourcesWrapperMock.Setup(x => x.SendChar($":Sr{_testProperties.telescopeRaResult}#")).Returns("1");
- _utilMock.Setup(x => x.HoursToHMS(rightAscension, ":", ":", ":", digitsRA)).Returns(telescopeRaResult);
- _utilMock.Setup(x => x.HMSToHours(hms)).Returns(rightAscension);
+ _utilMock.Setup(x => x.HoursToHMS(_testProperties.rightAscension, ":", ":", ":", digitsRA)).Returns(_testProperties.telescopeRaResult);
+ _utilMock.Setup(x => x.HMSToHours(hms)).Returns(_testProperties.rightAscension);
_utilMock.Setup(x => x.DegreesToDMS(declination, "*", ":", ":", digitsRA)).Returns(telescopeDecResult);
_utilMock.Setup(x => x.DMSToDegrees(telescopeDecResult)).Returns(declination);
-
- //_utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(hmsResult);
+
_utilMock.Setup(x => x.DMSToDegrees(dec)).Returns(declination);
- _utilMock.Setup(x => x.HoursToHMS(rightAscension, ":", ":", ":", 2)).Returns(hms);
+ _utilMock.Setup(x => x.HoursToHMS(_testProperties.rightAscension, ":", ":", ":", 2)).Returns(hms);
_utilMock.Setup(x => x.DegreesToDMS(declination, "*", ":", ":", digitsRA)).Returns(dec);
_sharedResourcesWrapperMock.Setup(x => x.SendChar($":Sr{hms}#")).Returns("1");
_sharedResourcesWrapperMock.Setup(x => x.SendChar($":Sd{dec}#")).Returns("1");
- _sharedResourcesWrapperMock.Setup(x => x.SendString($":CM#")).Returns("M31 EX GAL MAG 3.5 SZ178.0'#");
+ _sharedResourcesWrapperMock.Setup(x => x.SendString($":CM#", true)).Returns("M31 EX GAL MAG 3.5 SZ178.0'#");
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#")).Returns(telescopeDecResult);
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeRaResult);
-
- _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(rightAscension);
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#", true)).Returns(telescopeDecResult);
ConnectTelescope();
-
- _telescope.SyncToCoordinates(rightAscension, declination);
- _sharedResourcesWrapperMock.Verify( x => x.SendString(":CM#"), Times.Once);
- Assert.That(_telescope.TargetRightAscension, Is.EqualTo(rightAscension));
+ _telescope.SyncToCoordinates(_testProperties.rightAscension, declination);
+
+ _sharedResourcesWrapperMock.Verify(x => x.SendString(":CM#", true), Times.Once);
+ Assert.That(_telescope.TargetRightAscension, Is.EqualTo(_testProperties.rightAscension));
Assert.That(_telescope.TargetDeclination, Is.EqualTo(declination));
}
@@ -2358,7 +2437,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#", true), Times.Never);
}
[Test]
@@ -2370,13 +2449,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#", true), Times.Once);
}
[Test]
public void Slewing_WhenTelescopeIsSlewing_ThenReturnsTrue()
{
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":D#")).Returns("|");
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":D#", true)).Returns("|");
ConnectTelescope();
@@ -2384,7 +2463,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#", true),Times.Once);
}
[TestCase(0, 0, "2021-10-03T20:36:00", "2021-10-03T20:36:01", false)]
@@ -2422,7 +2501,7 @@ namespace Meade.net.Telescope.UnitTests
var slewingText = "|";
var notSlewingText = String.Empty;
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":D#")).Returns( () =>
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":D#", true)).Returns( () =>
{
if (timescalled == 0)
{
@@ -2451,15 +2530,11 @@ namespace Meade.net.Telescope.UnitTests
[TestCase(TelescopeList.LX200CLASSIC, "", "[FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF] [FF][FF][FF][FF][FF][FF]", false)] //The test case below is this same string encoded to return exactly what the telescope will return.
[TestCase(TelescopeList.LX200CLASSIC, "", "\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff \x00ff\x00ff\x00ff\x00ff\x00ff\x00ff", false)]
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "|", true)]
+ [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "\u007f", true)]
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "", false)]
public void Slewing_WhenTelescopeNotSlewing_ThenReturnsFalse(string productName, string firmwareVersion, string response, bool isSlewing)
{
- var telescopeRaResult = "HH:MM:SS";
- var hmsResult = 1.2;
-
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeRaResult);
- _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(hmsResult);
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":D#")).Returns(response);
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":D#", true)).Returns(response);
ConnectTelescope(productName, firmwareVersion);
@@ -2467,7 +2542,7 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(result, Is.EqualTo(isSlewing));
- _sharedResourcesWrapperMock.Verify(x => x.SendString(":D#"), Times.Once);
+ _sharedResourcesWrapperMock.Verify(x => x.SendString(":D#", true), Times.Once);
}
[TestCase(1, TelescopeAxes.axisPrimary)]
@@ -2483,7 +2558,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#", true), Times.Never);
}
[TestCase(1, TelescopeAxes.axisPrimary, 0, 0, false, false)]
@@ -2657,7 +2732,7 @@ namespace Meade.net.Telescope.UnitTests
var slewCounter = 0;
var iterations = 10;
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":D#")).Returns(() =>
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":D#", true)).Returns(() =>
{
slewCounter++;
if (slewCounter <= iterations)
@@ -2687,19 +2762,17 @@ namespace Meade.net.Telescope.UnitTests
{
var digitsRA = 2;
- var rightAscension = 1;
+ _testProperties.rightAscension = 1;
+
var declination = 2;
- var telescopeRaResult = "HH:MM:SS";
var telescopeDecResult = "s12*34’56";
_sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("0");
- _sharedResourcesWrapperMock.Setup(x => x.SendChar($":Sr{telescopeRaResult}#")).Returns("1");
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#")).Returns(telescopeDecResult);
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeRaResult);
- _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(rightAscension);
- _utilMock.Setup(x => x.HoursToHMS(rightAscension, ":", ":", ":", digitsRA)).Returns(telescopeRaResult);
+ _sharedResourcesWrapperMock.Setup(x => x.SendChar($":Sr{_testProperties.telescopeRaResult}#")).Returns("1");
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#", true)).Returns(telescopeDecResult);
+ _utilMock.Setup(x => x.HoursToHMS(_testProperties.rightAscension, ":", ":", ":", digitsRA)).Returns(_testProperties.telescopeRaResult);
_utilMock.Setup(x => x.DMSToDegrees(telescopeDecResult)).Returns(declination);
_utilMock.Setup(x => x.DegreesToDMS(declination, "*", ":", ":", digitsRA)).Returns(telescopeDecResult);
@@ -2717,10 +2790,10 @@ namespace Meade.net.Telescope.UnitTests
ConnectTelescope();
- _telescope.SlewToCoordinatesAsync(rightAscension, declination);
+ _telescope.SlewToCoordinatesAsync(_testProperties.rightAscension, declination);
//_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny()), Times.Exactly(iterations));
- Assert.That(_telescope.TargetRightAscension, Is.EqualTo(rightAscension));
+ Assert.That(_telescope.TargetRightAscension, Is.EqualTo(_testProperties.rightAscension));
Assert.That(_telescope.TargetDeclination, Is.EqualTo(declination));
_sharedResourcesWrapperMock.Verify( x => x.SendChar(":MS#"), Times.Once);
}
@@ -2735,31 +2808,25 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void SlewToCoordinates_WhenCalled_ThenSetsTargetAndSlews()
{
- var rightAscension = 1;
+ _testProperties.rightAscension = 1;
var declination = 2;
var telescopeDecResult = "s12*34’56";
var dmsResult = 1.2;
- var telescopeRaResult = "HH:MM:SS";
- var hmsResult = 1.3;
var digitsRA = 2;
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#")).Returns(telescopeDecResult);
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeRaResult);
- _sharedResourcesWrapperMock.Setup(x => x.SendChar($":Sr{telescopeRaResult}#")).Returns("1");
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#", true)).Returns(telescopeDecResult);
+ _sharedResourcesWrapperMock.Setup(x => x.SendChar($":Sr{_testProperties.telescopeRaResult}#")).Returns("1");
- _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(hmsResult);
- _utilMock.Setup(x => x.HoursToHMS(rightAscension, ":", ":", ":", digitsRA)).Returns(telescopeRaResult);
- _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(rightAscension);
+ _utilMock.Setup(x => x.HoursToHMS(_testProperties.rightAscension, ":", ":", ":", digitsRA)).Returns(_testProperties.telescopeRaResult);
_utilMock.Setup(x => x.DMSToDegrees(telescopeDecResult)).Returns(dmsResult);
_utilMock.Setup(x => x.DegreesToDMS(declination, "*", ":", ":", digitsRA)).Returns(telescopeDecResult);
-
_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#", true)).Returns(() =>
{
slewCounter++;
if (slewCounter <= iterations)
@@ -2769,8 +2836,8 @@ namespace Meade.net.Telescope.UnitTests
ConnectTelescope();
- _telescope.SlewToCoordinates(rightAscension, declination);
- Assert.That(_telescope.TargetRightAscension, Is.EqualTo(rightAscension));
+ _telescope.SlewToCoordinates(_testProperties.rightAscension, declination);
+ Assert.That(_telescope.TargetRightAscension, Is.EqualTo(_testProperties.rightAscension));
Assert.That(_telescope.TargetDeclination, Is.EqualTo(dmsResult));
_sharedResourcesWrapperMock.Verify(x => x.SendChar(":MS#"), Times.Once);
@@ -2823,18 +2890,19 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void SlewToAltAzAsync_WhenAltAndAzValid_ThenConvertsToRADec()
{
+ _testProperties.rightAscension = 20;
+
var altitude = 30;
var azimuth = 45;
- 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#", true)).Returns("10/15/20");
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GL#", true)).Returns("20:15:10");
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GG#", true)).Returns("-1.0");
_astroMathsMock
.Setup(x => x.ConvertHozToEq(It.IsAny(), It.IsAny(), It.IsAny(),
- It.IsAny())).Returns(new EquatorialCoordinates { Declination = declination, RightAscension = rightAscension });
+ It.IsAny())).Returns(new EquatorialCoordinates { Declination = declination, RightAscension = _testProperties.rightAscension });
_sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("0");
@@ -2844,8 +2912,8 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Setup(x => x.SendChar($":Sr{telescopeRaResult}#")).Returns("1");
- _utilMock.Setup(x => x.HoursToHMS(rightAscension, ":", ":", ":", digitsRA)).Returns(telescopeRaResult);
- _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(rightAscension);
+ _utilMock.Setup(x => x.HoursToHMS(_testProperties.rightAscension, ":", ":", ":", digitsRA)).Returns(telescopeRaResult);
+ _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(_testProperties.rightAscension);
_utilMock.Setup(x => x.DegreesToDMS(declination, "*", ":", ":", digitsRA)).Returns(telescopeDecResult);
_utilMock.Setup(x => x.DMSToDegrees(telescopeDecResult)).Returns(declination);
@@ -2853,7 +2921,7 @@ namespace Meade.net.Telescope.UnitTests
_telescope.SlewToAltAzAsync(azimuth, altitude);
- Assert.That(_telescope.TargetRightAscension, Is.EqualTo(rightAscension));
+ Assert.That(_telescope.TargetRightAscension, Is.EqualTo(_testProperties.rightAscension));
Assert.That(_telescope.TargetDeclination, Is.EqualTo(declination));
_sharedResourcesWrapperMock.Verify(x => x.SendChar(":MS#"), Times.Once);
}
@@ -2868,35 +2936,29 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void SlewToAltAz_WhenCalled_ThenSetsTargetAndSlews()
{
- var rightAscension = 10.0;
+ _testProperties.rightAscension = 10.0;
var declination = 20;
var azimuth = 30;
var altitude = 40;
- var telescopeRaResult = "HH:MM:SS";
- var hmsResult = 10.0;
-
- _utilMock.Setup(x => x.HoursToHMS(rightAscension, ":", ":", ":", 2)).Returns(telescopeRaResult);
- _utilMock.Setup(x => x.DegreesToDMS(declination, "*", ":", ":", 2)).Returns(telescopeRaResult);
- _utilMock.Setup(x => x.DMSToDegrees(telescopeRaResult)).Returns(declination);
-
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeRaResult);
- _utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(hmsResult);
+ _utilMock.Setup(x => x.HoursToHMS(_testProperties.rightAscension, ":", ":", ":", 2)).Returns(_testProperties.telescopeRaResult);
+ _utilMock.Setup(x => x.DegreesToDMS(declination, "*", ":", ":", 2)).Returns(_testProperties.telescopeRaResult);
+ _utilMock.Setup(x => x.DMSToDegrees(_testProperties.telescopeRaResult)).Returns(declination);
- _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#", true)).Returns("10/15/20");
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GL#", true)).Returns("20:15:10");
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GG#", true)).Returns("-1.0");
_sharedResourcesWrapperMock.Setup(x => x.SendChar(":Sd+HH:MM:SS#")).Returns("1");
_astroMathsMock
.Setup(x => x.ConvertHozToEq(It.IsAny(), It.IsAny(), It.IsAny(),
- It.IsAny())).Returns(new EquatorialCoordinates { Declination = declination, RightAscension = rightAscension });
+ It.IsAny())).Returns(new EquatorialCoordinates { Declination = declination, RightAscension = _testProperties.rightAscension });
_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#", true)).Returns(() =>
{
slewCounter++;
if (slewCounter <= iterations)
@@ -2908,7 +2970,7 @@ namespace Meade.net.Telescope.UnitTests
_telescope.SlewToAltAz( azimuth, altitude);
- Assert.That(_telescope.TargetRightAscension, Is.EqualTo(rightAscension));
+ Assert.That(_telescope.TargetRightAscension, Is.EqualTo(_testProperties.rightAscension));
Assert.That(_telescope.TargetDeclination, Is.EqualTo(declination));
_sharedResourcesWrapperMock.Verify(x => x.SendChar(":MS#"), Times.Once);
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny()), Times.Exactly(iterations));
@@ -2932,22 +2994,16 @@ namespace Meade.net.Telescope.UnitTests
var telescopeLongitude = "350";
var telescopeLongitudeValue = 350;
-
- var telescopeLatitude = "HH:MM:SS";
- var telescopeLatitudeValue = 1.2;
-
+
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#", true)).Returns("10/15/20");
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GL#", true)).Returns("20:15:10");
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GG#", true)).Returns("-1.0");
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":Gg#")).Returns(telescopeLongitude);
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":Gg#", true)).Returns(telescopeLongitude);
_utilMock.Setup(x => x.DMSToDegrees(telescopeLongitude)).Returns(telescopeLongitudeValue);
-
- _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);
_astroMathsMock.Setup(x => x.ConvertEqToHoz(mockHourAngle, It.IsAny(), It.IsAny())).Returns(new HorizonCoordinates { Altitude = 45, Azimuth = expectedAzimuth });
@@ -2978,21 +3034,15 @@ namespace Meade.net.Telescope.UnitTests
var telescopeLongitude = "350";
var telescopeLongitudeValue = 350;
- var telescopeLatitude = "HH:MM:SS";
- var telescopeLatitudeValue = 1.2;
-
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#", true)).Returns("10/15/20");
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GL#", true)).Returns("20:15:10");
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":GG#", true)).Returns("-1.0");
- _sharedResourcesWrapperMock.Setup(x => x.SendString(":Gg#")).Returns(telescopeLongitude);
+ _sharedResourcesWrapperMock.Setup(x => x.SendString(":Gg#", true)).Returns(telescopeLongitude);
_utilMock.Setup(x => x.DMSToDegrees(telescopeLongitude)).Returns(telescopeLongitudeValue);
- _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);
_astroMathsMock.Setup(x => x.ConvertEqToHoz(mockHourAngle, It.IsAny(), It.IsAny())).Returns(new HorizonCoordinates { Altitude = expectedAltitude, Azimuth = 200 });
@@ -3023,7 +3073,272 @@ namespace Meade.net.Telescope.UnitTests
var isSloSlewing = _telescope.Slewing;
Assert.That(isSloSlewing, Is.False);
- _sharedResourcesWrapperMock.Verify( x => x.SendString(":D#"), Times.Once);
+ _sharedResourcesWrapperMock.Verify( x => x.SendString(":D#", true), Times.Once);
+ }
+
+ [Test]
+ public void AbortSlew_WhenParked_ThenThrowsParkedException()
+ {
+ ConnectTelescope();
+ _telescope.Park();
+
+ Assert.Throws(() => { _telescope.AbortSlew(); });
+ }
+
+ [Test]
+ public void MoveAxis_WhenParked_ThenThrowsParkedException()
+ {
+ ConnectTelescope();
+ _telescope.Park();
+
+ Assert.Throws(() => { _telescope.MoveAxis(TelescopeAxes.axisPrimary, 0); });
+ }
+
+ [Test]
+ public void PulseGuide_WhenParked_ThenThrowsParkedException()
+ {
+ ConnectTelescope();
+ _telescope.Park();
+
+ Assert.Throws(() => { _telescope.PulseGuide(GuideDirections.guideEast, 0); });
+ }
+
+ [Test]
+ public void SlewToAltAz_WhenParked_ThenThrowsParkedException()
+ {
+ ConnectTelescope();
+ _telescope.Park();
+
+ Assert.Throws(() => { _telescope.SlewToAltAz(0, 0); });
+ }
+
+ [Test]
+ public void SlewToAltAzAsync_WhenParked_ThenThrowsParkedException()
+ {
+ ConnectTelescope();
+ _telescope.Park();
+
+ Assert.Throws(() => { _telescope.SlewToAltAzAsync(0, 0); });
+ }
+
+ [Test]
+ public void SlewToCoordinates_WhenParked_ThenThrowsParkedException()
+ {
+ ConnectTelescope();
+ _telescope.Park();
+
+ Assert.Throws(() => { _telescope.SlewToCoordinates(0, 0); });
+ }
+
+ [Test]
+ public void SlewToCoordinatesAsync_WhenParked_ThenThrowsParkedException()
+ {
+ ConnectTelescope();
+ _telescope.Park();
+
+ Assert.Throws(() => { _telescope.SlewToCoordinatesAsync(0, 0); });
+ }
+
+ [Test]
+ public void SlewToTarget_WhenParked_ThenThrowsParkedException()
+ {
+ ConnectTelescope();
+ _telescope.Park();
+
+ Assert.Throws(() => { _telescope.SlewToTarget(); });
+ }
+
+ [Test]
+ public void SlewToTargetAsync_WhenParked_ThenThrowsParkedException()
+ {
+ ConnectTelescope();
+ _telescope.Park();
+
+ Assert.Throws(() => { _telescope.SlewToTargetAsync(); });
+ }
+
+ [Test]
+ public void SyncToCoordinates_WhenParked_ThenThrowsParkedException()
+ {
+ ConnectTelescope();
+ _telescope.Park();
+
+ Assert.Throws(() => { _telescope.SyncToCoordinates(0,0); });
+ }
+
+ [Test]
+ public void SyncToTarget_WhenParked_ThenThrowsParkedException()
+ {
+ ConnectTelescope();
+ _telescope.Park();
+
+ Assert.Throws(() => { _telescope.SyncToTarget(); });
+ }
+
+ [Test]
+ public void TargetDeclination_WhenParked_ThenThrowsParkedException()
+ {
+ ConnectTelescope();
+ _telescope.Park();
+
+ Assert.Throws(() => { _telescope.TargetDeclination = 1; });
+ }
+
+ [Test]
+ public void TargetRightAscension_WhenParked_ThenThrowsParkedException()
+ {
+ ConnectTelescope();
+ _telescope.Park();
+
+ Assert.Throws(() => { _telescope.TargetRightAscension = 1; });
+ }
+
+ [Test]
+ public void TrackingRate_WhenParked_ThenThrowsParkedException()
+ {
+ ConnectTelescope();
+ _telescope.Park();
+
+ Assert.Throws(() => { _telescope.TrackingRate = DriveRates.driveLunar; });
+ }
+
+
+ [TestCase(ParkedBehaviour.NoCoordinates, true)]
+ [TestCase(ParkedBehaviour.LastGoodPosition, false)]
+ [TestCase(ParkedBehaviour.ReportCoordinates, false)]
+ public void UTCDate_WhenParked_ReturnsExpectedResult(ParkedBehaviour behaviour, bool throwsException)
+ {
+ _profileProperties.ParkedBehaviour = behaviour;
+ DateTime testNow = DateTime.ParseExact("2021-10-03T20:36:25", "yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture);
+ _clockMock.Setup(x => x.UtcNow).Returns(() => { return testNow; });
+
+ ConnectTelescope();
+ _telescope.Park();
+
+ if (throwsException)
+ Assert.Throws(() => { var date = _telescope.UTCDate; });
+ else
+ {
+ DateTime date = DateTime.MinValue;
+ Assert.DoesNotThrow(() => { date = _telescope.UTCDate; });
+
+ Assert.That(date, Is.EqualTo(testNow));
+ }
+ }
+
+ [TestCase(ParkedBehaviour.NoCoordinates, true)]
+ [TestCase(ParkedBehaviour.LastGoodPosition, false)]
+ [TestCase(ParkedBehaviour.ReportCoordinates, false)]
+ public void SiteLatitude_WhenParked_ThenThrowsParkedException(ParkedBehaviour behaviour, bool throwsParkedException)
+ {
+ _profileProperties.ParkedBehaviour = behaviour;
+
+ ConnectTelescope();
+ var siteLatitude = _telescope.SiteLatitude;
+ _telescope.Park();
+
+ if (throwsParkedException)
+ Assert.Throws(() => { var lat = _telescope.SiteLatitude; });
+ else
+ {
+ var lat = _telescope.SiteLatitude;
+ Assert.That(lat, Is.EqualTo(siteLatitude));
+ }
+ }
+
+ [TestCase(ParkedBehaviour.NoCoordinates, true)]
+ [TestCase(ParkedBehaviour.LastGoodPosition, false)]
+ [TestCase(ParkedBehaviour.ReportCoordinates, false)]
+ public void SiteLongitude_WhenParked_ThenThrowsParkedException(ParkedBehaviour behaviour, bool throwsParkedException)
+ {
+ _profileProperties.ParkedBehaviour = behaviour;
+
+ ConnectTelescope();
+ var siteLongitude = _telescope.SiteLongitude;
+ _telescope.Park();
+
+ if (throwsParkedException)
+ Assert.Throws(() => { var siteLong = _telescope.SiteLongitude; });
+ else
+ {
+ var l = _telescope.SiteLongitude;
+ Assert.That(l, Is.EqualTo(siteLongitude));
+ }
+
+ }
+
+ [TestCase(ParkedBehaviour.NoCoordinates)]
+ [TestCase(ParkedBehaviour.LastGoodPosition)]
+ [TestCase(ParkedBehaviour.ReportCoordinates)]
+ public void Declination_WhenParked_ThenThrowsParkedException(ParkedBehaviour behaviour)
+ {
+ _profileProperties.ParkedBehaviour = behaviour;
+ _profileProperties.ParkedAlt = 0;
+ _profileProperties.ParkedAz = 180;
+ DateTime testNow = DateTime.ParseExact("2021-10-03T20:36:25", "yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture);
+
+ var declination = 45;
+
+ _clockMock.Setup(x => x.UtcNow).Returns(() => { return testNow; });
+
+ _astroMathsMock
+ .Setup(x => x.ConvertHozToEq(It.IsAny(), It.IsAny(), It.IsAny(),
+ It.IsAny())).Returns(new EquatorialCoordinates { Declination = declination, RightAscension = _testProperties.rightAscension });
+
+ ConnectTelescope();
+ _telescope.Park();
+
+ switch (_profileProperties.ParkedBehaviour)
+ {
+ case ParkedBehaviour.LastGoodPosition:
+ var lastGoodDec = _telescope.Declination;
+ Assert.That(lastGoodDec, Is.EqualTo(0));
+ break;
+ case ParkedBehaviour.ReportCoordinates:
+ var dec = _telescope.Declination;
+ Assert.That(dec, Is.EqualTo(declination));
+ break;
+ default:
+ Assert.Throws(() => { var d = _telescope.Declination; });
+ break;
+ }
+ }
+
+ [TestCase(ParkedBehaviour.NoCoordinates)]
+ [TestCase(ParkedBehaviour.LastGoodPosition)]
+ [TestCase(ParkedBehaviour.ReportCoordinates)]
+ public void RightAscension_WhenParked_ThenThrowsParkedException(ParkedBehaviour behaviour)
+ {
+ _profileProperties.ParkedBehaviour = behaviour;
+ _profileProperties.ParkedAlt = 0;
+ _profileProperties.ParkedAz = 180;
+ DateTime testNow = DateTime.ParseExact("2021-10-03T20:36:25", "yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture);
+
+ var declination = 45;
+
+ _clockMock.Setup(x => x.UtcNow).Returns(() => { return testNow; });
+
+ _astroMathsMock
+ .Setup(x => x.ConvertHozToEq(It.IsAny(), It.IsAny(), It.IsAny(),
+ It.IsAny())).Returns(new EquatorialCoordinates { Declination = declination, RightAscension = _testProperties.rightAscension });
+
+ ConnectTelescope();
+ _telescope.Park();
+
+ switch (_profileProperties.ParkedBehaviour)
+ {
+ case ParkedBehaviour.LastGoodPosition:
+ var lastGoodRa = _telescope.RightAscension;
+ Assert.That(lastGoodRa, Is.EqualTo(1.2));
+ break;
+ case ParkedBehaviour.ReportCoordinates:
+ var reportRa = _telescope.RightAscension;
+ Assert.That(reportRa, Is.EqualTo(_testProperties.rightAscension));
+ break;
+ default:
+ Assert.Throws(() => { var ra = _telescope.RightAscension; });
+ break;
+ }
}
}
}
\ 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 cfae8a4..92ec7b9 100644
--- a/Meade.net.Telescope/Meade.net.Telescope.csproj
+++ b/Meade.net.Telescope/Meade.net.Telescope.csproj
@@ -122,7 +122,6 @@
-
diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs
index ada8098..81605b3 100644
--- a/Meade.net.Telescope/Telescope.cs
+++ b/Meade.net.Telescope/Telescope.cs
@@ -357,7 +357,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, raw);
//throw new ASCOM.MethodNotImplementedException("CommandString");
}
@@ -409,6 +409,9 @@ namespace ASCOM.Meade.net
{
LogMessage("Connected Set", "Making first connection telescope adjustments");
+ LogMessage("Connected Set", $"Site Longitude: {SiteLongitude}");
+ LogMessage("Connected Set", $"Site Latitude: {SiteLatitude}");
+
//These settings are applied only when the first device connects to the telescope.
SetLongFormat(true);
@@ -418,6 +421,36 @@ namespace ASCOM.Meade.net
}
SetTelescopePrecision("Connect");
+
+ LogMessage("Connected Set", $"SendDateTime: {SendDateTime}");
+ if (SendDateTime)
+ {
+ if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS)
+ {
+ LogMessage("Connected Set", $"LX200GPS Detecting if daylight savings message on screen: {SendDateTime}");
+ var displayText = Action("Handbox", "readdisplay");
+ LogMessage("Connected Set", $"Current Handset display: {displayText}");
+ if (displayText.Contains("Daylight"))
+ {
+ LogMessage("Connected Set", $"LX200GPS Setting Date time and bypassing settings screens: {SendDateTime}");
+ BypassHandboxEntryForAutostarII();
+ }
+ else
+ {
+ LogMessage("Connected Set", $"LX200GPS Sending current date and time: {SendDateTime}");
+ SendCurrentDateTime("Connect");
+ LogMessage("Connected Set", $"LX200GPS Attempting manual bypass of prompts: {SendDateTime}");
+ ApplySkipAutoStarPrompts("Connect");
+ }
+
+ }
+ else
+ {
+ LogMessage("Connected Set", "Autostar Attempting manual bypass of prompts");
+ ApplySkipAutoStarPrompts("Connect");
+ SendCurrentDateTime("Connect");
+ }
+ }
}
else
{
@@ -447,6 +480,48 @@ namespace ASCOM.Meade.net
}
}
+ private void SendCurrentDateTime(string connect)
+ {
+ if (SendDateTime)
+ {
+ UTCDate = _clock.UtcNow;
+ }
+ }
+
+ private void ApplySkipAutoStarPrompts(string connect)
+ {
+ if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS)
+ {
+ var displayText = Action("Handbox", "readdisplay");
+
+ if (displayText.Contains("Daylight"))
+ {
+ for (var i = 0; i < 3; i++)
+ {
+ Action("Handbox", "enter");
+ _utilities.WaitForMilliseconds(2000);
+ }
+ }
+ }
+ else if (SharedResourcesWrapper.ProductName == TelescopeList.Autostar497)
+ {
+ var i = 10;
+ while (i > 0)
+ {
+ var displayText = Action("Handbox", "readdisplay");
+ if (displayText.Contains("Align:"))
+ {
+ i = 0;
+ continue;
+ }
+
+ Action("Handbox", "mode");
+ _utilities.WaitForMilliseconds(500);
+ i--;
+ }
+ }
+ }
+
private void SetTelescopePrecision(string propertyName)
{
switch (Precision.ToLower())
@@ -558,7 +633,7 @@ namespace ASCOM.Meade.net
if((Math.Abs(RightAscension - rightTargetAscension ) <= eps) &&
(Math.Abs(Declination - targetDeclination) <= eps))
{
- LogMessage("IsTargetCoordinateInitRequired", $"0 diff -> false");
+ LogMessage("IsTargetCoordinateInitRequired", "0 diff -> false");
_isTargetCoordinateInitRequired = false;
return _isTargetCoordinateInitRequired;
}
@@ -582,7 +657,7 @@ namespace ASCOM.Meade.net
}
catch (Exception ex)
{
- LogMessage("InitTargetCoordinates", $"Error sync telescope position", ex.Message);
+ LogMessage("InitTargetCoordinates", "Error sync telescope position", ex.Message);
}
}
@@ -811,6 +886,7 @@ namespace ASCOM.Meade.net
public void AbortSlew()
{
CheckConnected("AbortSlew");
+ CheckParked();
LogMessage("AbortSlew", "Aborting slew");
SharedResourcesWrapper.SendBlind(":Q#");
@@ -822,6 +898,12 @@ namespace ASCOM.Meade.net
SetSlewingMinEndTime();
}
+ private void CheckParked()
+ {
+ if (AtPark)
+ throw new ParkedException("Telescope is parked");
+ }
+
public AlignmentModes AlignmentMode
{
get
@@ -907,7 +989,7 @@ namespace ASCOM.Meade.net
get
{
CheckConnected("Altitude Get");
-
+
var altAz = CalcAltAzFromTelescopeEqData();
LogMessage("Altitude", $"{altAz.Altitude}");
return altAz.Altitude;
@@ -1174,27 +1256,49 @@ namespace ASCOM.Meade.net
{
get
{
+ CheckConnected("CanUnpark");
+
//todo make this return false for non LX-200 GPS telescopes
LogMessage("CanUnpark", "Get - " + true);
- return true;
+ return SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS;
}
}
+ private double _lastGoodDeclination;
+
public double Declination
{
get
{
CheckConnected("Declination Get");
+ try
+ {
+ CheckParked();
- 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.
+ 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.
- double declination = _utilities.DMSToDegrees(result);
+ double declination = _utilities.DMSToDegrees(result);
- LogMessage("Declination", $"Get - {result} convert to {declination} {_utilitiesExtra.DegreesToDMS(declination, ":", ":")}");
- return declination;
+ LogMessage("Declination", $"Get - {result} convert to {declination} {_utilitiesExtra.DegreesToDMS(declination, ":", ":")}");
+ _lastGoodDeclination = declination;
+ return declination;
+ }
+ catch (ParkedException)
+ {
+ switch (ParkedBehaviour)
+ {
+ case ParkedBehaviour.LastGoodPosition:
+ return _lastGoodDeclination;
+ case ParkedBehaviour.ReportCoordinates:
+ var raDec = _astroMaths.ConvertHozToEq(UTCDate, SiteLatitude, SiteLongitude, ParkedAltAz);
+ return raDec.Declination;
+ default:
+ throw;
+ }
+ }
}
}
@@ -1346,6 +1450,7 @@ namespace ASCOM.Meade.net
{
LogMessage("MoveAxis", $"Axis={axis} rate={rate}");
CheckConnected("MoveAxis");
+ CheckParked();
var absRate = Math.Abs(rate);
@@ -1454,10 +1559,11 @@ namespace ASCOM.Meade.net
if (AtPark)
return;
+ //Setting park to true before sending the park command as the Autostar and Audiostar stop serial communications once the park command has been issued.
+ AtPark = true;
SharedResourcesWrapper.SendBlind(":hP#");
//:hP# Autostar, Autostar II and LX 16”Slew to Park Position
//Returns: Nothing
- AtPark = true;
}
private bool _userNewerPulseGuiding = true;
@@ -1468,6 +1574,7 @@ namespace ASCOM.Meade.net
try
{
CheckConnected("PulseGuide");
+ CheckParked();
if (IsSlewingToTarget())
throw new InvalidOperationException("Unable to PulseGuide whilst slewing to target.");
@@ -1577,21 +1684,43 @@ namespace ASCOM.Meade.net
var hms = $"{token[0]}:{seconds}";
return _utilities.HMSToHours(hms);
}
+
+ double _lastGoodRightAsension;
public double RightAscension
{
get
{
CheckConnected("RightAscension Get");
- 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
+ try
+ {
+ CheckParked();
- double rightAscension = HmToHours(result);
+ 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
- LogMessage("RightAscension", $"Get - {result} convert to {rightAscension} {_utilitiesExtra.HoursToHMS(rightAscension)}");
- return rightAscension;
+ double rightAscension = HmToHours(result);
+
+ LogMessage("RightAscension", $"Get - {result} convert to {rightAscension} {_utilitiesExtra.HoursToHMS(rightAscension)}");
+ _lastGoodRightAsension = rightAscension;
+ return rightAscension;
+ }
+ catch (ParkedException)
+ {
+ switch (ParkedBehaviour)
+ {
+ case ParkedBehaviour.LastGoodPosition:
+ return _lastGoodRightAsension;
+ case ParkedBehaviour.ReportCoordinates:
+ var raDec = _astroMaths.ConvertHozToEq(UTCDate, SiteLatitude, SiteLongitude, ParkedAltAz);
+ return raDec.RightAscension;
+ default:
+ throw;
+ }
+ }
+
}
}
@@ -1640,7 +1769,7 @@ namespace ASCOM.Meade.net
double siderealTime = 0.0;
using (var novas = new NOVAS31())
{
- var jd = _utilities.DateUTCToJulian(DateTime.UtcNow);
+ var jd = _utilities.DateUTCToJulian(_clock.UtcNow);
novas.SiderealTime(jd, 0, novas.DeltaT(jd),
GstType.GreenwichApparentSiderealTime,
Method.EquinoxBased,
@@ -1675,30 +1804,49 @@ namespace ASCOM.Meade.net
LogMessage("SiteElevation", $"Set: {value}");
if (Math.Abs(value - base.SiteElevation) < 0.1)
{
- LogMessage("SiteElevation", $"Set: no change detected");
+ LogMessage("SiteElevation", "Set: no change detected");
return;
}
LogMessage("SiteElevation", $"Set: {value} was {base.SiteElevation}");
base.SiteElevation = value;
- base.UpdateSiteElevation();
+ UpdateSiteElevation();
}
}
+ private double? _lastGoodSiteLatitude;
public double SiteLatitude
{
get
{
CheckConnected("SiteLatitude Get");
+ try
+ {
+ CheckParked();
- var latitude = SharedResourcesWrapper.SendString(":Gt#");
- //:Gt# Get Current Site Latitude
- //Returns: sDD* MM#
- //The latitude of the current site. Positive inplies North latitude.
+ var latitude = SharedResourcesWrapper.SendString(":Gt#");
+ //:Gt# Get Current Site Latitude
+ //Returns: sDD* MM#
+ //The latitude of the current site. Positive inplies North latitude.
- var siteLatitude = _utilities.DMSToDegrees(latitude);
- LogMessage("SiteLatitude Get", $"{_utilitiesExtra.DegreesToDMS(siteLatitude)}");
- return siteLatitude;
+ if (latitude != null)
+ {
+ var siteLatitude = _utilities.DMSToDegrees(latitude);
+ LogMessage("SiteLatitude Get", $"{_utilitiesExtra.DegreesToDMS(siteLatitude)}");
+
+ _lastGoodSiteLatitude = siteLatitude;
+ return siteLatitude;
+ }
+
+ throw new InvalidOperationException("unable to get site latitude from telescope.");
+ }
+ catch (ParkedException)
+ {
+ if (ParkedBehaviour == ParkedBehaviour.NoCoordinates)
+ throw;
+
+ return _lastGoodSiteLatitude.Value;
+ }
}
set
{
@@ -1727,26 +1875,42 @@ namespace ASCOM.Meade.net
//1 - Valid
if (result != "1")
throw new InvalidOperationException("Failed to set site latitude.");
+
+ _lastGoodSiteLatitude = value;
}
}
+ private double _lastGoodSiteLongitude;
+
public double SiteLongitude
{
get
{
CheckConnected("SiteLongitude Get");
+ try
+ {
+ CheckParked();
- var longitude = SharedResourcesWrapper.SendString(":Gg#");
- //:Gg# Get Current Site Longitude
- //Returns: sDDD*MM#
- //The current site Longitude. East Longitudes are expressed as negative
- double siteLongitude = -_utilities.DMSToDegrees(longitude);
+ var longitude = SharedResourcesWrapper.SendString(":Gg#");
+ //: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;
-
- LogMessage("SiteLongitude Get", $"{_utilitiesExtra.DegreesToDMS(siteLongitude)}");
- return siteLongitude;
+ if (siteLongitude < -180)
+ siteLongitude = siteLongitude + 360;
+
+ LogMessage("SiteLongitude Get", $"{_utilitiesExtra.DegreesToDMS(siteLongitude)}");
+ _lastGoodSiteLongitude = siteLongitude;
+ return siteLongitude;
+ }
+ catch (ParkedException)
+ {
+ if (ParkedBehaviour == ParkedBehaviour.NoCoordinates)
+ throw;
+
+ return _lastGoodSiteLongitude;
+ }
}
set
{
@@ -1780,6 +1944,8 @@ namespace ASCOM.Meade.net
//1 - Valid
if (result != "1")
throw new InvalidOperationException("Failed to set site longitude.");
+
+ _lastGoodSiteLongitude = value;
}
}
@@ -1803,6 +1969,7 @@ namespace ASCOM.Meade.net
{
LogMessage("SlewToAltAz", $"Az=~{azimuth} Alt={altitude}");
CheckConnected("SlewToAltAz");
+ CheckParked();
SlewToAltAzAsync(azimuth, altitude);
@@ -1815,6 +1982,7 @@ namespace ASCOM.Meade.net
public void SlewToAltAzAsync(double azimuth, double altitude)
{
CheckConnected("SlewToAltAzAsync");
+ CheckParked();
if (altitude > 90)
throw new InvalidValueException("Altitude cannot be greater than 90.");
@@ -1855,6 +2023,7 @@ namespace ASCOM.Meade.net
private void DoSlewAsync(bool polar)
{
CheckConnected("DoSlewAsync");
+ CheckParked();
SharedResourcesWrapper.Lock(() =>
{
@@ -1919,6 +2088,7 @@ namespace ASCOM.Meade.net
{
LogMessage("SlewToCoordinates", $"Ra={rightAscension}, Dec={declination}");
CheckConnected("SlewToCoordinates");
+ CheckParked();
SlewToCoordinatesAsync(rightAscension, declination);
@@ -1934,6 +2104,7 @@ namespace ASCOM.Meade.net
{
LogMessage("SlewToCoordinatesAsync", $"Ra={rightAscension}, Dec={declination}");
CheckConnected("SlewToCoordinatesAsync");
+ CheckParked();
SharedResourcesWrapper.Lock(() =>
{
@@ -1949,6 +2120,7 @@ namespace ASCOM.Meade.net
{
LogMessage("SlewToTarget", "Executing");
CheckConnected("SlewToTarget");
+ CheckParked();
SlewToTargetAsync();
while (Slewing)
@@ -1962,6 +2134,7 @@ namespace ASCOM.Meade.net
public void SlewToTargetAsync()
{
CheckConnected("SlewToTargetAsync");
+ CheckParked();
if (TargetDeclination.Equals(InvalidParameter) || TargetRightAscension.Equals(InvalidParameter))
throw new InvalidOperationException("No target selected to slew to.");
@@ -2007,13 +2180,18 @@ namespace ASCOM.Meade.net
private bool GetSlewing()
{
- if (!Connected) return false;
+ var result = false;
+ try
+ {
+ if (Connected)
+ result = MovingAxis() || IsSlewingToTarget();
+ }
+ finally
+ {
+ LogMessage("GetSlewing", $"Result = {result}");
+ }
-
- if (MovingAxis())
- return true;
-
- return IsSlewingToTarget();
+ return result;
}
private bool IsSlewingToTarget()
@@ -2023,7 +2201,15 @@ namespace ASCOM.Meade.net
if (_isGuiding)
return false;
- var result = SharedResourcesWrapper.SendString(":D#");
+ string result;
+ try
+ {
+ result = SharedResourcesWrapper.SendString(":D#");
+ }
+ catch (TimeoutException)
+ {
+ result = string.Empty;
+ }
//: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.
@@ -2045,6 +2231,12 @@ namespace ASCOM.Meade.net
return isSlewing;
}
+ if (result.Contains("\u007f"))
+ {
+ isSlewing = true;
+ return isSlewing;
+ }
+
////classic LX200 return bar with 32 chars. FF is contained from left to right when slewing
//byte[] ba = Encoding.Default.GetBytes(result);
////replace fill chars not belonging to a slew bar. Are there others? The bar character is a FF in hex.
@@ -2060,13 +2252,13 @@ namespace ASCOM.Meade.net
////a 0 movement will solved that lock if the target coordinates are set to the current coordinates.
//if (IsTargetCoordinateInitRequired())
// InitTargetCoordinates();
-
- return isSlewing;
}
finally
{
LogMessage("IsSlewingToTarget", $"IsSlewing = {isSlewing} : result = {result ?? ""}");
}
+
+ return isSlewing;
}
public void SyncToAltAz(double azimuth, double altitude)
@@ -2080,6 +2272,7 @@ namespace ASCOM.Meade.net
LogMessage("SyncToCoordinates", $"RA={rightAscension} Dec={declination}");
LogMessage("SyncToCoordinates", $"RA={_utilitiesExtra.HoursToHMS(rightAscension)} Dec={_utilitiesExtra.HoursToHMS(declination)}");
CheckConnected("SyncToCoordinates");
+ CheckParked();
SharedResourcesWrapper.Lock(() =>
{
@@ -2094,7 +2287,8 @@ namespace ASCOM.Meade.net
{
LogMessage("SyncToTarget", "Executing");
CheckConnected("SyncToTarget");
-
+ CheckParked();
+
var result = SharedResourcesWrapper.SendString(":CM#");
//:CM# Synchronizes the telescope's position with the currently selected database object's coordinates.
//Returns:
@@ -2147,6 +2341,7 @@ namespace ASCOM.Meade.net
LogMessage("TargetDeclination Set", $"{value}");
CheckConnected("TargetDeclination Set");
+ CheckParked();
if (value > 90)
throw new InvalidValueException("Declination cannot be greater than 90.");
@@ -2202,6 +2397,7 @@ namespace ASCOM.Meade.net
{
LogMessage("TargetRightAscension Set", $"{value}");
CheckConnected("TargetRightAscension Set");
+ CheckParked();
if (value < 0)
throw new InvalidValueException("Right ascension value cannot be below 0");
@@ -2270,6 +2466,7 @@ namespace ASCOM.Meade.net
{
LogMessage("TrackingRate Set", $"{value}");
CheckConnected("TrackingRate Set");
+ CheckParked();
switch (value)
{
@@ -2338,46 +2535,56 @@ namespace ASCOM.Meade.net
get
{
CheckConnected("UTCDate Get");
-
LogMessage("UTCDate", "Get started");
-
- var telescopeDateDetails = SharedResourcesWrapper.Lock(() =>
+ try
{
- var tdd = new TelescopeDateDetails
+ CheckParked();
+
+ var telescopeDateDetails = SharedResourcesWrapper.Lock(() =>
{
- TelescopeDate = SharedResourcesWrapper.SendString(":GC#"),
- //:GC# Get current date.
- //Returns: MM/DD/YY#
- //The current local calendar date for the telescope.
- TelescopeTime = SharedResourcesWrapper.SendString(":GL#"),
- //:GL# Get Local Time in 24 hour format
- //Returns: HH:MM:SS#
- //The Local Time in 24 - hour Format
- UtcCorrection = GetUtcCorrection()
- };
+ var tdd = new TelescopeDateDetails
+ {
+ TelescopeDate = SharedResourcesWrapper.SendString(":GC#"),
+ //:GC# Get current date.
+ //Returns: MM/DD/YY#
+ //The current local calendar date for the telescope.
+ TelescopeTime = SharedResourcesWrapper.SendString(":GL#"),
+ //:GL# Get Local Time in 24 hour format
+ //Returns: HH:MM:SS#
+ //The Local Time in 24 - hour Format
+ UtcCorrection = GetUtcCorrection()
+ };
- return tdd;
- });
+ return tdd;
+ });
- int month = telescopeDateDetails.TelescopeDate.Substring(0, 2).ToInteger();
- int day = telescopeDateDetails.TelescopeDate.Substring(3, 2).ToInteger();
- int year = telescopeDateDetails.TelescopeDate.Substring(6, 2).ToInteger();
+ int month = telescopeDateDetails.TelescopeDate.Substring(0, 2).ToInteger();
+ int day = telescopeDateDetails.TelescopeDate.Substring(3, 2).ToInteger();
+ int year = telescopeDateDetails.TelescopeDate.Substring(6, 2).ToInteger();
- if (year < 2000) //todo fix this hack that will create a Y2K100 bug
- {
- year = year + 2000;
+ if (year < 2000) //todo fix this hack that will create a Y2K100 bug
+ {
+ year = year + 2000;
+ }
+
+ int hour = telescopeDateDetails.TelescopeTime.Substring(0, 2).ToInteger();
+ int minute = telescopeDateDetails.TelescopeTime.Substring(3, 2).ToInteger();
+ int second = telescopeDateDetails.TelescopeTime.Substring(6, 2).ToInteger();
+
+ var utcDate = new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc) +
+ telescopeDateDetails.UtcCorrection;
+
+ LogMessage("UTCDate", "Get - " + utcDate.ToString("MM/dd/yy HH:mm:ss"));
+
+ return utcDate;
}
+ catch (ParkedException e)
+ {
+ if (ParkedBehaviour == ParkedBehaviour.NoCoordinates)
+ throw;
- int hour = telescopeDateDetails.TelescopeTime.Substring(0, 2).ToInteger();
- int minute = telescopeDateDetails.TelescopeTime.Substring(3, 2).ToInteger();
- int second = telescopeDateDetails.TelescopeTime.Substring(6, 2).ToInteger();
-
- var utcDate = new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc) +
- telescopeDateDetails.UtcCorrection;
-
- LogMessage("UTCDate", "Get - " + utcDate.ToString("MM/dd/yy HH:mm:ss"));
-
- return utcDate;
+ return _clock.UtcNow;
+ }
}
set
{
@@ -2425,8 +2632,11 @@ namespace ASCOM.Meade.net
public void Unpark()
{
LogMessage("Unpark", "Unparking telescope");
+ CheckConnected("Unpark");
+
+ if (SharedResourcesWrapper.ProductName != TelescopeList.LX200GPS)
+ throw new InvalidOperationException("Unable to unpark this telescope type");
- //todo make this return only work for LX-200 GPS telescopes
if (!AtPark)
return;
@@ -2434,18 +2644,24 @@ namespace ASCOM.Meade.net
//: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
+ BypassHandboxEntryForAutostarII();
+
+ AtPark = false;
+ }
+
+ private bool BypassHandboxEntryForAutostarII()
+ {
var utcCorrection = GetUtcCorrection();
- var localDateTime = DateTime.UtcNow - utcCorrection;
+ var localDateTime = _clock.UtcNow - utcCorrection;
//localDateTime: HH: mm: ss
- SharedResourcesWrapper.SendBlind($":hI{localDateTime:yyMMddhhmmss}#");
+ var result = SharedResourcesWrapper.SendChar($":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;
+ return result == "1";
}
#endregion
@@ -2542,14 +2758,19 @@ namespace ASCOM.Meade.net
private void WriteProfile()
{
- var profileProperties = new ProfileProperties
- {
- TraceLogger = Tl.Enabled,
- ComPort = ComPort,
- GuideRateArcSecondsPerSecond = GuideRate
- };
+ var changed = false;
- SharedResourcesWrapper.WriteProfile(profileProperties);
+ var profileProperties = SharedResourcesWrapper.ReadProfile();
+
+
+ if (Math.Abs(profileProperties.GuideRateArcSecondsPerSecond - GuideRate) > 0.0000001)
+ {
+ changed = true;
+ profileProperties.GuideRateArcSecondsPerSecond = GuideRate;
+ }
+
+ if (changed)
+ SharedResourcesWrapper.WriteProfile(profileProperties);
}
#endregion
}
diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs
index 025bfb5..634c33e 100644
--- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs
+++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs
@@ -59,15 +59,16 @@ namespace Meade.net.UnitTests
Assert.That(result, Is.EqualTo(expectedResult));
}
- [Test]
- public void SendString_WhenCalled_ThenSendsMessageAndReadsResultUntilTerminatorFound()
+ [TestCase(false, "Test")]
+ [TestCase(true, "#Test")]
+ public void SendString_WhenCalled_ThenSendsMessageAndReadsResultUntilTerminatorFound(bool includePrefix, string expectedMessage)
{
- var expectedMessage = "Test";
+ var transmitMessage = "Test";
var expectedResult = "TestMessage#";
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(expectedResult);
- var result = SharedResources.SendString(expectedMessage);
+ var result = SharedResources.SendString(transmitMessage, includePrefix);
_serialMock.Verify(x => x.ClearBuffers(), Times.Once);
_serialMock.Verify(x => x.Transmit(expectedMessage), Times.Once);
@@ -123,10 +124,19 @@ namespace Meade.net.UnitTests
Assert.That(profeWrapper.DeviceType, Is.EqualTo("Telescope"));
profileWrapperMock.Verify( x => x.WriteValue(DriverId, "Trace Level", profileProperties.TraceLogger.ToString()), Times.Once);
+
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "COM Port", profileProperties.ComPort), Times.Once);
+ profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Speed", profileProperties.Speed.ToString()), Times.Once);
+ profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Data Bits", profileProperties.DataBits.ToString()), Times.Once);
+ profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Stop Bits", profileProperties.StopBits), Times.Once);
+ profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Hand Shake", profileProperties.Handshake), Times.Once);
+ profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Parity", profileProperties.Parity), Times.Once);
+ profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Rts / Dtr", profileProperties.RtsDtrEnabled.ToString()), Times.Once);
+
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Guide Rate Arc Seconds Per Second", profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.CurrentCulture)), Times.Once);
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Precision", profileProperties.Precision), Times.Once);
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Guiding Style", profileProperties.GuidingStyle), Times.Once);
+
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);
}
@@ -136,14 +146,30 @@ namespace Meade.net.UnitTests
{
string DriverId = "ASCOM.MeadeGeneric.Telescope";
- string ComPortDefault = "COM1";
string TraceStateDefault = "false";
+
+ string ComPortDefault = "COM1";
+ string SpeedDefault = "9600";
+ string DataBitsDefault = "8";
+ string StopBitsDefault = "One";
+ string HandshakeDefault = "None";
+ string ParityDefault = "None";
+ string RtsDtrEnabledDefault = "true";
+
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
string PrecisionDefault = "Unchanged";
string GuidingStyleDefault = "Auto";
+
string BacklashCompensationDefault = "3000";
string ReverseFocuserDiectionDefault = "true";
+ string SendDateTimeDefault = "true";
+ string SkipPromptsDefault = "true";
+
+ string ParkedBehaviourDefault = "No Coordinates";
+ string ParkedAltDefault = "0";
+ string ParkedAzimuthDefault = "180";
+
Mock profileWrapperMock = new Mock();
profileWrapperMock.SetupAllProperties();
@@ -163,8 +189,46 @@ namespace Meade.net.UnitTests
x.GetValue(DriverId, "Backlash Compensation", string.Empty, BacklashCompensationDefault))
.Returns(BacklashCompensationDefault);
profileWrapperMock.Setup(x =>
- x.GetValue(DriverId, "Reverse Focuser Direction", string.Empty, ReverseFocuserDiectionDefault))
+ x.GetValue(DriverId, "Reverse Focuser Direction", string.Empty, "true"))
.Returns(() => ReverseFocuserDiectionDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault))
+ .Returns(() => SpeedDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault))
+ .Returns(() => DataBitsDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault))
+ .Returns(() => StopBitsDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault))
+ .Returns(() => HandshakeDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parity", string.Empty, ParityDefault))
+ .Returns(() => ParityDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Rts / Dtr", string.Empty, "false"))
+ .Returns(() => RtsDtrEnabledDefault);
+
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault))
+ .Returns(() => ParityDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault))
+ .Returns(() => ParkedAltDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault))
+ .Returns(() => ParkedAzimuthDefault);
+
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Send Date and time on connect", string.Empty, "false"))
+ .Returns(() => SendDateTimeDefault);
+
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Skip date prompts on connect", string.Empty, "false"))
+ .Returns(() => SkipPromptsDefault);
+
+
IProfileWrapper profeWrapper = profileWrapperMock.Object;
@@ -174,16 +238,29 @@ namespace Meade.net.UnitTests
SharedResources.ProfileFactory = profileFactoryMock.Object;
var profileProperties = SharedResources.ReadProfile();
-
+
Assert.That(profeWrapper.DeviceType, Is.EqualTo("Telescope"));
- Assert.That(profileProperties.ComPort, Is.EqualTo(ComPortDefault));
- Assert.That(profileProperties.GuideRateArcSecondsPerSecond,
- Is.EqualTo(double.Parse(GuideRateProfileNameDefault)));
+
Assert.That(profileProperties.TraceLogger, Is.EqualTo(bool.Parse(TraceStateDefault)));
+
+ Assert.That(profileProperties.ComPort, Is.EqualTo(ComPortDefault));
+
+ Assert.That(profileProperties.GuideRateArcSecondsPerSecond,
+ Is.EqualTo(double.Parse(GuideRateProfileNameDefault)));
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)));
+
+ Assert.That(profileProperties.Speed, Is.EqualTo(int.Parse(SpeedDefault)));
+ Assert.That(profileProperties.DataBits, Is.EqualTo(int.Parse(DataBitsDefault)));
+ Assert.That(profileProperties.StopBits, Is.EqualTo(StopBitsDefault));
+ Assert.That(profileProperties.Handshake, Is.EqualTo(HandshakeDefault));
+ Assert.That(profileProperties.Parity, Is.EqualTo(ParityDefault));
+ Assert.That(profileProperties.RtsDtrEnabled, Is.EqualTo(bool.Parse(RtsDtrEnabledDefault)));
+
+ Assert.That(profileProperties.SendDateTime, Is.EqualTo(bool.Parse(SendDateTimeDefault)));
}
[TestCase("TCP")]
@@ -199,27 +276,66 @@ namespace Meade.net.UnitTests
public void Connect_WhenDeviceIdIsSerialButGVPEchos_ThenThrowsException()
{
string deviceId = "Serial";
-
- string driverDriverId = "ASCOM.MeadeGeneric.Telescope";
+ string DriverId = "ASCOM.MeadeGeneric.Telescope";
string ComPortDefault = "COM1";
+ string SpeedDefault = "9600";
+ string DataBitsDefault = "8";
+ string StopBitsDefault = "One";
+ string HandshakeDefault = "None";
+ string ParityDefault = "None";
+ string RtsDtrEnabledDefault = "false";
+
string TraceStateDefault = "false";
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
string PrecisionDefault = "Unchanged";
+ string ParkedBehaviourDefault = "No Coordinates";
+ string ParkedAltDefault = "0";
+ string ParkedAzimuthDefault = "180";
+
Mock profileWrapperMock = new Mock();
profileWrapperMock.SetupAllProperties();
- profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Trace Level", string.Empty, TraceStateDefault))
+ profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault))
.Returns(TraceStateDefault);
- profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "COM Port", string.Empty, ComPortDefault))
+ profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault))
.Returns(ComPortDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault))
+ .Returns(() => SpeedDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault))
+ .Returns(() => DataBitsDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault))
+ .Returns(() => StopBitsDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault))
+ .Returns(() => HandshakeDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parity", string.Empty, ParityDefault))
+ .Returns(() => ParityDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault))
+ .Returns(() => RtsDtrEnabledDefault);
+
profileWrapperMock
- .Setup(x => x.GetValue(driverDriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
+ .Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
- profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Precision", string.Empty, PrecisionDefault))
+ profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault))
.Returns(PrecisionDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault))
+ .Returns(() => ParityDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault))
+ .Returns(() => ParkedAltDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault))
+ .Returns(() => ParkedAzimuthDefault);
+
Mock profileFactoryMock = new Mock();
profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object);
@@ -239,26 +355,65 @@ namespace Meade.net.UnitTests
public void Connect_WhenDeviceIdIsSerialButGVPNotSupported_ThenConnectsAndSetsProductToLX200Classic()
{
string deviceId = "Serial";
+ string DriverId = "ASCOM.MeadeGeneric.Telescope";
- string driverDriverId = "ASCOM.MeadeGeneric.Telescope";
+ string TraceStateDefault = "false";
string ComPortDefault = "COM1";
- string TraceStateDefault = "false";
+ string SpeedDefault = "9600";
+ string DataBitsDefault = "8";
+ string StopBitsDefault = "One";
+ string HandshakeDefault = "None";
+ string ParityDefault = "None";
+ string RtsDtrEnabledDefault = "false";
+
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
string PrecisionDefault = "Unchanged";
+ string ParkedBehaviourDefault = "No Coordinates";
+ string ParkedAltDefault = "0";
+ string ParkedAzimuthDefault = "180";
+
Mock profileWrapperMock = new Mock();
profileWrapperMock.SetupAllProperties();
- profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Trace Level", string.Empty, TraceStateDefault))
+ profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault))
.Returns(TraceStateDefault);
- profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "COM Port", string.Empty, ComPortDefault))
+ profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault))
.Returns(ComPortDefault);
profileWrapperMock
- .Setup(x => x.GetValue(driverDriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
+ .Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
- profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Precision", string.Empty, PrecisionDefault))
+ profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault))
.Returns(PrecisionDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault))
+ .Returns(() => SpeedDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault))
+ .Returns(() => DataBitsDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault))
+ .Returns(() => StopBitsDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault))
+ .Returns(() => HandshakeDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parity", string.Empty, ParityDefault))
+ .Returns(() => ParityDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault))
+ .Returns(() => RtsDtrEnabledDefault);
+
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault))
+ .Returns(() => ParityDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault))
+ .Returns(() => ParkedAltDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault))
+ .Returns(() => ParkedAzimuthDefault);
Mock profileFactoryMock = new Mock();
profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object);
@@ -293,25 +448,65 @@ namespace Meade.net.UnitTests
{
string deviceId = "Serial";
- string driverDriverId = "ASCOM.MeadeGeneric.Telescope";
+ string DriverId = "ASCOM.MeadeGeneric.Telescope";
+
+ string TraceStateDefault = "false";
string ComPortDefault = "COM1";
- string TraceStateDefault = "false";
+ string SpeedDefault = "9600";
+ string DataBitsDefault = "8";
+ string StopBitsDefault = "One";
+ string HandshakeDefault = "None";
+ string ParityDefault = "None";
+ string RtsDtrEnabledDefault = "false";
+
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
string PrecisionDefault = "Unchanged";
+ string ParkedBehaviourDefault = "No Coordinates";
+ string ParkedAltDefault = "0";
+ string ParkedAzimuthDefault = "180";
+
Mock profileWrapperMock = new Mock();
profileWrapperMock.SetupAllProperties();
- profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Trace Level", string.Empty, TraceStateDefault))
+ profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault))
.Returns(TraceStateDefault);
- profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "COM Port", string.Empty, ComPortDefault))
+ profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault))
.Returns(ComPortDefault);
profileWrapperMock
- .Setup(x => x.GetValue(driverDriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
+ .Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
- profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Precision", string.Empty, PrecisionDefault))
+ profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault))
.Returns(PrecisionDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault))
+ .Returns(() => SpeedDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault))
+ .Returns(() => DataBitsDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault))
+ .Returns(() => StopBitsDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault))
+ .Returns(() => HandshakeDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parity", string.Empty, ParityDefault))
+ .Returns(() => ParityDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault))
+ .Returns(() => RtsDtrEnabledDefault);
+
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault))
+ .Returns(() => ParityDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault))
+ .Returns(() => ParkedAltDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault))
+ .Returns(() => ParkedAzimuthDefault);
Mock profileFactoryMock = new Mock();
profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object);
@@ -343,25 +538,64 @@ namespace Meade.net.UnitTests
{
string deviceId = "Serial";
- string driverDriverId = "ASCOM.MeadeGeneric.Telescope";
+ string DriverId = "ASCOM.MeadeGeneric.Telescope";
+
+ string TraceStateDefault = "false";
string ComPortDefault = "COM1";
- string TraceStateDefault = "false";
+ string SpeedDefault = "9600";
+ string DataBitsDefault = "8";
+ string StopBitsDefault = "One";
+ string HandshakeDefault = "None";
+ string ParityDefault = "None";
+ string RtsDtrEnabledDefault = "false";
+
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
string PrecisionDefault = "Unchanged";
+ string ParkedBehaviourDefault = "No Coordinates";
+ string ParkedAltDefault = "0";
+ string ParkedAzimuthDefault = "180";
+
Mock profileWrapperMock = new Mock();
profileWrapperMock.SetupAllProperties();
- profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Trace Level", string.Empty, TraceStateDefault))
+ profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault))
.Returns(TraceStateDefault);
- profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "COM Port", string.Empty, ComPortDefault))
+ profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault))
.Returns(ComPortDefault);
profileWrapperMock
- .Setup(x => x.GetValue(driverDriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
+ .Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
- profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Precision", string.Empty, PrecisionDefault))
+ profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault))
.Returns(PrecisionDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault))
+ .Returns(() => SpeedDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault))
+ .Returns(() => DataBitsDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault))
+ .Returns(() => StopBitsDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault))
+ .Returns(() => HandshakeDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parity", string.Empty, ParityDefault))
+ .Returns(() => ParityDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault))
+ .Returns(() => RtsDtrEnabledDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault))
+ .Returns(() => ParityDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault))
+ .Returns(() => ParkedAltDefault);
+ profileWrapperMock.Setup(x =>
+ x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault))
+ .Returns(() => ParkedAzimuthDefault);
Mock profileFactoryMock = new Mock();
profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object);
diff --git a/Meade.net.Telescope/AstroMaths/HorizonCoordinates.cs b/Meade.net/AstroMaths/HorizonCoordinates.cs
similarity index 100%
rename from Meade.net.Telescope/AstroMaths/HorizonCoordinates.cs
rename to Meade.net/AstroMaths/HorizonCoordinates.cs
diff --git a/Meade.net/EnumExtensionMethods.cs b/Meade.net/EnumExtensionMethods.cs
new file mode 100644
index 0000000..2df6a5a
--- /dev/null
+++ b/Meade.net/EnumExtensionMethods.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Linq;
+using System.Reflection;
+
+namespace ASCOM.Meade.net
+{
+ public static class EnumExtensionMethods
+ {
+ public static string GetDescription(this Enum GenericEnum)
+ {
+ var genericEnumType = GenericEnum.GetType();
+ var memberInfo = genericEnumType.GetMember(GenericEnum.ToString());
+ if (memberInfo.Length > 0)
+ {
+ var _Attribs = memberInfo[0]
+ .GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false);
+ if (_Attribs.Any())
+ {
+ return ((System.ComponentModel.DescriptionAttribute) _Attribs.ElementAt(0)).Description;
+ }
+ }
+
+ return GenericEnum.ToString();
+ }
+
+ public static T GetValueFromDescription( string description) where T : Enum
+ {
+ foreach (T value in Enum.GetValues(typeof(T)))
+ {
+ if (value.GetDescription() == description)
+ {
+ return value;
+ }
+ }
+
+ return default;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Meade.net/Meade.net.csproj b/Meade.net/Meade.net.csproj
index eb6b45c..c30849a 100644
--- a/Meade.net/Meade.net.csproj
+++ b/Meade.net/Meade.net.csproj
@@ -129,6 +129,7 @@
+
Form
@@ -136,8 +137,10 @@
frmMain.cs
+
+
@@ -199,6 +202,7 @@
true
+