From e4af93dd0753590640e82106c3f52a8fa3beea75 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Wed, 21 Apr 2021 20:17:00 +0100 Subject: [PATCH] Added ability to skip the prompts initial connect, and added ability to send the date and time on initial connect --- Meade.net.Telescope/Telescope.cs | 27 +++ .../SharedResourcesUnitTests.cs | 24 ++- Meade.net/MeadeTelescopeBase.cs | 6 + Meade.net/ProfileProperties.cs | 2 + Meade.net/SetupDialogForm.cs | 9 +- Meade.net/SetupDialogForm.designer.cs | 21 +++ Meade.net/SetupDialogForm.resx | 163 +++++++++++++----- Meade.net/SharedResources.cs | 9 +- 8 files changed, 207 insertions(+), 54 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index ada8098..aa23f75 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -418,6 +418,9 @@ namespace ASCOM.Meade.net } SetTelescopePrecision("Connect"); + + ApplySkipAutoStarPrompts("Connect"); + SendCurrentDateTime("Connect"); } else { @@ -447,6 +450,30 @@ namespace ASCOM.Meade.net } } + private void SendCurrentDateTime(string connect) + { + if (SendDateTime) + { + UTCDate = DateTime.UtcNow; + } + } + + private void ApplySkipAutoStarPrompts(string connect) + { + if (SkipAutoStarPrompts) + { + var displayText = Action("Handbox", "readdisplay"); + if (displayText.Contains("Daylight")) + { + for(var i = 0; i < 3; i++) + { + Action("Handbox", "enter"); + _utilities.WaitForMilliseconds(2000); + } + } + } + } + private void SetTelescopePrecision(string propertyName) { switch (Precision.ToLower()) diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs index 976f3c6..414d327 100644 --- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs +++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs @@ -153,14 +153,17 @@ namespace Meade.net.UnitTests string StopBitsDefault = "One"; string HandshakeDefault = "None"; string ParityDefault = "None"; - string RtsDtrEnabledDefault = "false"; + string RtsDtrEnabledDefault = "true"; string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate string PrecisionDefault = "Unchanged"; string GuidingStyleDefault = "Auto"; string BacklashCompensationDefault = "3000"; - string ReverseFocuserDiectionDefault = "true"; + string ReverseFocuserDiectionDefault = "true"; + + string SendDateTimeDefault = "true"; + string SkipPromptsDefault = "true"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -181,7 +184,7 @@ namespace Meade.net.UnitTests x.GetValue(DriverId, "Backlash Compensation", string.Empty, BacklashCompensationDefault)) .Returns(BacklashCompensationDefault); profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Reverse Focuser Direction", string.Empty, ReverseFocuserDiectionDefault)) + x.GetValue(DriverId, "Reverse Focuser Direction", string.Empty, "true")) .Returns(() => ReverseFocuserDiectionDefault); profileWrapperMock.Setup(x => x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault)) @@ -199,9 +202,19 @@ namespace Meade.net.UnitTests x.GetValue(DriverId, "Parity", string.Empty, ParityDefault)) .Returns(() => ParityDefault); profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault)) + x.GetValue(DriverId, "Rts / Dtr", string.Empty, "false")) .Returns(() => RtsDtrEnabledDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Send Date and time on connect", string.Empty, "false")) + .Returns(() => SendDateTimeDefault); + + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Skip date prompts on connect", string.Empty, "false")) + .Returns(() => SkipPromptsDefault); + + + IProfileWrapper profeWrapper = profileWrapperMock.Object; Mock profileFactoryMock = new Mock(); @@ -231,6 +244,9 @@ namespace Meade.net.UnitTests Assert.That(profileProperties.Handshake, Is.EqualTo(HandshakeDefault)); Assert.That(profileProperties.Parity, Is.EqualTo(ParityDefault)); Assert.That(profileProperties.RtsDtrEnabled, Is.EqualTo(bool.Parse(RtsDtrEnabledDefault))); + + Assert.That(profileProperties.SendDateTime, Is.EqualTo(bool.Parse(SendDateTimeDefault))); + Assert.That(profileProperties.SkipPrompts, Is.EqualTo(bool.Parse(SkipPromptsDefault))); } [TestCase("TCP")] diff --git a/Meade.net/MeadeTelescopeBase.cs b/Meade.net/MeadeTelescopeBase.cs index 51e0892..3e79993 100644 --- a/Meade.net/MeadeTelescopeBase.cs +++ b/Meade.net/MeadeTelescopeBase.cs @@ -28,6 +28,8 @@ namespace ASCOM.Meade.net protected string GuidingStyle; protected double SiteElevation; protected short ProfileSettleTime; + protected bool SkipAutoStarPrompts; + protected bool SendDateTime; protected readonly ISharedResourcesWrapper SharedResourcesWrapper; @@ -69,6 +71,8 @@ namespace ASCOM.Meade.net GuidingStyle = profileProperties.GuidingStyle.ToLower(); SiteElevation = profileProperties.SiteElevation; ProfileSettleTime = profileProperties.SettleTime; + SkipAutoStarPrompts = profileProperties.SkipPrompts; + SendDateTime = profileProperties.SendDateTime; LogMessage("ReadProfile", $"Trace logger enabled: {Tl.Enabled}"); LogMessage("ReadProfile", $"Com Port: {ComPort}"); @@ -79,6 +83,8 @@ namespace ASCOM.Meade.net LogMessage("ReadProfile", $"Guiding Style: {GuidingStyle}"); LogMessage("ReadProfile", $"Site Elevation: {SiteElevation}"); LogMessage("ReadProfile", $"Settle Time after slew: {ProfileSettleTime}"); + LogMessage("ReadProfile", $"Skip Autostar startup prompts: {SkipAutoStarPrompts}"); + LogMessage("ReadProfile", $"Send date and time on connect: {SendDateTime}"); } /// diff --git a/Meade.net/ProfileProperties.cs b/Meade.net/ProfileProperties.cs index 391c31d..9c03728 100644 --- a/Meade.net/ProfileProperties.cs +++ b/Meade.net/ProfileProperties.cs @@ -19,5 +19,7 @@ namespace ASCOM.Meade.net public string Parity { get; set; } public int Speed { get; set; } public string Handshake { get; set; } + public bool SendDateTime { get; set; } + public bool SkipPrompts { get; set; } } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index 82fac95..40c753b 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -156,6 +156,9 @@ namespace ASCOM.Meade.net cbxReverseDirection.Checked = profileProperties.ReverseFocusDirection; cbxDynamicBreaking.Checked = profileProperties.DynamicBreaking; nudSettleTime.Value = profileProperties.SettleTime; + + cbxSendDateTime.Checked = profileProperties.SendDateTime; + cbxSkipPrompts.Checked = profileProperties.SkipPrompts; } public ProfileProperties GetProfile() @@ -177,8 +180,10 @@ namespace ASCOM.Meade.net ReverseFocusDirection = cbxReverseDirection.Checked, DynamicBreaking = cbxDynamicBreaking.Checked, SiteElevation = double.Parse(txtElevation.Text), - SettleTime = Convert.ToInt16(nudSettleTime.Value) - }; + SettleTime = Convert.ToInt16(nudSettleTime.Value), + SendDateTime = cbxSendDateTime.Checked, + SkipPrompts = cbxSkipPrompts.Checked + }; return profileProperties; } diff --git a/Meade.net/SetupDialogForm.designer.cs b/Meade.net/SetupDialogForm.designer.cs index 701c5be..2f9e0b7 100644 --- a/Meade.net/SetupDialogForm.designer.cs +++ b/Meade.net/SetupDialogForm.designer.cs @@ -75,6 +75,8 @@ 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.cbxSkipPrompts = new System.Windows.Forms.CheckBox(); + this.cbxSendDateTime = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudSettleTime)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numDatabits)).BeginInit(); @@ -137,6 +139,7 @@ namespace ASCOM.Meade.net // resources.ApplyResources(this.txtGuideRate, "txtGuideRate"); this.txtGuideRate.Name = "txtGuideRate"; + this.toolTip1.SetToolTip(this.txtGuideRate, resources.GetString("txtGuideRate.ToolTip")); this.txtGuideRate.TextChanged += new System.EventHandler(this.TextBox1_TextChanged); // // label4 @@ -335,10 +338,26 @@ namespace ASCOM.Meade.net resources.ApplyResources(this.label21, "label21"); this.label21.Name = "label21"; // + // cbxSkipPrompts + // + resources.ApplyResources(this.cbxSkipPrompts, "cbxSkipPrompts"); + this.cbxSkipPrompts.Name = "cbxSkipPrompts"; + this.toolTip1.SetToolTip(this.cbxSkipPrompts, resources.GetString("cbxSkipPrompts.ToolTip")); + this.cbxSkipPrompts.UseVisualStyleBackColor = true; + // + // cbxSendDateTime + // + resources.ApplyResources(this.cbxSendDateTime, "cbxSendDateTime"); + this.cbxSendDateTime.Name = "cbxSendDateTime"; + this.toolTip1.SetToolTip(this.cbxSendDateTime, resources.GetString("cbxSendDateTime.ToolTip")); + this.cbxSendDateTime.UseVisualStyleBackColor = true; + // // SetupDialogForm // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.cbxSendDateTime); + this.Controls.Add(this.cbxSkipPrompts); this.Controls.Add(this.label21); this.Controls.Add(this.label20); this.Controls.Add(this.label19); @@ -439,5 +458,7 @@ namespace ASCOM.Meade.net private Label label19; private Label label20; private Label label21; + private CheckBox cbxSkipPrompts; + private CheckBox cbxSendDateTime; } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.resx b/Meade.net/SetupDialogForm.resx index ca8813c..6103062 100644 --- a/Meade.net/SetupDialogForm.resx +++ b/Meade.net/SetupDialogForm.resx @@ -123,7 +123,7 @@ - 557, 391 + 715, 391 59, 24 @@ -145,13 +145,13 @@ $this - 40 + 42 Bottom, Right - 557, 421 + 715, 421 59, 25 @@ -172,7 +172,7 @@ $this - 39 + 41 12, 9 @@ -196,13 +196,13 @@ $this - 38 + 40 Top, Right - 568, 9 + 726, 9 48, 56 @@ -223,7 +223,7 @@ $this - 37 + 39 True @@ -250,7 +250,7 @@ $this - 36 + 38 True @@ -277,7 +277,7 @@ $this - 35 + 37 97, 87 @@ -298,7 +298,7 @@ $this - 34 + 36 True @@ -325,7 +325,7 @@ $this - 33 + 35 375, 166 @@ -339,6 +339,12 @@ 10.0 + + 17, 17 + + + LX-200GPS only + txtGuideRate @@ -349,7 +355,7 @@ $this - 32 + 34 True @@ -376,7 +382,7 @@ $this - 31 + 33 True @@ -403,7 +409,7 @@ $this - 30 + 32 True @@ -430,7 +436,7 @@ $this - 29 + 31 Unchanged @@ -460,7 +466,7 @@ $this - 28 + 30 True @@ -490,7 +496,7 @@ $this - 27 + 29 Auto @@ -520,7 +526,7 @@ $this - 26 + 28 True @@ -550,7 +556,7 @@ $this - 25 + 27 True @@ -583,7 +589,7 @@ $this - 24 + 26 375, 302 @@ -607,7 +613,7 @@ $this - 22 + 24 True @@ -637,7 +643,7 @@ $this - 23 + 25 True @@ -667,7 +673,7 @@ $this - 21 + 23 True @@ -700,7 +706,7 @@ $this - 20 + 22 True @@ -727,7 +733,7 @@ $this - 19 + 21 True @@ -754,7 +760,7 @@ $this - 18 + 20 True @@ -774,9 +780,6 @@ Enable RTS/DTR - - 17, 17 - Useful for Meade LS scopes @@ -790,7 +793,7 @@ $this - 17 + 19 True @@ -817,7 +820,7 @@ $this - 16 + 18 375, 93 @@ -838,7 +841,7 @@ $this - 15 + 17 True @@ -865,7 +868,7 @@ $this - 14 + 16 True @@ -892,7 +895,7 @@ $this - 13 + 15 375, 125 @@ -913,7 +916,7 @@ $this - 12 + 14 True @@ -940,7 +943,7 @@ $this - 11 + 13 True @@ -967,7 +970,7 @@ $this - 10 + 12 97, 163 @@ -988,7 +991,7 @@ $this - 9 + 11 97, 137 @@ -1009,7 +1012,7 @@ $this - 8 + 10 97, 190 @@ -1030,7 +1033,7 @@ $this - 7 + 9 97, 217 @@ -1051,7 +1054,7 @@ $this - 6 + 8 97, 244 @@ -1072,7 +1075,7 @@ $this - 5 + 7 True @@ -1099,7 +1102,7 @@ $this - 4 + 6 True @@ -1126,7 +1129,7 @@ $this - 3 + 5 True @@ -1153,7 +1156,7 @@ $this - 2 + 4 True @@ -1180,7 +1183,7 @@ $this - 1 + 3 True @@ -1213,6 +1216,72 @@ $this + 2 + + + True + + + NoControl + + + 615, 96 + + + 113, 17 + + + 40 + + + Skip Date prompts + + + driver will attempt to skip past the date prompts when a connection to the Autostar is made + + + cbxSkipPrompts + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + NoControl + + + 615, 123 + + + 145, 17 + + + 41 + + + Set current date and time + + + Send Current Date and Time + + + cbxSendDateTime + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 @@ -1225,7 +1294,7 @@ 6, 13 - 626, 454 + 784, 454 CenterScreen diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index cb1e747..1d07e15 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -153,6 +153,8 @@ namespace ASCOM.Meade.net private const string StopBitsName = "Stop Bits"; private const string HandShakeName = "Hand Shake"; private const string ParityName = "Parity"; + private const string SkipPromptsName = "Skip date prompts on connect"; + private const string SendDateTimeName = "Send Date and time on connect"; public static void WriteProfile(ProfileProperties profileProperties) { @@ -177,6 +179,8 @@ namespace ASCOM.Meade.net driverProfile.WriteValue(DriverId, DynamicBreakingName, profileProperties.DynamicBreaking.ToString()); driverProfile.WriteValue(DriverId, SiteElevationName, profileProperties.SiteElevation.ToString(CultureInfo.InvariantCulture)); driverProfile.WriteValue(DriverId, SettleTimeName, profileProperties.SettleTime.ToString()); + driverProfile.WriteValue(DriverId, SkipPromptsName, profileProperties.SkipPrompts.ToString()); + driverProfile.WriteValue(DriverId, SendDateTimeName, profileProperties.SendDateTime.ToString()); } } } @@ -197,6 +201,8 @@ namespace ASCOM.Meade.net private const string StopBitsDefault = "One"; private const string HandShakeDefault = "None"; private const string ParityDefault = "None"; + private const string SendDateTimeDefault = "false"; + private const string SkipPromptsDefault = "false"; public static ProfileProperties ReadProfile() { @@ -222,7 +228,8 @@ namespace ASCOM.Meade.net profileProperties.Handshake = driverProfile.GetValue(DriverId, HandShakeName, string.Empty, HandShakeDefault); 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.SkipPrompts = Convert.ToBoolean(driverProfile.GetValue(DriverId, SkipPromptsName, string.Empty, SkipPromptsDefault)); } return profileProperties;