Configurator.Net: Added BaudRate option

git-svn-id: https://arducopter.googlecode.com/svn/trunk@1733 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
mandrolic 2011-02-28 20:11:44 +00:00
parent 5f853768f4
commit dd008ec97f
7 changed files with 78 additions and 12 deletions

View File

@ -33,7 +33,7 @@
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>index.htm</WebPage>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<ApplicationRevision>7</ApplicationRevision>
<ApplicationRevision>8</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>

View File

@ -11,6 +11,7 @@ namespace ArducopterConfigurator
event Action<string> LineOfDataReceived;
string CommPort { get; set; }
bool IsConnected { get; }
int BaudRate { get; set; }
IEnumerable<string> ListCommPorts();
void Send(string send);
bool Connect();
@ -37,9 +38,11 @@ namespace ArducopterConfigurator
public string CommPort { get; set; }
public int BaudRate { get; set; }
public bool Connect()
{
_sp.BaudRate = 115200;
_sp.BaudRate = BaudRate;
_sp.PortName = CommPort;
_sp.NewLine = "\n";
_sp.Handshake = Handshake.None;
@ -125,6 +128,8 @@ namespace ArducopterConfigurator
get { return _sp.IsOpen; }
}
public IEnumerable<string> ListCommPorts()
{
return SerialPort.GetPortNames();

View File

@ -32,6 +32,9 @@ namespace ArducopterConfigurator
get { return _connected; }
}
public int BaudRate { get; set; }
public IEnumerable<string> ListCommPorts()
{
return new[] {"FakePort1", "FakePort2"};

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Timer=System.Windows.Forms.Timer;
@ -10,6 +11,7 @@ namespace ArducopterConfigurator.PresentationModels
private bool _isConnected;
private IPresentationModel _selectedVm;
private string _selectedPort;
private int _selectedBaudRate;
private string _apmVersion;
private Timer _connectionAttemptsTimer;
@ -54,7 +56,10 @@ namespace ArducopterConfigurator.PresentationModels
ConnectionState = SessionStates.Disconnected;
AvailablePorts = new BindingList<string>();
AvailableBaudRates = new BindingList<int>() {115200, 57600, 38400, 9600};
SelectedBaudRate = 115200;
RefreshPorts();
// Initially have selected the last discovered com port.
@ -131,6 +136,8 @@ namespace ArducopterConfigurator.PresentationModels
public BindingList<string> AvailablePorts { get; private set; }
public BindingList<int> AvailableBaudRates { get; private set; }
public enum SessionStates
{
Disconnected,
@ -178,11 +185,26 @@ namespace ArducopterConfigurator.PresentationModels
}
}
}
public int SelectedBaudRate
{
get { return _selectedBaudRate; }
set
{
if (_selectedBaudRate != value)
{
_selectedBaudRate = value;
FirePropertyChanged("SelectedBaudRate");
}
}
}
public void Connect()
{
_comms.CommPort = SelectedPort;
_comms.BaudRate = SelectedBaudRate;
// Todo: check the status of this call success/failure
if (!_comms.Connect())
{

View File

@ -16,6 +16,12 @@ namespace ArducopterConfiguratorTest
get { return _isConnected; }
}
public int BaudRate
{
get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); }
}
public IEnumerable<string> ListCommPorts()
{
return new[] {"MockComport1"};

View File

@ -39,12 +39,15 @@ namespace ArducopterConfigurator
this.button4 = new System.Windows.Forms.Button();
this.btnConnect = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.label1 = new System.Windows.Forms.Label();
this.cmboComPorts = new System.Windows.Forms.ComboBox();
this.lblConnectionStatus = new System.Windows.Forms.Label();
this.availableBaudRatesBindingSource = new System.Windows.Forms.BindingSource(this.components);
((System.ComponentModel.ISupportInitialize)(this.mainVmBindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.availablePortsBindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.availableBaudRatesBindingSource)).BeginInit();
this.SuspendLayout();
//
// tabCtrlMonitorVms
@ -95,7 +98,7 @@ namespace ArducopterConfigurator
this.btnConnect.Cursor = System.Windows.Forms.Cursors.Arrow;
this.btnConnect.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.mainVmBindingSource, "ConnectCommand", true));
this.btnConnect.Image = ((System.Drawing.Image)(resources.GetObject("btnConnect.Image")));
this.btnConnect.Location = new System.Drawing.Point(96, 407);
this.btnConnect.Location = new System.Drawing.Point(165, 408);
this.btnConnect.Name = "btnConnect";
this.btnConnect.Size = new System.Drawing.Size(26, 26);
this.btnConnect.TabIndex = 6;
@ -108,17 +111,29 @@ namespace ArducopterConfigurator
this.button1.Cursor = System.Windows.Forms.Cursors.Arrow;
this.button1.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.mainVmBindingSource, "DisconnectCommand", true));
this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image")));
this.button1.Location = new System.Drawing.Point(127, 407);
this.button1.Location = new System.Drawing.Point(196, 408);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(26, 26);
this.button1.TabIndex = 7;
this.toolTip.SetToolTip(this.button1, "Disconnect");
this.button1.UseVisualStyleBackColor = true;
//
// comboBox1
//
this.comboBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.comboBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.mainVmBindingSource, "SelectedBaudRate", true));
this.comboBox1.DataSource = this.availableBaudRatesBindingSource;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(80, 411);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(79, 21);
this.comboBox1.TabIndex = 15;
this.toolTip.SetToolTip(this.comboBox1, "Baud Rate");
//
// linkLabel1
//
this.linkLabel1.AutoSize = true;
this.linkLabel1.Location = new System.Drawing.Point(346, 415);
this.linkLabel1.Location = new System.Drawing.Point(355, 423);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(84, 13);
this.linkLabel1.TabIndex = 13;
@ -129,7 +144,7 @@ namespace ArducopterConfigurator
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(346, 399);
this.label1.Location = new System.Drawing.Point(355, 407);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(89, 13);
this.label1.TabIndex = 14;
@ -143,7 +158,7 @@ namespace ArducopterConfigurator
this.cmboComPorts.FormattingEnabled = true;
this.cmboComPorts.Location = new System.Drawing.Point(11, 410);
this.cmboComPorts.Name = "cmboComPorts";
this.cmboComPorts.Size = new System.Drawing.Size(79, 21);
this.cmboComPorts.Size = new System.Drawing.Size(63, 21);
this.cmboComPorts.TabIndex = 5;
this.cmboComPorts.DropDown += new System.EventHandler(this.cmboComPorts_DropDown);
//
@ -151,17 +166,23 @@ namespace ArducopterConfigurator
//
this.lblConnectionStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblConnectionStatus.AutoSize = true;
this.lblConnectionStatus.Location = new System.Drawing.Point(159, 418);
this.lblConnectionStatus.Location = new System.Drawing.Point(228, 419);
this.lblConnectionStatus.Name = "lblConnectionStatus";
this.lblConnectionStatus.Size = new System.Drawing.Size(112, 13);
this.lblConnectionStatus.TabIndex = 8;
this.lblConnectionStatus.Text = "connection string here";
//
// availableBaudRatesBindingSource
//
this.availableBaudRatesBindingSource.DataMember = "AvailableBaudRates";
this.availableBaudRatesBindingSource.DataSource = this.mainVmBindingSource;
//
// mainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(554, 445);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.lblConnectionStatus);
this.Controls.Add(this.button1);
@ -179,6 +200,7 @@ namespace ArducopterConfigurator
this.SizeChanged += new System.EventHandler(this.mainForm_SizeChanged);
((System.ComponentModel.ISupportInitialize)(this.mainVmBindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.availablePortsBindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.availableBaudRatesBindingSource)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -198,6 +220,8 @@ namespace ArducopterConfigurator
private System.Windows.Forms.ComboBox cmboComPorts;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label lblConnectionStatus;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.BindingSource availableBaudRatesBindingSource;
}
}

