getFWList() public method

Load xml from internet based on firmwareurl, and return softwarelist
public getFWList ( string firmwareurl = "" ) : List
firmwareurl string
return List
Esempio n. 1
0
        protected override void OnLoad(EventArgs e)
        {
            // check if its defined, and force to show it if not known about
            if (config["menu_autohide"] == null)
            {
                config["menu_autohide"] = "false";
            }

            try
            {
                AutoHideMenu(bool.Parse(config["menu_autohide"].ToString()));
            }
            catch { }

            MyView.AddScreen(new MainSwitcher.Screen("FlightData", FlightData, true));
            MyView.AddScreen(new MainSwitcher.Screen("FlightPlanner", FlightPlanner, true));
            MyView.AddScreen(new MainSwitcher.Screen("HWConfig", new GCSViews.InitialSetup(), false));
            MyView.AddScreen(new MainSwitcher.Screen("SWConfig", new GCSViews.SoftwareConfig(), false));
            MyView.AddScreen(new MainSwitcher.Screen("Simulation", Simulation, true));
            MyView.AddScreen(new MainSwitcher.Screen("Terminal", new GCSViews.Terminal(), false));
            MyView.AddScreen(new MainSwitcher.Screen("Help", new GCSViews.Help(), false));

            try
            {
                if (Control.ModifierKeys == Keys.Shift)
                {

                }
                else
                {
                    log.Info("Load Pluggins");
                    Plugin.PluginLoader.LoadAll();
                    log.Info("Load Pluggins Done");
                }
            }
            catch (Exception ex) { log.Error(ex); }

            if (Program.Logo != null && Program.vvvvz)
            {
                this.PerformLayout();
                MenuFlightPlanner_Click(this, e);
                MainMenu_ItemClicked(this, new ToolStripItemClickedEventArgs(MenuFlightPlanner));
            }
            else
            {
                this.PerformLayout();
                MenuFlightData_Click(this, e);
                MainMenu_ItemClicked(this, new ToolStripItemClickedEventArgs(MenuFlightData));
            }

            // for long running tasks using own threads.
            // for short use threadpool

            this.SuspendLayout();

            // setup http server
            try
            {
                httpthread = new Thread(new httpserver().listernforclients)
                {
                    Name = "motion jpg stream-network kml",
                    IsBackground = true
                };
                httpthread.Start();
            }
            catch (Exception ex)
            {
                log.Error("Error starting TCP listener thread: ", ex);
                CustomMessageBox.Show(ex.ToString());
            }

            /// setup joystick packet sender
            joystickthread = new Thread(new ThreadStart(joysticksend))
            {
                IsBackground = true,
                Priority = ThreadPriority.AboveNormal,
                Name = "Main joystick sender"
            };
            joystickthread.Start();

            // setup main serial reader
            serialreaderthread = new Thread(SerialReader)
            {
                IsBackground = true,
                Name = "Main Serial reader",
                Priority = ThreadPriority.AboveNormal
            };
            serialreaderthread.Start();

            // setup main plugin thread
            pluginthread = new Thread(PluginThread)
            {
                IsBackground = true,
                Name = "plugin runner thread",
                Priority = ThreadPriority.BelowNormal
            };
            pluginthread.Start();

            ThreadPool.QueueUserWorkItem(BGLoadAirports);

            ThreadPool.QueueUserWorkItem(BGCreateMaps);

            ThreadPool.QueueUserWorkItem(BGGetAlmanac);

            try
            {
                tfr.GetTFRs();
            }
            catch (Exception ex) { log.Error(ex); }

            try
            {
                // check the last kindex date
                if (MainV2.getConfig("kindexdate") == DateTime.Now.ToShortDateString())
                {
                    // set the cached kindex
                    if (MainV2.getConfig("kindex") != "")
                        KIndex_KIndex(int.Parse(MainV2.getConfig("kindex")),null);
                }
                else
                {
                    System.Threading.ThreadPool.QueueUserWorkItem((WaitCallback)delegate
                    {
                        try
                        {
                            // get a new kindex
                            KIndex.KIndexEvent += KIndex_KIndex;
                            KIndex.GetKIndex();

                            MainV2.config["kindexdate"] = DateTime.Now.ToShortDateString();
                        }
                        catch { }
                    });
                }
            }
            catch (Exception ex) { log.Error(ex); }

            // update firmware version list - only once per day
            try
            {
                System.Threading.ThreadPool.QueueUserWorkItem((WaitCallback)delegate
                {
                    try
                    {
                        if (getConfig("fw_check") != DateTime.Now.ToShortDateString())
                        {
                            var fw = new Firmware();
                            var list = fw.getFWList();
                            if (list.Count > 1)
                                Firmware.SaveSoftwares(list);

                            config["fw_check"] = DateTime.Now.ToShortDateString();
                        }
                    }
                    catch (Exception ex) { log.Error(ex); }
                }
                );
            }
            catch { }

            this.ResumeLayout();

            Program.Splash.Close();

            MissionPlanner.Utilities.Tracking.AddTiming("AppLoad", "Load Time", (DateTime.Now - Program.starttime).TotalMilliseconds, "");

            try
            {
                // single update check per day - in a seperate thread
                if (getConfig("update_check") != DateTime.Now.ToShortDateString())
                {
                    System.Threading.ThreadPool.QueueUserWorkItem(checkupdate);
                    config["update_check"] = DateTime.Now.ToShortDateString();
                }
                else if (getConfig("beta_updates") == "True")
                {
                    MissionPlanner.Utilities.Update.dobeta = true;
                    System.Threading.ThreadPool.QueueUserWorkItem(checkupdate);
                }
            }
            catch (Exception ex)
            {
                log.Error("Update check failed", ex);
            }

            // play a tlog that was passed to the program
            if (Program.args.Length > 0)
            {
                if (File.Exists(Program.args[0]) && Program.args[0].ToLower().Contains(".tlog"))
                {
                    FlightData.LoadLogFile(Program.args[0]);
                    FlightData.BUT_playlog_Click(null, null);
                }
            }

            // show wizard on first use
            /*  if (getConfig("newuser") == "")
              {
                  if (CustomMessageBox.Show("This is your first run, Do you wish to use the setup wizard?\nRecomended for new users.", "Wizard", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                  {
                      Wizard.Wizard wiz = new Wizard.Wizard();

                      wiz.ShowDialog(this);

                  }

                  CustomMessageBox.Show("To use the wizard please goto the initial setup screen, and click the wizard icon.", "Wizard");

                  config["newuser"] = DateTime.Now.ToShortDateString();
              }
              */
        }
