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:
@@ -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]
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace ASCOM.Meade.net
|
||||
// Your driver's DeviceID is ASCOM.Meade.net.Telescope
|
||||
//
|
||||
// The Guid attribute sets the CLSID for ASCOM.Meade.net.Telescope
|
||||
// The ClassInterface/None addribute prevents an empty interface called
|
||||
// The ClassInterface/None attribute prevents an empty interface called
|
||||
// _Meade.net from being created and used as the [default] interface
|
||||
//
|
||||
// Replace the not implemented exceptions with code to implement the function or
|
||||
@@ -78,6 +78,11 @@ namespace ASCOM.Meade.net
|
||||
/// </summary>
|
||||
private int _digitsDe = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Used to make sure that the slewing property returns true when in the middle of an ascom slew command, anything above 0 means that we are inside slewing commands.
|
||||
/// </summary>
|
||||
private int _forceSlewingCount = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Meade.net"/> class.
|
||||
/// Must be public for COM registration.
|
||||
@@ -1350,7 +1355,7 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
get
|
||||
{
|
||||
var apertureArea = _profileProperties.ApertureArea / 1000;
|
||||
var apertureArea = _profileProperties.ApertureArea / (1000*1000);
|
||||
LogMessage("ApertureArea Get", $"{apertureArea}");
|
||||
return apertureArea;
|
||||
}
|
||||
@@ -2860,6 +2865,9 @@ namespace ASCOM.Meade.net
|
||||
}
|
||||
|
||||
public void SlewToAltAzAsync(double azimuth, double altitude, bool polar)
|
||||
{
|
||||
_forceSlewingCount++;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -2906,6 +2914,11 @@ namespace ASCOM.Meade.net
|
||||
throw;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_forceSlewingCount--;
|
||||
}
|
||||
}
|
||||
|
||||
private double TargetAltitude
|
||||
{
|
||||
@@ -2992,7 +3005,7 @@ namespace ASCOM.Meade.net
|
||||
LogMessage("DoSlewAsync", "Beginning slew sequence");
|
||||
CheckConnected("DoSlewAsync");
|
||||
CheckParked();
|
||||
if (Slewing)
|
||||
if (GetSlewing(true))
|
||||
{
|
||||
LogMessage("DoSlewAsync", "Cannot start a slew whilst slew is in progress.");
|
||||
throw new ASCOM.InvalidOperationException("Cannot start a slew whilst slew is in progress.");
|
||||
@@ -3130,6 +3143,9 @@ namespace ASCOM.Meade.net
|
||||
}
|
||||
|
||||
public void SlewToCoordinatesAsync(double rightAscension, double declination)
|
||||
{
|
||||
_forceSlewingCount++;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -3149,6 +3165,11 @@ namespace ASCOM.Meade.net
|
||||
throw;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_forceSlewingCount--;
|
||||
}
|
||||
}
|
||||
|
||||
public void SlewToTarget()
|
||||
{
|
||||
@@ -3174,6 +3195,9 @@ namespace ASCOM.Meade.net
|
||||
private const double InvalidParameter = -1000;
|
||||
|
||||
public void SlewToTargetAsync()
|
||||
{
|
||||
_forceSlewingCount++;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -3191,6 +3215,11 @@ namespace ASCOM.Meade.net
|
||||
throw;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_forceSlewingCount--;
|
||||
}
|
||||
}
|
||||
|
||||
private bool MovingAxis()
|
||||
{
|
||||
@@ -3212,12 +3241,7 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
try
|
||||
{
|
||||
var isSlewing = GetSlewing();
|
||||
|
||||
if (isSlewing)
|
||||
SetSlewingMinEndTime();
|
||||
else if (_clock.UtcNow < SharedResourcesWrapper.EarliestNonSlewingTime)
|
||||
isSlewing = true;
|
||||
var isSlewing = GetSlewing(false);
|
||||
|
||||
LogMessage("Slewing", $"Result = {isSlewing}");
|
||||
return isSlewing;
|
||||
@@ -3240,17 +3264,32 @@ namespace ASCOM.Meade.net
|
||||
return TimeSpan.FromSeconds( SlewSettleTime + _profileProperties.SettleTime );
|
||||
}
|
||||
|
||||
private bool GetSlewing()
|
||||
private bool GetSlewing(bool isInternalCall)
|
||||
{
|
||||
var result = false;
|
||||
|
||||
try
|
||||
{
|
||||
if (Connected)
|
||||
{
|
||||
result = MovingAxis() || IsSlewingToTarget();
|
||||
if (!isInternalCall && !result)
|
||||
{
|
||||
result = _forceSlewingCount > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMessage("GetSlewing", $"Result = {result}");
|
||||
LogMessage("GetSlewing", $"Result = {result} (isInternalCall = {isInternalCall} _forceSlewingCount= {_forceSlewingCount})");
|
||||
}
|
||||
|
||||
if (result)
|
||||
SetSlewingMinEndTime();
|
||||
else if (_clock.UtcNow < SharedResourcesWrapper.EarliestNonSlewingTime && !isInternalCall)
|
||||
{
|
||||
LogMessage("GetSlewing", $"Last slewing operation has not yet completed. You need to wait for another {(_clock.UtcNow - SharedResourcesWrapper.EarliestNonSlewingTime).TotalMilliseconds} Milliseconds");
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -3807,18 +3846,18 @@ namespace ASCOM.Meade.net
|
||||
UtcCorrection = GetUtcCorrection()
|
||||
};
|
||||
|
||||
int month = telescopeDateDetails.TelescopeDate.Substring(0, 2).ToInteger();
|
||||
int day = telescopeDateDetails.TelescopeDate.Substring(3, 2).ToInteger();
|
||||
int year = telescopeDateDetails.TelescopeDate.Substring(6, 2).ToInteger();
|
||||
var month = telescopeDateDetails.TelescopeDate.Substring(0, 2).ToInteger();
|
||||
var day = telescopeDateDetails.TelescopeDate.Substring(3, 2).ToInteger();
|
||||
var year = telescopeDateDetails.TelescopeDate.Substring(6, 2).ToInteger();
|
||||
|
||||
if (year < 2000) //todo fix this hack that will create a Y2K100 bug
|
||||
{
|
||||
year = year + 2000;
|
||||
year += 2000;
|
||||
}
|
||||
|
||||
int hour = telescopeDateDetails.TelescopeTime.Substring(0, 2).ToInteger();
|
||||
int minute = telescopeDateDetails.TelescopeTime.Substring(3, 2).ToInteger();
|
||||
int second = telescopeDateDetails.TelescopeTime.Substring(6, 2).ToInteger();
|
||||
var hour = telescopeDateDetails.TelescopeTime.Substring(0, 2).ToInteger();
|
||||
var minute = telescopeDateDetails.TelescopeTime.Substring(3, 2).ToInteger();
|
||||
var second = telescopeDateDetails.TelescopeTime.Substring(6, 2).ToInteger();
|
||||
|
||||
var utcDate = new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc) +
|
||||
telescopeDateDetails.UtcCorrection;
|
||||
|
||||
@@ -388,6 +388,11 @@ namespace ASCOM.Meade.net
|
||||
Verb = "open"
|
||||
});
|
||||
}
|
||||
|
||||
private void label29_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Generated
+1
@@ -434,6 +434,7 @@ namespace ASCOM.Meade.net
|
||||
//
|
||||
resources.ApplyResources(this.label29, "label29");
|
||||
this.label29.Name = "label29";
|
||||
this.label29.Click += new System.EventHandler(this.label29_Click);
|
||||
//
|
||||
// txtApertureArea
|
||||
//
|
||||
|
||||
@@ -1579,13 +1579,13 @@
|
||||
<value>494, 139</value>
|
||||
</data>
|
||||
<data name="label29.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>23, 13</value>
|
||||
<value>26, 13</value>
|
||||
</data>
|
||||
<data name="label29.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>56</value>
|
||||
</data>
|
||||
<data name="label29.Text" xml:space="preserve">
|
||||
<value>mm</value>
|
||||
<value>mm²</value>
|
||||
</data>
|
||||
<data name=">>label29.Name" xml:space="preserve">
|
||||
<value>label29</value>
|
||||
@@ -1678,7 +1678,7 @@
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>25</value>
|
||||
<value>232</value>
|
||||
</metadata>
|
||||
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
|
||||
<value>6, 13</value>
|
||||
|
||||
Reference in New Issue
Block a user