Ejemplo n.º 1
0
        private void pdr_DoWork(IProgressReporterDialogue sender)
        {
            //if ((int)REL_Type == 99)
            {
                var fw = new Firmware();
                fw.Progress -= fw_Progress1;
                fw.Progress += fw_ProgressPDR;
                softwares    = fw.getFWList(firmwareurl, REL_Type);

                foreach (var soft in softwares)
                {
                    if (sender.doWorkArgs.CancelRequested)
                    {
                        sender.doWorkArgs.CancelAcknowledged = true;
                        return;
                    }

                    updateDisplayNameInvoke(soft);
                }

                return;
            }

            try
            {
                APFirmware.GetList();

                var official = APFirmware.GetRelease(REL_Type);

                var before = softwares.ToJSON();

                softwares = ConvertToOld(official);

                var after = softwares.ToJSON();
            }
            catch { }

            foreach (var soft in softwares)
            {
                if (sender.doWorkArgs.CancelRequested)
                {
                    sender.doWorkArgs.CancelAcknowledged = true;
                    return;
                }
                updateDisplayNameInvoke(soft);
            }
        }
Ejemplo n.º 2
0
        public Firmware()
        {
            InitializeComponent();

            quad.CommandParameter           = APFirmware.MAV_TYPE.Copter;
            rover.CommandParameter          = APFirmware.MAV_TYPE.GROUND_ROVER;
            plane.CommandParameter          = APFirmware.MAV_TYPE.FIXED_WING;
            sub.CommandParameter            = APFirmware.MAV_TYPE.SUBMARINE;
            heli.CommandParameter           = APFirmware.MAV_TYPE.HELICOPTER;
            antennatracker.CommandParameter = APFirmware.MAV_TYPE.ANTENNA_TRACKER;

            quad.ImageSource           = ImageSource.FromStream(() => Xamarin.Properties.Resources.FW_icons_2013_logos_04.ToMemoryStream());
            rover.ImageSource          = ImageSource.FromStream(() => Xamarin.Properties.Resources.rover_11.ToMemoryStream());
            plane.ImageSource          = ImageSource.FromStream(() => Xamarin.Properties.Resources.APM_airframes_001.ToMemoryStream());
            sub.ImageSource            = ImageSource.FromStream(() => Xamarin.Properties.Resources.sub.ToMemoryStream());
            heli.ImageSource           = ImageSource.FromStream(() => Xamarin.Properties.Resources.APM_airframes_08.ToMemoryStream());
            antennatracker.ImageSource = ImageSource.FromStream(() => Xamarin.Properties.Resources.Antenna_Tracker_01.ToMemoryStream());

            Task.Run(() =>
            {
                APFirmware.GetList();

                var options = APFirmware.GetRelease(APFirmware.RELEASE_TYPES.OFFICIAL);

                // get max version for each mavtype
                options = options.GroupBy(b => b.MavType).Select(a =>
                                                                 a.Where(b => a.Key == b.MavType && b.MavFirmwareVersion == a.Max(c => c.MavFirmwareVersion))
                                                                 .FirstOrDefault()).ToList();

                UpdateIconName(antennatracker,
                               options.First(a => a.MavType == APFirmware.MAV_TYPE.ANTENNA_TRACKER.ToString()));
                UpdateIconName(heli,
                               options.First(a => a.MavType == APFirmware.MAV_TYPE.HELICOPTER.ToString()));
                UpdateIconName(sub,
                               options.First(a => a.MavType == APFirmware.MAV_TYPE.SUBMARINE.ToString()));
                UpdateIconName(rover,
                               options.First(a => a.MavType == APFirmware.MAV_TYPE.GROUND_ROVER.ToString()));
                UpdateIconName(quad,
                               options.First(a => a.MavType == APFirmware.MAV_TYPE.Copter.ToString()));
                UpdateIconName(plane,
                               options.First(a => a.MavType == APFirmware.MAV_TYPE.FIXED_WING.ToString()));

                SetLoading(false);
            });
        }
        public void Activate()
        {
            MainV2.instance.DeviceChanged -= Instance_DeviceChanged;
            MainV2.instance.DeviceChanged += Instance_DeviceChanged;

            this.Enabled = false;

            flashdone = false;

            Task.Run(() =>
            {
                APFirmware.GetList("https://firmware.oborne.me/manifest.json.gz");

                var options = APFirmware.GetRelease(REL_Type);

                // get max version for each mavtype
                options = options.GroupBy(b => b.MavType).Select(a =>
                                                                 a.Where(b => a.Key == b.MavType && b.MavFirmwareVersion == a.Max(c => c.MavFirmwareVersion))
                                                                 .FirstOrDefault()).ToList();

                UpdateIconName(pictureAntennaTracker,
                               options.First(a => a.MavType == APFirmware.MAV_TYPE.ANTENNA_TRACKER.ToString()));
                UpdateIconName(pictureBoxHeli,
                               options.First(a => a.MavType == APFirmware.MAV_TYPE.HELICOPTER.ToString()));
                UpdateIconName(pictureBoxSub,
                               options.First(a => a.MavType == APFirmware.MAV_TYPE.SUBMARINE.ToString()));
                UpdateIconName(pictureBoxRover,
                               options.First(a => a.MavType == APFirmware.MAV_TYPE.GROUND_ROVER.ToString()));
                UpdateIconName(pictureBoxOctaQuad,
                               options.First(a => a.MavType == APFirmware.MAV_TYPE.Copter.ToString()));
                UpdateIconName(pictureBoxOcta, options.First(a => a.MavType == APFirmware.MAV_TYPE.Copter.ToString()));
                UpdateIconName(pictureBoxY6, options.First(a => a.MavType == APFirmware.MAV_TYPE.Copter.ToString()));
                UpdateIconName(pictureBoxTri, options.First(a => a.MavType == APFirmware.MAV_TYPE.Copter.ToString()));
                UpdateIconName(pictureBoxHexa, options.First(a => a.MavType == APFirmware.MAV_TYPE.Copter.ToString()));
                UpdateIconName(pictureBoxQuad, options.First(a => a.MavType == APFirmware.MAV_TYPE.Copter.ToString()));
                UpdateIconName(pictureBoxPlane,
                               options.First(a => a.MavType == APFirmware.MAV_TYPE.FIXED_WING.ToString()));
            });
        }