示例#1
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);
            }
        }
示例#2
0
        private void showImpulceCharacteristicButton_Click(object sender, EventArgs e)
        {
            try
            {
                int    n           = (int)impulceCharacteristicNNumericUpDown.Value;
                double threshold   = (double)impulceCharacteristicThresholdNumericUpDown.Value;
                var    windowType  = GetFourierTransformType();
                var    impCharType = (FirFilterType)Enum.Parse(typeof(FirFilterType), (string)impulseCharacteristicTypeComboBox.SelectedItem);

                double[] h = FiniteImpulseResponse.ImpulseCharacteristic(signal.Hz, n, threshold, impCharType, windowType);

                var form = new ShowSpectrumForm(h, " Импульсная характеристика", SpectrumType.NotSet, n);
                form.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#3
0
        private void showPhaseResponseButton_Click(object sender, EventArgs e)
        {
            Stopwatch watch = new Stopwatch();

            try
            {
                var    impCharType = (FirFilterType)Enum.Parse(typeof(FirFilterType), (string)impulseCharacteristicTypeComboBox.SelectedItem);
                int    n           = (int)impulceCharacteristicNNumericUpDown.Value;
                double threshold   = (double)impulceCharacteristicThresholdNumericUpDown.Value;

                watch.Start();
                double[] h         = FiniteImpulseResponse.ImpulseCharacteristic(signal.Hz, n, threshold, impCharType);
                double[] phaseSpec = FiniteImpulseResponse.PhaseResponse(h, signal.Hz);
                watch.Stop();

                var form = new ShowSpectrumForm(phaseSpec, "ФЧX", SpectrumType.Phase, signal.Hz, watch.ElapsedMilliseconds);
                form.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#4
0
        private void showFrequencyResponseDButton_Click(object sender, EventArgs e)
        {
            Stopwatch watch = new Stopwatch();

            try
            {
                int    n           = (int)impulceCharacteristicNNumericUpDown.Value;
                double threshold   = (double)impulceCharacteristicThresholdNumericUpDown.Value;
                var    windowType  = GetFourierTransformType();
                var    impCharType = (FirFilterType)Enum.Parse(typeof(FirFilterType), (string)impulseCharacteristicTypeComboBox.SelectedItem);

                watch.Start();
                double[] h        = FiniteImpulseResponse.ImpulseCharacteristic(signal.Hz, n, threshold, impCharType, windowType);
                double[] amplSpec = FiniteImpulseResponse.FrequencyResponse(h, signal.Hz);
                watch.Stop();

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