Пример #1
0
        public void AddFilter(WindowedSyncFilter newFilter)
        {
            WorkBook workBook = manager.ActiveWorkBook();

            workBook.WindowedSyncFilters.Add(newFilter.Name, newFilter);
            LoadFilterData(); // Property changed event handlers will be connected in this function
        }
Пример #2
0
        public void PlotData()
        {
            List <double> summedFilterData = manager.ActiveWorkBook().CombinedFilterImpulseResponse();

            if (null == summedFilterData)
            {
                return;
            }

            Signal workbookSourceSignal = manager.ActiveWorkBook().SumOfSources();

            if (workbookSourceSignal == null)
            {
                return;
            }

            SignalPlotPoints = new List <DataPoint>(workbookSourceSignal.Samples.Count);

            for (int idx = 0; idx < workbookSourceSignal.Samples.Count; idx++)
            {
                SignalPlotPoints.Add(new DataPoint(idx, workbookSourceSignal.Samples[idx]));
            }

            ConvolutionPlotPoints = new List <DataPoint>(summedFilterData.Count);

            for (int idx = 0; idx < summedFilterData.Count; idx++)
            {
                ConvolutionPlotPoints.Add(new DataPoint(idx, summedFilterData[idx]));
            }

            List <double> convolutionResult = convolver.Convolve(summedFilterData, workbookSourceSignal.Samples, ConvolutionType.INPUTSIDE);

            ResultPlotPoints = new List <DataPoint>(convolutionResult.Count);
            for (int idx = 0; idx < convolutionResult.Count; idx++)
            {
                ResultPlotPoints.Add(new DataPoint(idx, convolutionResult[idx]));
            }

            //IDFT cmplxFFT = new ComplexFastFourierTransform();
            IDFT cmplxFFT = new DSPGuideComplexDiscreteFourierTransform();

            FrequencyDomain frequencyDomain = cmplxFFT.Transform(convolutionResult, workbookSourceSignal.SamplingHZ);

            ResultFrequencyHistogram = new FrequencyHistogramViewModel(frequencyDomain);

            NotifyPropertyChanged(nameof(SignalPlotPoints));
            NotifyPropertyChanged(nameof(ConvolutionPlotPoints));
            NotifyPropertyChanged(nameof(ResultPlotPoints));
            NotifyPropertyChanged(nameof(ResultFrequencyHistogram));
        }
Пример #3
0
        private void ExportButton_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = $"{Properties.Resources.FILTER_IMPORT_EXPORT_FILE_EXTENSION} (*{Properties.Resources.FILTER_IMPORT_EXPORT_FILE_EXTENSION})|*{Properties.Resources.FILTER_IMPORT_EXPORT_FILE_EXTENSION}|{Properties.Resources.ALL_FILES} (*.*)|*.*";
            if (saveFileDialog.ShowDialog() == true)
            {
                try
                {
                    using (StreamWriter fileWriter = File.CreateText(saveFileDialog.FileName))
                    {
                        fileWriter.WriteLine(Properties.Resources.FILTER_CSV_HEADER);
                        List <double> summedFilterData              = manager.ActiveWorkBook().CombinedFilterImpulseResponse(true);
                        ComplexFastFourierTransform cmplxFFT        = new ComplexFastFourierTransform();
                        FrequencyDomain             frequencyDomain = cmplxFFT.Transform(summedFilterData, manager.ActiveWorkBook().WindowedSyncFilters.Values.First().FilterLength);

                        var magPhaseList = ComplexFastFourierTransform.ToMagnitudePhaseList(frequencyDomain);

                        foreach (Tuple <double, double> coefficientMagPhase in magPhaseList)
                        {
                            fileWriter.WriteLine($"{coefficientMagPhase.Item1},{coefficientMagPhase.Item2}");
                        }
                    }
                } catch (Exception ex)
                {
                    Log.Warning(ex, ex.Message);
                    // TODO warn user
                }
            }
        }
Пример #4
0
 public void AddSignal(Signal signal)
 {
     workBookManager.ActiveWorkBook().Signals.Add(signal.Name, signal);
     LoadSignalsFromActiveWorkBook();
 }