Added support for altitude
This commit is contained in:
@@ -306,8 +306,9 @@ namespace ASCOM.MeadeAutostar497
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
tl.LogMessage("Altitude", "Not implemented");
|
var alt = _telescopeController.Altitude;
|
||||||
throw new ASCOM.PropertyNotImplementedException("Altitude", false);
|
tl.LogMessage("Altitude", $"{alt}");
|
||||||
|
return alt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
bool AtPark { get; }
|
bool AtPark { get; }
|
||||||
double Azimuth { get; }
|
double Azimuth { get; }
|
||||||
double Declination { get; }
|
double Declination { get; }
|
||||||
|
double Altitude { get; }
|
||||||
void AbortSlew();
|
void AbortSlew();
|
||||||
void PulseGuide(GuideDirections direction, int duration);
|
void PulseGuide(GuideDirections direction, int duration);
|
||||||
void Park();
|
void Park();
|
||||||
|
|||||||
@@ -191,15 +191,7 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
{
|
{
|
||||||
var latitude = SerialPort.CommandTerminated( ":Gt#", "#");
|
var latitude = SerialPort.CommandTerminated( ":Gt#", "#");
|
||||||
|
|
||||||
double lat = int.Parse(latitude.Substring(1, 2));
|
return DMSToDouble(latitude);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@@ -220,12 +212,31 @@ namespace ASCOM.MeadeAutostar497.Controller
|
|||||||
|
|
||||||
private double DMSToDouble(string DMS)
|
private double DMSToDouble(string DMS)
|
||||||
{
|
{
|
||||||
double l = int.Parse(DMS.Substring(0, 3));
|
if (IsNumeric(DMS[0]))
|
||||||
l = l + double.Parse(DMS.Substring(4, 2)) / 60;
|
{
|
||||||
if (DMS.Length == 9)
|
double l = int.Parse(DMS.Substring(0, 3));
|
||||||
l = l + double.Parse(DMS.Substring(7, 2)) / 60 / 60;
|
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
|
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*MM’SS#
|
||||||
|
//The current scope altitude. The returned format depending on the current precision setting.
|
||||||
|
return DMSToDouble(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void AbortSlew()
|
public void AbortSlew()
|
||||||
{
|
{
|
||||||
SerialPort.Command("#:Q#");
|
SerialPort.Command("#:Q#");
|
||||||
|
|||||||
Reference in New Issue
Block a user