diff --git a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs index 2ba4e76..ca09d30 100644 --- a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs +++ b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs @@ -27,6 +27,12 @@ namespace Meade.net.Focuser.UnitTests { TraceLogger = false, ComPort = "TestCom1", + Speed = 9600, + Parity = "None", + Handshake = "None", + StopBits = "One", + DataBits = 8, + GuideRateArcSecondsPerSecond = 1.23, Precision = "Unchanged", GuidingStyle = "Auto" diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 16b330d..21dcaba 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -35,6 +35,12 @@ namespace Meade.net.Telescope.UnitTests { TraceLogger = false, ComPort = "TestCom1", + Speed = 9600, + Parity = "None", + Handshake = "None", + StopBits = "One", + DataBits = 8, + GuideRateArcSecondsPerSecond = 1.23, Precision = "Unchanged", GuidingStyle = "Auto" diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs index 025bfb5..976f3c6 100644 --- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs +++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs @@ -123,10 +123,19 @@ namespace Meade.net.UnitTests Assert.That(profeWrapper.DeviceType, Is.EqualTo("Telescope")); profileWrapperMock.Verify( x => x.WriteValue(DriverId, "Trace Level", profileProperties.TraceLogger.ToString()), Times.Once); + profileWrapperMock.Verify(x => x.WriteValue(DriverId, "COM Port", profileProperties.ComPort), Times.Once); + profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Speed", profileProperties.Speed.ToString()), Times.Once); + profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Data Bits", profileProperties.DataBits.ToString()), Times.Once); + profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Stop Bits", profileProperties.StopBits), Times.Once); + profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Hand Shake", profileProperties.Handshake), Times.Once); + profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Parity", profileProperties.Parity), Times.Once); + profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Rts / Dtr", profileProperties.RtsDtrEnabled.ToString()), Times.Once); + profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Guide Rate Arc Seconds Per Second", profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.CurrentCulture)), Times.Once); profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Precision", profileProperties.Precision), Times.Once); profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Guiding Style", profileProperties.GuidingStyle), Times.Once); + profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Backlash Compensation", profileProperties.BacklashCompensation.ToString(CultureInfo.CurrentCulture)), Times.Once); profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Reverse Focuser Direction", profileProperties.ReverseFocusDirection.ToString()), Times.Once); } @@ -136,13 +145,22 @@ namespace Meade.net.UnitTests { string DriverId = "ASCOM.MeadeGeneric.Telescope"; - string ComPortDefault = "COM1"; string TraceStateDefault = "false"; + + string ComPortDefault = "COM1"; + string SpeedDefault = "9600"; + string DataBitsDefault = "8"; + string StopBitsDefault = "One"; + string HandshakeDefault = "None"; + string ParityDefault = "None"; + string RtsDtrEnabledDefault = "false"; + string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate string PrecisionDefault = "Unchanged"; string GuidingStyleDefault = "Auto"; + string BacklashCompensationDefault = "3000"; - string ReverseFocuserDiectionDefault = "true"; + string ReverseFocuserDiectionDefault = "true"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -165,6 +183,24 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => x.GetValue(DriverId, "Reverse Focuser Direction", string.Empty, ReverseFocuserDiectionDefault)) .Returns(() => ReverseFocuserDiectionDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault)) + .Returns(() => SpeedDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault)) + .Returns(() => DataBitsDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault)) + .Returns(() => StopBitsDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault)) + .Returns(() => HandshakeDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parity", string.Empty, ParityDefault)) + .Returns(() => ParityDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault)) + .Returns(() => RtsDtrEnabledDefault); IProfileWrapper profeWrapper = profileWrapperMock.Object; @@ -174,16 +210,27 @@ namespace Meade.net.UnitTests SharedResources.ProfileFactory = profileFactoryMock.Object; var profileProperties = SharedResources.ReadProfile(); - + Assert.That(profeWrapper.DeviceType, Is.EqualTo("Telescope")); - Assert.That(profileProperties.ComPort, Is.EqualTo(ComPortDefault)); - Assert.That(profileProperties.GuideRateArcSecondsPerSecond, - Is.EqualTo(double.Parse(GuideRateProfileNameDefault))); + Assert.That(profileProperties.TraceLogger, Is.EqualTo(bool.Parse(TraceStateDefault))); + + Assert.That(profileProperties.ComPort, Is.EqualTo(ComPortDefault)); + + Assert.That(profileProperties.GuideRateArcSecondsPerSecond, + Is.EqualTo(double.Parse(GuideRateProfileNameDefault))); Assert.That(profileProperties.Precision, Is.EqualTo(PrecisionDefault)); Assert.That(profileProperties.GuidingStyle, Is.EqualTo(GuidingStyleDefault)); + Assert.That(profileProperties.BacklashCompensation, Is.EqualTo(int.Parse(BacklashCompensationDefault))); Assert.That(profileProperties.ReverseFocusDirection, Is.EqualTo(bool.Parse(ReverseFocuserDiectionDefault))); + + Assert.That(profileProperties.Speed, Is.EqualTo(int.Parse(SpeedDefault))); + Assert.That(profileProperties.DataBits, Is.EqualTo(int.Parse(DataBitsDefault))); + Assert.That(profileProperties.StopBits, Is.EqualTo(StopBitsDefault)); + Assert.That(profileProperties.Handshake, Is.EqualTo(HandshakeDefault)); + Assert.That(profileProperties.Parity, Is.EqualTo(ParityDefault)); + Assert.That(profileProperties.RtsDtrEnabled, Is.EqualTo(bool.Parse(RtsDtrEnabledDefault))); } [TestCase("TCP")] @@ -199,10 +246,16 @@ namespace Meade.net.UnitTests public void Connect_WhenDeviceIdIsSerialButGVPEchos_ThenThrowsException() { string deviceId = "Serial"; - - string driverDriverId = "ASCOM.MeadeGeneric.Telescope"; + string DriverId = "ASCOM.MeadeGeneric.Telescope"; string ComPortDefault = "COM1"; + string SpeedDefault = "9600"; + string DataBitsDefault = "8"; + string StopBitsDefault = "One"; + string HandshakeDefault = "None"; + string ParityDefault = "None"; + string RtsDtrEnabledDefault = "false"; + string TraceStateDefault = "false"; string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate string PrecisionDefault = "Unchanged"; @@ -210,14 +263,33 @@ namespace Meade.net.UnitTests Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); - profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Trace Level", string.Empty, TraceStateDefault)) + profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault)) .Returns(TraceStateDefault); - profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "COM Port", string.Empty, ComPortDefault)) + profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault)) .Returns(ComPortDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault)) + .Returns(() => SpeedDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault)) + .Returns(() => DataBitsDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault)) + .Returns(() => StopBitsDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault)) + .Returns(() => HandshakeDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parity", string.Empty, ParityDefault)) + .Returns(() => ParityDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault)) + .Returns(() => RtsDtrEnabledDefault); + profileWrapperMock - .Setup(x => x.GetValue(driverDriverId, "Guide Rate Arc Seconds Per Second", string.Empty, + .Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty, GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault); - profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Precision", string.Empty, PrecisionDefault)) + profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault)) .Returns(PrecisionDefault); Mock profileFactoryMock = new Mock(); @@ -239,26 +311,51 @@ namespace Meade.net.UnitTests public void Connect_WhenDeviceIdIsSerialButGVPNotSupported_ThenConnectsAndSetsProductToLX200Classic() { string deviceId = "Serial"; + string DriverId = "ASCOM.MeadeGeneric.Telescope"; - string driverDriverId = "ASCOM.MeadeGeneric.Telescope"; + string TraceStateDefault = "false"; string ComPortDefault = "COM1"; - string TraceStateDefault = "false"; + string SpeedDefault = "9600"; + string DataBitsDefault = "8"; + string StopBitsDefault = "One"; + string HandshakeDefault = "None"; + string ParityDefault = "None"; + string RtsDtrEnabledDefault = "false"; + string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate string PrecisionDefault = "Unchanged"; - + Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); - profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Trace Level", string.Empty, TraceStateDefault)) + profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault)) .Returns(TraceStateDefault); - profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "COM Port", string.Empty, ComPortDefault)) + profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault)) .Returns(ComPortDefault); profileWrapperMock - .Setup(x => x.GetValue(driverDriverId, "Guide Rate Arc Seconds Per Second", string.Empty, + .Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty, GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault); - profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Precision", string.Empty, PrecisionDefault)) + profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault)) .Returns(PrecisionDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault)) + .Returns(() => SpeedDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault)) + .Returns(() => DataBitsDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault)) + .Returns(() => StopBitsDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault)) + .Returns(() => HandshakeDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parity", string.Empty, ParityDefault)) + .Returns(() => ParityDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault)) + .Returns(() => RtsDtrEnabledDefault); Mock profileFactoryMock = new Mock(); profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); @@ -293,25 +390,51 @@ namespace Meade.net.UnitTests { string deviceId = "Serial"; - string driverDriverId = "ASCOM.MeadeGeneric.Telescope"; + string DriverId = "ASCOM.MeadeGeneric.Telescope"; + + string TraceStateDefault = "false"; string ComPortDefault = "COM1"; - string TraceStateDefault = "false"; + string SpeedDefault = "9600"; + string DataBitsDefault = "8"; + string StopBitsDefault = "One"; + string HandshakeDefault = "None"; + string ParityDefault = "None"; + string RtsDtrEnabledDefault = "false"; + string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate string PrecisionDefault = "Unchanged"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); - profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Trace Level", string.Empty, TraceStateDefault)) + profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault)) .Returns(TraceStateDefault); - profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "COM Port", string.Empty, ComPortDefault)) + profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault)) .Returns(ComPortDefault); profileWrapperMock - .Setup(x => x.GetValue(driverDriverId, "Guide Rate Arc Seconds Per Second", string.Empty, + .Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty, GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault); - profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Precision", string.Empty, PrecisionDefault)) + profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault)) .Returns(PrecisionDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault)) + .Returns(() => SpeedDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault)) + .Returns(() => DataBitsDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault)) + .Returns(() => StopBitsDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault)) + .Returns(() => HandshakeDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parity", string.Empty, ParityDefault)) + .Returns(() => ParityDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault)) + .Returns(() => RtsDtrEnabledDefault); Mock profileFactoryMock = new Mock(); profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); @@ -343,25 +466,51 @@ namespace Meade.net.UnitTests { string deviceId = "Serial"; - string driverDriverId = "ASCOM.MeadeGeneric.Telescope"; + string DriverId = "ASCOM.MeadeGeneric.Telescope"; + + string TraceStateDefault = "false"; string ComPortDefault = "COM1"; - string TraceStateDefault = "false"; + string SpeedDefault = "9600"; + string DataBitsDefault = "8"; + string StopBitsDefault = "One"; + string HandshakeDefault = "None"; + string ParityDefault = "None"; + string RtsDtrEnabledDefault = "false"; + string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate string PrecisionDefault = "Unchanged"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); - profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Trace Level", string.Empty, TraceStateDefault)) + profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault)) .Returns(TraceStateDefault); - profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "COM Port", string.Empty, ComPortDefault)) + profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault)) .Returns(ComPortDefault); profileWrapperMock - .Setup(x => x.GetValue(driverDriverId, "Guide Rate Arc Seconds Per Second", string.Empty, + .Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty, GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault); - profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Precision", string.Empty, PrecisionDefault)) + profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault)) .Returns(PrecisionDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault)) + .Returns(() => SpeedDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault)) + .Returns(() => DataBitsDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault)) + .Returns(() => StopBitsDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault)) + .Returns(() => HandshakeDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parity", string.Empty, ParityDefault)) + .Returns(() => ParityDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault)) + .Returns(() => RtsDtrEnabledDefault); Mock profileFactoryMock = new Mock(); profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); 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 d56b963..82fac95 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.ComponentModel; using System.Diagnostics; using System.Globalization; @@ -7,6 +8,7 @@ using System.Linq; using System.Runtime.InteropServices; using System.Windows.Forms; using ASCOM.Meade.net.Properties; +using ASCOM.Utilities; namespace ASCOM.Meade.net { @@ -20,6 +22,31 @@ namespace ASCOM.Meade.net var assemblyInfo = new AssemblyInfo(); Text = string.Format(Resources.SetupDialogForm_SetupDialogForm__0__Settings___1__, assemblyInfo.Product, assemblyInfo.AssemblyVersion); + + SetItemsFromEnum(cboStopBits.Items, typeof(SerialStopBits)); + SetItemsFromEnum(cboParity.Items, typeof(SerialParity)); + SetItemsFromEnumValues(cboSpeed.Items, typeof(SerialSpeed)); + SetItemsFromEnum(cboHandShake.Items, typeof(SerialHandshake)); + } + + private void SetItemsFromEnum(IList items, Type enumItems) + { + items.Clear(); + + foreach (var item in Enum.GetNames(enumItems)) + { + items.Add(item); + } + } + + private void SetItemsFromEnumValues(IList items, Type enumItems) + { + items.Clear(); + + foreach (int item in Enum.GetValues(enumItems)) + { + items.Add(item); + } } public sealed override string Text @@ -83,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); @@ -98,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 d0858bd..701c5be 100644 --- a/Meade.net/SetupDialogForm.designer.cs +++ b/Meade.net/SetupDialogForm.designer.cs @@ -64,8 +64,20 @@ namespace ASCOM.Meade.net this.label14 = new System.Windows.Forms.Label(); this.nudSettleTime = new System.Windows.Forms.NumericUpDown(); this.label15 = new System.Windows.Forms.Label(); + this.label16 = new System.Windows.Forms.Label(); + this.cboStopBits = new System.Windows.Forms.ComboBox(); + 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(); + this.label17 = new System.Windows.Forms.Label(); + this.label18 = new System.Windows.Forms.Label(); + this.label19 = new System.Windows.Forms.Label(); + this.label20 = new System.Windows.Forms.Label(); + this.label21 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudSettleTime)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numDatabits)).BeginInit(); this.SuspendLayout(); // // cmdOK @@ -255,10 +267,89 @@ namespace ASCOM.Meade.net resources.ApplyResources(this.label15, "label15"); this.label15.Name = "label15"; // + // label16 + // + resources.ApplyResources(this.label16, "label16"); + this.label16.Name = "label16"; + // + // cboStopBits + // + this.cboStopBits.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cboStopBits.FormattingEnabled = true; + resources.ApplyResources(this.cboStopBits, "cboStopBits"); + this.cboStopBits.Name = "cboStopBits"; + // + // numDatabits + // + resources.ApplyResources(this.numDatabits, "numDatabits"); + this.numDatabits.Maximum = new decimal(new int[] { + 32767, + 0, + 0, + 0}); + this.numDatabits.Name = "numDatabits"; + // + // cboParity + // + this.cboParity.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cboParity.FormattingEnabled = true; + resources.ApplyResources(this.cboParity, "cboParity"); + this.cboParity.Name = "cboParity"; + // + // cboSpeed + // + this.cboSpeed.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cboSpeed.FormattingEnabled = true; + resources.ApplyResources(this.cboSpeed, "cboSpeed"); + this.cboSpeed.Name = "cboSpeed"; + // + // cboHandShake + // + this.cboHandShake.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cboHandShake.FormattingEnabled = true; + resources.ApplyResources(this.cboHandShake, "cboHandShake"); + this.cboHandShake.Name = "cboHandShake"; + // + // label17 + // + resources.ApplyResources(this.label17, "label17"); + this.label17.Name = "label17"; + // + // label18 + // + resources.ApplyResources(this.label18, "label18"); + this.label18.Name = "label18"; + // + // label19 + // + resources.ApplyResources(this.label19, "label19"); + this.label19.Name = "label19"; + // + // label20 + // + resources.ApplyResources(this.label20, "label20"); + this.label20.Name = "label20"; + // + // label21 + // + resources.ApplyResources(this.label21, "label21"); + this.label21.Name = "label21"; + // // SetupDialogForm // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label21); + this.Controls.Add(this.label20); + this.Controls.Add(this.label19); + this.Controls.Add(this.label18); + this.Controls.Add(this.label17); + this.Controls.Add(this.cboHandShake); + this.Controls.Add(this.cboSpeed); + this.Controls.Add(this.cboParity); + this.Controls.Add(this.numDatabits); + this.Controls.Add(this.cboStopBits); + this.Controls.Add(this.label16); this.Controls.Add(this.label15); this.Controls.Add(this.nudSettleTime); this.Controls.Add(this.label14); @@ -298,6 +389,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.numDatabits)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -336,5 +428,16 @@ namespace ASCOM.Meade.net private Label label14; private NumericUpDown nudSettleTime; private Label label15; + private Label label16; + private ComboBox cboStopBits; + private NumericUpDown numDatabits; + private ComboBox cboParity; + private ComboBox cboSpeed; + private ComboBox cboHandShake; + private Label label17; + private Label label18; + private Label label19; + private Label label20; + private Label label21; } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.resx b/Meade.net/SetupDialogForm.resx index 73de650..ca8813c 100644 --- a/Meade.net/SetupDialogForm.resx +++ b/Meade.net/SetupDialogForm.resx @@ -123,7 +123,7 @@ - 281, 457 + 557, 391 59, 24 @@ -145,13 +145,13 @@ $this - 29 + 40 Bottom, Right - 281, 487 + 557, 421 59, 25 @@ -172,7 +172,7 @@ $this - 28 + 39 12, 9 @@ -196,13 +196,13 @@ $this - 27 + 38 Top, Right - 292, 9 + 568, 9 48, 56 @@ -223,7 +223,7 @@ $this - 26 + 37 True @@ -250,22 +250,22 @@ $this - 25 + 36 True - 97, 137 + 97, 305 - 69, 17 + 90, 17 2 - Trace on + Trace Log on chkTrace @@ -277,7 +277,7 @@ $this - 24 + 35 97, 87 @@ -298,13 +298,13 @@ $this - 23 + 34 True - 12, 278 + 290, 169 61, 13 @@ -325,10 +325,10 @@ $this - 22 + 33 - 97, 275 + 375, 166 46, 20 @@ -349,13 +349,13 @@ $this - 21 + 32 True - 149, 278 + 427, 169 122, 13 @@ -376,13 +376,13 @@ $this - 20 + 31 True - 149, 291 + 427, 182 105, 13 @@ -403,13 +403,13 @@ $this - 19 + 30 True - 12, 310 + 290, 201 50, 13 @@ -430,7 +430,7 @@ $this - 18 + 29 Unchanged @@ -442,7 +442,7 @@ High - 97, 307 + 375, 198 90, 21 @@ -460,7 +460,7 @@ $this - 17 + 28 True @@ -469,7 +469,7 @@ NoControl - 12, 337 + 290, 228 67, 13 @@ -490,7 +490,7 @@ $this - 16 + 27 Auto @@ -502,7 +502,7 @@ Pulse guiding - 97, 334 + 375, 225 90, 21 @@ -520,7 +520,7 @@ $this - 15 + 26 True @@ -529,7 +529,7 @@ Microsoft Sans Serif, 8.25pt, style=Bold - 12, 176 + 290, 67 66, 13 @@ -550,7 +550,7 @@ $this - 14 + 25 True @@ -562,7 +562,7 @@ NoControl - 12, 393 + 290, 284 52, 13 @@ -583,10 +583,10 @@ $this - 13 + 24 - 97, 411 + 375, 302 46, 20 @@ -607,7 +607,7 @@ $this - 11 + 22 True @@ -616,7 +616,7 @@ NoControl - 12, 414 + 290, 305 79, 13 @@ -637,7 +637,7 @@ $this - 12 + 23 True @@ -646,7 +646,7 @@ NoControl - 149, 414 + 427, 305 20, 13 @@ -667,7 +667,7 @@ $this - 10 + 21 True @@ -700,13 +700,13 @@ $this - 9 + 20 True - 97, 437 + 375, 328 109, 17 @@ -727,13 +727,13 @@ $this - 8 + 19 True - 97, 460 + 375, 351 112, 17 @@ -754,11 +754,8 @@ $this - 7 + 18 - - 17, 17 - True @@ -777,6 +774,9 @@ Enable RTS/DTR + + 17, 17 + Useful for Meade LS scopes @@ -790,16 +790,13 @@ $this - 6 + 17 - - 17, 17 - True - 12, 205 + 290, 96 72, 13 @@ -820,10 +817,10 @@ $this - 5 + 16 - 97, 202 + 375, 93 100, 20 @@ -841,13 +838,13 @@ $this - 4 + 15 True - 203, 205 + 481, 96 38, 13 @@ -868,13 +865,13 @@ $this - 3 + 14 True - 12, 236 + 290, 127 56, 13 @@ -895,10 +892,10 @@ $this - 2 + 13 - 97, 234 + 375, 125 120, 20 @@ -916,13 +913,13 @@ $this - 1 + 12 True - 223, 236 + 501, 127 47, 13 @@ -943,16 +940,292 @@ $this + 11 + + + True + + + 15, 139 + + + 49, 13 + + + 29 + + + Data bits + + + label16 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 10 + + + 97, 163 + + + 119, 21 + + + 30 + + + cboStopBits + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 9 + + + 97, 137 + + + 120, 20 + + + 31 + + + numDatabits + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 8 + + + 97, 190 + + + 119, 21 + + + 32 + + + cboParity + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 7 + + + 97, 217 + + + 119, 21 + + + 33 + + + cboSpeed + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 6 + + + 97, 244 + + + 121, 21 + + + 34 + + + cboHandShake + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 5 + + + True + + + 15, 166 + + + 49, 13 + + + 35 + + + Stop Bits + + + label17 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 4 + + + True + + + 15, 193 + + + 33, 13 + + + 36 + + + Parity + + + label18 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + True + + + 15, 220 + + + 38, 13 + + + 37 + + + Speed + + + label19 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + True + + + 15, 247 + + + 62, 13 + + + 38 + + + Handshake + + + label20 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + Microsoft Sans Serif, 8.25pt, style=Bold + + + NoControl + + + 15, 284 + + + 73, 13 + + + 39 + + + Diagnostics + + + label21 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 True + + 25 + 6, 13 - 350, 520 + 626, 454 CenterScreen diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 1aae39b..cb1e747 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 = "Data Bits"; + 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