From f4334c9aaf67e92245b019728c5790afc9a88888 Mon Sep 17 00:00:00 2001 From: Michael Oborne Date: Thu, 30 Aug 2012 20:51:29 +0800 Subject: [PATCH] Mission Planner 1.2.10 add useritems to HUD change hdop scale fix posible follow me bug (, vs .) fix posible friendly params bug (, vs .) tweak flightdata log playback timming fix gridv2 bug. if no waypoint had been done, the grid wold fail tweak some mission upload potential issues add ability to get param list from a log (from startup) add ability to get the first wp list in a log, if wps where received in that log. tweak video capture library timing --- Tools/ArdupilotMegaPlanner/Controls/HUD.cs | 37 +- .../Controls/QuickView.Designer.cs | 12 +- .../Controls/QuickView.cs | 13 +- Tools/ArdupilotMegaPlanner/CurrentState.cs | 2 +- Tools/ArdupilotMegaPlanner/FollowMe.cs | 5 +- .../ConfigurationView/ConfigFriendlyParams.cs | 2 +- .../GCSViews/FlightData.Designer.cs | 20 +- .../GCSViews/FlightData.cs | 179 ++++++++- .../GCSViews/FlightData.resx | 136 ++++--- .../GCSViews/FlightPlanner.cs | 11 +- Tools/ArdupilotMegaPlanner/MainV2.cs | 49 +-- Tools/ArdupilotMegaPlanner/Mavlink/MAVLink.cs | 10 +- .../MavlinkLog.Designer.cs | 20 + Tools/ArdupilotMegaPlanner/MavlinkLog.cs | 144 +++++++ Tools/ArdupilotMegaPlanner/MavlinkLog.resx | 94 ++++- Tools/ArdupilotMegaPlanner/Msi/installer.wxs | 350 +++++++++--------- .../Properties/AssemblyInfo.cs | 2 +- .../ArdupilotMegaPlanner/Utilities/Capture.cs | 55 ++- .../Utilities/CaptureMJPEG.cs | 3 + Tools/ArdupilotMegaPlanner/temp.cs | 4 +- 20 files changed, 827 insertions(+), 321 deletions(-) diff --git a/Tools/ArdupilotMegaPlanner/Controls/HUD.cs b/Tools/ArdupilotMegaPlanner/Controls/HUD.cs index 66b8600655..33f1ae38ec 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/HUD.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/HUD.cs @@ -7,7 +7,7 @@ using System.Text; using System.Windows.Forms; using System.IO; using System.Drawing.Imaging; - +using System.Collections; using System.Threading; using System.Drawing.Drawing2D; @@ -88,6 +88,7 @@ namespace ArdupilotMega.Controls float _airspeed = 0; float _targetspeed = 0; float _batterylevel = 0; + float _current = 0; float _batteryremaining = 0; float _gpsfix = 0; float _gpshdop = 0; @@ -128,6 +129,8 @@ namespace ArdupilotMega.Controls [System.ComponentModel.Browsable(true), System.ComponentModel.Category("Values")] public float batteryremaining { get { return _batteryremaining; } set { if (_batteryremaining != value) { _batteryremaining = value; this.Invalidate(); } } } [System.ComponentModel.Browsable(true), System.ComponentModel.Category("Values")] + public float current { get { return _current; } set { if (_current != value) { _current = value; this.Invalidate(); } } } + [System.ComponentModel.Browsable(true), System.ComponentModel.Category("Values")] public float gpsfix { get { return _gpsfix; } set { if (_gpsfix != value) { _gpsfix = value; this.Invalidate(); } } } [System.ComponentModel.Browsable(true), System.ComponentModel.Category("Values")] public float gpshdop { get { return _gpshdop; } set { if (_gpshdop != value) { _gpshdop = value; this.Invalidate(); } } } @@ -155,6 +158,17 @@ namespace ArdupilotMega.Controls [System.ComponentModel.Browsable(true), System.ComponentModel.Category("Values")] public int status { get; set; } + + public struct Custom + { + //public Point Position; + //public float FontSize; + public string Header; + public System.Reflection.PropertyInfo Item; + public float GetValue { get { return (float)Item.GetValue((object)MainV2.cs, null); } } + } + + public Hashtable CustomItems = new Hashtable(); int statuslast = 0; DateTime armedtimer = DateTime.MinValue; @@ -353,8 +367,8 @@ namespace ArdupilotMega.Controls { countdate = DateTime.Now; Console.WriteLine("HUD " + count + " hz drawtime " + (huddrawtime / count) + " gl " + opengl); - if ((huddrawtime / count) > 1000) - opengl = false; + // if ((huddrawtime / count) > 1000) + // opengl = false; count = 0; huddrawtime = 0; @@ -1373,7 +1387,7 @@ namespace ArdupilotMega.Controls drawstring(graphicsObject, "Bat", font, fontsize + 2, whiteBrush, fontsize, this.Height - 30 - fontoffset); drawstring(graphicsObject, _batterylevel.ToString("0.00v"), font, fontsize + 2, whiteBrush, fontsize * 4, this.Height - 30 - fontoffset); - drawstring(graphicsObject, _batteryremaining.ToString("0%"), font, fontsize + 2, whiteBrush, fontsize * 9, this.Height - 30 - fontoffset); + drawstring(graphicsObject, _current.ToString("0 A"), font, fontsize + 2, whiteBrush, fontsize * 9, this.Height - 30 - fontoffset); } // gps @@ -1402,6 +1416,21 @@ namespace ArdupilotMega.Controls if (isNaN) drawstring(graphicsObject, "NaN Error " + DateTime.Now, font, this.Height / 30 + 10, Brushes.Red, 50, 50); + // custom user items + graphicsObject.ResetTransform(); + int height = this.Height - 30 - fontoffset - fontsize - 8; + foreach (string key in CustomItems.Keys) + { + try + { + Custom item = (Custom)CustomItems[key]; + drawstring(graphicsObject, item.Header + item.GetValue.ToString("0.##"), font, fontsize + 2, whiteBrush, this.Width / 8, height); + height -= fontsize+5; + } + catch { } + + } + if (!opengl) { diff --git a/Tools/ArdupilotMegaPlanner/Controls/QuickView.Designer.cs b/Tools/ArdupilotMegaPlanner/Controls/QuickView.Designer.cs index 63a734a0c6..38991fb957 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/QuickView.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/QuickView.Designer.cs @@ -36,22 +36,24 @@ // // labelWithPseudoOpacity1 // + this.labelWithPseudoOpacity1.AutoSize = true; this.labelWithPseudoOpacity1.Dock = System.Windows.Forms.DockStyle.Fill; this.labelWithPseudoOpacity1.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.labelWithPseudoOpacity1.Location = new System.Drawing.Point(3, 0); this.labelWithPseudoOpacity1.Name = "labelWithPseudoOpacity1"; - this.labelWithPseudoOpacity1.Size = new System.Drawing.Size(161, 55); + this.labelWithPseudoOpacity1.Size = new System.Drawing.Size(161, 50); this.labelWithPseudoOpacity1.TabIndex = 0; this.labelWithPseudoOpacity1.Text = "Altitude:"; this.labelWithPseudoOpacity1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // labelWithPseudoOpacity2 // + this.labelWithPseudoOpacity2.AutoSize = true; this.labelWithPseudoOpacity2.Dock = System.Windows.Forms.DockStyle.Fill; this.labelWithPseudoOpacity2.Font = new System.Drawing.Font("Microsoft Sans Serif", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.labelWithPseudoOpacity2.Location = new System.Drawing.Point(170, 0); this.labelWithPseudoOpacity2.Name = "labelWithPseudoOpacity2"; - this.labelWithPseudoOpacity2.Size = new System.Drawing.Size(162, 55); + this.labelWithPseudoOpacity2.Size = new System.Drawing.Size(162, 50); this.labelWithPseudoOpacity2.TabIndex = 1; this.labelWithPseudoOpacity2.Text = "0.0"; this.labelWithPseudoOpacity2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -68,7 +70,7 @@ this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 1; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(335, 55); + this.tableLayoutPanel1.Size = new System.Drawing.Size(335, 50); this.tableLayoutPanel1.TabIndex = 2; // // QuickView @@ -76,9 +78,11 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.tableLayoutPanel1); + this.MinimumSize = new System.Drawing.Size(100, 27); this.Name = "QuickView"; - this.Size = new System.Drawing.Size(335, 55); + this.Size = new System.Drawing.Size(335, 50); this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); this.ResumeLayout(false); } diff --git a/Tools/ArdupilotMegaPlanner/Controls/QuickView.cs b/Tools/ArdupilotMegaPlanner/Controls/QuickView.cs index 4d7d89fd0e..78295aae74 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/QuickView.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/QuickView.cs @@ -12,11 +12,11 @@ namespace ArdupilotMega.Controls public partial class QuickView : UserControl { [System.ComponentModel.Browsable(true)] - public string desc { get { return labelWithPseudoOpacity1.Text; } set { labelWithPseudoOpacity1.Text = value; } } + public string desc { get { return labelWithPseudoOpacity1.Text; } set { if (labelWithPseudoOpacity1.Text == value) return; labelWithPseudoOpacity1.Text = value; } } [System.ComponentModel.Browsable(true)] - public string number { get { return labelWithPseudoOpacity2.Text; } set { labelWithPseudoOpacity2.Text = value; } } + public string number { get { return labelWithPseudoOpacity2.Text; } set { if (labelWithPseudoOpacity2.Text == value) return; labelWithPseudoOpacity2.Text = value; } } [System.ComponentModel.Browsable(true)] - public Color numberColor { get { return labelWithPseudoOpacity2.ForeColor; } set { labelWithPseudoOpacity2.ForeColor = value; } } + public Color numberColor { get { return labelWithPseudoOpacity2.ForeColor; } set { if (labelWithPseudoOpacity2.ForeColor == value) return; labelWithPseudoOpacity2.ForeColor = value; } } public QuickView() { @@ -54,5 +54,12 @@ namespace ArdupilotMega.Controls base.OnPaint(e); } + protected override void OnResize(EventArgs e) + { + if (this.Height > 20) + labelWithPseudoOpacity2.Font = new Font(labelWithPseudoOpacity2.Font.FontFamily, this.Height * 0.7f); + + base.OnResize(e); + } } } diff --git a/Tools/ArdupilotMegaPlanner/CurrentState.cs b/Tools/ArdupilotMegaPlanner/CurrentState.cs index b2a964f9b5..8d921b06aa 100644 --- a/Tools/ArdupilotMegaPlanner/CurrentState.cs +++ b/Tools/ArdupilotMegaPlanner/CurrentState.cs @@ -780,7 +780,7 @@ namespace ArdupilotMega gpsstatus = gps.fix_type; // Console.WriteLine("gpsfix {0}",gpsstatus); - gpshdop = (float)Math.Round((double)gps.eph / 10.0,2); + gpshdop = (float)Math.Round((double)gps.eph / 100.0,2); satcount = gps.satellites_visible; diff --git a/Tools/ArdupilotMegaPlanner/FollowMe.cs b/Tools/ArdupilotMegaPlanner/FollowMe.cs index 63e7525890..f8f257ae8d 100644 --- a/Tools/ArdupilotMegaPlanner/FollowMe.cs +++ b/Tools/ArdupilotMegaPlanner/FollowMe.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; using System.IO.Ports; +using System.Globalization; namespace ArdupilotMega { @@ -113,14 +114,14 @@ namespace ArdupilotMega continue; } - gotolocation.Lat = double.Parse(items[2]) / 100.0; + gotolocation.Lat = double.Parse(items[2], CultureInfo.InvariantCulture) / 100.0; gotolocation.Lat = (int)gotolocation.Lat + ((gotolocation.Lat - (int)gotolocation.Lat) / 0.60); if (items[3] == "S") gotolocation.Lat *= -1; - gotolocation.Lng = double.Parse(items[4]) / 100.0; + gotolocation.Lng = double.Parse(items[4], CultureInfo.InvariantCulture) / 100.0; gotolocation.Lng = (int)gotolocation.Lng + ((gotolocation.Lng - (int)gotolocation.Lng) / 0.60); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFriendlyParams.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFriendlyParams.cs index cf470e7920..3e867c616d 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFriendlyParams.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFriendlyParams.cs @@ -208,7 +208,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView { bool controlAdded = false; - string value = ((float)MainV2.comPort.param[x.Key]).ToString("0.###"); + string value = ((float)MainV2.comPort.param[x.Key]).ToString("0.###", CultureInfo.InvariantCulture); string description = _parameterMetaDataRepository.GetParameterMetaData(x.Key, ParameterMetaDataConstants.Description); string displayName = x.Value + " (" + x.Key + ")"; string units = _parameterMetaDataRepository.GetParameterMetaData(x.Key, ParameterMetaDataConstants.Units); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.Designer.cs index d47d041064..244ce4bcae 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.Designer.cs @@ -24,6 +24,7 @@ this.setMJPEGSourceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.setAspectRatioToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.displayBatteryInfoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.userItemsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabQuick = new System.Windows.Forms.TabPage(); @@ -181,10 +182,12 @@ this.hud1.batterylevel = 0F; this.hud1.batteryremaining = 0F; this.hud1.ContextMenuStrip = this.contextMenuStrip2; + this.hud1.current = 0F; this.hud1.DataBindings.Add(new System.Windows.Forms.Binding("airspeed", this.bindingSource1, "airspeed", true)); this.hud1.DataBindings.Add(new System.Windows.Forms.Binding("alt", this.bindingSource1, "alt", true)); this.hud1.DataBindings.Add(new System.Windows.Forms.Binding("batterylevel", this.bindingSource1, "battery_voltage", true)); this.hud1.DataBindings.Add(new System.Windows.Forms.Binding("batteryremaining", this.bindingSource1, "battery_remaining", true)); + this.hud1.DataBindings.Add(new System.Windows.Forms.Binding("current", this.bindingSource1, "current", true)); this.hud1.DataBindings.Add(new System.Windows.Forms.Binding("datetime", this.bindingSource1, "datetime", true)); this.hud1.DataBindings.Add(new System.Windows.Forms.Binding("disttowp", this.bindingSource1, "wp_dist", true)); this.hud1.DataBindings.Add(new System.Windows.Forms.Binding("gpsfix", this.bindingSource1, "gpsstatus", true)); @@ -244,7 +247,8 @@ this.stopRecordToolStripMenuItem, this.setMJPEGSourceToolStripMenuItem, this.setAspectRatioToolStripMenuItem, - this.displayBatteryInfoToolStripMenuItem}); + this.displayBatteryInfoToolStripMenuItem, + this.userItemsToolStripMenuItem}); this.contextMenuStrip2.Name = "contextMenuStrip2"; resources.ApplyResources(this.contextMenuStrip2, "contextMenuStrip2"); // @@ -278,6 +282,12 @@ resources.ApplyResources(this.displayBatteryInfoToolStripMenuItem, "displayBatteryInfoToolStripMenuItem"); this.displayBatteryInfoToolStripMenuItem.Click += new System.EventHandler(this.displayBatteryInfoToolStripMenuItem_Click); // + // userItemsToolStripMenuItem + // + this.userItemsToolStripMenuItem.Name = "userItemsToolStripMenuItem"; + resources.ApplyResources(this.userItemsToolStripMenuItem, "userItemsToolStripMenuItem"); + this.userItemsToolStripMenuItem.Click += new System.EventHandler(this.hud_UserItem); + // // bindingSource1 // this.bindingSource1.DataSource = typeof(ArdupilotMega.CurrentState); @@ -306,12 +316,14 @@ this.tabQuick.Controls.Add(this.quickView1); this.tabQuick.Name = "tabQuick"; this.tabQuick.UseVisualStyleBackColor = true; + this.tabQuick.Resize += new System.EventHandler(this.tabQuick_Resize); // // quickView6 // this.quickView6.DataBindings.Add(new System.Windows.Forms.Binding("number", this.bindingSource1, "DistToMAV", true)); this.quickView6.desc = "DistToMAV"; resources.ApplyResources(this.quickView6, "quickView6"); + this.quickView6.MinimumSize = new System.Drawing.Size(100, 27); this.quickView6.Name = "quickView6"; this.quickView6.number = "0.0"; this.quickView6.numberColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(252))))); @@ -322,6 +334,7 @@ this.quickView5.DataBindings.Add(new System.Windows.Forms.Binding("number", this.bindingSource1, "verticalspeed", true)); this.quickView5.desc = "verticalspeed"; resources.ApplyResources(this.quickView5, "quickView5"); + this.quickView5.MinimumSize = new System.Drawing.Size(100, 27); this.quickView5.Name = "quickView5"; this.quickView5.number = "0.0"; this.quickView5.numberColor = System.Drawing.Color.FromArgb(((int)(((byte)(254)))), ((int)(((byte)(254)))), ((int)(((byte)(86))))); @@ -332,6 +345,7 @@ this.quickView4.DataBindings.Add(new System.Windows.Forms.Binding("number", this.bindingSource1, "yaw", true)); this.quickView4.desc = "yaw"; resources.ApplyResources(this.quickView4, "quickView4"); + this.quickView4.MinimumSize = new System.Drawing.Size(100, 27); this.quickView4.Name = "quickView4"; this.quickView4.number = "0.0"; this.quickView4.numberColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(83))))); @@ -342,6 +356,7 @@ this.quickView3.DataBindings.Add(new System.Windows.Forms.Binding("number", this.bindingSource1, "wp_dist", true)); this.quickView3.desc = "wp_dist"; resources.ApplyResources(this.quickView3, "quickView3"); + this.quickView3.MinimumSize = new System.Drawing.Size(100, 27); this.quickView3.Name = "quickView3"; this.quickView3.number = "0.0"; this.quickView3.numberColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(96)))), ((int)(((byte)(91))))); @@ -352,6 +367,7 @@ this.quickView2.DataBindings.Add(new System.Windows.Forms.Binding("number", this.bindingSource1, "groundspeed", true)); this.quickView2.desc = "groundspeed"; resources.ApplyResources(this.quickView2, "quickView2"); + this.quickView2.MinimumSize = new System.Drawing.Size(100, 27); this.quickView2.Name = "quickView2"; this.quickView2.number = "0.0"; this.quickView2.numberColor = System.Drawing.Color.FromArgb(((int)(((byte)(254)))), ((int)(((byte)(132)))), ((int)(((byte)(46))))); @@ -362,6 +378,7 @@ this.quickView1.DataBindings.Add(new System.Windows.Forms.Binding("number", this.bindingSource1, "alt", true)); this.quickView1.desc = "alt"; resources.ApplyResources(this.quickView1, "quickView1"); + this.quickView1.MinimumSize = new System.Drawing.Size(100, 27); this.quickView1.Name = "quickView1"; this.quickView1.number = "0.0"; this.quickView1.numberColor = System.Drawing.Color.FromArgb(((int)(((byte)(209)))), ((int)(((byte)(151)))), ((int)(((byte)(248))))); @@ -1367,5 +1384,6 @@ private Controls.QuickView quickView5; private System.Windows.Forms.ToolStripMenuItem flyToHereAltToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem flightPlannerToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem userItemsToolStripMenuItem; } } \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs index 95a5d309aa..300bea53d2 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs @@ -312,6 +312,12 @@ namespace ArdupilotMega.GCSViews DateTime waypoints = DateTime.Now.AddSeconds(0); + DateTime updatescreen = DateTime.Now; + + DateTime tsreal = DateTime.Now; + double taketime = 0; + double timeerror = 0; + //comPort.stopall(true); while (threadrun == 1) @@ -370,8 +376,6 @@ namespace ArdupilotMega.GCSViews { if (threadrun == 0) { return; } - updatePlayPauseButton(true); - if (comPort.BaseStream.IsOpen) { MainV2.comPort.logreadmode = false; @@ -379,6 +383,18 @@ namespace ArdupilotMega.GCSViews MainV2.comPort.logplaybackfile = null; } + + //Console.WriteLine(DateTime.Now.Millisecond); + + if (updatescreen.AddMilliseconds(300) < DateTime.Now) + { + updatePlayPauseButton(true); + updateLogPlayPosition(); + updatescreen = DateTime.Now; + } + + //Console.WriteLine(DateTime.Now.Millisecond + " done "); + DateTime logplayback = MainV2.comPort.lastlogread; try { @@ -386,23 +402,45 @@ namespace ArdupilotMega.GCSViews } catch { } - updateLogPlayPosition(); - - int act = (int)(MainV2.comPort.lastlogread - logplayback).TotalMilliseconds; + double act = (MainV2.comPort.lastlogread - logplayback).TotalMilliseconds; if (act > 9999 || act < 0) act = 0; - int ts = 0; + double ts = 0; if (LogPlayBackSpeed == 0) LogPlayBackSpeed = 0.01; try { - ts = (int) Math.Min((act / LogPlayBackSpeed),1000); + ts = Math.Min((act / LogPlayBackSpeed),1000); } catch { } - if (ts > 0) - System.Threading.Thread.Sleep(ts); + + double timetook = (DateTime.Now - tsreal).TotalMilliseconds; + if (timetook != 0) + { + //Console.WriteLine("took: " + timetook + "=" + taketime + " " + (taketime - timetook) + " " + ts); + //Console.WriteLine(MainV2.comPort.lastlogread.Second + " " + DateTime.Now.Second + " " + (MainV2.comPort.lastlogread.Second - DateTime.Now.Second)); + //if ((taketime - timetook) < 0) + { + timeerror += (taketime - timetook); + if (ts != 0) + { + ts += timeerror; + timeerror = 0; + } + } + if (ts > 1000) + ts = 1000; + } + + taketime = ts; + tsreal = DateTime.Now; + + if (ts > 0 && ts < 1000) + System.Threading.Thread.Sleep((int)ts); + + if (threadrun == 0) { return; } @@ -415,6 +453,8 @@ namespace ArdupilotMega.GCSViews tunning = DateTime.Now; } + + if (MainV2.comPort.logplaybackfile != null && MainV2.comPort.logplaybackfile.BaseStream.Position == MainV2.comPort.logplaybackfile.BaseStream.Length) { MainV2.comPort.logreadmode = false; @@ -437,9 +477,9 @@ namespace ArdupilotMega.GCSViews try { - //Console.WriteLine(DateTime.Now.Millisecond); + // Console.WriteLine(DateTime.Now.Millisecond); updateBindingSource(); - //Console.WriteLine(DateTime.Now.Millisecond + " done "); + // Console.WriteLine(DateTime.Now.Millisecond + " done "); if (ArdupilotMega.Controls.OpenGLtest.instance != null) { @@ -700,7 +740,7 @@ namespace ArdupilotMega.GCSViews try { gMapControl1.Position = currentloc; - hud1.Refresh(); + //hud1.Refresh(); } catch { } }); @@ -1548,6 +1588,17 @@ namespace ArdupilotMega.GCSViews // temp.Dispose(); // tabStatus.Controls.Remove(temp); } + + if (tabControl1.SelectedTab == tabQuick) + { + int height = tabQuick.Height / 6; + quickView1.Size = new System.Drawing.Size(tabQuick.Width, height); + quickView2.Size = new System.Drawing.Size(tabQuick.Width, height); + quickView3.Size = new System.Drawing.Size(tabQuick.Width, height); + quickView4.Size = new System.Drawing.Size(tabQuick.Width, height); + quickView5.Size = new System.Drawing.Size(tabQuick.Width, height); + quickView6.Size = new System.Drawing.Size(tabQuick.Width, height); + } } } @@ -1693,6 +1744,103 @@ namespace ArdupilotMega.GCSViews selectform.Show(); } + private void hud_UserItem(object sender, EventArgs e) + { + + Form selectform = new Form() + { + Name = "select", + Width = 50, + Height = 250, + Text = "Display This" + }; + + int x = 10; + int y = 10; + + object thisBoxed = MainV2.cs; + Type test = thisBoxed.GetType(); + + foreach (var field in test.GetProperties()) + { + // field.Name has the field's name. + object fieldValue; + try + { + fieldValue = field.GetValue(thisBoxed, null); // Get value + } + catch { continue; } + + // Get the TypeCode enumeration. Multiple types get mapped to a common typecode. + TypeCode typeCode = Type.GetTypeCode(fieldValue.GetType()); + + if (!(typeCode == TypeCode.Single)) + continue; + + CheckBox chk_box = new CheckBox(); + + chk_box.Text = field.Name; + chk_box.Name = field.Name; + chk_box.Tag = (sender); + chk_box.Location = new Point(x, y); + chk_box.Size = new System.Drawing.Size(100, 20); + if (hud1.CustomItems.ContainsKey(field.Name)) + { + chk_box.Checked = true; + } + + chk_box.CheckedChanged += chk_box_hud_UserItem_CheckedChanged; + + selectform.Controls.Add(chk_box); + + Application.DoEvents(); + + x += 0; + y += 20; + + if (y > selectform.Height - 50) + { + x += 100; + y = 10; + + selectform.Width = x + 100; + } + } + ThemeManager.ApplyThemeTo(selectform); + selectform.Show(); + } + + void chk_box_hud_UserItem_CheckedChanged(object sender, EventArgs e) + { + if (((CheckBox)sender).Checked) + { + HUD.Custom cust = new HUD.Custom(); + + string prefix = ((CheckBox)sender).Name +": "; + if (MainV2.config["hud1_useritem_" + ((CheckBox)sender).Name] != null) + prefix = (string)MainV2.config["hud1_useritem_" + ((CheckBox)sender).Name]; + + Common.InputBox("Header", "Please enter your item prefix", ref prefix); + + MainV2.config["hud1_useritem_" + ((CheckBox)sender).Name] = prefix; + + cust.Header = prefix; + setupPropertyInfo(ref cust.Item, ((CheckBox)sender).Name, MainV2.cs); + + hud1.CustomItems.Add(((CheckBox)sender).Name, cust); + + hud1.Invalidate(); + } + else + { + if (hud1.CustomItems.ContainsKey(((CheckBox)sender).Name)) + { + hud1.CustomItems.Remove(((CheckBox)sender).Name); + } + hud1.Invalidate(); + } + } + void chk_log_CheckedChanged(object sender, EventArgs e) { if (((CheckBox)sender).Checked) @@ -1974,7 +2122,7 @@ print 'Roll complete' "; - CustomMessageBox.Show("This is Very ALPHA"); + // CustomMessageBox.Show("This is Very ALPHA"); Form scriptedit = new Form(); @@ -2231,5 +2379,10 @@ print 'Roll complete' ctl.Visible = true; } } + + private void tabQuick_Resize(object sender, EventArgs e) + { + tabControl1_SelectedIndexChanged(null, null); + } } } \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.resx b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.resx index 43060ba5b9..a47e7e7ae7 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.resx +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.resx @@ -209,8 +209,14 @@ Display Battery Info + + 176, 22 + + + User Items + - 177, 114 + 177, 158 contextMenuStrip2 @@ -238,7 +244,7 @@ hud1 - ArdupilotMega.Controls.HUD, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.HUD, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null SubMainLeft.Panel1 @@ -261,11 +267,14 @@ True + + Top + - 33, 272 + 3, 278 - 335, 55 + 384, 55 5 @@ -274,7 +283,7 @@ quickView6 - ArdupilotMega.Controls.QuickView, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.QuickView, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabQuick @@ -282,11 +291,14 @@ 0 + + Top + - 33, 224 + 3, 223 - 335, 55 + 384, 55 4 @@ -295,7 +307,7 @@ quickView5 - ArdupilotMega.Controls.QuickView, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.QuickView, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabQuick @@ -303,11 +315,14 @@ 1 + + Top + - 33, 168 + 3, 168 - 335, 55 + 384, 55 3 @@ -316,7 +331,7 @@ quickView4 - ArdupilotMega.Controls.QuickView, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.QuickView, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabQuick @@ -324,11 +339,14 @@ 2 + + Top + - 33, 112 + 3, 113 - 335, 55 + 384, 55 2 @@ -337,7 +355,7 @@ quickView3 - ArdupilotMega.Controls.QuickView, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.QuickView, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabQuick @@ -345,11 +363,14 @@ 3 + + Top + - 33, 55 + 3, 58 - 335, 55 + 384, 55 1 @@ -358,7 +379,7 @@ quickView2 - ArdupilotMega.Controls.QuickView, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.QuickView, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabQuick @@ -366,11 +387,14 @@ 4 + + Top + - 33, 6 + 3, 3 - 335, 55 + 384, 55 0 @@ -379,7 +403,7 @@ quickView1 - ArdupilotMega.Controls.QuickView, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.QuickView, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabQuick @@ -433,7 +457,7 @@ BUT_script - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabActions @@ -466,7 +490,7 @@ BUT_joystick - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabActions @@ -496,7 +520,7 @@ BUT_quickmanual - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabActions @@ -526,7 +550,7 @@ BUT_quickrtl - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabActions @@ -556,7 +580,7 @@ BUT_quickauto - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabActions @@ -610,7 +634,7 @@ BUT_setwp - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabActions @@ -661,7 +685,7 @@ BUT_setmode - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabActions @@ -691,7 +715,7 @@ BUT_clear_track - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabActions @@ -742,7 +766,7 @@ BUT_Homealt - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabActions @@ -772,7 +796,7 @@ BUT_RAWSensor - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabActions @@ -802,7 +826,7 @@ BUTrestartmission - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabActions @@ -832,7 +856,7 @@ BUTactiondo - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabActions @@ -886,7 +910,7 @@ Gvspeed - AGaugeApp.AGauge, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + AGaugeApp.AGauge, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabGauges @@ -916,7 +940,7 @@ Gheading - ArdupilotMega.Controls.HSI, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.HSI, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabGauges @@ -946,7 +970,7 @@ Galt - AGaugeApp.AGauge, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + AGaugeApp.AGauge, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabGauges @@ -979,7 +1003,7 @@ Gspeed - AGaugeApp.AGauge, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + AGaugeApp.AGauge, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabGauges @@ -1063,7 +1087,7 @@ lbl_playbackspeed - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabTLogs @@ -1090,7 +1114,7 @@ lbl_logpercent - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabTLogs @@ -1117,7 +1141,7 @@ NUM_playbackspeed - ArdupilotMega.Controls.MyTrackBar, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyTrackBar, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabTLogs @@ -1144,7 +1168,7 @@ BUT_log2kml - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabTLogs @@ -1198,7 +1222,7 @@ BUT_playlog - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabTLogs @@ -1225,7 +1249,7 @@ BUT_loadtelem - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null tabTLogs @@ -1411,7 +1435,7 @@ lbl_winddir - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null splitContainer1.Panel2 @@ -1441,7 +1465,7 @@ lbl_windvel - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null splitContainer1.Panel2 @@ -1474,7 +1498,7 @@ lbl_hdop - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null splitContainer1.Panel2 @@ -1507,7 +1531,7 @@ lbl_sats - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null splitContainer1.Panel2 @@ -1679,7 +1703,7 @@ gMapControl1 - ArdupilotMega.Controls.myGMAP, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.myGMAP, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null splitContainer1.Panel2 @@ -1742,7 +1766,7 @@ TXT_lat - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null panel1 @@ -1799,7 +1823,7 @@ label1 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null panel1 @@ -1829,7 +1853,7 @@ TXT_long - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null panel1 @@ -1859,7 +1883,7 @@ TXT_alt - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null panel1 @@ -2060,7 +2084,7 @@ label6 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null $this @@ -2134,6 +2158,12 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + userItemsToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + bindingSource1 @@ -2168,6 +2198,6 @@ FlightData - System.Windows.Forms.MyUserControl, ArdupilotMegaPlanner10, Version=1.1.4621.15928, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.MyUserControl, ArdupilotMegaPlanner10, Version=1.1.4623.36046, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.cs b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.cs index 9037c4ef1c..fc73679c75 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.cs @@ -348,6 +348,8 @@ namespace ArdupilotMega.GCSViews selectedrow = Commands.Rows.Add(); // Commands.CurrentCell = Commands.Rows[selectedrow].Cells[Param1.Index]; + ChangeColumnHeader(MAVLink.MAV_CMD.WAYPOINT.ToString()); + setfromGE(lat, lng, alt); } @@ -1362,7 +1364,9 @@ namespace ArdupilotMega.GCSViews temp.p4 = (float)(double.Parse(Commands.Rows[a].Cells[Param4.Index].Value.ToString())); MAVLink.MAV_MISSION_RESULT ans = port.setWP(temp, (ushort)(a + 1), frame, 0); - if (ans != MAVLink.MAV_MISSION_RESULT.MAV_MISSION_ACCEPTED) + // invalid sequence can only occur if we failed to see a responce from the apm when we sent the request. + // therefore it did see the request and has moved on that step, and so do we. + if (ans != MAVLink.MAV_MISSION_RESULT.MAV_MISSION_ACCEPTED && ans != MAVLink.MAV_MISSION_RESULT.MAV_MISSION_INVALID_SEQUENCE) { throw new Exception("Upload WPs Failed " + Commands.Rows[a].Cells[Command.Index].Value.ToString() + " " + Enum.Parse(typeof(MAVLink.MAV_MISSION_RESULT), ans.ToString())); } @@ -1509,7 +1513,10 @@ namespace ArdupilotMega.GCSViews CHK_holdalt.Checked = Convert.ToBoolean((float)param["ALT_HOLD_RTL"] > 0); log.Info("param ALT_HOLD_RTL " + CHK_holdalt.Checked.ToString()); + } + catch (Exception ex) { log.Error(ex); } + try { DataGridViewTextBoxCell cellhome; cellhome = Commands.Rows[0].Cells[Lat.Index] as DataGridViewTextBoxCell; @@ -1530,7 +1537,7 @@ namespace ArdupilotMega.GCSViews } } } - catch (Exception ex) { log.Info(ex.ToString()); } // if there is no valid home + catch (Exception ex) { log.Error(ex.ToString()); } // if there is no valid home if (Commands.RowCount > 0) { diff --git a/Tools/ArdupilotMegaPlanner/MainV2.cs b/Tools/ArdupilotMegaPlanner/MainV2.cs index 5353948cf4..73d9b54298 100644 --- a/Tools/ArdupilotMegaPlanner/MainV2.cs +++ b/Tools/ArdupilotMegaPlanner/MainV2.cs @@ -149,6 +149,8 @@ namespace ArdupilotMega public MainV2() { + log.Info("Mainv2 ctor"); + Form splash = new Splash(); splash.Show(); @@ -1010,7 +1012,7 @@ namespace ArdupilotMega /// speech voltage - custom - alt warning - data lost /// heartbeat packet sending /// - /// and cant fall out + /// and can't fall out /// private void SerialReader() { @@ -1018,10 +1020,7 @@ namespace ArdupilotMega return; serialThread = true; - int minbytes = 10; - - // if (MONO) - // minbytes = 0; + int minbytes = 0; DateTime speechcustomtime = DateTime.Now; @@ -1033,8 +1032,10 @@ namespace ArdupilotMega { Thread.Sleep(5); + // update connect/disconnect button and info stats UpdateConnectIcon(); + // 30 seconds interval speech options if (speechEnable && speechEngine != null && (DateTime.Now - speechcustomtime).TotalSeconds > 30 && MainV2.cs.lat != 0 && (MainV2.comPort.logreadmode || comPort.BaseStream.IsOpen)) { //speechbatteryvolt @@ -1054,6 +1055,7 @@ namespace ArdupilotMega speechcustomtime = DateTime.Now; } + // speech altitude warning. if (speechEnable && speechEngine != null && (MainV2.comPort.logreadmode || comPort.BaseStream.IsOpen)) { float warnalt = float.MaxValue; @@ -1069,17 +1071,20 @@ namespace ArdupilotMega catch { } // silent fail } + // if not connected or busy, sleep and loop if (!comPort.BaseStream.IsOpen || giveComport == true) { System.Threading.Thread.Sleep(100); continue; } + // make sure we attenuate the link quality if we dont see any valid packets if ((DateTime.Now - comPort.lastvalidpacket).TotalSeconds > 10) { MainV2.cs.linkqualitygcs = 0; } + // attenuate the link qualty over time if ((DateTime.Now - comPort.lastvalidpacket).TotalSeconds >= 1) { if (linkqualitytime.Second != DateTime.Now.Second) @@ -1087,25 +1092,20 @@ namespace ArdupilotMega MainV2.cs.linkqualitygcs = (ushort)(MainV2.cs.linkqualitygcs * 0.8f); linkqualitytime = DateTime.Now; + int checkthis; GCSViews.FlightData.myhud.Invalidate(); } } + // send a hb every seconds from gcs to ap if (heatbeatSend.Second != DateTime.Now.Second) { - // Console.WriteLine("remote lost {0}", cs.packetdropremote); - - MAVLink.mavlink_heartbeat_t htb = new MAVLink.mavlink_heartbeat_t(); - -#if MAVLINK10 - htb.type = (byte)MAVLink.MAV_TYPE.GCS; - htb.autopilot = (byte)MAVLink.MAV_AUTOPILOT.ARDUPILOTMEGA; - htb.mavlink_version = 3; -#else - htb.type = (byte)MAVLink.MAV_TYPE.MAV_GENERIC; - htb.autopilot = (byte)MAVLink.MAV_AUTOPILOT_TYPE.MAV_AUTOPILOT_ARDUPILOTMEGA; - htb.mavlink_version = 2; -#endif + MAVLink.mavlink_heartbeat_t htb = new MAVLink.mavlink_heartbeat_t() + { + type = (byte)MAVLink.MAV_TYPE.GCS, + autopilot = (byte)MAVLink.MAV_AUTOPILOT.ARDUPILOTMEGA, + mavlink_version = 3 + }; comPort.sendPacket(htb); heatbeatSend = DateTime.Now; @@ -1121,15 +1121,11 @@ namespace ArdupilotMega } } - // Console.WriteLine(DateTime.Now.Millisecond + " " + comPort.BaseStream.BytesToRead); - + // actauly read the packets while (comPort.BaseStream.BytesToRead > minbytes && giveComport == false) { - //Console.WriteLine(DateTime.Now.Millisecond + " SR1 " + comPort.BaseStream.BytesToRead ); comPort.readPacket(); - //Console.WriteLine(DateTime.Now.Millisecond + " SR2 " + comPort.BaseStream.BytesToRead); } - // Console.WriteLine("SR left"); } catch (Exception e) { @@ -1245,7 +1241,12 @@ namespace ArdupilotMega { if (!System.Diagnostics.Debugger.IsAttached) { - CheckForUpdate(); + // single update check per day + if (getConfig("update_check") != DateTime.Now.ToShortDateString()) + { + CheckForUpdate(); + config["update_check"] = DateTime.Now.ToShortDateString(); + } } } catch (Exception ex) diff --git a/Tools/ArdupilotMegaPlanner/Mavlink/MAVLink.cs b/Tools/ArdupilotMegaPlanner/Mavlink/MAVLink.cs index b1bd912668..c93f913a5c 100644 --- a/Tools/ArdupilotMegaPlanner/Mavlink/MAVLink.cs +++ b/Tools/ArdupilotMegaPlanner/Mavlink/MAVLink.cs @@ -1345,7 +1345,7 @@ namespace ArdupilotMega } else { - log.Info(DateTime.Now + " PC wpcount " + buffer[5] + " need " + MAVLINK_MSG_ID_MISSION_COUNT + " " + this.BaseStream.BytesToRead); + log.Info(DateTime.Now + " PC wpcount " + buffer[5] + " need " + MAVLINK_MSG_ID_MISSION_COUNT); } } } @@ -1919,21 +1919,13 @@ namespace ArdupilotMega #if MAVLINK10 if (buffer[5] == MAVLINK_MSG_ID_MISSION_ACK) { - - var ans = buffer.ByteArrayToStructure(6); - - log.Info("set wp " + index + " ACK 47 : " + buffer[5] + " ans " + Enum.Parse(typeof(MAV_MISSION_RESULT), ans.type.ToString())); return (MAV_MISSION_RESULT)ans.type; } else if (buffer[5] == MAVLINK_MSG_ID_MISSION_REQUEST) { var ans = buffer.ByteArrayToStructure(6); - - - - if (ans.seq == (index + 1)) { log.Info("set wp doing " + index + " req " + ans.seq + " REQ 40 : " + buffer[5]); diff --git a/Tools/ArdupilotMegaPlanner/MavlinkLog.Designer.cs b/Tools/ArdupilotMegaPlanner/MavlinkLog.Designer.cs index 256cde8672..52243d5cad 100644 --- a/Tools/ArdupilotMegaPlanner/MavlinkLog.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/MavlinkLog.Designer.cs @@ -35,6 +35,8 @@ this.BUT_graphmavlog = new ArdupilotMega.Controls.MyButton(); this.zg1 = new ZedGraph.ZedGraphControl(); this.BUT_convertcsv = new ArdupilotMega.Controls.MyButton(); + this.BUT_paramsfromlog = new ArdupilotMega.Controls.MyButton(); + this.BUT_getwpsfromlog = new ArdupilotMega.Controls.MyButton(); this.SuspendLayout(); // // BUT_redokml @@ -82,10 +84,26 @@ this.BUT_convertcsv.UseVisualStyleBackColor = true; this.BUT_convertcsv.Click += new System.EventHandler(this.BUT_convertcsv_Click); // + // BUT_paramsfromlog + // + resources.ApplyResources(this.BUT_paramsfromlog, "BUT_paramsfromlog"); + this.BUT_paramsfromlog.Name = "BUT_paramsfromlog"; + this.BUT_paramsfromlog.UseVisualStyleBackColor = true; + this.BUT_paramsfromlog.Click += new System.EventHandler(this.BUT_paramsfromlog_Click); + // + // BUT_getwpsfromlog + // + resources.ApplyResources(this.BUT_getwpsfromlog, "BUT_getwpsfromlog"); + this.BUT_getwpsfromlog.Name = "BUT_getwpsfromlog"; + this.BUT_getwpsfromlog.UseVisualStyleBackColor = true; + this.BUT_getwpsfromlog.Click += new System.EventHandler(this.BUT_getwpsfromlog_Click); + // // MavlinkLog // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.BUT_getwpsfromlog); + this.Controls.Add(this.BUT_paramsfromlog); this.Controls.Add(this.BUT_convertcsv); this.Controls.Add(this.zg1); this.Controls.Add(this.BUT_graphmavlog); @@ -106,5 +124,7 @@ private ArdupilotMega.Controls.MyButton BUT_graphmavlog; private ZedGraph.ZedGraphControl zg1; private Controls.MyButton BUT_convertcsv; + private Controls.MyButton BUT_paramsfromlog; + private Controls.MyButton BUT_getwpsfromlog; } } \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/MavlinkLog.cs b/Tools/ArdupilotMegaPlanner/MavlinkLog.cs index 1df89ba445..d9e9478490 100644 --- a/Tools/ArdupilotMegaPlanner/MavlinkLog.cs +++ b/Tools/ArdupilotMegaPlanner/MavlinkLog.cs @@ -1245,5 +1245,149 @@ namespace ArdupilotMega } } } + + private void BUT_paramsfromlog_Click(object sender, EventArgs e) + { + OpenFileDialog openFileDialog1 = new OpenFileDialog(); + openFileDialog1.Filter = "*.tlog|*.tlog"; + openFileDialog1.FilterIndex = 2; + openFileDialog1.RestoreDirectory = true; + openFileDialog1.Multiselect = true; + try + { + openFileDialog1.InitialDirectory = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + @"logs" + Path.DirectorySeparatorChar; + } + catch { } // incase dir doesnt exist + + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + if (MainV2.comPort.logplaybackfile != null) + { + MainV2.comPort.logreadmode = false; + MainV2.comPort.logplaybackfile.Close(); + } + + foreach (string logfile in openFileDialog1.FileNames) + { + + MAVLink mine = new MAVLink(); + try + { + mine.logplaybackfile = new BinaryReader(File.Open(logfile, FileMode.Open, FileAccess.Read, FileShare.Read)); + } + catch (Exception ex) { log.Debug(ex.ToString()); CustomMessageBox.Show("Log Can not be opened. Are you still connected?"); return; } + + mine.logreadmode = true; + + mine.packets.Initialize(); // clear + + StreamWriter sw = new StreamWriter(Path.GetDirectoryName(logfile) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(logfile) + ".param"); + + // bar moves to 100 % in this step + progressBar1.Value = (int)((float)mine.logplaybackfile.BaseStream.Position / (float)mine.logplaybackfile.BaseStream.Length * 100.0f / 1.0f); + + progressBar1.Refresh(); + //Application.DoEvents(); + + mine.getParamList(); + + foreach (string item in mine.param.Keys) + { + sw.WriteLine(item + "\t" + mine.param[item]); + } + + sw.Close(); + + progressBar1.Value = 100; + + mine.logreadmode = false; + mine.logplaybackfile.Close(); + mine.logplaybackfile = null; + + CustomMessageBox.Show("File Saved with log file"); + } + } + } + + private void BUT_getwpsfromlog_Click(object sender, EventArgs e) + { + OpenFileDialog openFileDialog1 = new OpenFileDialog(); + openFileDialog1.Filter = "*.tlog|*.tlog"; + openFileDialog1.FilterIndex = 2; + openFileDialog1.RestoreDirectory = true; + openFileDialog1.Multiselect = true; + try + { + openFileDialog1.InitialDirectory = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + @"logs" + Path.DirectorySeparatorChar; + } + catch { } // incase dir doesnt exist + + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + if (MainV2.comPort.logplaybackfile != null) + { + MainV2.comPort.logreadmode = false; + MainV2.comPort.logplaybackfile.Close(); + } + + foreach (string logfile in openFileDialog1.FileNames) + { + + MAVLink mine = new MAVLink(); + try + { + mine.logplaybackfile = new BinaryReader(File.Open(logfile, FileMode.Open, FileAccess.Read, FileShare.Read)); + } + catch (Exception ex) { log.Debug(ex.ToString()); CustomMessageBox.Show("Log Can not be opened. Are you still connected?"); return; } + + mine.logreadmode = true; + + mine.packets.Initialize(); // clear + + StreamWriter sw = new StreamWriter(Path.GetDirectoryName(logfile) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(logfile) + ".txt"); + + // bar moves to 100 % in this step + progressBar1.Value = (int)((float)mine.logplaybackfile.BaseStream.Position / (float)mine.logplaybackfile.BaseStream.Length * 100.0f / 1.0f); + + progressBar1.Refresh(); + //Application.DoEvents(); + + sw.WriteLine("QGC WPL 110"); + + byte count = mine.getWPCount(); + for (ushort a = 0; a < count; a++) + { + Locationwp wp = mine.getWP(a); + //sw.WriteLine(item + "\t" + mine.param[item]); + byte mode = (byte)wp.id; + + sw.Write((a + 1)); // seq + sw.Write("\t" + 0); // current + sw.Write("\t" + (byte)MAVLink.MAV_FRAME.GLOBAL_RELATIVE_ALT); //frame + sw.Write("\t" + mode); + sw.Write("\t" + wp.p1.ToString("0.000000", new System.Globalization.CultureInfo("en-US"))); + sw.Write("\t" + wp.p2.ToString("0.000000", new System.Globalization.CultureInfo("en-US"))); + sw.Write("\t" + wp.p3.ToString("0.000000", new System.Globalization.CultureInfo("en-US"))); + sw.Write("\t" + wp.p4.ToString("0.000000", new System.Globalization.CultureInfo("en-US"))); + sw.Write("\t" + wp.lat.ToString("0.000000", new System.Globalization.CultureInfo("en-US"))); + sw.Write("\t" + wp.lng.ToString("0.000000", new System.Globalization.CultureInfo("en-US"))); + sw.Write("\t" + (wp.alt / MainV2.cs.multiplierdist).ToString("0.000000", new System.Globalization.CultureInfo("en-US"))); + sw.Write("\t" + 1); + sw.WriteLine(""); + } + + sw.Close(); + + progressBar1.Value = 100; + + mine.logreadmode = false; + mine.logplaybackfile.Close(); + mine.logplaybackfile = null; + + CustomMessageBox.Show("File Saved with log file"); + + } + } + } } } \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/MavlinkLog.resx b/Tools/ArdupilotMegaPlanner/MavlinkLog.resx index 11b80999a6..b72c69d081 100644 --- a/Tools/ArdupilotMegaPlanner/MavlinkLog.resx +++ b/Tools/ArdupilotMegaPlanner/MavlinkLog.resx @@ -123,10 +123,10 @@ - 93, 12 + 10, 6 - 116, 23 + 68, 30 @@ -139,13 +139,13 @@ BUT_redokml - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4515.21878, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4622.30215, Culture=neutral, PublicKeyToken=null $this - 5 + 7 Top, Left, Right @@ -169,7 +169,7 @@ $this - 4 + 6 Top @@ -178,10 +178,10 @@ NoControl - 215, 12 + 84, 6 - 116, 23 + 68, 30 10 @@ -193,13 +193,13 @@ BUT_humanreadable - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4515.21878, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4622.30215, Culture=neutral, PublicKeyToken=null $this - 3 + 5 Top @@ -208,10 +208,10 @@ NoControl - 459, 12 + 232, 6 - 116, 23 + 68, 30 11 @@ -223,13 +223,13 @@ BUT_graphmavlog - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4515.21878, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4622.30215, Culture=neutral, PublicKeyToken=null $this - 2 + 4 Top, Bottom, Left, Right @@ -253,7 +253,7 @@ $this - 1 + 3 Top @@ -262,10 +262,10 @@ NoControl - 337, 12 + 158, 6 - 116, 23 + 68, 30 13 @@ -277,12 +277,72 @@ BUT_convertcsv - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4515.21878, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4622.30215, Culture=neutral, PublicKeyToken=null $this + 2 + + + Top + + + NoControl + + + 306, 6 + + + 68, 30 + + + 14 + + + Extract Params + + + BUT_paramsfromlog + + + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4622.30215, Culture=neutral, PublicKeyToken=null + + + $this + + + 1 + + + Top + + + NoControl + + + 380, 6 + + + 68, 30 + + + 15 + + + Extract WPs + + + BUT_getwpsfromlog + + + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4622.30215, Culture=neutral, PublicKeyToken=null + + + $this + + 0 diff --git a/Tools/ArdupilotMegaPlanner/Msi/installer.wxs b/Tools/ArdupilotMegaPlanner/Msi/installer.wxs index 45acc75dcc..1de47d2ad8 100644 --- a/Tools/ArdupilotMegaPlanner/Msi/installer.wxs +++ b/Tools/ArdupilotMegaPlanner/Msi/installer.wxs @@ -2,14 +2,14 @@ - + - - + + @@ -31,7 +31,7 @@ - + @@ -54,203 +54,205 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + - - - - - + + + + + - - - - + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - + + + + - - - - - - - - - + + + + + + + + + - - - - - - - + + + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - - - - - - + + + + + + + - - - + + + - - - - + + + + - - - + + + - - - + + + - - - + + + @@ -294,26 +296,26 @@ - - - - - - - - - + + + + + + + + - - + + - + + diff --git a/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs b/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs index 49216dd913..73d7f09fbd 100644 --- a/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs +++ b/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs @@ -34,5 +34,5 @@ using System.Resources; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.1.*")] -[assembly: AssemblyFileVersion("1.2.9")] +[assembly: AssemblyFileVersion("1.2.10")] [assembly: NeutralResourcesLanguageAttribute("")] diff --git a/Tools/ArdupilotMegaPlanner/Utilities/Capture.cs b/Tools/ArdupilotMegaPlanner/Utilities/Capture.cs index 6d721dea65..e977a150a8 100644 --- a/Tools/ArdupilotMegaPlanner/Utilities/Capture.cs +++ b/Tools/ArdupilotMegaPlanner/Utilities/Capture.cs @@ -50,7 +50,7 @@ namespace WebCamService IntPtr ip = IntPtr.Zero; public event CamImage camimage; - System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer(); + Thread timer1; #endregion @@ -88,8 +88,12 @@ namespace WebCamService m_bGotOne = true; m_bRunning = false; - timer1.Interval = 1000 / 15; // 15 fps - timer1.Tick += new EventHandler(timer1_Tick); + //timer1.Interval = 1000 / 15; // 15 fps + //timer1.Tick += new EventHandler(timer1_Tick); + //timer1.Start(); + + timer1 = new Thread(timer); + timer1.IsBackground = true; timer1.Start(); } @@ -99,10 +103,37 @@ namespace WebCamService throw; } } + + void timer() + { + DateTime last = DateTime.Now; + + while (true) + { + try + { + System.Threading.Thread.Sleep(1000/25); // 25 fps + + timer1_Tick(this, null); + + } + catch (ThreadAbortException) + { + break; + } + catch + { + + } + } + } + /// release everything. public void Dispose() { - timer1.Stop(); + if (timer1 != null) + timer1.Abort(); + if (camimage != null) { camimage(null); // clear last pic @@ -159,7 +190,7 @@ namespace WebCamService // Start waiting if ( ! m_PictureReady.WaitOne(5000, false) ) { - throw new Exception("Timeout waiting to get picture"); + //throw new Exception("Timeout waiting to get picture"); } //Pause(); //- we are effectivly pulling at 15 fps, so no need to pause } @@ -224,8 +255,8 @@ namespace WebCamService { camimage(image); } - } - catch { Console.WriteLine("Grab bmp failed"); timer1.Enabled = false; this.CloseInterfaces(); System.Windows.Forms.CustomMessageBox.Show("Problem with capture device, grabbing frame took longer than 5 sec"); } + }//System.Windows.Forms.CustomMessageBox.Show("Problem with capture device, grabbing frame took longer than 5 sec"); + catch { Console.WriteLine("Grab bmp failed"); } } /// build the capture graph for grabber. @@ -404,8 +435,14 @@ namespace WebCamService } // Set the new format - hr = videoStreamConfig.SetFormat( media ); - DsError.ThrowExceptionForHR( hr ); + try + { + hr = videoStreamConfig.SetFormat(media); + } + catch { } + + DsError.ThrowExceptionForHR(hr); + DsUtils.FreeAMMediaType(media); media = null; diff --git a/Tools/ArdupilotMegaPlanner/Utilities/CaptureMJPEG.cs b/Tools/ArdupilotMegaPlanner/Utilities/CaptureMJPEG.cs index 915a4c9502..477867c592 100644 --- a/Tools/ArdupilotMegaPlanner/Utilities/CaptureMJPEG.cs +++ b/Tools/ArdupilotMegaPlanner/Utilities/CaptureMJPEG.cs @@ -110,6 +110,9 @@ namespace ArdupilotMega.Utilities mpheader = mpheader.Substring(startboundary, endboundary - startboundary); } + dataStream.ReadTimeout = 30000; // 30 seconds + br.BaseStream.ReadTimeout = 30000; + while (running) { try diff --git a/Tools/ArdupilotMegaPlanner/temp.cs b/Tools/ArdupilotMegaPlanner/temp.cs index 8df60453fb..1686e14479 100644 --- a/Tools/ArdupilotMegaPlanner/temp.cs +++ b/Tools/ArdupilotMegaPlanner/temp.cs @@ -903,8 +903,6 @@ namespace ArdupilotMega private void myButton1_Click(object sender, EventArgs e) { new SerialOutput2().Show(); - } - - + } } }