@@ -1322,6 +1322,63 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
_utilMock.Verify( x => x.WaitForMilliseconds(duration), Times.Once);
|
_utilMock.Verify( x => x.WaitForMilliseconds(duration), Times.Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(GuideDirections.guideEast)]
|
||||||
|
[TestCase(GuideDirections.guideWest)]
|
||||||
|
[TestCase(GuideDirections.guideNorth)]
|
||||||
|
[TestCase(GuideDirections.guideSouth)]
|
||||||
|
public void PulseGuide_WhenSlewingAndPulseGuideAttempted_ThenThrowsExpectedException(GuideDirections direction)
|
||||||
|
{
|
||||||
|
_sharedResourcesWrapperMock.Setup(x => x.SendString("#:D#")).Returns("|");
|
||||||
|
|
||||||
|
var duration = 0;
|
||||||
|
ConnectTelescope();
|
||||||
|
|
||||||
|
var exception = Assert.Throws<InvalidOperationException>(() => { _telescope.PulseGuide(direction, duration); });
|
||||||
|
|
||||||
|
Assert.That(exception.Message, Is.EqualTo("Unable to PulseGuide whilst slewing to target."));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(GuideDirections.guideEast, TelescopeAxes.axisPrimary)]
|
||||||
|
[TestCase(GuideDirections.guideWest, TelescopeAxes.axisPrimary)]
|
||||||
|
[TestCase(GuideDirections.guideNorth, TelescopeAxes.axisSecondary)]
|
||||||
|
[TestCase(GuideDirections.guideSouth, TelescopeAxes.axisSecondary)]
|
||||||
|
public void PulseGuide_WhenMovingAxisAndPulseGuideAttempted_ThenThrowsExpectedException(GuideDirections direction, TelescopeAxes axes)
|
||||||
|
{
|
||||||
|
_sharedResourcesWrapperMock.Setup(x => x.SendString("#:D#")).Returns("");
|
||||||
|
|
||||||
|
var duration = 0;
|
||||||
|
ConnectTelescope();
|
||||||
|
|
||||||
|
_telescope.MoveAxis(axes, 1);
|
||||||
|
|
||||||
|
var exception = Assert.Throws<InvalidOperationException>(() => { _telescope.PulseGuide(direction, duration); });
|
||||||
|
|
||||||
|
Assert.That(exception.Message, Is.EqualTo("Unable to PulseGuide while moving same axis."));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(GuideDirections.guideEast)]
|
||||||
|
[TestCase(GuideDirections.guideWest)]
|
||||||
|
[TestCase(GuideDirections.guideNorth)]
|
||||||
|
[TestCase(GuideDirections.guideSouth)]
|
||||||
|
public void PulseGuide_WhenConnectedAndNewerPulseGuidingNotAvailable_ThenIsSlewingRespondsFalse(GuideDirections direction)
|
||||||
|
{
|
||||||
|
var duration = 0;
|
||||||
|
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
|
||||||
|
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_30Ee);
|
||||||
|
|
||||||
|
var isSlewing = true;
|
||||||
|
_utilMock.Setup(x => x.WaitForMilliseconds(duration)).Callback(() =>
|
||||||
|
{
|
||||||
|
isSlewing = _telescope.Slewing;
|
||||||
|
});
|
||||||
|
|
||||||
|
_telescope.Connected = true;
|
||||||
|
|
||||||
|
_telescope.PulseGuide(direction, duration);
|
||||||
|
|
||||||
|
Assert.That(isSlewing, Is.False);
|
||||||
|
}
|
||||||
|
|
||||||
[TestCase(GuideDirections.guideEast)]
|
[TestCase(GuideDirections.guideEast)]
|
||||||
[TestCase(GuideDirections.guideWest)]
|
[TestCase(GuideDirections.guideWest)]
|
||||||
[TestCase(GuideDirections.guideNorth)]
|
[TestCase(GuideDirections.guideNorth)]
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ namespace ASCOM.Meade.net
|
|||||||
}
|
}
|
||||||
|
|
||||||
private double _guideRate;
|
private double _guideRate;
|
||||||
|
private bool _isGuiding = false;
|
||||||
|
|
||||||
private void Initialise()
|
private void Initialise()
|
||||||
{
|
{
|
||||||
@@ -1415,6 +1416,15 @@ namespace ASCOM.Meade.net
|
|||||||
LogMessage("PulseGuide", $"pulse guide direction {direction} duration {duration}");
|
LogMessage("PulseGuide", $"pulse guide direction {direction} duration {duration}");
|
||||||
CheckConnected("PulseGuide");
|
CheckConnected("PulseGuide");
|
||||||
|
|
||||||
|
if (IsSlewingToTarget())
|
||||||
|
throw new InvalidOperationException("Unable to PulseGuide whilst slewing to target.");
|
||||||
|
|
||||||
|
if (_movingPrimary && (direction == GuideDirections.guideEast || direction == GuideDirections.guideWest))
|
||||||
|
throw new InvalidOperationException("Unable to PulseGuide while moving same axis.");
|
||||||
|
|
||||||
|
if (_movingSecondary && (direction == GuideDirections.guideNorth || direction == GuideDirections.guideSouth))
|
||||||
|
throw new InvalidOperationException("Unable to PulseGuide while moving same axis.");
|
||||||
|
|
||||||
var coordinatesBeforeMove = GetTelescopeRaAndDec();
|
var coordinatesBeforeMove = GetTelescopeRaAndDec();
|
||||||
|
|
||||||
if (_userNewerPulseGuiding && duration < 10000)
|
if (_userNewerPulseGuiding && duration < 10000)
|
||||||
@@ -1449,6 +1459,9 @@ namespace ASCOM.Meade.net
|
|||||||
_utilities.WaitForMilliseconds(duration); //todo figure out if this is really needed
|
_utilities.WaitForMilliseconds(duration); //todo figure out if this is really needed
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
_isGuiding = true;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
@@ -1474,6 +1487,11 @@ namespace ASCOM.Meade.net
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_isGuiding = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var coordinatesAfterMove = GetTelescopeRaAndDec();
|
var coordinatesAfterMove = GetTelescopeRaAndDec();
|
||||||
|
|
||||||
@@ -1915,6 +1933,9 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
private bool MovingAxis()
|
private bool MovingAxis()
|
||||||
{
|
{
|
||||||
|
if (_isGuiding)
|
||||||
|
return false;
|
||||||
|
|
||||||
return _movingPrimary || _movingSecondary;
|
return _movingPrimary || _movingSecondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1928,8 +1949,17 @@ namespace ASCOM.Meade.net
|
|||||||
if (MovingAxis())
|
if (MovingAxis())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
return IsSlewingToTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsSlewingToTarget()
|
||||||
|
{
|
||||||
CheckConnected("Slewing Get");
|
CheckConnected("Slewing Get");
|
||||||
|
|
||||||
|
if (_isGuiding)
|
||||||
|
return false;
|
||||||
|
|
||||||
var result = _sharedResourcesWrapper.SendString("#:D#");
|
var result = _sharedResourcesWrapper.SendString("#:D#");
|
||||||
//:D# Requests a string of bars indicating the distance to the current target location.
|
//:D# Requests a string of bars indicating the distance to the current target location.
|
||||||
//Returns:
|
//Returns:
|
||||||
@@ -1946,7 +1976,6 @@ namespace ASCOM.Meade.net
|
|||||||
LogMessage("Slewing Get", $"Result = {isSlewing}");
|
LogMessage("Slewing Get", $"Result = {isSlewing}");
|
||||||
return isSlewing;
|
return isSlewing;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void SyncToAltAz(double azimuth, double altitude)
|
public void SyncToAltAz(double azimuth, double altitude)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user