Merged in develop (pull request #50)

Develop
This commit is contained in:
2024-11-12 18:59:03 +00:00
3 changed files with 55 additions and 32 deletions
@@ -911,12 +911,14 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(result, Is.EqualTo(expected)); Assert.That(result, Is.EqualTo(expected));
} }
[Test] [TestCase("Autostar", "43Eg", true)]
public void CanPark_Get_ReturnsTrue() [TestCase("LX200 Classic", "", false)]
public void CanPark_Get_ReturnsTrue(string productName, string firmware, bool canPark)
{ {
ConnectTelescope(productName, firmware, $"{_testProperties.AlignmentMode}N0");
var result = _telescope.CanPark; var result = _telescope.CanPark;
Assert.That(result, Is.True); Assert.That(result, Is.EqualTo(canPark));
} }
[TestCase("Autostar", "43Eg")] [TestCase("Autostar", "43Eg")]
@@ -1622,25 +1624,13 @@ namespace Meade.net.Telescope.UnitTests
} }
[Test] [Test]
public void Park_WhenLX200NotParked_ThenSendsParkCommand() public void Park_WhenLX200ClassicNotParked_ThenSendsParkCommand()
{ {
var alt = 77.55;
var altAsDM = "77*30";
_utilMock.Setup(x => x.DegreesToDM(alt, "*", "", 2)).Returns(altAsDM);
var az = 180;
var azAsDM = "180*00";
_utilMock.Setup(x => x.DegreesToDM(az, "*", "", 2)).Returns(azAsDM);
_sharedResourcesWrapperMock.Setup(x => x.SendBool(_traceLoggerMock.Object, "Sa+77*30", false)).Returns(true);
_sharedResourcesWrapperMock.Setup(x => x.SendBool(_traceLoggerMock.Object, "Sz180*00", false)).Returns(true);
ConnectTelescope(TelescopeList.LX200CLASSIC); ConnectTelescope(TelescopeList.LX200CLASSIC);
Assert.That(_telescope.AtPark, Is.False); Assert.That(_telescope.AtPark, Is.False);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "hP", false), Times.Never);
_telescope.Park(); Assert.Throws<ASCOM.NotImplementedException>(() => { _telescope.Park(); });
Assert.That(_telescope.AtPark, Is.True);
} }
[Test] [Test]
@@ -2701,6 +2691,38 @@ namespace Meade.net.Telescope.UnitTests
[TestCase(DriveRates.driveLunar, "58.9", "Autostar", "A4S4")] [TestCase(DriveRates.driveLunar, "58.9", "Autostar", "A4S4")]
public void TrackingRate_Get_WhenConnected_ThenSendsCommandToTelescope(DriveRates rate, string trackingRate, string productName, string firmware) public void TrackingRate_Get_WhenConnected_ThenSendsCommandToTelescope(DriveRates rate, string trackingRate, string productName, string firmware)
{ {
CultureInfo.CurrentCulture = new CultureInfo("en-GB");
_siderealTrackingRate = trackingRate;
ConnectTelescope(productName, firmware);
_telescope.TrackingRate = rate;
var result = _telescope.TrackingRate;
Assert.That(result, Is.EqualTo(rate));
}
[TestCase(DriveRates.driveSidereal, "60.1", "Autostar", "43Eg")]
[TestCase(DriveRates.driveSidereal, "60.0", "Autostar", "43Eg")]
[TestCase(DriveRates.driveLunar, "57.9", "Autostar", "43Eg")]
[TestCase(DriveRates.driveSidereal, "+60.1", "Autostar", "43Eg")]
[TestCase(DriveRates.driveSidereal, "+60.0", "Autostar", "43Eg")]
[TestCase(DriveRates.driveLunar, "+57.9", "Autostar", "43Eg")]
[TestCase(DriveRates.driveLunar, "57.3", "Autostar", "43Eg")]
[TestCase(DriveRates.driveLunar, "58.9", "Autostar", "43Eg")]
[TestCase(DriveRates.driveSidereal, "60.1", "Autostar", "A4S4")]
[TestCase(DriveRates.driveSidereal, "60.0", "Autostar", "A4S4")]
[TestCase(DriveRates.driveLunar, "57.9", "Autostar", "A4S4")]
[TestCase(DriveRates.driveSidereal, "+60.1", "Autostar", "A4S4")]
[TestCase(DriveRates.driveSidereal, "+60.0", "Autostar", "A4S4")]
[TestCase(DriveRates.driveLunar, "+57.9", "Autostar", "A4S4")]
[TestCase(DriveRates.driveLunar, "57.3", "Autostar", "A4S4")]
[TestCase(DriveRates.driveLunar, "58.9", "Autostar", "A4S4")]
public void TrackingRate_Get_WhenConnectedAndCurrentCultureIsSpanish_ThenSendsCommandToTelescope(DriveRates rate, string trackingRate, string productName, string firmware)
{
CultureInfo.CurrentCulture = new CultureInfo("es-ES");
_siderealTrackingRate = trackingRate; _siderealTrackingRate = trackingRate;
ConnectTelescope(productName, firmware); ConnectTelescope(productName, firmware);
@@ -3005,6 +3027,7 @@ namespace Meade.net.Telescope.UnitTests
[TestCase(TelescopeList.LX200CLASSIC, "", "", false)] [TestCase(TelescopeList.LX200CLASSIC, "", "", false)]
[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, "", "[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.LX200CLASSIC, "", "\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff \x00ff\x00ff\x00ff\x00ff\x00ff\x00ff", false)]
[TestCase(TelescopeList.LX200CLASSIC, "", "[FF][FF][FF] [FF][FF][FF] ", true)] //The test case below is this same string encoded to return exactly what the telescope will return.
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "|", true)] [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "|", true)]
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "\x007f", true)] [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "\x007f", true)]
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "", false)] [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "", false)]
+12 -14
View File
@@ -1520,8 +1520,9 @@ namespace ASCOM.Meade.net
{ {
try try
{ {
LogMessage("CanPark", "Get - " + true); var canPark = SharedResourcesWrapper.ProductName != TelescopeList.LX200CLASSIC;
return true; LogMessage("CanPark", "Get - " + canPark);
return canPark;
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -2289,17 +2290,8 @@ namespace ASCOM.Meade.net
} }
else else
{ {
LogMessage("Park", $"Calculating Park Alt Az"); LogMessage("Park", $"LX200 Classic does not support parking");
var siteLatitude = SiteLatitude; throw new NotImplementedException("Park");
var parkAlt = AlignmentMode == AlignmentModes.algAltAz ? 0 : 90 - siteLatitude;
var parkAz = siteLatitude >= 0 ? 180 : 0;
LogMessage("Park", $"Parking LX200 Classic");
Tracking = false;
LogMessage("Park", $"Slewing to park position az:{parkAz} alt:{parkAlt}");
SlewToAltAz(parkAz, parkAlt, false);
LogMessage("Park", $"Arrived at park position");
} }
//Setting park to true before sending the park command as the Autostar and Audiostar stop serial communications once the park command has been issued. //Setting park to true before sending the park command as the Autostar and Audiostar stop serial communications once the park command has been issued.
@@ -3306,6 +3298,12 @@ namespace ASCOM.Meade.net
isSlewing = true; isSlewing = true;
return isSlewing; return isSlewing;
} }
if (result.Equals("[FF][FF][FF] [FF][FF][FF] "))
{
isSlewing = true;
return isSlewing;
}
////classic LX200 return bar with 32 chars. FF is contained from left to right when slewing ////classic LX200 return bar with 32 chars. FF is contained from left to right when slewing
//byte[] ba = Encoding.Default.GetBytes(result); //byte[] ba = Encoding.Default.GetBytes(result);
@@ -3668,7 +3666,7 @@ namespace ASCOM.Meade.net
rate = rate.Replace("+", string.Empty); rate = rate.Replace("+", string.Empty);
var rateDouble = double.Parse(rate); var rateDouble = double.Parse(rate, CultureInfo.InvariantCulture);
DriveRates result; DriveRates result;
+2
View File
@@ -2,10 +2,12 @@
<Settings> <Settings>
<AllowParallelTestExecution>True</AllowParallelTestExecution> <AllowParallelTestExecution>True</AllowParallelTestExecution>
<CopyReferencedAssembliesToWorkspace>True</CopyReferencedAssembliesToWorkspace> <CopyReferencedAssembliesToWorkspace>True</CopyReferencedAssembliesToWorkspace>
<EnableRDI>True</EnableRDI>
<MetricsExclusionList> <MetricsExclusionList>
<Value>FocuserTestConsole\FocuserTestConsole.csproj</Value> <Value>FocuserTestConsole\FocuserTestConsole.csproj</Value>
<Value>TelescopeTestConsole\TelescopeTestConsole.csproj</Value> <Value>TelescopeTestConsole\TelescopeTestConsole.csproj</Value>
</MetricsExclusionList> </MetricsExclusionList>
<RdiConfigured>True</RdiConfigured>
<SolutionConfigured>True</SolutionConfigured> <SolutionConfigured>True</SolutionConfigured>
</Settings> </Settings>
</SolutionConfiguration> </SolutionConfiguration>