Added more logging around the tracking rates.
Corrected the Command logged messages to use the correct info. Added a try catch to the setup dialog to see if an error occurs to give a better message.
This commit is contained in:
@@ -822,9 +822,9 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: AlignmentMode Set"));
|
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: AlignmentMode Set"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("AUTOSTAR", "43Eg", AlignmentModes.algAltAz, "AA")]
|
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, AlignmentModes.algAltAz, "AA")]
|
||||||
[TestCase("AUTOSTAR", "43Eg", AlignmentModes.algPolar, "AP")]
|
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, AlignmentModes.algPolar, "AP")]
|
||||||
[TestCase("AUTOSTAR", "43Eg", AlignmentModes.algGermanPolar, "AP")]
|
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, AlignmentModes.algGermanPolar, "AP")]
|
||||||
public void AlignmentMode_Set_WhenConnected_ThenSendsExpectedCommand(string productName, string firmware, AlignmentModes alignmentMode, string expectedCommand)
|
public void AlignmentMode_Set_WhenConnected_ThenSendsExpectedCommand(string productName, string firmware, AlignmentModes alignmentMode, string expectedCommand)
|
||||||
{
|
{
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName);
|
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName);
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
public void CommandBlind(string command, bool raw)
|
public void CommandBlind(string command, bool raw)
|
||||||
{
|
{
|
||||||
LogMessage("CommandBlind", "raw: {0} command {0}", raw, command);
|
LogMessage("CommandBlind", $"raw: {raw} command {command}");
|
||||||
CheckConnected("CommandBlind");
|
CheckConnected("CommandBlind");
|
||||||
// Call CommandString and return as soon as it finishes
|
// Call CommandString and return as soon as it finishes
|
||||||
//this.CommandString(command, raw);
|
//this.CommandString(command, raw);
|
||||||
@@ -352,16 +352,16 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
public bool CommandBool(string command, bool raw)
|
public bool CommandBool(string command, bool raw)
|
||||||
{
|
{
|
||||||
LogMessage("CommandBool", "raw: {0} command {0}", raw, command);
|
LogMessage("CommandBool", $"raw: {raw} command {command}");
|
||||||
CheckConnected("CommandBool");
|
CheckConnected("CommandBool");
|
||||||
var result = SharedResourcesWrapper.SendBool(command, raw);
|
var result = SharedResourcesWrapper.SendBool(command, raw);
|
||||||
LogMessage("CommandBool", "Completed: {0}", result);
|
LogMessage("CommandBool", $"Completed: {result}");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string CommandString(string command, bool raw)
|
public string CommandString(string command, bool raw)
|
||||||
{
|
{
|
||||||
LogMessage("CommandString", "raw: {0} command {0}", raw, command);
|
LogMessage("CommandString", $"raw: {raw} command {command}");
|
||||||
CheckConnected("CommandString");
|
CheckConnected("CommandString");
|
||||||
// it's a good idea to put all the low level communication with the device here,
|
// it's a good idea to put all the low level communication with the device here,
|
||||||
// then all communication calls this function
|
// then all communication calls this function
|
||||||
@@ -377,7 +377,7 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
result = SharedResourcesWrapper.SendString(command, raw);
|
result = SharedResourcesWrapper.SendString(command, raw);
|
||||||
}
|
}
|
||||||
LogMessage("CommandString", "Completed: {0}", result);
|
LogMessage("CommandString", $"Completed: {result}");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -622,13 +622,26 @@ namespace ASCOM.Meade.net
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsGWCommandSupported() => FirmwareIsGreaterThan(TelescopeList.Autostar497_43Eg);
|
private bool IsGwCommandSupported()
|
||||||
|
{
|
||||||
|
switch (SharedResourcesWrapper.ProductName)
|
||||||
|
{
|
||||||
|
case TelescopeList.LX200CLASSIC:
|
||||||
|
return false;
|
||||||
|
case TelescopeList.Autostar497:
|
||||||
|
return FirmwareIsGreaterThan(TelescopeList.Autostar497_43Eg);
|
||||||
|
case TelescopeList.LX200GPS:
|
||||||
|
return FirmwareIsGreaterThan(TelescopeList.LX200GPS_42G);
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// true iff the mount will perform a meridian flip when required
|
// true iff the mount will perform a meridian flip when required
|
||||||
// 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.algAltAz;
|
||||||
|
|
||||||
private bool FirmwareIsGreaterThan(string minVersion)
|
private bool FirmwareIsGreaterThan(string minVersion)
|
||||||
{
|
{
|
||||||
@@ -955,7 +968,7 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
CheckConnected("AlignmentMode Get");
|
CheckConnected("AlignmentMode Get");
|
||||||
|
|
||||||
if (IsGWCommandSupported())
|
if (IsGwCommandSupported())
|
||||||
{
|
{
|
||||||
var alignmentStatus = GetScopeAlignmentStatus();
|
var alignmentStatus = GetScopeAlignmentStatus();
|
||||||
return alignmentStatus.AlignmentMode;
|
return alignmentStatus.AlignmentMode;
|
||||||
@@ -996,7 +1009,7 @@ namespace ASCOM.Meade.net
|
|||||||
CheckConnected("AlignmentMode Set");
|
CheckConnected("AlignmentMode Set");
|
||||||
|
|
||||||
//todo tidy this up into a better solution that means can :GW#, :AL#, :AA#, & :AP# and checked for Autostar properly
|
//todo tidy this up into a better solution that means can :GW#, :AL#, :AA#, & :AP# and checked for Autostar properly
|
||||||
if (!IsGWCommandSupported())
|
if (!IsGwCommandSupported())
|
||||||
throw new PropertyNotImplementedException("AlignmentMode", true);
|
throw new PropertyNotImplementedException("AlignmentMode", true);
|
||||||
|
|
||||||
switch (value)
|
switch (value)
|
||||||
@@ -1023,6 +1036,7 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
private AlignmentStatus GetScopeAlignmentStatus()
|
private AlignmentStatus GetScopeAlignmentStatus()
|
||||||
{
|
{
|
||||||
|
LogMessage("GetScopeAlignmentStatus", "Started");
|
||||||
var alignmentString = CommandString("GW", false);
|
var alignmentString = CommandString("GW", false);
|
||||||
//:GW# Get Scope Alignment Status
|
//:GW# Get Scope Alignment Status
|
||||||
//Returns: <mount><tracking><alignment>#
|
//Returns: <mount><tracking><alignment>#
|
||||||
@@ -1045,6 +1059,7 @@ namespace ASCOM.Meade.net
|
|||||||
alignmentStatus.AlignmentMode = AlignmentModes.algGermanPolar;
|
alignmentStatus.AlignmentMode = AlignmentModes.algGermanPolar;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
alignmentStatus.Tracking = alignmentString[1] == 'T';
|
alignmentStatus.Tracking = alignmentString[1] == 'T';
|
||||||
switch (alignmentString[2])
|
switch (alignmentString[2])
|
||||||
{
|
{
|
||||||
@@ -1068,6 +1083,7 @@ namespace ASCOM.Meade.net
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogMessage("GetScopeAlignmentStatus", $"Result {alignmentStatus}");
|
||||||
return alignmentStatus;
|
return alignmentStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1309,7 +1325,7 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var canSetTracking = IsGWCommandSupported();
|
var canSetTracking = IsGwCommandSupported();
|
||||||
LogMessage("CanSetTracking", "Get - " + canSetTracking);
|
LogMessage("CanSetTracking", "Get - " + canSetTracking);
|
||||||
return canSetTracking;
|
return canSetTracking;
|
||||||
}
|
}
|
||||||
@@ -2591,7 +2607,7 @@ namespace ASCOM.Meade.net
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
LogMessage("Tracking", "Get");
|
LogMessage("Tracking", "Get");
|
||||||
if (IsGWCommandSupported())
|
if (IsGwCommandSupported())
|
||||||
{
|
{
|
||||||
var alignmentStatus = GetScopeAlignmentStatus();
|
var alignmentStatus = GetScopeAlignmentStatus();
|
||||||
return alignmentStatus.Tracking;
|
return alignmentStatus.Tracking;
|
||||||
@@ -2607,7 +2623,7 @@ namespace ASCOM.Meade.net
|
|||||||
}
|
}
|
||||||
|
|
||||||
LogMessage("Tracking Set", $"{value}");
|
LogMessage("Tracking Set", $"{value}");
|
||||||
SharedResourcesWrapper.SendBlind(value ? "AP" : "AL");
|
SharedResourcesWrapper.SendBlind(value ? "AP" : "AL"); //todo need to route this to the real commands.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2617,11 +2633,11 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
var rate = CommandString("GT", false);
|
var rate = CommandString("GT", false);
|
||||||
|
|
||||||
if (rate == "+60.1")
|
DriveRates result = rate == "+60.1" ? DriveRates.driveSidereal : DriveRates.driveLunar;
|
||||||
return DriveRates.driveSidereal;
|
|
||||||
|
|
||||||
// we only support two rates ATM so return lunar tracking rate
|
LogMessage("TrackingRate Get", $"{rate} {result}");
|
||||||
return DriveRates.driveLunar;
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@@ -2737,7 +2753,7 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
return utcDate;
|
return utcDate;
|
||||||
}
|
}
|
||||||
catch (ParkedException e)
|
catch (ParkedException)
|
||||||
{
|
{
|
||||||
if (ParkedBehaviour == ParkedBehaviour.NoCoordinates)
|
if (ParkedBehaviour == ParkedBehaviour.NoCoordinates)
|
||||||
throw;
|
throw;
|
||||||
|
|||||||
@@ -291,6 +291,8 @@ namespace ASCOM.Meade.net
|
|||||||
#region SetupDialog
|
#region SetupDialog
|
||||||
|
|
||||||
public static void SetupDialog()
|
public static void SetupDialog()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var profileProperties = ReadProfile();
|
var profileProperties = ReadProfile();
|
||||||
|
|
||||||
@@ -308,10 +310,17 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
profileProperties = f.GetProfile();
|
profileProperties = f.GetProfile();
|
||||||
|
|
||||||
WriteProfile(profileProperties); // Persist device configuration values to the ASCOM Profile store
|
WriteProfile(
|
||||||
|
profileProperties); // Persist device configuration values to the ASCOM Profile store
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user