Esempio n. 2
0
        private void but_getfw_Click(object sender, EventArgs e)
        {
            string basedir = Application.StartupPath + Path.DirectorySeparatorChar + "History";

            Directory.CreateDirectory(basedir);

            Firmware fw = new Firmware();

            var list = fw.getFWList();

            using (XmlTextWriter xmlwriter = new XmlTextWriter(basedir + Path.DirectorySeparatorChar + @"firmware2.xml", Encoding.ASCII))
            {
                xmlwriter.Formatting = Formatting.Indented;

                xmlwriter.WriteStartDocument();

                xmlwriter.WriteStartElement("options");

                foreach (var software in list)
                {
                    xmlwriter.WriteStartElement("Firmware");

                    if (software.url != "")
                        xmlwriter.WriteElementString("url", new Uri(software.url).LocalPath.TrimStart('/','\\'));
                    if (software.url2560 != "")
                        xmlwriter.WriteElementString("url2560", new Uri(software.url2560).LocalPath.TrimStart('/', '\\'));
                    if (software.url2560_2 != "")
                        xmlwriter.WriteElementString("url2560-2", new Uri(software.url2560_2).LocalPath.TrimStart('/', '\\'));
                    if (software.urlpx4v1 != "")
                        xmlwriter.WriteElementString("urlpx4", new Uri(software.urlpx4v1).LocalPath.TrimStart('/', '\\'));
                    if (software.urlpx4v2 != "")
                        xmlwriter.WriteElementString("urlpx4v2", new Uri(software.urlpx4v2).LocalPath.TrimStart('/', '\\'));
                    xmlwriter.WriteElementString("name", software.name);
                    xmlwriter.WriteElementString("desc", software.desc);
                    xmlwriter.WriteElementString("format_version", software.k_format_version.ToString());

                    xmlwriter.WriteEndElement();

                    if (software.url != "")
                    {
                        Common.getFilefromNet(software.url, basedir + new Uri(software.url).LocalPath);
                    }
                    if (software.url2560 != "")
                    {
                        Common.getFilefromNet(software.url2560, basedir + new Uri(software.url2560).LocalPath);
                    }
                    if (software.url2560_2 != "")
                    {
                        Common.getFilefromNet(software.url2560_2, basedir + new Uri(software.url2560_2).LocalPath);
                    }
                    if (software.urlpx4v1 != "")
                    {
                        Common.getFilefromNet(software.urlpx4v1, basedir + new Uri(software.urlpx4v1).LocalPath);
                    }
                    if (software.urlpx4v2 != "")
                    {
                        Common.getFilefromNet(software.urlpx4v2, basedir + new Uri(software.urlpx4v2).LocalPath);
                    }
                }

                xmlwriter.WriteEndElement();
                xmlwriter.WriteEndDocument();
            }
        }
