Merged in develop (pull request #51)

Develop

* Added an extra test to Slewing so that if connected will check with the mount to see if it's actually slewing, which is should have been doing

* Added extra check to ensure that slewing is return true whilst executing one of the ascom slew commands.

* Tweaked the GetSlewing command hopefully this makes the logic function correctly.
Also upgraded the logging to expose whether it's an internal call or not.

* Another slight tweak to the GetSlewing internal call code.

* Fixed problem where the telescope area was in mm when it should be mm squared.  And the driver was incorrect by a factor of 1000.

* Adding more information to the tracelog for get slewing

* Tweaked the code so that the _forceInternal variable doesn't care about if the scope is connected or not.

* Modified the code again, so that the _forceSlewingCount is done last, so that it's at up to date as possible.
This commit is contained in:
2025-01-01 12:10:00 +00:00
parent 372c98a22c
commit 7a0ee85af6
5 changed files with 154 additions and 87 deletions
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using ASCOM;
using ASCOM.Astrometry.AstroUtils;
@@ -843,9 +845,11 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void ApertureArea_Get_ReturnsExpectedResult()
{
_profileProperties.ApertureArea = 130674;
var result = _telescope.ApertureArea;
Assert.That(result, Is.EqualTo(_profileProperties.ApertureArea / 1000));
Assert.That(result, Is.EqualTo(_profileProperties.ApertureArea / (1000*1000)));
}
[Test]
@@ -2940,13 +2944,15 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void Slewing_WhenConnectedAndTelescopeFails_ThenReturnsFalse()
{
_sharedResourcesWrapperMock.Setup(x => x.SendString(_traceLoggerMock.Object, "D", false)).Returns("");
ConnectTelescope();
var result = _telescope.Slewing;
Assert.That(result, Is.False);
_sharedResourcesWrapperMock.Verify(x => x.SendString(_traceLoggerMock.Object, "D", false), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendString(_traceLoggerMock.Object, "D", false), Times.Exactly(1));
}
[Test]
@@ -3033,7 +3039,24 @@ namespace Meade.net.Telescope.UnitTests
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "", false)]
public void Slewing_WhenTelescopeNotSlewing_ThenReturnsFalse(string productName, string firmwareVersion, string response, bool isSlewing)
{
_sharedResourcesWrapperMock.Setup(x => x.SendString(_traceLoggerMock.Object, "D", false)).Returns(response);
List<string> slewingResponses = new List<string>();
if (isSlewing)
slewingResponses.Add("|");
slewingResponses.Add(response);
var callCounter = 0;
_sharedResourcesWrapperMock.Setup(x => x.SendString(_traceLoggerMock.Object, "D", false)).Returns( () => {
var slewingResult = slewingResponses[callCounter];
callCounter++;
if (callCounter > slewingResponses.Count - 1)
{
callCounter = slewingResponses.Count - 1;
}
return slewingResult;
});
ConnectTelescope(productName, firmwareVersion);
@@ -3041,7 +3064,10 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(result, Is.EqualTo(isSlewing));
_sharedResourcesWrapperMock.Verify(x => x.SendString(_traceLoggerMock.Object, "D", false), Times.Once);
if (isSlewing)
{
_sharedResourcesWrapperMock.Verify(x => x.SendString(_traceLoggerMock.Object, "D", false), Times.Exactly(1));
}
}
[TestCase(1, TelescopeAxes.axisPrimary)]
@@ -3267,7 +3293,7 @@ namespace Meade.net.Telescope.UnitTests
{
_sharedResourcesWrapperMock.Setup(x => x.SendChar(_traceLoggerMock.Object, "MS", false)).Returns("0");
var preTestItterations = 1;
var preTestItterations = 2;
var slewCounter = 0;
var iterations = 10;
@@ -3293,8 +3319,6 @@ namespace Meade.net.Telescope.UnitTests
_telescope.TargetDeclination = 1;
_telescope.SlewToTarget();
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations - preTestItterations));
}
[Test]
@@ -3359,7 +3383,7 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Setup(x => x.SendChar(_traceLoggerMock.Object, "MS", false)).Returns("0");
var preTestItterations = 1;
var preTestItterations = 2;
var slewCounter = 0;
var iterations = 10;
_sharedResourcesWrapperMock.Setup(x => x.SendString(_traceLoggerMock.Object, "D", false)).Returns(() =>
@@ -3378,8 +3402,6 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(_telescope.TargetRightAscension, Is.EqualTo(_testProperties.RightAscension));
Assert.That(_telescope.TargetDeclination, Is.EqualTo(dmsResult));
_sharedResourcesWrapperMock.Verify(x => x.SendChar(_traceLoggerMock.Object, "MS", false), Times.Once);
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations - preTestItterations));
}
[Test]
@@ -3482,7 +3504,7 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock.Setup(x => x.SendChar(_traceLoggerMock.Object, "MS", false)).Returns("0");
var preTestItterations = 1;
var preTestItterations = 2;
var slewCounter = 0;
var iterations = 10;
_sharedResourcesWrapperMock.Setup(x => x.SendString(_traceLoggerMock.Object, "D", false)).Returns(() =>
@@ -3502,7 +3524,6 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(_telescope.TargetRightAscension, Is.EqualTo(_testProperties.RightAscension));
Assert.That(_telescope.TargetDeclination, Is.EqualTo(_testProperties.Declination));
_sharedResourcesWrapperMock.Verify(x => x.SendChar(_traceLoggerMock.Object, "MS", false), Times.Once);
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations - preTestItterations));
}
[Test]
@@ -3583,16 +3604,17 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void AbortSlew_WhenConnected_ThenSendsStopSlewingToTelescope()
{
_sharedResourcesWrapperMock.Setup(x => x.SendString(_traceLoggerMock.Object, "D", false)).Returns("");
ConnectTelescope();
_telescope.AbortSlew();
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "Q", false), Times.Once);
var isSloSlewing = _telescope.Slewing;
var isSlewing = _telescope.Slewing;
Assert.That(isSloSlewing, Is.False);
_sharedResourcesWrapperMock.Verify(x => x.SendString(_traceLoggerMock.Object, "D", false), Times.Once);
Assert.That(isSlewing, Is.False);
}
[Test]