Compare commits

..

9 Commits

Author SHA1 Message Date
ColinD a605a3ed9d Merged in develop (pull request #38)
Develop
2021-09-26 16:18:18 +00:00
ColinD ad9169a48d Modified so that the driver supports either +60.1 or 60.1 for tracking rate 2021-09-26 16:50:46 +01:00
ColinD 3b056ef7f8 Fixed bug in tracking rate get where it always returns lunar when it should be sidereal 2021-09-17 09:38:35 +01:00
ColinD 710ae0420a Added left, right as sysonyms of back and forward for the handbox commands.
Added scrollup and scrolldown handbox commands as well.
2021-09-09 12:14:15 +01:00
ColinD 2a6b74c6fd Merged in develop (pull request #37)
version 1.3.1
2021-08-04 18:48:01 +00:00
ColinD 49c43358de Added check to ensure that the Lunar Tracking rate cannot be selected on the LX200 Classic. 2021-08-04 18:48:24 +01:00
ColinD 27a0f54b07 Added check to make sure that the tracking rate cannot be set for an LX200. 2021-08-04 17:01:06 +01:00
ColinD a562b848c0 Corrected the expected result of the GT command. 2021-08-04 09:22:31 +01:00
ColinD f4c26d777b Added more logging around the tracking rates.
Corrected the Command logged messages to use the correct info.
Added a try catch to the setup dialog to see if an error occurs to give a better message.
2021-08-03 21:55:06 +01:00
4 changed files with 144 additions and 49 deletions
@@ -56,12 +56,14 @@ namespace Meade.net.Telescope.UnitTests
private bool _isParked; private bool _isParked;
private ParkedPosition _parkedPosition; private ParkedPosition _parkedPosition;
private string _siderealTrackingRate;
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
_isParked = false; _isParked = false;
_parkedPosition = null; _parkedPosition = null;
_siderealTrackingRate = "+60.1";
_testProperties = new TestProperties(); _testProperties = new TestProperties();
@@ -142,11 +144,10 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Setup(x => x.SendString("GL", false)).Returns(() => _testProperties.telescopeTime); _sharedResourcesWrapperMock.Setup(x => x.SendString("GL", false)).Returns(() => _testProperties.telescopeTime);
_sharedResourcesWrapperMock.Setup(x => x.SendString("GG", false)).Returns(() => _testProperties.telescopeUtcCorrection); _sharedResourcesWrapperMock.Setup(x => x.SendString("GG", false)).Returns(() => _testProperties.telescopeUtcCorrection);
const string siderealTrackingRate = "+60.1"; _testProperties.TrackingRate = _siderealTrackingRate;
_testProperties.TrackingRate = siderealTrackingRate;
_sharedResourcesWrapperMock.Setup(x => x.SendString("GT", false)).Returns(() => _testProperties.TrackingRate); _sharedResourcesWrapperMock.Setup(x => x.SendString("GT", false)).Returns(() => _testProperties.TrackingRate);
_sharedResourcesWrapperMock.Setup(x => x.SendBlind("TL", false)).Callback(() => _testProperties.TrackingRate = "lunar"); _sharedResourcesWrapperMock.Setup(x => x.SendBlind("TL", false)).Callback(() => _testProperties.TrackingRate = "lunar");
_sharedResourcesWrapperMock.Setup(x => x.SendBlind("TQ", false)).Callback(() => _testProperties.TrackingRate = siderealTrackingRate); _sharedResourcesWrapperMock.Setup(x => x.SendBlind("TQ", false)).Callback(() => _testProperties.TrackingRate = _siderealTrackingRate);
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => productName); _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => productName);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => firmwareVersion); _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => firmwareVersion);
@@ -246,6 +247,10 @@ namespace Meade.net.Telescope.UnitTests
[TestCase("down", "EK118")] [TestCase("down", "EK118")]
[TestCase("back", "EK87")] [TestCase("back", "EK87")]
[TestCase("forward", "EK69")] [TestCase("forward", "EK69")]
[TestCase("left", "EK87")]
[TestCase("right", "EK69")]
[TestCase("scrollup", "EK85")]
[TestCase("scrolldown", "EK68")]
[TestCase("?", "EK63")] [TestCase("?", "EK63")]
public void Action_Handbox_WhenCalling_ThenSendsAppropriateBlindCommands(string action, string expectedString) public void Action_Handbox_WhenCalling_ThenSendsAppropriateBlindCommands(string action, string expectedString)
{ {
@@ -822,9 +827,9 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: AlignmentMode Set")); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: AlignmentMode Set"));
} }
[TestCase("AUTOSTAR", "43Eg", AlignmentModes.algAltAz, "AA")] [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, AlignmentModes.algAltAz, "AA")]
[TestCase("AUTOSTAR", "43Eg", AlignmentModes.algPolar, "AP")] [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, AlignmentModes.algPolar, "AP")]
[TestCase("AUTOSTAR", "43Eg", AlignmentModes.algGermanPolar, "AP")] [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, AlignmentModes.algGermanPolar, "AP")]
public void AlignmentMode_Set_WhenConnected_ThenSendsExpectedCommand(string productName, string firmware, AlignmentModes alignmentMode, string expectedCommand) public void AlignmentMode_Set_WhenConnected_ThenSendsExpectedCommand(string productName, string firmware, AlignmentModes alignmentMode, string expectedCommand)
{ {
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName); _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName);
@@ -2702,7 +2707,10 @@ namespace Meade.net.Telescope.UnitTests
[TestCase(DriveRates.driveLunar, "TL")] [TestCase(DriveRates.driveLunar, "TL")]
public void TrackingRate_Set_WhenConnected_ThenSendsCommandToTelescope(DriveRates rate, string commandString) public void TrackingRate_Set_WhenConnected_ThenSendsCommandToTelescope(DriveRates rate, string commandString)
{ {
ConnectTelescope(); string productName = TelescopeList.Autostar497;
string firmwareVersion = TelescopeList.Autostar497_43Eg;
ConnectTelescope(productName, firmwareVersion);
_telescope.TrackingRate = rate; _telescope.TrackingRate = rate;
@@ -2715,15 +2723,19 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void TrackingRate_Set_WhenUnSupportedRateSet_ThenThrowsException() public void TrackingRate_Set_WhenUnSupportedRateSet_ThenThrowsException()
{ {
ConnectTelescope(); string productName = TelescopeList.Autostar497;
string firmwareVersion = TelescopeList.Autostar497_43Eg;
ConnectTelescope(productName, firmwareVersion);
var exception = Assert.Throws<ArgumentOutOfRangeException>(() => _telescope.TrackingRate = DriveRates.driveKing); var exception = Assert.Throws<ArgumentOutOfRangeException>(() => _telescope.TrackingRate = DriveRates.driveKing);
Assert.That(exception.Message, Is.EqualTo("Exception of type 'System.ArgumentOutOfRangeException' was thrown.\r\nParameter name: value\r\nActual value was driveKing.")); Assert.That(exception.Message, Is.EqualTo("Exception of type 'System.ArgumentOutOfRangeException' was thrown.\r\nParameter name: value\r\nActual value was driveKing."));
} }
[Test] [TestCase("60.1")]
public void TrackingRage_Get_WhenReadongDefaultValue_ThenAssumesSidereal() [TestCase("+60.1")]
public void TrackingRage_Get_WhenReadingDefaultValue_ThenAssumesSidereal(string trackingRate)
{ {
ConnectTelescope(); ConnectTelescope();
@@ -2732,11 +2744,18 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(result, Is.EqualTo(DriveRates.driveSidereal)); Assert.That(result, Is.EqualTo(DriveRates.driveSidereal));
} }
[TestCase(DriveRates.driveSidereal)] [TestCase(DriveRates.driveSidereal, "60.1")]
[TestCase(DriveRates.driveLunar)] [TestCase(DriveRates.driveLunar, "60.1")]
public void TrackingRate_Get_WhenConnected_ThenSendsCommandToTelescope(DriveRates rate) [TestCase(DriveRates.driveSidereal, "+60.1")]
[TestCase(DriveRates.driveLunar, "+60.1")]
public void TrackingRate_Get_WhenConnected_ThenSendsCommandToTelescope(DriveRates rate, string trackingRate)
{ {
ConnectTelescope(); _siderealTrackingRate = trackingRate;
string productName = TelescopeList.Autostar497;
string firmwareVersion = TelescopeList.Autostar497_43Eg;
ConnectTelescope(productName, firmwareVersion);
_telescope.TrackingRate = rate; _telescope.TrackingRate = rate;
@@ -2745,13 +2764,41 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(result, Is.EqualTo(rate)); Assert.That(result, Is.EqualTo(rate));
} }
[Test] [TestCase(DriveRates.driveSidereal, "60.1")]
public void TrackingRates_Get_ReturnsExpectedType() [TestCase(DriveRates.driveLunar, "60.1")]
[TestCase(DriveRates.driveSidereal, "+60.1")]
[TestCase(DriveRates.driveLunar, "+60.1")]
public void TrackingRate_Set_WhenConnectedToLX200_ThenThrowsException(DriveRates rate, string trackingRate)
{ {
string productName = TelescopeList.LX200CLASSIC;
string firmwareVersion = string.Empty;
ConnectTelescope(productName, firmwareVersion);
var result = Assert.Throws<ASCOM.NotImplementedException>( () => _telescope.TrackingRate = rate );
Assert.That(result.Message, Is.EqualTo("TrackingRate Set is not implemented in this driver."));
}
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, true )]
[TestCase(TelescopeList.LX200CLASSIC, "", false)]
public void TrackingRates_Get_ReturnsExpectedType(string productName, string firmwareVersion, bool supportsLunar)
{
ConnectTelescope(productName, firmwareVersion);
var result = _telescope.TrackingRates; var result = _telescope.TrackingRates;
Assert.That(result, Is.Not.Null); Assert.That(result, Is.Not.Null);
Assert.That(result, Is.AssignableTo<TrackingRates>()); Assert.That(result, Is.AssignableTo<TrackingRates>());
if (supportsLunar)
{
Assert.That(result.Count, Is.EqualTo(2));
}
else
{
Assert.That(result.Count, Is.EqualTo(1));
}
} }
[Test] [Test]
+7 -3
View File
@@ -149,15 +149,19 @@ namespace ASCOM.Meade.net
// Default constructor - Internal prevents public creation // Default constructor - Internal prevents public creation
// of instances. Returned by Telescope.AxisRates. // of instances. Returned by Telescope.AxisRates.
// //
internal TrackingRates() internal TrackingRates(bool supportsLunar)
{ {
// //
// This array must hold ONE or more DriveRates values, indicating // This array must hold ONE or more DriveRates values, indicating
// the tracking rates supported by your telescope. The one value // the tracking rates supported by your telescope. The one value
// (tracking rate) that MUST be supported is driveSidereal! // (tracking rate) that MUST be supported is driveSidereal!
// //
_trackingRates = new[] { DriveRates.driveSidereal, DriveRates.driveLunar }; if (supportsLunar)
// TODO Initialize this array with any additional tracking rates that your driver may provide {
_trackingRates = new[] {DriveRates.driveSidereal, DriveRates.driveLunar};
}
else
_trackingRates = new[] { DriveRates.driveSidereal };
} }
#region ITrackingRates Members #region ITrackingRates Members
+53 -18
View File
@@ -249,11 +249,19 @@ namespace ASCOM.Meade.net
SharedResourcesWrapper.SendBlind("EK118"); SharedResourcesWrapper.SendBlind("EK118");
break; break;
case "back": case "back":
case "left":
SharedResourcesWrapper.SendBlind("EK87"); SharedResourcesWrapper.SendBlind("EK87");
break; break;
case "forward": case "forward":
case "right":
SharedResourcesWrapper.SendBlind("EK69"); SharedResourcesWrapper.SendBlind("EK69");
break; break;
case "scrollup":
SharedResourcesWrapper.SendBlind("EK85");
break;
case "scrolldown":
SharedResourcesWrapper.SendBlind("EK68");
break;
case "?": case "?":
SharedResourcesWrapper.SendBlind("EK63"); SharedResourcesWrapper.SendBlind("EK63");
break; break;
@@ -339,7 +347,7 @@ namespace ASCOM.Meade.net
public void CommandBlind(string command, bool raw) public void CommandBlind(string command, bool raw)
{ {
LogMessage("CommandBlind", "raw: {0} command {0}", raw, command); LogMessage("CommandBlind", $"raw: {raw} command {command}");
CheckConnected("CommandBlind"); CheckConnected("CommandBlind");
// Call CommandString and return as soon as it finishes // Call CommandString and return as soon as it finishes
//this.CommandString(command, raw); //this.CommandString(command, raw);
@@ -352,16 +360,16 @@ namespace ASCOM.Meade.net
public bool CommandBool(string command, bool raw) public bool CommandBool(string command, bool raw)
{ {
LogMessage("CommandBool", "raw: {0} command {0}", raw, command); LogMessage("CommandBool", $"raw: {raw} command {command}");
CheckConnected("CommandBool"); CheckConnected("CommandBool");
var result = SharedResourcesWrapper.SendBool(command, raw); var result = SharedResourcesWrapper.SendBool(command, raw);
LogMessage("CommandBool", "Completed: {0}", result); LogMessage("CommandBool", $"Completed: {result}");
return result; return result;
} }
public string CommandString(string command, bool raw) public string CommandString(string command, bool raw)
{ {
LogMessage("CommandString", "raw: {0} command {0}", raw, command); LogMessage("CommandString", $"raw: {raw} command {command}");
CheckConnected("CommandString"); CheckConnected("CommandString");
// it's a good idea to put all the low level communication with the device here, // it's a good idea to put all the low level communication with the device here,
// then all communication calls this function // then all communication calls this function
@@ -377,7 +385,7 @@ namespace ASCOM.Meade.net
{ {
result = SharedResourcesWrapper.SendString(command, raw); result = SharedResourcesWrapper.SendString(command, raw);
} }
LogMessage("CommandString", "Completed: {0}", result); LogMessage("CommandString", $"Completed: {result}");
return result; return result;
} }
@@ -622,13 +630,26 @@ namespace ASCOM.Meade.net
return false; return false;
} }
private bool IsGWCommandSupported() => FirmwareIsGreaterThan(TelescopeList.Autostar497_43Eg); private bool IsGwCommandSupported()
{
switch (SharedResourcesWrapper.ProductName)
{
case TelescopeList.LX200CLASSIC:
return false;
case TelescopeList.Autostar497:
return FirmwareIsGreaterThan(TelescopeList.Autostar497_43Eg);
case TelescopeList.LX200GPS:
return FirmwareIsGreaterThan(TelescopeList.LX200GPS_42G);
default:
return false;
}
}
// true iff the mount will perform a meridian flip when required // true iff the mount will perform a meridian flip when required
// According to "A User's Guide to the Meade LXD55 and LXD75 Telescopes" Autostar supports meridian flip so // According to "A User's Guide to the Meade LXD55 and LXD75 Telescopes" Autostar supports meridian flip so
// we assume that for any telescope that supports the GW command and is not in Alt-Az mode then // we assume that for any telescope that supports the GW command and is not in Alt-Az mode then
// meridian flip on slew is supported // meridian flip on slew is supported
private bool IsMeridianFlipOnSlewSupported() => IsGWCommandSupported() && AlignmentMode != AlignmentModes.algAltAz; private bool IsMeridianFlipOnSlewSupported() => IsGwCommandSupported() && AlignmentMode != AlignmentModes.algAltAz;
private bool FirmwareIsGreaterThan(string minVersion) private bool FirmwareIsGreaterThan(string minVersion)
{ {
@@ -955,7 +976,7 @@ namespace ASCOM.Meade.net
CheckConnected("AlignmentMode Get"); CheckConnected("AlignmentMode Get");
if (IsGWCommandSupported()) if (IsGwCommandSupported())
{ {
var alignmentStatus = GetScopeAlignmentStatus(); var alignmentStatus = GetScopeAlignmentStatus();
return alignmentStatus.AlignmentMode; return alignmentStatus.AlignmentMode;
@@ -996,7 +1017,7 @@ namespace ASCOM.Meade.net
CheckConnected("AlignmentMode Set"); CheckConnected("AlignmentMode Set");
//todo tidy this up into a better solution that means can :GW#, :AL#, :AA#, & :AP# and checked for Autostar properly //todo tidy this up into a better solution that means can :GW#, :AL#, :AA#, & :AP# and checked for Autostar properly
if (!IsGWCommandSupported()) if (!IsGwCommandSupported())
throw new PropertyNotImplementedException("AlignmentMode", true); throw new PropertyNotImplementedException("AlignmentMode", true);
switch (value) switch (value)
@@ -1023,6 +1044,7 @@ namespace ASCOM.Meade.net
private AlignmentStatus GetScopeAlignmentStatus() private AlignmentStatus GetScopeAlignmentStatus()
{ {
LogMessage("GetScopeAlignmentStatus", "Started");
var alignmentString = CommandString("GW", false); var alignmentString = CommandString("GW", false);
//:GW# Get Scope Alignment Status //:GW# Get Scope Alignment Status
//Returns: <mount><tracking><alignment># //Returns: <mount><tracking><alignment>#
@@ -1045,6 +1067,7 @@ namespace ASCOM.Meade.net
alignmentStatus.AlignmentMode = AlignmentModes.algGermanPolar; alignmentStatus.AlignmentMode = AlignmentModes.algGermanPolar;
break; break;
} }
alignmentStatus.Tracking = alignmentString[1] == 'T'; alignmentStatus.Tracking = alignmentString[1] == 'T';
switch (alignmentString[2]) switch (alignmentString[2])
{ {
@@ -1068,6 +1091,7 @@ namespace ASCOM.Meade.net
break; break;
} }
LogMessage("GetScopeAlignmentStatus", $"Result {alignmentStatus}");
return alignmentStatus; return alignmentStatus;
} }
@@ -1309,7 +1333,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
var canSetTracking = IsGWCommandSupported(); var canSetTracking = IsGwCommandSupported();
LogMessage("CanSetTracking", "Get - " + canSetTracking); LogMessage("CanSetTracking", "Get - " + canSetTracking);
return canSetTracking; return canSetTracking;
} }
@@ -2591,7 +2615,7 @@ namespace ASCOM.Meade.net
get get
{ {
LogMessage("Tracking", "Get"); LogMessage("Tracking", "Get");
if (IsGWCommandSupported()) if (IsGwCommandSupported())
{ {
var alignmentStatus = GetScopeAlignmentStatus(); var alignmentStatus = GetScopeAlignmentStatus();
return alignmentStatus.Tracking; return alignmentStatus.Tracking;
@@ -2607,7 +2631,7 @@ namespace ASCOM.Meade.net
} }
LogMessage("Tracking Set", $"{value}"); LogMessage("Tracking Set", $"{value}");
SharedResourcesWrapper.SendBlind(value ? "AP" : "AL"); SharedResourcesWrapper.SendBlind(value ? "AP" : "AL"); //todo need to route this to the real commands.
} }
} }
@@ -2616,12 +2640,18 @@ namespace ASCOM.Meade.net
get get
{ {
var rate = CommandString("GT", false); var rate = CommandString("GT", false);
//:GT# Get tracking rate
//Returns: TT.T#
//Current Track Frequency expressed in hertz assuming a synchonous motor design where a 60.0 Hz motor clock
// would produce 1 revolution of the telescope in 24 hours.
if (rate == "+60.1") rate = rate.Replace("+", string.Empty);
return DriveRates.driveSidereal;
// we only support two rates ATM so return lunar tracking rate DriveRates result = rate == "60.1" ? DriveRates.driveSidereal : DriveRates.driveLunar;
return DriveRates.driveLunar;
LogMessage("TrackingRate Get", $"{rate} {result}");
return result;
} }
set set
{ {
@@ -2629,6 +2659,11 @@ namespace ASCOM.Meade.net
CheckConnected("TrackingRate Set"); CheckConnected("TrackingRate Set");
CheckParked(); CheckParked();
if (SharedResourcesWrapper.ProductName == TelescopeList.LX200CLASSIC)
{
throw new ASCOM.NotImplementedException("TrackingRate Set");
}
switch (value) switch (value)
{ {
case DriveRates.driveSidereal: case DriveRates.driveSidereal:
@@ -2660,7 +2695,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
ITrackingRates trackingRates = new TrackingRates(); ITrackingRates trackingRates = new TrackingRates(SharedResourcesWrapper.ProductName != TelescopeList.LX200CLASSIC);
LogMessage("TrackingRates", "Get - "); LogMessage("TrackingRates", "Get - ");
foreach (DriveRates driveRate in trackingRates) foreach (DriveRates driveRate in trackingRates)
{ {
@@ -2737,7 +2772,7 @@ namespace ASCOM.Meade.net
return utcDate; return utcDate;
} }
catch (ParkedException e) catch (ParkedException)
{ {
if (ParkedBehaviour == ParkedBehaviour.NoCoordinates) if (ParkedBehaviour == ParkedBehaviour.NoCoordinates)
throw; throw;
+21 -12
View File
@@ -292,25 +292,34 @@ namespace ASCOM.Meade.net
public static void SetupDialog() public static void SetupDialog()
{ {
var profileProperties = ReadProfile(); try
using (SetupDialogForm f = new SetupDialogForm())
{ {
f.SetProfile(profileProperties); var profileProperties = ReadProfile();
if (IsConnected()) using (SetupDialogForm f = new SetupDialogForm())
{ {
f.SetReadOnlyMode(); f.SetProfile(profileProperties);
}
var result = f.ShowDialog(); if (IsConnected())
if (result == DialogResult.OK) {
{ f.SetReadOnlyMode();
profileProperties = f.GetProfile(); }
WriteProfile(profileProperties); // Persist device configuration values to the ASCOM Profile store var result = f.ShowDialog();
if (result == DialogResult.OK)
{
profileProperties = f.GetProfile();
WriteProfile(
profileProperties); // Persist device configuration values to the ASCOM Profile store
}
} }
} }
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
} }
#endregion #endregion