Refactored code

Added support for setting the guide rate on the RCX400
This commit is contained in:
2022-07-17 12:03:32 +01:00
parent 5f75916116
commit 5f3157a58d
2 changed files with 114 additions and 103 deletions
@@ -965,24 +965,16 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: CanSetGuideRates Get")); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: CanSetGuideRates Get"));
} }
[Test] [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_31Ee, false)]
public void CanSetGuideRates_Get_WhenConnectedToAutostar_ThenReturnsFalse() [TestCase(TelescopeList.LX200GPS, TelescopeList.LX200GPS_42G, true )]
[TestCase(TelescopeList.RCX400, TelescopeList.RCX400_22I, true)]
public void CanSetGuideRates_Get_WhenConnectedToTelescope_ThenReturnsExpectedValue( string productName, string firmware, bool expectedResult)
{ {
ConnectTelescope(); ConnectTelescope(productName, firmware);
var result = _telescope.CanSetGuideRates; var result = _telescope.CanSetGuideRates;
Assert.That(result, Is.False); Assert.That(result, Is.EqualTo(expectedResult));
}
[Test]
public void CanSetGuideRates_Get_WhenConnectedToLX200GPS_ThenReturnsTrue()
{
ConnectTelescope(TelescopeList.LX200GPS, TelescopeList.LX200GPS_42G);
var result = _telescope.CanSetGuideRates;
Assert.That(result, Is.True);
} }
[Test] [Test]
@@ -1195,6 +1187,7 @@ namespace Meade.net.Telescope.UnitTests
} }
[TestCase(TelescopeList.LX200GPS, TelescopeList.LX200GPS_42G, true)] [TestCase(TelescopeList.LX200GPS, TelescopeList.LX200GPS_42G, true)]
[TestCase(TelescopeList.RCX400, TelescopeList.RCX400_22I, true)]
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, false)] [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, false)]
public void CanUnpark_Get_ReturnsExpectedValue(string productVersion, string firmware, bool expectedResult) public void CanUnpark_Get_ReturnsExpectedValue(string productVersion, string firmware, bool expectedResult)
{ {
+107 -89
View File
@@ -579,33 +579,38 @@ namespace ASCOM.Meade.net
LogMessage("SendTimeTimeToHandbox", $"SendDateTime: {_profileProperties.SendDateTime}"); LogMessage("SendTimeTimeToHandbox", $"SendDateTime: {_profileProperties.SendDateTime}");
if (_profileProperties.SendDateTime) if (_profileProperties.SendDateTime)
{ {
if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) switch (SharedResourcesWrapper.ProductName)
{ {
LogMessage("SendTimeTimeToHandbox", case TelescopeList.LX200GPS:
$"LX200GPS Detecting if daylight savings message on screen: {_profileProperties.SendDateTime}"); case TelescopeList.RCX400:
var displayText = Action("Handbox", "readdisplay"); {
LogMessage("SendTimeTimeToHandbox", $"Current Handset display: {displayText}");
if (displayText.Contains("Daylight"))
{
LogMessage("SendTimeTimeToHandbox", LogMessage("SendTimeTimeToHandbox",
$"LX200GPS Setting Date time and bypassing settings screens: {_profileProperties.SendDateTime}"); $"{SharedResourcesWrapper.ProductName} Detecting if daylight savings message on screen: {_profileProperties.SendDateTime}");
BypassHandboxEntryForAutostarII(); var displayText = Action("Handbox", "readdisplay");
LogMessage("SendTimeTimeToHandbox", $"Current Handset display: {displayText}");
if (displayText.Contains("Daylight"))
{
LogMessage("SendTimeTimeToHandbox",
$"{SharedResourcesWrapper.ProductName} Setting Date time and bypassing settings screens: {_profileProperties.SendDateTime}");
BypassHandboxEntryForAutostarII();
}
else
{
LogMessage("SendTimeTimeToHandbox",
$"{SharedResourcesWrapper.ProductName} Sending current date and time: {_profileProperties.SendDateTime}");
SendCurrentDateTime();
LogMessage("SendTimeTimeToHandbox",
$"{SharedResourcesWrapper.ProductName} Attempting manual bypass of prompts: {_profileProperties.SendDateTime}");
ApplySkipAutoStarPrompts();
}
break;
} }
else default:
{ LogMessage("Connected Set", $"{SharedResourcesWrapper.ProductName} Attempting manual bypass of prompts");
LogMessage("SendTimeTimeToHandbox",
$"LX200GPS Sending current date and time: {_profileProperties.SendDateTime}");
SendCurrentDateTime();
LogMessage("SendTimeTimeToHandbox",
$"LX200GPS Attempting manual bypass of prompts: {_profileProperties.SendDateTime}");
ApplySkipAutoStarPrompts(); ApplySkipAutoStarPrompts();
} SendCurrentDateTime();
} break;
else
{
LogMessage("Connected Set", "Autostar Attempting manual bypass of prompts");
ApplySkipAutoStarPrompts();
SendCurrentDateTime();
} }
} }
} }
@@ -647,34 +652,42 @@ namespace ASCOM.Meade.net
private void ApplySkipAutoStarPrompts() private void ApplySkipAutoStarPrompts()
{ {
if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS || SharedResourcesWrapper.ProductName == TelescopeList.RCX400) switch (SharedResourcesWrapper.ProductName)
{ {
var displayText = Action("Handbox", "readdisplay"); case TelescopeList.LX200GPS:
case TelescopeList.RCX400:
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"); var displayText = Action("Handbox", "readdisplay");
if (displayText.Contains("Align:"))
if (displayText.Contains("Daylight"))
{ {
i = 0; for (var i = 0; i < 3; i++)
continue; {
Action("Handbox", "enter");
_utilities.WaitForMilliseconds(2000);
}
} }
Action("Handbox", "mode"); break;
_utilities.WaitForMilliseconds(500); }
i--; default:
{
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--;
}
break;
} }
} }
} }
@@ -707,24 +720,18 @@ namespace ASCOM.Meade.net
return false; return false;
case "pulse guiding": case "pulse guiding":
return true; return true;
default: default:
if (SharedResourcesWrapper.ProductName == TelescopeList.Autostar497) switch (SharedResourcesWrapper.ProductName)
{ {
return FirmwareIsGreaterThan(TelescopeList.Autostar497_31Ee); case TelescopeList.Autostar497:
return FirmwareIsGreaterThan(TelescopeList.Autostar497_31Ee);
case TelescopeList.LX200GPS:
return true;
case TelescopeList.RCX400:
return FirmwareIsGreaterThan(TelescopeList.RCX400_22I);
default:
return false;
} }
if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS)
{
return true;
}
if (SharedResourcesWrapper.ProductName == TelescopeList.RCX400)
{
return FirmwareIsGreaterThan(TelescopeList.RCX400_22I);
}
return false;
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -746,12 +753,14 @@ namespace ASCOM.Meade.net
private bool IsGuideRateSettingSupported() private bool IsGuideRateSettingSupported()
{ {
if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) switch (SharedResourcesWrapper.ProductName)
{ {
return true; case TelescopeList.LX200GPS:
case TelescopeList.RCX400:
return true;
default:
return false;
} }
return false;
} }
private bool IsGwCommandSupported() private bool IsGwCommandSupported()
@@ -1230,14 +1239,16 @@ namespace ASCOM.Meade.net
{ {
CheckConnected("Altitude Get"); CheckConnected("Altitude Get");
if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) switch (SharedResourcesWrapper.ProductName)
{ {
return GetRealTelescopeAltitude(); case TelescopeList.LX200GPS:
case TelescopeList.RCX400:
return GetRealTelescopeAltitude();
default:
var altAz = CalcAltAzFromTelescopeEqData();
LogMessage("Altitude", $"{altAz.Altitude}");
return altAz.Altitude;
} }
var altAz = CalcAltAzFromTelescopeEqData();
LogMessage("Altitude", $"{altAz.Altitude}");
return altAz.Altitude;
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -1394,14 +1405,16 @@ namespace ASCOM.Meade.net
{ {
CheckConnected("Azimuth Get"); CheckConnected("Azimuth Get");
if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) switch (SharedResourcesWrapper.ProductName)
{ {
return GetRealTelescopeAzimuth(); case TelescopeList.LX200GPS:
case TelescopeList.RCX400:
return GetRealTelescopeAzimuth();
default:
var altAz = CalcAltAzFromTelescopeEqData();
LogMessage("Azimuth Get", $"{altAz.Azimuth}");
return altAz.Azimuth;
} }
var altAz = CalcAltAzFromTelescopeEqData();
LogMessage("Azimuth Get", $"{altAz.Azimuth}");
return altAz.Azimuth;
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -1754,6 +1767,7 @@ namespace ASCOM.Meade.net
var unParkableScopes = new List<string> var unParkableScopes = new List<string>
{ {
TelescopeList.LX200GPS, TelescopeList.LX200GPS,
TelescopeList.RCX400,
TelescopeList.LX200CLASSIC TelescopeList.LX200CLASSIC
}; };
@@ -3812,22 +3826,26 @@ namespace ASCOM.Meade.net
if (!AtPark) if (!AtPark)
return; return;
if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) switch (SharedResourcesWrapper.ProductName)
{ {
case TelescopeList.RCX400:
case TelescopeList.LX200GPS:
SharedResourcesWrapper.SendChar("I");
//:I# LX200 GPS Only - Causes the telescope to cease current operations and restart at its power on initialization.
//Returns: X once the handset restart has completed
SharedResourcesWrapper.SendChar("I"); BypassHandboxEntryForAutostarII();
//:I# LX200 GPS Only - Causes the telescope to cease current operations and restart at its power on initialization. break;
//Returns: X once the handset restart has completed case TelescopeList.LX200CLASSIC:
BypassHandboxEntryForAutostarII();
}
else if (SharedResourcesWrapper.ProductName == TelescopeList.LX200CLASSIC)
{
if (SharedResourcesWrapper.RestartTracking)
{ {
LogMessage("Unpark", "Turning tracking on"); if (SharedResourcesWrapper.RestartTracking)
Tracking = true; {
LogMessage("Unpark", "Turning tracking on completed"); LogMessage("Unpark", "Turning tracking on");
Tracking = true;
LogMessage("Unpark", "Turning tracking on completed");
}
break;
} }
} }