private void btnBuildGraphics_Click(object sender, EventArgs e) { if (!_seqGen.IsValid) { return; } var param = new List <IEnumerable <double> >(6); long ms = 0; Stopwatch sw = new Stopwatch(); switch (cmbCorrelationMethod.SelectedIndex) { case 0: { var sp = new SearchPeak( _seqGen, 1, 1, double.Parse(txtTimeConstant.Text.Replace(',', '.'), new CultureInfo("en-US")), double.Parse(txtDnl.Text.Replace(',', '.'), new CultureInfo("en-US")), cmbPowNl.SelectedIndex + 2, true ); sw.Start(); sp.Calculate(); sw.Stop(); ms = sw.ElapsedMilliseconds; param.Add(sp.Mls.Select(Convert.ToDouble)); param.Add(new List <double>()); param.Add(new List <double>()); param.Add(new List <double>()); param.Add(sp.ResponseNL.Select(Convert.ToDouble)); } break; case 1: { var sp = new SearchPeak( _seqGen, DiscreteInMinPulse, (int)numCorrelationPeriods.Value, double.Parse(txtTimeConstant.Text.Replace(',', '.'), new CultureInfo("en-US")), double.Parse(txtDnl.Text.Replace(',', '.'), new CultureInfo("en-US")), cmbPowNl.SelectedIndex + 2 ); sw.Start(); sp.Calculate(); sw.Stop(); ms = sw.ElapsedMilliseconds; param.Add(sp.Mls.Select(Convert.ToDouble)); param.Add(sp.ResponseE.Select(Convert.ToDouble)); param.Add(sp.ResponseNL.Select(Convert.ToDouble)); param.Add(sp.CorrelationE.Select(Convert.ToDouble)); param.Add(sp.CorrelationNL.Select(Convert.ToDouble)); param.Add(param[4].Take(sp.OnePer).Zip(param[3], (x, y) => x - y)); param.Add(param[3].Take(sp.OnePer)); param.Add(param[4].Take(sp.OnePer)); } break; case 2: case 3: case 4: { var sp = new PrecisionSearchPeak( _seqGen, DiscreteInMinPulse, (int)numCorrelationPeriods.Value, double.Parse(txtTimeConstant.Text.Replace(',', '.'), new CultureInfo("en-US")), double.Parse(txtDnl.Text.Replace(',', '.'), new CultureInfo("en-US")), cmbPowNl.SelectedIndex + 2 ); var ct = sp.N * 1L * sp.OnePer; if (LongTimeMessageNo(ct)) { return; } sw.Start(); sp.Calculate(); sw.Stop(); ms = sw.ElapsedMilliseconds; param.Add(sp.Mls.Select(Convert.ToDouble)); param.Add(sp.ResponseE.Select(Convert.ToDouble)); param.Add(sp.ResponseNL.Select(Convert.ToDouble)); param.Add(sp.CorrelationE.Select(Convert.ToDouble)); param.Add(sp.CorrelationNL.Select(Convert.ToDouble)); param.Add(sp.SubCorNlCorE().Skip(sp.OnePer).Take(sp.OnePer).Select(Convert.ToDouble)); param.Add(param[3].Skip(sp.OnePer).Take(sp.OnePer)); param.Add(param[4].Skip(sp.OnePer).Take(sp.OnePer)); if (cmbCorrelationMethod.SelectedIndex > 2) { SearchPeak spf; param[1] = new List <double>(); param[2] = new List <double>(); param[3] = new List <double>(); param[5] = new List <double>(); param[6] = new List <double>(); switch (cmbCorrelationMethod.SelectedIndex) { case 3: { spf = new SearchPeak( _seqGen, DiscreteInMinPulse, (int)numCorrelationPeriods.Value, double.Parse(txtTimeConstant.Text.Replace(',', '.'), new CultureInfo("en-US")), double.Parse(txtDnl.Text.Replace(',', '.'), new CultureInfo("en-US")), cmbPowNl.SelectedIndex + 2 ); sw.Start(); spf.Calculate(); sw.Stop(); ms += sw.ElapsedMilliseconds; param.Add(spf.CorrelationNL.Select(Convert.ToDouble)); param.Add(param[4].Skip(sp.OnePer).Zip(param[8], (x, y) => y - x)); } break; case 4: { spf = new SearchPeak( _seqGen, 1, 1, double.Parse(txtTimeConstant.Text.Replace(',', '.'), new CultureInfo("en-US")) / DiscreteInMinPulse, double.Parse(txtDnl.Text.Replace(',', '.'), new CultureInfo("en-US")), cmbPowNl.SelectedIndex + 2, true ); sw.Start(); spf.Calculate(); sw.Stop(); ms += sw.ElapsedMilliseconds; param.Add(spf.ResponseNL.Select(Convert.ToDouble)); var d = DiscreteInMinPulse; var a = param[4].Skip(sp.OnePer).Take(sp.OnePer).ToList(); var b = param[8].ToList(); for (int i = 0; i < a.Count; i++) { a[i] = b[i / d] - a[i]; } param.Add(a); } break; } } } break; } lblTime.Text = ms.ToString(); ViewForm vf = new ViewForm(param); vf.Show(); vf.Activate(); }
private void btnFindAllCorPeak_Click(object sender, EventArgs e) { if (!_allFbList.Any()) { return; } _allCorPeakList = new List <int>(_allFbList.Count); var sg = new SeqGen(_seqGen); if (numCorStart.Value > numCorEnd.Value) { var t = numCorStart.Value; numCorStart.Value = numCorEnd.Value; numCorEnd.Value = t; } int start = (int)numCorStart.Value - 1; int end = (int)numCorEnd.Value - 1; Stopwatch sw = new Stopwatch(); if (cmbCorrelationMethod.SelectedIndex != 2) { if (MessageBox.Show("Данная операция отключена", "", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Information) != DialogResult.Ignore) { return; } if (cmbCorrelationMethod.SelectedIndex == 0) { var sp = new SearchPeak( sg, 1, 1, double.Parse(txtTimeConstant.Text.Replace(',', '.'), new CultureInfo("en-US")), double.Parse(txtDnl.Text.Replace(',', '.'), new CultureInfo("en-US")), cmbPowNl.SelectedIndex + 2, true ); sw.Start(); foreach (var fb in _allFbList) { sg.Feedback = fb; sp.Calculate(); var i = 0; var oldMv = double.MinValue; var res = 0; var fSt = (start + DiscreteInMinPulse - 1) / DiscreteInMinPulse + 1; var fE = end / DiscreteInMinPulse; foreach (var val in sp.ResponseNL) { if (fSt <= i && i <= fE && val > oldMv) //Добавить диапазон { oldMv = val; res = i; } i++; } res *= DiscreteInMinPulse; res -= DiscreteInMinPulse - 1; res = Math.Max(res, start); res = Math.Min(res, end); _allCorPeakList.Add(res); } } else { return; } } else { var ct = sg.Period * 1L * DiscreteInMinPulse; ct *= ct * _allFbList.Count * (int)numCorrelationPeriods.Value; if (LongTimeMessageNo(ct)) { return; } var sp = new PrecisionSearchPeak( sg, DiscreteInMinPulse, (int)numCorrelationPeriods.Value, double.Parse(txtTimeConstant.Text.Replace(',', '.'), new CultureInfo("en-US")), double.Parse(txtDnl.Text.Replace(',', '.'), new CultureInfo("en-US")), cmbPowNl.SelectedIndex + 2 ); sw.Start(); foreach (var fb in _allFbList) { sg.Feedback = fb; sp.Calculate(); var i = 0; var oldMv = double.MinValue; var res = 0; foreach (var val in sp.CorrelationNL.Skip(sp.OnePer).Take(sp.OnePer)) { if (start <= i && i <= end && (double)val > oldMv) //Добавить диапазон { oldMv = (double)val; res = i; } i++; } _allCorPeakList.Add(res); } } sw.Stop(); lblTime.Text = sw.ElapsedMilliseconds.ToString(); UpdateFeedbacksList(); }