Esempio n. 1
0
        /// <summary>
        /// Отрисока зашумленного полигармонического сигнала
        /// </summary>
        private void DrawNoizeblePolyHarmonicSignal()
        {
            try
            {
                if (polyHarmonicPoints == null && polyHarmonicPoints.Length == 0 &&
                    noizePoints == null && noizePoints.Length == 0)
                {
                    return;
                }
                noizeblePolyHarmonicPoints = DigitalSignalsGenerator.GetNoizeblHarmonicSignal(polyHarmonicPoints, noizePoints);

                chartModlingResults.Series.Add("NoizebleHarmonic");
                chartModlingResults.Series["NoizebleHarmonic"].ChartType         = SeriesChartType.Line;
                chartModlingResults.Series["NoizebleHarmonic"].Color             = Color.Crimson;
                chartModlingResults.Series["NoizebleHarmonic"].IsVisibleInLegend = false;

                double x = 0, stp = ((double)polyHarmonicPoints.Length / (double)noizeblePolyHarmonicPoints.Length) / double.Parse(textBoxFrequency.Text);
                var    d = dT;
                foreach (var p in noizeblePolyHarmonicPoints)
                {
                    chartModlingResults.Series["NoizebleHarmonic"].Points.AddXY(x, p);
                    x += dT;
                    if (x > totalTime)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{ex.Message} [{ex.TargetSite.Name}]");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Отрисовка шума
        /// </summary>
        private void DrawNoizeSignal()
        {
            try
            {
                if (polyHarmonicPoints == null && polyHarmonicPoints.Length == 0)
                {
                    return;
                }
                double max = double.Parse(textBoxNoizeMax.Text);
                int    hz  = int.Parse(textBoxNoizeFrequency.Text);
                noizePoints = DigitalSignalsGenerator.GetNoize(max, hz, totalTime, totalSamplingFrequency);

                chartModlingResults.Series.Add("Noize");
                chartModlingResults.Series["Noize"].ChartType         = SeriesChartType.Line;
                chartModlingResults.Series["Noize"].Color             = Color.SteelBlue;
                chartModlingResults.Series["Noize"].IsVisibleInLegend = false;

                double x = 0;
                foreach (var p in noizePoints)
                {
                    chartModlingResults.Series["Noize"].Points.AddXY(x, p);
                    x += dT;
                    if (x > totalTime)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{ex.Message} [{ex.TargetSite.Name}]");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Добавить шум для квазистационарного сигнала
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonSetNoizeToQst_Click(object sender, EventArgs e)
        {
            try
            {
                if (qstSignalPoints == null || qstSignalPoints.Length == 0)
                {
                    MessageBox.Show("Сигнал не сгенерирован.", "Ошибка!");
                    return;
                }
                if (chartQstSignal.Series.IndexOf("QstNoize") == -1)
                {
                    chartQstSignal.Series.Add("QstNoize");
                    chartQstSignal.Series["QstNoize"].ChartType         = SeriesChartType.Line;
                    chartQstSignal.Series["QstNoize"].Color             = Color.Crimson;
                    chartQstSignal.Series["QstNoize"].IsVisibleInLegend = false;
                }
                if (chartQstSignal.Series.IndexOf("NoizebleQstSignal") == -1)
                {
                    chartQstSignal.Series.Add("NoizebleQstSignal");
                    chartQstSignal.Series["NoizebleQstSignal"].ChartType         = SeriesChartType.Line;
                    chartQstSignal.Series["NoizebleQstSignal"].Color             = Color.Plum;
                    chartQstSignal.Series["NoizebleQstSignal"].IsVisibleInLegend = false;
                }

                signalsGenerator = new DigitalSignalsGenerator();
                int time = (int)(qstSignal.Select(h => h.Time).Sum());

                qstNoizePoints          = DigitalSignalsGenerator.GetNoize(double.Parse(textBoxQstNoizeMax.Text) + 1, int.Parse(textBoxQstNoizeFr.Text), time, int.Parse(textBoxQstDiscFr.Text));
                qstNoizebleSignalPoints = DigitalSignalsGenerator.GetNoizeblHarmonicSignal(qstSignalPoints, qstNoizePoints);


                double x = 0, stp = (double)qstSignalPoints.Length / (double)qstNoizePoints.Length;

                foreach (var p in qstNoizebleSignalPoints)
                {
                    chartQstSignal.Series["NoizebleQstSignal"].Points.AddXY(x, p);
                    x += stp;
                    if (x > qstSignalPoints.Length)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{ex.Message} [{ex.TargetSite.Name}]");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Отрисовка сегмента
        /// </summary>
        private void DrawSegment()
        {
            segmentPoints = DigitalSignalsGenerator.GetHarmonicSignal(segment.Harmonics, int.Parse(textBoxQstDiscFr.Text), int.Parse(textBoxQstTotalTime.Text));

            if (chartQstSegment.Series != null)
            {
                chartQstSegment.Series.Clear();
            }

            chartQstSegment.Series.Add("PolyHarmonic");
            chartQstSegment.Series["PolyHarmonic"].ChartType         = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
            chartQstSegment.Series["PolyHarmonic"].Color             = Color.LimeGreen;
            chartQstSegment.Series["PolyHarmonic"].BorderWidth       = 2;
            chartQstSegment.Series["PolyHarmonic"].IsVisibleInLegend = false;

            chartQstSegment.Series["PolyHarmonic"].Points.DataBindY(segmentPoints);
        }
Esempio n. 5
0
        /// <summary>
        /// Выполнение сегментации исходного сигнала
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonGetQstSegments_Click(object sender, EventArgs e)
        {
            if (qstNoizebleSignalPoints == null || qstNoizebleSignalPoints.Count() == 0)
            {
                MessageBox.Show("Выполните зашумление исходного сигнала", "Ошибка!");
                return;
            }

            Meta.Numerics.Statistics.BivariateSample           bevar  = new Meta.Numerics.Statistics.BivariateSample();
            Dictionary <string, SignalUtilities.SegmentBounds> bounds = new Dictionary <string, SignalUtilities.SegmentBounds>();
            int discfrecuency = int.Parse(textBoxQstDiscFr.Text);

            foreach (var segment in qstSignal)
            {
                var segmentPoins  = DigitalSignalsGenerator.GetHarmonicSignal(segment.Harmonics, discfrecuency, segment.Time);
                var segmentBounds = SignalUtilities.GetSegment(qstNoizebleSignalPoints, segmentPoins);
                bounds.Add(segment.Name, segmentBounds);
            }

            DrawSegmentsAttributes(bounds, chartQstSignal);
        }
Esempio n. 6
0
        /// <summary>
        /// Отрисовка квазистационарного сигнала
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonGenQstSignal_Click(object sender, EventArgs e)
        {
            try
            {
                qstSignalPoints = DigitalSignalsGenerator.GetQstSignal(qstSignal, int.Parse(textBoxQstDiscFr.Text));

                if (chartQstSignal.Series.Count != 0)
                {
                    chartQstSignal.Series.Clear();
                }

                chartQstSignal.Series.Add("QstSignal");
                chartQstSignal.Series["QstSignal"].ChartType         = SeriesChartType.Line;
                chartQstSignal.Series["QstSignal"].Color             = Color.SteelBlue;
                chartQstSignal.Series["QstSignal"].IsVisibleInLegend = false;

                chartQstSignal.Series["QstSignal"].Points.DataBindY(qstSignalPoints);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{ex.Message} [{ex.TargetSite.Name}]");
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Отрисовка полигармонического сигнала
        /// </summary>
        private void DrawPolyHarmonicSignal()
        {
            try
            {
                polyHarmonicPoints = DigitalSignalsGenerator.GetHarmonicSignal(harmonics, totalSamplingFrequency, totalTime);

                chartModlingResults.Series.Add("PolyHarmonic");
                chartModlingResults.Series["PolyHarmonic"].ChartType         = SeriesChartType.Spline;
                chartModlingResults.Series["PolyHarmonic"].Color             = Color.LimeGreen;
                chartModlingResults.Series["PolyHarmonic"].BorderWidth       = 2;
                chartModlingResults.Series["PolyHarmonic"].IsVisibleInLegend = false;

                double x = 0;
                foreach (var p in polyHarmonicPoints)
                {
                    chartModlingResults.Series["PolyHarmonic"].Points.AddXY(x, p);
                    x += dT;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{ex.Message} [{ex.TargetSite.Name}]");
            }
        }
Esempio n. 8
0
 public MainWindow()
 {
     InitializeComponent();
     signalsGenerator = new DigitalSignalsGenerator();
 }