View File

@ -120,6 +120,9 @@
<metadata name="mainVmBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>7, 19</value>
</metadata>
<metadata name="mainVmBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>7, 19</value>
</metadata>
<metadata name="availablePortsBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>170, 20</value>
</metadata>
@ -130,8 +133,8 @@
<data name="button3.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALBgAA
CwYBZDTpJAAABLRJREFUWEftVm1Mk1cYJVn8NxPjD7Nl2YeAWWJCliWbYxuwDzIdYDHIpgiKG9IBqYVR
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALBAAA
CwQBG8oqrQAABLRJREFUWEftVm1Mk1cYJVn8NxPjD7Nl2YeAWWJCliWbYxuwDzIdYDHIpgiKG9IBqYVR
UEuFgu8AKZ+1CGg7ZUBhDtdYMykMaPmmxSJfwoAhTuwYCBuEIIgMPOu9TnRY2rVz4Y8/Tpomvfec8zzn
eXrtANitJlaVnBh/KsDqCmxVeGCjzB52Yrt/4GXZRrxT7GasqnWZslqAk9wJv6EHbYvV0C6qULNwAao/
z6FhsQwvFjn8/wLWSdei854GknkBUuaiIZzhgjfNhnpRCbu8Z1DT3GqVCLMVICVdI1kDQkqwVvos/Wxd
@ -210,6 +213,9 @@
IEcrx3nZquyh7NsISVnw5bFgit2/J/uPz/w7PYg4GfFdEjIAAAAASUVORK5CYII=
</value>
</data>
<metadata name="availableBaudRatesBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>466, 20</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAgAAAAAAAEAIACJiQAAhgAAAICAAAABACAAKAgBAA+KAABISAAAAQAgAIhUAAA3kgEAQEAAAAEA