Added Alt Az coordinates to the connected message.

This commit is contained in:
2022-05-07 14:00:29 +01:00
parent 350dd23ed1
commit 700802033b
3 changed files with 69 additions and 48 deletions
@@ -477,7 +477,7 @@ namespace Meade.net.Telescope.UnitTests
if (expectedConnected) if (expectedConnected)
{ {
_sharedResourcesWrapperMock.Verify(x => x.SendString("GZ", false), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.SendString("GZ", false), Times.AtLeastOnce);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($"Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}", false), Times.Never); _sharedResourcesWrapperMock.Verify(x => x.SendBlind($"Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}", false), Times.Never);
} }
} }
@@ -488,7 +488,7 @@ namespace Meade.net.Telescope.UnitTests
ConnectTelescope(TelescopeList.LX200GPS, string.Empty); ConnectTelescope(TelescopeList.LX200GPS, string.Empty);
_sharedResourcesWrapperMock.Verify(x => x.Connect("Serial", It.IsAny<string>(), It.IsAny<ITraceLogger>()), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.Connect("Serial", It.IsAny<string>(), It.IsAny<ITraceLogger>()), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendString("GZ", false), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.SendString("GZ", false), Times.AtLeastOnce);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($"Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}", false), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.SendBlind($"Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}", false), Times.Once);
} }
+65 -45
View File
@@ -503,8 +503,9 @@ namespace ASCOM.Meade.net
} }
var raAndDec = GetTelescopeRaAndDec(); var raAndDec = GetTelescopeRaAndDec();
var altAndAz = GetTelescopeAltAz();
LogMessage("Connected Set", LogMessage("Connected Set",
$"Connected OK. Current RA = {_utilitiesExtra.HoursToHMS(raAndDec.RightAscension)} Dec = {_utilitiesExtra.DegreesToDMS(raAndDec.Declination)}"); $"Connected OK. Current RA = {_utilitiesExtra.HoursToHMS(raAndDec.RightAscension)} Dec = {_utilitiesExtra.DegreesToDMS(raAndDec.Declination)} Az={altAndAz.Azimuth} Alt={altAndAz.Altitude}");
} }
catch (Exception) catch (Exception)
{ {
@@ -1102,28 +1103,7 @@ namespace ASCOM.Meade.net
if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS)
{ {
try return GetRealTelescopeAltitude();
{
CheckParked();
//firmware bug in 44Eg, :GA# is returning the dec, not the altitude!
var result = SharedResourcesWrapper.SendString("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.
var alt = _utilities.DMSToDegrees(result);
LogMessage("Altitude", $"{alt}");
return alt;
}
catch (ParkedException)
{
var parkedPosition = SharedResourcesWrapper.ParkedPosition;
if (parkedPosition != null)
return parkedPosition.Altitude;
throw;
}
} }
var altAz = CalcAltAzFromTelescopeEqData(); var altAz = CalcAltAzFromTelescopeEqData();
@@ -1132,6 +1112,32 @@ namespace ASCOM.Meade.net
} }
} }
private double GetRealTelescopeAltitude()
{
try
{
CheckParked();
//firmware bug in 44Eg, :GA# is returning the dec, not the altitude!
var result = SharedResourcesWrapper.SendString("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.
var alt = _utilities.DMSToDegrees(result);
LogMessage("Altitude", $"{alt}");
return alt;
}
catch (ParkedException)
{
var parkedPosition = SharedResourcesWrapper.ParkedPosition;
if (parkedPosition != null)
return parkedPosition.Altitude;
throw;
}
}
private HorizonCoordinates CalcAltAzFromTelescopeEqData() private HorizonCoordinates CalcAltAzFromTelescopeEqData()
{ {
var altitudeData = new AltitudeData var altitudeData = new AltitudeData
@@ -1159,6 +1165,15 @@ namespace ASCOM.Meade.net
}; };
} }
private HorizonCoordinates GetTelescopeAltAz()
{
return new HorizonCoordinates()
{
Altitude = GetRealTelescopeAltitude(),
Azimuth = GetRealTelescopeAzimuth()
};
}
public double ApertureArea public double ApertureArea
{ {
get get
@@ -1212,28 +1227,7 @@ namespace ASCOM.Meade.net
if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS)
{ {
try return GetRealTelescopeAzimuth();
{
CheckParked();
var result = SharedResourcesWrapper.SendString("GZ");
//:GZ# Get telescope azimuth
//Returns: DDD*MM#T or DDD*MM'SS#
//The current telescope Azimuth depending on the selected precision.
double az = _utilities.DMSToDegrees(result);
LogMessage("Azimuth Get", $"{az}");
return az;
}
catch (ParkedException)
{
var parkedPosition = SharedResourcesWrapper.ParkedPosition;
if (parkedPosition != null)
return parkedPosition.Azimuth;
throw;
}
} }
var altAz = CalcAltAzFromTelescopeEqData(); var altAz = CalcAltAzFromTelescopeEqData();
@@ -1242,6 +1236,32 @@ namespace ASCOM.Meade.net
} }
} }
private double GetRealTelescopeAzimuth()
{
try
{
CheckParked();
var result = SharedResourcesWrapper.SendString("GZ");
//:GZ# Get telescope azimuth
//Returns: DDD*MM#T or DDD*MM'SS#
//The current telescope Azimuth depending on the selected precision.
double az = _utilities.DMSToDegrees(result);
LogMessage("Azimuth Get", $"{az}");
return az;
}
catch (ParkedException)
{
var parkedPosition = SharedResourcesWrapper.ParkedPosition;
if (parkedPosition != null)
return parkedPosition.Azimuth;
throw;
}
}
public bool CanFindHome public bool CanFindHome
{ {
get get
+1
View File
@@ -391,6 +391,7 @@ namespace ASCOM.Meade.net
SharedSerial.Parity = (SerialParity)Enum.Parse(typeof(SerialParity), profileProperties.Parity); SharedSerial.Parity = (SerialParity)Enum.Parse(typeof(SerialParity), profileProperties.Parity);
SharedSerial.Speed = (SerialSpeed)profileProperties.Speed; SharedSerial.Speed = (SerialSpeed)profileProperties.Speed;
SharedSerial.Handshake = (SerialHandshake)Enum.Parse(typeof(SerialHandshake), profileProperties.Handshake); SharedSerial.Handshake = (SerialHandshake)Enum.Parse(typeof(SerialHandshake), profileProperties.Handshake);
SharedSerial.ReceiveTimeout = 5; //5 second timeout;
SharedSerial.Connected = true; SharedSerial.Connected = true;
try try