diff --git a/Tools/ArdupilotMegaPlanner/Antenna/Tracker.Designer.cs b/Tools/ArdupilotMegaPlanner/Antenna/Tracker.Designer.cs index 90eea7c0671..ef9c5d36ea7 100644 --- a/Tools/ArdupilotMegaPlanner/Antenna/Tracker.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/Antenna/Tracker.Designer.cs @@ -253,7 +253,6 @@ this.Controls.Add(this.label1); this.Controls.Add(this.CMB_interface); this.Name = "Tracker"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Tracker_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.TRK_pantrim)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.TRK_tilttrim)).EndInit(); this.ResumeLayout(false); diff --git a/Tools/ArdupilotMegaPlanner/Antenna/Tracker.cs b/Tools/ArdupilotMegaPlanner/Antenna/Tracker.cs index 5db7724fd17..8287d79f6a6 100644 --- a/Tools/ArdupilotMegaPlanner/Antenna/Tracker.cs +++ b/Tools/ArdupilotMegaPlanner/Antenna/Tracker.cs @@ -12,7 +12,7 @@ using ArdupilotMega.Utilities; namespace ArdupilotMega.Antenna { - public partial class Tracker : BackStageViewContentPanel + public partial class Tracker : UserControl, IDeactivate { System.Threading.Thread t12; static bool threadrun = false; @@ -217,7 +217,7 @@ namespace ArdupilotMega.Antenna } - private void Tracker_FormClosing(object sender, FormClosingEventArgs e) + public void Deactivate() { saveconfig(); } diff --git a/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj b/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj index 8581ec4862a..dbe1bbcf923 100644 --- a/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj +++ b/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj @@ -308,7 +308,6 @@ ConfigArdurover.cs - @@ -1208,6 +1207,8 @@ + + diff --git a/Tools/ArdupilotMegaPlanner/Common.cs b/Tools/ArdupilotMegaPlanner/Common.cs index d6f34ea45e5..6deb1096202 100644 --- a/Tools/ArdupilotMegaPlanner/Common.cs +++ b/Tools/ArdupilotMegaPlanner/Common.cs @@ -84,7 +84,7 @@ namespace ArdupilotMega // undo autochange in mouse over if (Pen.Color == Color.Blue) Pen.Color = Color.White; - + double width = (MainMap.Manager.GetDistance(MainMap.FromLocalToLatLng(0, 0), MainMap.FromLocalToLatLng(MainMap.Width, 0)) * 1000.0); double height = (MainMap.Manager.GetDistance(MainMap.FromLocalToLatLng(0, 0), MainMap.FromLocalToLatLng(MainMap.Height, 0)) * 1000.0); double m2pixelwidth = MainMap.Width / width; diff --git a/Tools/ArdupilotMegaPlanner/Comms/CommsSerialPort.cs b/Tools/ArdupilotMegaPlanner/Comms/CommsSerialPort.cs index 5685593422c..41088c0211c 100644 --- a/Tools/ArdupilotMegaPlanner/Comms/CommsSerialPort.cs +++ b/Tools/ArdupilotMegaPlanner/Comms/CommsSerialPort.cs @@ -48,6 +48,7 @@ namespace ArdupilotMega.Comms allPorts.AddRange(Directory.GetFiles("/dev/serial/by-id/", "*")); allPorts.AddRange(Directory.GetFiles("/dev/", "ttyACM*")); allPorts.AddRange(Directory.GetFiles("/dev/", "ttyUSB*")); + allPorts.AddRange(Directory.GetFiles("/dev/", "rfcomm*")); } string[] ports = System.IO.Ports.SerialPort.GetPortNames() diff --git a/Tools/ArdupilotMegaPlanner/Controls/AGauge.cs b/Tools/ArdupilotMegaPlanner/Controls/AGauge.cs index 9221e63906c..6caed494153 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/AGauge.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/AGauge.cs @@ -1410,6 +1410,8 @@ System.ComponentModel.Description("Enables or disables the range selected by Nee } } + + #endregion #region helper @@ -1471,22 +1473,37 @@ System.ComponentModel.Description("Enables or disables the range selected by Nee } #endregion + /// + /// Override to prevent offscreen drawing the control - mono mac + /// + public new void Invalidate() + { + if (!ThisReallyVisible()) + { + return; + } + + base.Invalidate(); + } + + public override void Refresh() + { + base.Refresh(); + } + /// /// this is to fix a mono off screen drawing issue /// /// public bool ThisReallyVisible() { - if (Parent != null) - return this.Bounds.IntersectsWith(Parent.ClientRectangle); - - return true; + Control ctl = Control.FromHandle(this.Handle); + return ctl.Visible; } #region base member overrides protected override void OnPaintBackground(PaintEventArgs pevent) { - base.OnPaintBackground(pevent); } protected override void OnPaint(PaintEventArgs pe) @@ -1497,9 +1514,11 @@ System.ComponentModel.Description("Enables or disables the range selected by Nee } if (!ThisReallyVisible()) + { + Console.WriteLine(this.Visible); + base.OnPaint(pe); return; - - base.OnPaint(pe); + } float scale = 1; diff --git a/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackStageViewContentPanel.cs b/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackStageViewContentPanel.cs index c74b8a3dd9b..b9c41fb8fed 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackStageViewContentPanel.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackStageViewContentPanel.cs @@ -5,7 +5,31 @@ using System.Windows.Forms; namespace ArdupilotMega.Controls.BackstageView { - public class BackStageViewContentPanel : UserControl + /// + /// The implementor executes some logic on activation, for e.g when moving + /// from not selected to selected in a tab control + /// + public interface IActivate + { + // Should be idempotent + void Activate(); + } + + /// + /// The implementor executes some logic on deactivation, for e.g when moving + /// from selected to not selected in a tab control + /// + public interface IDeactivate + { + // Should be idempotent + void Deactivate(); + } + + /// + /// Base class for user controls that wish to participate as a backstage view + /// + [Obsolete("This doesn't do much any more, and should be replaced by indicating lifecycle features with IActivate etc")] + public class BackStageViewContentPanel : UserControl, IActivate, IDeactivate { public event FormClosingEventHandler FormClosing; @@ -25,5 +49,15 @@ namespace ArdupilotMega.Controls.BackstageView // this is now done on page load via parent control // base.OnLoad(e); } + + public void Activate() + { + DoLoad(EventArgs.Empty); + } + + public void Deactivate() + { + Close(); + } } } diff --git a/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackstageView.Designer.cs b/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackstageView.Designer.cs index 66d11286360..1b741e1086a 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackstageView.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackstageView.Designer.cs @@ -37,10 +37,10 @@ this.pnlPages.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.pnlPages.Location = new System.Drawing.Point(150, 0); + this.pnlPages.Location = new System.Drawing.Point(152, 0); this.pnlPages.MinimumSize = new System.Drawing.Size(100, 0); this.pnlPages.Name = "pnlPages"; - this.pnlPages.Size = new System.Drawing.Size(297, 192); + this.pnlPages.Size = new System.Drawing.Size(291, 192); this.pnlPages.TabIndex = 0; // // pnlMenu @@ -49,7 +49,7 @@ | System.Windows.Forms.AnchorStyles.Left))); this.pnlMenu.Location = new System.Drawing.Point(0, 0); this.pnlMenu.Name = "pnlMenu"; - this.pnlMenu.Size = new System.Drawing.Size(150, 192); + this.pnlMenu.Size = new System.Drawing.Size(152, 192); this.pnlMenu.TabIndex = 1; // // BackstageView diff --git a/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackstageView.cs b/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackstageView.cs index 1ae5b2bc97f..2514a968682 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackstageView.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackstageView.cs @@ -9,6 +9,12 @@ using ArdupilotMega.Utilities; namespace ArdupilotMega.Controls.BackstageView { + /// + /// A Control to somewhat emulate the 'backstage view' as in MS Office 2010 + /// + /// + /// 'Tabs' are added as a control in a + /// public partial class BackstageView : UserControl { private Color _buttonsAreaBgColor = Color.White; @@ -18,13 +24,14 @@ namespace ArdupilotMega.Controls.BackstageView private Color _highlightColor1 = Color.DarkBlue; private Color _highlightColor2 = Color.Blue; - private readonly List _pages= new List(); + private readonly List _items = new List(); private BackstageViewPage _activePage; private const int ButtonSpacing = 30; private const int ButtonHeight = 30; public BackstageViewPage SelectedPage { get { return _activePage; } } - public List Pages { get { return _pages; } } + + public List Pages { get { return _items.OfType().ToList(); } } public BackstageView() { @@ -38,12 +45,6 @@ namespace ArdupilotMega.Controls.BackstageView pnlMenu.GradColor = this.BackColor; } - protected override void OnPaint(PaintEventArgs e) - { - base.OnPaint(e); - } - - public override Color BackColor { get @@ -53,7 +54,7 @@ namespace ArdupilotMega.Controls.BackstageView set { base.BackColor = value; - UpdateButtons(); + UpdateButtonAppearance(); pnlMenu.GradColor = this.BackColor; } } @@ -68,7 +69,7 @@ namespace ArdupilotMega.Controls.BackstageView _buttonsAreaPencilColor = value; pnlMenu.PencilBorderColor = _buttonsAreaPencilColor; pnlMenu.Invalidate(); - UpdateButtons(); + UpdateButtonAppearance(); Invalidate(); } } @@ -96,7 +97,7 @@ namespace ArdupilotMega.Controls.BackstageView set { _selectedTextColor = value; - UpdateButtons(); + UpdateButtonAppearance(); } } @@ -108,7 +109,7 @@ namespace ArdupilotMega.Controls.BackstageView set { _unSelectedTextColor = value; - UpdateButtons(); + UpdateButtonAppearance(); Invalidate(); } } @@ -121,7 +122,7 @@ namespace ArdupilotMega.Controls.BackstageView set { _highlightColor1 = value; - UpdateButtons(); + UpdateButtonAppearance(); Invalidate(); } } @@ -134,36 +135,33 @@ namespace ArdupilotMega.Controls.BackstageView set { _highlightColor2 = value; - UpdateButtons(); + UpdateButtonAppearance(); Invalidate(); } } - - - private void UpdateButtons() + + /// + /// Add a page (tab) to this backstage view. Will be added at the end/bottom + /// + public void AddPage(UserControl userControl, string headerText) { - foreach (var backstageViewButton in pnlMenu.Controls.OfType()) - { - backstageViewButton.HighlightColor2 = _highlightColor2; - backstageViewButton.HighlightColor1 = _highlightColor1; - backstageViewButton.UnSelectedTextColor = _unSelectedTextColor; - backstageViewButton.SelectedTextColor = _selectedTextColor; - backstageViewButton.ContentPageColor = this.BackColor; - backstageViewButton.PencilBorderColor = _buttonsAreaPencilColor; + var page = new BackstageViewPage(userControl, headerText) + { + Page = + { + Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top, + Location = new Point(pnlMenu.Width, 0), + Dock = DockStyle.Fill + } + }; - backstageViewButton.Invalidate(); - } - } - - public void AddPage(BackstageViewPage page) - { - page.Page.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; - page.Page.Location = new Point(pnlMenu.Width, 0); - page.Page.Dock = DockStyle.Fill; - - _pages.Add(page); + _items.Add(page); + CreateLinkButton(page); - //this.pnlPages.Controls.Add(page.Page); + + page.Page.Visible = false; + + this.pnlPages.Controls.Add(page.Page); if (_activePage == null) { @@ -173,13 +171,22 @@ namespace ArdupilotMega.Controls.BackstageView } } + /// + /// Add a spacer to this backstage view. Will be added at the end/bottom + /// + /// the amount to space by + public void AddSpacer(int spacerheight) + { + _items.Add(new BackstageViewSpacer(spacerheight)); + } + private void CreateLinkButton(BackstageViewPage page) { var lnkButton = new BackstageViewButton { Text = page.LinkText, Tag = page, - Top = _pages.IndexOf(page) * ButtonSpacing, + Top = _items.TakeWhile(i => i != page).Sum(i => i.Spacing), Width = this.pnlMenu.Width, Height = ButtonHeight, ContentPageColor = this.BackColor, @@ -195,12 +202,32 @@ namespace ArdupilotMega.Controls.BackstageView lnkButton.DoubleClick += lnkButton_DoubleClick; } - void lnkButton_DoubleClick(object sender, EventArgs e) + private void UpdateButtonAppearance() + { + foreach (var backstageViewButton in pnlMenu.Controls.OfType()) + { + backstageViewButton.HighlightColor2 = _highlightColor2; + backstageViewButton.HighlightColor1 = _highlightColor1; + backstageViewButton.UnSelectedTextColor = _unSelectedTextColor; + backstageViewButton.SelectedTextColor = _selectedTextColor; + backstageViewButton.ContentPageColor = this.BackColor; + backstageViewButton.PencilBorderColor = _buttonsAreaPencilColor; + + backstageViewButton.Invalidate(); + } + } + + /* + * Experimental - double clicking a button will spawn it out into a new form + * Care must be given to lifecycle here - two pages can now be interacted with + * 'simultaneously' + */ + private void lnkButton_DoubleClick(object sender, EventArgs e) { var backstageViewButton = ((BackstageViewButton)sender); var associatedPage = backstageViewButton.Tag as BackstageViewPage; - Form popoutForm = new Form(); + var popoutForm = new Form(); popoutForm.FormClosing += popoutForm_FormClosing; int maxright = 0, maxdown = 0; @@ -214,7 +241,7 @@ namespace ArdupilotMega.Controls.BackstageView // set the height to 0, so we can derive the header height in the next step popoutForm.Height = 0; - popoutForm.Size = new System.Drawing.Size(maxright + 20, maxdown + 20 + popoutForm.Height); + popoutForm.Size = new Size(maxright + 20, maxdown + 20 + popoutForm.Height); popoutForm.Controls.Add(associatedPage.Page); popoutForm.Tag = associatedPage; @@ -226,19 +253,18 @@ namespace ArdupilotMega.Controls.BackstageView popoutForm.Show(this); } - void popoutForm_FormClosing(object sender, FormClosingEventArgs e) + private void popoutForm_FormClosing(object sender, FormClosingEventArgs e) { // get the page back var temp = ((Form)sender).Tag as BackstageViewPage; + // add back to where it belongs this.pnlPages.Controls.Add(temp.Page); - // clear the controls, so we dont dispose the good control + // clear the controls, so we dont dispose the good control when it closes ((Form)sender).Controls.Clear(); - } - private void ButtonClick(object sender, EventArgs e) { var backstageViewButton = ((BackstageViewButton) sender); @@ -248,29 +274,36 @@ namespace ArdupilotMega.Controls.BackstageView public void ActivatePage(BackstageViewPage associatedPage) { - // deactivate the old page - _activePage.Page.Close(); - Pages.ForEach(x => + // Deactivate old page + if (_activePage.Page is IDeactivate) { - x.Page.Visible = false; - }); - this.pnlPages.Controls.Remove(_activePage.Page); + ((IDeactivate)(_activePage.Page)).Deactivate(); + } + + // deactivate the old page - obsolete way of notifying activation + //_activePage.Page.Close(); + + foreach (var p in Pages) + p.Page.Visible = false; // deactivate button _activePage.Page.Visible = false; var oldButton = this.pnlMenu.Controls.OfType().Single(b => b.Tag == _activePage); oldButton.IsSelected = false; + // ensure fields have been init - obsolete way of notifying activation + //associatedPage.Page.DoLoad(new EventArgs()); - ThemeManager.ApplyThemeTo(associatedPage.Page); + // new way of notifying activation. Goal is to get rid of BackStageViewContentPanel + // so plain old user controls can be added + if (associatedPage.Page is IActivate) + { + ((IActivate)(associatedPage.Page)).Activate(); + } - // ensure fields have been init - associatedPage.Page.DoLoad(new EventArgs()); // show it associatedPage.Page.Visible = true; - // add control - this.pnlPages.Controls.Add(associatedPage.Page); - + var newButton = this.pnlMenu.Controls.OfType().Single(b => b.Tag == associatedPage); newButton.IsSelected = true; @@ -279,22 +312,70 @@ namespace ArdupilotMega.Controls.BackstageView public void Close() { - foreach (BackstageViewPage page in _pages) + foreach (var page in _items) { - page.Page.Close(); + if (((BackstageViewPage)page).Page is IDeactivate) + { + ((IDeactivate)((BackstageViewPage)(page)).Page).Deactivate(); + } + else + { + ((BackstageViewPage)page).Page.Dispose(); + } } } - public class BackstageViewPage + public abstract class BackstageViewItem + { + public abstract int Spacing { get; } + } + + /// + /// Place-holder for a bit of blank space in a + /// Used to visually seperate logically related groups of link buttons + /// + public class BackstageViewSpacer : BackstageViewItem + { + private int _spacing; + + public BackstageViewSpacer(int spacerheight) + { + _spacing = spacerheight; + } + + // How much (vertical) space the thing takes up in the button menu + public override int Spacing + { + get { return _spacing; } + } + } + + + /// + /// Data structure to hold information about a 'tab' in the + /// + public class BackstageViewPage : BackstageViewItem { - public BackstageViewPage(BackStageViewContentPanel page, string linkText) + public BackstageViewPage(UserControl page, string linkText) { Page = page; LinkText = linkText; } - public BackStageViewContentPanel Page { get; set; } + /// + /// The user content of the tab + /// + public UserControl Page { get; set; } + + /// + /// The text to go in the 'tab header' + /// public string LinkText { get; set; } + + public override int Spacing + { + get { return ButtonSpacing; } + } } } diff --git a/Tools/ArdupilotMegaPlanner/Controls/ConfigPanel.cs b/Tools/ArdupilotMegaPlanner/Controls/ConfigPanel.cs index 9aeb5289ca5..7591c3099a5 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/ConfigPanel.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/ConfigPanel.cs @@ -13,7 +13,7 @@ using ArdupilotMega.Utilities; namespace ArdupilotMega.Controls { - public partial class ConfigPanel : BackStageViewContentPanel + public partial class ConfigPanel : UserControl { /// /// store temp pending changes @@ -22,9 +22,11 @@ namespace ArdupilotMega.Controls // store linked param options Hashtable _linkedParams = new Hashtable(); - public ConfigPanel() + public ConfigPanel(string XMLFile) { InitializeComponent(); + + LoadXML(XMLFile); } /// diff --git a/Tools/ArdupilotMegaPlanner/Controls/ConnectionStats.cs b/Tools/ArdupilotMegaPlanner/Controls/ConnectionStats.cs index a9f455a6ec6..5705d01048b 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/ConnectionStats.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/ConnectionStats.cs @@ -11,10 +11,10 @@ namespace ArdupilotMega.Controls { public partial class ConnectionStats : UserControl { - private readonly IMAVLink _mavlink; + private readonly MAVLink _mavlink; private CompositeDisposable _subscriptionsDisposable; - public ConnectionStats(IMAVLink comPort) + public ConnectionStats(MAVLink comPort) : this() { _mavlink = comPort; diff --git a/Tools/ArdupilotMegaPlanner/Controls/CustomMessageBox.cs b/Tools/ArdupilotMegaPlanner/Controls/CustomMessageBox.cs index de5e9592a54..e6e11168ac7 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/CustomMessageBox.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/CustomMessageBox.cs @@ -52,7 +52,7 @@ namespace System.Windows.Forms var msgBoxFrm = new Form { FormBorderStyle = FormBorderStyle.FixedDialog, - ShowInTaskbar = false, + ShowInTaskbar = true, StartPosition = FormStartPosition.CenterScreen, Text = caption, MaximizeBox = false, @@ -60,7 +60,7 @@ namespace System.Windows.Forms Width = textSize.Width + 50, Height = textSize.Height + 100, TopMost = true, - TopLevel = true, + TopLevel = true }; Rectangle screenRectangle = msgBoxFrm.RectangleToScreen(msgBoxFrm.ClientRectangle); @@ -103,6 +103,8 @@ namespace System.Windows.Forms } catch { } + Console.WriteLine("CustomMessageBox 1"); + if (System.Windows.Forms.Application.OpenForms.Count > 0) { msgBoxFrm.StartPosition = FormStartPosition.Manual; @@ -110,13 +112,17 @@ namespace System.Windows.Forms // center of first form msgBoxFrm.Location = new Point(parentForm.Location.X + parentForm.Width / 2 - msgBoxFrm.Width / 2, parentForm.Location.Y + parentForm.Height / 2 - msgBoxFrm.Height / 2); - DialogResult test = msgBoxFrm.ShowDialog(); + Console.WriteLine("CustomMessageBox 2a"); + DialogResult test = msgBoxFrm.ShowDialog(null); } else { - DialogResult test = msgBoxFrm.ShowDialog(); + Console.WriteLine("CustomMessageBox 2b"); + DialogResult test = msgBoxFrm.ShowDialog(null); } + Console.WriteLine("CustomMessageBox 3"); + DialogResult answer = _state; return answer; diff --git a/Tools/ArdupilotMegaPlanner/Controls/HSI.cs b/Tools/ArdupilotMegaPlanner/Controls/HSI.cs index 6f105a6c132..48642745a30 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/HSI.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/HSI.cs @@ -31,6 +31,29 @@ namespace ArdupilotMega.Controls set { _navbearing = value; } } + /// + /// Override to prevent offscreen drawing the control - mono mac + /// + public new void Invalidate() + { + if (!ThisReallyVisible()) + { + return; + } + + base.Invalidate(); + } + + /// + /// this is to fix a mono off screen drawing issue + /// + /// + public bool ThisReallyVisible() + { + Control ctl = Control.FromHandle(this.Handle); + return ctl.Visible; + } + public HSI() { InitializeComponent(); diff --git a/Tools/ArdupilotMegaPlanner/Controls/HUD.cs b/Tools/ArdupilotMegaPlanner/Controls/HUD.cs index e28715c258b..f5530757328 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/HUD.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/HUD.cs @@ -182,10 +182,38 @@ namespace ArdupilotMega.Controls public override void Refresh() { + if (!ThisReallyVisible()) + { + return; + } + //base.Refresh(); OnPaint(new PaintEventArgs(this.CreateGraphics(),this.ClientRectangle)); } + /// + /// Override to prevent offscreen drawing the control - mono mac + /// + public new void Invalidate() + { + if (!ThisReallyVisible()) + { + return; + } + + base.Invalidate(); + } + + /// + /// this is to fix a mono off screen drawing issue + /// + /// + public bool ThisReallyVisible() + { + //Control ctl = Control.FromHandle(this.Handle); + return this.Visible; + } + protected override void OnLoad(EventArgs e) { if (opengl) @@ -245,9 +273,11 @@ namespace ArdupilotMega.Controls started = true; } + object lockit = new object(); bool inOnPaint = false; string otherthread = ""; + protected override void OnPaint(PaintEventArgs e) { //GL.Enable(EnableCap.AlphaTest) @@ -270,16 +300,21 @@ namespace ArdupilotMega.Controls return; } - if (inOnPaint) + lock (lockit) { - log.Info("Was in onpaint Hud th:" + System.Threading.Thread.CurrentThread.Name + " in " + otherthread); - return; + + if (inOnPaint) + { + log.Info("Was in onpaint Hud th:" + System.Threading.Thread.CurrentThread.Name + " in " + otherthread); + return; + } + + otherthread = System.Threading.Thread.CurrentThread.Name; + + inOnPaint = true; + } - otherthread = System.Threading.Thread.CurrentThread.Name; - - inOnPaint = true; - starttime = DateTime.Now; try @@ -701,6 +736,8 @@ namespace ArdupilotMega.Controls graphicsObjectGDIP.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault; } + graphicsObjectGDIP.InterpolationMode = InterpolationMode.Bilinear; + graphicsObject.Clear(Color.Gray); @@ -1310,7 +1347,7 @@ namespace ArdupilotMega.Controls graphicsObject.DrawLine(redPen, scrollbg.Left, scrollbg.Top - (int)(fontsize * 2.2) - 2, scrollbg.Left + 50, scrollbg.Top - (int)(fontsize * 2.2) - 2 - 20); } - drawstring(graphicsObject, _datetime.ToString("HH:mm:ss"), font, fontsize, whiteBrush, scrollbg.Left - 20, scrollbg.Top - fontsize - 2 - 20); + drawstring(graphicsObject, _datetime.ToString("HH:mm:ss"), font, fontsize, whiteBrush, scrollbg.Left - 30, scrollbg.Top - fontsize - 2 - 20); // battery @@ -1558,27 +1595,86 @@ namespace ArdupilotMega.Controls if (text == null || text == "") return; - pth.Reset(); - - if (text != null) - pth.AddString(text, font.FontFamily, 0, fontsize + 5, new Point((int)x, (int)y), StringFormat.GenericTypographic); + + char[] chars = text.ToCharArray(); - //Draw the edge - // this uses lots of cpu time + float maxy = 0; - //e.SmoothingMode = SmoothingMode.HighSpeed; + foreach (char cha in chars) + { + int charno = (int)cha; + + int charid = charno + (128 * (int)fontsize); + + if (charbitmaps[charid] == null) + { + charbitmaps[charid] = new Bitmap(128, 128, System.Drawing.Imaging.PixelFormat.Format32bppArgb); + + charbitmaps[charid].MakeTransparent(Color.Transparent); + + //charbitmaptexid + + float maxx = this.Width / 150; // for space + + + // create bitmap + using (Graphics gfx = Graphics.FromImage(charbitmaps[charid])) + { + pth.Reset(); + + if (text != null) + pth.AddString(cha + "", font.FontFamily, 0, fontsize + 5, new Point((int)0, (int)0), StringFormat.GenericTypographic); + + gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; + + gfx.DrawPath(P, pth); + + //Draw the face + + gfx.FillPath(brush, pth); + + + if (pth.PointCount > 0) + { + foreach (PointF pnt in pth.PathPoints) + { + if (pnt.X > maxx) + maxx = pnt.X; + + if (pnt.Y > maxy) + maxy = pnt.Y; + } + } + } + + charwidth[charid] = (int)(maxx + 2); + } + + // draw it + + float scale = 1.0f; + + DrawImage(charbitmaps[charid], (int)x, (int)y, charbitmaps[charid].Width, charbitmaps[charid].Height); + + x += charwidth[charid] * scale; + + /* + pth.Reset(); + + if (text != null) + pth.AddString(text, font.FontFamily, 0, fontsize + 5, new Point((int)x, (int)y), StringFormat.GenericTypographic); + + if (e == null || P == null || pth == null || pth.PointCount == 0) + return; - if (e == null || P == null || pth == null || pth.PointCount == 0) - return; - - //if (!ArdupilotMega.MainV2.MONO) e.DrawPath(P, pth); - //Draw the face + //Draw the face - e.FillPath(brush, pth); + e.FillPath(brush, pth); + */ + } - //pth.Dispose(); } protected override void OnHandleCreated(EventArgs e) @@ -1646,6 +1742,8 @@ namespace ArdupilotMega.Controls { if (opengl) { + MakeCurrent(); + GL.MatrixMode(MatrixMode.Projection); GL.LoadIdentity(); GL.Ortho(0, Width, Height, 0, -1, 1); diff --git a/Tools/ArdupilotMegaPlanner/Controls/LabelWithPseudoOpacity.cs b/Tools/ArdupilotMegaPlanner/Controls/LabelWithPseudoOpacity.cs index 6b25ba319d6..1617f2110d7 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/LabelWithPseudoOpacity.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/LabelWithPseudoOpacity.cs @@ -35,12 +35,7 @@ namespace ArdupilotMega.Controls throw new ArgumentOutOfRangeException(); _opacity = value; - Console.WriteLine("Opacity:" + _opacity); Invalidate(); - Invalidate(); - Invalidate(); - Invalidate(); - } } diff --git a/Tools/ArdupilotMegaPlanner/Controls/LineSeparator.cs b/Tools/ArdupilotMegaPlanner/Controls/LineSeparator.cs index 5c96aff3e4c..6d8f7815744 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/LineSeparator.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/LineSeparator.cs @@ -1,51 +1,73 @@ using System; -using System.Collections.Generic; using System.ComponentModel; using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; +using System.Drawing.Drawing2D; using System.Windows.Forms; namespace ArdupilotMega.Controls { - + /// + /// A seperator that is fundamentally made from two lines the top 'Primary' and the + /// bottom 'Secondary' Thus the height is always 2 pixels + /// In addition, the opacity can be modulated for the left, middle and right most + /// points, and the color blended between. That way the seperator can be made to + /// fade out to the left or right or both, and more subtle UI effects made etc + /// public partial class LineSeparator : UserControl { + [Description("Primary Color of the secondary line"), Category("Appearance")] + [DefaultValue(typeof(Color), "DarkGray")] + public Color PrimaryColor { get; set; } + + [Description("Secondary Color of the secondary line"), Category("Appearance")] + [DefaultValue(typeof(Color), "White")] + public Color SecondaryColor { get; set; } + + [Description("Opacity at the left most point"), Category("Appearance")] + [DefaultValue(typeof(float), "1.0")] + public float Opacity1 { get; set; } + + [Description("Opacity at the mid point"), Category("Appearance")] + [DefaultValue(typeof(float), "1.0")] + public float Opacity2 { get; set; } + + [Description("Opacity at the right most point"), Category("Appearance")] + [DefaultValue(typeof(float), "1.0")] + public float Opacity3 { get; set; } + public LineSeparator() { + this.PrimaryColor = Color.DarkGray; + this.SecondaryColor = Color.White; + this.Opacity1 = Opacity2 = Opacity3 = 1f; + this.Height = 2; - - this.Paint += new PaintEventHandler(LineSeparator_Paint); - - + this.Paint += LineSeparator_Paint; this.MaximumSize = new Size(2000, 2); - - this.MinimumSize = new Size(0, 2); - - //this.Width = 350; - } - private void LineSeparator_Paint(object sender, PaintEventArgs e) { - - - - - Graphics g = e.Graphics; - - g.DrawLine( - - Pens.DarkGray, new Point(0, 0), new Point(this.Width, 0)); - - g.DrawLine( - - Pens.White, new Point(0, 1), new Point(this.Width, 1)); - + DrawLine(PrimaryColor, 0, e.Graphics); + DrawLine(SecondaryColor, 1, e.Graphics); } + private void DrawLine(Color baseColor, int y, Graphics g) + { + var c1 = Color.FromArgb((int)(Opacity1 * 255), baseColor.R, baseColor.G, baseColor.B); + var c2 = Color.FromArgb((int)(Opacity2 * 255), baseColor.R, baseColor.G, baseColor.B); + var c3 = Color.FromArgb((int)(Opacity3 * 255), baseColor.R, baseColor.G, baseColor.B); + + var point1 = new Point(0, y); + var point2 = new Point(Width / 2, y); + var point = new Point(Width, y); + + var b1 = new LinearGradientBrush(point1, point2, c1, c2); + var b2 = new LinearGradientBrush(point2, point, c2, c3); + + g.DrawLine(new Pen(b1), point1, point2); + g.DrawLine(new Pen(b2), point2, point); + } } } \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/Controls/MainSwitcher.cs b/Tools/ArdupilotMegaPlanner/Controls/MainSwitcher.cs index 65b4d00d946..8fa9f8b47da 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/MainSwitcher.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/MainSwitcher.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; using ArdupilotMega.Utilities; +using ArdupilotMega.Controls.BackstageView; namespace ArdupilotMega.Controls { @@ -43,6 +44,11 @@ namespace ArdupilotMega.Controls // check if we need to remove the current control if (!current.Persistent) { + if (current.Control is IDeactivate) + { + ((IDeactivate)(current.Control)).Deactivate(); + } + // cleanup current.Control.Close(); @@ -63,6 +69,11 @@ namespace ArdupilotMega.Controls nextscreen.Visible = true; + if (nextscreen.Control is IActivate) + { + ((IActivate)(nextscreen.Control)).Activate(); + } + this.Controls.Add(nextscreen.Control); ThemeManager.ApplyThemeTo(nextscreen.Control); diff --git a/Tools/ArdupilotMegaPlanner/Controls/MyLabel.cs b/Tools/ArdupilotMegaPlanner/Controls/MyLabel.cs index c5393c2c9c4..a3ff19f0b34 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/MyLabel.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/MyLabel.cs @@ -64,7 +64,22 @@ namespace ArdupilotMega.Controls return this.Bounds.IntersectsWith(Parent.ClientRectangle); return true; - } + } + + public override void Refresh() + { + base.Refresh(); + } + + protected override void OnParentBindingContextChanged(EventArgs e) + { + base.OnParentBindingContextChanged(e); + } + + protected override void OnVisibleChanged(EventArgs e) + { + base.OnVisibleChanged(e); + } SolidBrush s = new SolidBrush(Color.White); @@ -75,9 +90,7 @@ namespace ArdupilotMega.Controls protected override void OnPaint(PaintEventArgs e) { - TextRenderer.DrawText(e.Graphics, label, this.Font, new Point(0, 0), ForeColor); - /* - //return; + // TextRenderer.DrawText(e.Graphics, label, this.Font, new Point(0, 0), ForeColor); stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Center; @@ -85,7 +98,7 @@ namespace ArdupilotMega.Controls s = new SolidBrush(ForeColor); e.Graphics.DrawString(label, this.Font, s, new PointF(0, this.Height / 2.0f), stringFormat); - */ + } protected override void OnPaintBackground(PaintEventArgs pevent) diff --git a/Tools/ArdupilotMegaPlanner/Controls/MyUserControl.cs b/Tools/ArdupilotMegaPlanner/Controls/MyUserControl.cs index 5903f7d2d8e..d668d91bf17 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/MyUserControl.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/MyUserControl.cs @@ -11,6 +11,10 @@ namespace System.Windows.Forms /// public class MyUserControl : System.Windows.Forms.UserControl { + /// + /// implement an on closing event to tidy up enviroment. + /// Using preedefined refrence as can easerly change betwen form and user control this way. + /// public event FormClosingEventHandler FormClosing; public void Close(object sender, FormClosingEventArgs e) diff --git a/Tools/ArdupilotMegaPlanner/Controls/ProgressReporterDialogue.cs b/Tools/ArdupilotMegaPlanner/Controls/ProgressReporterDialogue.cs index 58b2fdd2237..7fec2e5eebc 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/ProgressReporterDialogue.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/ProgressReporterDialogue.cs @@ -17,6 +17,9 @@ namespace ArdupilotMega.Controls private Exception workerException; public ProgressWorkerEventArgs doWorkArgs; + internal int _progress = -1; + internal string _status = ""; + public delegate void DoWorkEventHandler(object sender, ProgressWorkerEventArgs e); // This is the event that will be raised on the BG thread @@ -48,7 +51,7 @@ namespace ArdupilotMega.Controls // mono fix - ensure the dialog is running while (this.IsHandleCreated == false) - System.Threading.Thread.Sleep(5); + System.Threading.Thread.Sleep(1); try { @@ -59,10 +62,18 @@ namespace ArdupilotMega.Controls // The background operation thew an exception. // Examine the work args, if there is an error, then display that and the exception details // Otherwise display 'Unexpected error' and exception details + timer1.Stop(); ShowDoneWithError(e, doWorkArgs.ErrorMessage); return; } + // stop the timer + timer1.Stop(); + // run once more to do final message and progressbar + this.Invoke((MethodInvoker)delegate + { + timer1_Tick(null, null); + }); if (doWorkArgs.CancelRequested && doWorkArgs.CancelAcknowledged) { @@ -183,24 +194,9 @@ namespace ArdupilotMega.Controls if (doWorkArgs.CancelRequested && !doWorkArgs.CancelAcknowledged) return; - if (this.InvokeRequired) - { - // invoke async - this.BeginInvoke((MethodInvoker) delegate - { + _progress = progress; + _status = status; - lblProgressMessage.Text = status; - if (progress == -1) - { - this.progressBar1.Style = ProgressBarStyle.Marquee; - } - else - { - this.progressBar1.Style = ProgressBarStyle.Continuous; - this.progressBar1.Value = progress; - } - }); - } } private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) @@ -212,6 +208,25 @@ namespace ArdupilotMega.Controls CustomMessageBox.Show(message,"Exception Details",MessageBoxButtons.OK,MessageBoxIcon.Information); } + /// + /// prevent using invokes on main update status call "UpdateProgressAndStatus", as this is slow on mono + /// + /// + /// + private void timer1_Tick(object sender, EventArgs e) + { + lblProgressMessage.Text = _status; + if (_progress == -1) + { + this.progressBar1.Style = ProgressBarStyle.Marquee; + } + else + { + this.progressBar1.Style = ProgressBarStyle.Continuous; + this.progressBar1.Value = _progress; + } + } + } public class ProgressWorkerEventArgs : EventArgs diff --git a/Tools/ArdupilotMegaPlanner/Controls/ProgressReporterDialogue.designer.cs b/Tools/ArdupilotMegaPlanner/Controls/ProgressReporterDialogue.designer.cs index 93261295d66..15e1bdaff69 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/ProgressReporterDialogue.designer.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/ProgressReporterDialogue.designer.cs @@ -33,12 +33,14 @@ namespace ArdupilotMega.Controls /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.progressBar1 = new System.Windows.Forms.ProgressBar(); this.lblProgressMessage = new System.Windows.Forms.Label(); this.btnCancel = new System.Windows.Forms.Button(); this.imgWarning = new System.Windows.Forms.PictureBox(); this.linkLabel1 = new System.Windows.Forms.LinkLabel(); this.btnClose = new System.Windows.Forms.Button(); + this.timer1 = new System.Windows.Forms.Timer(this.components); ((System.ComponentModel.ISupportInitialize)(this.imgWarning)).BeginInit(); this.SuspendLayout(); // @@ -94,7 +96,7 @@ namespace ArdupilotMega.Controls this.linkLabel1.Visible = false; this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); // - // btn_Close + // btnClose // this.btnClose.Location = new System.Drawing.Point(213, 109); this.btnClose.Name = "btnClose"; @@ -104,6 +106,11 @@ namespace ArdupilotMega.Controls this.btnClose.UseVisualStyleBackColor = true; this.btnClose.Click += new System.EventHandler(this.btn_Close_Click); // + // timer1 + // + this.timer1.Enabled = true; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // // ProgressReporterDialogue // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -123,6 +130,7 @@ namespace ArdupilotMega.Controls this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Progress"; + this.TopMost = true; ((System.ComponentModel.ISupportInitialize)(this.imgWarning)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -137,5 +145,6 @@ namespace ArdupilotMega.Controls private PictureBox imgWarning; private LinkLabel linkLabel1; private Button btnClose; + private Timer timer1; } } \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/Controls/ProgressReporterDialogue.resx b/Tools/ArdupilotMegaPlanner/Controls/ProgressReporterDialogue.resx index 7080a7d118e..886d0de36eb 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/ProgressReporterDialogue.resx +++ b/Tools/ArdupilotMegaPlanner/Controls/ProgressReporterDialogue.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/Controls/PseudoOpacityHelper.cs b/Tools/ArdupilotMegaPlanner/Controls/PseudoOpacityHelper.cs index bc3230ce084..879f1ec9bd7 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/PseudoOpacityHelper.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/PseudoOpacityHelper.cs @@ -10,9 +10,6 @@ namespace ArdupilotMega.Controls { var bgcolor = c.BackColor; int alpha = 255 - ((int)(opacity * 255)); - - Console.WriteLine("Alpha:" + alpha); - var opacityColor = Color.FromArgb(alpha, bgcolor.R, bgcolor.G, bgcolor.B); using (var brush = new SolidBrush(opacityColor)) diff --git a/Tools/ArdupilotMegaPlanner/CurrentState.cs b/Tools/ArdupilotMegaPlanner/CurrentState.cs index 4a43983cea0..e48233ea7a8 100644 --- a/Tools/ArdupilotMegaPlanner/CurrentState.cs +++ b/Tools/ArdupilotMegaPlanner/CurrentState.cs @@ -78,6 +78,7 @@ namespace ArdupilotMega public float mz { get; set; } public float magfield { get { return (float)Math.Sqrt(Math.Pow(mx, 2) + Math.Pow(my, 2) + Math.Pow(mz, 2)); } } + public float accelsq { get { return (float)Math.Sqrt(Math.Pow(ax, 2) + Math.Pow(ay, 2) + Math.Pow(az, 2)) / 980.665f; } } // calced turn rate public float turnrate { get { if (groundspeed <= 1) return 0; return (roll * 9.8f) / groundspeed; } } @@ -131,9 +132,9 @@ namespace ArdupilotMega public float nav_bearing { get; set; } public float target_bearing { get; set; } public float wp_dist { get { return (_wpdist * multiplierdist); } set { _wpdist = value; } } - public float alt_error { get { return _alt_error * multiplierdist; } set { _alt_error = value; _targetalt = (float)Math.Round(alt + alt_error, 0); } } + public float alt_error { get { return _alt_error * multiplierdist; } set { if (_alt_error == value) return; _alt_error = value; _targetalt = _targetalt * 0.5f + (float)Math.Round(alt + alt_error, 0) * 0.5f; Console.WriteLine(_targetalt); } } public float ber_error { get { return (target_bearing - yaw); } set { } } - public float aspd_error { get { return _aspd_error * multiplierspeed; } set { _aspd_error = value; } } + public float aspd_error { get { return _aspd_error * multiplierspeed; } set { if (_aspd_error == value) return; _aspd_error = value; _targetairspeed = _targetairspeed * 0.5f + (float)Math.Round(airspeed + aspd_error / 100, 0) * 0.5f; } } public float xtrack_error { get; set; } public float wpno { get; set; } public string mode { get; set; } @@ -142,12 +143,13 @@ namespace ArdupilotMega float _aspd_error; float _alt_error; float _targetalt; + float _targetairspeed; public float targetaltd100 { get { return (_targetalt / 100) % 10; } } public float targetalt { get { return _targetalt; } } //airspeed_error = (airspeed_error - airspeed); - public float targetairspeed { get { return (float)Math.Round(airspeed + aspd_error / 100, 0); } } + public float targetairspeed { get { return _targetairspeed; } } //message @@ -352,7 +354,7 @@ namespace ArdupilotMega UpdateCurrentSettings(bs, false, MainV2.comPort); } */ - public void UpdateCurrentSettings(System.Windows.Forms.BindingSource bs, bool updatenow, IMAVLink mavinterface) + public void UpdateCurrentSettings(System.Windows.Forms.BindingSource bs, bool updatenow, MAVLink mavinterface) { if (DateTime.Now > lastupdate.AddMilliseconds(19) || updatenow) // 50 hz { @@ -430,24 +432,6 @@ namespace ArdupilotMega //MAVLink.packets[MAVLink.MAVLINK_MSG_ID_HWSTATUS] = null; } - - bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT]; - - if (bytearray != null) - { - var nav = bytearray.ByteArrayToStructure(6); - - nav_roll = nav.nav_roll; - nav_pitch = nav.nav_pitch; - nav_bearing = nav.nav_bearing; - target_bearing = nav.target_bearing; - wp_dist = nav.wp_dist; - alt_error = nav.alt_error; - aspd_error = nav.aspd_error; - xtrack_error = nav.xtrack_error; - - //MAVLink.packets[MAVLink.MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT] = null; - } #if MAVLINK10 @@ -849,6 +833,26 @@ namespace ArdupilotMega } #endif + + + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT]; + + if (bytearray != null) + { + var nav = bytearray.ByteArrayToStructure(6); + + nav_roll = nav.nav_roll; + nav_pitch = nav.nav_pitch; + nav_bearing = nav.nav_bearing; + target_bearing = nav.target_bearing; + wp_dist = nav.wp_dist; + alt_error = nav.alt_error; + aspd_error = nav.aspd_error; + xtrack_error = nav.xtrack_error; + + //MAVLink.packets[MAVLink.MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT] = null; + } + bytearray = mavinterface.packets[MAVLink.MAVLINK_MSG_ID_RC_CHANNELS_RAW]; if (bytearray != null) { @@ -964,7 +968,7 @@ namespace ArdupilotMega //System.Diagnostics.Debug.WriteLine(DateTime.Now.Millisecond); //Console.WriteLine(DateTime.Now.Millisecond); bs.DataSource = this; - //Console.WriteLine(DateTime.Now.Millisecond + " 1 " + updatenow); + // Console.WriteLine(DateTime.Now.Millisecond + " 1 " + updatenow + " " + System.Threading.Thread.CurrentThread.Name); bs.ResetBindings(false); //Console.WriteLine(DateTime.Now.Millisecond + " done "); } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAP_Limits.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAP_Limits.Designer.cs index 059559a5c51..7ed6e03606c 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAP_Limits.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAP_Limits.Designer.cs @@ -259,7 +259,6 @@ this.Controls.Add(this.LIM_ENABLED); this.Controls.Add(this.LNK_wiki); this.Name = "ConfigAP_Limits"; - this.Load += new System.EventHandler(this.ConfigAP_Limits_Load); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.groupBox5.ResumeLayout(false); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAP_Limits.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAP_Limits.cs index 152ae47e764..090de0a367e 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAP_Limits.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAP_Limits.cs @@ -13,7 +13,7 @@ using System.Diagnostics; namespace ArdupilotMega.GCSViews.ConfigurationView { - public partial class ConfigAP_Limits : BackStageViewContentPanel + public partial class ConfigAP_Limits : UserControl, IActivate { public ConfigAP_Limits() { @@ -73,7 +73,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView ProcessChange(sender, e); } - private void ConfigAP_Limits_Load(object sender, EventArgs e) + public void Activate() { PopulateData(); } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationPlane.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationPlane.Designer.cs index 265f207745c..c4468673f53 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationPlane.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationPlane.Designer.cs @@ -83,7 +83,6 @@ this.Controls.Add(this.BUT_levelplane); this.Name = "ConfigAccelerometerCalibrationPlane"; this.toolTip1.SetToolTip(this, resources.GetString("$this.ToolTip")); - this.Load += new System.EventHandler(this.ConfigAccelerometerCalibration_Load); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationPlane.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationPlane.cs index 9a5ed1adbc3..488cc8fb6b8 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationPlane.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationPlane.cs @@ -11,7 +11,7 @@ using ArdupilotMega.Controls; namespace ArdupilotMega.GCSViews.ConfigurationView { - public partial class ConfigAccelerometerCalibrationPlane : BackStageViewContentPanel + public partial class ConfigAccelerometerCalibrationPlane : UserControl, IActivate { bool startup = false; @@ -20,7 +20,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView InitializeComponent(); } - private void ConfigAccelerometerCalibration_Load(object sender, EventArgs e) + public void Activate() { if (!MainV2.comPort.BaseStream.IsOpen) { diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationQuad.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationQuad.Designer.cs index bab5902f1c3..08a98c90411 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationQuad.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationQuad.Designer.cs @@ -1,4 +1,6 @@ -namespace ArdupilotMega.GCSViews.ConfigurationView +using ArdupilotMega.Controls; + +namespace ArdupilotMega.GCSViews.ConfigurationView { partial class ConfigAccelerometerCalibrationQuad { @@ -29,52 +31,77 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ConfigAccelerometerCalibrationQuad)); - this.label28 = new System.Windows.Forms.Label(); - this.label15 = new System.Windows.Forms.Label(); - this.pictureBoxQuadX = new System.Windows.Forms.PictureBox(); - this.pictureBoxQuad = new System.Windows.Forms.PictureBox(); - this.BUT_levelac2 = new ArdupilotMega.Controls.MyButton(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.pictureBox2 = new System.Windows.Forms.PictureBox(); - this.pictureBox3 = new System.Windows.Forms.PictureBox(); - this.pictureBox4 = new System.Windows.Forms.PictureBox(); + this.radioButton_Plus = new System.Windows.Forms.RadioButton(); + this.radioButton_X = new System.Windows.Forms.RadioButton(); + this.label5 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); - this.lbl_frame = new System.Windows.Forms.Label(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxQuadX)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxQuad)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.pictureBoxPlus = new ArdupilotMega.Controls.PictureBoxWithPseudoOpacity(); + this.pictureBoxX = new ArdupilotMega.Controls.PictureBoxWithPseudoOpacity(); + this.BUT_levelac2 = new ArdupilotMega.Controls.MyButton(); + this.label4 = new System.Windows.Forms.Label(); + this.lineSeparator3 = new ArdupilotMega.Controls.LineSeparator(); + this.lineSeparator2 = new ArdupilotMega.Controls.LineSeparator(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlus)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxX)).BeginInit(); this.SuspendLayout(); // - // label28 + // radioButton_Plus // - resources.ApplyResources(this.label28, "label28"); - this.label28.Name = "label28"; + resources.ApplyResources(this.radioButton_Plus, "radioButton_Plus"); + this.radioButton_Plus.Name = "radioButton_Plus"; + this.radioButton_Plus.TabStop = true; + this.radioButton_Plus.UseVisualStyleBackColor = true; + this.radioButton_Plus.CheckedChanged += new System.EventHandler(this.RadioButtonPlusCheckedChanged); // - // label15 + // radioButton_X // - resources.ApplyResources(this.label15, "label15"); - this.label15.Name = "label15"; + resources.ApplyResources(this.radioButton_X, "radioButton_X"); + this.radioButton_X.Name = "radioButton_X"; + this.radioButton_X.TabStop = true; + this.radioButton_X.UseVisualStyleBackColor = true; + this.radioButton_X.CheckedChanged += new System.EventHandler(this.RadioButtonPlusCheckedChanged); // - // pictureBoxQuadX + // label5 // - this.pictureBoxQuadX.Cursor = System.Windows.Forms.Cursors.Hand; - this.pictureBoxQuadX.Image = global::ArdupilotMega.Properties.Resources.quadx; - resources.ApplyResources(this.pictureBoxQuadX, "pictureBoxQuadX"); - this.pictureBoxQuadX.Name = "pictureBoxQuadX"; - this.pictureBoxQuadX.TabStop = false; - this.pictureBoxQuadX.Click += new System.EventHandler(this.pictureBoxQuadX_Click); + resources.ApplyResources(this.label5, "label5"); + this.label5.ForeColor = System.Drawing.Color.WhiteSmoke; + this.label5.Name = "label5"; // - // pictureBoxQuad + // label1 // - this.pictureBoxQuad.Cursor = System.Windows.Forms.Cursors.Hand; - this.pictureBoxQuad.Image = global::ArdupilotMega.Properties.Resources.quad; - resources.ApplyResources(this.pictureBoxQuad, "pictureBoxQuad"); - this.pictureBoxQuad.Name = "pictureBoxQuad"; - this.pictureBoxQuad.TabStop = false; - this.pictureBoxQuad.Click += new System.EventHandler(this.pictureBoxQuad_Click); + resources.ApplyResources(this.label1, "label1"); + this.label1.ForeColor = System.Drawing.Color.WhiteSmoke; + this.label1.Name = "label1"; + // + // label2 + // + resources.ApplyResources(this.label2, "label2"); + this.label2.Name = "label2"; + // + // label3 + // + resources.ApplyResources(this.label3, "label3"); + this.label3.Name = "label3"; + // + // pictureBoxPlus + // + this.pictureBoxPlus.Cursor = System.Windows.Forms.Cursors.Hand; + this.pictureBoxPlus.Image = global::ArdupilotMega.Properties.Resources.frames_plus; + resources.ApplyResources(this.pictureBoxPlus, "pictureBoxPlus"); + this.pictureBoxPlus.Name = "pictureBoxPlus"; + this.pictureBoxPlus.TabStop = false; + this.pictureBoxPlus.Click += new System.EventHandler(this.pictureBox_Click); + // + // pictureBoxX + // + this.pictureBoxX.Cursor = System.Windows.Forms.Cursors.Hand; + this.pictureBoxX.Image = global::ArdupilotMega.Properties.Resources.frames_x; + resources.ApplyResources(this.pictureBoxX, "pictureBoxX"); + this.pictureBoxX.Name = "pictureBoxX"; + this.pictureBoxX.TabStop = false; + this.pictureBoxX.Click += new System.EventHandler(this.pictureBox_Click); // // BUT_levelac2 // @@ -83,75 +110,54 @@ this.BUT_levelac2.UseVisualStyleBackColor = true; this.BUT_levelac2.Click += new System.EventHandler(this.BUT_levelac2_Click); // - // pictureBox1 + // label4 // - this.pictureBox1.Cursor = System.Windows.Forms.Cursors.Hand; - this.pictureBox1.Image = global::ArdupilotMega.Properties.Resources.frames_06; - resources.ApplyResources(this.pictureBox1, "pictureBox1"); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.TabStop = false; - this.pictureBox1.Click += new System.EventHandler(this.pictureBoxQuadX_Click); + resources.ApplyResources(this.label4, "label4"); + this.label4.Name = "label4"; // - // pictureBox2 + // lineSeparator3 // - this.pictureBox2.Cursor = System.Windows.Forms.Cursors.Hand; - this.pictureBox2.Image = global::ArdupilotMega.Properties.Resources.hexa; - resources.ApplyResources(this.pictureBox2, "pictureBox2"); - this.pictureBox2.Name = "pictureBox2"; - this.pictureBox2.TabStop = false; - this.pictureBox2.Click += new System.EventHandler(this.pictureBoxQuad_Click); + resources.ApplyResources(this.lineSeparator3, "lineSeparator3"); + this.lineSeparator3.MaximumSize = new System.Drawing.Size(2000, 2); + this.lineSeparator3.MinimumSize = new System.Drawing.Size(0, 2); + this.lineSeparator3.Name = "lineSeparator3"; + this.lineSeparator3.Opacity1 = 0.6F; + this.lineSeparator3.Opacity2 = 0.7F; + this.lineSeparator3.Opacity3 = 0.1F; + this.lineSeparator3.PrimaryColor = System.Drawing.Color.Black; + this.lineSeparator3.SecondaryColor = System.Drawing.Color.Gainsboro; // - // pictureBox3 + // lineSeparator2 // - this.pictureBox3.Cursor = System.Windows.Forms.Cursors.Hand; - this.pictureBox3.Image = global::ArdupilotMega.Properties.Resources.octox; - resources.ApplyResources(this.pictureBox3, "pictureBox3"); - this.pictureBox3.Name = "pictureBox3"; - this.pictureBox3.TabStop = false; - this.pictureBox3.Click += new System.EventHandler(this.pictureBoxQuadX_Click); - // - // pictureBox4 - // - this.pictureBox4.Cursor = System.Windows.Forms.Cursors.Hand; - this.pictureBox4.Image = global::ArdupilotMega.Properties.Resources.octo; - resources.ApplyResources(this.pictureBox4, "pictureBox4"); - this.pictureBox4.Name = "pictureBox4"; - this.pictureBox4.TabStop = false; - this.pictureBox4.Click += new System.EventHandler(this.pictureBoxQuad_Click); - // - // label1 - // - resources.ApplyResources(this.label1, "label1"); - this.label1.Name = "label1"; - // - // lbl_frame - // - resources.ApplyResources(this.lbl_frame, "lbl_frame"); - this.lbl_frame.Name = "lbl_frame"; + resources.ApplyResources(this.lineSeparator2, "lineSeparator2"); + this.lineSeparator2.MaximumSize = new System.Drawing.Size(2000, 2); + this.lineSeparator2.MinimumSize = new System.Drawing.Size(0, 2); + this.lineSeparator2.Name = "lineSeparator2"; + this.lineSeparator2.Opacity1 = 0.6F; + this.lineSeparator2.Opacity2 = 0.7F; + this.lineSeparator2.Opacity3 = 0.1F; + this.lineSeparator2.PrimaryColor = System.Drawing.Color.Black; + this.lineSeparator2.SecondaryColor = System.Drawing.Color.Gainsboro; // // ConfigAccelerometerCalibrationQuad // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.lbl_frame); + this.Controls.Add(this.lineSeparator2); + this.Controls.Add(this.lineSeparator3); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); this.Controls.Add(this.label1); - this.Controls.Add(this.pictureBox3); - this.Controls.Add(this.pictureBox4); - this.Controls.Add(this.pictureBox1); - this.Controls.Add(this.pictureBox2); - this.Controls.Add(this.label28); - this.Controls.Add(this.label15); - this.Controls.Add(this.pictureBoxQuadX); - this.Controls.Add(this.pictureBoxQuad); + this.Controls.Add(this.label5); + this.Controls.Add(this.radioButton_X); + this.Controls.Add(this.radioButton_Plus); + this.Controls.Add(this.pictureBoxPlus); + this.Controls.Add(this.pictureBoxX); this.Controls.Add(this.BUT_levelac2); this.Name = "ConfigAccelerometerCalibrationQuad"; - this.Load += new System.EventHandler(this.ConfigAccelerometerCalibration_Load); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxQuadX)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxQuad)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlus)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxX)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -159,16 +165,17 @@ #endregion - private System.Windows.Forms.Label label28; - private System.Windows.Forms.Label label15; - private System.Windows.Forms.PictureBox pictureBoxQuadX; - private System.Windows.Forms.PictureBox pictureBoxQuad; + private PictureBoxWithPseudoOpacity pictureBoxX; private ArdupilotMega.Controls.MyButton BUT_levelac2; - private System.Windows.Forms.PictureBox pictureBox1; - private System.Windows.Forms.PictureBox pictureBox2; - private System.Windows.Forms.PictureBox pictureBox3; - private System.Windows.Forms.PictureBox pictureBox4; + private PictureBoxWithPseudoOpacity pictureBoxPlus; + private System.Windows.Forms.RadioButton radioButton_Plus; + private System.Windows.Forms.RadioButton radioButton_X; + private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label lbl_frame; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private LineSeparator lineSeparator3; + private LineSeparator lineSeparator2; } } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationQuad.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationQuad.cs index 9d3d7516acb..84ad9c6cbb4 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationQuad.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationQuad.cs @@ -1,90 +1,118 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; +using System.Reflection; using System.Windows.Forms; using ArdupilotMega.Controls.BackstageView; -using ArdupilotMega.Controls; +using log4net; +using Transitions; namespace ArdupilotMega.GCSViews.ConfigurationView { - public partial class ConfigAccelerometerCalibrationQuad : BackStageViewContentPanel + public partial class ConfigAccelerometerCalibrationQuad : UserControl, IActivate, IDeactivate { + private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private const float DisabledOpacity = 0.2F; + private const float EnabledOpacity = 1.0F; + public ConfigAccelerometerCalibrationQuad() { InitializeComponent(); } - private void pictureBoxQuadX_Click(object sender, EventArgs e) - { - try - { - MainV2.comPort.setParam("FRAME", 1f); - CustomMessageBox.Show("Set to x"); - - lbl_frame.Text = "X"; - } - catch { CustomMessageBox.Show("Set frame failed"); } - } - private void BUT_levelac2_Click(object sender, EventArgs e) { try { #if MAVLINK10 + Log.Info("Sending level command (mavlink 1.0)"); int fixme; // needs to be accel only MainV2.comPort.doCommand(MAVLink.MAV_CMD.PREFLIGHT_CALIBRATION,1,1,1,1,1,1,1); #else + log.Info("Sending level command (mavlink 0.9)"); MainV2.comPort.doAction(MAVLink.MAV_ACTION.MAV_ACTION_CALIBRATE_ACC); #endif BUT_levelac2.Text = "Complete"; } - catch + catch(Exception ex) { + Log.Error("Exception on level", ex); CustomMessageBox.Show("Failed to level : ac2 2.0.37+ is required"); } } - private void pictureBoxQuad_Click(object sender, EventArgs e) + private void pictureBox_Click(object sender, EventArgs e) { - try - { - MainV2.comPort.setParam("FRAME", 0f); - CustomMessageBox.Show("Set to +"); - lbl_frame.Text = "+"; - } - catch { CustomMessageBox.Show("Set frame failed"); } + if (sender == pictureBoxPlus) + radioButton_Plus.Checked = true; + else + radioButton_X.Checked = true; } - private void ConfigAccelerometerCalibration_Load(object sender, EventArgs e) + private void SetPlus() { - if (!MainV2.comPort.BaseStream.IsOpen) + FadePicBoxes(DisabledOpacity, EnabledOpacity); + SetFrameParam(true); + } + + private void SetX() + { + FadePicBoxes(EnabledOpacity, DisabledOpacity); + SetFrameParam(false); + } + + private void SetFrameParam(bool isPlus) + { + var f = isPlus ? 0f : 1f; + + try { - this.Enabled = false; - return; + MainV2.comPort.setParam("FRAME", f); + } + catch + { + CustomMessageBox.Show("Set frame failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + + private void FadePicBoxes(float xOpacity, float plusOpacity) + { + var fade = new Transition(new TransitionType_Linear(400)); + fade.add(pictureBoxX, "Opacity", xOpacity); + fade.add(pictureBoxPlus, "Opacity", plusOpacity); + fade.run(); + } + + public void Activate() + { + if ((float)MainV2.comPort.param["FRAME"] == 0) + { + this.radioButton_Plus.Checked = true; + pictureBoxX.Opacity = DisabledOpacity; + pictureBoxPlus.Opacity = EnabledOpacity; } else { - if (MainV2.cs.firmware == MainV2.Firmwares.ArduCopter2) - { - this.Enabled = true; - } - else - { - this.Enabled = false; - return; - } + this.radioButton_X.Checked = true; + pictureBoxX.Opacity = EnabledOpacity; + pictureBoxPlus.Opacity = DisabledOpacity; } - try - { - lbl_frame.Text = ((float)MainV2.comPort.param["FRAME"] == 0) ? "+" : "X"; - } - catch { lbl_frame.Text = "Invalid Frame"; } + radioButton_Plus.CheckedChanged += RadioButtonPlusCheckedChanged; + } + + public void Deactivate() + { + radioButton_Plus.CheckedChanged -= RadioButtonPlusCheckedChanged; + + } + + void RadioButtonPlusCheckedChanged(object sender, EventArgs e) + { + if (radioButton_X.Checked) + SetX(); + else + SetPlus(); } } } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationQuad.resx b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationQuad.resx index e8c9f7ce21a..2d8586c8829 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationQuad.resx +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationQuad.resx @@ -118,271 +118,115 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + True - + NoControl - - 194, 8 + + 76, 96 - - 239, 13 + + 14, 13 - - 15 + + 23 - - Level your MultiCopter to set default accel offsets + + radioButton_Plus - - label28 + + System.Windows.Forms.RadioButton, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + $this - - 6 - - - True - - - NoControl - - - 254, 94 - - - 102, 13 - - - 12 - - - Frame Setup (+ or x) - - - label15 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 7 - - - NoControl - - - 71, 285 - - - 150, 150 - - - Zoom - - - 11 - - - pictureBoxQuadX - - - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - + 8 - + + True + + NoControl - - 71, 115 + + 76, 197 - - 150, 150 + + 14, 13 - - Zoom + + 24 - - 10 + + radioButton_X - - pictureBoxQuad + + System.Windows.Forms.RadioButton, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + $this - - 9 + + 7 - - 269, 38 + + True - - 75, 23 + + Microsoft Sans Serif, 12pt - - 16 - - - Level - - - BUT_levelac2 - - - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4503.13960, Culture=neutral, PublicKeyToken=null - - - $this - - - 10 - - + NoControl - - 227, 285 + + 16, 282 - - 150, 150 + + 191, 20 - - Zoom + + 65 - - 18 + + Accelerometer Calibration - - pictureBox1 + + label5 - - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 4 - - - NoControl - - - 227, 115 - - - 150, 150 - - - Zoom - - - 17 - - - pictureBox2 - - - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 5 - - - NoControl - - - 383, 285 - - - 150, 150 - - - Zoom - - - 20 - - - pictureBox3 - - - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 2 - - - NoControl - - - 383, 115 - - - 150, 150 - - - Zoom - - - 19 - - - pictureBox4 - - - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 + + 6 True + + Microsoft Sans Serif, 12pt + NoControl - 262, 74 + 16, 13 - 57, 13 + 102, 20 - 21 + 66 - Currently : + Frame Setup label1 @@ -394,36 +238,216 @@ $this - 1 + 5 - + True - + NoControl - - 323, 74 + + 39, 96 - - 13, 13 + + 31, 13 - - 22 + + 68 - - + + + 'Plus' - - lbl_frame + + label2 - + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - + + 4 + + + True + + + NoControl + + + 52, 197 + + + 18, 13 + + + 69 + + + 'X' + + + label3 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + NoControl + + + 116, 65 + + + 248, 81 + + + Zoom + + + 17 + + + pictureBoxPlus + + + ArdupilotMega.Controls.PictureBoxWithPseudoOpacity, ArdupilotMegaPlanner10, Version=1.1.4581.34461, Culture=neutral, PublicKeyToken=null + + + $this + + + 9 + + + NoControl + + + 116, 164 + + + 248, 85 + + + Zoom + + + 11 + + + pictureBoxX + + + ArdupilotMega.Controls.PictureBoxWithPseudoOpacity, ArdupilotMegaPlanner10, Version=1.1.4581.34461, Culture=neutral, PublicKeyToken=null + + + $this + + + 10 + + + NoControl + + + 378, 318 + + + 102, 23 + + + 16 + + + Calibrate Now + + + BUT_levelac2 + + + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4581.34461, Culture=neutral, PublicKeyToken=null + + + $this + + + 11 + + + True + + + 85, 323 + + + 279, 13 + + + 70 + + + Level your Multicopter to set default accelerometer offsets + + + label4 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + 20, 36 + + + 460, 2 + + + 80 + + + lineSeparator3 + + + ArdupilotMega.Controls.LineSeparator, ArdupilotMegaPlanner10, Version=1.1.4581.34461, Culture=neutral, PublicKeyToken=null + + + $this + + + 1 + + + 20, 300 + + + 460, 2 + + + 81 + + + lineSeparator2 + + + ArdupilotMega.Controls.LineSeparator, ArdupilotMegaPlanner10, Version=1.1.4581.34461, Culture=neutral, PublicKeyToken=null + + + $this + + 0 @@ -433,12 +457,12 @@ 6, 13 - 621, 460 + 495, 363 ConfigAccelerometerCalibrationQuad - ArdupilotMega.Controls.BackstageView.BackStageViewContentPanel, ArdupilotMegaPlanner, Version=1.1.4503.13960, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.UserControl, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.Designer.cs index b1247dc95ab..001ff14236e 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.Designer.cs @@ -303,6 +303,11 @@ // THR_RATE_IMAX // resources.ApplyResources(this.THR_RATE_IMAX, "THR_RATE_IMAX"); + this.THR_RATE_IMAX.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); this.THR_RATE_IMAX.Name = "THR_RATE_IMAX"; // // THR_RATE_I @@ -896,7 +901,6 @@ this.Controls.Add(this.groupBox24); this.Controls.Add(this.groupBox25); this.Name = "ConfigArducopter"; - this.Load += new System.EventHandler(this.ConfigArducopter_Load); ((System.ComponentModel.ISupportInitialize)(this.TUNE_LOW)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.TUNE_HIGH)).EndInit(); this.groupBox5.ResumeLayout(false); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.cs index b0ccea8669c..6f01f8c2ba0 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.cs @@ -12,7 +12,7 @@ using ArdupilotMega.Controls; namespace ArdupilotMega.GCSViews.ConfigurationView { - public partial class ConfigArducopter : BackStageViewContentPanel + public partial class ConfigArducopter : UserControl, IActivate { Hashtable changes = new Hashtable(); static Hashtable tooltips = new Hashtable(); @@ -34,7 +34,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView public string desc; } - private void ConfigArducopter_Load(object sender, EventArgs e) + public void Activate() { if (!MainV2.comPort.BaseStream.IsOpen) { @@ -203,6 +203,12 @@ namespace ArdupilotMega.GCSViews.ConfigurationView thisctl.Minimum = -180; } + if (thisctl.Name.ToUpper().EndsWith("THR_RATE_IMAX")) + { + thisctl.Maximum = 1000; // is a pwm + thisctl.Minimum = 0; + } + thisctl.Enabled = true; thisctl.BackColor = Color.FromArgb(0x43, 0x44, 0x45); @@ -412,7 +418,8 @@ namespace ArdupilotMega.GCSViews.ConfigurationView ((Control)sender).Enabled = true; - this.DoLoad(new EventArgs()); + + this.Activate(); } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.resx b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.resx index c155d19dff0..5f85ba95761 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.resx +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.resx @@ -135,7 +135,7 @@ myLabel3 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4564.20854, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4585.13688, Culture=neutral, PublicKeyToken=null $this @@ -201,7 +201,7 @@ myLabel2 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4564.20854, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4585.13688, Culture=neutral, PublicKeyToken=null $this @@ -312,7 +312,7 @@ myLabel1 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4564.20854, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4585.13688, Culture=neutral, PublicKeyToken=null $this @@ -2506,7 +2506,7 @@ BUT_writePIDS - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4564.20854, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.13688, Culture=neutral, PublicKeyToken=null $this @@ -2536,7 +2536,7 @@ BUT_rerequestparams - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4564.20854, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.13688, Culture=neutral, PublicKeyToken=null $this @@ -2782,6 +2782,6 @@ ConfigArducopter - ArdupilotMega.Controls.BackstageView.BackStageViewContentPanel, ArdupilotMegaPlanner10, Version=1.1.4564.20854, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.UserControl, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.Designer.cs index 0fd14d9cc30..dcc8c522695 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.Designer.cs @@ -824,7 +824,6 @@ this.Controls.Add(this.groupBox9); this.Controls.Add(this.groupBox8); this.Name = "ConfigArduplane"; - this.Load += new System.EventHandler(this.ConfigArduplane_Load); this.groupBox3.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.THR_FS_VALUE)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.THR_MAX)).EndInit(); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.cs index 575b7e9cb64..3eeccc83334 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.cs @@ -12,7 +12,7 @@ using ArdupilotMega.Controls; namespace ArdupilotMega.GCSViews.ConfigurationView { - public partial class ConfigArduplane : BackStageViewContentPanel + public partial class ConfigArduplane : UserControl, IActivate { Hashtable changes = new Hashtable(); static Hashtable tooltips = new Hashtable(); @@ -23,7 +23,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView InitializeComponent(); } - private void ConfigArduplane_Load(object sender, EventArgs e) + public void Activate() { if (!MainV2.comPort.BaseStream.IsOpen) { @@ -318,7 +318,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView ((Control)sender).Enabled = true; - this.DoLoad(new EventArgs()); + this.Activate(); } } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArdurover.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArdurover.Designer.cs index 271fce64f26..c0b39b4a6b9 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArdurover.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArdurover.Designer.cs @@ -509,7 +509,6 @@ this.Controls.Add(this.groupBox14); this.Controls.Add(this.groupBox11); this.Name = "ConfigArdurover"; - this.Load += new System.EventHandler(this.ConfigArduplane_Load); this.groupBox3.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.THR_FS_VALUE)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.THR_MAX)).EndInit(); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArdurover.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArdurover.cs index 12feeefa1a9..1c5036dd797 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArdurover.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArdurover.cs @@ -12,7 +12,7 @@ using ArdupilotMega.Controls; namespace ArdupilotMega.GCSViews.ConfigurationView { - public partial class ConfigArdurover : BackStageViewContentPanel + public partial class ConfigArdurover : UserControl, IActivate { Hashtable changes = new Hashtable(); static Hashtable tooltips = new Hashtable(); @@ -23,7 +23,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView InitializeComponent(); } - private void ConfigArduplane_Load(object sender, EventArgs e) + public void Activate() { if (!MainV2.comPort.BaseStream.IsOpen) { @@ -318,7 +318,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView ((Control)sender).Enabled = true; - this.DoLoad(new EventArgs()); + this.Activate(); } } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigBatteryMonitoring.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigBatteryMonitoring.Designer.cs index 13627c83b76..ca8aa746cf6 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigBatteryMonitoring.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigBatteryMonitoring.Designer.cs @@ -186,7 +186,6 @@ // // timer1 // - this.timer1.Enabled = true; this.timer1.Interval = 1000; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // @@ -204,7 +203,6 @@ this.Controls.Add(this.CMB_batmontype); this.Controls.Add(this.pictureBox5); this.Name = "ConfigBatteryMonitoring"; - this.Load += new System.EventHandler(this.ConfigBatteryMonitoring_Load); this.groupBox4.ResumeLayout(false); this.groupBox4.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit(); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigBatteryMonitoring.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigBatteryMonitoring.cs index 953efb94fc8..c420b573057 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigBatteryMonitoring.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigBatteryMonitoring.cs @@ -11,7 +11,7 @@ using ArdupilotMega.Controls; namespace ArdupilotMega.GCSViews.ConfigurationView { - public partial class ConfigBatteryMonitoring : BackStageViewContentPanel + public partial class ConfigBatteryMonitoring : UserControl, IActivate, IDeactivate { bool startup = false; @@ -278,18 +278,13 @@ namespace ArdupilotMega.GCSViews.ConfigurationView } } - private void ConfigBatteryMonitoring_Load(object sender, EventArgs e) + public void Deactivate() { - if (!MainV2.comPort.BaseStream.IsOpen) - { - this.Enabled = false; - return; - } - else - { - this.Enabled = true; - } + timer1.Stop(); + } + public void Activate() + { startup = true; bool not_supported = false; if (MainV2.comPort.param["BATT_MONITOR"] != null) @@ -345,6 +340,8 @@ namespace ArdupilotMega.GCSViews.ConfigurationView } startup = false; + + timer1.Start(); } int getIndex(ComboBox ctl, int no) diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigBatteryMonitoring.resx b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigBatteryMonitoring.resx index 34d2e7f1d59..3f3991e00d4 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigBatteryMonitoring.resx +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigBatteryMonitoring.resx @@ -682,6 +682,6 @@ Then subtract 0.3v from that value and enter it in field #1 at left. ConfigBatteryMonitoring - ArdupilotMega.Controls.BackstageView.BackStageViewContentPanel, ArdupilotMegaPlanner10, Version=1.1.4564.19603, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.UserControl, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigCameraStab.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigCameraStab.Designer.cs index f8e6c3c7f5e..8099c6e16c8 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigCameraStab.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigCameraStab.Designer.cs @@ -574,7 +574,6 @@ namespace ArdupilotMega.GCSViews.ConfigurationView this.Controls.Add(this.pictureBox1); this.Name = "ConfigCameraStab"; this.Size = new System.Drawing.Size(674, 432); - this.Load += new System.EventHandler(this.ConfigCameraStab_Load); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.presenterBindingSource)).EndInit(); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigCameraStab.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigCameraStab.cs index ca3a0f5cfc9..3c03d481027 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigCameraStab.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigCameraStab.cs @@ -10,7 +10,7 @@ using Transitions; namespace ArdupilotMega.GCSViews.ConfigurationView { - public partial class ConfigCameraStab : BackStageViewContentPanel + public partial class ConfigCameraStab : UserControl, IActivate { private ConfigCameraStabPresenter _presenter; private Transition[] _ErrorTransition; @@ -23,7 +23,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView LBL_Error.Opacity = 0.0F; } - private void ConfigCameraStab_Load(object sender, EventArgs ev) + public void Activate() { _presenter = new ConfigCameraStabPresenter(MainV2.comPort); presenterBindingSource.DataSource = _presenter; diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFlightModes.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFlightModes.Designer.cs index 23b51bcdcb1..137f3e145b7 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFlightModes.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFlightModes.Designer.cs @@ -279,7 +279,6 @@ this.Controls.Add(this.CMB_fmode1); this.Controls.Add(this.BUT_SaveModes); this.Name = "ConfigFlightModes"; - this.Load += new System.EventHandler(this.ConfigFlightModes_Load); ((System.ComponentModel.ISupportInitialize)(this.currentStateBindingSource)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFlightModes.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFlightModes.cs index fb8ba958ffe..7f4cf09bda6 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFlightModes.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFlightModes.cs @@ -12,7 +12,7 @@ using ArdupilotMega.Controls; namespace ArdupilotMega.GCSViews.ConfigurationView { - public partial class ConfigFlightModes : BackStageViewContentPanel + public partial class ConfigFlightModes : UserControl, IActivate, IDeactivate { Timer timer = new Timer(); @@ -124,18 +124,13 @@ namespace ArdupilotMega.GCSViews.ConfigurationView Simple6 = 32, } - private void ConfigFlightModes_Load(object sender, EventArgs e) + public void Deactivate() { - if (!MainV2.comPort.BaseStream.IsOpen) - { - this.Enabled = false; - return; - } - else - { - this.Enabled = true; - } + timer.Stop(); + } + public void Activate() + { if (MainV2.cs.firmware == MainV2.Firmwares.ArduPlane) // APM { CB_simple1.Visible = false; diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFriendlyParams.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFriendlyParams.Designer.cs index 444a62e31ab..f3dfda34d41 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFriendlyParams.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFriendlyParams.Designer.cs @@ -79,7 +79,6 @@ this.Controls.Add(this.tableLayoutPanel1); this.Name = "ConfigFriendlyParams"; this.Size = new System.Drawing.Size(673, 177); - this.Load += new System.EventHandler(this.ConfigRawParamsV2_Load); this.ResumeLayout(false); } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFriendlyParams.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFriendlyParams.cs index 050eebb2989..aa9518f602f 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFriendlyParams.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigFriendlyParams.cs @@ -14,7 +14,7 @@ using log4net; namespace ArdupilotMega.GCSViews.ConfigurationView { - public partial class ConfigFriendlyParams : BackStageViewContentPanel + public partial class ConfigFriendlyParams : UserControl, IActivate { #region Class Fields @@ -130,7 +130,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView /// /// The source of the event. /// The instance containing the event data. - protected void ConfigRawParamsV2_Load(object sender, EventArgs e) + public void Activate() { BindParamList(); } @@ -297,6 +297,8 @@ namespace ArdupilotMega.GCSViews.ConfigurationView catch (Exception ex) { log.Error(ex); } } }); + + ThemeManager.ApplyThemeTo(this); } /// diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigHardwareOptions.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigHardwareOptions.Designer.cs index fa7ac3e81ea..474d57dc7d9 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigHardwareOptions.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigHardwareOptions.Designer.cs @@ -191,7 +191,6 @@ this.Controls.Add(this.pictureBox3); this.Controls.Add(this.pictureBox1); this.Name = "ConfigHardwareOptions"; - this.Load += new System.EventHandler(this.ConfigHardwareOptions_Load); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit(); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigHardwareOptions.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigHardwareOptions.cs index 4355da48d61..2afd0b7de5f 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigHardwareOptions.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigHardwareOptions.cs @@ -11,7 +11,7 @@ using ArdupilotMega.Controls; namespace ArdupilotMega.GCSViews.ConfigurationView { - public partial class ConfigHardwareOptions : BackStageViewContentPanel + public partial class ConfigHardwareOptions : UserControl, IActivate { bool startup = false; @@ -233,7 +233,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView catch { CustomMessageBox.Show("Set SONAR_TYPE Failed"); } } - private void ConfigHardwareOptions_Load(object sender, EventArgs e) + public void Activate() { if (!MainV2.comPort.BaseStream.IsOpen) { diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigPlanner.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigPlanner.cs index 7f764f6ef8d..642f93887be 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigPlanner.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigPlanner.cs @@ -16,10 +16,10 @@ using System.Threading; namespace ArdupilotMega.GCSViews.ConfigurationView { - public partial class ConfigPlanner : BackStageViewContentPanel + public partial class ConfigPlanner : UserControl, IActivate { private bool startup = false; - List languages = new List(); + private List _languages; public class GCSBitmapInfo { @@ -422,104 +422,12 @@ namespace ArdupilotMega.GCSViews.ConfigurationView MainV2.config["CHK_GDIPlus"] = CHK_GDIPlus.Checked.ToString(); } + // This load handler now only contains code that should execute once + // on start up. See Activate() for the remainder private void ConfigPlanner_Load(object sender, EventArgs e) { startup = true; - // setup up camera button states - if (MainV2.cam != null) - { - BUT_videostart.Enabled = false; - CHK_hudshow.Checked = GCSViews.FlightData.myhud.hudon; - } - else - { - BUT_videostart.Enabled = true; - } - - // setup speech states - if (MainV2.config["speechenable"] != null) - CHK_enablespeech.Checked = bool.Parse(MainV2.config["speechenable"].ToString()); - if (MainV2.config["speechwaypointenabled"] != null) - CHK_speechwaypoint.Checked = bool.Parse(MainV2.config["speechwaypointenabled"].ToString()); - if (MainV2.config["speechmodeenabled"] != null) - CHK_speechmode.Checked = bool.Parse(MainV2.config["speechmodeenabled"].ToString()); - if (MainV2.config["speechcustomenabled"] != null) - CHK_speechcustom.Checked = bool.Parse(MainV2.config["speechcustomenabled"].ToString()); - if (MainV2.config["speechbatteryenabled"] != null) - CHK_speechbattery.Checked = bool.Parse(MainV2.config["speechbatteryenabled"].ToString()); - if (MainV2.config["speechaltenabled"] != null) - CHK_speechaltwarning.Checked = bool.Parse(MainV2.config["speechaltenabled"].ToString()); - - // this can't fail because it set at startup - NUM_tracklength.Value = int.Parse(MainV2.config["NUM_tracklength"].ToString()); - - // get wps on connect - if (MainV2.config["loadwpsonconnect"] != null) - CHK_loadwponconnect.Checked = bool.Parse(MainV2.config["loadwpsonconnect"].ToString()); - - // setup other config state - if (MainV2.config["CHK_resetapmonconnect"] != null) - CHK_resetapmonconnect.Checked = bool.Parse(MainV2.config["CHK_resetapmonconnect"].ToString()); - - CMB_rateattitude.Text = MainV2.cs.rateattitude.ToString(); - CMB_rateposition.Text = MainV2.cs.rateposition.ToString(); - CMB_raterc.Text = MainV2.cs.raterc.ToString(); - CMB_ratestatus.Text = MainV2.cs.ratestatus.ToString(); - CMB_ratesensors.Text = MainV2.cs.ratesensors.ToString(); - - - if (MainV2.config["CHK_GDIPlus"] != null) - CHK_GDIPlus.Checked = bool.Parse(MainV2.config["CHK_GDIPlus"].ToString()); - - if (MainV2.config["CHK_maprotation"] != null) - CHK_maprotation.Checked = bool.Parse(MainV2.config["CHK_maprotation"].ToString()); - - //set hud color state - string hudcolor = (string)MainV2.config["hudcolor"]; - - CMB_osdcolor.DataSource = Enum.GetNames(typeof(KnownColor)); - if (hudcolor != null) - { - int index = CMB_osdcolor.Items.IndexOf(hudcolor); - CMB_osdcolor.SelectedIndex = index; - } - else - { - int index = CMB_osdcolor.Items.IndexOf("White"); - CMB_osdcolor.SelectedIndex = index; - } - - // set distance/speed unit states - CMB_distunits.DataSource = Enum.GetNames(typeof(Common.distances)); - CMB_speedunits.DataSource = Enum.GetNames(typeof(Common.speeds)); - - if (MainV2.config["distunits"] != null) - CMB_distunits.Text = MainV2.config["distunits"].ToString(); - if (MainV2.config["speedunits"] != null) - CMB_speedunits.Text = MainV2.config["speedunits"].ToString(); - - // setup language selection - CultureInfo ci = null; - foreach (string name in new string[] { "en-US", "zh-Hans", "zh-TW", "ru-RU", "Fr", "Pl", "it-IT", "es-ES" }) - { - ci = CultureInfoEx.GetCultureInfo(name); - if (ci != null) - languages.Add(ci); - } - - CMB_language.DisplayMember = "DisplayName"; - CMB_language.DataSource = languages; - ci = Thread.CurrentThread.CurrentUICulture; - for (int i = 0; i < languages.Count; i++) - { - if (ci.IsChildOf(languages[i])) - { - CMB_language.SelectedIndex = i; - break; - } - } - //CMB_language.SelectedIndexChanged += CMB_language_SelectedIndexChanged; startup = false; } @@ -571,5 +479,94 @@ namespace ArdupilotMega.GCSViews.ConfigurationView return; MainV2.config["CHK_maprotation"] = CHK_maprotation.Checked.ToString(); } + // Called every time that this control is made current in the backstage view + public void Activate() + { + startup = true; // flag to ignore changes while we programatically populate controls + + + CMB_osdcolor.DataSource = Enum.GetNames(typeof(KnownColor)); + + // set distance/speed unit states + CMB_distunits.DataSource = Enum.GetNames(typeof(Common.distances)); + CMB_speedunits.DataSource = Enum.GetNames(typeof(Common.speeds)); + + // setup language selection + var cultureCodes = new[] { "en-US", "zh-Hans", "zh-TW", "ru-RU", "Fr", "Pl", "it-IT", "es-ES" }; + + _languages = cultureCodes + .Select(CultureInfoEx.GetCultureInfo) + .Where(c => c != null) + .ToList(); + + CMB_language.DisplayMember = "DisplayName"; + CMB_language.DataSource = _languages; + var currentUiCulture = Thread.CurrentThread.CurrentUICulture; + + for (int i = 0; i < _languages.Count; i++) + { + if (currentUiCulture.IsChildOf(_languages[i])) + { + CMB_language.SelectedIndex = i; + break; + } + } + + // setup up camera button states + if (MainV2.cam != null) + { + BUT_videostart.Enabled = false; + CHK_hudshow.Checked = GCSViews.FlightData.myhud.hudon; + } + else + { + BUT_videostart.Enabled = true; + } + + // setup speech states + SetCheckboxFromConfig("speechenable", CHK_enablespeech); + SetCheckboxFromConfig("speechwaypointenabled", CHK_speechwaypoint); + SetCheckboxFromConfig("speechmodeenabled", CHK_speechmode); + SetCheckboxFromConfig("speechcustomenabled", CHK_speechcustom); + SetCheckboxFromConfig("speechbatteryenabled", CHK_speechbattery); + SetCheckboxFromConfig("speechaltenabled", CHK_speechaltwarning); + + // this can't fail because it set at startup + NUM_tracklength.Value = int.Parse(MainV2.config["NUM_tracklength"].ToString()); + + // get wps on connect + SetCheckboxFromConfig("loadwpsonconnect", CHK_loadwponconnect); + + // setup other config state + SetCheckboxFromConfig("CHK_resetapmonconnect", CHK_resetapmonconnect); + + CMB_rateattitude.Text = MainV2.cs.rateattitude.ToString(); + CMB_rateposition.Text = MainV2.cs.rateposition.ToString(); + CMB_raterc.Text = MainV2.cs.raterc.ToString(); + CMB_ratestatus.Text = MainV2.cs.ratestatus.ToString(); + CMB_ratesensors.Text = MainV2.cs.ratesensors.ToString(); + + SetCheckboxFromConfig("CHK_GDIPlus", CHK_GDIPlus); + SetCheckboxFromConfig("CHK_maprotation", CHK_maprotation); + + //set hud color state + string hudcolor = (string)MainV2.config["hudcolor"]; + int index = CMB_osdcolor.Items.IndexOf(hudcolor ?? "White"); + CMB_osdcolor.SelectedIndex = index; + + + if (MainV2.config["distunits"] != null) + CMB_distunits.Text = MainV2.config["distunits"].ToString(); + if (MainV2.config["speedunits"] != null) + CMB_speedunits.Text = MainV2.config["speedunits"].ToString(); + } + + + + private static void SetCheckboxFromConfig(string configKey, CheckBox chk) + { + if (MainV2.config[configKey] != null) + chk.Checked = bool.Parse(MainV2.config[configKey].ToString()); + } } } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRadioInput.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRadioInput.Designer.cs index e3109a7abce..0cddec28b3c 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRadioInput.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRadioInput.Designer.cs @@ -269,7 +269,6 @@ this.Controls.Add(this.BARyaw); this.Controls.Add(this.BARroll); this.Name = "ConfigRadioInput"; - this.Load += new System.EventHandler(this.ConfigRadioInput_Load); this.groupBoxElevons.ResumeLayout(false); this.groupBoxElevons.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.currentStateBindingSource)).EndInit(); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRadioInput.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRadioInput.cs index dd659eaa355..e09399c2227 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRadioInput.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRadioInput.cs @@ -11,7 +11,7 @@ using ArdupilotMega.Controls; namespace ArdupilotMega.GCSViews.ConfigurationView { - public partial class ConfigRadioInput : BackStageViewContentPanel + public partial class ConfigRadioInput : UserControl, IActivate, IDeactivate { bool startup = false; bool run = false; @@ -36,10 +36,11 @@ namespace ArdupilotMega.GCSViews.ConfigurationView // setup rc update timer.Tick += new EventHandler(timer_Tick); + } - timer.Enabled = true; - timer.Interval = 100; - timer.Start(); + public void Deactivate() + { + timer.Stop(); } void timer_Tick(object sender, EventArgs e) @@ -52,17 +53,11 @@ namespace ArdupilotMega.GCSViews.ConfigurationView catch { } } - private void ConfigRadioInput_Load(object sender, EventArgs e) + public void Activate() { - if (!MainV2.comPort.BaseStream.IsOpen) - { - this.Enabled = false; - return; - } - else - { - this.Enabled = true; - } + timer.Enabled = true; + timer.Interval = 100; + timer.Start(); startup = true; diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRawParams.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRawParams.Designer.cs index 6b072f30bfa..21aab51f675 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRawParams.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRawParams.Designer.cs @@ -151,7 +151,6 @@ this.Controls.Add(this.BUT_load); this.Controls.Add(this.Params); this.Name = "ConfigRawParams"; - this.Load += new System.EventHandler(this.ConfigRawParams_Load); ((System.ComponentModel.ISupportInitialize)(this.Params)).EndInit(); this.ResumeLayout(false); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRawParams.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRawParams.cs index 7c7cb95e0ed..df10f0b4b6e 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRawParams.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRawParams.cs @@ -11,7 +11,7 @@ using ArdupilotMega.Controls.BackstageView; namespace ArdupilotMega.GCSViews.ConfigurationView { - public partial class ConfigRawParams : BackStageViewContentPanel + public partial class ConfigRawParams : UserControl, IActivate { private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); @@ -424,7 +424,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView Params.Sort(Params.Columns[0], ListSortDirection.Ascending); } - private void ConfigRawParams_Load(object sender, EventArgs e) + public void Activate() { // read tooltips if (tooltips.Count == 0) diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigTradHeli.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigTradHeli.Designer.cs index 1b8df594190..ed9e82af790 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigTradHeli.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigTradHeli.Designer.cs @@ -685,8 +685,6 @@ this.Controls.Add(this.HS3); this.Controls.Add(this.Gservoloc); this.Name = "ConfigTradHeli"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ConfigTradHeli_FormClosing); - this.Load += new System.EventHandler(this.ConfigTradHeli_Load); this.groupBox5.ResumeLayout(false); this.groupBox5.PerformLayout(); this.groupBox3.ResumeLayout(false); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigTradHeli.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigTradHeli.cs index 6f99332ff1f..1c806247fb1 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigTradHeli.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigTradHeli.cs @@ -11,7 +11,7 @@ using ArdupilotMega.Controls; namespace ArdupilotMega.GCSViews.ConfigurationView { - public partial class ConfigTradHeli : BackStageViewContentPanel + public partial class ConfigTradHeli : UserControl, IActivate, IDeactivate { bool startup = false; bool inpwmdetect = false; @@ -368,17 +368,8 @@ namespace ArdupilotMega.GCSViews.ConfigurationView MainV2.comPort.setParam(((CheckBox)sender).Name, ((CheckBox)sender).Checked == true ? 1.0f : 0.0f); } - private void ConfigTradHeli_Load(object sender, EventArgs e) + public void Activate() { - if (!MainV2.comPort.BaseStream.IsOpen) - { - this.Enabled = false; - return; - } - else - { - this.Enabled = true; - } if (MainV2.comPort.param["H_GYR_ENABLE"] == null) { @@ -487,8 +478,10 @@ namespace ArdupilotMega.GCSViews.ConfigurationView } } - private void ConfigTradHeli_FormClosing(object sender, FormClosingEventArgs e) + public void Deactivate() { + timer.Stop(); + startup = true; } } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Setup.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Setup.cs index 602e7bce28c..ccafe8a6431 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Setup.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Setup.cs @@ -25,18 +25,22 @@ namespace ArdupilotMega.GCSViews.ConfigurationView if (MainV2.comPort.BaseStream.IsOpen) { AddPagesForConnectedState(); + // backstageView.AddSpacer(20); } // These pages work when not connected to an APM AddBackstageViewPage(new ArdupilotMega._3DRradio(), "3DR Radio"); AddBackstageViewPage(new ArdupilotMega.Antenna.Tracker(), "Antenna Tracker"); +//backstageView.AddSpacer(15); AddBackstageViewPage(new ConfigPlanner(), "Planner"); this.backstageView.ActivatePage(backstageView.Pages[0]); if (!MainV2.comPort.BaseStream.IsOpen) { - Common.MessageShowAgain("Config Connect", "Please connect (click Connect Button) before using setup!!"); + ThemeManager.ApplyThemeTo(this); + Common.MessageShowAgain("Config Connect", @"Please connect (click Connect Button) before using setup. +If you are just setting up 3DR radios, you may continue without connecting."); } } @@ -61,8 +65,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView AddBackstageViewPage(new ConfigTradHeli(), "Heli Setup"); - var configpanel = new Controls.ConfigPanel(); - configpanel.LoadXML("ArduCopterConfig.xml"); + var configpanel = new Controls.ConfigPanel(Application.StartupPath + System.IO.Path.DirectorySeparatorChar + "ArduCopterConfig.xml"); AddBackstageViewPage(configpanel, "ArduCopter Pids"); AddBackstageViewPage(new ConfigArducopter(), "ArduCopter Config"); @@ -74,8 +77,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView AddBackstageViewPage(new ConfigAccelerometerCalibrationQuad(), "ArduCopter Level"); - var configpanel = new Controls.ConfigPanel(); - configpanel.LoadXML("ArduCopterConfig.xml"); + var configpanel = new Controls.ConfigPanel(Application.StartupPath + System.IO.Path.DirectorySeparatorChar + "ArduCopterConfig.xml"); AddBackstageViewPage(configpanel, "ArduCopter Pids"); AddBackstageViewPage(new ConfigArducopter(), "ArduCopter Config"); @@ -99,9 +101,9 @@ namespace ArdupilotMega.GCSViews.ConfigurationView AddBackstageViewPage(new ConfigRawParams(), "Parameter List"); } - private void AddBackstageViewPage(BackStageViewContentPanel userControl, string headerText) + private void AddBackstageViewPage(UserControl userControl, string headerText) { - backstageView.AddPage(new BackstageView.BackstageViewPage(userControl, headerText)); + backstageView.AddPage(userControl, headerText); } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.Designer.cs index f86424e8cbf..25f4a81c19d 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.Designer.cs @@ -1161,6 +1161,7 @@ this.Controls.Add(this.label6); this.MinimumSize = new System.Drawing.Size(1008, 461); this.Name = "FlightData"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FlightData_FormClosing); this.Load += new System.EventHandler(this.FlightData_Load); this.Resize += new System.EventHandler(this.FlightData_Resize); this.ParentChanged += new System.EventHandler(this.FlightData_ParentChanged); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs index 0e3be7e4aea..335627742c5 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs @@ -18,13 +18,14 @@ using ZedGraph; // Graphs using System.Drawing.Drawing2D; using ArdupilotMega.Controls; using ArdupilotMega.Utilities; +using ArdupilotMega.Controls.BackstageView; // written by michael oborne namespace ArdupilotMega.GCSViews { - partial class FlightData : MyUserControl + partial class FlightData : MyUserControl, IActivate, IDeactivate { - ArdupilotMega.IMAVLink comPort = MainV2.comPort; + ArdupilotMega.MAVLink comPort = MainV2.comPort; public static int threadrun = 0; StreamWriter swlog; int tickStart = 0; @@ -196,6 +197,22 @@ namespace ArdupilotMega.GCSViews catch { } } + public void Activate() + { + if (CB_tuning.Checked) + ZedGraphTimer.Start(); + + // SubMainLeft.Panel1.Controls.Clear(); + // SubMainLeft.Panel1.Controls.Add(hud1); + } + + public void Deactivate() + { + //SubMainLeft.Panel1.Controls.Remove(hud1); + hud1.Size = new System.Drawing.Size(0, 0); + ZedGraphTimer.Stop(); + } + void tabControl1_DrawItem(object sender, DrawItemEventArgs e) { // Draw the background of the ListBox control for each item. @@ -223,8 +240,6 @@ namespace ArdupilotMega.GCSViews private void FlightData_Load(object sender, EventArgs e) { - MainV2.bs = bindingSource1; - System.Threading.Thread t11 = new System.Threading.Thread(new System.Threading.ThreadStart(mainloop)) { IsBackground = true, @@ -255,6 +270,8 @@ namespace ArdupilotMega.GCSViews DateTime tunning = DateTime.Now.AddSeconds(0); + DateTime mapupdate = DateTime.Now.AddSeconds(0); + DateTime vidrec = DateTime.Now.AddSeconds(0); DateTime waypoints = DateTime.Now.AddSeconds(0); @@ -319,8 +336,6 @@ namespace ArdupilotMega.GCSViews updatePlayPauseButton(true); - MainV2.comPort.setAPType(); - if (comPort.BaseStream.IsOpen) { MainV2.comPort.logreadmode = false; @@ -429,45 +444,51 @@ namespace ArdupilotMega.GCSViews setMapBearing(); } + if (route == null) + { + route = new GMapRoute(trackPoints, "track"); + routes.Routes.Add(route); + } + + PointLatLng currentloc = new PointLatLng(MainV2.cs.lat, MainV2.cs.lng); + gMapControl1.HoldInvalidation = true; + int cnt = 0; + while (gMapControl1.inOnPaint == true) { System.Threading.Thread.Sleep(1); + cnt++; } - - if (trackPoints.Count > int.Parse(MainV2.config["NUM_tracklength"].ToString())) + + if (route.Points.Count > int.Parse(MainV2.config["NUM_tracklength"].ToString())) { - trackPoints.RemoveRange(0, trackPoints.Count - int.Parse(MainV2.config["NUM_tracklength"].ToString())); + // trackPoints.RemoveRange(0, trackPoints.Count - int.Parse(MainV2.config["NUM_tracklength"].ToString())); + route.Points.RemoveRange(0, route.Points.Count - int.Parse(MainV2.config["NUM_tracklength"].ToString())); } if (MainV2.cs.lat != 0) - trackPoints.Add(new PointLatLng(MainV2.cs.lat, MainV2.cs.lng)); + { + // trackPoints.Add(currentloc); + route.Points.Add(currentloc); + } // if (CB_tuning.Checked == false) // draw if in view { - if (MainV2.comPort.logreadmode && MainV2.comPort.logplaybackfile != null) - { - // this is for the pulled wp list from a mavlink logfile - FlightPlanner.pointlist.Clear(); - FlightPlanner.pointlist.AddRange(MainV2.comPort.wps); - } - - while (gMapControl1.inOnPaint == true) { System.Threading.Thread.Sleep(1); } - updateClearRoutes(); - - route = new GMapRoute(trackPoints, "track"); + //route = new GMapRoute(route.Points, "track"); //track.Stroke = Pens.Red; //route.Stroke = new Pen(Color.FromArgb(144, Color.Red)); //route.Stroke.Width = 5; //route.Tag = "track"; + routes.Routes.Clear(); routes.Routes.Add(route); if (waypoints.AddSeconds(10) < DateTime.Now) @@ -475,6 +496,12 @@ namespace ArdupilotMega.GCSViews //Console.WriteLine("Doing FD WP's"); polygons.Markers.Clear(); + if (MainV2.comPort.logreadmode && MainV2.comPort.logplaybackfile != null) + { + FlightPlanner.pointlist.Clear(); + FlightPlanner.pointlist.AddRange(MainV2.comPort.wps); + } + foreach (PointLatLngAlt plla in FlightPlanner.pointlist) { if (plla == null || plla.Lng == 0 || plla.Lat == 0) @@ -494,29 +521,35 @@ namespace ArdupilotMega.GCSViews //routes.Polygons.Add(poly); - if (trackPoints.Count > 0) + if (route.Points.Count > 0) { - PointLatLng currentloc = new PointLatLng(MainV2.cs.lat, MainV2.cs.lng); + // add primary route icon + if (routes.Markers.Count != 1) + { + routes.Markers.Clear(); + routes.Markers.Add( new GMapMarkerCross(currentloc)); + } if (MainV2.cs.firmware == MainV2.Firmwares.ArduPlane) { - routes.Markers.Add(new GMapMarkerPlane(currentloc, MainV2.cs.yaw, MainV2.cs.groundcourse, MainV2.cs.nav_bearing, MainV2.cs.target_bearing, gMapControl1)); + routes.Markers[0] = (new GMapMarkerPlane(currentloc, MainV2.cs.yaw, MainV2.cs.groundcourse, MainV2.cs.nav_bearing, MainV2.cs.target_bearing, gMapControl1)); } else if (MainV2.cs.firmware == MainV2.Firmwares.ArduRover) { - routes.Markers.Add(new GMapMarkerRover(currentloc, MainV2.cs.yaw, MainV2.cs.groundcourse, MainV2.cs.nav_bearing, MainV2.cs.target_bearing, gMapControl1)); + routes.Markers[0] = (new GMapMarkerRover(currentloc, MainV2.cs.yaw, MainV2.cs.groundcourse, MainV2.cs.nav_bearing, MainV2.cs.target_bearing, gMapControl1)); } else { - routes.Markers.Add(new GMapMarkerQuad(currentloc, MainV2.cs.yaw, MainV2.cs.groundcourse, MainV2.cs.nav_bearing)); + routes.Markers[0] = (new GMapMarkerQuad(currentloc, MainV2.cs.yaw, MainV2.cs.groundcourse, MainV2.cs.nav_bearing)); } - if (trackPoints[trackPoints.Count - 1].Lat != 0 && (DateTime.Now.Second % 4 == 0) && CHK_autopan.Checked) + if (route.Points[route.Points.Count - 1].Lat != 0 && (mapupdate.AddSeconds(3) < DateTime.Now) && CHK_autopan.Checked) { updateMapPosition(currentloc); + mapupdate = DateTime.Now; } - if (trackPoints.Count == 1 && gMapControl1.Zoom == 3) // 3 is the default load zoom + if (route.Points.Count == 1 && gMapControl1.Zoom == 3) // 3 is the default load zoom { updateMapPosition(currentloc); updateMapZoom(17); @@ -539,28 +572,19 @@ namespace ArdupilotMega.GCSViews private void setMapBearing() { - this.Invoke((System.Windows.Forms.MethodInvoker)delegate() + this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate() { gMapControl1.Bearing = (int)MainV2.cs.yaw; }); } - - // to prevent cross thread calls while in a draw and exception - private void updateClearRoutes() - { - // not async - this.Invoke((System.Windows.Forms.MethodInvoker)delegate() - { - routes.Markers.Clear(); - routes.Routes.Clear(); - }); - } - private void updatePlayPauseButton(bool playing) { if (playing) { + if (BUT_playlog.Text == "Pause") + return; + this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate() { try @@ -626,9 +650,10 @@ namespace ArdupilotMega.GCSViews { try { - tracklog.Value = (int)(MainV2.comPort.logplaybackfile.BaseStream.Position / (double)MainV2.comPort.logplaybackfile.BaseStream.Length * 100); - - lbl_logpercent.Text = (MainV2.comPort.logplaybackfile.BaseStream.Position / (double)MainV2.comPort.logplaybackfile.BaseStream.Length).ToString("0.00%"); + if (tracklog.Visible) + tracklog.Value = (int)(MainV2.comPort.logplaybackfile.BaseStream.Position / (double)MainV2.comPort.logplaybackfile.BaseStream.Length * 100); + if (lbl_logpercent.Visible) + lbl_logpercent.Text = (MainV2.comPort.logplaybackfile.BaseStream.Position / (double)MainV2.comPort.logplaybackfile.BaseStream.Length).ToString("0.00%"); } catch { } }); @@ -806,15 +831,20 @@ namespace ArdupilotMega.GCSViews { ZedGraphTimer.Stop(); threadrun = 0; - if (comPort.BaseStream.IsOpen) + try { - comPort.Close(); + if (comPort.BaseStream.IsOpen) + { + comPort.Close(); + } } + catch { } } private void BUT_clear_track_Click(object sender, EventArgs e) { - trackPoints.Clear(); + if (route !=null) + route.Points.Clear(); } private void BUT_save_log_Click(object sender, EventArgs e) @@ -1349,7 +1379,7 @@ namespace ArdupilotMega.GCSViews foreach (Control temp in tabStatus.Controls) { - temp.DataBindings.Clear(); + // temp.DataBindings.Clear(); //temp.Dispose(); } //tabStatus.Controls.Clear(); @@ -1387,10 +1417,14 @@ namespace ArdupilotMega.GCSViews } catch { } + if (add) + { + lbl1.Location = new Point(x, y); lbl1.Size = new System.Drawing.Size(75, 13); lbl1.Text = field.Name; lbl1.Name = field.Name; + lbl1.Visible = true; lbl2.AutoSize = false; lbl2.Location = new Point(lbl1.Right + 5, y); @@ -1398,10 +1432,10 @@ namespace ArdupilotMega.GCSViews //if (lbl2.Name == "") lbl2.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bindingSource1, field.Name, true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, "")); lbl2.Name = field.Name + "value"; + lbl2.Visible = true; //lbl2.Text = fieldValue.ToString(); - if (add) - { + tabStatus.Controls.Add(lbl1); tabStatus.Controls.Add(lbl2); } @@ -1426,7 +1460,9 @@ namespace ArdupilotMega.GCSViews { foreach (Control temp in tabStatus.Controls) { - temp.DataBindings.Clear(); + // temp.DataBindings.Clear(); + // temp.Dispose(); + // tabStatus.Controls.Remove(temp); } } } @@ -1903,5 +1939,6 @@ print 'Roll complete' { hud1.batteryon = !hud1.batteryon; } + } } \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.resx b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.resx index 245f70bf344..dffd4144370 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.resx +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.resx @@ -226,7 +226,7 @@ hud1 - ArdupilotMega.Controls.HUD, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.HUD, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null SubMainLeft.Panel1 @@ -265,7 +265,7 @@ BUT_script - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabActions @@ -298,7 +298,7 @@ BUT_joystick - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabActions @@ -328,7 +328,7 @@ BUT_quickmanual - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabActions @@ -358,7 +358,7 @@ BUT_quickrtl - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabActions @@ -388,7 +388,7 @@ BUT_quickauto - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabActions @@ -442,7 +442,7 @@ BUT_setwp - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabActions @@ -493,7 +493,7 @@ BUT_setmode - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabActions @@ -523,7 +523,7 @@ BUT_clear_track - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabActions @@ -574,7 +574,7 @@ BUT_Homealt - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabActions @@ -604,7 +604,7 @@ BUT_RAWSensor - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabActions @@ -634,7 +634,7 @@ BUTrestartmission - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabActions @@ -664,7 +664,7 @@ BUTactiondo - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabActions @@ -718,7 +718,7 @@ Gvspeed - AGaugeApp.AGauge, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + AGaugeApp.AGauge, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabGauges @@ -748,7 +748,7 @@ Gheading - ArdupilotMega.Controls.HSI, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.HSI, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabGauges @@ -778,7 +778,7 @@ Galt - AGaugeApp.AGauge, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + AGaugeApp.AGauge, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabGauges @@ -811,7 +811,7 @@ Gspeed - AGaugeApp.AGauge, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + AGaugeApp.AGauge, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabGauges @@ -895,7 +895,7 @@ lbl_playbackspeed - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabTLogs @@ -922,7 +922,7 @@ lbl_logpercent - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabTLogs @@ -949,7 +949,7 @@ NUM_playbackspeed - ArdupilotMega.Controls.MyTrackBar, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyTrackBar, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabTLogs @@ -976,7 +976,7 @@ BUT_log2kml - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabTLogs @@ -1030,7 +1030,7 @@ BUT_playlog - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabTLogs @@ -1057,7 +1057,7 @@ BUT_loadtelem - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null tabTLogs @@ -1246,7 +1246,7 @@ lbl_hdop - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null splitContainer1.Panel2 @@ -1279,7 +1279,7 @@ lbl_sats - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null splitContainer1.Panel2 @@ -1309,7 +1309,7 @@ lbl_winddir - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null splitContainer1.Panel2 @@ -1339,7 +1339,7 @@ lbl_windvel - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null splitContainer1.Panel2 @@ -1511,7 +1511,7 @@ gMapControl1 - ArdupilotMega.Controls.myGMAP, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.myGMAP, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null splitContainer1.Panel2 @@ -1574,7 +1574,7 @@ TXT_lat - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null panel1 @@ -1631,7 +1631,7 @@ label1 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null panel1 @@ -1661,7 +1661,7 @@ TXT_long - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null panel1 @@ -1691,7 +1691,7 @@ TXT_alt - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null panel1 @@ -1892,7 +1892,7 @@ label6 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null $this @@ -1988,6 +1988,6 @@ FlightData - System.Windows.Forms.MyUserControl, ArdupilotMegaPlanner10, Version=1.1.4580.38577, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.MyUserControl, ArdupilotMegaPlanner10, Version=1.1.4585.31842, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.Designer.cs index 6cfcf061af2..9a16bdec806 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.Designer.cs @@ -111,13 +111,13 @@ this.jumpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.jumpstartToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.jumpwPToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.createWpCircleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.ContextMeasure = new System.Windows.Forms.ToolStripMenuItem(); this.rotateMapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.polygonToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.addPolygonPointToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.clearPolygonToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.clearMissionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.geoFenceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); @@ -126,6 +126,7 @@ this.setReturnLocationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.loadFromFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveToFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.clearMissionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.trackBar1 = new ArdupilotMega.Controls.MyTrackBar(); this.label11 = new System.Windows.Forms.Label(); this.panelBASE = new System.Windows.Forms.Panel(); @@ -721,12 +722,13 @@ this.deleteWPToolStripMenuItem, this.loiterToolStripMenuItem, this.jumpToolStripMenuItem, + this.createWpCircleToolStripMenuItem, this.toolStripSeparator1, this.ContextMeasure, this.rotateMapToolStripMenuItem, this.polygonToolStripMenuItem, - this.clearMissionToolStripMenuItem, - this.geoFenceToolStripMenuItem}); + this.geoFenceToolStripMenuItem, + this.clearMissionToolStripMenuItem}); this.contextMenuStrip1.Name = "contextMenuStrip1"; resources.ApplyResources(this.contextMenuStrip1, "contextMenuStrip1"); // @@ -783,6 +785,12 @@ resources.ApplyResources(this.jumpwPToolStripMenuItem, "jumpwPToolStripMenuItem"); this.jumpwPToolStripMenuItem.Click += new System.EventHandler(this.jumpwPToolStripMenuItem_Click); // + // createWpCircleToolStripMenuItem + // + this.createWpCircleToolStripMenuItem.Name = "createWpCircleToolStripMenuItem"; + resources.ApplyResources(this.createWpCircleToolStripMenuItem, "createWpCircleToolStripMenuItem"); + this.createWpCircleToolStripMenuItem.Click += new System.EventHandler(this.createWpCircleToolStripMenuItem_Click); + // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; @@ -820,12 +828,6 @@ resources.ApplyResources(this.clearPolygonToolStripMenuItem, "clearPolygonToolStripMenuItem"); this.clearPolygonToolStripMenuItem.Click += new System.EventHandler(this.clearPolygonToolStripMenuItem_Click); // - // clearMissionToolStripMenuItem - // - this.clearMissionToolStripMenuItem.Name = "clearMissionToolStripMenuItem"; - resources.ApplyResources(this.clearMissionToolStripMenuItem, "clearMissionToolStripMenuItem"); - this.clearMissionToolStripMenuItem.Click += new System.EventHandler(this.clearMissionToolStripMenuItem_Click); - // // geoFenceToolStripMenuItem // this.geoFenceToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -879,6 +881,12 @@ resources.ApplyResources(this.saveToFileToolStripMenuItem, "saveToFileToolStripMenuItem"); this.saveToFileToolStripMenuItem.Click += new System.EventHandler(this.saveToFileToolStripMenuItem_Click); // + // clearMissionToolStripMenuItem + // + this.clearMissionToolStripMenuItem.Name = "clearMissionToolStripMenuItem"; + resources.ApplyResources(this.clearMissionToolStripMenuItem, "clearMissionToolStripMenuItem"); + this.clearMissionToolStripMenuItem.Click += new System.EventHandler(this.clearMissionToolStripMenuItem_Click); + // // trackBar1 // resources.ApplyResources(this.trackBar1, "trackBar1"); @@ -911,7 +919,6 @@ // // timer1 // - this.timer1.Enabled = true; this.timer1.Interval = 1000; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // @@ -923,6 +930,7 @@ this.Controls.Add(this.panelBASE); this.MinimumSize = new System.Drawing.Size(1008, 461); this.Name = "FlightPlanner"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FlightPlanner_FormClosing); this.Load += new System.EventHandler(this.Planner_Load); this.Resize += new System.EventHandler(this.Planner_Resize); ((System.ComponentModel.ISupportInitialize)(this.Commands)).EndInit(); @@ -1037,5 +1045,6 @@ private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem GeoFenceuploadToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; + private System.Windows.Forms.ToolStripMenuItem createWpCircleToolStripMenuItem; } } \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.cs b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.cs index a16b011f915..b815ac0d251 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.cs @@ -23,11 +23,12 @@ using SharpKml.Base; using SharpKml.Dom; using ArdupilotMega.Controls; using ArdupilotMega.Utilities; +using ArdupilotMega.Controls.BackstageView; namespace ArdupilotMega.GCSViews { - partial class FlightPlanner : MyUserControl + partial class FlightPlanner : MyUserControl, IDeactivate { private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); int selectedrow = 0; @@ -697,6 +698,8 @@ namespace ArdupilotMega.GCSViews panelMap_Resize(null, null); writeKML(); + + timer1.Start(); } void parser_ElementAdded(object sender, SharpKml.Base.ElementEventArgs e) @@ -1223,7 +1226,7 @@ namespace ArdupilotMega.GCSViews try { - IMAVLink port = MainV2.comPort; + MAVLink port = MainV2.comPort; if (!port.BaseStream.IsOpen) { @@ -1256,12 +1259,13 @@ namespace ArdupilotMega.GCSViews catch (Exception ex) { error = 1; CustomMessageBox.Show("Error : " + ex.ToString()); } try { - this.BeginInvoke((MethodInvoker)delegate() + this.Invoke((MethodInvoker)delegate() { if (error == 0) { try { + log.Info("Process " + cmds.Count); processToScreen(cmds); } catch (Exception exx) { log.Info(exx.ToString()); } @@ -1332,7 +1336,7 @@ namespace ArdupilotMega.GCSViews { try { - IMAVLink port = MainV2.comPort; + MAVLink port = MainV2.comPort; if (!port.BaseStream.IsOpen) { @@ -1430,7 +1434,9 @@ namespace ArdupilotMega.GCSViews void processToScreen(List cmds) { quickadd = true; - Commands.Rows.Clear(); + + while (Commands.Rows.Count > 0) + Commands.Rows.RemoveAt(0); if (cmds.Count == 0) { @@ -1500,25 +1506,6 @@ namespace ArdupilotMega.GCSViews } try { - DataGridViewTextBoxCell cellhome; - cellhome = Commands.Rows[0].Cells[Lat.Index] as DataGridViewTextBoxCell; - if (cellhome.Value != null) - { - if (cellhome.Value.ToString() != TXT_homelat.Text && cellhome.Value.ToString() != "0") - { - DialogResult dr = CustomMessageBox.Show("Reset Home to loaded coords", "Reset Home Coords", MessageBoxButtons.YesNo); - - if (dr == DialogResult.Yes) - { - TXT_homelat.Text = (double.Parse(cellhome.Value.ToString())).ToString(); - cellhome = Commands.Rows[0].Cells[Lon.Index] as DataGridViewTextBoxCell; - TXT_homelng.Text = (double.Parse(cellhome.Value.ToString())).ToString(); - cellhome = Commands.Rows[0].Cells[Alt.Index] as DataGridViewTextBoxCell; - TXT_homealt.Text = (double.Parse(cellhome.Value.ToString()) * MainV2.cs.multiplierdist).ToString(); - } - } - } - log.Info("Setting wp params"); string hold_alt = ((int)((float)param["ALT_HOLD_RTL"] * MainV2.cs.multiplierdist)).ToString(); @@ -1551,6 +1538,26 @@ namespace ArdupilotMega.GCSViews CHK_holdalt.Checked = Convert.ToBoolean((float)param["ALT_HOLD_RTL"] > 0); log.Info("param ALT_HOLD_RTL " + CHK_holdalt.Checked.ToString()); + + + DataGridViewTextBoxCell cellhome; + cellhome = Commands.Rows[0].Cells[Lat.Index] as DataGridViewTextBoxCell; + if (cellhome.Value != null) + { + if (cellhome.Value.ToString() != TXT_homelat.Text && cellhome.Value.ToString() != "0") + { + DialogResult dr = CustomMessageBox.Show("Reset Home to loaded coords", "Reset Home Coords", MessageBoxButtons.YesNo); + + if (dr == DialogResult.Yes) + { + TXT_homelat.Text = (double.Parse(cellhome.Value.ToString())).ToString(); + cellhome = Commands.Rows[0].Cells[Lon.Index] as DataGridViewTextBoxCell; + TXT_homelng.Text = (double.Parse(cellhome.Value.ToString())).ToString(); + cellhome = Commands.Rows[0].Cells[Alt.Index] as DataGridViewTextBoxCell; + TXT_homealt.Text = (double.Parse(cellhome.Value.ToString()) * MainV2.cs.multiplierdist).ToString(); + } + } + } } catch (Exception ex) { log.Info(ex.ToString()); } // if there is no valid home @@ -2840,7 +2847,8 @@ namespace ArdupilotMega.GCSViews private void clearMissionToolStripMenuItem_Click(object sender, EventArgs e) { - Commands.Rows.Clear(); + while (Commands.Rows.Count > 0) + Commands.Rows.RemoveAt(0); selectedrow = 0; writeKML(); } @@ -3394,5 +3402,66 @@ namespace ArdupilotMega.GCSViews return (T)formatter.Deserialize(ms); } } + + private void createWpCircleToolStripMenuItem_Click(object sender, EventArgs e) + { + string RadiusIn = "50"; + Common.InputBox("Radius", "Radius", ref RadiusIn); + + string Pointsin = "20"; + Common.InputBox("Points", "Number of points to generate Circle", ref Pointsin); + + int Points = 0; + int Radius = 0; + + if (!int.TryParse(RadiusIn, out Radius)) + { + CustomMessageBox.Show("Bad Radius"); + return; + } + + if (!int.TryParse(Pointsin, out Points)) + { + CustomMessageBox.Show("Bad Point value"); + return; + } + + + + for (double a = 0; a <= 360; a += 360.0f / Points) + { + + selectedrow = Commands.Rows.Add(); + + Commands.Rows[selectedrow].Cells[Command.Index].Value = MAVLink.MAV_CMD.WAYPOINT.ToString(); + + ChangeColumnHeader(MAVLink.MAV_CMD.WAYPOINT.ToString()); + + float d = Radius; + float R = 6371000; + + var lat2 = Math.Asin(Math.Sin(end.Lat * deg2rad) * Math.Cos(d / R) + + Math.Cos(end.Lat * deg2rad) * Math.Sin(d / R) * Math.Cos(a * deg2rad)); + var lon2 = end.Lng * deg2rad + Math.Atan2(Math.Sin(a * deg2rad) * Math.Sin(d / R) * Math.Cos(end.Lat * deg2rad), + Math.Cos(d / R) - Math.Sin(end.Lat * deg2rad) * Math.Sin(lat2)); + + PointLatLng pll = new PointLatLng(lat2 * rad2deg, lon2 * rad2deg); + + setfromGE(pll.Lat, pll.Lng, (int)float.Parse(TXT_DefaultAlt.Text)); + + } + + //drawnpolygon.Points.Add(new PointLatLng(start.Lat, start.Lng)); + } + + public void Deactivate() + { + timer1.Stop(); + } + + private void FlightPlanner_FormClosing(object sender, FormClosingEventArgs e) + { + timer1.Stop(); + } } } \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.resx b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.resx index 779b17c4567..86587af632e 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.resx +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.resx @@ -556,7 +556,7 @@ BUT_write - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4579.33184, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.39185, Culture=neutral, PublicKeyToken=null panel5 @@ -583,7 +583,7 @@ BUT_read - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4579.33184, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.39185, Culture=neutral, PublicKeyToken=null panel5 @@ -610,7 +610,7 @@ SaveFile - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4579.33184, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.39185, Culture=neutral, PublicKeyToken=null panel5 @@ -637,7 +637,7 @@ BUT_loadwpfile - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4579.33184, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.39185, Culture=neutral, PublicKeyToken=null panel5 @@ -1261,7 +1261,7 @@ BUT_loadkml - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4579.33184, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.39185, Culture=neutral, PublicKeyToken=null panelWaypoints @@ -1291,7 +1291,7 @@ BUT_zoomto - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4579.33184, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.39185, Culture=neutral, PublicKeyToken=null panelWaypoints @@ -1321,7 +1321,7 @@ BUT_Camera - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4579.33184, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.39185, Culture=neutral, PublicKeyToken=null panelWaypoints @@ -1351,7 +1351,7 @@ BUT_grid - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4579.33184, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.39185, Culture=neutral, PublicKeyToken=null panelWaypoints @@ -1381,7 +1381,7 @@ BUT_Prefetch - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4579.33184, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.39185, Culture=neutral, PublicKeyToken=null panelWaypoints @@ -1411,7 +1411,7 @@ button1 - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4579.33184, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.39185, Culture=neutral, PublicKeyToken=null panelWaypoints @@ -1441,7 +1441,7 @@ BUT_Add - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4579.33184, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.39185, Culture=neutral, PublicKeyToken=null panelWaypoints @@ -1647,6 +1647,12 @@ Jump + + 167, 22 + + + Create Wp Circle + 164, 6 @@ -1680,12 +1686,6 @@ Draw Polygon - - 167, 22 - - - Clear Mission - 177, 22 @@ -1731,8 +1731,14 @@ Geo-Fence + + 167, 22 + + + Clear Mission + - 168, 208 + 168, 230 contextMenuStrip1 @@ -1898,7 +1904,7 @@ MainMap - ArdupilotMega.Controls.myGMAP, ArdupilotMegaPlanner10, Version=1.1.4579.33184, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.myGMAP, ArdupilotMegaPlanner10, Version=1.1.4582.39185, Culture=neutral, PublicKeyToken=null panelMap @@ -1928,7 +1934,7 @@ trackBar1 - ArdupilotMega.Controls.MyTrackBar, ArdupilotMegaPlanner10, Version=1.1.4579.33184, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyTrackBar, ArdupilotMegaPlanner10, Version=1.1.4582.39185, Culture=neutral, PublicKeyToken=null panelMap @@ -2161,6 +2167,12 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + createWpCircleToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + toolStripSeparator1 @@ -2197,12 +2209,6 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - clearMissionToolStripMenuItem - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - geoFenceToolStripMenuItem @@ -2251,6 +2257,12 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + clearMissionToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + toolTip1 @@ -2267,6 +2279,6 @@ FlightPlanner - System.Windows.Forms.MyUserControl, ArdupilotMegaPlanner10, Version=1.1.4579.33184, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.MyUserControl, ArdupilotMegaPlanner10, Version=1.1.4582.39185, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.Designer.cs index 54ae0bb1a20..d4c451fab6a 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.Designer.cs @@ -40,7 +40,6 @@ this.TXT_pitch = new ArdupilotMega.Controls.MyLabel(); this.TXT_heading = new ArdupilotMega.Controls.MyLabel(); this.TXT_wpdist = new ArdupilotMega.Controls.MyLabel(); - this.currentStateBindingSource = new System.Windows.Forms.BindingSource(this.components); this.TXT_bererror = new ArdupilotMega.Controls.MyLabel(); this.TXT_alterror = new ArdupilotMega.Controls.MyLabel(); this.TXT_lat = new ArdupilotMega.Controls.MyLabel(); @@ -114,7 +113,6 @@ this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.RAD_JSBSim = new System.Windows.Forms.RadioButton(); this.CHK_xplane10 = new System.Windows.Forms.CheckBox(); - ((System.ComponentModel.ISupportInitialize)(this.currentStateBindingSource)).BeginInit(); this.panel1.SuspendLayout(); this.panel2.SuspendLayout(); this.panel3.SuspendLayout(); @@ -200,10 +198,6 @@ this.TXT_wpdist.Name = "TXT_wpdist"; this.TXT_wpdist.resize = false; // - // currentStateBindingSource - // - this.currentStateBindingSource.DataSource = typeof(ArdupilotMega.CurrentState); - // // TXT_bererror // resources.ApplyResources(this.TXT_bererror, "TXT_bererror"); @@ -743,8 +737,8 @@ this.Controls.Add(this.CHKREV_pitch); this.Controls.Add(this.CHKREV_roll); this.Name = "Simulation"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Simulation_FormClosing); this.Load += new System.EventHandler(this.Simulation_Load); - ((System.ComponentModel.ISupportInitialize)(this.currentStateBindingSource)).EndInit(); this.panel1.ResumeLayout(false); this.panel2.ResumeLayout(false); this.panel3.ResumeLayout(false); @@ -833,7 +827,6 @@ private ArdupilotMega.Controls.MyLabel TXT_yaw; private ArdupilotMega.Controls.MyButton but_advsettings; private System.Windows.Forms.CheckBox chkSensor; - private System.Windows.Forms.BindingSource currentStateBindingSource; private System.Windows.Forms.CheckBox CHK_quad; private ArdupilotMega.Controls.MyButton BUT_startfgquad; private ArdupilotMega.Controls.MyButton BUT_startfgplane; diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.cs b/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.cs index 670b2902628..e42abd1492b 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.cs @@ -22,7 +22,7 @@ namespace ArdupilotMega.GCSViews public partial class Simulation : MyUserControl { private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - IMAVLink comPort = MainV2.comPort; + MAVLink comPort = MainV2.comPort; UdpClient XplanesSEND; UdpClient MavLink; Socket SimulatorRECV; @@ -263,6 +263,8 @@ namespace ArdupilotMega.GCSViews private void Simulation_Load(object sender, EventArgs e) { + timer_servo_graph.Stop(); + GPSrate.SelectedIndex = 2; xmlconfig(false); @@ -725,7 +727,7 @@ namespace ArdupilotMega.GCSViews /// Packet /// Length /// Com Port - private void RECVprocess(byte[] data, int receviedbytes, ArdupilotMega.IMAVLink comPort) + private void RECVprocess(byte[] data, int receviedbytes, ArdupilotMega.MAVLink comPort) { #if MAVLINK10 ArdupilotMega.MAVLink.mavlink_hil_state_t hilstate = new ArdupilotMega.MAVLink.mavlink_hil_state_t(); @@ -2190,5 +2192,10 @@ namespace ArdupilotMega.GCSViews CHKgraphthrottle.Visible = false; } } + + private void Simulation_FormClosing(object sender, FormClosingEventArgs e) + { + timer_servo_graph.Stop(); + } } } \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.resx b/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.resx index 0b480ae370d..fff2575e470 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.resx +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.resx @@ -261,7 +261,7 @@ ConnectComPort - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel5 @@ -309,7 +309,7 @@ TXT_roll - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel2 @@ -330,7 +330,7 @@ TXT_pitch - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel2 @@ -351,7 +351,7 @@ TXT_heading - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel2 @@ -372,7 +372,7 @@ TXT_wpdist - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel4 @@ -380,9 +380,6 @@ 8 - - 104, 17 - 75, 50 @@ -396,7 +393,7 @@ TXT_bererror - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel4 @@ -417,7 +414,7 @@ TXT_alterror - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel4 @@ -438,7 +435,7 @@ TXT_lat - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel1 @@ -459,7 +456,7 @@ TXT_long - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel1 @@ -480,7 +477,7 @@ TXT_alt - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel1 @@ -504,7 +501,7 @@ SaveSettings - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null $this @@ -588,7 +585,7 @@ TXT_servoroll - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel3 @@ -609,7 +606,7 @@ TXT_servopitch - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel3 @@ -630,7 +627,7 @@ TXT_servorudder - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel3 @@ -651,7 +648,7 @@ TXT_servothrottle - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel3 @@ -675,7 +672,7 @@ label4 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel1 @@ -699,7 +696,7 @@ label3 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel1 @@ -723,7 +720,7 @@ label2 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel1 @@ -747,7 +744,7 @@ label1 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel1 @@ -792,7 +789,7 @@ label30 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel2 @@ -813,7 +810,7 @@ TXT_yaw - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel2 @@ -837,7 +834,7 @@ label11 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel2 @@ -861,7 +858,7 @@ label7 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel2 @@ -885,7 +882,7 @@ label6 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel2 @@ -909,7 +906,7 @@ label5 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel2 @@ -954,7 +951,7 @@ label8 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel4 @@ -978,7 +975,7 @@ label9 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel4 @@ -1002,7 +999,7 @@ label10 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel4 @@ -1026,7 +1023,7 @@ label16 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel3 @@ -1050,7 +1047,7 @@ label15 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel3 @@ -1074,7 +1071,7 @@ label14 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel3 @@ -1098,7 +1095,7 @@ label13 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel3 @@ -1122,7 +1119,7 @@ label12 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel3 @@ -1167,7 +1164,7 @@ label20 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel4 @@ -1191,7 +1188,7 @@ label19 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel4 @@ -1212,7 +1209,7 @@ TXT_control_mode - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel4 @@ -1233,7 +1230,7 @@ TXT_WP - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel4 @@ -1257,7 +1254,7 @@ label18 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel4 @@ -1302,7 +1299,7 @@ label17 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null $this @@ -1375,7 +1372,7 @@ label28 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel6 @@ -1399,7 +1396,7 @@ label29 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel6 @@ -1423,7 +1420,7 @@ label27 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel6 @@ -1447,7 +1444,7 @@ label25 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel6 @@ -1495,7 +1492,7 @@ label24 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel6 @@ -1519,7 +1516,7 @@ label23 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel6 @@ -1543,7 +1540,7 @@ label22 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel6 @@ -1567,7 +1564,7 @@ label21 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null panel6 @@ -1684,7 +1681,7 @@ label26 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null $this @@ -1855,7 +1852,7 @@ but_advsettings - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null $this @@ -1939,7 +1936,7 @@ BUT_startfgquad - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null $this @@ -1966,7 +1963,7 @@ BUT_startfgplane - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null $this @@ -1993,7 +1990,7 @@ BUT_startxplane - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null $this @@ -2136,12 +2133,6 @@ 722, 742 - - currentStateBindingSource - - - System.Windows.Forms.BindingSource, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - timer_servo_graph @@ -2158,6 +2149,6 @@ Simulation - System.Windows.Forms.MyUserControl, ArdupilotMegaPlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=38326cb7e06851fc + System.Windows.Forms.MyUserControl, ArdupilotMegaPlanner10, Version=1.1.4582.35218, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Terminal.cs b/Tools/ArdupilotMegaPlanner/GCSViews/Terminal.cs index a17f360d491..829edced057 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Terminal.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Terminal.cs @@ -147,10 +147,15 @@ namespace ArdupilotMega.GCSViews { threadrun = false; - if (comPort.IsOpen) + try { - comPort.Close(); + if (comPort.IsOpen) + { + comPort.Close(); + } } + catch { } // Exception System.IO.IOException: The specified port does not exist. + System.Threading.Thread.Sleep(400); MainV2.giveComport = false; diff --git a/Tools/ArdupilotMegaPlanner/Log.Designer.cs b/Tools/ArdupilotMegaPlanner/Log.Designer.cs index 92c4948aeee..f0d3c964f56 100644 --- a/Tools/ArdupilotMegaPlanner/Log.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/Log.Designer.cs @@ -77,6 +77,7 @@ // TXT_status // resources.ApplyResources(this.TXT_status, "TXT_status"); + this.TXT_status.ForeColor = System.Drawing.Color.Red; this.TXT_status.Name = "TXT_status"; // // BUT_redokml diff --git a/Tools/ArdupilotMegaPlanner/Log.resx b/Tools/ArdupilotMegaPlanner/Log.resx index 4b99ecc7a94..f4550b92dc2 100644 --- a/Tools/ArdupilotMegaPlanner/Log.resx +++ b/Tools/ArdupilotMegaPlanner/Log.resx @@ -159,7 +159,7 @@ BUT_DLall - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4537.26254, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4583.40805, Culture=neutral, PublicKeyToken=null $this @@ -183,7 +183,7 @@ BUT_DLthese - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4537.26254, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4583.40805, Culture=neutral, PublicKeyToken=null $this @@ -207,7 +207,7 @@ BUT_clearlogs - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4537.26254, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4583.40805, Culture=neutral, PublicKeyToken=null $this @@ -276,7 +276,7 @@ BUT_redokml - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4537.26254, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4583.40805, Culture=neutral, PublicKeyToken=null $this @@ -300,7 +300,7 @@ BUT_firstperson - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4537.26254, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4583.40805, Culture=neutral, PublicKeyToken=null $this @@ -328,7 +328,7 @@ BUT_dumpdf - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4537.26254, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4583.40805, Culture=neutral, PublicKeyToken=null $this diff --git a/Tools/ArdupilotMegaPlanner/MainV2.cs b/Tools/ArdupilotMegaPlanner/MainV2.cs index a4a9da14b40..d32052c0dae 100644 --- a/Tools/ArdupilotMegaPlanner/MainV2.cs +++ b/Tools/ArdupilotMegaPlanner/MainV2.cs @@ -44,7 +44,7 @@ namespace ArdupilotMega /// /// Main Comport interface /// - public static IMAVLink comPort = new MAVLink(); + public static MAVLink comPort = new MAVLink(); /// /// Comport name /// @@ -90,10 +90,6 @@ namespace ArdupilotMega /// bool serialThread = false; /// - /// unused at this point - potential to move all forms to this single binding source. need to evalutate performance/exception issues - /// - static internal BindingSource bs; - /// /// used for mini https server for websockets/mjpeg video stream, and network link kmls /// private TcpListener listener; @@ -977,7 +973,7 @@ namespace ArdupilotMega this.MenuConnect.BackgroundImage = global::ArdupilotMega.Properties.Resources.connect; this.MenuConnect.BackgroundImage.Tag = "Connect"; _connectionControl.IsConnected(false); - if (_connectionStats != null) + if (_connectionStats != null) { _connectionStats.StopUpdates(); } @@ -990,7 +986,7 @@ namespace ArdupilotMega { _connectionControl.IsConnected(true); }); - } + } } connectButtonUpdate = DateTime.Now; } @@ -1014,8 +1010,8 @@ namespace ArdupilotMega int minbytes = 10; - if (MONO) - minbytes = 0; + // if (MONO) + // minbytes = 0; DateTime speechcustomtime = DateTime.Now; @@ -1081,8 +1077,7 @@ namespace ArdupilotMega MainV2.cs.linkqualitygcs = (ushort)(MainV2.cs.linkqualitygcs * 0.8f); linkqualitytime = DateTime.Now; - int fixme; - //GCSViews.FlightData.myhud.Invalidate(); + GCSViews.FlightData.myhud.Invalidate(); } } @@ -1116,16 +1111,19 @@ namespace ArdupilotMega } } - //Console.WriteLine(DateTime.Now.Millisecond + " " + comPort.BaseStream.BytesToRead); + // Console.WriteLine(DateTime.Now.Millisecond + " " + comPort.BaseStream.BytesToRead); 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) { - log.Error("Serial Reader fail :" + e.Message); + log.Error("Serial Reader fail :" + e.ToString()); try { comPort.Close(); @@ -1186,7 +1184,7 @@ namespace ArdupilotMega private void MainV2_Load(object sender, EventArgs e) { - MyView.AddScreen(new MainSwitcher.Screen("FlightData",FlightData,true)); + MyView.AddScreen(new MainSwitcher.Screen("FlightData", FlightData, true)); MyView.AddScreen(new MainSwitcher.Screen("FlightPlanner", FlightPlanner, true)); MyView.AddScreen(new MainSwitcher.Screen("Config", new GCSViews.ConfigurationView.Setup(), false)); MyView.AddScreen(new MainSwitcher.Screen("Simulation", Simulation, true)); @@ -1228,7 +1226,8 @@ namespace ArdupilotMega new Thread(SerialReader) { IsBackground = true, - Name = "Main Serial reader" + Name = "Main Serial reader", + Priority = ThreadPriority.AboveNormal }.Start(); try @@ -1448,7 +1447,7 @@ namespace ArdupilotMega foreach (var point in GCSViews.FlightPlanner.pointlist) { if (point != null) - coords.Add(new SharpKml.Base.Vector(point.Lat, point.Lng, point.Alt)); + coords.Add(new SharpKml.Base.Vector(point.Lat, point.Lng, point.Alt)); } @@ -1977,7 +1976,7 @@ namespace ArdupilotMega } } catch { } - log.Debug(file + " " + bytes); + // log.Debug(file + " " + bytes); int len = dataStream.Read(buf1, 0, 1024); if (len == 0) break; @@ -2081,11 +2080,9 @@ namespace ArdupilotMega if (keyData == (Keys.Control | Keys.W)) // test ac config { - Controls.ConfigPanel cfg = new Controls.ConfigPanel(); + Controls.ConfigPanel cfg = new Controls.ConfigPanel(Application.StartupPath + System.IO.Path.DirectorySeparatorChar + "ArduCopterConfig.xml"); - cfg.LoadXML("ArduCopterConfig.xml"); - - //cfg.ShowDialog(); + //cfg.Show(); return true; } diff --git a/Tools/ArdupilotMegaPlanner/Mavlink/MAVLink.cs b/Tools/ArdupilotMegaPlanner/Mavlink/MAVLink.cs index c8022f437f5..4e5581424f3 100644 --- a/Tools/ArdupilotMegaPlanner/Mavlink/MAVLink.cs +++ b/Tools/ArdupilotMegaPlanner/Mavlink/MAVLink.cs @@ -19,7 +19,7 @@ using System.Windows.Forms; namespace ArdupilotMega { - public partial class MAVLink: IMAVLink + public partial class MAVLink { private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public ICommsSerial BaseStream { get; set; } @@ -703,6 +703,8 @@ namespace ArdupilotMega DateTime start = DateTime.Now; DateTime restart = DateTime.Now; + DateTime lastmessage = DateTime.MinValue; + do { @@ -763,13 +765,15 @@ namespace ArdupilotMega log.Info(DateTime.Now.Millisecond + " got param " + (par.param_index) + " of " + (par.param_count) + " name: " + paramID); + //Console.WriteLine(DateTime.Now.Millisecond + " gp " + BaseStream.BytesToRead); + modifyParamForDisplay(true, paramID, ref par.param_value); param[paramID] = (par.param_value); param_count++; got.Add(par.param_index); - // if (Progress != null) - // Progress((param.Count * 100) / param_total, "Got param " + paramID); + Console.WriteLine(DateTime.Now.Millisecond + " gp1 " + BaseStream.BytesToRead); + this.frmProgressReporter.UpdateProgressAndStatus((got.Count * 100) / param_total, "Got param " + paramID); // we have them all - lets escape eq total = 176 index = 0-175 @@ -782,6 +786,7 @@ namespace ArdupilotMega } //stopwatch.Stop(); //Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed); + Console.WriteLine(DateTime.Now.Millisecond + " gp2 " + BaseStream.BytesToRead); } } while (got.Count < param_total); @@ -801,14 +806,12 @@ namespace ArdupilotMega public static void modifyParamForDisplay(bool fromapm, string paramname, ref float value) { - if (paramname.ToUpper().EndsWith("_IMAX") || paramname.ToUpper().EndsWith("ALT_HOLD_RTL") || paramname.ToUpper().EndsWith("TRIM_ARSPD_CM") + if (paramname.ToUpper().EndsWith("_IMAX") || paramname.ToUpper().EndsWith("ALT_HOLD_RTL") || paramname.ToUpper().EndsWith("APPROACH_ALT") || paramname.ToUpper().EndsWith("TRIM_ARSPD_CM") || paramname.ToUpper().EndsWith("XTRK_ANGLE_CD") || paramname.ToUpper().EndsWith("LIM_PITCH_MAX") || paramname.ToUpper().EndsWith("LIM_PITCH_MIN") || paramname.ToUpper().EndsWith("LIM_ROLL_CD") || paramname.ToUpper().EndsWith("PITCH_MAX") || paramname.ToUpper().EndsWith("WP_SPEED_MAX")) { - if (paramname.ToUpper().EndsWith("THR_HOLD_IMAX")) - { + if (paramname.ToUpper().EndsWith("THR_RATE_IMAX") || paramname.ToUpper().EndsWith("THR_HOLD_IMAX")) return; - } if (fromapm) { @@ -2049,7 +2052,7 @@ namespace ArdupilotMega /// public byte[] readPacket() { - byte[] temp = new byte[300]; + byte[] buffer = new byte[300]; int count = 0; int length = 0; int readcount = 0; @@ -2073,6 +2076,7 @@ namespace ArdupilotMega lock (readlock) { +// Console.WriteLine(DateTime.Now.Millisecond + " SR " + BaseStream.BytesToRead); while (BaseStream.IsOpen || logreadmode) { @@ -2104,11 +2108,11 @@ namespace ArdupilotMega if (oldlogformat) { - temp = readlogPacket(); //old style log + buffer = readlogPacket(); //old style log } else { - temp = readlogPacketMavlink(); + buffer = readlogPacketMavlink(); } } else @@ -2126,51 +2130,53 @@ namespace ArdupilotMega } // System.Threading.Thread.Sleep(1); } + //Console.WriteLine(DateTime.Now.Millisecond + " SR1 " + BaseStream.BytesToRead); if (BaseStream.IsOpen) { - temp[count] = (byte)BaseStream.ReadByte(); + buffer[count] = (byte)BaseStream.ReadByte(); if (rawlogfile != null && rawlogfile.BaseStream.CanWrite) - rawlogfile.Write(temp[count]); + rawlogfile.Write(buffer[count]); } } } catch (Exception e) { log.Info("MAVLink readpacket read error: " + e.ToString()); break; } // check if looks like a mavlink packet and check for exclusions and write to console - if (temp[0] != 254 && temp[0] != 'U' || lastbad[0] == 'I' && lastbad[1] == 'M' || lastbad[1] == 'G' || lastbad[1] == 'A') // out of sync "AUTO" "GUIDED" "IMU" + if (buffer[0] != 254 && buffer[0] != 'U' || lastbad[0] == 'I' && lastbad[1] == 'M' || lastbad[1] == 'G' || lastbad[1] == 'A') // out of sync "AUTO" "GUIDED" "IMU" { - if (temp[0] >= 0x20 && temp[0] <= 127 || temp[0] == '\n' || temp[0] == '\r') + if (buffer[0] >= 0x20 && buffer[0] <= 127 || buffer[0] == '\n' || buffer[0] == '\r') { - TCPConsole.Write(temp[0]); - Console.Write((char)temp[0]); + TCPConsole.Write(buffer[0]); + Console.Write((char)buffer[0]); } _bytesReceivedSubj.OnNext(1); count = 0; lastbad[0] = lastbad[1]; - lastbad[1] = temp[0]; - temp[1] = 0; + lastbad[1] = buffer[0]; + buffer[1] = 0; continue; } // reset count on valid packet readcount = 0; + //Console.WriteLine(DateTime.Now.Millisecond + " SR2 " + BaseStream.BytesToRead); - if (temp[0] == 'U' || temp[0] == 254) + if (buffer[0] == 'U' || buffer[0] == 254) { - length = temp[1] + 6 + 2 - 2; // data + header + checksum - U - length + length = buffer[1] + 6 + 2 - 2; // data + header + checksum - U - length if (count >= 5 || logreadmode) { if (sysid != 0) { - if (sysid != temp[3] || compid != temp[4]) + if (sysid != buffer[3] || compid != buffer[4]) { - if (temp[3] == '3' && temp[4] == 'D') + if (buffer[3] == '3' && buffer[4] == 'D') { // this is a 3dr radio rssi packet } else { - log.InfoFormat("Mavlink Bad Packet (not addressed to this MAV) got {0} {1} vs {2} {3}", temp[3], temp[4], sysid, compid); + log.InfoFormat("Mavlink Bad Packet (not addressed to this MAV) got {0} {1} vs {2} {3}", buffer[3], buffer[4], sysid, compid); return new byte[0]; } } @@ -2197,12 +2203,11 @@ namespace ArdupilotMega } if (BaseStream.IsOpen) { - int read = BaseStream.Read(temp, 6, length - 4); + int read = BaseStream.Read(buffer, 6, length - 4); if (rawlogfile != null && rawlogfile.BaseStream.CanWrite) { // write only what we read, temp is the whole packet, so 6-end - rawlogfile.Write(temp, 6, read); - rawlogfile.BaseStream.Flush(); + rawlogfile.Write(buffer, 6, read); } } } @@ -2218,11 +2223,13 @@ namespace ArdupilotMega if (count == 299) break; } + + //Console.WriteLine(DateTime.Now.Millisecond + " SR3 " + BaseStream.BytesToRead); }// end readlock - Array.Resize(ref temp, count); + Array.Resize(ref buffer, count); - _bytesReceivedSubj.OnNext(temp.Length); + _bytesReceivedSubj.OnNext(buffer.Length); if (packetlosttimer.AddSeconds(5) < DateTime.Now) { @@ -2241,34 +2248,34 @@ namespace ArdupilotMega bpstime = DateTime.Now; } - bps1 += temp.Length; + bps1 += buffer.Length; bps = (bps1 + bps2) / 2; - if (temp.Length >= 5 && temp[3] == 255 && logreadmode) // gcs packet + if (buffer.Length >= 5 && buffer[3] == 255 && logreadmode) // gcs packet { - getWPsfromstream(ref temp); - return temp;// new byte[0]; + getWPsfromstream(ref buffer); + return buffer;// new byte[0]; } - ushort crc = MavlinkCRC.crc_calculate(temp, temp.Length - 2); + ushort crc = MavlinkCRC.crc_calculate(buffer, buffer.Length - 2); - if (temp.Length > 5 && temp[0] == 254) + if (buffer.Length > 5 && buffer[0] == 254) { - crc = MavlinkCRC.crc_accumulate(MAVLINK_MESSAGE_CRCS[temp[5]], crc); + crc = MavlinkCRC.crc_accumulate(MAVLINK_MESSAGE_CRCS[buffer[5]], crc); } - if (temp.Length > 5 && temp[1] != MAVLINK_MESSAGE_LENGTHS[temp[5]]) + if (buffer.Length > 5 && buffer[1] != MAVLINK_MESSAGE_LENGTHS[buffer[5]]) { - if (MAVLINK_MESSAGE_LENGTHS[temp[5]] == 0) // pass for unknown packets + if (MAVLINK_MESSAGE_LENGTHS[buffer[5]] == 0) // pass for unknown packets { } else { - log.InfoFormat("Mavlink Bad Packet (Len Fail) len {0} pkno {1}", temp.Length, temp[5]); + log.InfoFormat("Mavlink Bad Packet (Len Fail) len {0} pkno {1}", buffer.Length, buffer[5]); #if MAVLINK10 - if (temp.Length == 11 && temp[0] == 'U' && temp[5] == 0){ + if (buffer.Length == 11 && buffer[0] == 'U' && buffer[5] == 0){ string message ="Mavlink 0.9 Heartbeat, Please upgrade your AP, This planner is for Mavlink 1.0\n\n"; System.Windows.Forms.CustomMessageBox.Show(message); throw new Exception(message); @@ -2285,28 +2292,28 @@ namespace ArdupilotMega } } - if (temp.Length < 5 || temp[temp.Length - 1] != (crc >> 8) || temp[temp.Length - 2] != (crc & 0xff)) + if (buffer.Length < 5 || buffer[buffer.Length - 1] != (crc >> 8) || buffer[buffer.Length - 2] != (crc & 0xff)) { int packetno = -1; - if (temp.Length > 5) + if (buffer.Length > 5) { - packetno = temp[5]; + packetno = buffer[5]; } - log.InfoFormat("Mavlink Bad Packet (crc fail) len {0} crc {1} pkno {2}", temp.Length, crc, packetno); + log.InfoFormat("Mavlink Bad Packet (crc fail) len {0} crc {1} pkno {2}", buffer.Length, crc, packetno); return new byte[0]; } try { - if ((temp[0] == 'U' || temp[0] == 254) && temp.Length >= temp[1]) + if ((buffer[0] == 'U' || buffer[0] == 254) && buffer.Length >= buffer[1]) { - if (temp[3] == '3' && temp[4] == 'D') + if (buffer[3] == '3' && buffer[4] == 'D') { } else { - byte packetSeqNo = temp[2]; + byte packetSeqNo = buffer[2]; int expectedPacketSeqNo = ((recvpacketcount + 1) % 0x100); if (packetSeqNo != expectedPacketSeqNo) @@ -2340,26 +2347,26 @@ namespace ArdupilotMega // Console.Write(temp[5] + " " + DateTime.Now.Millisecond + " " + packetspersecond[temp[5]] + " " + (DateTime.Now - packetspersecondbuild[temp[5]]).TotalMilliseconds + " \n"); - if (double.IsInfinity(packetspersecond[temp[5]])) - packetspersecond[temp[5]] = 0; + if (double.IsInfinity(packetspersecond[buffer[5]])) + packetspersecond[buffer[5]] = 0; - packetspersecond[temp[5]] = (((1000 / ((DateTime.Now - packetspersecondbuild[temp[5]]).TotalMilliseconds) + packetspersecond[temp[5]]) / 2)); + packetspersecond[buffer[5]] = (((1000 / ((DateTime.Now - packetspersecondbuild[buffer[5]]).TotalMilliseconds) + packetspersecond[buffer[5]]) / 2)); - packetspersecondbuild[temp[5]] = DateTime.Now; + packetspersecondbuild[buffer[5]] = DateTime.Now; //Console.WriteLine("Packet {0}",temp[5]); // store packet history lock (objlock) { - packets[temp[5]] = temp; + packets[buffer[5]] = buffer; } if (debugmavlink) - DebugPacket(temp); + DebugPacket(buffer); - if (temp[5] == MAVLink.MAVLINK_MSG_ID_STATUSTEXT) // status text + if (buffer[5] == MAVLink.MAVLINK_MSG_ID_STATUSTEXT) // status text { - string logdata = Encoding.ASCII.GetString(temp, 7, temp.Length - 7); + string logdata = Encoding.ASCII.GetString(buffer, 7, buffer.Length - 7); int ind = logdata.IndexOf('\0'); if (ind != -1) logdata = logdata.Substring(0, ind); @@ -2372,7 +2379,7 @@ namespace ArdupilotMega } - getWPsfromstream(ref temp); + getWPsfromstream(ref buffer); try { @@ -2383,8 +2390,12 @@ namespace ArdupilotMega byte[] datearray = BitConverter.GetBytes((UInt64)((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds * 1000)); //ASCIIEncoding.ASCII.GetBytes(DateTime.Now.ToBinary() + ":"); Array.Reverse(datearray); logfile.Write(datearray, 0, datearray.Length); - logfile.Write(temp, 0, temp.Length); - logfile.Flush(); + logfile.Write(buffer, 0, buffer.Length); + + if (buffer[5] == 0) {// flush on heartbeat - 1 seconds + logfile.Flush(); + rawlogfile.BaseStream.Flush(); + } } } @@ -2398,7 +2409,9 @@ namespace ArdupilotMega // Console.Write((DateTime.Now - start).TotalMilliseconds.ToString("00.000") + "\t" + temp.Length + " \r"); - return temp; + // Console.WriteLine(DateTime.Now.Millisecond + " SR4 " + BaseStream.BytesToRead); + + return buffer; } /// diff --git a/Tools/ArdupilotMegaPlanner/Presenter/ConfigCameraStabPresenter.cs b/Tools/ArdupilotMegaPlanner/Presenter/ConfigCameraStabPresenter.cs index 19a44f09931..edfa4044710 100644 --- a/Tools/ArdupilotMegaPlanner/Presenter/ConfigCameraStabPresenter.cs +++ b/Tools/ArdupilotMegaPlanner/Presenter/ConfigCameraStabPresenter.cs @@ -34,10 +34,10 @@ namespace ArdupilotMega.Presenter private CameraAxisProperties _pitchAxis; private CameraAxisProperties _rollAxis; - private readonly IMAVLink _mavlink; + private readonly MAVLink _mavlink; private readonly Dictionary _errors; - public ConfigCameraStabPresenter(IMAVLink mavlink) + public ConfigCameraStabPresenter(MAVLink mavlink) { _mavlink = mavlink; _errors = new Dictionary(); diff --git a/Tools/ArdupilotMegaPlanner/Program.cs b/Tools/ArdupilotMegaPlanner/Program.cs index 27cb31cf7b2..cae92447e58 100644 --- a/Tools/ArdupilotMegaPlanner/Program.cs +++ b/Tools/ArdupilotMegaPlanner/Program.cs @@ -31,10 +31,6 @@ namespace ArdupilotMega Application.Idle += Application_Idle; - int wt = 0, ct = 0; - ThreadPool.GetMaxThreads(out wt, out ct); - log.Info("Max Threads: " + wt); - //MagCalib.ProcessLog(); //MessageBox.Show("NOTE: This version may break advanced mission scripting"); @@ -67,17 +63,7 @@ namespace ArdupilotMega return; */ - char[] line = "testtesttesttesttest".ToCharArray(); - - Delta.delta_encode(ref line); - - Delta.delta_decode(ref line); - - if (System.Diagnostics.Debugger.IsAttached) - { - // testing - // Utilities.ParameterMetaDataParser.GetParameterInformation(); - } + try { @@ -94,13 +80,19 @@ namespace ArdupilotMega } } + static DateTime lastidle = DateTime.Now; + static void Application_Idle(object sender, EventArgs e) { //System.Threading.Thread.Sleep(10); //Console.Write("Idle\n"); + if (lastidle.AddMilliseconds(20) < DateTime.Now) + { + Application.DoEvents(); + lastidle = DateTime.Now; + } - System.Threading.Thread.Sleep(20); - Application.DoEvents(); + System.Threading.Thread.Sleep(1); } static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) diff --git a/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs b/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs index 7d56cdc5df0..4502aa440b7 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.1.98")] +[assembly: AssemblyFileVersion("1.1.99")] [assembly: NeutralResourcesLanguageAttribute("")] diff --git a/Tools/ArdupilotMegaPlanner/Properties/Resources.Designer.cs b/Tools/ArdupilotMegaPlanner/Properties/Resources.Designer.cs index 2b5dbc11a85..6a01753179f 100644 --- a/Tools/ArdupilotMegaPlanner/Properties/Resources.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/Properties/Resources.Designer.cs @@ -177,6 +177,18 @@ namespace ArdupilotMega.Properties { } } + public static System.Drawing.Bitmap frames_plus { + get { + object obj = ResourceManager.GetObject("frames_plus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + public static System.Drawing.Bitmap frames_x { + get { + object obj = ResourceManager.GetObject("frames_x", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } public static System.Drawing.Bitmap Gaugebg { get { object obj = ResourceManager.GetObject("Gaugebg", resourceCulture); diff --git a/Tools/ArdupilotMegaPlanner/Properties/Resources.resx b/Tools/ArdupilotMegaPlanner/Properties/Resources.resx index e737b3bdf31..0305d2ee19c 100644 --- a/Tools/ArdupilotMegaPlanner/Properties/Resources.resx +++ b/Tools/ArdupilotMegaPlanner/Properties/Resources.resx @@ -1234,11 +1234,17 @@ ..\Resources\car.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\cameraGimalPitch1.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\cameraGimalRoll1.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\frames_plus.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\frames_x.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/Radio/3DRradio.Designer.cs b/Tools/ArdupilotMegaPlanner/Radio/3DRradio.Designer.cs index 407468d0f34..85dcfa24e79 100644 --- a/Tools/ArdupilotMegaPlanner/Radio/3DRradio.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/Radio/3DRradio.Designer.cs @@ -101,6 +101,8 @@ this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.label9 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.linkLabel1 = new System.Windows.Forms.LinkLabel(); this.SPLIT_local.Panel1.SuspendLayout(); this.SPLIT_local.Panel2.SuspendLayout(); this.SPLIT_local.SuspendLayout(); @@ -835,10 +837,25 @@ resources.ApplyResources(this.label9, "label9"); this.label9.Name = "label9"; // + // label10 + // + resources.ApplyResources(this.label10, "label10"); + this.label10.Name = "label10"; + // + // linkLabel1 + // + resources.ApplyResources(this.linkLabel1, "linkLabel1"); + this.linkLabel1.Name = "linkLabel1"; + this.linkLabel1.TabStop = true; + this.toolTip1.SetToolTip(this.linkLabel1, resources.GetString("linkLabel1.ToolTip")); + this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); + // // _3DRradio // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.linkLabel1); + this.Controls.Add(this.label10); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Controls.Add(this.BUT_Syncoptions); @@ -942,5 +959,7 @@ private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.Label label9; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.LinkLabel linkLabel1; } } \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/Radio/3DRradio.cs b/Tools/ArdupilotMegaPlanner/Radio/3DRradio.cs index a9d474bb8e2..2da4e1e6bf9 100644 --- a/Tools/ArdupilotMegaPlanner/Radio/3DRradio.cs +++ b/Tools/ArdupilotMegaPlanner/Radio/3DRradio.cs @@ -17,7 +17,7 @@ using System.Text.RegularExpressions; namespace ArdupilotMega { - public partial class _3DRradio : BackStageViewContentPanel + public partial class _3DRradio : UserControl { public delegate void LogEventHandler(string message, int level = 0); @@ -719,5 +719,14 @@ namespace ArdupilotMega SPLIT_local.Panel2Collapsed = !CHK_advanced.Checked; SPLIT_remote.Panel2Collapsed = !CHK_advanced.Checked; } + + private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + CustomMessageBox.Show(@"The 3DR Radios have 2 status LEDs, one red and one green. +green LED blinking - searching for another radio +green LED solid - link is established with another radio +red LED flashing - transmitting data +red LED solid - in firmware update mode"); + } } } \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/Radio/3DRradio.resx b/Tools/ArdupilotMegaPlanner/Radio/3DRradio.resx index 6817cb57c57..df00f160bf6 100644 --- a/Tools/ArdupilotMegaPlanner/Radio/3DRradio.resx +++ b/Tools/ArdupilotMegaPlanner/Radio/3DRradio.resx @@ -138,8 +138,11 @@ $this - 7 + 9 + + 17, 17 + 115 @@ -176,9 +179,6 @@ 4 - - 17, 17 - Serial baud rate in rounded kbps. So 57 means 57600. @@ -733,6 +733,9 @@ 14 + + 17, 17 + 83, 191 @@ -1799,13 +1802,13 @@ which result in a valid packet CRC BUT_savesettings - ArdupilotMega.Controls.MyButton, 3DRRadio, Version=0.6.4521.12642, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.14832, Culture=neutral, PublicKeyToken=null $this - 4 + 6 269, 3 @@ -1823,13 +1826,13 @@ which result in a valid packet CRC BUT_getcurrent - ArdupilotMega.Controls.MyButton, 3DRRadio, Version=0.6.4521.12642, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.14832, Culture=neutral, PublicKeyToken=null $this - 5 + 7 12, 361 @@ -1850,7 +1853,7 @@ which result in a valid packet CRC $this - 6 + 8 419, 3 @@ -1868,13 +1871,13 @@ which result in a valid packet CRC BUT_upload - ArdupilotMega.Controls.MyButton, 3DRRadio, Version=0.6.4521.12642, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.14832, Culture=neutral, PublicKeyToken=null $this - 8 + 10 True @@ -2550,7 +2553,7 @@ which result in a valid packet CRC $this - 3 + 5 False @@ -2574,13 +2577,13 @@ which result in a valid packet CRC BUT_Syncoptions - ArdupilotMega.Controls.MyButton, 3DRRadio, Version=0.6.4521.12642, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner10, Version=1.1.4585.14832, Culture=neutral, PublicKeyToken=null $this - 2 + 4 210, 12 @@ -2625,25 +2628,7 @@ which result in a valid packet CRC $this - 1 - - - True - - - NoControl - - - 12, 15 - - - 42, 13 - - - 37 - - - Version + 3 label9 @@ -2679,6 +2664,97 @@ which result in a valid packet CRC $this + 2 + + + True + + + NoControl + + + 12, 15 + + + 42, 13 + + + 37 + + + Version + + + label9 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 0 + + + True + + + NoControl + + + 9, 11 + + + 0, 13 + + + 82 + + + label10 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + 689, 11 + + + 63, 13 + + + 83 + + + Status Leds + + + The 3DR Radios have 2 status LEDs, one red and one green. +green LED blinking - searching for another radio +green LED solid - link is established with another radio +red LED flashing - transmitting data +red LED solid - in firmware update mode + + + linkLabel1 + + + System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 @@ -2700,6 +2776,6 @@ which result in a valid packet CRC _3DRradio - ArdupilotMega.Controls.BackstageView.BackStageViewContentPanel, 3DRRadio, Version=0.6.4521.12642, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.UserControl, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/Resources/new frames-05X.png b/Tools/ArdupilotMegaPlanner/Resources/new frames-05X.png new file mode 100644 index 00000000000..0cb3b8b81a0 Binary files /dev/null and b/Tools/ArdupilotMegaPlanner/Resources/new frames-05X.png differ diff --git a/Tools/ArdupilotMegaPlanner/Utilities/ParameterMetaDataParser.cs b/Tools/ArdupilotMegaPlanner/Utilities/ParameterMetaDataParser.cs index 79ff1d4c3d3..14a5c3ddc1c 100644 --- a/Tools/ArdupilotMegaPlanner/Utilities/ParameterMetaDataParser.cs +++ b/Tools/ArdupilotMegaPlanner/Utilities/ParameterMetaDataParser.cs @@ -29,7 +29,7 @@ namespace ArdupilotMega.Utilities parameterLocations.RemoveAll(String.IsNullOrEmpty); string sStartupPath = Application.StartupPath; - using (var objXmlTextWriter = new XmlTextWriter(String.Format("{0}\\{1}", sStartupPath, ConfigurationManager.AppSettings["ParameterMetaDataXMLFileName"]), null)) + using (var objXmlTextWriter = new XmlTextWriter(String.Format("{0}{1}{2}", Application.StartupPath, Path.DirectorySeparatorChar, ConfigurationManager.AppSettings["ParameterMetaDataXMLFileName"]), null)) { objXmlTextWriter.Formatting = Formatting.Indented; objXmlTextWriter.WriteStartDocument(); @@ -96,6 +96,7 @@ namespace ArdupilotMega.Utilities .ForEach(path => path.Value.Split(new []{ ParameterMetaDataConstants.PathDelimeter }, StringSplitOptions.None) .ForEach(separatedPath => { + log.Info("Process "+ node.Key + " : " + separatedPath); // Match based on the regex defined at the top of this class Match pathMatch = _parentDirectoryRegex.Match(separatedPath); if (pathMatch.Success && pathMatch.Groups["Path"] != null && !String.IsNullOrEmpty(pathMatch.Groups["Path"].Value)) diff --git a/Tools/ArdupilotMegaPlanner/Utilities/ParameterMetaDataRepository.cs b/Tools/ArdupilotMegaPlanner/Utilities/ParameterMetaDataRepository.cs index d91cbf2b9a1..a6380ac1e7f 100644 --- a/Tools/ArdupilotMegaPlanner/Utilities/ParameterMetaDataRepository.cs +++ b/Tools/ArdupilotMegaPlanner/Utilities/ParameterMetaDataRepository.cs @@ -21,7 +21,7 @@ namespace ArdupilotMega.Utilities public void Reload() { - string paramMetaDataXMLFileName = String.Format("{0}\\{1}", Application.StartupPath, ConfigurationManager.AppSettings["ParameterMetaDataXMLFileName"]); + string paramMetaDataXMLFileName = String.Format("{0}{1}{2}", Application.StartupPath, Path.DirectorySeparatorChar, ConfigurationManager.AppSettings["ParameterMetaDataXMLFileName"]); try { if (File.Exists(paramMetaDataXMLFileName)) diff --git a/Tools/ArdupilotMegaPlanner/Utilities/ThemeManager.cs b/Tools/ArdupilotMegaPlanner/Utilities/ThemeManager.cs index 739a59ad929..49312b2664e 100644 --- a/Tools/ArdupilotMegaPlanner/Utilities/ThemeManager.cs +++ b/Tools/ArdupilotMegaPlanner/Utilities/ThemeManager.cs @@ -105,7 +105,7 @@ namespace ArdupilotMega.Utilities DomainUpDown txt = (DomainUpDown)ctl; txt.BorderStyle = BorderStyle.None; } - else if (ctl.GetType() == typeof(GroupBox)) + else if (ctl.GetType() == typeof(GroupBox) || ctl.GetType() == typeof(UserControl)) { ctl.BackColor = BGColor; ctl.ForeColor = TextColor;// Color.FromArgb(0xe6, 0xe8, 0xea); diff --git a/Tools/ArdupilotMegaPlanner/georefimage.cs b/Tools/ArdupilotMegaPlanner/georefimage.cs index 363fd7679f2..e24fe4b5f85 100644 --- a/Tools/ArdupilotMegaPlanner/georefimage.cs +++ b/Tools/ArdupilotMegaPlanner/georefimage.cs @@ -215,13 +215,20 @@ namespace ArdupilotMega imagetotime = new Hashtable(); //logFile = @"C:\Users\hog\Pictures\farm 1-10-2011\100SSCAM\2011-10-01 11-48 1.log"; + TXT_outputlog.AppendText("Read Log\n"); List list = readLog(logFile); + TXT_outputlog.AppendText("Log Read\n"); + //dirWithImages = @"C:\Users\hog\Pictures\farm 1-10-2011\100SSCAM"; + TXT_outputlog.AppendText("Read images\n"); + string[] files = Directory.GetFiles(dirWithImages); + TXT_outputlog.AppendText("images read\n"); + Document kml = new Document(); StreamWriter sw4 = new StreamWriter(dirWithImages + Path.DirectorySeparatorChar + "loglocation.csv"); @@ -242,6 +249,8 @@ namespace ArdupilotMega int lastmatchindex = 0; + TXT_outputlog.AppendText("start Processing\n"); + foreach (string filename in files) { if (filename.ToLower().EndsWith(".jpg") && !filename.ToLower().Contains("_geotag")) @@ -277,7 +286,9 @@ namespace ArdupilotMega if (lastmatchindex > (a)) continue; - //Application.DoEvents(); + + if (a % 1000 == 0) + Application.DoEvents(); DateTime logdt = startTime.AddMilliseconds(int.Parse(arr[1])).AddSeconds(offsetseconds); @@ -293,6 +304,13 @@ namespace ArdupilotMega first++; } + // time has past, logs are in time order + if (photodt < logdt.AddSeconds(-1)) + { + lastmatchindex = a; + break; + } + //Console.Write("ph " + dt + " log " + crap + " \r"); diff --git a/Tools/ArdupilotMegaPlanner/srtm.cs b/Tools/ArdupilotMegaPlanner/srtm.cs index a17ca827480..6efa01b991a 100644 --- a/Tools/ArdupilotMegaPlanner/srtm.cs +++ b/Tools/ArdupilotMegaPlanner/srtm.cs @@ -277,7 +277,7 @@ namespace ArdupilotMega } } catch { } - Thread.Sleep(500); + Thread.Sleep(1000); } } diff --git a/Tools/ArdupilotMegaPlanner/temp.cs b/Tools/ArdupilotMegaPlanner/temp.cs index f8170db65b9..f77fc00b7c1 100644 --- a/Tools/ArdupilotMegaPlanner/temp.cs +++ b/Tools/ArdupilotMegaPlanner/temp.cs @@ -31,11 +31,11 @@ namespace ArdupilotMega if (System.Diagnostics.Debugger.IsAttached) { - ArdupilotMega.Controls.OpenGLtest ogl = new Controls.OpenGLtest(); + // ArdupilotMega.Controls.OpenGLtest ogl = new Controls.OpenGLtest(); - this.Controls.Add(ogl); + // this.Controls.Add(ogl); - ogl.Dock = DockStyle.Fill; + // ogl.Dock = DockStyle.Fill; } }