示例#1
0
        private void GenerateChart()
        {
            if (csv == null)
            {
                return;
            }

            WaitingScreen.Visible = true;
            this.Refresh();

            list1.Clear();
            list2.Clear();

            IFilter Filter;

            string FilterType = FilterSelector.Text;

            switch (FilterType)
            {
            case "FIR Filter":
                Filter = new FIRFilter(new List <double>()
                {
                    0.25, 0.25, 0.25, 0.25
                });
                break;

            case "Alpha Beta Filter":
                Filter = new AlphaBetaFilter(0.2, 0.3);
                break;

            case "Smart Alpha Beta Filter":
                Filter = new SmartAlphaBetaFilter(0.003307643036326, 200);
                break;

            default:
                Filter = null;
                break;
            }

            int PreviousProgress = 0;
            int Progress         = 0;
            int i = 0;


            Integrator integrator = new Integrator();

            foreach (KeyValuePair <double, List <double> > entry in csv.Data)
            {
                InertialNavigationSystem.Sample sample = new InertialNavigationSystem.Sample(entry.Key, entry.Value[ColumnSelector.SelectedIndex]);

                if (Filter != null)
                {
                    sample = Filter.AddSample(sample);
                }

                list1.Add(sample.Time, sample.Value);

                integrator.AddSample(sample);
                if (DrawIntegral.Checked)
                {
                    list2.Add(sample.Time, integrator.Value);
                }

                i++;

                Progress = i * 100 / csv.Data.Count;

                if (PreviousProgress != Progress)
                {
                    ProgressIndicator.Value = Progress;
                    Application.DoEvents();
                }

                PreviousProgress = Progress;
            }

            Chart1.AxisChange();
            Chart1.Refresh();

            WaitingScreen.Visible = false;
        }