diff --git a/Meade.net/ProfileProperties.cs b/Meade.net/ProfileProperties.cs index b4f11cc..391c31d 100644 --- a/Meade.net/ProfileProperties.cs +++ b/Meade.net/ProfileProperties.cs @@ -14,5 +14,10 @@ namespace ASCOM.Meade.net public bool RtsDtrEnabled { get; set; } public double SiteElevation { get; set; } public short SettleTime { get; set; } + public int DataBits { get; set; } + public string StopBits { get; set; } + public string Parity { get; set; } + public int Speed { get; set; } + public string Handshake { get; set; } } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index 42e7be1..82fac95 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -110,6 +110,46 @@ namespace ASCOM.Meade.net cboGuidingStyle.SelectedItem = "Auto"; } + numDatabits.Value = profileProperties.DataBits; + + try + { + cboStopBits.SelectedItem = profileProperties.StopBits; + } + catch (Exception) + { + cboStopBits.SelectedItem = "One"; + } + + + try + { + cboParity.SelectedItem = profileProperties.Parity; + } + catch (Exception) + { + cboParity.SelectedItem = "None"; + } + + try + { + cboSpeed.SelectedItem = profileProperties.Speed; + } + catch (Exception) + { + cboParity.SelectedItem = "9600"; + } + + + try + { + cboHandShake.SelectedItem = profileProperties.Handshake; + } + catch (Exception) + { + cboHandShake.SelectedItem = "None"; + } + txtBacklashSteps.Text = profileProperties.BacklashCompensation.ToString(CultureInfo.CurrentCulture); txtElevation.Text = profileProperties.SiteElevation.ToString(CultureInfo.CurrentCulture); @@ -125,6 +165,11 @@ namespace ASCOM.Meade.net TraceLogger = chkTrace.Checked, ComPort = comboBoxComPort.SelectedItem.ToString(), RtsDtrEnabled = cbxRtsDtr.Checked, + DataBits = Convert.ToInt32(numDatabits.Value), + StopBits = cboStopBits.SelectedItem.ToString(), + Parity = cboParity.SelectedItem.ToString(), + Speed = Convert.ToInt32(cboSpeed.SelectedItem), + Handshake = cboHandShake.SelectedItem.ToString(), GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text.Trim()), Precision = cboPrecision.SelectedItem.ToString(), GuidingStyle = cboGuidingStyle.SelectedItem.ToString(), diff --git a/Meade.net/SetupDialogForm.designer.cs b/Meade.net/SetupDialogForm.designer.cs index e049e87..74b44f7 100644 --- a/Meade.net/SetupDialogForm.designer.cs +++ b/Meade.net/SetupDialogForm.designer.cs @@ -66,7 +66,7 @@ namespace ASCOM.Meade.net this.label15 = new System.Windows.Forms.Label(); this.label16 = new System.Windows.Forms.Label(); this.cboStopBits = new System.Windows.Forms.ComboBox(); - this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); + this.numDatabits = new System.Windows.Forms.NumericUpDown(); this.cboParity = new System.Windows.Forms.ComboBox(); this.cboSpeed = new System.Windows.Forms.ComboBox(); this.cboHandShake = new System.Windows.Forms.ComboBox(); @@ -77,7 +77,7 @@ namespace ASCOM.Meade.net this.label21 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudSettleTime)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numDatabits)).BeginInit(); this.SuspendLayout(); // // cmdOK @@ -278,15 +278,15 @@ namespace ASCOM.Meade.net resources.ApplyResources(this.cboStopBits, "cboStopBits"); this.cboStopBits.Name = "cboStopBits"; // - // numericUpDown1 + // numDatabits // - resources.ApplyResources(this.numericUpDown1, "numericUpDown1"); - this.numericUpDown1.Maximum = new decimal(new int[] { + resources.ApplyResources(this.numDatabits, "numDatabits"); + this.numDatabits.Maximum = new decimal(new int[] { 32767, 0, 0, 0}); - this.numericUpDown1.Name = "numericUpDown1"; + this.numDatabits.Name = "numDatabits"; // // cboParity // @@ -343,7 +343,7 @@ namespace ASCOM.Meade.net this.Controls.Add(this.cboHandShake); this.Controls.Add(this.cboSpeed); this.Controls.Add(this.cboParity); - this.Controls.Add(this.numericUpDown1); + this.Controls.Add(this.numDatabits); this.Controls.Add(this.cboStopBits); this.Controls.Add(this.label16); this.Controls.Add(this.label15); @@ -385,7 +385,7 @@ namespace ASCOM.Meade.net this.Shown += new System.EventHandler(this.SetupDialogForm_Shown); ((System.ComponentModel.ISupportInitialize)(this.picASCOM)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nudSettleTime)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numDatabits)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -426,7 +426,7 @@ namespace ASCOM.Meade.net private Label label15; private Label label16; private ComboBox cboStopBits; - private NumericUpDown numericUpDown1; + private NumericUpDown numDatabits; private ComboBox cboParity; private ComboBox cboSpeed; private ComboBox cboHandShake; diff --git a/Meade.net/SetupDialogForm.resx b/Meade.net/SetupDialogForm.resx index 7500694..ca8813c 100644 --- a/Meade.net/SetupDialogForm.resx +++ b/Meade.net/SetupDialogForm.resx @@ -756,9 +756,6 @@ 18 - - 17, 17 - True @@ -777,6 +774,9 @@ Enable RTS/DTR + + 17, 17 + Useful for Meade LS scopes @@ -792,9 +792,6 @@ 17 - - 17, 17 - True @@ -993,25 +990,25 @@ 9 - + 97, 137 - + 120, 20 - + 31 - - numericUpDown1 + + numDatabits - + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - + 8 @@ -1230,9 +1227,6 @@ 626, 454 - - NoControl - CenterScreen diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 1aae39b..af84be1 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -148,6 +148,12 @@ namespace ASCOM.Meade.net private const string SiteElevationName = "Site Elevation"; private const string SettleTimeName = "Settle Time"; + private const string SpeedName = "Speed"; + private const string DataBitsName = "8"; + private const string StopBitsName = "Stop Bits"; + private const string HandShakeName = "Hand Shake"; + private const string ParityName = "Parity"; + public static void WriteProfile(ProfileProperties profileProperties) { lock (LockObject) @@ -158,6 +164,11 @@ namespace ASCOM.Meade.net driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString()); driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort); driverProfile.WriteValue(DriverId, RtsDtrProfileName, profileProperties.RtsDtrEnabled.ToString()); + driverProfile.WriteValue(DriverId, SpeedName, profileProperties.Speed.ToString(CultureInfo.InvariantCulture)); + driverProfile.WriteValue(DriverId, DataBitsName, profileProperties.DataBits.ToString(CultureInfo.InvariantCulture)); + driverProfile.WriteValue(DriverId, StopBitsName, profileProperties.StopBits); + driverProfile.WriteValue(DriverId, HandShakeName, profileProperties.Handshake); + driverProfile.WriteValue(DriverId, ParityName, profileProperties.Parity); driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.InvariantCulture)); driverProfile.WriteValue(DriverId, PrecisionProfileName, profileProperties.Precision); driverProfile.WriteValue(DriverId, GuidingStyleProfileName, profileProperties.GuidingStyle); @@ -181,6 +192,11 @@ namespace ASCOM.Meade.net private const string DynamicBreakingDefault = "true"; private const string SiteElevationDefault = "0"; private const string SettleTimeDefault = "2"; + private const string SpeedDefault = "9600"; + private const string DataBitsDefault = "8"; + private const string StopBitsDefault = "One"; + private const string HandShakeDefault = "None"; + private const string ParityDefault = "None"; public static ProfileProperties ReadProfile() { @@ -201,6 +217,12 @@ namespace ASCOM.Meade.net profileProperties.DynamicBreaking = Convert.ToBoolean(driverProfile.GetValue(DriverId, DynamicBreakingName, string.Empty, DynamicBreakingDefault)); profileProperties.SiteElevation = Convert.ToInt32(driverProfile.GetValue(DriverId, SiteElevationName, string.Empty, SiteElevationDefault)); profileProperties.SettleTime = Convert.ToInt16(driverProfile.GetValue(DriverId, SettleTimeName, string.Empty, SettleTimeDefault)); + profileProperties.StopBits = driverProfile.GetValue(DriverId, StopBitsName, string.Empty, StopBitsDefault); + profileProperties.DataBits = Convert.ToInt32(driverProfile.GetValue(DriverId, DataBitsName, string.Empty, DataBitsDefault)); + 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); + } return profileProperties; @@ -286,11 +308,11 @@ namespace ASCOM.Meade.net SharedSerial.PortName = profileProperties.ComPort; SharedSerial.DTREnable = profileProperties.RtsDtrEnabled; SharedSerial.RTSEnable = profileProperties.RtsDtrEnabled; - SharedSerial.DataBits = 8; - SharedSerial.StopBits = SerialStopBits.One; - SharedSerial.Parity = SerialParity.None; - SharedSerial.Speed = SerialSpeed.ps9600; - SharedSerial.Handshake = SerialHandshake.None; + SharedSerial.DataBits = profileProperties.DataBits; + SharedSerial.StopBits = (SerialStopBits)Enum.Parse(typeof(SerialStopBits), profileProperties.StopBits ); + SharedSerial.Parity = (SerialParity)Enum.Parse(typeof(SerialParity), profileProperties.Parity); + SharedSerial.Speed = (SerialSpeed)profileProperties.Speed; + SharedSerial.Handshake = (SerialHandshake)Enum.Parse(typeof(SerialHandshake), profileProperties.Handshake); SharedSerial.Connected = true; try