From 86e4cd4feef8d145e14af6d293b3ee268be47e0b Mon Sep 17 00:00:00 2001 From: mandrolic Date: Sun, 27 Feb 2011 08:09:16 +0000 Subject: [PATCH] Configurator.Net: Added heading field git-svn-id: https://arducopter.googlecode.com/svn/trunk@1730 f9c3cf11-9bcb-44bc-f272-b75c42450872 --- .../ArducopterConfigurator.csproj | 2 +- Configurator/Configurator.Net/CommsSession.cs | 1 + .../PresentationModels/MainVm.cs | 7 +++- .../PresentationModels/SensorsVm.cs | 32 ++++++++++++++++++- .../Views/FlightDataView.Designer.cs | 29 ++++++++++++++++- .../Views/FlightDataView.resx | 3 -- 6 files changed, 67 insertions(+), 7 deletions(-) diff --git a/Configurator/Configurator.Net/ArducopterConfigurator.csproj b/Configurator/Configurator.Net/ArducopterConfigurator.csproj index 31d11d44ab..1fda748519 100644 --- a/Configurator/Configurator.Net/ArducopterConfigurator.csproj +++ b/Configurator/Configurator.Net/ArducopterConfigurator.csproj @@ -33,7 +33,7 @@ true index.htm false - 6 + 7 1.0.0.%2a false true diff --git a/Configurator/Configurator.Net/CommsSession.cs b/Configurator/Configurator.Net/CommsSession.cs index 04bac3bdde..2b1bdd85c3 100644 --- a/Configurator/Configurator.Net/CommsSession.cs +++ b/Configurator/Configurator.Net/CommsSession.cs @@ -61,6 +61,7 @@ namespace ArducopterConfigurator catch (Exception ex) { Error = ex.Message; + return false; } return true; } diff --git a/Configurator/Configurator.Net/PresentationModels/MainVm.cs b/Configurator/Configurator.Net/PresentationModels/MainVm.cs index 154703d65b..5803ded9cd 100644 --- a/Configurator/Configurator.Net/PresentationModels/MainVm.cs +++ b/Configurator/Configurator.Net/PresentationModels/MainVm.cs @@ -182,7 +182,12 @@ namespace ArducopterConfigurator.PresentationModels _comms.CommPort = SelectedPort; // Todo: check the status of this call success/failure - _comms.Connect(); + if (!_comms.Connect()) + { + ConnectionState = SessionStates.Disconnected; + ApmVersion = "Error"; + return; + } ConnectionState = SessionStates.Connecting; diff --git a/Configurator/Configurator.Net/PresentationModels/SensorsVm.cs b/Configurator/Configurator.Net/PresentationModels/SensorsVm.cs index 3fcbe4b4e7..8f725bd213 100644 --- a/Configurator/Configurator.Net/PresentationModels/SensorsVm.cs +++ b/Configurator/Configurator.Net/PresentationModels/SensorsVm.cs @@ -95,7 +95,7 @@ namespace ArducopterConfigurator.PresentationModels "AccelRoll", "AccelPitch", "AccelZ", - "UnusedFloat", // AP_Compass.heading + "CompassHeading", // AP_Compass.heading "UnusedFloat", // AP_Compass.heading_x "UnusedFloat", // AP_Compass.heading_y "Unused", // AP_Compass.mag_x @@ -368,6 +368,36 @@ namespace ArducopterConfigurator.PresentationModels } } + private float _compassHeading; + + + /// + /// The current compass Heading as read from the magnetometer in radians? + /// + public float CompassHeading + { + get { return _compassHeading; } + set + { + if (_compassHeading == value) return; + _compassHeading = value; + FirePropertyChanged("CompassHeading"); + FirePropertyChanged("CompassHeadingDegrees"); + } + } + + /// + /// The current compass Heading as read from the magnetometer in degrees + /// + public float CompassHeadingDegrees + { + get + { + var degrees = (float) ((CompassHeading) * (180 / Math.PI)); + return (360 + degrees) % 360; + } + } + #endregion public int Unused { get; set; } diff --git a/Configurator/Configurator.Net/Views/FlightDataView.Designer.cs b/Configurator/Configurator.Net/Views/FlightDataView.Designer.cs index 961f7a37ef..2f6bf27db0 100644 --- a/Configurator/Configurator.Net/Views/FlightDataView.Designer.cs +++ b/Configurator/Configurator.Net/Views/FlightDataView.Designer.cs @@ -71,6 +71,8 @@ this.cirularIndicatorControl5 = new ArducopterConfigurator.Views.controls.CirularIndicatorControl(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.label1 = new System.Windows.Forms.Label(); + this.textBox14 = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.FlightDataVmBindingSource)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); @@ -608,10 +610,33 @@ this.label1.TabIndex = 57; this.label1.Text = "ARMED"; // + // textBox14 + // + this.textBox14.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.textBox14.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.FlightDataVmBindingSource, "CompassHeadingDegrees", true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, null, "N0")); + this.textBox14.Enabled = false; + this.textBox14.Location = new System.Drawing.Point(102, 244); + this.textBox14.Name = "textBox14"; + this.textBox14.ReadOnly = true; + this.textBox14.Size = new System.Drawing.Size(35, 20); + this.textBox14.TabIndex = 58; + this.textBox14.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(44, 246); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(47, 13); + this.label2.TabIndex = 59; + this.label2.Text = "Heading"; + // // FlightDataView // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label2); + this.Controls.Add(this.textBox14); this.Controls.Add(this.label1); this.Controls.Add(this.cirularIndicatorControl5); this.Controls.Add(this.cirularIndicatorControl4); @@ -652,7 +677,7 @@ this.Controls.Add(this.pictureBox2); this.DoubleBuffered = true; this.Name = "FlightDataView"; - this.Size = new System.Drawing.Size(453, 260); + this.Size = new System.Drawing.Size(453, 273); ((System.ComponentModel.ISupportInitialize)(this.FlightDataVmBindingSource)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); @@ -704,5 +729,7 @@ private ArducopterConfigurator.Views.controls.CirularIndicatorControl cirularIndicatorControl5; private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox textBox14; + private System.Windows.Forms.Label label2; } } diff --git a/Configurator/Configurator.Net/Views/FlightDataView.resx b/Configurator/Configurator.Net/Views/FlightDataView.resx index 6328a6f0ab..093ac4fe95 100644 --- a/Configurator/Configurator.Net/Views/FlightDataView.resx +++ b/Configurator/Configurator.Net/Views/FlightDataView.resx @@ -172,7 +172,4 @@ kDAHyJw4EoECAARSrmTK0SPIjAQxYjW4taBWrF8zhrU4tkBAADs= - - 225, 28 - \ No newline at end of file