private void timer_status_Tick(object sender, EventArgs e)
        {
            // clean up old
            foreach (Control ctl in PNL_status.Controls)
            {
                if (!MainV2.Comports.Contains((MAVLinkInterface) ctl.Tag))
                {
                    ctl.Dispose();
                }
            }

            // setup new
            foreach (var port in MainV2.Comports)
            {
                bool exists = false;
                foreach (Control ctl in PNL_status.Controls)
                {
                    if (ctl is Status && ctl.Tag == port)
                    {
                        exists = true;
                        ((Status) ctl).GPS.Text = port.MAV.cs.gpsstatus >= 3 ? "OK" : "Bad";
                        ((Status) ctl).Armed.Text = port.MAV.cs.armed.ToString();
                        ((Status) ctl).Mode.Text = port.MAV.cs.mode;
                        ((Status) ctl).MAV.Text = port.ToString();
                        ((Status) ctl).Guided.Text = port.MAV.GuidedMode.x + "," + port.MAV.GuidedMode.y + "," +
                                                     port.MAV.GuidedMode.z;
                    }
                }

                if (!exists)
                {
                    Status newstatus = new Status();
                    newstatus.Tag = port;
                    PNL_status.Controls.Add(newstatus);
                }
            }
        }
Esempio n. 2
0
        private void timer_status_Tick(object sender, EventArgs e)
        {
            // clean up old
            foreach (Control ctl in PNL_status.Controls)
            {
                if (!MainV2.Comports.Contains((MAVLinkInterface)ctl.Tag))
                {
                    ctl.Dispose();
                    webBrowser1.Document.InvokeScript("ClearMap");//2015年12月3日09:48:56,清除地图上的标记点
                }
            }

            // setup new
            foreach (var port in MainV2.Comports)
            {
                bool exists = false;
                foreach (Control ctl in PNL_status.Controls)
                {
                    if (ctl is Status && ctl.Tag == port)
                    {
                        exists = true;
                        // MessageBox.Show(MainV2.Comports.ToString());
                        ((Status)ctl).GPS.Text = port.MAV.cs.gpsstatus >= 3 ? "OK" : "Bad";
                        ((Status)ctl).Armed.Text = port.MAV.cs.armed.ToString();
                        ((Status)ctl).Mode.Text = port.MAV.cs.mode;
                        ((Status)ctl).MAV.Text = port.ToString();
                        ((Status)ctl).Guided.Text = port.MAV.GuidedMode.x + "," + port.MAV.GuidedMode.y + "," + port.MAV.GuidedMode.z;
                    }
                }

                if (!exists)
                {
                    Status newstatus = new Status();
                    newstatus.Tag = port;
                    PNL_status.Controls.Add(newstatus);
                }
            }

            //显示各类标记点,如编队内飞行器及脱队飞行器
            foreach (var port in formationComports)
                webBrowser1.Document.InvokeScript("MarkFormation", new object[] { port.MAV.GuidedMode.x, port.MAV.GuidedMode.y, GetSerialString((MAVLinkInterface)port) });//2015年12月3日10:08:38,显示地图标记点
            foreach (var port in outComports)
                webBrowser1.Document.InvokeScript("MarkOut", new object[] { port.MAV.GuidedMode.x, port.MAV.GuidedMode.y, GetSerialString((MAVLinkInterface)port) });//2015年12月3日10:08:38,显示地图标记点


        }