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:
@@ -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,89 +1420,103 @@ 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}");
|
||||||
CheckConnected("PulseGuide");
|
try
|
||||||
|
|
||||||
if (IsSlewingToTarget())
|
|
||||||
throw new InvalidOperationException("Unable to PulseGuide whilst slewing to target.");
|
|
||||||
|
|
||||||
if (_movingPrimary && (direction == GuideDirections.guideEast || direction == GuideDirections.guideWest))
|
|
||||||
throw new InvalidOperationException("Unable to PulseGuide while moving same axis.");
|
|
||||||
|
|
||||||
if (_movingSecondary && (direction == GuideDirections.guideNorth || direction == GuideDirections.guideSouth))
|
|
||||||
throw new InvalidOperationException("Unable to PulseGuide while moving same axis.");
|
|
||||||
|
|
||||||
var coordinatesBeforeMove = GetTelescopeRaAndDec();
|
|
||||||
|
|
||||||
if (_userNewerPulseGuiding && duration < 10000)
|
|
||||||
{
|
{
|
||||||
string d = string.Empty;
|
CheckConnected("PulseGuide");
|
||||||
switch (direction)
|
if (IsSlewingToTarget())
|
||||||
{
|
throw new InvalidOperationException("Unable to PulseGuide whilst slewing to target.");
|
||||||
case GuideDirections.guideEast:
|
|
||||||
d = "e";
|
|
||||||
break;
|
|
||||||
case GuideDirections.guideNorth:
|
|
||||||
d = "n";
|
|
||||||
break;
|
|
||||||
case GuideDirections.guideSouth:
|
|
||||||
d = "s";
|
|
||||||
break;
|
|
||||||
case GuideDirections.guideWest:
|
|
||||||
d = "w";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
LogMessage("PulseGuide", "Using new pulse guiding technique");
|
|
||||||
_sharedResourcesWrapper.SendBlind($"#:Mg{d}{duration:0000}#");
|
|
||||||
//:MgnDDDD#
|
|
||||||
//:MgsDDDD#
|
|
||||||
//:MgeDDDD#
|
|
||||||
//:MgwDDDD#
|
|
||||||
//Guide telescope in the commanded direction(nsew) for the number of milliseconds indicated by the unsigned number
|
|
||||||
//passed in the command.These commands support serial port driven guiding.
|
|
||||||
//Returns – Nothing
|
|
||||||
//LX200 – Not Supported
|
|
||||||
_utilities.WaitForMilliseconds(duration); //todo figure out if this is really needed
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_isGuiding = true;
|
_isGuiding = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
switch (direction)
|
if (_movingPrimary &&
|
||||||
|
(direction == GuideDirections.guideEast || direction == GuideDirections.guideWest))
|
||||||
|
throw new InvalidOperationException("Unable to PulseGuide while moving same axis.");
|
||||||
|
|
||||||
|
if (_movingSecondary &&
|
||||||
|
(direction == GuideDirections.guideNorth || direction == GuideDirections.guideSouth))
|
||||||
|
throw new InvalidOperationException("Unable to PulseGuide while moving same axis.");
|
||||||
|
|
||||||
|
var coordinatesBeforeMove = GetTelescopeRaAndDec();
|
||||||
|
|
||||||
|
if (_userNewerPulseGuiding && duration < 10000)
|
||||||
{
|
{
|
||||||
case GuideDirections.guideEast:
|
string d = string.Empty;
|
||||||
MoveAxis(TelescopeAxes.axisPrimary, 1);
|
switch (direction)
|
||||||
_utilities.WaitForMilliseconds(duration);
|
{
|
||||||
MoveAxis(TelescopeAxes.axisPrimary, 0);
|
case GuideDirections.guideEast:
|
||||||
break;
|
d = "e";
|
||||||
case GuideDirections.guideNorth:
|
break;
|
||||||
MoveAxis(TelescopeAxes.axisSecondary, 1);
|
case GuideDirections.guideNorth:
|
||||||
_utilities.WaitForMilliseconds(duration);
|
d = "n";
|
||||||
MoveAxis(TelescopeAxes.axisSecondary, 0);
|
break;
|
||||||
break;
|
case GuideDirections.guideSouth:
|
||||||
case GuideDirections.guideSouth:
|
d = "s";
|
||||||
MoveAxis(TelescopeAxes.axisSecondary, -1);
|
break;
|
||||||
_utilities.WaitForMilliseconds(duration);
|
case GuideDirections.guideWest:
|
||||||
MoveAxis(TelescopeAxes.axisSecondary, 0);
|
d = "w";
|
||||||
break;
|
break;
|
||||||
case GuideDirections.guideWest:
|
}
|
||||||
MoveAxis(TelescopeAxes.axisPrimary, -1);
|
|
||||||
_utilities.WaitForMilliseconds(duration);
|
LogMessage("PulseGuide", "Using new pulse guiding technique");
|
||||||
MoveAxis(TelescopeAxes.axisPrimary, 0);
|
_sharedResourcesWrapper.SendBlind($"#:Mg{d}{duration:0000}#");
|
||||||
break;
|
//:MgnDDDD#
|
||||||
|
//:MgsDDDD#
|
||||||
|
//:MgeDDDD#
|
||||||
|
//:MgwDDDD#
|
||||||
|
//Guide telescope in the commanded direction(nsew) for the number of milliseconds indicated by the unsigned number
|
||||||
|
//passed in the command.These commands support serial port driven guiding.
|
||||||
|
//Returns – Nothing
|
||||||
|
//LX200 – Not Supported
|
||||||
|
_utilities.WaitForMilliseconds(duration); //todo figure out if this is really needed
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogMessage("PulseGuide", "Using old pulse guiding technique");
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case GuideDirections.guideEast:
|
||||||
|
MoveAxis(TelescopeAxes.axisPrimary, 1);
|
||||||
|
_utilities.WaitForMilliseconds(duration);
|
||||||
|
MoveAxis(TelescopeAxes.axisPrimary, 0);
|
||||||
|
break;
|
||||||
|
case GuideDirections.guideNorth:
|
||||||
|
MoveAxis(TelescopeAxes.axisSecondary, 1);
|
||||||
|
_utilities.WaitForMilliseconds(duration);
|
||||||
|
MoveAxis(TelescopeAxes.axisSecondary, 0);
|
||||||
|
break;
|
||||||
|
case GuideDirections.guideSouth:
|
||||||
|
MoveAxis(TelescopeAxes.axisSecondary, -1);
|
||||||
|
_utilities.WaitForMilliseconds(duration);
|
||||||
|
MoveAxis(TelescopeAxes.axisSecondary, 0);
|
||||||
|
break;
|
||||||
|
case GuideDirections.guideWest:
|
||||||
|
MoveAxis(TelescopeAxes.axisPrimary, -1);
|
||||||
|
_utilities.WaitForMilliseconds(duration);
|
||||||
|
MoveAxis(TelescopeAxes.axisPrimary, 0);
|
||||||
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user