Add SlewSettleTime and IsLongFormat to SharedResources interface
Also ensure that digit precision is set during initialisation
This commit is contained in:
@@ -107,7 +107,9 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
_sharedResourcesWrapperMock
|
_sharedResourcesWrapperMock
|
||||||
.SetupProperty(x => x.SideOfPier)
|
.SetupProperty(x => x.SideOfPier)
|
||||||
.SetupProperty(x => x.TargetRightAscension)
|
.SetupProperty(x => x.TargetRightAscension)
|
||||||
.SetupProperty(x => x.TargetDeclination);
|
.SetupProperty(x => x.TargetDeclination)
|
||||||
|
.SetupProperty(x => x.SlewSettleTime)
|
||||||
|
.SetupProperty(x => x.IsLongFormat);
|
||||||
|
|
||||||
_astroMathsMock = new Mock<IAstroMaths>();
|
_astroMathsMock = new Mock<IAstroMaths>();
|
||||||
|
|
||||||
@@ -1018,6 +1020,29 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
_sharedResourcesWrapperMock.Verify(x => x.SendChar("P", false), Times.Never);
|
_sharedResourcesWrapperMock.Verify(x => x.SendChar("P", false), Times.Never);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(0)]
|
||||||
|
[TestCase(1)]
|
||||||
|
[TestCase(2)]
|
||||||
|
public void SlewSettleTime_WhenSecondConnectionMade_ThenSlewSettleTimeIsPreserved(short slewSettleTime)
|
||||||
|
{
|
||||||
|
ConnectTelescope();
|
||||||
|
|
||||||
|
_telescope.SlewSettleTime = slewSettleTime;
|
||||||
|
|
||||||
|
Assert.That(_connectionInfo.SameDevice, Is.EqualTo(1));
|
||||||
|
|
||||||
|
var secondTelescopeInstance =
|
||||||
|
new ASCOM.Meade.net.Telescope(_utilMock.Object, _utilExtraMock.Object, _astroUtilsMock.Object,
|
||||||
|
_sharedResourcesWrapperMock.Object, _astroMathsMock.Object, _clockMock.Object, _novasMock.Object);
|
||||||
|
|
||||||
|
Assert.That(secondTelescopeInstance.Connected, Is.False);
|
||||||
|
|
||||||
|
_connectionInfo.SameDevice = 2;
|
||||||
|
secondTelescopeInstance.Connected = true;
|
||||||
|
|
||||||
|
Assert.That(secondTelescopeInstance.SlewSettleTime, Is.EqualTo(slewSettleTime));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void CanSetPark_Get_ReturnsFalse()
|
public void CanSetPark_Get_ReturnsFalse()
|
||||||
{
|
{
|
||||||
@@ -2369,6 +2394,46 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
Assert.That(result, Is.EqualTo(declination));
|
Assert.That(result, Is.EqualTo(declination));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(-90d)]
|
||||||
|
[TestCase(-45d)]
|
||||||
|
[TestCase(0d)]
|
||||||
|
[TestCase(45d)]
|
||||||
|
[TestCase(90d)]
|
||||||
|
public void TargetDeclination_Set_WhenSecondConnectionMade_ThenSlewSettleTimeIsPreserved(double targetDeclination)
|
||||||
|
{
|
||||||
|
var targetDeclinationDMS = targetDeclination + "DMS";
|
||||||
|
var sign = targetDeclination >= 0 ? "+" : string.Empty;
|
||||||
|
var command = $"Sd{sign}{targetDeclinationDMS}";
|
||||||
|
|
||||||
|
_utilMock.Setup(x => x.DegreesToDMS(targetDeclination, "*", ":", ":", 2)).Returns(targetDeclinationDMS);
|
||||||
|
_utilMock.Setup(x => x.DMSToDegrees(targetDeclinationDMS)).Returns(targetDeclination);
|
||||||
|
_sharedResourcesWrapperMock.Setup(x => x.SendChar(command, false)).Returns("1");
|
||||||
|
|
||||||
|
ConnectTelescope();
|
||||||
|
Assert.That(_connectionInfo.SameDevice, Is.EqualTo(1));
|
||||||
|
Assert.That(_sharedResourcesWrapperMock.Object.IsLongFormat, Is.True);
|
||||||
|
|
||||||
|
_telescope.TargetDeclination = targetDeclination;
|
||||||
|
|
||||||
|
Assert.That(_telescope.TargetDeclination, Is.EqualTo(targetDeclination));
|
||||||
|
|
||||||
|
var secondTelescopeInstance =
|
||||||
|
new ASCOM.Meade.net.Telescope(_utilMock.Object, _utilExtraMock.Object, _astroUtilsMock.Object,
|
||||||
|
_sharedResourcesWrapperMock.Object, _astroMathsMock.Object, _clockMock.Object, _novasMock.Object);
|
||||||
|
|
||||||
|
Assert.That(secondTelescopeInstance.Connected, Is.False);
|
||||||
|
|
||||||
|
_connectionInfo.SameDevice = 2;
|
||||||
|
secondTelescopeInstance.Connected = true;
|
||||||
|
|
||||||
|
Assert.That(_sharedResourcesWrapperMock.Object.IsLongFormat, Is.True);
|
||||||
|
Assert.That(secondTelescopeInstance.TargetDeclination, Is.EqualTo(targetDeclination));
|
||||||
|
|
||||||
|
_utilMock.Verify(x => x.DegreesToDMS(targetDeclination, "*", ":", ":", 2), Times.Once);
|
||||||
|
_utilMock.Verify(x => x.DMSToDegrees(targetDeclinationDMS), Times.Once);
|
||||||
|
_sharedResourcesWrapperMock.Verify(x => x.SendChar(command, false), Times.Once);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TargetRightAscension_Set_WhenNotConnected_ThenThrowsException()
|
public void TargetRightAscension_Set_WhenNotConnected_ThenThrowsException()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -78,8 +78,6 @@ namespace ASCOM.Meade.net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private int _digitsDe = 2;
|
private int _digitsDe = 2;
|
||||||
|
|
||||||
private short _settleTime;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Meade.net"/> class.
|
/// Initializes a new instance of the <see cref="Meade.net"/> class.
|
||||||
/// Must be public for COM registration.
|
/// Must be public for COM registration.
|
||||||
@@ -487,6 +485,13 @@ namespace ASCOM.Meade.net
|
|||||||
CheckParked();
|
CheckParked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!SharedResourcesWrapper.IsLongFormat)
|
||||||
|
{
|
||||||
|
// use low precision digits
|
||||||
|
_digitsRa = 1;
|
||||||
|
_digitsDe = 0;
|
||||||
|
}
|
||||||
|
|
||||||
var raAndDec = GetTelescopeRaAndDec();
|
var raAndDec = GetTelescopeRaAndDec();
|
||||||
LogMessage("Connected Set",
|
LogMessage("Connected Set",
|
||||||
$"Connected OK. Current RA = {_utilitiesExtra.HoursToHMS(raAndDec.RightAscension)} Dec = {_utilitiesExtra.DegreesToDMS(raAndDec.Declination)}");
|
$"Connected OK. Current RA = {_utilitiesExtra.HoursToHMS(raAndDec.RightAscension)} Dec = {_utilitiesExtra.DegreesToDMS(raAndDec.Declination)}");
|
||||||
@@ -634,8 +639,6 @@ namespace ASCOM.Meade.net
|
|||||||
return comparison >= 0;
|
return comparison >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsLongFormat { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// classic LX200 needs initial set of target coordinates, if it is slewing and the target RA DE coordinates are 0 and differ from the current coordinates
|
/// classic LX200 needs initial set of target coordinates, if it is slewing and the target RA DE coordinates are 0 and differ from the current coordinates
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -708,13 +711,11 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
public void SetLongFormat(bool setLongFormat)
|
public void SetLongFormat(bool setLongFormat)
|
||||||
{
|
{
|
||||||
IsLongFormat = false;
|
|
||||||
|
|
||||||
if (!IsLongFormatSupported())
|
if (!IsLongFormatSupported())
|
||||||
{
|
{
|
||||||
LogMessage("SetLongFormat", "Long coordinate format not supported for this mount");
|
LogMessage("SetLongFormat", "Long coordinate format not supported for this mount");
|
||||||
_digitsRa = 1;
|
|
||||||
_digitsDe = 0;
|
SharedResourcesWrapper.Lock(() => SharedResourcesWrapper.IsLongFormat = false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -726,9 +727,9 @@ namespace ASCOM.Meade.net
|
|||||||
//Returns: DDD*MM.T or DDD*MM'SS#
|
//Returns: DDD*MM.T or DDD*MM'SS#
|
||||||
//The current telescope Azimuth depending on the selected precision.
|
//The current telescope Azimuth depending on the selected precision.
|
||||||
|
|
||||||
IsLongFormat = result.Length > 6;
|
SharedResourcesWrapper.IsLongFormat = result.Length > 6;
|
||||||
|
|
||||||
if (IsLongFormat != setLongFormat)
|
if (SharedResourcesWrapper.IsLongFormat != setLongFormat)
|
||||||
{
|
{
|
||||||
_utilities.WaitForMilliseconds(500);
|
_utilities.WaitForMilliseconds(500);
|
||||||
SharedResourcesWrapper.SendBlind("U");
|
SharedResourcesWrapper.SendBlind("U");
|
||||||
@@ -737,9 +738,9 @@ namespace ASCOM.Meade.net
|
|||||||
//High - Dec / Az / El displays and messages HH:MM: SS sDD*MM:SS
|
//High - Dec / Az / El displays and messages HH:MM: SS sDD*MM:SS
|
||||||
// Returns Nothing
|
// Returns Nothing
|
||||||
result = SharedResourcesWrapper.SendString("GZ");
|
result = SharedResourcesWrapper.SendString("GZ");
|
||||||
IsLongFormat = result.Length > 6;
|
SharedResourcesWrapper.IsLongFormat = result.Length > 6;
|
||||||
LogMessage("SetLongFormat", $"Get - Azimuth {result}");
|
LogMessage("SetLongFormat", $"Get - Azimuth {result}");
|
||||||
if (IsLongFormat == setLongFormat)
|
if (SharedResourcesWrapper.IsLongFormat == setLongFormat)
|
||||||
LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} ");
|
LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2077,14 +2078,14 @@ namespace ASCOM.Meade.net
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
CheckConnected("SlewSettleTime Get");
|
CheckConnected("SlewSettleTime Get");
|
||||||
LogMessage("SlewSettleTime Get", $"{_settleTime} Seconds");
|
LogMessage("SlewSettleTime Get", $"{SharedResourcesWrapper.SlewSettleTime} Seconds");
|
||||||
return _settleTime;
|
return SharedResourcesWrapper.SlewSettleTime;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
CheckConnected("SlewSettleTime Set");
|
CheckConnected("SlewSettleTime Set");
|
||||||
LogMessage("SlewSettleTime Set", $"Setting from {_settleTime} to {value}");
|
LogMessage("SlewSettleTime Set", $"Setting from {SharedResourcesWrapper.SlewSettleTime} to {value}");
|
||||||
_settleTime = value;
|
SharedResourcesWrapper.SlewSettleTime = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2481,7 +2482,7 @@ namespace ASCOM.Meade.net
|
|||||||
if (value < -90)
|
if (value < -90)
|
||||||
throw new InvalidValueException("Declination cannot be less than -90.");
|
throw new InvalidValueException("Declination cannot be less than -90.");
|
||||||
|
|
||||||
var dms = IsLongFormat ?
|
var dms = SharedResourcesWrapper.IsLongFormat ?
|
||||||
_utilities.DegreesToDMS(value, "*", ":", ":", _digitsDe) :
|
_utilities.DegreesToDMS(value, "*", ":", ":", _digitsDe) :
|
||||||
_utilities.DegreesToDM(value, "*", "", _digitsDe);
|
_utilities.DegreesToDM(value, "*", "", _digitsDe);
|
||||||
|
|
||||||
@@ -2537,7 +2538,7 @@ namespace ASCOM.Meade.net
|
|||||||
if (value >= 24)
|
if (value >= 24)
|
||||||
throw new InvalidValueException("Right ascension value cannot be greater than 23:59:59");
|
throw new InvalidValueException("Right ascension value cannot be greater than 23:59:59");
|
||||||
|
|
||||||
var hms = IsLongFormat ?
|
var hms = SharedResourcesWrapper.IsLongFormat ?
|
||||||
_utilities.HoursToHMS(value, ":", ":", ":", _digitsRa) :
|
_utilities.HoursToHMS(value, ":", ":", ":", _digitsRa) :
|
||||||
_utilities.HoursToHM(value, ":", "", _digitsRa).Replace(',','.');
|
_utilities.HoursToHM(value, ":", "", _digitsRa).Replace(',','.');
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace ASCOM.Meade.net
|
|||||||
protected ParkedBehaviour ParkedBehaviour;
|
protected ParkedBehaviour ParkedBehaviour;
|
||||||
protected HorizonCoordinates ParkedAltAz;
|
protected HorizonCoordinates ParkedAltAz;
|
||||||
|
|
||||||
protected readonly ISharedResourcesWrapper SharedResourcesWrapper;
|
protected readonly ISharedResourcesWrapper SharedResourcesWrapper;
|
||||||
|
|
||||||
public MeadeTelescopeBase()
|
public MeadeTelescopeBase()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -509,10 +509,14 @@ namespace ASCOM.Meade.net
|
|||||||
/// Start with <see cref="PierSide.pierUnknown"/>.
|
/// Start with <see cref="PierSide.pierUnknown"/>.
|
||||||
/// As we do not know the physical declination axis position, we have to keep track manually.
|
/// As we do not know the physical declination axis position, we have to keep track manually.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static PierSide SideOfPier { get; set; } = PierSide.pierUnknown;
|
public static PierSide SideOfPier { get; internal set; } = PierSide.pierUnknown;
|
||||||
|
|
||||||
public static double? TargetRightAscension { get; set; }
|
public static double? TargetRightAscension { get; internal set; }
|
||||||
|
|
||||||
public static double? TargetDeclination { get; set; }
|
public static double? TargetDeclination { get; internal set; }
|
||||||
|
|
||||||
|
public static short SlewSettleTime { get; internal set; }
|
||||||
|
|
||||||
|
public static bool IsLongFormat { get; internal set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,6 +36,10 @@ namespace ASCOM.Meade.net.Wrapper
|
|||||||
PierSide SideOfPier { get; set; }
|
PierSide SideOfPier { get; set; }
|
||||||
double? TargetRightAscension { get; set; }
|
double? TargetRightAscension { get; set; }
|
||||||
double? TargetDeclination { get; set; }
|
double? TargetDeclination { get; set; }
|
||||||
|
|
||||||
|
short SlewSettleTime { get; set; }
|
||||||
|
|
||||||
|
bool IsLongFormat { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SharedResourcesWrapper : ISharedResourcesWrapper
|
public class SharedResourcesWrapper : ISharedResourcesWrapper
|
||||||
@@ -135,5 +139,17 @@ namespace ASCOM.Meade.net.Wrapper
|
|||||||
get => SharedResources.TargetDeclination;
|
get => SharedResources.TargetDeclination;
|
||||||
set => SharedResources.TargetDeclination = value;
|
set => SharedResources.TargetDeclination = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public short SlewSettleTime
|
||||||
|
{
|
||||||
|
get => SharedResources.SlewSettleTime;
|
||||||
|
set => SharedResources.SlewSettleTime = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsLongFormat
|
||||||
|
{
|
||||||
|
get => SharedResources.IsLongFormat;
|
||||||
|
set => SharedResources.IsLongFormat = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user