Added support for the LX200GPS to use the newer pulse guiding commands.

Added support for setting the guide rate on the LX200GPS (untested)
This commit is contained in:
2019-07-20 16:53:09 +01:00
parent ce74e980fa
commit c2ebe329c5
8 changed files with 138 additions and 54 deletions
@@ -37,10 +37,7 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock = new Mock<ISharedResourcesWrapper>();
_sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MMSS");
_sharedResourcesWrapperMock.Setup(x => x.Autostar497).Returns(() => "AUTOSTAR");
_sharedResourcesWrapperMock.Setup(x => x.Autostar49731Ee).Returns(() => "31Ee");
_sharedResourcesWrapperMock.Setup(x => x.Autostar49743Eg) .Returns(() => "43Eg");
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Action>())).Callback<Action>(action => { action(); });
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Func<ASCOM.Meade.net.Telescope.TelescopeDateDetails>>())).Returns<Func<ASCOM.Meade.net.Telescope.TelescopeDateDetails>>( (func) => func());
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Func<AltitudeData>>())).Returns<Func<AltitudeData>>((func) => func());
@@ -56,8 +53,8 @@ namespace Meade.net.Telescope.UnitTests
private void ConnectTelescope()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.Autostar49731Ee);
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee);
_telescope.Connected = true;
}
@@ -238,8 +235,8 @@ namespace Meade.net.Telescope.UnitTests
[TestCase(false)]
public void Connected_Get_ReturnsExpectedValue(bool expectedConnected)
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.Autostar49731Ee);
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee);
_telescope.Connected = expectedConnected;
Assert.That(_telescope.Connected, Is.EqualTo(expectedConnected));
@@ -275,8 +272,8 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void Connected_Set_WhenFailsToConnect_ThenDisconnects()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.Autostar49731Ee);
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee);
_sharedResourcesWrapperMock.Setup(x => x.SendString(It.IsAny<string>())).Throws(new Exception("TestFailed"));
@@ -287,10 +284,11 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Verify(x => x.Disconnect(It.IsAny<string>()), Times.Once());
}
[TestCase("AUTOSTAR", "30Ab", false)]
[TestCase("AUTOSTAR","31Ee", true)]
[TestCase("AUTOSTAR", "43Eg", true)]
[TestCase("AUTOSTAR II", "", false)]
[TestCase("Autostar", "30Ab", false)]
[TestCase("Autostar", "31Ee", true)]
[TestCase("Autostar", "43Eg", true)]
[TestCase("Autostar II", "", false)]
[TestCase("LX2001", "", true)]
public void IsNewPulseGuidingSupported_ThenIsSupported_ThenReturnsTrue(string productName, string firmware, bool isSupported)
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName);
@@ -777,12 +775,28 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void GuideRateDeclination_Set_ThenThrowsException()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { _telescope.GuideRateDeclination = 0; });
Assert.That(excpetion.Property, Is.EqualTo("GuideRateDeclination"));
Assert.That(excpetion.AccessorSet, Is.True);
}
[Test]
public void GuideRateDeclination_Set_WhenIsSupported_ThenSetsNewGuideRate()
{
var newGuideRate = 10;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS);
_telescope.GuideRateDeclination = newGuideRate;
_sharedResourcesWrapperMock.Verify( x => x.SendBlind(":Rg10.0#"),Times.Once);
Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate));
}
[Test]
public void GuideRateRightAscension_Get_ThenThrowsException()
{
@@ -794,12 +808,28 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void GuideRateRightAscension_Set_ThenThrowsException()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { _telescope.GuideRateRightAscension = 0; });
Assert.That(excpetion.Property, Is.EqualTo("GuideRateRightAscension"));
Assert.That(excpetion.AccessorSet, Is.True);
}
[Test]
public void GuideRateRightAscension_Set_WhenIsSupported_ThenSetsNewGuideRate()
{
var newGuideRate = 10;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS);
_telescope.GuideRateRightAscension = newGuideRate;
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Rg10.0#"), Times.Once);
Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate));
}
[Test]
public void IsPulseGuiding_Get_ReturnsFalse()
{
@@ -997,8 +1027,8 @@ namespace Meade.net.Telescope.UnitTests
public void PulseGuide_WhenConnectedAndNewerPulseGuidingNotAvailable_ThenSendsOldCommandsAndWaits(GuideDirections direction)
{
var duration = 0;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => "31Ed");
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_30Ee);
_telescope.Connected = true;
_telescope.PulseGuide(direction, duration);
@@ -1033,8 +1063,8 @@ namespace Meade.net.Telescope.UnitTests
public void PulseGuide_WhenConnectedAndNewerPulseGuidingAvailableButDurationTooLong_ThenSendsOldCommandsAndWaits(GuideDirections direction)
{
var duration = 10000;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => "31Ed");
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_30Ee);
_telescope.Connected = true;
_telescope.PulseGuide(direction, duration);
@@ -1328,8 +1358,6 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void SyncToAltAz_WhenConnected_ThenSendsExpectedMessage()
{
string expectedMessage = "test blind Message";
ConnectTelescope();
var exception = Assert.Throws<MethodNotImplementedException>(() => { _telescope.SyncToAltAz(0,0); });
+14
View File
@@ -0,0 +1,14 @@
namespace ASCOM.Meade.net
{
public static class DoubleExtensions
{
public static bool InRange(this double value, double low, double high)
{
if (value < low)
return false;
if (value > high)
return false;
return true;
}
}
}
@@ -118,6 +118,7 @@
<Compile Include="AstroMaths\EquatorialCoordinates.cs" />
<Compile Include="AstroMaths\HorizonCoordinates.cs" />
<Compile Include="AstroMaths\IAstroMaths.cs" />
<Compile Include="DoubleExtensions.cs" />
<Compile Include="StringExtensions.cs" />
<Compile Include="Telescope.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+44 -19
View File
@@ -344,11 +344,25 @@ namespace ASCOM.Meade.net
public bool IsNewPulseGuidingSupported()
{
if (_sharedResourcesWrapper.ProductName == _sharedResourcesWrapper.Autostar497)
if (_sharedResourcesWrapper.ProductName == TelescopeList.Autostar497)
{
return FirmwareIsGreaterThan(_sharedResourcesWrapper.Autostar49731Ee);
return FirmwareIsGreaterThan(TelescopeList.Autostar497_31Ee);
}
if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS)
{
return true;
}
return false;
}
private bool IsGuideRateSettingSupported()
{
if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS)
{
return true;
}
return false;
}
@@ -495,7 +509,7 @@ namespace ASCOM.Meade.net
//P If scope in Polar Mode
//todo implement GW Command - Supported in Autostar 43Eg and above
//if FirmwareIsGreaterThan(_sharedResourcesWrapper.AUTOSTAR497_43EG)
//if FirmwareIsGreaterThan(TelescopeList.Autostar497_43EG)
//{
//var alignmentString = SerialPort.CommandTerminated(":GW#", "#");
//:GW# Get Scope Alignment Status
@@ -531,7 +545,7 @@ namespace ASCOM.Meade.net
CheckConnected("AlignmentMode Set");
//todo tidy this up into a better solution that means can :GW#, :AL#, :AA#, & :AP# and checked for Autostar properly
if (!FirmwareIsGreaterThan(_sharedResourcesWrapper.Autostar49743Eg))
if (!FirmwareIsGreaterThan(TelescopeList.Autostar497_43Eg))
throw new PropertyNotImplementedException("AlignmentMode",true );
//todo make this only try with Autostar 43Eg and above.
@@ -904,6 +918,29 @@ namespace ASCOM.Meade.net
}
}
private void SetNewGuideRate(double value, string propertyName)
{
if (!IsGuideRateSettingSupported())
{
LogMessage("GuideRateDeclination Set", "Not implemented");
throw new PropertyNotImplementedException(propertyName, true);
}
if (!value.InRange(0, 15.0417))
{
throw new InvalidValueException(propertyName, value.ToString(), "0 to 15.0417”/sec");
}
_sharedResourcesWrapper.SendBlind($":Rg{value:00.0}#");
//:RgSS.S#
//Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking
//Rates when the CCD guider or handbox guider buttons are pressed when the guide rate is selected.Rate shall not exceed
//sidereal speed(approx 15.0417”/sec)[Autostar II only]
//Returns: Nothing
_guideRate = value;
}
public double GuideRateDeclination
{
get
@@ -913,16 +950,10 @@ namespace ASCOM.Meade.net
}
set
{
LogMessage("GuideRateDeclination Set", "Not implemented");
throw new PropertyNotImplementedException("GuideRateDeclination", true);
//:RgSS.S#
//Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking
//Rates when the CCD guider or handbox guider buttons are pressed when the guide rate is selected.Rate shall not exceed
//sidereal speed(approx 15.0417”/ sec)[Autostar II only]
//Returns: Nothing
SetNewGuideRate(value, "GuideRateDeclination");
}
}
public double GuideRateRightAscension
{
get
@@ -932,13 +963,7 @@ namespace ASCOM.Meade.net
}
set
{
LogMessage("GuideRateRightAscension Set", "Not implemented");
throw new PropertyNotImplementedException("GuideRateRightAscension", true);
//:RgSS.S#
//Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking
//Rates when the CCD guider or handbox guider buttons are pressed when the guide rate is selected.Rate shall not exceed
//sidereal speed(approx 15.0417”/ sec)[Autostar II only]
//Returns: Nothing
SetNewGuideRate(value, "GuideRateRightAscension");
}
}
-1
View File
@@ -112,7 +112,6 @@ namespace ASCOM.Meade.net
private readonly Type _mClassType;
private Guid _mClassId;
private readonly ArrayList _mInterfaceTypes;
private UInt32 _mLocked = 0;
private uint _mCookie;
private readonly string _mProgid;
+1
View File
@@ -133,6 +133,7 @@
<Compile Include="LocalServer.cs" />
<Compile Include="ProfileProperties.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TelescopeList.cs" />
<Compile Include="Wrapper\SharedResourcesWrapper.cs" />
<EmbeddedResource Include="frmMain.resx">
<SubType>Designer</SubType>
+30
View File
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
namespace ASCOM.Meade.net
{
public static class TelescopeList
{
#region Autostar 497/Audiostar
public readonly static string Autostar497 = "Autostar";
//Autostar/Audiostar firmware revisions
public readonly static string Autostar497_30Ee = "30Ee";
public readonly static string Autostar497_31Ee = "31Ee";
public readonly static string Autostar497_43Eg = "43Eg";
#endregion
#region LX200GPS
public readonly static string LX200GPS = "LX2001";
public readonly static string LX200GPS_42G = "4.2G";
#endregion
}
}
@@ -4,11 +4,6 @@ namespace ASCOM.Meade.net.Wrapper
{
public interface ISharedResourcesWrapper
{
string Autostar497 { get; }
string Autostar49731Ee { get; }
string Autostar49743Eg { get;}
void Connect(string deviceId);
void Disconnect(string deviceId);
@@ -32,15 +27,6 @@ namespace ASCOM.Meade.net.Wrapper
public class SharedResourcesWrapper : ISharedResourcesWrapper
{
#region AutostarProducts
public string Autostar497 => "Autostar";
public string Autostar49731Ee => "31Ee";
public string Autostar49743Eg => "43Eg";
#endregion
public void Connect(string deviceId)
{
SharedResources.Connect( deviceId);