コード例 #1
0
        public void CreateFilter()
        {
            Func <int, double, List <double> >        filterFunction = null;
            Func <List <double>, int, List <double> > windowFunction = null;

            switch (SelectedFilter.Substring(1, 2))
            {
            case "F0":
                filterFunction = Filter.LowPassFilter;
                break;

            case "F1":
                filterFunction = Filter.MidPassFilter;
                break;

            case "F2":
                filterFunction = Filter.HighPassFilter;
                break;
            }
            switch (SelectedWindow.Substring(1, 2))
            {
            case "O0":
                windowFunction = Filter.RectangularWindow;
                break;

            case "O1":
                windowFunction = Filter.HammingWindow;
                break;

            case "O2":
                windowFunction = Filter.HanningWindow;
                break;

            case "O3":
                windowFunction = Filter.BlackmanWindow;
                break;
            }
            SampledSignal signal = new SampledSignal();

            signal.PointsY = Filter.CreateFilterSignal(M, K, filterFunction, windowFunction);
            signal.Name    = FilterName + " - F";
            SignalCreator.AddSignal(signal);
        }
コード例 #2
0
        public void Compute()
        {
            int    distancePoints = 0;
            double distance       = 0;
            bool   radar          = false;

            SelectedSignal1Tab.TabContent.Data.FromSamples = true;
            SelectedSignal2Tab.TabContent.Data.FromSamples = true;
            if (SelectedSignal1Tab.TabContent.Data.HasData() && SelectedSignal2Tab.TabContent.Data.HasData())
            {
                DataHandler   data    = new DataHandler();
                List <double> pointsY = new List <double>();

                switch (SelectedOperation.Substring(1, 2))
                {
                case "O1":
                    if (!SelectedSignal2Tab.TabContent.Data.IsValidConvulution(SelectedSignal1Tab.TabContent.Data))
                    {
                        MessageBox.Show("Given signals are not valid", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    pointsY = SignalFiltering.CalculateConvolution(SelectedSignal1Tab.TabContent.Data.Samples,
                                                                   SelectedSignal2Tab.TabContent.Data.Samples);
                    break;

                case "O2":
                    int windowType = int.Parse(SelectedWindow.Substring(0, 1));
                    int filterType = int.Parse(SelectedFilter.Substring(0, 1));
                    pointsY = SignalFiltering.Filter(SelectedSignal1Tab.TabContent.Data.Samples, M, K, windowType, filterType);
                    break;

                case "O3":
                    if (!SelectedSignal2Tab.TabContent.Data.IsValidConvulution(SelectedSignal1Tab.TabContent.Data))
                    {
                        MessageBox.Show("Given signals are not valid", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    pointsY = SignalFiltering.CalculateCorrelation(SelectedSignal1Tab.TabContent.Data.Samples,
                                                                   SelectedSignal2Tab.TabContent.Data.Samples);
                    break;

                case "O4":
                    pointsY = SignalFiltering.CalculateDistance(SelectedSignal1Tab.TabContent.Data.Samples,
                                                                SignalFiltering.DelaySignal(SelectedSignal1Tab.TabContent.Data.Samples, t * SelectedSignal1Tab.TabContent.Data.Frequency), out distancePoints);
                    distance = distancePoints * v / SelectedSignal1Tab.TabContent.Data.Frequency;
                    radar    = true;
                    break;
                }

                data.StartTime   = SelectedSignal1Tab.TabContent.Data.StartTime;
                data.Frequency   = SelectedSignal1Tab.TabContent.Data.Frequency;
                data.Samples     = pointsY;
                data.FromSamples = true;
                SelectedResultTab.TabContent.IsScattered = true;
                SelectedResultTab.TabContent.LoadData(data);
                SelectedResultTab.TabContent.AddOriginal = false;
                SelectedResultTab.TabContent.AddSamples  = false;
                SelectedResultTab.TabContent.DrawCharts();
                SelectedResultTab.TabContent.CalculateSignalInfo(isDiscrete: true, fromSamples: true);
                if (radar)
                {
                    MessageBox.Show("Odległość: " + distance.ToString() + " m", "Radar", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
        }