Move SideOfPier, TargetRA/DEC properties to SharedResourcesWrapper

This change allows several instances of the driver to be in sync
w.r.t. TargetRightAscension, TargetDeclination and SideOfPier
This commit is contained in:
Sebastian Godelet
2021-06-12 15:47:34 +10:00
parent 8c4b08d0c6
commit 1684bd60bd
4 changed files with 122 additions and 80 deletions
@@ -100,10 +100,15 @@ namespace Meade.net.Telescope.UnitTests
SameDevice = 1 SameDevice = 1
}; };
_sharedResourcesWrapperMock.Setup(x => x.Connect("Serial", It.IsAny<string>(), It.IsAny<ITraceLogger>())).Returns( () => _connectionInfo ); _sharedResourcesWrapperMock.Setup(x => x.Connect("Serial", It.IsAny<string>(), It.IsAny<ITraceLogger>())).Returns( () => _connectionInfo);
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(_profileProperties); _sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(_profileProperties);
_sharedResourcesWrapperMock
.SetupProperty(x => x.SideOfPier)
.SetupProperty(x => x.TargetRightAscension)
.SetupProperty(x => x.TargetDeclination);
_astroMathsMock = new Mock<IAstroMaths>(); _astroMathsMock = new Mock<IAstroMaths>();
_clockMock = new Mock<IClock>(); _clockMock = new Mock<IClock>();
@@ -1230,6 +1235,10 @@ namespace Meade.net.Telescope.UnitTests
public void DestinationSideOfPier_WhenHASiderealTimeDiffIsNotNull_ThenSideOfPierIsCalculated(double ra, double dec, double siderealTime, PierSide expectedDSOP) public void DestinationSideOfPier_WhenHASiderealTimeDiffIsNotNull_ThenSideOfPierIsCalculated(double ra, double dec, double siderealTime, PierSide expectedDSOP)
{ {
// given // given
// deterministic start
_sharedResourcesWrapperMock.Object.SideOfPier = PierSide.pierUnknown;
// SideralTime uses ConditionRA to normalize to [0..24h), so we use it to mock the property // SideralTime uses ConditionRA to normalize to [0..24h), so we use it to mock the property
_astroUtilsMock.Setup(x => x.ConditionRA(It.IsAny<double>())).Returns(siderealTime); _astroUtilsMock.Setup(x => x.ConditionRA(It.IsAny<double>())).Returns(siderealTime);
+67 -68
View File
@@ -418,8 +418,6 @@ namespace ASCOM.Meade.net
$"Connected to port {ComPort}. Product: {SharedResourcesWrapper.ProductName} Version:{SharedResourcesWrapper.FirmwareVersion}"); $"Connected to port {ComPort}. Product: {SharedResourcesWrapper.ProductName} Version:{SharedResourcesWrapper.FirmwareVersion}");
_userNewerPulseGuiding = IsNewPulseGuidingSupported(); _userNewerPulseGuiding = IsNewPulseGuidingSupported();
_targetDeclination = InvalidParameter;
_targetRightAscension = InvalidParameter;
_tracking = true; _tracking = true;
LogMessage("Connected Set", $"New Pulse Guiding Supported: {_userNewerPulseGuiding}"); LogMessage("Connected Set", $"New Pulse Guiding Supported: {_userNewerPulseGuiding}");
@@ -443,6 +441,11 @@ namespace ASCOM.Meade.net
SetTelescopePrecision("Connect"); SetTelescopePrecision("Connect");
// target RA, DEC and SideOfPier are set to default values
SharedResourcesWrapper.SideOfPier = PierSide.pierUnknown;
SharedResourcesWrapper.TargetDeclination = InvalidParameter;
SharedResourcesWrapper.TargetRightAscension = InvalidParameter;
LogMessage("Connected Set", $"SendDateTime: {SendDateTime}"); LogMessage("Connected Set", $"SendDateTime: {SendDateTime}");
if (SendDateTime) if (SendDateTime)
{ {
@@ -720,7 +723,7 @@ namespace ASCOM.Meade.net
var result = SharedResourcesWrapper.SendString("GZ"); var result = SharedResourcesWrapper.SendString("GZ");
LogMessage("SetLongFormat", $"Get - Azimuth {result}"); LogMessage("SetLongFormat", $"Get - Azimuth {result}");
//:GZ# Get telescope azimuth //:GZ# Get telescope azimuth
//Returns: DDD*MM.T or DDD*MMSS# //Returns: DDD*MM.T or DDD*MM'SS#
//The current telescope Azimuth depending on the selected precision. //The current telescope Azimuth depending on the selected precision.
IsLongFormat = result.Length > 6; IsLongFormat = result.Length > 6;
@@ -754,8 +757,8 @@ namespace ASCOM.Meade.net
var result = SharedResourcesWrapper.SendChar("P"); var result = SharedResourcesWrapper.SendChar("P");
//:P# Toggles High Precsion Pointing. When High precision pointing is enabled scope will first allow the operator to center a nearby bright star before moving to the actual target. //:P# Toggles High Precsion Pointing. When High precision pointing is enabled scope will first allow the operator to center a nearby bright star before moving to the actual target.
//Returns: <string> //Returns: <string>
//HIGH PRECISION Current setting after this command. //"HIGH PRECISION" Current setting after this command.
//LOW PRECISION Current setting after this command. //"LOW PRECISION" Current setting after this command.
int throwAwayCharacters = "LOW PRECISION".Length - 1; int throwAwayCharacters = "LOW PRECISION".Length - 1;
@@ -816,33 +819,33 @@ namespace ASCOM.Meade.net
case 1: case 1:
command = $"SM{sitename}"; command = $"SM{sitename}";
//:SM<string># //:SM<string>#
//Set site 1s name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters. //Set site 1's name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters.
// Returns: // Returns:
//0 Invalid //0 - Invalid
//1 - Valid //1 - Valid
break; break;
case 2: case 2:
command = $"SN{sitename}"; command = $"SN{sitename}";
//:SN<string># //:SN<string>#
//Set site 2s name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters. //Set site 2's name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters.
// Returns: // Returns:
//0 Invalid //0 - Invalid
//1 - Valid //1 - Valid
break; break;
case 3: case 3:
command = $"SO{sitename}"; command = $"SO{sitename}";
//:SO<string># //:SO<string>#
//Set site 3s name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters. //Set site 3's name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters.
// Returns: // Returns:
//0 Invalid //0 - Invalid
//1 - Valid //1 - Valid
break; break;
case 4: case 4:
command = $"SP{sitename}"; command = $"SP{sitename}";
//:SP<string># //:SP<string>#
//Set site 4s name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters. //Set site 4's name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters.
// Returns: // Returns:
//0 Invalid //0 - Invalid
//1 - Valid //1 - Valid
break; break;
default: default:
@@ -867,22 +870,22 @@ namespace ASCOM.Meade.net
return SharedResourcesWrapper.SendString("GM"); return SharedResourcesWrapper.SendString("GM");
//:GM# Get Site 1 Name //:GM# Get Site 1 Name
//Returns: <string># //Returns: <string>#
//A # terminated string with the name of the requested site. //A '#' terminated string with the name of the requested site.
case 2: case 2:
return SharedResourcesWrapper.SendString("GN"); return SharedResourcesWrapper.SendString("GN");
//:GN# Get Site 2 Name //:GN# Get Site 2 Name
//Returns: <string># //Returns: <string>#
//A # terminated string with the name of the requested site. //A '#' terminated string with the name of the requested site.
case 3: case 3:
return SharedResourcesWrapper.SendString("GO"); return SharedResourcesWrapper.SendString("GO");
//:GO# Get Site 3 Name //:GO# Get Site 3 Name
//Returns: <string># //Returns: <string>#
//A # terminated string with the name of the requested site. //A '#' terminated string with the name of the requested site.
case 4: case 4:
return SharedResourcesWrapper.SendString("GP"); return SharedResourcesWrapper.SendString("GP");
//:GP# Get Site 4 Name //:GP# Get Site 4 Name
//Returns: <string># //Returns: <string>#
//A # terminated string with the name of the requested site. //A '#' terminated string with the name of the requested site.
default: default:
throw new ArgumentOutOfRangeException(nameof(site), site, throw new ArgumentOutOfRangeException(nameof(site), site,
Resources.Telescope_GetSiteName_Site_out_of_range); Resources.Telescope_GetSiteName_Site_out_of_range);
@@ -1040,7 +1043,7 @@ namespace ASCOM.Meade.net
//firmware bug in 44Eg, :GA# is returning the dec, not the altitude! //firmware bug in 44Eg, :GA# is returning the dec, not the altitude!
var result = SharedResourcesWrapper.SendString("GA"); var result = SharedResourcesWrapper.SendString("GA");
//:GA# Get Telescope Altitude //:GA# Get Telescope Altitude
//Returns: sDD* MM# or sDD*MMSS# //Returns: sDD* MM# or sDD*MM'SS#
//The current scope altitude. The returned format depending on the current precision setting. //The current scope altitude. The returned format depending on the current precision setting.
var alt = _utilities.DMSToDegrees(result); var alt = _utilities.DMSToDegrees(result);
@@ -1147,7 +1150,7 @@ namespace ASCOM.Meade.net
var result = SharedResourcesWrapper.SendString("GZ"); var result = SharedResourcesWrapper.SendString("GZ");
//:GZ# Get telescope azimuth //:GZ# Get telescope azimuth
//Returns: DDD*MM#T or DDD*MMSS# //Returns: DDD*MM#T or DDD*MM'SS#
//The current telescope Azimuth depending on the selected precision. //The current telescope Azimuth depending on the selected precision.
double az = _utilities.DMSToDegrees(result); double az = _utilities.DMSToDegrees(result);
@@ -1347,7 +1350,7 @@ namespace ASCOM.Meade.net
var result = SharedResourcesWrapper.SendString("GD"); var result = SharedResourcesWrapper.SendString("GD");
//:GD# Get Telescope Declination. //:GD# Get Telescope Declination.
//Returns: sDD*MM# or sDD*MMSS# //Returns: sDD*MM# or sDD*MM'SS#
//Depending upon the current precision setting for the telescope. //Depending upon the current precision setting for the telescope.
double declination = _utilities.DMSToDegrees(result); double declination = _utilities.DMSToDegrees(result);
@@ -1449,7 +1452,7 @@ namespace ASCOM.Meade.net
if (!value.InRange(0, 15.0417)) if (!value.InRange(0, 15.0417))
{ {
throw new InvalidValueException(propertyName, value.ToString(CultureInfo.CurrentCulture), $"{0.ToString(CultureInfo.CurrentCulture)} to {15.0417.ToString(CultureInfo.CurrentCulture)}”/sec"); throw new InvalidValueException(propertyName, value.ToString(CultureInfo.CurrentCulture), $"{0.ToString(CultureInfo.CurrentCulture)} to {15.0417.ToString(CultureInfo.CurrentCulture)}\"/sec");
} }
LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString(CultureInfo.CurrentCulture)} arc seconds/second ({value.ToString(CultureInfo.CurrentCulture)} degrees/second)"); LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString(CultureInfo.CurrentCulture)} arc seconds/second ({value.ToString(CultureInfo.CurrentCulture)} degrees/second)");
@@ -1457,7 +1460,7 @@ namespace ASCOM.Meade.net
//:RgSS.S# //:RgSS.S#
//Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking //Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking
//Rates when the CCD guider or handbox guider buttons are pressed when the guide rate is selected.Rate shall not exceed //Rates when the CCD guider or handbox guider buttons are pressed when the guide rate is selected.Rate shall not exceed
//sidereal speed(approx 15.0417/sec)[Autostar II only] //sidereal speed(approx 15.0417"/sec)[Autostar II only]
//Returns: Nothing //Returns: Nothing
//info from RickB says that 15.04107 is a better value for //info from RickB says that 15.04107 is a better value for
@@ -1583,7 +1586,7 @@ namespace ASCOM.Meade.net
//Returns: Nothing //Returns: Nothing
_movingPrimary = true; _movingPrimary = true;
// in principle we could calculate the current side of pier, but unknown is the safer option. // in principle we could calculate the current side of pier, but unknown is the safer option.
_pierSide = PierSide.pierUnknown; SharedResourcesWrapper.SideOfPier = PierSide.pierUnknown;
break; break;
case ComparisonResult.Lower: case ComparisonResult.Lower:
SharedResourcesWrapper.SendBlind("Mw"); SharedResourcesWrapper.SendBlind("Mw");
@@ -1591,7 +1594,7 @@ namespace ASCOM.Meade.net
//Returns: Nothing //Returns: Nothing
_movingPrimary = true; _movingPrimary = true;
// in principle we could calculate the current side of pier, but unknown is the safer option. // in principle we could calculate the current side of pier, but unknown is the safer option.
_pierSide = PierSide.pierUnknown; SharedResourcesWrapper.SideOfPier = PierSide.pierUnknown;
break; break;
} }
break; break;
@@ -1672,7 +1675,7 @@ namespace ASCOM.Meade.net
//Setting park to true before sending the park command as the Autostar and Audiostar stop serial communications once the park command has been issued. //Setting park to true before sending the park command as the Autostar and Audiostar stop serial communications once the park command has been issued.
SharedResourcesWrapper.SetParked(true, parkedPosition); SharedResourcesWrapper.SetParked(true, parkedPosition);
SharedResourcesWrapper.SendBlind("hP"); SharedResourcesWrapper.SendBlind("hP");
//:hP# Autostar, Autostar II and LX 16Slew to Park Position //:hP# Autostar, Autostar II and LX 16" Slew to Park Position
//Returns: Nothing //Returns: Nothing
} }
@@ -1728,8 +1731,8 @@ namespace ASCOM.Meade.net
//:MgwDDDD# //:MgwDDDD#
//Guide telescope in the commanded direction(nsew) for the number of milliseconds indicated by the unsigned number //Guide telescope in the commanded direction(nsew) for the number of milliseconds indicated by the unsigned number
//passed in the command.These commands support serial port driven guiding. //passed in the command.These commands support serial port driven guiding.
//Returns Nothing //Returns - Nothing
//LX200 Not Supported //LX200 - Not Supported
_utilities.WaitForMilliseconds(duration); _utilities.WaitForMilliseconds(duration);
} }
else else
@@ -1851,11 +1854,6 @@ namespace ASCOM.Meade.net
throw new MethodNotImplementedException("SetPark"); throw new MethodNotImplementedException("SetPark");
} }
/// <summary>
/// Start with <see cref="PierSide.pierUnknown"/>.
/// As we do not know the physical declination axis position, we have to keep track manually.
/// </summary>
private PierSide _pierSide = PierSide.pierUnknown;
public PierSide SideOfPier public PierSide SideOfPier
{ {
get get
@@ -1864,7 +1862,7 @@ namespace ASCOM.Meade.net
{ {
// while mount is slewing return unknown, this is required since // while mount is slewing return unknown, this is required since
// DoSlewAsync updates _pierSide before slew is finished // DoSlewAsync updates _pierSide before slew is finished
var pierSide = Slewing ? PierSide.pierUnknown : _pierSide; var pierSide = Slewing ? PierSide.pierUnknown : SharedResourcesWrapper.SideOfPier;
LogMessage("SideOfPier", "Get - " + pierSide); LogMessage("SideOfPier", "Get - " + pierSide);
return pierSide; return pierSide;
@@ -1996,7 +1994,7 @@ namespace ASCOM.Meade.net
//:StsDD*MM# //:StsDD*MM#
//Sets the current site latitude to sDD* MM# //Sets the current site latitude to sDD* MM#
//Returns: //Returns:
//0 Invalid //0 - Invalid
//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.");
@@ -2063,9 +2061,9 @@ namespace ASCOM.Meade.net
var result = SharedResourcesWrapper.SendChar(commandstring); var result = SharedResourcesWrapper.SendChar(commandstring);
//:SgDDD*MM# //:SgDDD*MM#
//Set current sites longitude to DDD*MM an ASCII position string //Set current site's longitude to DDD*MM an ASCII position string
//Returns: //Returns:
//0 Invalid //0 - Invalid
//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.");
@@ -2172,7 +2170,7 @@ namespace ASCOM.Meade.net
{ {
// Update side of pier to destination side of pier // Update side of pier to destination side of pier
// Assumption: Mount will do meridian flip if required // Assumption: Mount will do meridian flip if required
_pierSide = DestinationSideOfPier(TargetRightAscension, TargetDeclination); SharedResourcesWrapper.SideOfPier = DestinationSideOfPier(TargetRightAscension, TargetDeclination);
} }
SetSlewingMinEndTime(); SetSlewingMinEndTime();
@@ -2201,11 +2199,11 @@ namespace ASCOM.Meade.net
break; break;
case false: case false:
var maResponse = SharedResourcesWrapper.SendChar("MA"); var maResponse = SharedResourcesWrapper.SendChar("MA");
//:MA# Autostar, LX 16, Autostar II Slew to target Alt and Az //:MA# Autostar, LX 16", Autostar II - Slew to target Alt and Az
//Returns: //Returns:
//0 - No fault //0 - No fault
//1 Fault //1 - Fault
// LX200 Not supported //LX200 - Not supported
if (maResponse == "1") if (maResponse == "1")
{ {
@@ -2345,8 +2343,8 @@ namespace ASCOM.Meade.net
} }
//:D# Requests a string of bars indicating the distance to the current target location. //:D# Requests a string of bars indicating the distance to the current target location.
//Returns: //Returns:
//LX200's a string of bar characters indicating the distance. //LX200's - a string of bar characters indicating the distance.
//Autostars and Autostar II a string containing one bar until a slew is complete, then a null string is returned. //Autostars and Autostar II - a string containing one bar until a slew is complete, then a null string is returned.
bool isSlewing = false; bool isSlewing = false;
try try
@@ -2433,41 +2431,42 @@ namespace ASCOM.Meade.net
// At least the classic LX200 low precision might not slew to the exact target position // At least the classic LX200 low precision might not slew to the exact target position
// This Requires to retrieve the aimed target ra de from the telescope // This Requires to retrieve the aimed target ra de from the telescope
double targetRA = SharedResourcesWrapper.TargetRightAscension ?? InvalidParameter;
double ra = RightAscension; double ra = RightAscension;
if (Math.Abs(_targetRightAscension - InvalidParameter) > 0.1 && if (Math.Abs(targetRA - InvalidParameter) > 0.1 &&
_utilities.HoursToHMS(ra, ":", ":", ":", _digitsRa) != _utilities.HoursToHMS(_targetRightAscension, ":", ":", ":", _digitsRa)) _utilities.HoursToHMS(ra, ":", ":", ":", _digitsRa) != _utilities.HoursToHMS(targetRA, ":", ":", ":", _digitsRa))
{ {
LogMessage("SyncToTarget", $"differ RA real {ra} targeted {_targetRightAscension}"); LogMessage("SyncToTarget", $"differ RA real {ra} targeted {targetRA}");
_targetRightAscension = ra; SharedResourcesWrapper.TargetRightAscension = ra;
} }
double targetDEC = SharedResourcesWrapper.TargetDeclination ?? InvalidParameter;
double de = Declination; double de = Declination;
if (Math.Abs(_targetDeclination - InvalidParameter) > 0.1 && if (Math.Abs(targetDEC - InvalidParameter) > 0.1 &&
_utilities.DegreesToDMS(de, "*", ":", ":", _digitsDe) != _utilities.DegreesToDMS(_targetDeclination, "*", ":", ":", _digitsDe)) _utilities.DegreesToDMS(de, "*", ":", ":", _digitsDe) != _utilities.DegreesToDMS(targetDEC, "*", ":", ":", _digitsDe))
{ {
LogMessage("SyncToTarget", $"differ DE real {de} targeted {_targetDeclination}"); LogMessage("SyncToTarget", $"differ DE real {de} targeted {targetDEC}");
_targetDeclination = de; SharedResourcesWrapper.TargetDeclination = de;
} }
} }
private double _targetDeclination = InvalidParameter;
public double TargetDeclination public double TargetDeclination
{ {
get get
{ {
if (_targetDeclination.Equals(InvalidParameter)) var targetDeclination = SharedResourcesWrapper.TargetDeclination ?? InvalidParameter;
if (targetDeclination.Equals(InvalidParameter))
throw new InvalidOperationException("Target not set"); throw new InvalidOperationException("Target not set");
//var result = SerialPort.CommandTerminated(":Gd#", "#"); //var result = SerialPort.CommandTerminated(":Gd#", "#");
////:Gd# Get Currently Selected Object/Target Declination ////:Gd# Get Currently Selected Object/Target Declination
////Returns: sDD* MM# or sDD*MMSS# ////Returns: sDD* MM# or sDD*MM'SS#
////Depending upon the current precision setting for the telescope. ////Depending upon the current precision setting for the telescope.
//double targetDec = DmsToDouble(result); //double targetDec = DmsToDouble(result);
//return targetDec; //return targetDec;
LogMessage("TargetDeclination Get", $"{targetDeclination}");
LogMessage("TargetDeclination Get", $"{_targetDeclination}"); return targetDeclination;
return _targetDeclination;
} }
set set
{ {
@@ -2496,23 +2495,23 @@ namespace ASCOM.Meade.net
//Set target object declination to sDD*MM or sDD*MM:SS depending on the current precision setting //Set target object declination to sDD*MM or sDD*MM:SS depending on the current precision setting
//Returns: //Returns:
//1 - Dec Accepted //1 - Dec Accepted
//0 Dec invalid //0 - Dec invalid
if (result == "0") if (result == "0")
{ {
throw new InvalidOperationException("Target declination invalid"); throw new InvalidOperationException("Target declination invalid");
} }
_targetDeclination = _utilities.DMSToDegrees(dms); SharedResourcesWrapper.TargetDeclination = _utilities.DMSToDegrees(dms);
} }
} }
private double _targetRightAscension = InvalidParameter;
public double TargetRightAscension public double TargetRightAscension
{ {
get get
{ {
if (_targetRightAscension.Equals(InvalidParameter)) var targetRightAscension = SharedResourcesWrapper.TargetRightAscension ?? InvalidParameter;
if (targetRightAscension.Equals(InvalidParameter))
throw new InvalidOperationException("Target not set"); throw new InvalidOperationException("Target not set");
//var result = SerialPort.CommandTerminated(":Gr#", "#"); //var result = SerialPort.CommandTerminated(":Gr#", "#");
@@ -2523,8 +2522,8 @@ namespace ASCOM.Meade.net
//double targetRa = HmsToDouble(result); //double targetRa = HmsToDouble(result);
//return targetRa; //return targetRa;
LogMessage("TargetRightAscension Get", $"{_targetRightAscension}"); LogMessage("TargetRightAscension Get", $"{targetRightAscension}");
return _targetRightAscension; return targetRightAscension;
} }
set set
{ {
@@ -2549,13 +2548,13 @@ namespace ASCOM.Meade.net
//:SrHH:MM:SS# //:SrHH:MM:SS#
//Set target object RA to HH:MM.T or HH: MM: SS depending on the current precision setting. //Set target object RA to HH:MM.T or HH: MM: SS depending on the current precision setting.
// Returns: // Returns:
//0 Invalid //0 - Invalid
//1 - Valid //1 - Valid
if (response == "0") if (response == "0")
throw new InvalidOperationException("Failed to set TargetRightAscension."); throw new InvalidOperationException("Failed to set TargetRightAscension.");
_targetRightAscension = _utilities.HMSToHours(hms); SharedResourcesWrapper.TargetRightAscension = _utilities.HMSToHours(hms);
} }
} }
@@ -2735,7 +2734,7 @@ namespace ASCOM.Meade.net
//:SLHH:MM:SS# //:SLHH:MM:SS#
//Set the local Time //Set the local Time
//Returns: //Returns:
//0 Invalid //0 - Invalid
//1 - Valid //1 - Valid
if (timeResult != "1") if (timeResult != "1")
{ {
@@ -2747,8 +2746,8 @@ namespace ASCOM.Meade.net
//:SCMM/DD/YY# //:SCMM/DD/YY#
//Change Handbox Date to MM/DD/YY //Change Handbox Date to MM/DD/YY
//Returns: <D><string> //Returns: <D><string>
//D = 0 if the date is invalid.The string is the null string. //D = '0' if the date is invalid. The string is the null string.
//D = 1 for valid dates and the string is Updating Planetary Data# # //D = '1' for valid dates and the string is "Updating Planetary Data# #"
//Note: For Autostar II this is the UTC data! //Note: For Autostar II this is the UTC data!
if (dateResult != "1") if (dateResult != "1")
{ {
@@ -2796,7 +2795,7 @@ namespace ASCOM.Meade.net
//Bypass handbox entry of daylight savings, date and time.Use the values supplied in this command.This feature is //Bypass handbox entry of daylight savings, date and time.Use the values supplied in this command.This feature is
//intended to allow use of the Autostar II from permanent installations where GPS reception is not possible, such as within //intended to allow use of the Autostar II from permanent installations where GPS reception is not possible, such as within
//metal domes. This command must be issued while the telescope is waiting at the initial daylight savings prompt. //metal domes. This command must be issued while the telescope is waiting at the initial daylight savings prompt.
//Returns: 1 if command was accepted. //Returns: 1 - if command was accepted.
return result == "1"; return result == "1";
} }
+21 -10
View File
@@ -4,7 +4,7 @@
// ================ // ================
// //
// This class is a container for all shared resources that may be needed // This class is a container for all shared resources that may be needed
// by the drivers served by the Local Server. // by the drivers served by the Local Server.
// //
// NOTES: // NOTES:
// //
@@ -20,6 +20,7 @@ using System.Globalization;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security.AccessControl; using System.Security.AccessControl;
using System.Windows.Forms; using System.Windows.Forms;
using ASCOM.DeviceInterface;
using ASCOM.Meade.net.Wrapper; using ASCOM.Meade.net.Wrapper;
using ASCOM.Utilities; using ASCOM.Utilities;
using ASCOM.Utilities.Interfaces; using ASCOM.Utilities.Interfaces;
@@ -49,7 +50,7 @@ namespace ASCOM.Meade.net
#region single serial port connector #region single serial port connector
// //
// this region shows a way that a single serial port could be connected to by multiple // this region shows a way that a single serial port could be connected to by multiple
// drivers. // drivers.
// //
// Connected is used to handle the connections to the port. // Connected is used to handle the connections to the port.
@@ -73,7 +74,7 @@ namespace ASCOM.Meade.net
public static IProfileFactory ProfileFactory public static IProfileFactory ProfileFactory
{ {
get => _profileFactory ?? ( _profileFactory = new ProfileFactory()); get => _profileFactory ?? (_profileFactory = new ProfileFactory());
set => _profileFactory = value; set => _profileFactory = value;
} }
@@ -122,7 +123,7 @@ namespace ASCOM.Meade.net
public static bool SendBool(string command, bool raw = false) public static bool SendBool(string command, bool raw = false)
{ {
var result = SendChar(command, raw); var result = SendChar(command, raw);
return result == "1"; return result == "1";
@@ -273,7 +274,7 @@ namespace ASCOM.Meade.net
profileProperties.Speed = Convert.ToInt32(driverProfile.GetValue(DriverId, SpeedName, string.Empty, SpeedDefault)); profileProperties.Speed = Convert.ToInt32(driverProfile.GetValue(DriverId, SpeedName, string.Empty, SpeedDefault));
profileProperties.Parity = driverProfile.GetValue(DriverId, ParityName, string.Empty, ParityDefault); profileProperties.Parity = driverProfile.GetValue(DriverId, ParityName, string.Empty, ParityDefault);
profileProperties.SendDateTime = Convert.ToBoolean(driverProfile.GetValue(DriverId, SendDateTimeName, string.Empty, SendDateTimeDefault)); profileProperties.SendDateTime = Convert.ToBoolean(driverProfile.GetValue(DriverId, SendDateTimeName, string.Empty, SendDateTimeDefault));
profileProperties.ParkedBehaviour = EnumExtensionMethods.GetValueFromDescription<ParkedBehaviour>(driverProfile.GetValue(DriverId, ParkedBehaviourName, string.Empty, ParkedBehaviourDefault)); profileProperties.ParkedBehaviour = EnumExtensionMethods.GetValueFromDescription<ParkedBehaviour>(driverProfile.GetValue(DriverId, ParkedBehaviourName, string.Empty, ParkedBehaviourDefault));
profileProperties.ParkedAlt = double.Parse(driverProfile.GetValue(DriverId, ParkedAltName, string.Empty, ParkedAltDefault), NumberFormatInfo.InvariantInfo); profileProperties.ParkedAlt = double.Parse(driverProfile.GetValue(DriverId, ParkedAltName, string.Empty, ParkedAltDefault), NumberFormatInfo.InvariantInfo);
profileProperties.ParkedAz = double.Parse(driverProfile.GetValue(DriverId, ParkedAzimuthName, string.Empty, ParkedAzimuthDefault), NumberFormatInfo.InvariantInfo); profileProperties.ParkedAz = double.Parse(driverProfile.GetValue(DriverId, ParkedAzimuthName, string.Empty, ParkedAzimuthDefault), NumberFormatInfo.InvariantInfo);
@@ -311,7 +312,7 @@ namespace ASCOM.Meade.net
} }
#endregion #endregion
#region Multi Driver handling #region Multi Driver handling
public static string ProductName { get; private set; } = string.Empty; public static string ProductName { get; private set; } = string.Empty;
@@ -334,7 +335,7 @@ namespace ASCOM.Meade.net
private static readonly Dictionary<string, DeviceHardware> ConnectedDevices = new Dictionary<string, DeviceHardware>(); private static readonly Dictionary<string, DeviceHardware> ConnectedDevices = new Dictionary<string, DeviceHardware>();
private static readonly Dictionary<string, DeviceHardware> ConnectedDeviceIds = new Dictionary<string, DeviceHardware>(); private static readonly Dictionary<string, DeviceHardware> ConnectedDeviceIds = new Dictionary<string, DeviceHardware>();
private static IProfileFactory _profileFactory ; private static IProfileFactory _profileFactory;
/// <summary> /// <summary>
@@ -350,7 +351,7 @@ namespace ASCOM.Meade.net
{ {
if (!ConnectedDevices.ContainsKey(deviceId)) if (!ConnectedDevices.ContainsKey(deviceId))
ConnectedDevices.Add(deviceId, new DeviceHardware()); ConnectedDevices.Add(deviceId, new DeviceHardware());
if (!ConnectedDeviceIds.ContainsKey(driverId)) if (!ConnectedDeviceIds.ContainsKey(driverId))
ConnectedDeviceIds.Add(driverId, new DeviceHardware()); ConnectedDeviceIds.Add(driverId, new DeviceHardware());
@@ -363,7 +364,7 @@ namespace ASCOM.Meade.net
SharedSerial.DTREnable = profileProperties.RtsDtrEnabled; SharedSerial.DTREnable = profileProperties.RtsDtrEnabled;
SharedSerial.RTSEnable = profileProperties.RtsDtrEnabled; SharedSerial.RTSEnable = profileProperties.RtsDtrEnabled;
SharedSerial.DataBits = profileProperties.DataBits; SharedSerial.DataBits = profileProperties.DataBits;
SharedSerial.StopBits = (SerialStopBits)Enum.Parse(typeof(SerialStopBits), profileProperties.StopBits ); SharedSerial.StopBits = (SerialStopBits)Enum.Parse(typeof(SerialStopBits), profileProperties.StopBits);
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);
@@ -493,7 +494,7 @@ namespace ASCOM.Meade.net
Count = 0; Count = 0;
} }
} }
public static void SetParked(bool atPark, ParkedPosition parkedPosition) public static void SetParked(bool atPark, ParkedPosition parkedPosition)
{ {
IsParked = atPark; IsParked = atPark;
@@ -503,5 +504,15 @@ namespace ASCOM.Meade.net
public static bool IsParked { get; private set; } public static bool IsParked { get; private set; }
public static ParkedPosition ParkedPosition { get; private set; } public static ParkedPosition ParkedPosition { get; private set; }
/// <summary>
/// Start with <see cref="PierSide.pierUnknown"/>.
/// As we do not know the physical declination axis position, we have to keep track manually.
/// </summary>
public static PierSide SideOfPier { get; set; } = PierSide.pierUnknown;
public static double? TargetRightAscension { get; set; }
public static double? TargetDeclination { get; set; }
} }
} }
+24 -1
View File
@@ -1,4 +1,5 @@
using System; using System;
using ASCOM.DeviceInterface;
using ASCOM.Utilities.Interfaces; using ASCOM.Utilities.Interfaces;
namespace ASCOM.Meade.net.Wrapper namespace ASCOM.Meade.net.Wrapper
@@ -31,6 +32,10 @@ namespace ASCOM.Meade.net.Wrapper
void SetParked(bool atPark, ParkedPosition parkedPosition); void SetParked(bool atPark, ParkedPosition parkedPosition);
bool IsParked { get; } bool IsParked { get; }
ParkedPosition ParkedPosition { get; } ParkedPosition ParkedPosition { get; }
PierSide SideOfPier { get; set; }
double? TargetRightAscension { get; set; }
double? TargetDeclination { get; set; }
} }
public class SharedResourcesWrapper : ISharedResourcesWrapper public class SharedResourcesWrapper : ISharedResourcesWrapper
@@ -74,7 +79,7 @@ namespace ASCOM.Meade.net.Wrapper
return SharedResources.SendBool(command, raw); return SharedResources.SendBool(command, raw);
} }
public string SendChar(string message,bool raw = false) public string SendChar(string message, bool raw = false)
{ {
return SharedResources.SendChar(message, raw); return SharedResources.SendChar(message, raw);
} }
@@ -112,5 +117,23 @@ namespace ASCOM.Meade.net.Wrapper
public bool IsParked => SharedResources.IsParked; public bool IsParked => SharedResources.IsParked;
public ParkedPosition ParkedPosition => SharedResources.ParkedPosition; public ParkedPosition ParkedPosition => SharedResources.ParkedPosition;
public PierSide SideOfPier
{
get => SharedResources.SideOfPier;
set => SharedResources.SideOfPier = value;
}
public double? TargetRightAscension
{
get => SharedResources.TargetRightAscension;
set => SharedResources.TargetRightAscension = value;
}
public double? TargetDeclination
{
get => SharedResources.TargetDeclination;
set => SharedResources.TargetDeclination = value;
}
} }
} }