From f788320927d1b040f62a073fe117e913682e17ea Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Tue, 3 May 2022 21:57:25 +0100 Subject: [PATCH] Refactor to use ProfileProperties instead of assigning individual variables. Added support for ApertureArea and ApertureDiameter --- .../TelescopeUnitTests.cs | 27 +- Meade.net.Telescope/Telescope.cs | 88 ++--- .../SharedResourcesUnitTests.cs | 50 ++- Meade.net.focuser/Focuser.cs | 10 +- Meade.net/MeadeTelescopeBase.cs | 70 ++-- Meade.net/ProfileProperties.cs | 2 + Meade.net/SetupDialogForm.cs | 22 +- Meade.net/SetupDialogForm.designer.cs | 48 +++ Meade.net/SetupDialogForm.resx | 319 +++++++++++++----- Meade.net/SharedResources.cs | 8 + 10 files changed, 445 insertions(+), 199 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 9cc12d8..72761b7 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -636,12 +636,9 @@ namespace Meade.net.Telescope.UnitTests public void IsNewPulseGuidingSupported_ThenIsSupported_ThenReturnsTrue(string guidingStyle, string productName, string firmware, bool isSupported) { - _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName); - _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware); - _profileProperties.GuidingStyle = guidingStyle; - _telescope.Connected = true; + ConnectTelescope(productName, firmware); var result = _telescope.IsNewPulseGuidingSupported(); @@ -853,29 +850,19 @@ namespace Meade.net.Telescope.UnitTests } [Test] - public void ApertureArea_Get_ThrowsNotImplementedException() + public void ApertureArea_Get_ReturnsExpectedResult() { - var excpetion = Assert.Throws(() => - { - var result = _telescope.ApertureArea; - Assert.Fail($"{result} should not have returned"); - }); + var result = _telescope.ApertureArea; - Assert.That(excpetion.Property, Is.EqualTo("ApertureArea")); - Assert.That(excpetion.AccessorSet, Is.False); + Assert.That(result, Is.EqualTo(_profileProperties.ApertureArea / 1000)); } [Test] public void ApertureDiameter_Get_ThrowsNotImplementedException() { - var excpetion = Assert.Throws(() => - { - var result = _telescope.ApertureDiameter; - Assert.Fail($"{result} should not have returned"); - }); + var result = _telescope.ApertureDiameter; - Assert.That(excpetion.Property, Is.EqualTo("ApertureDiameter")); - Assert.That(excpetion.AccessorSet, Is.False); + Assert.That(result, Is.EqualTo(_profileProperties.ApertureDiameter / 1000)); } [Test] @@ -1434,7 +1421,7 @@ namespace Meade.net.Telescope.UnitTests { var result = _telescope.FocalLength; - Assert.That(result, Is.EqualTo(_profileProperties.FocalLength)); + Assert.That(result, Is.EqualTo(_profileProperties.FocalLength/1000)); } [Test] diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 26e0428..af929af 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -419,12 +419,12 @@ namespace ASCOM.Meade.net { ReadProfile(); - LogMessage("Connected Set", "Connecting to port {0}", _ComPort); + LogMessage("Connected Set", "Connecting to port {0}", _profileProperties.ComPort); var connectionInfo = SharedResourcesWrapper.Connect("Serial", DriverId, Tl); try { LogMessage("Connected Set", - $"Connected to port {_ComPort}. Product: {SharedResourcesWrapper.ProductName} Version:{SharedResourcesWrapper.FirmwareVersion}"); + $"Connected to port {_profileProperties.ComPort}. Product: {SharedResourcesWrapper.ProductName} Version:{SharedResourcesWrapper.FirmwareVersion}"); _userNewerPulseGuiding = IsNewPulseGuidingSupported(); @@ -444,7 +444,7 @@ namespace ASCOM.Meade.net if (CanSetGuideRates) { - SetNewGuideRate(_GuideRate, "Connect"); + SetNewGuideRate(_profileProperties.GuideRateArcSecondsPerSecond, "Connect"); } SetTelescopePrecision("Connect"); @@ -454,28 +454,28 @@ namespace ASCOM.Meade.net SharedResourcesWrapper.TargetDeclination = InvalidParameter; SharedResourcesWrapper.TargetRightAscension = InvalidParameter; - LogMessage("Connected Set", $"SendDateTime: {_SendDateTime}"); - if (_SendDateTime) + LogMessage("Connected Set", $"SendDateTime: {_profileProperties.SendDateTime}"); + if (_profileProperties.SendDateTime) { if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) { LogMessage("Connected Set", - $"LX200GPS Detecting if daylight savings message on screen: {_SendDateTime}"); + $"LX200GPS Detecting if daylight savings message on screen: {_profileProperties.SendDateTime}"); var displayText = Action("Handbox", "readdisplay"); LogMessage("Connected Set", $"Current Handset display: {displayText}"); if (displayText.Contains("Daylight")) { LogMessage("Connected Set", - $"LX200GPS Setting Date time and bypassing settings screens: {_SendDateTime}"); + $"LX200GPS Setting Date time and bypassing settings screens: {_profileProperties.SendDateTime}"); BypassHandboxEntryForAutostarII(); } else { LogMessage("Connected Set", - $"LX200GPS Sending current date and time: {_SendDateTime}"); + $"LX200GPS Sending current date and time: {_profileProperties.SendDateTime}"); SendCurrentDateTime("Connect"); LogMessage("Connected Set", - $"LX200GPS Attempting manual bypass of prompts: {_SendDateTime}"); + $"LX200GPS Attempting manual bypass of prompts: {_profileProperties.SendDateTime}"); ApplySkipAutoStarPrompts("Connect"); } @@ -514,12 +514,12 @@ namespace ASCOM.Meade.net } catch (Exception ex) { - LogMessage("Connected Set", "Error connecting to port {0} - {1}", _ComPort, ex.Message); + LogMessage("Connected Set", "Error connecting to port {0} - {1}", _profileProperties.ComPort, ex.Message); } } else { - LogMessage("Connected Set", "Disconnecting from port {0}", _ComPort); + LogMessage("Connected Set", "Disconnecting from port {0}", _profileProperties.ComPort); SharedResourcesWrapper.Disconnect("Serial", DriverId); IsConnected = false; } @@ -528,7 +528,7 @@ namespace ASCOM.Meade.net private void SendCurrentDateTime(string connect) { - if (_SendDateTime) + if (_profileProperties.SendDateTime) { UTCDate = _clock.UtcNow; } @@ -570,7 +570,7 @@ namespace ASCOM.Meade.net private void SetTelescopePrecision(string propertyName) { - switch (_Precision.ToLower()) + switch (_profileProperties.Precision.ToLower()) { case "high": TelescopePointingPrecision(true); @@ -588,7 +588,7 @@ namespace ASCOM.Meade.net public bool IsNewPulseGuidingSupported() { - switch (_GuidingStyle) + switch (_profileProperties.GuidingStyle.ToLower()) { case "guide rate slew": return false; @@ -1161,8 +1161,9 @@ namespace ASCOM.Meade.net { get { - LogMessage("ApertureArea Get", "Not implemented"); - throw new PropertyNotImplementedException("ApertureArea", false); + var apertureArea = _profileProperties.ApertureArea / 1000; + LogMessage("ApertureArea Get", $"{apertureArea}"); + return apertureArea; } } @@ -1170,8 +1171,9 @@ namespace ASCOM.Meade.net { get { - LogMessage("ApertureDiameter Get", "Not implemented"); - throw new PropertyNotImplementedException("ApertureDiameter", false); + var apertureDiameter = _profileProperties.ApertureDiameter / 1000; + LogMessage("ApertureDiameter Get", $"{apertureDiameter}"); + return apertureDiameter; } } @@ -1500,8 +1502,9 @@ namespace ASCOM.Meade.net { get { - LogMessage("FocalLength Get", "Not implemented"); - return _focalLength; + var focalLength = _profileProperties.FocalLength / 1000; + LogMessage("FocalLength Get", $"{focalLength}"); + return focalLength; } } @@ -1528,7 +1531,7 @@ namespace ASCOM.Meade.net //info from RickB says that 15.04107 is a better value for - _GuideRate = value; + _profileProperties.GuideRateArcSecondsPerSecond = value; WriteProfile(); } @@ -1547,8 +1550,8 @@ namespace ASCOM.Meade.net { get { - var degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_GuideRate); - LogMessage("GuideRateDeclination Get", $"{_GuideRate} arc seconds / second = {degreesPerSecond} degrees per second"); + var degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_profileProperties.GuideRateArcSecondsPerSecond); + LogMessage("GuideRateDeclination Get", $"{_profileProperties.GuideRateArcSecondsPerSecond} arc seconds / second = {degreesPerSecond} degrees per second"); return degreesPerSecond; } set @@ -1562,8 +1565,8 @@ namespace ASCOM.Meade.net { get { - double degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_GuideRate); - LogMessage("GuideRateRightAscension Get", $"{_GuideRate} arc seconds / second = {degreesPerSecond} degrees per second"); + double degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_profileProperties.GuideRateArcSecondsPerSecond); + LogMessage("GuideRateRightAscension Get", $"{_profileProperties.GuideRateArcSecondsPerSecond} arc seconds / second = {degreesPerSecond} degrees per second"); return degreesPerSecond; } set @@ -1698,7 +1701,7 @@ namespace ASCOM.Meade.net return; ParkedPosition parkedPosition; - switch (_ParkedBehaviour) + switch (_profileProperties.ParkedBehaviour) { case ParkedBehaviour.LastGoodPosition: parkedPosition = new ParkedPosition @@ -1715,12 +1718,17 @@ namespace ASCOM.Meade.net var utcDateTime = UTCDate; var latitude = SiteLatitude; var longitude = SiteLongitude; - var raDec = _astroMaths.ConvertHozToEq(utcDateTime, latitude, longitude, _ParkedAltAz); + var parkedAltAz = new HorizonCoordinates() + { + Altitude = _profileProperties.ParkedAlt, + Azimuth = _profileProperties.ParkedAz + }; + var raDec = _astroMaths.ConvertHozToEq(utcDateTime, latitude, longitude, parkedAltAz); parkedPosition = new ParkedPosition { - Altitude = _ParkedAltAz.Altitude, - Azimuth = _ParkedAltAz.Azimuth, + Altitude = parkedAltAz.Altitude, + Azimuth = parkedAltAz.Azimuth, RightAscension = raDec.RightAscension, Declination = raDec.Declination, SiteLatitude = latitude, @@ -1981,8 +1989,8 @@ namespace ASCOM.Meade.net { CheckConnected("SiteElevation Get"); - LogMessage("SiteElevation", $"Get {_SiteElevation}"); - return _SiteElevation; + LogMessage("SiteElevation", $"Get {_profileProperties.SiteElevation}"); + return _profileProperties.SiteElevation; } // ReSharper disable once ValueParameterNotUsed set @@ -1990,14 +1998,14 @@ namespace ASCOM.Meade.net CheckConnected("SiteElevation Set"); LogMessage("SiteElevation", $"Set: {value}"); - if (Math.Abs(value - _SiteElevation) < 0.1) + if (Math.Abs(value - _profileProperties.SiteElevation) < 0.1) { LogMessage("SiteElevation", "Set: no change detected"); return; } - LogMessage("SiteElevation", $"Set: {value} was {_SiteElevation}"); - _SiteElevation = value; + LogMessage("SiteElevation", $"Set: {value} was {_profileProperties.SiteElevation}"); + _profileProperties.SiteElevation = value; UpdateSiteElevation(); } } @@ -2025,7 +2033,7 @@ namespace ASCOM.Meade.net throw new InvalidOperationException("unable to get site latitude from telescope."); } - catch (ParkedException) when (_ParkedBehaviour != ParkedBehaviour.NoCoordinates && SharedResourcesWrapper.ParkedPosition is var parkedPosition) + catch (ParkedException) when (_profileProperties.ParkedBehaviour != ParkedBehaviour.NoCoordinates && SharedResourcesWrapper.ParkedPosition is var parkedPosition) { return parkedPosition.SiteLatitude; } @@ -2083,7 +2091,7 @@ namespace ASCOM.Meade.net return siteLongitude; } - catch (ParkedException) when (_ParkedBehaviour != ParkedBehaviour.NoCoordinates && SharedResourcesWrapper.ParkedPosition is var parkedPosition) + catch (ParkedException) when (_profileProperties.ParkedBehaviour != ParkedBehaviour.NoCoordinates && SharedResourcesWrapper.ParkedPosition is var parkedPosition) { return parkedPosition.SiteLongitude; } @@ -2354,7 +2362,7 @@ namespace ASCOM.Meade.net private TimeSpan GetTotalSlewingSettleTime() { - return TimeSpan.FromSeconds( SlewSettleTime + _ProfileSettleTime ); + return TimeSpan.FromSeconds( SlewSettleTime + _profileProperties.SettleTime ); } private bool GetSlewing() @@ -2779,7 +2787,7 @@ namespace ASCOM.Meade.net } catch (ParkedException) { - if (_ParkedBehaviour == ParkedBehaviour.NoCoordinates) + if (_profileProperties.ParkedBehaviour == ParkedBehaviour.NoCoordinates) throw; return _clock.UtcNow; @@ -2962,10 +2970,10 @@ namespace ASCOM.Meade.net var profileProperties = SharedResourcesWrapper.ReadProfile(); - if (Math.Abs(profileProperties.GuideRateArcSecondsPerSecond - _GuideRate) > 0.0000001) + if (Math.Abs(profileProperties.GuideRateArcSecondsPerSecond - _profileProperties.GuideRateArcSecondsPerSecond) > 0.0000001) { changed = true; - profileProperties.GuideRateArcSecondsPerSecond = _GuideRate; + profileProperties.GuideRateArcSecondsPerSecond = _profileProperties.GuideRateArcSecondsPerSecond; } if (changed) diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs index 518c59c..30582f1 100644 --- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs +++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs @@ -172,6 +172,8 @@ namespace Meade.net.UnitTests string ParkedAltDefault = "0"; string ParkedAzimuthDefault = "180"; string FocalLengthDefault = "2000"; + string ApertureAreaDefault = "32685"; + string ApertureDiameterDefault = "203"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -227,6 +229,15 @@ namespace Meade.net.UnitTests x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault)) .Returns(() => FocalLengthDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Aperture Area (mm²)", string.Empty, ApertureAreaDefault)) + .Returns(() => ApertureAreaDefault); + + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Aperture Diameter (mm)", string.Empty, ApertureDiameterDefault)) + .Returns(() => ApertureDiameterDefault); + + profileWrapperMock.Setup(x => x.GetValue(DriverId, "Send Date and time on connect", string.Empty, "false")) .Returns(() => SendDateTimeDefault); @@ -300,7 +311,9 @@ namespace Meade.net.UnitTests string ParkedBehaviourDefault = "No Coordinates"; string ParkedAltDefault = "0"; string ParkedAzimuthDefault = "180"; - string FocalLengthDefault = "2000"; + string FocalLengthDefault = "2000"; + string ApertureAreaDefault = "32685"; + string ApertureDiameterDefault = "203"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -347,6 +360,15 @@ namespace Meade.net.UnitTests x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault)) .Returns(() => FocalLengthDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Aperture Area (mm²)", string.Empty, ApertureAreaDefault)) + .Returns(() => ApertureAreaDefault); + + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Aperture Diameter (mm)", string.Empty, ApertureDiameterDefault)) + .Returns(() => ApertureDiameterDefault); + + Mock profileFactoryMock = new Mock(); profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); @@ -356,7 +378,7 @@ namespace Meade.net.UnitTests _serialMock.Setup(x => x.Transmit("#:GVP#")).Callback(() => { serialPortReturn = ":GVP#"; }); _serialMock.Setup(x => x.Transmit("#:GG#")).Callback(() => { serialPortReturn = "0"; }); - _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns( () => serialPortReturn); + _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn); var result = Assert.Throws(() => { SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object); }); Assert.That(result.Message, Is.EqualTo("Serial port is looping back data, something is wrong with the hardware.")); @@ -385,6 +407,8 @@ namespace Meade.net.UnitTests string ParkedAltDefault = "0"; string ParkedAzimuthDefault = "180"; string FocalLengthDefault = "2000"; + string ApertureAreaDefault = "32685"; + string ApertureDiameterDefault = "203"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -429,6 +453,12 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault)) .Returns(() => FocalLengthDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Aperture Area (mm²)", string.Empty, ApertureAreaDefault)) + .Returns(() => ApertureAreaDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Aperture Diameter (mm)", string.Empty, ApertureDiameterDefault)) + .Returns(() => ApertureDiameterDefault); Mock profileFactoryMock = new Mock(); profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); @@ -482,6 +512,8 @@ namespace Meade.net.UnitTests string ParkedAltDefault = "0"; string ParkedAzimuthDefault = "180"; string FocalLengthDefault = "2000"; + string ApertureAreaDefault = "32685"; + string ApertureDiameterDefault = "203"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -526,6 +558,12 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault)) .Returns(() => FocalLengthDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Aperture Area (mm²)", string.Empty, ApertureAreaDefault)) + .Returns(() => ApertureAreaDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Aperture Diameter (mm)", string.Empty, ApertureDiameterDefault)) + .Returns(() => ApertureDiameterDefault); Mock profileFactoryMock = new Mock(); profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); @@ -576,6 +614,8 @@ namespace Meade.net.UnitTests string ParkedAltDefault = "0"; string ParkedAzimuthDefault = "180"; string FocalLengthDefault = "2000"; + string ApertureAreaDefault = "32685"; + string ApertureDiameterDefault = "203"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -619,6 +659,12 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault)) .Returns(() => FocalLengthDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Aperture Area (mm²)", string.Empty, ApertureAreaDefault)) + .Returns(() => ApertureAreaDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Aperture Diameter (mm)", string.Empty, ApertureDiameterDefault)) + .Returns(() => ApertureDiameterDefault); Mock profileFactoryMock = new Mock(); profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index 0ef3771..75ae1cc 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -176,12 +176,12 @@ namespace ASCOM.Meade.net } catch (Exception ex) { - LogMessage("Connected Set", "Error connecting to port {0} - {1}", _ComPort, ex.Message); + LogMessage("Connected Set", "Error connecting to port {0} - {1}", _profileProperties.ComPort, ex.Message); } } else { - LogMessage("Connected Set", "Disconnecting from port {0}", _ComPort); + LogMessage("Connected Set", "Disconnecting from port {0}", _profileProperties.ComPort); SharedResourcesWrapper.Disconnect("Serial", DriverId); IsConnected = false; } @@ -295,11 +295,11 @@ namespace ASCOM.Meade.net return; var direction = position > 0; - if (_ReverseFocusDirection) + if (_profileProperties.ReverseFocusDirection) direction = !direction; //backlash compensation. - var backlashCompensationSteps = direction ? Math.Abs(_BacklashCompensation) : 0; + var backlashCompensationSteps = direction ? Math.Abs(_profileProperties.BacklashCompensation) : 0; var steps = Math.Abs(position) + backlashCompensationSteps; @@ -322,7 +322,7 @@ namespace ASCOM.Meade.net private void DynamicBreaking(bool directionOut) { - if (!_UseDynamicBreaking) + if (!_profileProperties.DynamicBreaking) return; Tl.LogMessage("Move", "Applying dynamic breaking"); diff --git a/Meade.net/MeadeTelescopeBase.cs b/Meade.net/MeadeTelescopeBase.cs index a9bfca7..b7b2963 100644 --- a/Meade.net/MeadeTelescopeBase.cs +++ b/Meade.net/MeadeTelescopeBase.cs @@ -1,7 +1,6 @@ using System; using System.Reflection; using System.Runtime.InteropServices; -using ASCOM.Meade.net.AstroMaths; using ASCOM.Meade.net.Wrapper; using ASCOM.Utilities; @@ -20,21 +19,8 @@ namespace ASCOM.Meade.net /// protected static readonly string DriverDescription = "Meade Generic"; - protected static string _ComPort; // Variables to hold the currrent device configuration - protected static int _BacklashCompensation; - protected static bool _ReverseFocusDirection; - protected static bool _UseDynamicBreaking; - protected double _GuideRate; - protected string _Precision; - protected string _GuidingStyle; - protected double _SiteElevation; - protected short _ProfileSettleTime; - protected bool _SendDateTime; - protected ParkedBehaviour _ParkedBehaviour; - protected HorizonCoordinates _ParkedAltAz; - protected double _focalLength; - protected readonly ISharedResourcesWrapper SharedResourcesWrapper; + protected ProfileProperties _profileProperties; public MeadeTelescopeBase() { @@ -63,43 +49,25 @@ namespace ASCOM.Meade.net /// protected void ReadProfile() { - var profileProperties = SharedResourcesWrapper.ReadProfile(); - Tl.Enabled = profileProperties.TraceLogger; - _ComPort = profileProperties.ComPort; - _BacklashCompensation = profileProperties.BacklashCompensation; - _ReverseFocusDirection = profileProperties.ReverseFocusDirection; - _UseDynamicBreaking = profileProperties.DynamicBreaking; - _GuideRate = profileProperties.GuideRateArcSecondsPerSecond; - _Precision = profileProperties.Precision; - _GuidingStyle = profileProperties.GuidingStyle.ToLower(); - _SiteElevation = profileProperties.SiteElevation; - _ProfileSettleTime = profileProperties.SettleTime; - _SendDateTime = profileProperties.SendDateTime; - _ParkedBehaviour = profileProperties.ParkedBehaviour; - - _ParkedAltAz = new HorizonCoordinates - { - Altitude = profileProperties.ParkedAlt, - Azimuth = profileProperties.ParkedAz - }; - - _focalLength = profileProperties.FocalLength; + _profileProperties = SharedResourcesWrapper.ReadProfile(); + Tl.Enabled = _profileProperties.TraceLogger; LogMessage("ReadProfile", $"Trace logger enabled: {Tl.Enabled}"); - LogMessage("ReadProfile", $"Com Port: {_ComPort}"); - LogMessage("ReadProfile", $"Backlash Steps: {_BacklashCompensation}"); - LogMessage("ReadProfile", $"Dynamic breaking: {_UseDynamicBreaking}"); - LogMessage("ReadProfile", $"Guide Rate: {_GuideRate}"); - LogMessage("ReadProfile", $"Precision: {_Precision}"); - LogMessage("ReadProfile", $"Guiding Style: {_GuidingStyle}"); - LogMessage("ReadProfile", $"Site Elevation: {_SiteElevation}"); - 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: {_ParkedAltAz.Altitude}"); - LogMessage("ReadProfile", $"Parked Az: {_ParkedAltAz.Azimuth}"); - LogMessage("ReadProfile", $"Focal Length: {_focalLength}"); - + LogMessage("ReadProfile", $"Com Port: {_profileProperties.ComPort}"); + LogMessage("ReadProfile", $"Backlash Steps: {_profileProperties.BacklashCompensation}"); + LogMessage("ReadProfile", $"Dynamic breaking: {_profileProperties.DynamicBreaking}"); + LogMessage("ReadProfile", $"Guide Rate: {_profileProperties.GuideRateArcSecondsPerSecond}"); + LogMessage("ReadProfile", $"Precision: {_profileProperties.Precision}"); + LogMessage("ReadProfile", $"Guiding Style: {_profileProperties.GuidingStyle}"); + LogMessage("ReadProfile", $"Site Elevation: {_profileProperties.SiteElevation}"); + LogMessage("ReadProfile", $"Settle Time after slew: {_profileProperties.SettleTime}"); + LogMessage("ReadProfile", $"Send date and time on connect: {_profileProperties.SendDateTime}"); + LogMessage("ReadProfile", $"Parked Behaviour: {_profileProperties.ParkedBehaviour}"); + LogMessage("ReadProfile", $"Parked Alt: {_profileProperties.ParkedAlt}"); + LogMessage("ReadProfile", $"Parked Az: {_profileProperties.ParkedAz}"); + LogMessage("ReadProfile", $"Focal Length: {_profileProperties.FocalLength}"); + LogMessage("ReadProfile", $"Aperture Area: {_profileProperties.ApertureArea}"); + LogMessage("ReadProfile", $"Aperture Area: {_profileProperties.ApertureDiameter}"); } /// @@ -164,7 +132,7 @@ namespace ASCOM.Meade.net protected void UpdateSiteElevation() { var profileProperties = SharedResourcesWrapper.ReadProfile(); - profileProperties.SiteElevation = _SiteElevation; + profileProperties.SiteElevation = _profileProperties.SiteElevation; SharedResourcesWrapper.WriteProfile(profileProperties); } } diff --git a/Meade.net/ProfileProperties.cs b/Meade.net/ProfileProperties.cs index 0e75d6b..6a3833d 100644 --- a/Meade.net/ProfileProperties.cs +++ b/Meade.net/ProfileProperties.cs @@ -24,5 +24,7 @@ namespace ASCOM.Meade.net public double ParkedAlt { get; set; } public double ParkedAz { get; set; } public double FocalLength { get; set; } + public double ApertureArea { get; set; } + public double ApertureDiameter { get; set; } } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index fd661a4..2529e32 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -197,6 +197,24 @@ namespace ASCOM.Meade.net txtFocalLength.Text = "2000"; } + try + { + txtApertureArea.Text = profileProperties.ApertureArea.ToString(CultureInfo.CurrentCulture); + } + catch (Exception) + { + txtApertureArea.Text = "32685"; + } + + try + { + txtApertureDiameter.Text = profileProperties.ApertureDiameter.ToString(CultureInfo.CurrentCulture); + } + catch (Exception) + { + txtApertureDiameter.Text = "203"; + } + UpdateParkedItemsEnabled(); } @@ -224,7 +242,9 @@ namespace ASCOM.Meade.net ParkedBehaviour = EnumExtensionMethods.GetValueFromDescription(cboParkedBehaviour.SelectedItem.ToString()), ParkedAlt = double.Parse(txtParkedAlt.Text), ParkedAz = double.Parse(txtParkedAz.Text), - FocalLength = double.Parse(txtFocalLength.Text) + FocalLength = double.Parse(txtFocalLength.Text), + ApertureArea = double.Parse(txtApertureArea.Text), + ApertureDiameter = double.Parse(txtApertureDiameter.Text) }; return profileProperties; diff --git a/Meade.net/SetupDialogForm.designer.cs b/Meade.net/SetupDialogForm.designer.cs index f710e6a..7d0266b 100644 --- a/Meade.net/SetupDialogForm.designer.cs +++ b/Meade.net/SetupDialogForm.designer.cs @@ -85,6 +85,12 @@ namespace ASCOM.Meade.net this.label25 = new System.Windows.Forms.Label(); this.txtFocalLength = new System.Windows.Forms.TextBox(); this.label26 = new System.Windows.Forms.Label(); + this.label27 = new System.Windows.Forms.Label(); + this.txtApertureDiameter = new System.Windows.Forms.TextBox(); + this.label28 = new System.Windows.Forms.Label(); + this.label29 = new System.Windows.Forms.Label(); + this.txtApertureArea = new System.Windows.Forms.TextBox(); + this.label30 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudSettleTime)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numDatabits)).BeginInit(); @@ -408,10 +414,46 @@ namespace ASCOM.Meade.net resources.ApplyResources(this.label26, "label26"); this.label26.Name = "label26"; // + // label27 + // + resources.ApplyResources(this.label27, "label27"); + this.label27.Name = "label27"; + // + // txtApetureDiameter + // + resources.ApplyResources(this.txtApertureDiameter, "txtApertureDiameter"); + this.txtApertureDiameter.Name = "txtApertureDiameter"; + // + // label28 + // + resources.ApplyResources(this.label28, "label28"); + this.label28.Name = "label28"; + // + // label29 + // + resources.ApplyResources(this.label29, "label29"); + this.label29.Name = "label29"; + // + // txtApetureArea + // + resources.ApplyResources(this.txtApertureArea, "txtApertureArea"); + this.txtApertureArea.Name = "txtApertureArea"; + // + // label30 + // + resources.ApplyResources(this.label30, "label30"); + this.label30.Name = "label30"; + // // SetupDialogForm // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label29); + this.Controls.Add(this.txtApertureArea); + this.Controls.Add(this.label30); + this.Controls.Add(this.label27); + this.Controls.Add(this.txtApertureDiameter); + this.Controls.Add(this.label28); this.Controls.Add(this.label26); this.Controls.Add(this.txtFocalLength); this.Controls.Add(this.label25); @@ -532,5 +574,11 @@ namespace ASCOM.Meade.net private Label label25; private TextBox txtFocalLength; private Label label26; + private Label label27; + private TextBox txtApertureDiameter; + private Label label28; + private Label label29; + private TextBox txtApertureArea; + private Label label30; } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.resx b/Meade.net/SetupDialogForm.resx index 706338b..56169b2 100644 --- a/Meade.net/SetupDialogForm.resx +++ b/Meade.net/SetupDialogForm.resx @@ -145,7 +145,7 @@ $this - 50 + 56 Bottom, Right @@ -172,7 +172,7 @@ $this - 49 + 55 12, 9 @@ -196,7 +196,7 @@ $this - 48 + 54 Top, Right @@ -223,7 +223,7 @@ $this - 47 + 53 True @@ -250,13 +250,13 @@ $this - 46 + 52 True - 97, 305 + 97, 380 90, 17 @@ -277,7 +277,7 @@ $this - 45 + 51 97, 87 @@ -298,13 +298,13 @@ $this - 44 + 50 True - 290, 187 + 290, 262 61, 13 @@ -325,13 +325,10 @@ $this - 43 + 49 - - 17, 17 - - 375, 184 + 388, 259 46, 20 @@ -342,6 +339,9 @@ 10.0 + + 17, 17 + LX-200GPS only @@ -355,13 +355,13 @@ $this - 42 + 48 True - 427, 187 + 440, 262 122, 13 @@ -382,13 +382,13 @@ $this - 41 + 47 True - 427, 200 + 440, 275 105, 13 @@ -409,13 +409,13 @@ $this - 40 + 46 True - 290, 219 + 290, 294 50, 13 @@ -436,7 +436,7 @@ $this - 39 + 45 Unchanged @@ -448,7 +448,7 @@ High - 375, 216 + 388, 291 90, 21 @@ -466,7 +466,7 @@ $this - 38 + 44 True @@ -475,7 +475,7 @@ NoControl - 290, 246 + 290, 321 67, 13 @@ -496,7 +496,7 @@ $this - 37 + 43 Auto @@ -508,7 +508,7 @@ Pulse guiding - 375, 243 + 388, 318 90, 21 @@ -526,7 +526,7 @@ $this - 36 + 42 True @@ -556,7 +556,7 @@ $this - 35 + 41 True @@ -568,7 +568,7 @@ NoControl - 290, 284 + 290, 359 52, 13 @@ -589,10 +589,10 @@ $this - 34 + 40 - 375, 302 + 388, 377 46, 20 @@ -613,7 +613,7 @@ $this - 32 + 38 True @@ -622,7 +622,7 @@ NoControl - 290, 305 + 290, 380 79, 13 @@ -643,7 +643,7 @@ $this - 33 + 39 True @@ -652,7 +652,7 @@ NoControl - 427, 305 + 440, 380 20, 13 @@ -673,7 +673,7 @@ $this - 31 + 37 True @@ -706,13 +706,13 @@ $this - 30 + 36 True - 375, 328 + 388, 403 109, 17 @@ -733,13 +733,13 @@ $this - 29 + 35 True - 375, 351 + 388, 426 112, 17 @@ -760,7 +760,7 @@ $this - 28 + 34 True @@ -793,11 +793,8 @@ $this - 27 + 33 - - 17, 17 - True @@ -829,13 +826,13 @@ $this - 9 + 15 True - 290, 114 + 290, 189 72, 13 @@ -856,10 +853,10 @@ $this - 26 + 32 - 375, 111 + 388, 186 100, 20 @@ -877,13 +874,13 @@ $this - 25 + 31 True - 481, 114 + 494, 189 38, 13 @@ -904,13 +901,13 @@ $this - 24 + 30 True - 290, 145 + 290, 220 56, 13 @@ -931,10 +928,10 @@ $this - 23 + 29 - 375, 143 + 388, 218 120, 20 @@ -952,13 +949,13 @@ $this - 22 + 28 True - 501, 145 + 514, 220 47, 13 @@ -979,7 +976,7 @@ $this - 21 + 27 True @@ -1006,7 +1003,7 @@ $this - 20 + 26 97, 163 @@ -1027,7 +1024,7 @@ $this - 19 + 25 97, 137 @@ -1048,7 +1045,7 @@ $this - 18 + 24 97, 190 @@ -1069,7 +1066,7 @@ $this - 17 + 23 97, 217 @@ -1090,7 +1087,7 @@ $this - 16 + 22 97, 244 @@ -1111,7 +1108,7 @@ $this - 15 + 21 True @@ -1138,7 +1135,7 @@ $this - 14 + 20 True @@ -1165,7 +1162,7 @@ $this - 13 + 19 True @@ -1192,7 +1189,7 @@ $this - 12 + 18 True @@ -1219,7 +1216,7 @@ $this - 11 + 17 True @@ -1231,7 +1228,7 @@ NoControl - 15, 284 + 15, 359 73, 13 @@ -1252,7 +1249,7 @@ $this - 10 + 16 No Coordinates @@ -1282,7 +1279,7 @@ $this - 8 + 14 True @@ -1309,7 +1306,7 @@ $this - 7 + 13 True @@ -1336,7 +1333,7 @@ $this - 6 + 12 True @@ -1363,7 +1360,7 @@ $this - 5 + 11 697, 151 @@ -1384,7 +1381,7 @@ $this - 4 + 10 697, 177 @@ -1405,7 +1402,7 @@ $this - 3 + 9 True @@ -1435,10 +1432,10 @@ $this - 2 + 8 - 375, 87 + 388, 87 100, 20 @@ -1456,7 +1453,7 @@ $this - 1 + 7 True @@ -1465,7 +1462,7 @@ NoControl - 481, 90 + 494, 90 23, 13 @@ -1486,8 +1483,170 @@ $this + 6 + + + True + + + NoControl + + + 494, 114 + + + 23, 13 + + + 53 + + + mm + + + label27 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + 388, 111 + + + 100, 20 + + + 52 + + + txtApertureDiameter + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 4 + + + True + + + NoControl + + + 290, 114 + + + 92, 13 + + + 51 + + + Aperture Diameter + + + label28 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 5 + + + True + + + NoControl + + + 494, 139 + + + 23, 13 + + + 56 + + + mm + + + label29 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 + + 388, 136 + + + 100, 20 + + + 55 + + + txtApertureArea + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + NoControl + + + 290, 139 + + + 72, 13 + + + 54 + + + Aperture Area + + + label30 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + True diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index f813870..4ad7cf6 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -199,6 +199,8 @@ namespace ASCOM.Meade.net private const string ParkedAltName = "Parked Altitude"; private const string ParkedAzimuthName = "Parked Azimuth"; private const string FocalLengthName = "Focal Length (mm)"; + private const string ApertureAreaName = "Aperture Area (mm²)"; + private const string ApertureDiameterName = "Aperture Diameter (mm)"; public static void WriteProfile(ProfileProperties profileProperties) { @@ -228,6 +230,8 @@ namespace ASCOM.Meade.net driverProfile.WriteValue(DriverId, ParkedAltName, profileProperties.ParkedAlt.ToString(CultureInfo.InvariantCulture)); driverProfile.WriteValue(DriverId, ParkedAzimuthName, profileProperties.ParkedAz.ToString(CultureInfo.InvariantCulture)); driverProfile.WriteValue(DriverId, FocalLengthName, profileProperties.FocalLength.ToString(CultureInfo.InvariantCulture)); + driverProfile.WriteValue(DriverId, ApertureAreaName, profileProperties.ApertureArea.ToString(CultureInfo.InvariantCulture)); + driverProfile.WriteValue(DriverId, ApertureDiameterName, profileProperties.ApertureDiameter.ToString(CultureInfo.InvariantCulture)); } } } @@ -253,6 +257,8 @@ namespace ASCOM.Meade.net private const string ParkedAltDefault = "0"; private const string ParkedAzimuthDefault = "180"; private const string FocalLengthDefault = "2000"; + private const string ApertureAreaDefault = "32685"; + private const string ApertureDiameterDefault = "203"; public static ProfileProperties ReadProfile() { @@ -284,6 +290,8 @@ namespace ASCOM.Meade.net 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.FocalLength = double.Parse(driverProfile.GetValue(DriverId, FocalLengthName, string.Empty, FocalLengthDefault), NumberFormatInfo.InvariantInfo); + profileProperties.ApertureArea = double.Parse(driverProfile.GetValue(DriverId, ApertureAreaName, string.Empty, ApertureAreaDefault), NumberFormatInfo.InvariantInfo); + profileProperties.ApertureDiameter = double.Parse(driverProfile.GetValue(DriverId, ApertureDiameterName, string.Empty, ApertureDiameterDefault), NumberFormatInfo.InvariantInfo); } return profileProperties;