Impemented the code changes to return co-ordinated when the telescope is parked.

Also added loads of checks for if the telescope is parked.
This commit is contained in:
2021-04-24 20:52:21 +01:00
parent f4eafa668d
commit 18ea52c972
6 changed files with 97 additions and 25 deletions
@@ -90,6 +90,10 @@
<Project>{64308775-bd4a-469c-bcab-3ed830b811af}</Project>
<Name>Meade.net.Telescope</Name>
</ProjectReference>
<ProjectReference Include="..\Meade.net\Meade.net.csproj">
<Project>{3689a2cb-94c5-4012-a5cf-7e7d1dd27143}</Project>
<Name>Meade.net</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
@@ -122,7 +122,6 @@
<Compile Include="AstroMaths\AstroMathExtensions.cs" />
<Compile Include="AstroMaths\AstroMaths.cs" />
<Compile Include="AstroMaths\EquatorialCoordinates.cs" />
<Compile Include="AstroMaths\HorizonCoordinates.cs" />
<Compile Include="AstroMaths\IAstroMaths.cs" />
<Compile Include="Clock.cs" />
<Compile Include="ComparisonResult.cs" />
+77 -14
View File
@@ -878,6 +878,7 @@ namespace ASCOM.Meade.net
public void AbortSlew()
{
CheckConnected("AbortSlew");
CheckParked();
LogMessage("AbortSlew", "Aborting slew");
SharedResourcesWrapper.SendBlind(":Q#");
@@ -889,6 +890,12 @@ namespace ASCOM.Meade.net
SetSlewingMinEndTime();
}
private void CheckParked()
{
if (AtPark)
throw new ParkedException("Telescope is parked");
}
public AlignmentModes AlignmentMode
{
get
@@ -1247,21 +1254,41 @@ namespace ASCOM.Meade.net
}
}
private double _lastGoodDeclination;
public double Declination
{
get
{
CheckConnected("Declination Get");
try
{
CheckParked();
var result = SharedResourcesWrapper.SendString(":GD#");
//:GD# Get Telescope Declination.
//Returns: sDD*MM# or sDD*MMSS#
//Depending upon the current precision setting for the telescope.
var result = SharedResourcesWrapper.SendString(":GD#");
//:GD# Get Telescope Declination.
//Returns: sDD*MM# or sDD*MMSS#
//Depending upon the current precision setting for the telescope.
double declination = _utilities.DMSToDegrees(result);
double declination = _utilities.DMSToDegrees(result);
LogMessage("Declination", $"Get - {result} convert to {declination} {_utilitiesExtra.DegreesToDMS(declination, ":", ":")}");
return declination;
LogMessage("Declination", $"Get - {result} convert to {declination} {_utilitiesExtra.DegreesToDMS(declination, ":", ":")}");
_lastGoodDeclination = declination;
return declination;
}
catch (ParkedException)
{
switch (ParkedBehaviour)
{
case ParkedBehaviour.LastGoodPosition:
return _lastGoodDeclination;
case ParkedBehaviour.ReportCoordinates:
var raDec = _astroMaths.ConvertHozToEq(UTCDate, SiteLatitude, SiteLongitude, ParkedAltAz);
return raDec.Declination;
default:
throw;
}
}
}
}
@@ -1413,6 +1440,7 @@ namespace ASCOM.Meade.net
{
LogMessage("MoveAxis", $"Axis={axis} rate={rate}");
CheckConnected("MoveAxis");
CheckParked();
var absRate = Math.Abs(rate);
@@ -1535,6 +1563,7 @@ namespace ASCOM.Meade.net
try
{
CheckConnected("PulseGuide");
CheckParked();
if (IsSlewingToTarget())
throw new InvalidOperationException("Unable to PulseGuide whilst slewing to target.");
@@ -1645,20 +1674,42 @@ namespace ASCOM.Meade.net
return _utilities.HMSToHours(hms);
}
double _lastGoodRightAsension;
public double RightAscension
{
get
{
CheckConnected("RightAscension Get");
var result = SharedResourcesWrapper.SendString(":GR#");
//:GR# Get Telescope RA
//Returns: HH:MM.T# or HH:MM:SS#
//Depending which precision is set for the telescope
try
{
CheckParked();
double rightAscension = HmToHours(result);
var result = SharedResourcesWrapper.SendString(":GR#");
//:GR# Get Telescope RA
//Returns: HH:MM.T# or HH:MM:SS#
//Depending which precision is set for the telescope
double rightAscension = HmToHours(result);
LogMessage("RightAscension", $"Get - {result} convert to {rightAscension} {_utilitiesExtra.HoursToHMS(rightAscension)}");
_lastGoodRightAsension = rightAscension;
return rightAscension;
}
catch (ParkedException)
{
switch (ParkedBehaviour)
{
case ParkedBehaviour.LastGoodPosition:
return _lastGoodRightAsension;
case ParkedBehaviour.ReportCoordinates:
var raDec = _astroMaths.ConvertHozToEq(UTCDate, SiteLatitude, SiteLongitude, ParkedAltAz);
return raDec.RightAscension;
default:
throw;
}
}
LogMessage("RightAscension", $"Get - {result} convert to {rightAscension} {_utilitiesExtra.HoursToHMS(rightAscension)}");
return rightAscension;
}
}
@@ -1870,6 +1921,7 @@ namespace ASCOM.Meade.net
{
LogMessage("SlewToAltAz", $"Az=~{azimuth} Alt={altitude}");
CheckConnected("SlewToAltAz");
CheckParked();
SlewToAltAzAsync(azimuth, altitude);
@@ -1882,6 +1934,7 @@ namespace ASCOM.Meade.net
public void SlewToAltAzAsync(double azimuth, double altitude)
{
CheckConnected("SlewToAltAzAsync");
CheckParked();
if (altitude > 90)
throw new InvalidValueException("Altitude cannot be greater than 90.");
@@ -1922,6 +1975,7 @@ namespace ASCOM.Meade.net
private void DoSlewAsync(bool polar)
{
CheckConnected("DoSlewAsync");
CheckParked();
SharedResourcesWrapper.Lock(() =>
{
@@ -1986,6 +2040,7 @@ namespace ASCOM.Meade.net
{
LogMessage("SlewToCoordinates", $"Ra={rightAscension}, Dec={declination}");
CheckConnected("SlewToCoordinates");
CheckParked();
SlewToCoordinatesAsync(rightAscension, declination);
@@ -2001,6 +2056,7 @@ namespace ASCOM.Meade.net
{
LogMessage("SlewToCoordinatesAsync", $"Ra={rightAscension}, Dec={declination}");
CheckConnected("SlewToCoordinatesAsync");
CheckParked();
SharedResourcesWrapper.Lock(() =>
{
@@ -2016,6 +2072,7 @@ namespace ASCOM.Meade.net
{
LogMessage("SlewToTarget", "Executing");
CheckConnected("SlewToTarget");
CheckParked();
SlewToTargetAsync();
while (Slewing)
@@ -2029,6 +2086,7 @@ namespace ASCOM.Meade.net
public void SlewToTargetAsync()
{
CheckConnected("SlewToTargetAsync");
CheckParked();
if (TargetDeclination.Equals(InvalidParameter) || TargetRightAscension.Equals(InvalidParameter))
throw new InvalidOperationException("No target selected to slew to.");
@@ -2167,6 +2225,7 @@ namespace ASCOM.Meade.net
LogMessage("SyncToCoordinates", $"RA={rightAscension} Dec={declination}");
LogMessage("SyncToCoordinates", $"RA={_utilitiesExtra.HoursToHMS(rightAscension)} Dec={_utilitiesExtra.HoursToHMS(declination)}");
CheckConnected("SyncToCoordinates");
CheckParked();
SharedResourcesWrapper.Lock(() =>
{
@@ -2181,6 +2240,7 @@ namespace ASCOM.Meade.net
{
LogMessage("SyncToTarget", "Executing");
CheckConnected("SyncToTarget");
CheckParked();
var result = SharedResourcesWrapper.SendString(":CM#");
//:CM# Synchronizes the telescope's position with the currently selected database object's coordinates.
@@ -2234,6 +2294,7 @@ namespace ASCOM.Meade.net
LogMessage("TargetDeclination Set", $"{value}");
CheckConnected("TargetDeclination Set");
CheckParked();
if (value > 90)
throw new InvalidValueException("Declination cannot be greater than 90.");
@@ -2289,6 +2350,7 @@ namespace ASCOM.Meade.net
{
LogMessage("TargetRightAscension Set", $"{value}");
CheckConnected("TargetRightAscension Set");
CheckParked();
if (value < 0)
throw new InvalidValueException("Right ascension value cannot be below 0");
@@ -2357,6 +2419,7 @@ namespace ASCOM.Meade.net
{
LogMessage("TrackingRate Set", $"{value}");
CheckConnected("TrackingRate Set");
CheckParked();
switch (value)
{
+2
View File
@@ -137,6 +137,7 @@
<DependentUpon>frmMain.cs</DependentUpon>
</Compile>
<Compile Include="GarbageCollection.cs" />
<Compile Include="AstroMaths\HorizonCoordinates.cs" />
<Compile Include="LocalServer.cs" />
<Compile Include="MeadeTelescopeBase.cs" />
<Compile Include="ParkedBehaviour.cs" />
@@ -201,6 +202,7 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
+11 -7
View File
@@ -1,6 +1,7 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using ASCOM.Meade.net.AstroMaths;
using ASCOM.Meade.net.Wrapper;
using ASCOM.Utilities;
@@ -30,10 +31,9 @@ namespace ASCOM.Meade.net
protected short ProfileSettleTime;
protected bool SendDateTime;
protected ParkedBehaviour ParkedBehaviour;
protected double ParkedAzimuth;
protected double ParkedAlt;
protected HorizonCoordinates ParkedAltAz;
protected readonly ISharedResourcesWrapper SharedResourcesWrapper;
protected readonly ISharedResourcesWrapper SharedResourcesWrapper;
public MeadeTelescopeBase()
{
@@ -75,8 +75,12 @@ namespace ASCOM.Meade.net
ProfileSettleTime = profileProperties.SettleTime;
SendDateTime = profileProperties.SendDateTime;
ParkedBehaviour = profileProperties.ParkedBehaviour;
ParkedAlt = profileProperties.ParkedAlt;
ParkedAzimuth = profileProperties.ParkedAz;
var ParkedAltAz = new HorizonCoordinates
{
Altitude = profileProperties.ParkedAlt,
Azimuth = profileProperties.ParkedAz
};
LogMessage("ReadProfile", $"Trace logger enabled: {Tl.Enabled}");
LogMessage("ReadProfile", $"Com Port: {ComPort}");
@@ -89,8 +93,8 @@ namespace ASCOM.Meade.net
LogMessage("ReadProfile", $"Settle Time after slew: {ProfileSettleTime}");
LogMessage("ReadProfile", $"Send date and time on connect: {SendDateTime}");
LogMessage("ReadProfile", $"Parked Behaviour: {ParkedBehaviour}");
LogMessage("ReadProfile", $"Parked Alt: {ParkedAlt}");
LogMessage("ReadProfile", $"Parked Az: {ParkedAzimuth}");
LogMessage("ReadProfile", $"Parked Alt: {ParkedAltAz.Altitude}");
LogMessage("ReadProfile", $"Parked Az: {ParkedAltAz.Azimuth}");
}
/// <summary>