Added support for setting all serial properties.
This commit is contained in:
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
|
||||
Generated
+9
-9
@@ -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;
|
||||
|
||||
@@ -756,9 +756,6 @@
|
||||
<data name=">>cbxDynamicBreaking.ZOrder" xml:space="preserve">
|
||||
<value>18</value>
|
||||
</data>
|
||||
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<data name="cbxRtsDtr.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
@@ -777,6 +774,9 @@
|
||||
<data name="cbxRtsDtr.Text" xml:space="preserve">
|
||||
<value>Enable RTS/DTR</value>
|
||||
</data>
|
||||
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<data name="cbxRtsDtr.ToolTip" xml:space="preserve">
|
||||
<value>Useful for Meade LS scopes</value>
|
||||
</data>
|
||||
@@ -792,9 +792,6 @@
|
||||
<data name=">>cbxRtsDtr.ZOrder" xml:space="preserve">
|
||||
<value>17</value>
|
||||
</data>
|
||||
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<data name="label12.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
@@ -993,25 +990,25 @@
|
||||
<data name=">>cboStopBits.ZOrder" xml:space="preserve">
|
||||
<value>9</value>
|
||||
</data>
|
||||
<data name="numericUpDown1.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<data name="numDatabits.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>97, 137</value>
|
||||
</data>
|
||||
<data name="numericUpDown1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<data name="numDatabits.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>120, 20</value>
|
||||
</data>
|
||||
<data name="numericUpDown1.TabIndex" type="System.Int32, mscorlib">
|
||||
<data name="numDatabits.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>31</value>
|
||||
</data>
|
||||
<data name=">>numericUpDown1.Name" xml:space="preserve">
|
||||
<value>numericUpDown1</value>
|
||||
<data name=">>numDatabits.Name" xml:space="preserve">
|
||||
<value>numDatabits</value>
|
||||
</data>
|
||||
<data name=">>numericUpDown1.Type" xml:space="preserve">
|
||||
<data name=">>numDatabits.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>numericUpDown1.Parent" xml:space="preserve">
|
||||
<data name=">>numDatabits.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>numericUpDown1.ZOrder" xml:space="preserve">
|
||||
<data name=">>numDatabits.ZOrder" xml:space="preserve">
|
||||
<value>8</value>
|
||||
</data>
|
||||
<data name="cboParity.Location" type="System.Drawing.Point, System.Drawing">
|
||||
@@ -1230,9 +1227,6 @@
|
||||
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>626, 454</value>
|
||||
</data>
|
||||
<data name="$this.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
|
||||
<value>CenterScreen</value>
|
||||
</data>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user