Added code to make sure that the scope returns values in high precision mode.

This commit is contained in:
2019-05-19 00:59:21 +01:00
parent cf28ecc7c2
commit d39846fa18
3 changed files with 36 additions and 9 deletions
@@ -111,15 +111,12 @@ namespace AstroMath.UnitTests
[Test] [Test]
public void ConvertEqToHoz_book() public void ConvertEqToHoz_book()
{ {
DateTime dateTime = new DateTime(2019, 05, 18, 22, 26, 15, DateTimeKind.Utc);
var longitude = -1.7833333333333332;
var latitude = 52.0; var latitude = 52.0;
EquatorialCoordinates equatorialCoordinates = new EquatorialCoordinates(); EquatorialCoordinates equatorialCoordinates = new EquatorialCoordinates();
equatorialCoordinates.RightAscension = 5.862222222222222;//5 51' 44" equatorialCoordinates.RightAscension = 5.862222222222222;//5 51' 44"
equatorialCoordinates.Declination = 23.21944444444444;//23 13' 10" equatorialCoordinates.Declination = 23.21944444444444;//23 13' 10"
//var hourAngle = _astroMath.RightAscensionToHourAngle(dateTime, longitude, equatorialCoordinates.RightAscension);
var hourAngle = 5.682222; var hourAngle = 5.682222;
var altAz = _astroMath.ConvertEqToHoz(hourAngle, latitude, equatorialCoordinates); var altAz = _astroMath.ConvertEqToHoz(hourAngle, latitude, equatorialCoordinates);
+31 -4
View File
@@ -237,6 +237,7 @@ namespace ASCOM.Meade.net
connectedState = true; connectedState = true;
SelectSite(1); SelectSite(1);
SetLongFormat(true);
} }
else else
{ {
@@ -247,6 +248,29 @@ namespace ASCOM.Meade.net
} }
} }
private void SetLongFormat(bool setLongFormat)
{
SharedResources.Lock(() =>
{
var result = SharedResources.SendString(":GZ#");
//:GZ# Get telescope azimuth
//Returns: DDD*MM#T or DDD*MMSS#
//The current telescope Azimuth depending on the selected precision.
bool isLongFormat = result.Length > 6;
if (isLongFormat != setLongFormat)
{
utilities.WaitForMilliseconds(500);
SharedResources.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
}
});
}
private void SelectSite(int site) private void SelectSite(int site)
{ {
SharedResources.SendBlind($":W{site}#"); SharedResources.SendBlind($":W{site}#");
@@ -1173,9 +1197,10 @@ namespace ASCOM.Meade.net
if (value < 0) if (value < 0)
throw new ASCOM.InvalidValueException("Altitide cannot be less than 0."); throw new ASCOM.InvalidValueException("Altitide cannot be less than 0.");
//todo this serial string does not work. Calculate the EQ version instead.
var dms = utilities.DegreesToDMS(value, "*", "'", ".", 2); var dms = utilities.DegreesToDMS(value, "*", "'", "",0);
var s = value < 0 ? '-' : '+'; var s = value < 0 ? "-" : "+";
var result = SharedResources.SendChar($":Sa{s}{dms}#"); var result = SharedResources.SendChar($":Sa{s}{dms}#");
//:SasDD*MM# //:SasDD*MM#
@@ -1199,9 +1224,11 @@ namespace ASCOM.Meade.net
if (value < 0) if (value < 0)
throw new ASCOM.InvalidValueException("Azimuth cannot be less than 0."); throw new ASCOM.InvalidValueException("Azimuth cannot be less than 0.");
var dms = utilities.DegreesToDM(value, "*", ":", 2); //todo this serial string does not work. Calculate the EQ version instead.
var result = SharedResources.SendChar($":Sd{dms}#"); var dms = utilities.DegreesToDM(value, "*" );
var result = SharedResources.SendChar($":Sz{dms}#");
//:SzDDD*MM# //:SzDDD*MM#
//Sets the target Object Azimuth[LX 16” and Autostar II only] //Sets the target Object Azimuth[LX 16” and Autostar II only]
//Returns: //Returns:
+5 -2
View File
@@ -43,8 +43,11 @@ namespace ASCOM
// TODO add more code to test the driver. // TODO add more code to test the driver.
device.Connected = true; device.Connected = true;
Console.WriteLine($"Ra {device.RightAscension}"); device.CommandBlind(":Sa+30*00'00#", true);
Console.WriteLine($"Dec {device.Declination}"); device.CommandBlind(":Sz150*00#", true);
device.CommandBlind(":MS#", true);
//Console.WriteLine($"Ra {device.RightAscension}");
//Console.WriteLine($"Dec {device.Declination}");
Console.WriteLine($"Altitude {device.Altitude}"); Console.WriteLine($"Altitude {device.Altitude}");
Console.WriteLine($"Azimuth {device.Azimuth}"); Console.WriteLine($"Azimuth {device.Azimuth}");