Modified the puleguide method to make sure that the _isGuiding property is set correctly regardless of the old or new guiding method.

Added log message for when PulseGuide fails with an error for any reason
This commit is contained in:
2020-05-24 15:56:24 +01:00
parent 2ab9cfb9c8
commit 3e00398af0
+25 -14
View File
@@ -47,7 +47,6 @@ namespace ASCOM.Meade.net
//internal static string driverID = "ASCOM.Meade.net.Telescope"; //internal static string driverID = "ASCOM.Meade.net.Telescope";
private static readonly string DriverId = Marshal.GenerateProgIdForType(MethodBase.GetCurrentMethod().DeclaringType ?? throw new System.InvalidOperationException()); private static readonly string DriverId = Marshal.GenerateProgIdForType(MethodBase.GetCurrentMethod().DeclaringType ?? throw new System.InvalidOperationException());
// TODO Change the descriptive string for your driver then remove this line
/// <summary> /// <summary>
/// Driver description that displays in the ASCOM Chooser. /// Driver description that displays in the ASCOM Chooser.
/// </summary> /// </summary>
@@ -707,7 +706,6 @@ namespace ASCOM.Meade.net
public string Description public string Description
{ {
// TODO customise this device description
get get
{ {
LogMessage("Description Get", DriverDescription); LogMessage("Description Get", DriverDescription);
@@ -719,7 +717,6 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
// TODO customise this driver description
string driverInfo = $"{Description} .net driver. Version: {DriverVersion}"; string driverInfo = $"{Description} .net driver. Version: {DriverVersion}";
LogMessage("DriverInfo Get", driverInfo); LogMessage("DriverInfo Get", driverInfo);
return driverInfo; return driverInfo;
@@ -1423,15 +1420,21 @@ namespace ASCOM.Meade.net
public void PulseGuide(GuideDirections direction, int duration) public void PulseGuide(GuideDirections direction, int duration)
{ {
LogMessage("PulseGuide", $"pulse guide direction {direction} duration {duration}"); LogMessage("PulseGuide", $"pulse guide direction {direction} duration {duration}");
try
{
CheckConnected("PulseGuide"); CheckConnected("PulseGuide");
if (IsSlewingToTarget()) if (IsSlewingToTarget())
throw new InvalidOperationException("Unable to PulseGuide whilst slewing to target."); throw new InvalidOperationException("Unable to PulseGuide whilst slewing to target.");
if (_movingPrimary && (direction == GuideDirections.guideEast || direction == GuideDirections.guideWest)) _isGuiding = true;
try
{
if (_movingPrimary &&
(direction == GuideDirections.guideEast || direction == GuideDirections.guideWest))
throw new InvalidOperationException("Unable to PulseGuide while moving same axis."); throw new InvalidOperationException("Unable to PulseGuide while moving same axis.");
if (_movingSecondary && (direction == GuideDirections.guideNorth || direction == GuideDirections.guideSouth)) if (_movingSecondary &&
(direction == GuideDirections.guideNorth || direction == GuideDirections.guideSouth))
throw new InvalidOperationException("Unable to PulseGuide while moving same axis."); throw new InvalidOperationException("Unable to PulseGuide while moving same axis.");
var coordinatesBeforeMove = GetTelescopeRaAndDec(); var coordinatesBeforeMove = GetTelescopeRaAndDec();
@@ -1469,9 +1472,7 @@ namespace ASCOM.Meade.net
} }
else else
{ {
_isGuiding = true; LogMessage("PulseGuide", "Using old pulse guiding technique");
try
{
switch (direction) switch (direction)
{ {
case GuideDirections.guideEast: case GuideDirections.guideEast:
@@ -1495,17 +1496,27 @@ namespace ASCOM.Meade.net
MoveAxis(TelescopeAxes.axisPrimary, 0); MoveAxis(TelescopeAxes.axisPrimary, 0);
break; break;
} }
LogMessage("PulseGuide", "Using old pulse guiding technique complete");
}
var coordinatesAfterMove = GetTelescopeRaAndDec();
LogMessage("PulseGuide",
$"Complete Before RA: {_utilitiesExtra.HoursToHMS(coordinatesBeforeMove.RightAscension)} Dec:{_utilitiesExtra.DegreesToDMS(coordinatesBeforeMove.Declination)}");
LogMessage("PulseGuide",
$"Complete After RA: {_utilitiesExtra.HoursToHMS(coordinatesAfterMove.RightAscension)} Dec:{_utilitiesExtra.DegreesToDMS(coordinatesAfterMove.Declination)}");
} }
finally finally
{ {
_isGuiding = false; _isGuiding = false;
} }
} }
catch (Exception ex)
var coordinatesAfterMove = GetTelescopeRaAndDec(); {
LogMessage("PulseGuide", $"Error performing pulse guide: {ex.Message}");
LogMessage("PulseGuide", $"Complete Before RA: {_utilitiesExtra.HoursToHMS(coordinatesBeforeMove.RightAscension)} Dec:{_utilitiesExtra.DegreesToDMS(coordinatesBeforeMove.Declination)}"); throw;
LogMessage("PulseGuide", $"Complete Before RA: {_utilitiesExtra.HoursToHMS(coordinatesAfterMove.RightAscension)} Dec:{_utilitiesExtra.DegreesToDMS(coordinatesAfterMove.Declination)}"); }
} }
public double RightAscension public double RightAscension