Пример #1
0
        private void bPFilterButton_Click(object sender, EventArgs e)
        {
            try
            {
                int threshold0 = (int)bPFilterNnumericUpDown0.Value;
                int threshold1 = (int)bPFilterNumericUpDown1.Value;

                if (bPFilterComboBox.Text == "Гц")
                {
                    threshold0 = (int)(threshold0 / (signal.Hz / signal.Count));
                    threshold1 = (int)(threshold1 / (signal.Hz / signal.Count));
                }

                FilterType type         = GetFourierTransformType();
                double[]   preparedData = FiltersUtils.PrepareDataToFilter(signal.Data, type);

                var filteredData = FourierTransform.BPFilter(preparedData, threshold0, threshold1, type);

                if (saveToFileCheckBox.Checked)
                {
                    WriteDataToFile(filteredData);
                }

                var form = new ShowChartForm(filteredData, filePath + " полосовой фильтр", signal.Type, signal.Hz);
                form.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        /// <summary>
        /// Обработчик нажатия кнопки "Амплитудный спектр (БПФ)"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void showAmplitudeSpectrumButton_Click(object sender, EventArgs e)
        {
            Stopwatch watch = new Stopwatch();

            try
            {
                FilterType type;
                double[]   preparedData;
                string     label;

                var button = (Button)sender;
                switch (button.Name)
                {
                case "showAmplitudeSpectrumBFTButton":
                    type  = FilterType.FourierBase;
                    label = "Амплитудный спектр ПФ";
                    break;

                case "showAmplitudeSpectrumFFTButton":
                    type  = FilterType.FourierFast;
                    label = "Амплитудный спектр БПФ";
                    break;

                case "showAmplitudeSpectrumFTSButton":
                    type  = FilterType.FourierSpeed;
                    label = "Амплитудный спектр ПФУ";
                    break;

                default:
                    throw new ArgumentException();
                }

                preparedData = FiltersUtils.PrepareDataToFilter(signal.Data, type);

                watch.Start();
                double[] amplSpec = FourierTransform.AmplitudeSpectrum(preparedData, type);
                watch.Stop();

                var form0 = new ShowSpectrumForm(amplSpec, label, SpectrumType.Amplitude, signal.Hz, watch.ElapsedMilliseconds);
                form0.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }