void DrawG2Osc(int OscPage = 0) { if (!G2Set) { var p = Parent.Parent.Parent as Form1; p.SetLastError("Настройки ГНЧ не заданы"); return; } var signal = new MultiToneSignal(harmonics, ProceedInput(KEdit.Text)); OG2 = new Oscilloscope("ГНЧ", signal, OscPage); OG2.DrawOsc(); OG2.DrawSpec(); OG2.DrawPhaseSpec(); OG2.Show(); }
private void DrawPreview() { //Stopwatch stopwatch1 = new Stopwatch(); //Stopwatch stopwatch2 = new Stopwatch(); //stopwatch1.Start(); List <Harmonic> temp = new List <Harmonic>(); for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells[1].Value != null && (bool)dataGridView1.Rows[i].Cells[1].Value == true) { double amp = ProceedInput(dataGridView1.Rows[i].Cells[2].Value); double freq = ProceedInput(dataGridView1.Rows[i].Cells[3].Value); double phase = ProceedInput(dataGridView1.Rows[i].Cells[4].Value); temp.Add(new Harmonic( Form1.unitsType == Form1.UnitsType.Radian ? freq : freq * 2 * Math.PI, Form1.unitsType == Form1.UnitsType.Radian ? phase : phase * (Math.PI / 180), amp)); } } if (temp.Where(t => t.Freq != 0).Count() == 0) { return; } var painter = new MultiToneSignal(temp, 1); PreviewChart.Series.Clear(); PreviewChart.Series.Add($"Ser{PreviewChart.Series.Count}"); PreviewChart.Series[PreviewChart.Series.Count - 1].ChartType = SeriesChartType.Spline; PreviewChart.Series[PreviewChart.Series.Count - 1].BorderWidth = 1; PreviewChart.Series[PreviewChart.Series.Count - 1].Color = Color.Blue; var Points = painter.DrawOsc(); //stopwatch1.Stop(); //stopwatch2.Start(); { int index = 0; for (int i = 0; i < Points.X.Count; i++) { if (Points.X[i] != 0 && Points.Y[i] != 0) { index = i; break; } } int Xunits = Points.X[index].Reduce().Order; //var Yunits = ReduceUnits(Points.Y[index]).Y; for (int i = 0; i < Points.X.Count; i++) { Points.X[i] = Points.X[i].Reorder(-Xunits).Trim(); //Points.Y[i] *= Math.Pow(1000, Yunits / 3); } } for (int i = 0; i < Points.X.Count; i++) { PreviewChart.Series[PreviewChart.Series.Count - 1].Points.AddXY(Points.X[i], Points.Y[i]); } //stopwatch2.Stop(); //Text =$"{stopwatch1.ElapsedMilliseconds} {stopwatch2.ElapsedMilliseconds}"; }