getFilefromNet() 공개 정적인 메소드

public static getFilefromNet ( string url, string saveto ) : bool
url string
saveto string
리턴 bool
예제 #1
0
        bool getFirmware(uploader.Uploader.Code device)
        {
            // was https://raw.github.com/tridge/SiK/master/Firmware/dst/radio.hm_trp.hex
            // now http://www.samba.org/tridge/UAV/3DR/radio.hm_trp.hex

            if (device == uploader.Uploader.Code.DEVICE_ID_HM_TRP)
            {
                return(Common.getFilefromNet("http://www.samba.org/tridge/UAV/3DR/radio.hm_trp.hex", firmwarefile));
            }
            else if (device == uploader.Uploader.Code.DEVICE_ID_RFD900)
            {
                return(Common.getFilefromNet("http://rfdesign.com.au/firmware/radio.rfd900.hex", firmwarefile));
            }
            else if (device == uploader.Uploader.Code.DEVICE_ID_RFD900A)
            {
                int fixme;
                int fixme23;

                //  return Common.getFilefromNet("http://rfdesign.com.au/firmware/MPSiK%20V2.2%20radio~rfd900a.ihx", firmwarefile);

                return(Common.getFilefromNet("http://rfdesign.com.au/firmware/radio.rfd900a.hex", firmwarefile));
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
파일: temp.cs 프로젝트: saonam/x-drone
        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");

                    xmlwriter.WriteElementString("url", new Uri(software.url).LocalPath.TrimStart('/', '\\'));
                    xmlwriter.WriteElementString("url2560", new Uri(software.url2560).LocalPath.TrimStart('/', '\\'));
                    xmlwriter.WriteElementString("url2560-2", new Uri(software.url2560_2).LocalPath.TrimStart('/', '\\'));
                    xmlwriter.WriteElementString("urlpx4", new Uri(software.urlpx4v1).LocalPath.TrimStart('/', '\\'));
                    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();
            }
        }
예제 #3
0
        bool getFirmware(uploader.Uploader.Board device, bool custom = false)
        {
            // was https://raw.github.com/tridge/SiK/master/Firmware/dst/radio.hm_trp.hex
            // was http://www.samba.org/tridge/UAV/3DR/radio.hm_trp.hex
            // now http://firmware.diydrones.com/SiK/stable/

            if (custom)
            {
                return(getFirmwareLocal(device));
            }

            if (device == uploader.Uploader.Board.DEVICE_ID_HM_TRP)
            {
                if (beta)
                {
                    return(Common.getFilefromNet("http://firmware.diydrones.com/SiK/beta/radio~hm_trp.ihx", firmwarefile));
                }
                else
                {
                    return(Common.getFilefromNet("http://firmware.diydrones.com/SiK/stable/radio~hm_trp.ihx", firmwarefile));
                }
            }
            else if (device == uploader.Uploader.Board.DEVICE_ID_RFD900)
            {
                if (beta)
                {
                    return(Common.getFilefromNet("http://firmware.diydrones.com/SiK/beta/radio~rfd900.ihx", firmwarefile));
                }
                else
                {
                    return(Common.getFilefromNet("http://firmware.diydrones.com/SiK/stable/radio~rfd900.ihx", firmwarefile));
                }
            }
            else if (device == uploader.Uploader.Board.DEVICE_ID_RFD900A)
            {
                int fixme;

                //  return Common.getFilefromNet("http://rfdesign.com.au/firmware/MPSik%20V2.3%20radio~rfd900a.ihx", firmwarefile);
                if (beta)
                {
                    return(Common.getFilefromNet("http://firmware.diydrones.com/SiK/beta/radio~rfd900a.ihx", firmwarefile));
                }
                else
                {
                    return(Common.getFilefromNet("http://firmware.diydrones.com/SiK/stable/radio~rfd900a.ihx", firmwarefile));
                }
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        private bool getFirmware(Uploader.Board device, bool custom = false)
        {
            if (custom)
            {
                return(getFirmwareLocal(device));
            }

            if (device == Uploader.Board.DEVICE_ID_HM_TRP)
            {
                if (beta)
                {
                    return(Common.getFilefromNet("http://firmware.ardupilot.org/SiK/beta/radio~hm_trp.ihx", firmwarefile));
                }
                return(Common.getFilefromNet("http://firmware.ardupilot.org/SiK/stable/radio~hm_trp.ihx",
                                             firmwarefile));
            }
            if (device == Uploader.Board.DEVICE_ID_RFD900)
            {
                if (beta)
                {
                    return(Common.getFilefromNet("http://firmware.ardupilot.org/SiK/beta/radio~rfd900.ihx", firmwarefile));
                }
                return(Common.getFilefromNet("http://firmware.ardupilot.org/SiK/stable/radio.rfd900.hex", firmwarefile));
            }
            if (device == Uploader.Board.DEVICE_ID_RFD900A)
            {
                if (beta)
                {
                    return(Common.getFilefromNet("http://firmware.ardupilot.org/SiK/beta/radio~rfd900a.ihx",
                                                 firmwarefile));
                }
                return(Common.getFilefromNet("http://firmware.ardupilot.org/SiK/stable/radio.rfd900a.hex", firmwarefile));
            }
            if (device == Uploader.Board.DEVICE_ID_RFD900U)
            {
                if (beta)
                {
                    return(Common.getFilefromNet("http://rfdesign.com.au/firmware/radio~rfd900u.ihx", firmwarefile));
                }
                return(Common.getFilefromNet("http://firmware.ardupilot.org/SiK/stable/radio~rfd900u.ihx", firmwarefile));
            }
            if (device == Uploader.Board.DEVICE_ID_RFD900P)
            {
                if (beta)
                {
                    return(Common.getFilefromNet("http://rfdesign.com.au/firmware/radio~rfd900p.ihx", firmwarefile));
                }
                return(Common.getFilefromNet("http://firmware.ardupilot.org/SiK/stable/radio~rfd900p.ihx", firmwarefile));
            }
            return(false);
        }
예제 #5
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");

                int a = 0;

                foreach (var software in list)
                {
                    a++;
                    Loading.ShowLoading(((a - 1) / (float)list.Count) * 100.0 + "% " + software.name, this);

                    //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.urlpx4v4pro != "")
                    {
                        xmlwriter.WriteElementString("urlpx4v4pro",
                                                     new Uri(software.urlpx4v4pro).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.urlpx4v4pro != "")
                    {
                        Common.getFilefromNet(software.urlpx4v4pro, basedir + new Uri(software.urlpx4v4pro).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();
            }

            Loading.Close();
        }
예제 #6
0
 private void myButton3_Click(object sender, EventArgs e)
 {
     Common.getFilefromNet("http://firm.ardupilot.org/", "./test.txt");
 }