Seperated the SlewSettleTime property from the ProfileSettle time, and implemented a delay on IsSlewing to use the combined SettleTimes
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace ASCOM.Meade.net
|
||||
{
|
||||
public class Clock : IClock
|
||||
{
|
||||
public DateTime UtcNow => DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace ASCOM.Meade.net
|
||||
{
|
||||
public interface IClock
|
||||
{
|
||||
DateTime UtcNow { get; }
|
||||
}
|
||||
}
|
||||
@@ -124,8 +124,10 @@
|
||||
<Compile Include="AstroMaths\EquatorialCoordinates.cs" />
|
||||
<Compile Include="AstroMaths\HorizonCoordinates.cs" />
|
||||
<Compile Include="AstroMaths\IAstroMaths.cs" />
|
||||
<Compile Include="Clock.cs" />
|
||||
<Compile Include="ComparisonResult.cs" />
|
||||
<Compile Include="DoubleExtensions.cs" />
|
||||
<Compile Include="IClock.cs" />
|
||||
<Compile Include="StringExtensions.cs" />
|
||||
<Compile Include="Telescope.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
@@ -60,16 +60,20 @@ namespace ASCOM.Meade.net
|
||||
|
||||
private readonly IAstroMaths _astroMaths;
|
||||
|
||||
private readonly IClock _clock;
|
||||
|
||||
/// <summary>
|
||||
/// Private variable to hold number of decimals for RA
|
||||
/// </summary>
|
||||
private int _digitsRa = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Private variable to hold number of decimals for DE
|
||||
/// Private variable to hold number of decimals for Dec
|
||||
/// </summary>
|
||||
private int _digitsDe = 2;
|
||||
|
||||
private short _settleTime;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Meade.net"/> class.
|
||||
/// Must be public for COM registration.
|
||||
@@ -84,6 +88,7 @@ namespace ASCOM.Meade.net
|
||||
_utilitiesExtra = util; //Initialise util object
|
||||
_astroUtilities = new AstroUtils(); // Initialise astro utilities object
|
||||
_astroMaths = new AstroMaths.AstroMaths();
|
||||
_clock = new Clock();
|
||||
|
||||
Initialise(nameof(Telescope));
|
||||
}
|
||||
@@ -116,8 +121,9 @@ namespace ASCOM.Meade.net
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
public Telescope( IUtil util, IUtilExtra utilExtra, IAstroUtils astroUtilities, ISharedResourcesWrapper sharedResourcesWrapper, IAstroMaths astroMaths) : base(sharedResourcesWrapper)
|
||||
public Telescope( IUtil util, IUtilExtra utilExtra, IAstroUtils astroUtilities, ISharedResourcesWrapper sharedResourcesWrapper, IAstroMaths astroMaths, IClock clock) : base(sharedResourcesWrapper)
|
||||
{
|
||||
_clock = clock;
|
||||
_utilities = util; //Initialise util object
|
||||
_utilitiesExtra = utilExtra; //Initialise util object
|
||||
_astroUtilities = astroUtilities; // Initialise astro utilities object
|
||||
@@ -1775,15 +1781,14 @@ namespace ASCOM.Meade.net
|
||||
get
|
||||
{
|
||||
CheckConnected("SlewSettleTime Get");
|
||||
LogMessage("SlewSettleTime Get", $"{SettleTime} Seconds");
|
||||
return SettleTime;
|
||||
LogMessage("SlewSettleTime Get", $"{_settleTime} Seconds");
|
||||
return _settleTime;
|
||||
}
|
||||
// ReSharper disable once ValueParameterNotUsed
|
||||
set
|
||||
{
|
||||
CheckConnected("SlewSettleTime Set");
|
||||
LogMessage("SlewSettleTime Set", $"Setting from {SettleTime} to {value}");
|
||||
SettleTime = value;
|
||||
LogMessage("SlewSettleTime Set", $"Setting from {_settleTime} to {value}");
|
||||
_settleTime = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1964,16 +1969,29 @@ namespace ASCOM.Meade.net
|
||||
return _movingPrimary || _movingSecondary;
|
||||
}
|
||||
|
||||
private DateTime _earliestNonSlewingTime = DateTime.MinValue;
|
||||
|
||||
public bool Slewing
|
||||
{
|
||||
get
|
||||
{
|
||||
var isSlewing = GetSlewing();
|
||||
|
||||
if (isSlewing)
|
||||
_earliestNonSlewingTime = _clock.UtcNow + GetTotalSlewingSettleTime();
|
||||
else if (_clock.UtcNow < _earliestNonSlewingTime)
|
||||
isSlewing = true;
|
||||
|
||||
LogMessage("Slewing", $"Result = {isSlewing}");
|
||||
return isSlewing;
|
||||
}
|
||||
}
|
||||
|
||||
private TimeSpan GetTotalSlewingSettleTime()
|
||||
{
|
||||
return TimeSpan.FromSeconds( SlewSettleTime + ProfileSettleTime );
|
||||
}
|
||||
|
||||
private bool GetSlewing()
|
||||
{
|
||||
if (!Connected) return false;
|
||||
@@ -2001,7 +2019,7 @@ namespace ASCOM.Meade.net
|
||||
bool isSlewing = false;
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(result))
|
||||
if (string.IsNullOrEmpty(result))
|
||||
{
|
||||
isSlewing = false;
|
||||
return isSlewing;
|
||||
|
||||
Reference in New Issue
Block a user