From fdd008fcfbc52fd8c8fe4599d86baf4cc5b76778 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Sat, 24 Apr 2021 19:16:36 +0100 Subject: [PATCH] Adding support for sending co-ordinates when scope is parked. --- Meade.net.Telescope/Telescope.cs | 11 +- .../SharedResourcesUnitTests.cs | 71 ++++- Meade.net/EnumExtensionMethods.cs | 39 +++ Meade.net/Meade.net.csproj | 2 + Meade.net/MeadeTelescopeBase.cs | 11 +- Meade.net/ParkedBehaviour.cs | 14 + Meade.net/ProfileProperties.cs | 3 + Meade.net/SetupDialogForm.cs | 73 ++++- Meade.net/SetupDialogForm.designer.cs | 57 ++++ Meade.net/SetupDialogForm.resx | 254 ++++++++++++++---- Meade.net/SharedResources.cs | 13 + 11 files changed, 492 insertions(+), 56 deletions(-) create mode 100644 Meade.net/EnumExtensionMethods.cs create mode 100644 Meade.net/ParkedBehaviour.cs diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 08e8dfd..0210715 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -423,7 +423,16 @@ namespace ASCOM.Meade.net { if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) { - BypassHandboxEntryForAutostarII(); + var displayText = Action("Handbox", "readdisplay"); + if (displayText.Contains("Daylight")) + { + BypassHandboxEntryForAutostarII(); + } + else + { + SendCurrentDateTime("Connect"); + } + } else { diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs index d6888e6..634c33e 100644 --- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs +++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs @@ -166,6 +166,10 @@ namespace Meade.net.UnitTests string SendDateTimeDefault = "true"; string SkipPromptsDefault = "true"; + string ParkedBehaviourDefault = "No Coordinates"; + string ParkedAltDefault = "0"; + string ParkedAzimuthDefault = "180"; + Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -206,6 +210,16 @@ namespace Meade.net.UnitTests x.GetValue(DriverId, "Rts / Dtr", string.Empty, "false")) .Returns(() => RtsDtrEnabledDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault)) + .Returns(() => ParityDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault)) + .Returns(() => ParkedAltDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault)) + .Returns(() => ParkedAzimuthDefault); + profileWrapperMock.Setup(x => x.GetValue(DriverId, "Send Date and time on connect", string.Empty, "false")) .Returns(() => SendDateTimeDefault); @@ -276,6 +290,10 @@ namespace Meade.net.UnitTests string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate string PrecisionDefault = "Unchanged"; + string ParkedBehaviourDefault = "No Coordinates"; + string ParkedAltDefault = "0"; + string ParkedAzimuthDefault = "180"; + Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -308,6 +326,16 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault)) .Returns(PrecisionDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault)) + .Returns(() => ParityDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault)) + .Returns(() => ParkedAltDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault)) + .Returns(() => ParkedAzimuthDefault); + Mock profileFactoryMock = new Mock(); profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); @@ -341,7 +369,11 @@ namespace Meade.net.UnitTests string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate string PrecisionDefault = "Unchanged"; - + + string ParkedBehaviourDefault = "No Coordinates"; + string ParkedAltDefault = "0"; + string ParkedAzimuthDefault = "180"; + Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -373,6 +405,16 @@ namespace Meade.net.UnitTests x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault)) .Returns(() => RtsDtrEnabledDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault)) + .Returns(() => ParityDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault)) + .Returns(() => ParkedAltDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault)) + .Returns(() => ParkedAzimuthDefault); + Mock profileFactoryMock = new Mock(); profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); @@ -421,6 +463,10 @@ namespace Meade.net.UnitTests string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate string PrecisionDefault = "Unchanged"; + string ParkedBehaviourDefault = "No Coordinates"; + string ParkedAltDefault = "0"; + string ParkedAzimuthDefault = "180"; + Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -452,6 +498,16 @@ namespace Meade.net.UnitTests x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault)) .Returns(() => RtsDtrEnabledDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault)) + .Returns(() => ParityDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault)) + .Returns(() => ParkedAltDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault)) + .Returns(() => ParkedAzimuthDefault); + Mock profileFactoryMock = new Mock(); profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); @@ -497,6 +553,10 @@ namespace Meade.net.UnitTests string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate string PrecisionDefault = "Unchanged"; + string ParkedBehaviourDefault = "No Coordinates"; + string ParkedAltDefault = "0"; + string ParkedAzimuthDefault = "180"; + Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -527,6 +587,15 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault)) .Returns(() => RtsDtrEnabledDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault)) + .Returns(() => ParityDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault)) + .Returns(() => ParkedAltDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault)) + .Returns(() => ParkedAzimuthDefault); Mock profileFactoryMock = new Mock(); profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); diff --git a/Meade.net/EnumExtensionMethods.cs b/Meade.net/EnumExtensionMethods.cs new file mode 100644 index 0000000..82b834a --- /dev/null +++ b/Meade.net/EnumExtensionMethods.cs @@ -0,0 +1,39 @@ +using System; +using System.Linq; +using System.Reflection; + +namespace ASCOM.Meade.net +{ + public static class EnumExtensionMethods + { + public static string GetDescription(this Enum GenericEnum) + { + Type genericEnumType = GenericEnum.GetType(); + MemberInfo[] memberInfo = genericEnumType.GetMember(GenericEnum.ToString()); + if ((memberInfo != null && memberInfo.Length > 0)) + { + var _Attribs = memberInfo[0] + .GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false); + if ((_Attribs != null && _Attribs.Count() > 0)) + { + return ((System.ComponentModel.DescriptionAttribute) _Attribs.ElementAt(0)).Description; + } + } + + return GenericEnum.ToString(); + } + + public static T GetValueFromDescription( string description) where T : Enum + { + foreach (T value in Enum.GetValues(typeof(T))) + { + if (value.GetDescription() == description) + { + return value; + } + } + + return default; + } + } +} \ No newline at end of file diff --git a/Meade.net/Meade.net.csproj b/Meade.net/Meade.net.csproj index eb6b45c..366e8e0 100644 --- a/Meade.net/Meade.net.csproj +++ b/Meade.net/Meade.net.csproj @@ -129,6 +129,7 @@ + Form @@ -138,6 +139,7 @@ + diff --git a/Meade.net/MeadeTelescopeBase.cs b/Meade.net/MeadeTelescopeBase.cs index a923a2a..a84f993 100644 --- a/Meade.net/MeadeTelescopeBase.cs +++ b/Meade.net/MeadeTelescopeBase.cs @@ -29,7 +29,10 @@ namespace ASCOM.Meade.net protected double SiteElevation; protected short ProfileSettleTime; protected bool SendDateTime; - + protected ParkedBehaviour ParkedBehaviour; + protected double ParkedAzimuth; + protected double ParkedAlt; + protected readonly ISharedResourcesWrapper SharedResourcesWrapper; public MeadeTelescopeBase() @@ -71,6 +74,9 @@ namespace ASCOM.Meade.net SiteElevation = profileProperties.SiteElevation; ProfileSettleTime = profileProperties.SettleTime; SendDateTime = profileProperties.SendDateTime; + ParkedBehaviour = profileProperties.ParkedBehaviour; + ParkedAlt = profileProperties.ParkedAlt; + ParkedAzimuth = profileProperties.ParkedAz; LogMessage("ReadProfile", $"Trace logger enabled: {Tl.Enabled}"); LogMessage("ReadProfile", $"Com Port: {ComPort}"); @@ -82,6 +88,9 @@ namespace ASCOM.Meade.net 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: {ParkedAlt}"); + LogMessage("ReadProfile", $"Parked Az: {ParkedAzimuth}"); } /// diff --git a/Meade.net/ParkedBehaviour.cs b/Meade.net/ParkedBehaviour.cs new file mode 100644 index 0000000..e67945f --- /dev/null +++ b/Meade.net/ParkedBehaviour.cs @@ -0,0 +1,14 @@ +using System.ComponentModel; + +namespace ASCOM.Meade.net +{ + public enum ParkedBehaviour + { + [Description("No Coordinates")] + NoCoordinates, + [Description("Last Good Position")] + LastGoodPosition, + [Description("Report coordinates as")] + ReportCoordinates + } +} \ No newline at end of file diff --git a/Meade.net/ProfileProperties.cs b/Meade.net/ProfileProperties.cs index e95c707..8cd29c5 100644 --- a/Meade.net/ProfileProperties.cs +++ b/Meade.net/ProfileProperties.cs @@ -20,5 +20,8 @@ namespace ASCOM.Meade.net public int Speed { get; set; } public string Handshake { get; set; } public bool SendDateTime { get; set; } + public ParkedBehaviour ParkedBehaviour { get; set; } + public double ParkedAlt { get; set; } + public double ParkedAz { get; set; } } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index af0db74..3b7b039 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -27,15 +27,17 @@ namespace ASCOM.Meade.net SetItemsFromEnum(cboParity.Items, typeof(SerialParity)); SetItemsFromEnumValues(cboSpeed.Items, typeof(SerialSpeed)); SetItemsFromEnum(cboHandShake.Items, typeof(SerialHandshake)); + SetItemsFromEnum(cboParkedBehaviour.Items, typeof(ParkedBehaviour)); } private void SetItemsFromEnum(IList items, Type enumItems) { items.Clear(); - foreach (var item in Enum.GetNames(enumItems)) + foreach (var value in Enum.GetValues(enumItems) ) { - items.Add(item); + var val = value as Enum; + items.Add(val.GetDescription()); } } @@ -158,6 +160,35 @@ namespace ASCOM.Meade.net nudSettleTime.Value = profileProperties.SettleTime; cbxSendDateTime.Checked = profileProperties.SendDateTime; + + try + { + cboParkedBehaviour.SelectedItem = profileProperties.ParkedBehaviour.GetDescription(); + } + catch (Exception) + { + cboParkedBehaviour.SelectedItem = ParkedBehaviour.NoCoordinates.GetDescription(); + } + + try + { + txtParkedAlt.Text = profileProperties.ParkedAlt.ToString(CultureInfo.CurrentCulture); + } + catch (Exception) + { + txtParkedAlt.Text = "0"; + } + + try + { + txtParkedAz.Text = profileProperties.ParkedAz.ToString(CultureInfo.CurrentCulture); + } + catch (Exception) + { + txtParkedAz.Text = "180"; + } + + UpdateParkedItemsEnabled(); } public ProfileProperties GetProfile() @@ -180,7 +211,10 @@ namespace ASCOM.Meade.net DynamicBreaking = cbxDynamicBreaking.Checked, SiteElevation = double.Parse(txtElevation.Text), SettleTime = Convert.ToInt16(nudSettleTime.Value), - SendDateTime = cbxSendDateTime.Checked + SendDateTime = cbxSendDateTime.Checked, + ParkedBehaviour = EnumExtensionMethods.GetValueFromDescription(cboParkedBehaviour.SelectedItem.ToString()), + ParkedAlt = double.Parse(txtParkedAlt.Text), + ParkedAz = double.Parse(txtParkedAz.Text) }; return profileProperties; @@ -257,5 +291,36 @@ namespace ASCOM.Meade.net txtBacklashSteps.Text = txtElevation.Text.Remove(txtBacklashSteps.Text.Length - 1); } } + + private void cboParkedBehaviour_SelectionChangeCommitted(object sender, EventArgs e) + { + UpdateParkedItemsEnabled(); + } + + private void UpdateParkedItemsEnabled() + { + txtParkedAlt.Enabled = cboParkedBehaviour.SelectedItem?.ToString() == "Report coordinates as"; + txtParkedAz.Enabled = txtParkedAlt.Enabled; + } + + private void txtParkedAlt_TextChanged(object sender, EventArgs e) + { + if (System.Text.RegularExpressions.Regex.IsMatch(txtParkedAlt.Text, "[^0-9]")) + { + MessageBox.Show(Resources.SetupDialogForm_txtElevation_TextChanged_1_Please_enter_only_numbers_); + txtParkedAlt.Text = txtParkedAlt.Text.Remove(txtParkedAlt.Text.Length - 1); + } + } + + private void txtParkedAz_TextChanged(object sender, EventArgs e) + { + if (System.Text.RegularExpressions.Regex.IsMatch(txtParkedAz.Text, "[^0-9]")) + { + MessageBox.Show(Resources.SetupDialogForm_txtElevation_TextChanged_1_Please_enter_only_numbers_); + txtParkedAz.Text = txtParkedAz.Text.Remove(txtParkedAz.Text.Length - 1); + } + } } -} \ No newline at end of file +} + + diff --git a/Meade.net/SetupDialogForm.designer.cs b/Meade.net/SetupDialogForm.designer.cs index 3e9a255..b401604 100644 --- a/Meade.net/SetupDialogForm.designer.cs +++ b/Meade.net/SetupDialogForm.designer.cs @@ -76,6 +76,12 @@ namespace ASCOM.Meade.net this.label19 = new System.Windows.Forms.Label(); this.label20 = new System.Windows.Forms.Label(); this.label21 = new System.Windows.Forms.Label(); + this.cboParkedBehaviour = new System.Windows.Forms.ComboBox(); + this.label22 = new System.Windows.Forms.Label(); + this.label23 = new System.Windows.Forms.Label(); + this.label24 = new System.Windows.Forms.Label(); + this.txtParkedAlt = new System.Windows.Forms.TextBox(); + this.txtParkedAz = new System.Windows.Forms.TextBox(); ((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudSettleTime)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numDatabits)).BeginInit(); @@ -344,10 +350,55 @@ namespace ASCOM.Meade.net resources.ApplyResources(this.label21, "label21"); this.label21.Name = "label21"; // + // cboParkedBehaviour + // + this.cboParkedBehaviour.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cboParkedBehaviour.FormattingEnabled = true; + this.cboParkedBehaviour.Items.AddRange(new object[] { + resources.GetString("cboParkedBehaviour.Items"), + resources.GetString("cboParkedBehaviour.Items1"), + resources.GetString("cboParkedBehaviour.Items2")}); + resources.ApplyResources(this.cboParkedBehaviour, "cboParkedBehaviour"); + this.cboParkedBehaviour.Name = "cboParkedBehaviour"; + this.cboParkedBehaviour.SelectionChangeCommitted += new System.EventHandler(this.cboParkedBehaviour_SelectionChangeCommitted); + // + // label22 + // + resources.ApplyResources(this.label22, "label22"); + this.label22.Name = "label22"; + // + // label23 + // + resources.ApplyResources(this.label23, "label23"); + this.label23.Name = "label23"; + // + // label24 + // + resources.ApplyResources(this.label24, "label24"); + this.label24.Name = "label24"; + // + // txtParkedAlt + // + resources.ApplyResources(this.txtParkedAlt, "txtParkedAlt"); + this.txtParkedAlt.Name = "txtParkedAlt"; + this.txtParkedAlt.TextChanged += new System.EventHandler(this.txtParkedAlt_TextChanged); + // + // txtParkedAz + // + resources.ApplyResources(this.txtParkedAz, "txtParkedAz"); + this.txtParkedAz.Name = "txtParkedAz"; + this.txtParkedAz.TextChanged += new System.EventHandler(this.txtParkedAz_TextChanged); + // // SetupDialogForm // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.txtParkedAz); + this.Controls.Add(this.txtParkedAlt); + this.Controls.Add(this.label24); + this.Controls.Add(this.label23); + this.Controls.Add(this.label22); + this.Controls.Add(this.cboParkedBehaviour); this.Controls.Add(this.cbxSendDateTime); this.Controls.Add(this.label21); this.Controls.Add(this.label20); @@ -450,5 +501,11 @@ namespace ASCOM.Meade.net private Label label20; private Label label21; private CheckBox cbxSendDateTime; + private ComboBox cboParkedBehaviour; + private Label label22; + private Label label23; + private Label label24; + private TextBox txtParkedAlt; + private TextBox txtParkedAz; } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.resx b/Meade.net/SetupDialogForm.resx index 726e548..2e52c51 100644 --- a/Meade.net/SetupDialogForm.resx +++ b/Meade.net/SetupDialogForm.resx @@ -123,7 +123,7 @@ - 715, 391 + 765, 391 59, 24 @@ -145,13 +145,13 @@ $this - 41 + 47 Bottom, Right - 715, 421 + 765, 421 59, 25 @@ -172,7 +172,7 @@ $this - 40 + 46 12, 9 @@ -196,13 +196,13 @@ $this - 39 + 45 Top, Right - 726, 9 + 776, 9 48, 56 @@ -223,7 +223,7 @@ $this - 38 + 44 True @@ -250,7 +250,7 @@ $this - 37 + 43 True @@ -277,7 +277,7 @@ $this - 36 + 42 97, 87 @@ -298,7 +298,7 @@ $this - 35 + 41 True @@ -325,8 +325,11 @@ $this - 34 + 40 + + 17, 17 + 375, 166 @@ -339,9 +342,6 @@ 10.0 - - 17, 17 - LX-200GPS only @@ -355,7 +355,7 @@ $this - 33 + 39 True @@ -382,7 +382,7 @@ $this - 32 + 38 True @@ -409,7 +409,7 @@ $this - 31 + 37 True @@ -436,7 +436,7 @@ $this - 30 + 36 Unchanged @@ -466,7 +466,7 @@ $this - 29 + 35 True @@ -496,7 +496,7 @@ $this - 28 + 34 Auto @@ -526,7 +526,7 @@ $this - 27 + 33 True @@ -556,7 +556,7 @@ $this - 26 + 32 True @@ -589,7 +589,7 @@ $this - 25 + 31 375, 302 @@ -613,7 +613,7 @@ $this - 23 + 29 True @@ -643,7 +643,7 @@ $this - 24 + 30 True @@ -673,7 +673,7 @@ $this - 22 + 28 True @@ -706,7 +706,7 @@ $this - 21 + 27 True @@ -733,7 +733,7 @@ $this - 20 + 26 True @@ -760,7 +760,7 @@ $this - 19 + 25 True @@ -793,8 +793,11 @@ $this - 18 + 24 + + 17, 17 + True @@ -802,7 +805,7 @@ NoControl - 627, 95 + 671, 96 145, 17 @@ -826,7 +829,7 @@ $this - 0 + 6 True @@ -853,7 +856,7 @@ $this - 17 + 23 375, 93 @@ -874,7 +877,7 @@ $this - 16 + 22 True @@ -901,7 +904,7 @@ $this - 15 + 21 True @@ -928,7 +931,7 @@ $this - 14 + 20 375, 125 @@ -949,7 +952,7 @@ $this - 13 + 19 True @@ -976,7 +979,7 @@ $this - 12 + 18 True @@ -1003,7 +1006,7 @@ $this - 11 + 17 97, 163 @@ -1024,7 +1027,7 @@ $this - 10 + 16 97, 137 @@ -1045,7 +1048,7 @@ $this - 9 + 15 97, 190 @@ -1066,7 +1069,7 @@ $this - 8 + 14 97, 217 @@ -1087,7 +1090,7 @@ $this - 7 + 13 97, 244 @@ -1108,7 +1111,7 @@ $this - 6 + 12 True @@ -1135,7 +1138,7 @@ $this - 5 + 11 True @@ -1162,7 +1165,7 @@ $this - 4 + 10 True @@ -1189,7 +1192,7 @@ $this - 3 + 9 True @@ -1216,7 +1219,7 @@ $this - 2 + 8 True @@ -1249,8 +1252,161 @@ $this + 7 + + + No Coordinates + + + Last Good Position + + + Report coordinates as + + + 671, 124 + + + 126, 21 + + + 42 + + + cboParkedBehaviour + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 5 + + + True + + + 574, 127 + + + 91, 13 + + + 43 + + + Parked behaviour + + + label22 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 4 + + + True + + + 668, 154 + + + 19, 13 + + + 44 + + + Alt + + + label23 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + True + + + 668, 180 + + + 19, 13 + + + 45 + + + Az + + + label24 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + 697, 151 + + + 100, 20 + + + 46 + + + txtParkedAlt + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 1 + + 697, 177 + + + 100, 20 + + + 47 + + + txtParkedAz + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + True @@ -1261,7 +1417,7 @@ 6, 13 - 784, 454 + 834, 454 CenterScreen diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index ebcc48c..70afea1 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -159,6 +159,9 @@ namespace ASCOM.Meade.net private const string HandShakeName = "Hand Shake"; private const string ParityName = "Parity"; private const string SendDateTimeName = "Send Date and time on connect"; + private const string ParkedBehaviourName = "Parked Behaviour"; + private const string ParkedAltName = "Parked Altitude"; + private const string ParkedAzimuthName = "Parked Azimuth"; public static void WriteProfile(ProfileProperties profileProperties) { @@ -184,6 +187,9 @@ namespace ASCOM.Meade.net driverProfile.WriteValue(DriverId, SiteElevationName, profileProperties.SiteElevation.ToString(CultureInfo.InvariantCulture)); driverProfile.WriteValue(DriverId, SettleTimeName, profileProperties.SettleTime.ToString()); driverProfile.WriteValue(DriverId, SendDateTimeName, profileProperties.SendDateTime.ToString()); + driverProfile.WriteValue(DriverId, ParkedBehaviourName, profileProperties.ParkedBehaviour.GetDescription()); + driverProfile.WriteValue(DriverId, ParkedAltName, profileProperties.ParkedAlt.ToString(CultureInfo.InvariantCulture)); + driverProfile.WriteValue(DriverId, ParkedAzimuthName, profileProperties.ParkedAz.ToString(CultureInfo.InvariantCulture)); } } } @@ -205,6 +211,9 @@ namespace ASCOM.Meade.net private const string HandShakeDefault = "None"; private const string ParityDefault = "None"; private const string SendDateTimeDefault = "false"; + private static string ParkedBehaviourDefault = "No Coordinates"; + private const string ParkedAltDefault = "0"; + private const string ParkedAzimuthDefault = "180"; public static ProfileProperties ReadProfile() { @@ -231,6 +240,10 @@ namespace ASCOM.Meade.net profileProperties.Speed = Convert.ToInt32(driverProfile.GetValue(DriverId, SpeedName, string.Empty, SpeedDefault)); profileProperties.Parity = driverProfile.GetValue(DriverId, ParityName, string.Empty, ParityDefault); profileProperties.SendDateTime = Convert.ToBoolean(driverProfile.GetValue(DriverId, SendDateTimeName, string.Empty, SendDateTimeDefault)); + + profileProperties.ParkedBehaviour = EnumExtensionMethods.GetValueFromDescription(driverProfile.GetValue(DriverId, ParkedBehaviourName, string.Empty, ParkedBehaviourDefault)); + 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); } return profileProperties;