Esempio n. 3
0
        private void pdr_DoWork(object sender, ProgressWorkerEventArgs e, object passdata = null)
        {
            var fw = new Firmware();
            fw.Progress -= fw_Progress1;
            fw.Progress += fw_Progress;
            softwares = fw.getFWList(firmwareurl);

            foreach (var soft in softwares)
            {
                updateDisplayNameInvoke(soft);
            }
        }
Esempio n. 4
0
        private void BGFirmwareCheck(object state)
        {
            try
            {
                if (Settings.Instance["fw_check"] != DateTime.Now.ToShortDateString())
                {
                    var fw = new Firmware();
                    var list = fw.getFWList();
                    if (list.Count > 1)
                        Firmware.SaveSoftwares(list);

                    Settings.Instance["fw_check"] = DateTime.Now.ToShortDateString();
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Esempio n. 5
0
        private void but_getfw_Click(object sender, EventArgs e)
        {
            string basedir = Application.StartupPath + Path.DirectorySeparatorChar + "History";

            Directory.CreateDirectory(basedir);

            Firmware fw = new Firmware();

            string betafirmwareurl = "https://raw.github.com/diydrones/binary/master/dev/firmware2.xml";

            var list = fw.getFWList();

            using (XmlTextWriter xmlwriter = new XmlTextWriter(basedir + Path.DirectorySeparatorChar + @"firmware2.xml", Encoding.ASCII))
            {
                xmlwriter.Formatting = Formatting.Indented;

                xmlwriter.WriteStartDocument();

                xmlwriter.WriteStartElement("options");

                foreach (var software in list)
                {
                    //if (!software.name.Contains("Copter"))
                      //  continue;

                    xmlwriter.WriteStartElement("Firmware");

                    if (software.url != "")
                        xmlwriter.WriteElementString("url", new Uri(software.url).LocalPath.TrimStart('/','\\'));
                    if (software.url2560 != "")
                        xmlwriter.WriteElementString("url2560", new Uri(software.url2560).LocalPath.TrimStart('/', '\\'));
                    if (software.url2560_2 != "")
                        xmlwriter.WriteElementString("url2560-2", new Uri(software.url2560_2).LocalPath.TrimStart('/', '\\'));
                    if (software.urlpx4v1 != "")
                        xmlwriter.WriteElementString("urlpx4", new Uri(software.urlpx4v1).LocalPath.TrimStart('/', '\\'));
                    if (software.urlpx4v2 != "")
                        xmlwriter.WriteElementString("urlpx4v2", new Uri(software.urlpx4v2).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrbrainv40 != "")
                        xmlwriter.WriteElementString("urlvrbrainv40", new Uri(software.urlvrbrainv40).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrbrainv45 != "")
                        xmlwriter.WriteElementString("urlvrbrainv45", new Uri(software.urlvrbrainv45).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrbrainv50 != "")
                        xmlwriter.WriteElementString("urlvrbrainv50", new Uri(software.urlvrbrainv50).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrbrainv51 != "")
                        xmlwriter.WriteElementString("urlvrbrainv51", new Uri(software.urlvrbrainv51).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrbrainv52 != "")
                        xmlwriter.WriteElementString("urlvrbrainv52", new Uri(software.urlvrbrainv52).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrherov10 != "")
                        xmlwriter.WriteElementString("urlvrherov10", new Uri(software.urlvrherov10).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrubrainv51 != "")
                        xmlwriter.WriteElementString("urlvrubrainv51", new Uri(software.urlvrubrainv51).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrubrainv52 != "")
                        xmlwriter.WriteElementString("urlvrubrainv52", new Uri(software.urlvrubrainv52).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrgimbalv20 != "")
                        xmlwriter.WriteElementString("urlvrgimbalv20", new Uri(software.urlvrgimbalv20).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrugimbalv11 != "")
                        xmlwriter.WriteElementString("urlvrugimbalv11", new Uri(software.urlvrugimbalv11).LocalPath.TrimStart('/', '\\'));
                    xmlwriter.WriteElementString("name", software.name);
                    xmlwriter.WriteElementString("desc", software.desc);
                    xmlwriter.WriteElementString("format_version", software.k_format_version.ToString());

                    xmlwriter.WriteEndElement();

                    if (software.url != "")
                    {
                        Common.getFilefromNet(software.url, basedir + new Uri(software.url).LocalPath);
                    }
                    if (software.url2560 != "")
                    {
                        Common.getFilefromNet(software.url2560, basedir + new Uri(software.url2560).LocalPath);
                    }
                    if (software.url2560_2 != "")
                    {
                        Common.getFilefromNet(software.url2560_2, basedir + new Uri(software.url2560_2).LocalPath);
                    }
                    if (software.urlpx4v1 != "")
                    {
                        Common.getFilefromNet(software.urlpx4v1, basedir + new Uri(software.urlpx4v1).LocalPath);
                    }
                    if (software.urlpx4v2 != "")
                    {
                        Common.getFilefromNet(software.urlpx4v2, basedir + new Uri(software.urlpx4v2).LocalPath);
                    }
                    
                    if (software.urlvrbrainv40 != "")
                    {
                        Common.getFilefromNet(software.urlvrbrainv40, basedir + new Uri(software.urlvrbrainv40).LocalPath);
                    }
                    if (software.urlvrbrainv45 != "")
                    {
                        Common.getFilefromNet(software.urlvrbrainv45, basedir + new Uri(software.urlvrbrainv45).LocalPath);
                    }
                    if (software.urlvrbrainv50 != "")
                    {
                        Common.getFilefromNet(software.urlvrbrainv50, basedir + new Uri(software.urlvrbrainv50).LocalPath);
                    }
                    if (software.urlvrbrainv51 != "")
                    {
                        Common.getFilefromNet(software.urlvrbrainv51, basedir + new Uri(software.urlvrbrainv51).LocalPath);
                    }
                    if (software.urlvrbrainv52 != "")
                    {
                        Common.getFilefromNet(software.urlvrbrainv52, basedir + new Uri(software.urlvrbrainv52).LocalPath);
                    }
                    if (software.urlvrherov10 != "")
                    {
                        Common.getFilefromNet(software.urlvrherov10, basedir + new Uri(software.urlvrherov10).LocalPath);
                    }
                    if (software.urlvrubrainv51 != "")
                    {
                        Common.getFilefromNet(software.urlvrubrainv51, basedir + new Uri(software.urlvrubrainv51).LocalPath);
                    }
                    if (software.urlvrubrainv52 != "")
                    {
                        Common.getFilefromNet(software.urlvrubrainv52, basedir + new Uri(software.urlvrubrainv52).LocalPath);
                    }
                    if (software.urlvrgimbalv20 != "")
                    {
                        Common.getFilefromNet(software.urlvrgimbalv20, basedir + new Uri(software.urlvrgimbalv20).LocalPath);
                    }
                    if (software.urlvrugimbalv11 != "")
                    {
                        Common.getFilefromNet(software.urlvrugimbalv11, basedir + new Uri(software.urlvrugimbalv11).LocalPath);
                    }
                     
                }

                xmlwriter.WriteEndElement();
                xmlwriter.WriteEndDocument();
            }
        }
Esempio n. 6
0
        private void but_getfw_Click(object sender, EventArgs e)
        {
            var basedir = Settings.GetDataDirectory() + "History";

            Directory.CreateDirectory(basedir);

            var fw = new Firmware();

            var list = fw.getFWList();

            using (
                var xmlwriter = new XmlTextWriter(basedir + Path.DirectorySeparatorChar + @"firmware2.xml",
                    Encoding.ASCII))
            {
                xmlwriter.Formatting = Formatting.Indented;

                xmlwriter.WriteStartDocument();

                xmlwriter.WriteStartElement("options");

                foreach (var software in list)
                {
                    //if (!software.name.Contains("Copter"))
                    //  continue;

                    xmlwriter.WriteStartElement("Firmware");

                    if (software.url != "")
                        xmlwriter.WriteElementString("url", new Uri(software.url).LocalPath.TrimStart('/', '\\'));
                    if (software.url2560 != "")
                        xmlwriter.WriteElementString("url2560", new Uri(software.url2560).LocalPath.TrimStart('/', '\\'));
                    if (software.url2560_2 != "")
                        xmlwriter.WriteElementString("url2560-2",
                            new Uri(software.url2560_2).LocalPath.TrimStart('/', '\\'));
                    if (software.urlpx4v1 != "")
                        xmlwriter.WriteElementString("urlpx4", new Uri(software.urlpx4v1).LocalPath.TrimStart('/', '\\'));
                    if (software.urlpx4v2 != "")
                        xmlwriter.WriteElementString("urlpx4v2",
                            new Uri(software.urlpx4v2).LocalPath.TrimStart('/', '\\'));
                    if (software.urlpx4v4 != "")
                        xmlwriter.WriteElementString("urlpx4v4",
                            new Uri(software.urlpx4v4).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrbrainv40 != "")
                        xmlwriter.WriteElementString("urlvrbrainv40",
                            new Uri(software.urlvrbrainv40).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrbrainv45 != "")
                        xmlwriter.WriteElementString("urlvrbrainv45",
                            new Uri(software.urlvrbrainv45).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrbrainv50 != "")
                        xmlwriter.WriteElementString("urlvrbrainv50",
                            new Uri(software.urlvrbrainv50).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrbrainv51 != "")
                        xmlwriter.WriteElementString("urlvrbrainv51",
                            new Uri(software.urlvrbrainv51).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrbrainv52 != "")
                        xmlwriter.WriteElementString("urlvrbrainv52",
                            new Uri(software.urlvrbrainv52).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrcorev10 != "")
                        xmlwriter.WriteElementString("urlvrcorev10",
                            new Uri(software.urlvrcorev10).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrubrainv51 != "")
                        xmlwriter.WriteElementString("urlvrubrainv51",
                            new Uri(software.urlvrubrainv51).LocalPath.TrimStart('/', '\\'));
                    if (software.urlvrubrainv52 != "")
                        xmlwriter.WriteElementString("urlvrubrainv52",
                            new Uri(software.urlvrubrainv52).LocalPath.TrimStart('/', '\\'));
                    if (software.urlbebop2 != "")
                        xmlwriter.WriteElementString("urlbebop2",
                            new Uri(software.urlbebop2).LocalPath.TrimStart('/', '\\'));
                    if (software.urldisco != "")
                        xmlwriter.WriteElementString("urldisco",
                            new Uri(software.urldisco).LocalPath.TrimStart('/', '\\'));
                    xmlwriter.WriteElementString("name", software.name);
                    xmlwriter.WriteElementString("desc", software.desc);
                    xmlwriter.WriteElementString("format_version", software.k_format_version.ToString());

                    xmlwriter.WriteEndElement();

                    if (software.url != "")
                    {
                        Common.getFilefromNet(software.url, basedir + new Uri(software.url).LocalPath);
                    }
                    if (software.url2560 != "")
                    {
                        Common.getFilefromNet(software.url2560, basedir + new Uri(software.url2560).LocalPath);
                    }
                    if (software.url2560_2 != "")
                    {
                        Common.getFilefromNet(software.url2560_2, basedir + new Uri(software.url2560_2).LocalPath);
                    }
                    if (software.urlpx4v1 != "")
                    {
                        Common.getFilefromNet(software.urlpx4v1, basedir + new Uri(software.urlpx4v1).LocalPath);
                    }
                    if (software.urlpx4v2 != "")
                    {
                        Common.getFilefromNet(software.urlpx4v2, basedir + new Uri(software.urlpx4v2).LocalPath);
                    }
                    if (software.urlpx4v4 != "")
                    {
                        Common.getFilefromNet(software.urlpx4v4, basedir + new Uri(software.urlpx4v4).LocalPath);
                    }

                    if (software.urlvrbrainv40 != "")
                    {
                        Common.getFilefromNet(software.urlvrbrainv40,
                            basedir + new Uri(software.urlvrbrainv40).LocalPath);
                    }
                    if (software.urlvrbrainv45 != "")
                    {
                        Common.getFilefromNet(software.urlvrbrainv45,
                            basedir + new Uri(software.urlvrbrainv45).LocalPath);
                    }
                    if (software.urlvrbrainv50 != "")
                    {
                        Common.getFilefromNet(software.urlvrbrainv50,
                            basedir + new Uri(software.urlvrbrainv50).LocalPath);
                    }
                    if (software.urlvrbrainv51 != "")
                    {
                        Common.getFilefromNet(software.urlvrbrainv51,
                            basedir + new Uri(software.urlvrbrainv51).LocalPath);
                    }
                    if (software.urlvrbrainv52 != "")
                    {
                        Common.getFilefromNet(software.urlvrbrainv52,
                            basedir + new Uri(software.urlvrbrainv52).LocalPath);
                    }
                    if (software.urlvrcorev10 != "")
                    {
                        Common.getFilefromNet(software.urlvrcorev10, basedir + new Uri(software.urlvrcorev10).LocalPath);
                    }
                    if (software.urlvrubrainv51 != "")
                    {
                        Common.getFilefromNet(software.urlvrubrainv51,
                            basedir + new Uri(software.urlvrubrainv51).LocalPath);
                    }
                    if (software.urlvrubrainv52 != "")
                    {
                        Common.getFilefromNet(software.urlvrubrainv52,
                            basedir + new Uri(software.urlvrubrainv52).LocalPath);
                    }
                    if (software.urlbebop2 != "")
                    {
                        Common.getFilefromNet(software.urlbebop2,
                            basedir + new Uri(software.urlbebop2).LocalPath);
                    }
                    if (software.urldisco != "")
                    {
                        Common.getFilefromNet(software.urldisco,
                            basedir + new Uri(software.urldisco).LocalPath);
                    }
                }

                xmlwriter.WriteEndElement();
                xmlwriter.WriteEndDocument();
            }
        }