public getFWList ( string firmwareurl = "" ) : List |
||
firmwareurl | string | |
return | List |
public List<software> getFWList(string firmwareurl = "")
{
if (firmwareurl == "")
firmwareurl = this.firmwareurl;
// mirror support
L10N.ReplaceMirrorUrl(ref firmwareurl);
log.Info("getFWList");
string url = "";
string url2560 = "";
string url2560_2 = "";
string px4 = "";
string px4v2 = "";
string px4v4 = "";
string vrbrainv40 = "";
string vrbrainv45 = "";
string vrbrainv50 = "";
string vrbrainv51 = "";
string vrbrainv52 = "";
string vrcorev10 = "";
string vrubrainv51 = "";
string vrubrainv52 = "";
string bebop2 = "";
string disco = "";
string name = "";
string desc = "";
int k_format_version = 0;
softwares.Clear();
software temp = new software();
// this is for mono to a ssl server
//ServicePointManager.CertificatePolicy = new NoCheckCertificatePolicy();
ServicePointManager.ServerCertificateValidationCallback =
new System.Net.Security.RemoteCertificateValidationCallback(
(sender1, certificate, chain, policyErrors) => { return true; });
updateProgress(-1, Strings.GettingFWList);
try
{
log.Info("url: " + firmwareurl);
using (XmlTextReader xmlreader = new XmlTextReader(firmwareurl))
{
while (xmlreader.Read())
{
xmlreader.MoveToElement();
switch (xmlreader.Name)
{
case "url":
url = xmlreader.ReadString();
break;
case "url2560":
url2560 = xmlreader.ReadString();
break;
case "url2560-2":
url2560_2 = xmlreader.ReadString();
break;
case "urlpx4":
px4 = xmlreader.ReadString();
break;
case "urlpx4v2":
px4v2 = xmlreader.ReadString();
break;
case "urlpx4v4":
px4v4 = xmlreader.ReadString();
break;
case "urlvrbrainv40":
vrbrainv40 = xmlreader.ReadString();
break;
case "urlvrbrainv45":
vrbrainv45 = xmlreader.ReadString();
break;
case "urlvrbrainv50":
vrbrainv50 = xmlreader.ReadString();
break;
case "urlvrbrainv51":
vrbrainv51 = xmlreader.ReadString();
break;
case "urlvrbrainv52":
vrbrainv52 = xmlreader.ReadString();
break;
case "urlvrcorev10":
vrcorev10 = xmlreader.ReadString();
break;
case "urlvrubrainv51":
vrubrainv51 = xmlreader.ReadString();
break;
case "urlvrubrainv52":
vrubrainv52 = xmlreader.ReadString();
break;
case "urlbebop2":
bebop2 = xmlreader.ReadString();
break;
case "urldisco":
disco = xmlreader.ReadString();
break;
case "name":
name = xmlreader.ReadString();
break;
case "format_version":
k_format_version = int.Parse(xmlreader.ReadString());
break;
case "desc":
desc = xmlreader.ReadString();
break;
case "Firmware":
if (!name.Equals("") && !desc.Equals("Please Update"))
{
temp.desc = desc.Trim();
temp.name = name;
temp.url = url;
temp.url2560 = url2560;
temp.url2560_2 = url2560_2;
temp.urlpx4v1 = px4;
temp.urlpx4v2 = px4v2;
temp.urlpx4v4 = px4v4;
temp.urlvrbrainv40 = vrbrainv40;
temp.urlvrbrainv45 = vrbrainv45;
temp.urlvrbrainv50 = vrbrainv50;
temp.urlvrbrainv51 = vrbrainv51;
temp.urlvrbrainv52 = vrbrainv52;
temp.urlvrcorev10 = vrcorev10;
temp.urlvrubrainv51 = vrubrainv51;
temp.urlvrubrainv52 = vrubrainv52;
temp.urlbebop2 = bebop2;
temp.urldisco = disco;
temp.k_format_version = k_format_version;
try
{
try
{
if (!url2560.Contains("github"))
{
//name =
lock (this)
{
ingetapmversion++;
}
System.Threading.ThreadPool.QueueUserWorkItem(getAPMVersion, temp);
//if (name != "")
//temp.name = name;
}
}
catch
{
}
}
catch
{
} // just in case
softwares.Add(temp);
}
url = "";
url2560 = "";
url2560_2 = "";
px4 = "";
px4v2 = "";
px4v4 = "";
vrbrainv40 = "";
vrbrainv45 = "";
vrbrainv50 = "";
vrbrainv51 = "";
vrbrainv52 = "";
vrcorev10 = "";
vrubrainv51 = "";
vrubrainv52 = "";
bebop2 = "";
disco = "";
name = "";
desc = "";
k_format_version = 0;
temp = new software();
break;
default:
break;
}
}
}
}
catch (Exception ex)
{
log.Error(ex);
//CustomMessageBox.Show("Failed to get Firmware List : " + ex.Message);
throw;
}
while (ingetapmversion > 0)
System.Threading.Thread.Sleep(100);
log.Info("load done");
updateProgress(-1, Strings.ReceivedList);
return softwares;
}
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(); } */ }