Added support for altitude

This commit is contained in:
2019-05-06 17:17:22 +01:00
parent e8793231d1
commit 2d69a4fba8
3 changed files with 40 additions and 16 deletions
@@ -16,6 +16,7 @@ namespace ASCOM.MeadeAutostar497.Controller
bool AtPark { get; }
double Azimuth { get; }
double Declination { get; }
double Altitude { get; }
void AbortSlew();
void PulseGuide(GuideDirections direction, int duration);
void Park();
@@ -190,16 +190,8 @@ namespace ASCOM.MeadeAutostar497.Controller
get
{
var latitude = SerialPort.CommandTerminated( ":Gt#", "#");
double lat = int.Parse(latitude.Substring(1, 2));
lat = lat + double.Parse(latitude.Substring(4, 2)) / 60;
if (latitude.Length == 9)
lat = lat + double.Parse(latitude.Substring(7, 2)) / 60 / 60;
if (latitude[0] == '-')
lat = -lat;
return lat;
return DMSToDouble(latitude);
}
set
{
@@ -220,12 +212,31 @@ namespace ASCOM.MeadeAutostar497.Controller
private double DMSToDouble(string DMS)
{
double l = int.Parse(DMS.Substring(0, 3));
l = l + double.Parse(DMS.Substring(4, 2)) / 60;
if (DMS.Length == 9)
l = l + double.Parse(DMS.Substring(7, 2)) / 60 / 60;
if (IsNumeric(DMS[0]))
{
double l = int.Parse(DMS.Substring(0, 3));
l = l + double.Parse(DMS.Substring(4, 2)) / 60;
if (DMS.Length == 9)
l = l + double.Parse(DMS.Substring(7, 2)) / 60 / 60;
return l;
return l;
}
double lat = int.Parse(DMS.Substring(1, 2));
lat = lat + double.Parse(DMS.Substring(4, 2)) / 60;
if (DMS.Length == 9)
lat = lat + double.Parse(DMS.Substring(7, 2)) / 60 / 60;
if (DMS[0] == '-')
lat = -lat;
return lat;
}
private bool IsNumeric(char c)
{
char[] nums = new[] {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
return nums.Contains(c);
}
public double SiteLongitude
@@ -339,6 +350,17 @@ namespace ASCOM.MeadeAutostar497.Controller
}
}
public double Altitude {
get
{
var result = SerialPort.CommandTerminated(":GA#", "#");
//:GA# Get Telescope Altitude
//Returns: sDD* MM# or sDD*MMSS#
//The current scope altitude. The returned format depending on the current precision setting.
return DMSToDouble(result);
}
}
public void AbortSlew()
{
SerialPort.Command("#:Q#");