Modified the implementation of side of pier support detection. Hopefully will now,
Added extra checking to ensure that a slew cannot be started whilst a slew is in progress.
This commit is contained in:
@@ -42,8 +42,6 @@ namespace Meade.net.Focuser.UnitTests
|
|||||||
|
|
||||||
_sharedResourcesWrapperMock = new Mock<ISharedResourcesWrapper>();
|
_sharedResourcesWrapperMock = new Mock<ISharedResourcesWrapper>();
|
||||||
|
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Action>())).Callback<Action>(action => { action(); });
|
|
||||||
|
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(() => _profileProperties);
|
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(() => _profileProperties);
|
||||||
|
|
||||||
_focuser = new ASCOM.Meade.net.Focuser(_utilMock.Object, _sharedResourcesWrapperMock.Object);
|
_focuser = new ASCOM.Meade.net.Focuser(_utilMock.Object, _sharedResourcesWrapperMock.Object);
|
||||||
@@ -422,8 +420,6 @@ namespace Meade.net.Focuser.UnitTests
|
|||||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F+", false), Times.Once);
|
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F+", false), Times.Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
_sharedResourcesWrapperMock.Verify(x => x.Lock(It.IsAny<Action>()), Times.Once);
|
|
||||||
|
|
||||||
_utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once);
|
_utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once);
|
||||||
_utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(_profileProperties.BacklashCompensation)), Times.Never);
|
_utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(_profileProperties.BacklashCompensation)), Times.Never);
|
||||||
_utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Once());
|
_utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Once());
|
||||||
@@ -455,8 +451,6 @@ namespace Meade.net.Focuser.UnitTests
|
|||||||
_utilMock.Verify(x => x.WaitForMilliseconds(_profileProperties.BacklashCompensation), Times.Once);
|
_utilMock.Verify(x => x.WaitForMilliseconds(_profileProperties.BacklashCompensation), Times.Once);
|
||||||
_utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(2));
|
_utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
_sharedResourcesWrapperMock.Verify(x => x.Lock(It.IsAny<Action>()), Times.Once);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|||||||
@@ -95,9 +95,6 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
_sharedResourcesWrapperMock.Setup(x => x.SendString("GZ", false)).Returns("DDD*MM’SS");
|
_sharedResourcesWrapperMock.Setup(x => x.SendString("GZ", false)).Returns("DDD*MM’SS");
|
||||||
|
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(() =>_profileProperties);
|
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(() =>_profileProperties);
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Action>())).Callback<Action>(action => { action(); });
|
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Func<ASCOM.Meade.net.Telescope.TelescopeDateDetails>>())).Returns<Func<ASCOM.Meade.net.Telescope.TelescopeDateDetails>>( func => func());
|
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Func<AltitudeData>>())).Returns<Func<AltitudeData>>(func => func());
|
|
||||||
|
|
||||||
_connectionInfo = new ConnectionInfo
|
_connectionInfo = new ConnectionInfo
|
||||||
{
|
{
|
||||||
@@ -1930,11 +1927,12 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
Assert.That(excpetion.Method, Is.EqualTo("SetPark"));
|
Assert.That(excpetion.Method, Is.EqualTo("SetPark"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[TestCase(TelescopeList.LX200CLASSIC, null)]
|
||||||
public void SideOfPier_Get_WhenMeridianFlipNotSupported_ThenThrowsException()
|
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_31Ee)]
|
||||||
|
[TestCase(TelescopeList.LX200GPS, TelescopeList.LX200GPS_42F)]
|
||||||
|
public void SideOfPier_Get_WhenMeridianFlipNotSupported_ThenThrowsException(string model, string firmware)
|
||||||
{
|
{
|
||||||
// LX200 classic is a fork mounted scope so it does not support meridian flips
|
ConnectTelescope(model, firmware);
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(TelescopeList.LX200CLASSIC);
|
|
||||||
|
|
||||||
var excpetion = Assert.Throws<PropertyNotImplementedException>(() =>
|
var excpetion = Assert.Throws<PropertyNotImplementedException>(() =>
|
||||||
{
|
{
|
||||||
@@ -1946,6 +1944,41 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
Assert.That(excpetion.AccessorSet, Is.False);
|
Assert.That(excpetion.AccessorSet, Is.False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg)]
|
||||||
|
[TestCase(TelescopeList.LX200GPS, TelescopeList.LX200GPS_42G)]
|
||||||
|
public void SideOfPier_Get_WhenMeridianFlipSupported_ThenReturnsResult(string model, string firmware)
|
||||||
|
{
|
||||||
|
ConnectTelescope(model, firmware);
|
||||||
|
|
||||||
|
Assert.DoesNotThrow(() => { var result = _telescope.SideOfPier; });
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, AlignmentModes.algAltAz, 'A')]
|
||||||
|
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, AlignmentModes.algPolar, 'P')]
|
||||||
|
public void SideOfPier_Get_WhenMeridianFlipNotSupportedByAlignementMode_ThenThrowsException(string model, string firmware, AlignmentModes alignmode, char alignmentStatus)
|
||||||
|
{
|
||||||
|
ConnectTelescope(model, firmware);
|
||||||
|
_testProperties.AlignmentStatus = new[] { alignmentStatus, 'T', '1' };
|
||||||
|
|
||||||
|
var excpetion = Assert.Throws<PropertyNotImplementedException>(() =>
|
||||||
|
{
|
||||||
|
var result = _telescope.SideOfPier;
|
||||||
|
Assert.Fail($"{result} should not have returned");
|
||||||
|
});
|
||||||
|
|
||||||
|
Assert.That(excpetion.Property, Is.EqualTo("SideOfPier"));
|
||||||
|
Assert.That(excpetion.AccessorSet, Is.False);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, AlignmentModes.algGermanPolar, 'G')]
|
||||||
|
public void SideOfPier_Get_WhenMeridianFlipSupportedByAlignementMode_ThenDoesNotThrow(string model, string firmware, AlignmentModes alignmode, char alignmentStatus)
|
||||||
|
{
|
||||||
|
ConnectTelescope(model, firmware);
|
||||||
|
_testProperties.AlignmentStatus = new[] { alignmentStatus, 'T', '1' };
|
||||||
|
|
||||||
|
Assert.DoesNotThrow(() => { var result = _telescope.SideOfPier; });
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void SideOfPier_Set_ThenThrowsException()
|
public void SideOfPier_Set_ThenThrowsException()
|
||||||
{
|
{
|
||||||
@@ -2119,7 +2152,7 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
|
|
||||||
_sharedResourcesWrapperMock.Verify(x => x.SendString("Gg", false), Times.Exactly(3));
|
_sharedResourcesWrapperMock.Verify(x => x.SendString("Gg", false), Times.Exactly(3));
|
||||||
_sharedResourcesWrapperMock.Verify(x => x.SendChar("MS", false), Times.Exactly(2));
|
_sharedResourcesWrapperMock.Verify(x => x.SendChar("MS", false), Times.Exactly(2));
|
||||||
_sharedResourcesWrapperMock.Verify(x => x.SendString("D", false), Times.Exactly(3));
|
_sharedResourcesWrapperMock.Verify(x => x.SendString("D", false), Times.AtLeast(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -3272,12 +3305,15 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
{
|
{
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.SendChar("MS", false)).Returns("0");
|
_sharedResourcesWrapperMock.Setup(x => x.SendChar("MS", false)).Returns("0");
|
||||||
|
|
||||||
|
var preTestItterations = 1;
|
||||||
var slewCounter = 0;
|
var slewCounter = 0;
|
||||||
var iterations = 10;
|
var iterations = 10;
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.SendString("D", false)).Returns(() =>
|
_sharedResourcesWrapperMock.Setup(x => x.SendString("D", false)).Returns(() =>
|
||||||
{
|
{
|
||||||
slewCounter++;
|
slewCounter++;
|
||||||
if (slewCounter <= iterations)
|
if (slewCounter <= preTestItterations)
|
||||||
|
return "";
|
||||||
|
else if (slewCounter <= iterations)
|
||||||
return "|";
|
return "|";
|
||||||
return "";
|
return "";
|
||||||
});
|
});
|
||||||
@@ -3289,7 +3325,7 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
|
|
||||||
_telescope.SlewToTarget();
|
_telescope.SlewToTarget();
|
||||||
|
|
||||||
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations));
|
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations - preTestItterations));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -3366,12 +3402,15 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
|
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.SendChar("MS", false)).Returns("0");
|
_sharedResourcesWrapperMock.Setup(x => x.SendChar("MS", false)).Returns("0");
|
||||||
|
|
||||||
|
var preTestItterations = 1;
|
||||||
var slewCounter = 0;
|
var slewCounter = 0;
|
||||||
var iterations = 10;
|
var iterations = 10;
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.SendString("D", false)).Returns(() =>
|
_sharedResourcesWrapperMock.Setup(x => x.SendString("D", false)).Returns(() =>
|
||||||
{
|
{
|
||||||
slewCounter++;
|
slewCounter++;
|
||||||
if (slewCounter <= iterations)
|
if (slewCounter <= preTestItterations)
|
||||||
|
return "";
|
||||||
|
else if (slewCounter <= iterations)
|
||||||
return "|";
|
return "|";
|
||||||
return "";
|
return "";
|
||||||
});
|
});
|
||||||
@@ -3383,7 +3422,7 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
Assert.That(_telescope.TargetDeclination, Is.EqualTo(dmsResult));
|
Assert.That(_telescope.TargetDeclination, Is.EqualTo(dmsResult));
|
||||||
_sharedResourcesWrapperMock.Verify(x => x.SendChar("MS", false), Times.Once);
|
_sharedResourcesWrapperMock.Verify(x => x.SendChar("MS", false), Times.Once);
|
||||||
|
|
||||||
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations));
|
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations - preTestItterations));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -3486,12 +3525,15 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
|
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.SendChar("MS", false)).Returns("0");
|
_sharedResourcesWrapperMock.Setup(x => x.SendChar("MS", false)).Returns("0");
|
||||||
|
|
||||||
|
var preTestItterations = 1;
|
||||||
var slewCounter = 0;
|
var slewCounter = 0;
|
||||||
var iterations = 10;
|
var iterations = 10;
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.SendString("D", false)).Returns(() =>
|
_sharedResourcesWrapperMock.Setup(x => x.SendString("D", false)).Returns(() =>
|
||||||
{
|
{
|
||||||
slewCounter++;
|
slewCounter++;
|
||||||
if (slewCounter <= iterations)
|
if (slewCounter <= preTestItterations)
|
||||||
|
return "";
|
||||||
|
else if (slewCounter <= iterations)
|
||||||
return "|";
|
return "|";
|
||||||
return "";
|
return "";
|
||||||
});
|
});
|
||||||
@@ -3503,7 +3545,7 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
Assert.That(_telescope.TargetRightAscension, Is.EqualTo(_testProperties.rightAscension));
|
Assert.That(_telescope.TargetRightAscension, Is.EqualTo(_testProperties.rightAscension));
|
||||||
Assert.That(_telescope.TargetDeclination, Is.EqualTo(_testProperties.declination));
|
Assert.That(_telescope.TargetDeclination, Is.EqualTo(_testProperties.declination));
|
||||||
_sharedResourcesWrapperMock.Verify(x => x.SendChar("MS", false), Times.Once);
|
_sharedResourcesWrapperMock.Verify(x => x.SendChar("MS", false), Times.Once);
|
||||||
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations));
|
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations - preTestItterations));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|||||||
+145
-160
@@ -649,7 +649,7 @@ namespace ASCOM.Meade.net
|
|||||||
// According to "A User's Guide to the Meade LXD55 and LXD75 Telescopes" Autostar supports meridian flip so
|
// According to "A User's Guide to the Meade LXD55 and LXD75 Telescopes" Autostar supports meridian flip so
|
||||||
// we assume that for any telescope that supports the GW command and is not in Alt-Az mode then
|
// we assume that for any telescope that supports the GW command and is not in Alt-Az mode then
|
||||||
// meridian flip on slew is supported
|
// meridian flip on slew is supported
|
||||||
private bool IsMeridianFlipOnSlewSupported() => IsGwCommandSupported() && AlignmentMode != AlignmentModes.algAltAz;
|
private bool IsMeridianFlipOnSlewSupported() => IsGwCommandSupported() && AlignmentMode == AlignmentModes.algGermanPolar;
|
||||||
|
|
||||||
private bool FirmwareIsGreaterThan(string minVersion)
|
private bool FirmwareIsGreaterThan(string minVersion)
|
||||||
{
|
{
|
||||||
@@ -734,39 +734,36 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
LogMessage("SetLongFormat", "Long coordinate format not supported for this mount");
|
LogMessage("SetLongFormat", "Long coordinate format not supported for this mount");
|
||||||
|
|
||||||
SharedResourcesWrapper.Lock(() => SharedResourcesWrapper.IsLongFormat = false);
|
SharedResourcesWrapper.IsLongFormat = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedResourcesWrapper.Lock(() =>
|
var result = SharedResourcesWrapper.SendString("GZ");
|
||||||
|
LogMessage("SetLongFormat", $"Get - Azimuth {result}");
|
||||||
|
//:GZ# Get telescope azimuth
|
||||||
|
//Returns: DDD*MM.T or DDD*MM'SS#
|
||||||
|
//The current telescope Azimuth depending on the selected precision.
|
||||||
|
|
||||||
|
SharedResourcesWrapper.IsLongFormat = result.Length > 6;
|
||||||
|
|
||||||
|
if (SharedResourcesWrapper.IsLongFormat != setLongFormat)
|
||||||
{
|
{
|
||||||
var result = SharedResourcesWrapper.SendString("GZ");
|
_utilities.WaitForMilliseconds(500);
|
||||||
LogMessage("SetLongFormat", $"Get - Azimuth {result}");
|
SharedResourcesWrapper.SendBlind("U");
|
||||||
//:GZ# Get telescope azimuth
|
//:U# Toggle between low/hi precision positions
|
||||||
//Returns: DDD*MM.T or DDD*MM'SS#
|
//Low - RA displays and messages HH:MM.T sDD*MM
|
||||||
//The current telescope Azimuth depending on the selected precision.
|
//High - Dec / Az / El displays and messages HH:MM: SS sDD*MM:SS
|
||||||
|
// Returns Nothing
|
||||||
|
result = SharedResourcesWrapper.SendString("GZ");
|
||||||
SharedResourcesWrapper.IsLongFormat = result.Length > 6;
|
SharedResourcesWrapper.IsLongFormat = result.Length > 6;
|
||||||
|
LogMessage("SetLongFormat", $"Get - Azimuth {result}");
|
||||||
if (SharedResourcesWrapper.IsLongFormat != setLongFormat)
|
if (SharedResourcesWrapper.IsLongFormat == setLongFormat)
|
||||||
{
|
|
||||||
_utilities.WaitForMilliseconds(500);
|
|
||||||
SharedResourcesWrapper.SendBlind("U");
|
|
||||||
//:U# Toggle between low/hi precision positions
|
|
||||||
//Low - RA displays and messages HH:MM.T sDD*MM
|
|
||||||
//High - Dec / Az / El displays and messages HH:MM: SS sDD*MM:SS
|
|
||||||
// Returns Nothing
|
|
||||||
result = SharedResourcesWrapper.SendString("GZ");
|
|
||||||
SharedResourcesWrapper.IsLongFormat = result.Length > 6;
|
|
||||||
LogMessage("SetLongFormat", $"Get - Azimuth {result}");
|
|
||||||
if (SharedResourcesWrapper.IsLongFormat == setLongFormat)
|
|
||||||
LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} ");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} ");
|
LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} ");
|
||||||
}
|
}
|
||||||
});
|
else
|
||||||
|
{
|
||||||
|
LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} ");
|
||||||
|
}
|
||||||
|
|
||||||
LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} ");
|
LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} ");
|
||||||
}
|
}
|
||||||
@@ -1001,8 +998,8 @@ namespace ASCOM.Meade.net
|
|||||||
alignmentMode = AlignmentModes.algPolar;
|
alignmentMode = AlignmentModes.algPolar;
|
||||||
break;
|
break;
|
||||||
//case "G":
|
//case "G":
|
||||||
// alignmentMode = AlignmentModes.algGermanPolar;
|
//alignmentMode = AlignmentModes.algGermanPolar;
|
||||||
// break;
|
//break;
|
||||||
default:
|
default:
|
||||||
throw new InvalidValueException(
|
throw new InvalidValueException(
|
||||||
$"unknown alignment returned from telescope: {alignmentString}");
|
$"unknown alignment returned from telescope: {alignmentString}");
|
||||||
@@ -1135,13 +1132,13 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
private HorizonCoordinates CalcAltAzFromTelescopeEqData()
|
private HorizonCoordinates CalcAltAzFromTelescopeEqData()
|
||||||
{
|
{
|
||||||
var altitudeData = SharedResourcesWrapper.Lock(() => new AltitudeData
|
var altitudeData = new AltitudeData
|
||||||
{
|
{
|
||||||
UtcDateTime = UTCDate,
|
UtcDateTime = UTCDate,
|
||||||
SiteLongitude = SiteLongitude,
|
SiteLongitude = SiteLongitude,
|
||||||
SiteLatitude = SiteLatitude,
|
SiteLatitude = SiteLatitude,
|
||||||
EquatorialCoordinates = GetTelescopeRaAndDec()
|
EquatorialCoordinates = GetTelescopeRaAndDec()
|
||||||
});
|
};
|
||||||
|
|
||||||
double hourAngle = _astroMaths.RightAscensionToHourAngle(altitudeData.UtcDateTime,
|
double hourAngle = _astroMaths.RightAscensionToHourAngle(altitudeData.UtcDateTime,
|
||||||
altitudeData.SiteLongitude,
|
altitudeData.SiteLongitude,
|
||||||
@@ -2175,98 +2172,94 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
LogMessage("SlewToAltAzAsync", $"Az={azimuth} Alt={altitude}");
|
LogMessage("SlewToAltAzAsync", $"Az={azimuth} Alt={altitude}");
|
||||||
|
|
||||||
HorizonCoordinates altAz = new HorizonCoordinates {Azimuth = azimuth, Altitude = altitude};
|
HorizonCoordinates altAz = new HorizonCoordinates { Azimuth = azimuth, Altitude = altitude };
|
||||||
|
|
||||||
var utcDateTime = UTCDate;
|
var utcDateTime = UTCDate;
|
||||||
var latitude = SiteLatitude;
|
var latitude = SiteLatitude;
|
||||||
var longitude = SiteLongitude;
|
var longitude = SiteLongitude;
|
||||||
|
|
||||||
SharedResourcesWrapper.Lock(() =>
|
var raDec = _astroMaths.ConvertHozToEq(utcDateTime, latitude, longitude, altAz);
|
||||||
{
|
|
||||||
var raDec = _astroMaths.ConvertHozToEq(utcDateTime, latitude, longitude, altAz);
|
|
||||||
|
|
||||||
TargetRightAscension = raDec.RightAscension;
|
TargetRightAscension = raDec.RightAscension;
|
||||||
TargetDeclination = raDec.Declination;
|
TargetDeclination = raDec.Declination;
|
||||||
|
|
||||||
DoSlewAsync(true);
|
DoSlewAsync(true);
|
||||||
|
|
||||||
//TargetAltitude = altitude;
|
|
||||||
//TargetAzimuth = azimuth;
|
|
||||||
|
|
||||||
//DoSlewAsync(false);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoSlewAsync(bool polar)
|
private void DoSlewAsync(bool polar)
|
||||||
{
|
{
|
||||||
CheckConnected("DoSlewAsync");
|
CheckConnected("DoSlewAsync");
|
||||||
CheckParked();
|
CheckParked();
|
||||||
|
if (Slewing)
|
||||||
SharedResourcesWrapper.Lock(() =>
|
|
||||||
{
|
{
|
||||||
switch (polar)
|
LogMessage("DoSlewAsync", "Cannot start a slew whilst slew is in progress.");
|
||||||
{
|
throw new ASCOM.InvalidOperationException("Cannot start a slew whilst slew is in progress.");
|
||||||
case true:
|
}
|
||||||
var response = SharedResourcesWrapper.SendChar("MS");
|
|
||||||
//:MS# Slew to Target Object
|
|
||||||
//Returns:
|
|
||||||
//0 Slew is Possible
|
|
||||||
//1<string># Object Below Horizon w/string message
|
|
||||||
//2<string># Object Below Higher w/string message
|
|
||||||
|
|
||||||
switch (response)
|
switch (polar)
|
||||||
{
|
{
|
||||||
case "0":
|
case true:
|
||||||
//We're slewing everything should be working just fine.
|
var response = SharedResourcesWrapper.SendChar("MS");
|
||||||
LogMessage("DoSlewAsync", "Slewing to target");
|
//:MS# Slew to Target Object
|
||||||
|
//Returns:
|
||||||
|
//0 Slew is Possible
|
||||||
|
//1<string># Object Below Horizon w/string message
|
||||||
|
//2<string># Object Below Higher w/string message
|
||||||
|
|
||||||
if (IsMeridianFlipOnSlewSupported())
|
switch (response)
|
||||||
{
|
{
|
||||||
// Update side of pier to destination side of pier
|
case "0":
|
||||||
// Assumption: Mount will do meridian flip if required
|
//We're slewing everything should be working just fine.
|
||||||
SharedResourcesWrapper.SideOfPier = DestinationSideOfPier(TargetRightAscension, TargetDeclination);
|
LogMessage("DoSlewAsync", "Slewing to target");
|
||||||
}
|
|
||||||
|
|
||||||
SetSlewingMinEndTime();
|
if (IsMeridianFlipOnSlewSupported())
|
||||||
break;
|
{
|
||||||
case "1":
|
// Update side of pier to destination side of pier
|
||||||
//Below Horizon
|
// Assumption: Mount will do meridian flip if required
|
||||||
string belowHorizonMessage = SharedResourcesWrapper.ReadTerminated();
|
SharedResourcesWrapper.SideOfPier =
|
||||||
LogMessage("DoSlewAsync", $"Slew failed \"{belowHorizonMessage}\"");
|
DestinationSideOfPier(TargetRightAscension, TargetDeclination);
|
||||||
throw new InvalidOperationException(belowHorizonMessage);
|
}
|
||||||
case "2":
|
|
||||||
//Below minimum elevation
|
|
||||||
string belowMinimumElevationMessage = SharedResourcesWrapper.ReadTerminated();
|
|
||||||
LogMessage("DoSlewAsync", $"Slew failed \"{belowMinimumElevationMessage}\"");
|
|
||||||
throw new InvalidOperationException(belowMinimumElevationMessage);
|
|
||||||
case "3":
|
|
||||||
//Telescope can hit the mount
|
|
||||||
string canHitMountMessage = SharedResourcesWrapper.ReadTerminated();
|
|
||||||
LogMessage("DoSlewAsync", $"Slew failed \"{canHitMountMessage}\"");
|
|
||||||
throw new InvalidOperationException(canHitMountMessage);
|
|
||||||
default:
|
|
||||||
LogMessage("DoSlewAsync", $"Slew failed - unknown response \"{response}\"");
|
|
||||||
throw new DriverException("This error should not happen");
|
|
||||||
|
|
||||||
}
|
SetSlewingMinEndTime();
|
||||||
|
break;
|
||||||
|
case "1":
|
||||||
|
//Below Horizon
|
||||||
|
string belowHorizonMessage = SharedResourcesWrapper.ReadTerminated();
|
||||||
|
LogMessage("DoSlewAsync", $"Slew failed \"{belowHorizonMessage}\"");
|
||||||
|
throw new InvalidOperationException(belowHorizonMessage);
|
||||||
|
case "2":
|
||||||
|
//Below minimum elevation
|
||||||
|
string belowMinimumElevationMessage = SharedResourcesWrapper.ReadTerminated();
|
||||||
|
LogMessage("DoSlewAsync", $"Slew failed \"{belowMinimumElevationMessage}\"");
|
||||||
|
throw new InvalidOperationException(belowMinimumElevationMessage);
|
||||||
|
case "3":
|
||||||
|
//Telescope can hit the mount
|
||||||
|
string canHitMountMessage = SharedResourcesWrapper.ReadTerminated();
|
||||||
|
LogMessage("DoSlewAsync", $"Slew failed \"{canHitMountMessage}\"");
|
||||||
|
throw new InvalidOperationException(canHitMountMessage);
|
||||||
|
default:
|
||||||
|
LogMessage("DoSlewAsync", $"Slew failed - unknown response \"{response}\"");
|
||||||
|
throw new DriverException("This error should not happen");
|
||||||
|
|
||||||
break;
|
}
|
||||||
case false:
|
|
||||||
var maResponse = SharedResourcesWrapper.SendChar("MA");
|
|
||||||
//:MA# Autostar, LX 16", Autostar II - Slew to target Alt and Az
|
|
||||||
//Returns:
|
|
||||||
//0 - No fault
|
|
||||||
//1 - Fault
|
|
||||||
//LX200 - Not supported
|
|
||||||
|
|
||||||
if (maResponse == "1")
|
break;
|
||||||
{
|
case false:
|
||||||
throw new InvalidOperationException("fault");
|
var maResponse = SharedResourcesWrapper.SendChar("MA");
|
||||||
}
|
//:MA# Autostar, LX 16", Autostar II - Slew to target Alt and Az
|
||||||
SetSlewingMinEndTime();
|
//Returns:
|
||||||
break;
|
//0 - No fault
|
||||||
}
|
//1 - Fault
|
||||||
});
|
//LX200 - Not supported
|
||||||
|
|
||||||
|
if (maResponse == "1")
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("fault");
|
||||||
|
}
|
||||||
|
|
||||||
|
SetSlewingMinEndTime();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SlewToCoordinates(double rightAscension, double declination)
|
public void SlewToCoordinates(double rightAscension, double declination)
|
||||||
@@ -2450,17 +2443,15 @@ namespace ASCOM.Meade.net
|
|||||||
public void SyncToCoordinates(double rightAscension, double declination)
|
public void SyncToCoordinates(double rightAscension, double declination)
|
||||||
{
|
{
|
||||||
LogMessage("SyncToCoordinates", $"RA={rightAscension} Dec={declination}");
|
LogMessage("SyncToCoordinates", $"RA={rightAscension} Dec={declination}");
|
||||||
LogMessage("SyncToCoordinates", $"RA={_utilitiesExtra.HoursToHMS(rightAscension)} Dec={_utilitiesExtra.HoursToHMS(declination)}");
|
LogMessage("SyncToCoordinates",
|
||||||
|
$"RA={_utilitiesExtra.HoursToHMS(rightAscension)} Dec={_utilitiesExtra.HoursToHMS(declination)}");
|
||||||
CheckConnected("SyncToCoordinates");
|
CheckConnected("SyncToCoordinates");
|
||||||
CheckParked();
|
CheckParked();
|
||||||
|
|
||||||
SharedResourcesWrapper.Lock(() =>
|
TargetRightAscension = rightAscension;
|
||||||
{
|
TargetDeclination = declination;
|
||||||
TargetRightAscension = rightAscension;
|
|
||||||
TargetDeclination = declination;
|
|
||||||
|
|
||||||
SyncToTarget();
|
SyncToTarget();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SyncToTarget()
|
public void SyncToTarget()
|
||||||
@@ -2612,13 +2603,15 @@ namespace ASCOM.Meade.net
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
LogMessage("Tracking", "Get");
|
LogMessage("Tracking", "Get");
|
||||||
|
bool isTracking = true;
|
||||||
if (IsGwCommandSupported())
|
if (IsGwCommandSupported())
|
||||||
{
|
{
|
||||||
var alignmentStatus = GetScopeAlignmentStatus();
|
var alignmentStatus = GetScopeAlignmentStatus();
|
||||||
return alignmentStatus.Tracking;
|
isTracking = alignmentStatus.Tracking;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
LogMessage("Tracking", $"Get = {isTracking}");
|
||||||
|
return isTracking;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@@ -2731,23 +2724,18 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
CheckParked();
|
CheckParked();
|
||||||
|
|
||||||
var telescopeDateDetails = SharedResourcesWrapper.Lock(() =>
|
var telescopeDateDetails = new TelescopeDateDetails
|
||||||
{
|
{
|
||||||
var tdd = new TelescopeDateDetails
|
TelescopeDate = SharedResourcesWrapper.SendString("GC"),
|
||||||
{
|
//:GC# Get current date.
|
||||||
TelescopeDate = SharedResourcesWrapper.SendString("GC"),
|
//Returns: MM/DD/YY#
|
||||||
//:GC# Get current date.
|
//The current local calendar date for the telescope.
|
||||||
//Returns: MM/DD/YY#
|
TelescopeTime = SharedResourcesWrapper.SendString("GL"),
|
||||||
//The current local calendar date for the telescope.
|
//:GL# Get Local Time in 24 hour format
|
||||||
TelescopeTime = SharedResourcesWrapper.SendString("GL"),
|
//Returns: HH:MM:SS#
|
||||||
//:GL# Get Local Time in 24 hour format
|
//The Local Time in 24 - hour Format
|
||||||
//Returns: HH:MM:SS#
|
UtcCorrection = GetUtcCorrection()
|
||||||
//The Local Time in 24 - hour Format
|
};
|
||||||
UtcCorrection = GetUtcCorrection()
|
|
||||||
};
|
|
||||||
|
|
||||||
return tdd;
|
|
||||||
});
|
|
||||||
|
|
||||||
int month = telescopeDateDetails.TelescopeDate.Substring(0, 2).ToInteger();
|
int month = telescopeDateDetails.TelescopeDate.Substring(0, 2).ToInteger();
|
||||||
int day = telescopeDateDetails.TelescopeDate.Substring(3, 2).ToInteger();
|
int day = telescopeDateDetails.TelescopeDate.Substring(3, 2).ToInteger();
|
||||||
@@ -2783,40 +2771,37 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
CheckConnected("UTCDate Set");
|
CheckConnected("UTCDate Set");
|
||||||
|
|
||||||
SharedResourcesWrapper.Lock(() =>
|
var utcCorrection = GetUtcCorrection();
|
||||||
|
var localDateTime = value - utcCorrection;
|
||||||
|
|
||||||
|
string localStingCommand = $"SL{localDateTime:HH:mm:ss}";
|
||||||
|
var timeResult = SharedResourcesWrapper.SendChar(localStingCommand);
|
||||||
|
//:SLHH:MM:SS#
|
||||||
|
//Set the local Time
|
||||||
|
//Returns:
|
||||||
|
//0 - Invalid
|
||||||
|
//1 - Valid
|
||||||
|
if (timeResult != "1")
|
||||||
{
|
{
|
||||||
var utcCorrection = GetUtcCorrection();
|
throw new InvalidOperationException("Failed to set local time");
|
||||||
var localDateTime = value - utcCorrection;
|
}
|
||||||
|
|
||||||
string localStingCommand = $"SL{localDateTime:HH:mm:ss}";
|
string localDateCommand = $"SC{localDateTime:MM/dd/yy}";
|
||||||
var timeResult = SharedResourcesWrapper.SendChar(localStingCommand);
|
var dateResult = SharedResourcesWrapper.SendChar(localDateCommand);
|
||||||
//:SLHH:MM:SS#
|
//:SCMM/DD/YY#
|
||||||
//Set the local Time
|
//Change Handbox Date to MM/DD/YY
|
||||||
//Returns:
|
//Returns: <D><string>
|
||||||
//0 - Invalid
|
//D = '0' if the date is invalid. The string is the null string.
|
||||||
//1 - Valid
|
//D = '1' for valid dates and the string is "Updating Planetary Data# #"
|
||||||
if (timeResult != "1")
|
//Note: For Autostar II this is the UTC data!
|
||||||
{
|
if (dateResult != "1")
|
||||||
throw new InvalidOperationException("Failed to set local time");
|
{
|
||||||
}
|
throw new InvalidOperationException("Failed to set local date");
|
||||||
|
}
|
||||||
|
|
||||||
string localDateCommand = $"SC{localDateTime:MM/dd/yy}";
|
//throwing away these two strings which represent
|
||||||
var dateResult = SharedResourcesWrapper.SendChar(localDateCommand);
|
SharedResourcesWrapper.ReadTerminated(); //Updating Planetary Data#
|
||||||
//:SCMM/DD/YY#
|
SharedResourcesWrapper.ReadTerminated(); // #
|
||||||
//Change Handbox Date to MM/DD/YY
|
|
||||||
//Returns: <D><string>
|
|
||||||
//D = '0' if the date is invalid. The string is the null string.
|
|
||||||
//D = '1' for valid dates and the string is "Updating Planetary Data# #"
|
|
||||||
//Note: For Autostar II this is the UTC data!
|
|
||||||
if (dateResult != "1")
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Failed to set local date");
|
|
||||||
}
|
|
||||||
|
|
||||||
//throwing away these two strings which represent
|
|
||||||
SharedResourcesWrapper.ReadTerminated(); //Updating Planetary Data#
|
|
||||||
SharedResourcesWrapper.ReadTerminated(); // #
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -297,30 +297,27 @@ namespace ASCOM.Meade.net
|
|||||||
var direction = position > 0;
|
var direction = position > 0;
|
||||||
if (ReverseFocusDirection)
|
if (ReverseFocusDirection)
|
||||||
direction = !direction;
|
direction = !direction;
|
||||||
|
|
||||||
|
//backlash compensation.
|
||||||
|
var backlashCompensationSteps = direction ? Math.Abs(BacklashCompensation) : 0;
|
||||||
|
|
||||||
SharedResourcesWrapper.Lock(() =>
|
var steps = Math.Abs(position) + backlashCompensationSteps;
|
||||||
|
|
||||||
|
|
||||||
|
MoveFocuser(direction, steps);
|
||||||
|
|
||||||
|
|
||||||
|
//todo refactor the backlash compensation to combine the commands into as few moves as practicle.
|
||||||
|
//ApplyBacklashCompensation(direction);
|
||||||
|
if (direction & backlashCompensationSteps != 0)
|
||||||
{
|
{
|
||||||
//backlash compensation.
|
Tl.LogMessage("Move", "Applying backlash compensation");
|
||||||
var backlashCompensationSteps = direction ? Math.Abs(BacklashCompensation) : 0;
|
MoveFocuser(!direction, backlashCompensationSteps);
|
||||||
|
}
|
||||||
|
|
||||||
var steps = Math.Abs(position) + backlashCompensationSteps;
|
DynamicBreaking(direction);
|
||||||
|
//todo implement dynamic braking
|
||||||
|
//dynamic breaking is sending the command to move in the opposite direction immediatly followed by the command to stop.
|
||||||
MoveFocuser(direction, steps);
|
|
||||||
|
|
||||||
|
|
||||||
//todo refactor the backlash compensation to combine the commands into as few moves as practicle.
|
|
||||||
//ApplyBacklashCompensation(direction);
|
|
||||||
if (direction & backlashCompensationSteps != 0)
|
|
||||||
{
|
|
||||||
Tl.LogMessage("Move", "Applying backlash compensation");
|
|
||||||
MoveFocuser(!direction, backlashCompensationSteps);
|
|
||||||
}
|
|
||||||
|
|
||||||
DynamicBreaking(direction);
|
|
||||||
//todo implement dynamic braking
|
|
||||||
//dynamic breaking is sending the command to move in the opposite direction immediatly followed by the command to stop.
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DynamicBreaking(bool directionOut)
|
private void DynamicBreaking(bool directionOut)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
// ReSharper disable once InconsistentNaming
|
// ReSharper disable once InconsistentNaming
|
||||||
public const string LX200GPS = "LX2001";
|
public const string LX200GPS = "LX2001";
|
||||||
|
|
||||||
|
public const string LX200GPS_42F = "4.2F";
|
||||||
// ReSharper disable once InconsistentNaming
|
// ReSharper disable once InconsistentNaming
|
||||||
public const string LX200GPS_42G = "4.2G";
|
public const string LX200GPS_42G = "4.2G";
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -12,10 +12,7 @@ namespace ASCOM.Meade.net.Wrapper
|
|||||||
string ProductName { get; }
|
string ProductName { get; }
|
||||||
|
|
||||||
string FirmwareVersion { get; }
|
string FirmwareVersion { get; }
|
||||||
|
|
||||||
void Lock(Action action);
|
|
||||||
T Lock<T>(Func<T> func);
|
|
||||||
|
|
||||||
string SendString(string message, bool raw = false);
|
string SendString(string message, bool raw = false);
|
||||||
void SendBlind(string message, bool raw = false);
|
void SendBlind(string message, bool raw = false);
|
||||||
bool SendBool(string command, bool raw = false);
|
bool SendBool(string command, bool raw = false);
|
||||||
@@ -69,16 +66,6 @@ namespace ASCOM.Meade.net.Wrapper
|
|||||||
|
|
||||||
public string FirmwareVersion => SharedResources.FirmwareVersion;
|
public string FirmwareVersion => SharedResources.FirmwareVersion;
|
||||||
|
|
||||||
public void Lock(Action action)
|
|
||||||
{
|
|
||||||
SharedResources.Lock(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
public T Lock<T>(Func<T> func)
|
|
||||||
{
|
|
||||||
return SharedResources.Lock(func);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string SendString(string message, bool raw = false)
|
public string SendString(string message, bool raw = false)
|
||||||
{
|
{
|
||||||
return SharedResources.SendString(message, raw);
|
return SharedResources.SendString(message, raw);
|
||||||
|
|||||||
Reference in New Issue
Block a user