Moved parked SiteLat/Long to ParkedPosition data

This commit is contained in:
Sebastian Godelet
2021-06-28 12:45:26 +10:00
parent a3408a86c3
commit 90713de34b
2 changed files with 14 additions and 26 deletions
+12 -26
View File
@@ -1383,7 +1383,6 @@ namespace ASCOM.Meade.net
} }
} }
private double _lastGoodDeclination;
public double Declination public double Declination
{ {
@@ -1402,7 +1401,6 @@ namespace ASCOM.Meade.net
double declination = _utilities.DMSToDegrees(result); double declination = _utilities.DMSToDegrees(result);
LogMessage("Declination", $"Get - {result} convert to {declination} {_utilitiesExtra.DegreesToDMS(declination, ":", ":")}"); LogMessage("Declination", $"Get - {result} convert to {declination} {_utilitiesExtra.DegreesToDMS(declination, ":", ":")}");
_lastGoodDeclination = declination;
return declination; return declination;
} }
catch (ParkedException) catch (ParkedException)
@@ -1689,7 +1687,9 @@ namespace ASCOM.Meade.net
Altitude = Altitude, Altitude = Altitude,
Azimuth = Azimuth, Azimuth = Azimuth,
RightAscension = RightAscension, RightAscension = RightAscension,
Declination = Declination Declination = Declination,
SiteLatitude = SiteLatitude,
SiteLongitude = SiteLongitude
}; };
break; break;
case ParkedBehaviour.ReportCoordinates: case ParkedBehaviour.ReportCoordinates:
@@ -1703,7 +1703,9 @@ namespace ASCOM.Meade.net
Altitude = ParkedAltAz.Altitude, Altitude = ParkedAltAz.Altitude,
Azimuth = ParkedAltAz.Azimuth, Azimuth = ParkedAltAz.Azimuth,
RightAscension = raDec.RightAscension, RightAscension = raDec.RightAscension,
Declination = raDec.Declination Declination = raDec.Declination,
SiteLatitude = latitude,
SiteLongitude = longitude
}; };
break; break;
default: default:
@@ -1837,7 +1839,6 @@ namespace ASCOM.Meade.net
return _utilities.HMSToHours(hms); return _utilities.HMSToHours(hms);
} }
double _lastGoodRightAsension;
public double RightAscension public double RightAscension
{ {
@@ -1856,7 +1857,6 @@ namespace ASCOM.Meade.net
double rightAscension = HmToHours(result); double rightAscension = HmToHours(result);
LogMessage("RightAscension", $"Get - {result} convert to {rightAscension} {_utilitiesExtra.HoursToHMS(rightAscension)}"); LogMessage("RightAscension", $"Get - {result} convert to {rightAscension} {_utilitiesExtra.HoursToHMS(rightAscension)}");
_lastGoodRightAsension = rightAscension;
return rightAscension; return rightAscension;
} }
catch (ParkedException) catch (ParkedException)
@@ -1983,7 +1983,6 @@ namespace ASCOM.Meade.net
} }
} }
private double? _lastGoodSiteLatitude;
public double SiteLatitude public double SiteLatitude
{ {
get get
@@ -2002,19 +2001,14 @@ namespace ASCOM.Meade.net
{ {
var siteLatitude = _utilities.DMSToDegrees(latitude); var siteLatitude = _utilities.DMSToDegrees(latitude);
LogMessage("SiteLatitude Get", $"{_utilitiesExtra.DegreesToDMS(siteLatitude)}"); LogMessage("SiteLatitude Get", $"{_utilitiesExtra.DegreesToDMS(siteLatitude)}");
_lastGoodSiteLatitude = siteLatitude;
return siteLatitude; return siteLatitude;
} }
throw new InvalidOperationException("unable to get site latitude from telescope."); throw new InvalidOperationException("unable to get site latitude from telescope.");
} }
catch (ParkedException) catch (ParkedException) when (ParkedBehaviour != ParkedBehaviour.NoCoordinates && SharedResourcesWrapper.ParkedPosition is var parkedPosition)
{ {
if (ParkedBehaviour == ParkedBehaviour.NoCoordinates) return parkedPosition.SiteLatitude;
throw;
return _lastGoodSiteLatitude.Value;
} }
} }
set set
@@ -2044,12 +2038,9 @@ namespace ASCOM.Meade.net
//1 - Valid //1 - Valid
if (result != "1") if (result != "1")
throw new InvalidOperationException("Failed to set site latitude."); throw new InvalidOperationException("Failed to set site latitude.");
_lastGoodSiteLatitude = value;
} }
} }
private double _lastGoodSiteLongitude;
public double SiteLongitude public double SiteLongitude
{ {
@@ -2067,18 +2058,15 @@ namespace ASCOM.Meade.net
double siteLongitude = -_utilities.DMSToDegrees(longitude); double siteLongitude = -_utilities.DMSToDegrees(longitude);
if (siteLongitude < -180) if (siteLongitude < -180)
siteLongitude = siteLongitude + 360; siteLongitude += 360;
LogMessage("SiteLongitude Get", $"{_utilitiesExtra.DegreesToDMS(siteLongitude)}"); LogMessage("SiteLongitude Get", $"{_utilitiesExtra.DegreesToDMS(siteLongitude)}");
_lastGoodSiteLongitude = siteLongitude;
return siteLongitude; return siteLongitude;
} }
catch (ParkedException) catch (ParkedException) when (ParkedBehaviour != ParkedBehaviour.NoCoordinates && SharedResourcesWrapper.ParkedPosition is var parkedPosition)
{ {
if (ParkedBehaviour == ParkedBehaviour.NoCoordinates) return parkedPosition.SiteLongitude;
throw;
return _lastGoodSiteLongitude;
} }
} }
set set
@@ -2113,8 +2101,6 @@ namespace ASCOM.Meade.net
//1 - Valid //1 - Valid
if (result != "1") if (result != "1")
throw new InvalidOperationException("Failed to set site longitude."); throw new InvalidOperationException("Failed to set site longitude.");
_lastGoodSiteLongitude = value;
} }
} }
+2
View File
@@ -6,5 +6,7 @@ namespace ASCOM.Meade.net
public double Azimuth { get; set; } public double Azimuth { get; set; }
public double RightAscension { get; set; } public double RightAscension { get; set; }
public double Declination { get; set; } public double Declination { get; set; }
public double SiteLongitude { get; set; }
public double SiteLatitude { get; set; }
} }
} }