本文整理汇总了C#中software类的典型用法代码示例。如果您正苦于以下问题:C# software类的具体用法?C# software怎么用?C# software使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
software类属于命名空间,在下文中一共展示了software类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getFWList
/// <summary>
/// Load xml from internet based on firmwareurl, and return softwarelist
/// </summary>
/// <returns></returns>
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 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 "name":
name = xmlreader.ReadString();
break;
case "format_version":
//.........这里部分代码省略.........
示例2: update
/// <summary>
/// Do full update - get firmware from internet
/// </summary>
/// <param name="temp"></param>
/// <param name="historyhash"></param>
public bool update(string comport, software temp, string historyhash)
{
BoardDetect.boards board = BoardDetect.boards.none;
try
{
updateProgress(-1, Strings.DetectingBoardVersion);
board = BoardDetect.DetectBoard(comport);
if (board == BoardDetect.boards.none)
{
CustomMessageBox.Show(Strings.CantDetectBoardVersion);
return false;
}
log.Info("Detected a " + board);
updateProgress(-1, Strings.DetectedA + board);
string baseurl = "";
if (board == BoardDetect.boards.b2560)
{
baseurl = temp.url2560.ToString();
}
else if (board == BoardDetect.boards.b1280)
{
baseurl = temp.url.ToString();
}
else if (board == BoardDetect.boards.b2560v2)
{
baseurl = temp.url2560_2.ToString();
}
else if (board == BoardDetect.boards.px4)
{
baseurl = temp.urlpx4v1.ToString();
}
else if (board == BoardDetect.boards.px4v2)
{
baseurl = temp.urlpx4v2.ToString();
}
else if (board == BoardDetect.boards.px4v4)
{
baseurl = temp.urlpx4v4.ToString();
}
else if (board == BoardDetect.boards.vrbrainv40)
{
baseurl = temp.urlvrbrainv40.ToString();
}
else if (board == BoardDetect.boards.vrbrainv45)
{
baseurl = temp.urlvrbrainv45.ToString();
}
else if (board == BoardDetect.boards.vrbrainv50)
{
baseurl = temp.urlvrbrainv50.ToString();
}
else if (board == BoardDetect.boards.vrbrainv51)
{
baseurl = temp.urlvrbrainv51.ToString();
}
else if (board == BoardDetect.boards.vrbrainv52)
{
baseurl = temp.urlvrbrainv52.ToString();
}
else if (board == BoardDetect.boards.vrcorev10)
{
baseurl = temp.urlvrcorev10.ToString();
}
else if (board == BoardDetect.boards.vrubrainv51)
{
baseurl = temp.urlvrubrainv51.ToString();
}
else if (board == BoardDetect.boards.vrubrainv52)
{
baseurl = temp.urlvrubrainv52.ToString();
}
else
{
CustomMessageBox.Show(Strings.InvalidBoardType);
return false;
}
if (board < BoardDetect.boards.px4)
{
if (temp.name.ToLower().Contains("arducopter"))
{
CustomMessageBox.Show(Strings.ThisBoardHasBeenRetired, Strings.Note);
}
}
if (historyhash != "")
baseurl = getUrl(historyhash, baseurl);
// update to use mirror url
//.........这里部分代码省略.........
示例3: pdr_DoWork
void pdr_DoWork(object sender, Controls.ProgressWorkerEventArgs e, object passdata = null)
{
log.Info("FW load");
string url = "";
string url2560 = "";
string url2560_2 = "";
string px4 = "";
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; });
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 "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 (!url2560.Equals("") && !name.Equals("") && !desc.Equals("Please Update"))
{
temp.desc = desc;
temp.name = name;
temp.url = url;
temp.url2560 = url2560;
temp.url2560_2 = url2560_2;
temp.urlpx4 = px4;
temp.k_format_version = k_format_version;
try
{
try
{
if (!url2560.Contains("github"))
{
name = getAPMVersion(temp.url2560);
if (name != "")
temp.name = name;
}
}
catch { }
updateDisplayNameInvoke(temp);
}
catch { } // just in case
softwares.Add(temp);
}
url = "";
url2560 = "";
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 ex;
//.........这里部分代码省略.........
示例4: update
private void update(software temp)
{
string board = "";
MainV2.comPort.BaseStream.DtrEnable = false;
MainV2.comPort.Close();
System.Threading.Thread.Sleep(100);
MainV2.comPort.giveComport = true;
try
{
if (softwares.Count == 0)
{
CustomMessageBox.Show("No valid options");
return;
}
lbl_status.Text = "Detecting APM Version";
this.Refresh();
Application.DoEvents();
/*
ArdupilotMega.Controls.Firmware_Board fwb = new ArdupilotMega.Controls.Firmware_Board();
fwb.ShowDialog();
var boardname = ArdupilotMega.Controls.Firmware_Board.fw;
switch (boardname)
{
case ArdupilotMega.Controls.Firmware_Board.Firmware.apm1:
board = "2560";
break;
case ArdupilotMega.Controls.Firmware_Board.Firmware.apm2:
board = "2560-2";
break;
case ArdupilotMega.Controls.Firmware_Board.Firmware.apm2_5:
board = "2560-2";
break;
case ArdupilotMega.Controls.Firmware_Board.Firmware.px4:
board = "px4";
break;
}
*/
board = ArduinoDetect.DetectBoard(MainV2.comPortName);
if (board == "")
{
CustomMessageBox.Show("Cant detect your APM version. Please check your cabling");
return;
}
int apmformat_version = -1; // fail continue
if (board != "px4")
{
try
{
apmformat_version = ArduinoDetect.decodeApVar(MainV2.comPortName, board);
}
catch { }
if (apmformat_version != -1 && apmformat_version != temp.k_format_version)
{
if (DialogResult.No == CustomMessageBox.Show("Epprom changed, all your setting will be lost during the update,\nDo you wish to continue?", "Epprom format changed (" + apmformat_version + " vs " + temp.k_format_version + ")", MessageBoxButtons.YesNo))
{
CustomMessageBox.Show("Please connect and backup your config in the configuration tab.");
return;
}
}
}
log.Info("Detected a " + board);
string baseurl = "";
if (board == "2560")
{
baseurl = temp.url2560.ToString();
}
else if (board == "1280")
{
baseurl = temp.url.ToString();
}
else if (board == "2560-2")
{
baseurl = temp.url2560_2.ToString();
}
else if (board == "px4")
{
baseurl = temp.urlpx4.ToString();
}
else
{
CustomMessageBox.Show("Invalid Board Type");
return;
}
// use the git-history url
if (CMB_history.Visible == true)
{
//.........这里部分代码省略.........
示例5: updateDisplayNameInvoke
void updateDisplayNameInvoke(software temp)
{
this.Invoke((MethodInvoker)delegate
{
updateDisplayName(temp);
});
}
示例6: findfirmware
void findfirmware(software findwhat)
{
DialogResult dr = CustomMessageBox.Show("Are you sure you want to upload " + findwhat.name + "?", "Continue", MessageBoxButtons.YesNo);
if (dr == System.Windows.Forms.DialogResult.Yes)
{
update(findwhat);
}
}
示例7: update
/// <summary>
/// Do full update - get firmware from internet
/// </summary>
/// <param name="temp"></param>
/// <param name="historyhash"></param>
public bool update(string comport, software temp, string historyhash)
{
BoardDetect.boards board = BoardDetect.boards.none;
try
{
updateProgress(-1, "Detecting Board Version");
board = BoardDetect.DetectBoard(comport);
if (board == BoardDetect.boards.none)
{
CustomMessageBox.Show("Cant detect your Board version. Please check your cabling");
return false;
}
int apmformat_version = -1; // fail continue
if (board != BoardDetect.boards.px4 && board != BoardDetect.boards.px4v2)
{
try
{
apmformat_version = BoardDetect.decodeApVar(comport, board);
}
catch { }
if (apmformat_version != -1 && apmformat_version != temp.k_format_version)
{
if (DialogResult.No == CustomMessageBox.Show("Epprom changed, all your setting will be lost during the update,\nDo you wish to continue?", "Epprom format changed (" + apmformat_version + " vs " + temp.k_format_version + ")", MessageBoxButtons.YesNo))
{
CustomMessageBox.Show("Please connect and backup your config in the configuration tab.");
return false;
}
}
}
log.Info("Detected a " + board);
updateProgress(-1, "Detected a " + board);
string baseurl = "";
if (board == BoardDetect.boards.b2560)
{
baseurl = temp.url2560.ToString();
}
else if (board == BoardDetect.boards.b1280)
{
baseurl = temp.url.ToString();
}
else if (board == BoardDetect.boards.b2560v2)
{
baseurl = temp.url2560_2.ToString();
}
else if (board == BoardDetect.boards.px4)
{
baseurl = temp.urlpx4v1.ToString();
}
else if (board == BoardDetect.boards.px4v2)
{
baseurl = temp.urlpx4v2.ToString();
}
else
{
CustomMessageBox.Show("Invalid Board Type");
return false;
}
if (historyhash != "")
baseurl = getUrl(historyhash, baseurl);
log.Info("Using " + baseurl);
// Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create(baseurl);
request.Timeout = 10000;
// Set the Method property of the request to POST.
request.Method = "GET";
// Get the request stream.
Stream dataStream; //= request.GetRequestStream();
// Get the response.
WebResponse response = request.GetResponse();
// Display the status.
log.Info(((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
dataStream = response.GetResponseStream();
long bytes = response.ContentLength;
long contlen = bytes;
byte[] buf1 = new byte[1024];
FileStream fs = new FileStream(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + @"firmware.hex", FileMode.Create);
updateProgress(0, "Downloading from Internet");
//.........这里部分代码省略.........
示例8: updateDisplayName
void updateDisplayName(software temp)
{
if (temp.url2560.ToLower().Contains("AR2".ToLower()) || temp.url2560.ToLower().Contains("apm1/APMRover".ToLower()))
{
pictureBoxRover.Text = temp.name;
pictureBoxRover.Tag = temp;
}
else if (temp.url2560.ToLower().Contains("AP-".ToLower()) || temp.url2560.ToLower().Contains("apm1/ArduPlane".ToLower()))
{
pictureBoxAPM.Text = temp.name;
pictureBoxAPM.Tag = temp;
}
else if (temp.url2560.ToLower().Contains("APHIL-".ToLower()) || temp.url2560.ToLower().Contains("apm1-hilsensors/ArduPlane".ToLower()))
{
pictureBoxAPHil.Text = temp.name;
pictureBoxAPHil.Tag = temp;
}
else if (temp.url2560.ToLower().Contains("ac2-quad-".ToLower()) || temp.url2560.ToLower().Contains("1-quad/ArduCopter".ToLower()))
{
pictureBoxQuad.Text = temp.name;
pictureBoxQuad.Tag = temp;
}
else if (temp.url2560.ToLower().Contains("ac2-tri".ToLower()) || temp.url2560.ToLower().Contains("-tri/ArduCopter".ToLower()))
{
pictureBoxTri.Text = temp.name;
pictureBoxTri.Tag = temp;
}
else if (temp.url2560.ToLower().Contains("ac2-hexa".ToLower()) || temp.url2560.ToLower().Contains("-hexa/ArduCopter".ToLower()))
{
pictureBoxHexa.Text = temp.name;
pictureBoxHexa.Tag = temp;
}
else if (temp.url2560.ToLower().Contains("ac2-y6".ToLower()) || temp.url2560.ToLower().Contains("-y6/ArduCopter".ToLower()))
{
pictureBoxY6.Text = temp.name;
pictureBoxY6.Tag = temp;
}
else if (temp.url2560.ToLower().Contains("ac2-heli-".ToLower()) || temp.url2560.ToLower().Contains("-heli/ArduCopter".ToLower()))
{
pictureBoxHeli.Text = temp.name;
pictureBoxHeli.Tag = temp;
}
else if (temp.url2560.ToLower().Contains("ac2-helhil".ToLower()) || temp.url2560.ToLower().Contains("-heli-hil/ArduCopter".ToLower()))
{
pictureBoxACHHil.Text = temp.name;
pictureBoxACHHil.Tag = temp;
}
else if (temp.url2560.ToLower().Contains("ac2-quadhil".ToLower()) || temp.url2560.ToLower().Contains("-quad-hil/ArduCopter".ToLower()))
{
pictureBoxACHil.Text = temp.name;
pictureBoxACHil.Tag = temp;
}
else if (temp.url2560.ToLower().Contains("ac2-octaquad-".ToLower()) || temp.url2560.ToLower().Contains("-octa-quad/ArduCopter".ToLower()))
{
pictureBoxOctaQuad.Text = temp.name;
pictureBoxOctaQuad.Tag = temp;
}
else if (temp.url2560.ToLower().Contains("ac2-octa-".ToLower()) || temp.url2560.ToLower().Contains("-octa/ArduCopter".ToLower()))
{
pictureBoxOcta.Text = temp.name;
pictureBoxOcta.Tag = temp;
}
else
{
log.Info("No Home " + temp.name + " " + temp.url2560);
}
}
示例9: Firmware_Load
internal void Firmware_Load(object sender, EventArgs e)
{
log.Info("FW load");
string url = "";
string url2560 = "";
string url2560_2 = "";
string name = "";
string desc = "";
int k_format_version = 0;
softwares.Clear();
software temp = new software();
try
{
using (XmlTextReader xmlreader = new XmlTextReader("http://ardupilot-mega.googlecode.com/git/Tools/ArdupilotMegaPlanner/Firmware/firmware2.xml"))
{
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 "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 (!url.Equals("") && !name.Equals("") && !desc.Equals("Please Update"))
{
temp.desc = desc;
temp.name = name;
temp.url = url;
temp.url2560 = url2560;
temp.url2560_2 = url2560_2;
temp.k_format_version = k_format_version;
try
{
updateDisplayName(temp);
}
catch { } // just in case
softwares.Add(temp);
}
url = "";
url2560 = "";
name = "";
desc = "";
k_format_version = 0;
temp = new software();
break;
default:
break;
}
}
}
}
catch (Exception ex)
{
CustomMessageBox.Show("Failed to get Firmware List : " + ex.Message);
}
log.Info("FW load done");
}
示例10: updateDisplayName
void updateDisplayName(software temp)
{
if (temp.url.ToLower().Contains("firmware/AP-1".ToLower()))
{
pictureBoxAPM.Text = temp.name;
}
else if (temp.url.ToLower().Contains("firmware/APHIL-".ToLower()))
{
pictureBoxAPHil.Text = temp.name;
}
else if (temp.url.ToLower().Contains("firmware/ac2-quad-".ToLower()))
{
pictureBoxQuad.Text = temp.name;
}
else if (temp.url.ToLower().Contains("firmware/ac2-tri".ToLower()))
{
pictureBoxTri.Text = temp.name;
}
else if (temp.url.ToLower().Contains("firmware/ac2-hexa".ToLower()))
{
pictureBoxHexa.Text = temp.name;
}
else if (temp.url.ToLower().Contains("firmware/ac2-y6".ToLower()))
{
pictureBoxY6.Text = temp.name;
}
else if (temp.url.ToLower().Contains("firmware/ac2-heli-1".ToLower()))
{
pictureBoxHeli.Text = temp.name;
}
else if (temp.url.ToLower().Contains("firmware/ac2-quadhil".ToLower()))
{
pictureBoxACHil.Text = temp.name;
}
else if (temp.url.ToLower().Contains("firmware/ac2-octav-".ToLower()))
{
pictureBoxOctav.Text = temp.name;
}
else if (temp.url.ToLower().Contains("firmware/ac2-octa-".ToLower()))
{
pictureBoxOcta.Text = temp.name;
}
else
{
log.Info("No Home " + temp.name + " " + temp.url);
}
}
示例11: update
/// <summary>
/// Do full update - get firmware from internet
/// </summary>
/// <param name="temp"></param>
/// <param name="historyhash"></param>
public bool update(string comport, software temp, string historyhash)
{
BoardDetect.boards board = BoardDetect.boards.none;
try
{
updateProgress(-1, Strings.DetectingBoardVersion);
board = BoardDetect.DetectBoard(comport);
if (board == BoardDetect.boards.none)
{
CustomMessageBox.Show(Strings.CantDetectBoardVersion);
return false;
}
int apmformat_version = -1; // fail continue
if (board != BoardDetect.boards.px4 && board != BoardDetect.boards.px4v2 && board != BoardDetect.boards.vrbrainv40 && board != BoardDetect.boards.vrbrainv45 && board != BoardDetect.boards.vrbrainv50 && board != BoardDetect.boards.vrbrainv51 && board != BoardDetect.boards.vrbrainv52 && board != BoardDetect.boards.vrherov10 && board != BoardDetect.boards.vrubrainv51 && board != BoardDetect.boards.vrubrainv52 && board != BoardDetect.boards.vrgimbalv20 && board != BoardDetect.boards.vrugimbalv11)
{
try
{
apmformat_version = BoardDetect.decodeApVar(comport, board);
}
catch { }
if (apmformat_version != -1 && apmformat_version != temp.k_format_version)
{
if (DialogResult.No == CustomMessageBox.Show(Strings.EppromChanged, String.Format(Strings.EppromFormatChanged, apmformat_version, temp.k_format_version), MessageBoxButtons.YesNo))
{
CustomMessageBox.Show(Strings.PleaseConnectAndBackupConfig);
return false;
}
}
}
log.Info("Detected a " + board);
updateProgress(-1, Strings.DetectedA + board);
string baseurl = "";
if (board == BoardDetect.boards.b2560)
{
baseurl = temp.url2560.ToString();
}
else if (board == BoardDetect.boards.b1280)
{
baseurl = temp.url.ToString();
}
else if (board == BoardDetect.boards.b2560v2)
{
baseurl = temp.url2560_2.ToString();
}
else if (board == BoardDetect.boards.px4)
{
baseurl = temp.urlpx4v1.ToString();
}
else if (board == BoardDetect.boards.px4v2)
{
baseurl = temp.urlpx4v2.ToString();
}
else if (board == BoardDetect.boards.vrbrainv40)
{
baseurl = temp.urlvrbrainv40.ToString();
}
else if (board == BoardDetect.boards.vrbrainv45)
{
baseurl = temp.urlvrbrainv45.ToString();
}
else if (board == BoardDetect.boards.vrbrainv50)
{
baseurl = temp.urlvrbrainv50.ToString();
}
else if (board == BoardDetect.boards.vrbrainv51)
{
baseurl = temp.urlvrbrainv51.ToString();
}
else if (board == BoardDetect.boards.vrbrainv52)
{
baseurl = temp.urlvrbrainv52.ToString();
}
else if (board == BoardDetect.boards.vrherov10)
{
baseurl = temp.urlvrherov10.ToString();
}
else if (board == BoardDetect.boards.vrubrainv51)
{
baseurl = temp.urlvrubrainv51.ToString();
}
else if (board == BoardDetect.boards.vrubrainv52)
{
baseurl = temp.urlvrubrainv52.ToString();
}
//.........这里部分代码省略.........
示例12: getFWList
/// <summary>
/// Load xml from internet based on firmwareurl, and return softwarelist
/// </summary>
/// <returns></returns>
public List<software> getFWList(string firmwareurl = "")
{
if (firmwareurl == "")
firmwareurl = this.firmwareurl;
log.Info("getFWList");
string url = "";
string url2560 = "";
string url2560_2 = "";
string px4 = "";
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,"Getting FW List");
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 "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 (!url2560.Equals("") && !name.Equals("") && !desc.Equals("Please Update"))
{
temp.desc = desc;
temp.name = name;
temp.url = url;
temp.url2560 = url2560;
temp.url2560_2 = url2560_2;
temp.urlpx4 = px4;
temp.k_format_version = k_format_version;
try
{
try
{
if (!url2560.Contains("github"))
{
name = getAPMVersion(temp.url2560);
if (name != "")
temp.name = name;
}
}
catch { }
}
catch { } // just in case
softwares.Add(temp);
}
url = "";
url2560 = "";
name = "";
desc = "";
k_format_version = 0;
temp = new software();
break;
default:
break;
}
}
}
//.........这里部分代码省略.........
示例13: updateDisplayName
void updateDisplayName(software temp)
{
if (temp.url.ToLower().Contains("firmware/AP-1".ToLower()))
{
lbl_AP.Text = temp.name;
}
else if (temp.url.ToLower().Contains("firmware/APHIL-".ToLower()))
{
lbl_APHil.Text = temp.name;
}
else if (temp.url.ToLower().Contains("firmware/ac2-quad-".ToLower()))
{
lbl_ACQuad.Text = temp.name;
}
else if (temp.url.ToLower().Contains("firmware/ac2-tri".ToLower()))
{
lbl_ACTri.Text = temp.name;
}
else if (temp.url.ToLower().Contains("firmware/ac2-hexa".ToLower()))
{
lbl_ACHexa.Text = temp.name;
}
else if (temp.url.ToLower().Contains("firmware/ac2-y6".ToLower()))
{
lbl_ACY6.Text = temp.name;
}
else if (temp.url.ToLower().Contains("firmware/ac2-heli-1".ToLower()))
{
lbl_Heli.Text = temp.name;
}
else if (temp.url.ToLower().Contains("firmware/ac2-quadhil".ToLower()))
{
lbl_ACHil.Text = temp.name;
}
else
{
Console.WriteLine("No Home "+ temp.name + " " + temp.url);
}
}
示例14: Firmware_Load
internal void Firmware_Load(object sender, EventArgs e)
{
log.Info("FW load");
string url = "";
string url2560 = "";
string url2560_2 = "";
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; });
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 "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 (!url.Equals("") && !name.Equals("") && !desc.Equals("Please Update"))
{
temp.desc = desc;
temp.name = name;
temp.url = url;
temp.url2560 = url2560;
temp.url2560_2 = url2560_2;
temp.k_format_version = k_format_version;
try
{
updateDisplayName(temp);
}
catch { } // just in case
softwares.Add(temp);
}
url = "";
url2560 = "";
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);
}
log.Info("FW load done");
}
示例15: UploadFlash
public void UploadFlash(string filename, string board, software installing)
{
if (board == "px4")
{
UploadPX4(filename);
return;
}
byte[] FLASH = new byte[1];
StreamReader sr = null;
try
{
lbl_status.Text = "Reading Hex File";
this.Refresh();
Application.DoEvents();
sr = new StreamReader(filename);
FLASH = readIntelHEXv2(sr);
sr.Close();
log.InfoFormat("\n\nSize: {0}\n\n", FLASH.Length);
}
catch (Exception ex)
{
if (sr != null)
{
sr.Dispose();
}
lbl_status.Text = "Failed read HEX";
CustomMessageBox.Show("Failed to read firmware.hex : " + ex.Message);
return;
}
IArduinoComms port = new ArduinoSTK();
if (board == "1280")
{
if (FLASH.Length > 126976)
{
CustomMessageBox.Show("Firmware is to big for a 1280, Please upgrade your hardware!!");
return;
}
//port = new ArduinoSTK();
port.BaudRate = 57600;
}
else if (board == "2560" || board == "2560-2")
{
port = new ArduinoSTKv2
{
BaudRate = 115200
};
}
port.DataBits = 8;
port.StopBits = System.IO.Ports.StopBits.One;
port.Parity = System.IO.Ports.Parity.None;
port.DtrEnable = true;
try
{
port.PortName = MainV2.comPortName;
port.Open();
flashing = true;
if (port.connectAP())
{
log.Info("starting");
lbl_status.Text = "Uploading " + FLASH.Length + " bytes to APM Board: " + board;
progress.Value = 0;
this.Refresh();
// this is enough to make ap_var reset
//port.upload(new byte[256], 0, 2, 0);
port.Progress += port_Progress;
if (!port.uploadflash(FLASH, 0, FLASH.Length, 0))
{
flashing = false;
if (port.IsOpen)
port.Close();
throw new Exception("Upload failed. Lost sync. Try Arduino!!");
}
port.Progress -= new ProgressEventHandler(port_Progress);
progress.Value = 100;
log.Info("Uploaded");
this.Refresh();
int start = 0;
short length = 0x100;
byte[] flashverify = new byte[FLASH.Length + 256];
lbl_status.Text = "Verify APM";
progress.Value = 0;
this.Refresh();
while (start < FLASH.Length)
//.........这里部分代码省略.........