public DWT(int n, int detailLevel, AbstractIndicator indicator = null) : base(n) { priceData = new MovingQueue <double>(n); st = new SignalTransform(); this.detailLevel = detailLevel; this.indicator = indicator; }
private void Transform(object param) { SignalTransform transform = null; bool absoluteValue = false; TransformWindow dialog = new TransformWindow(); if (dialog.ShowDialog() == true) { transform = dialog.SelectedTransform; absoluteValue = dialog.AbsoluteValue; } if (transform == null) { return; } ISignal signal; switch (param.ToString()) { case "1": signal = FirstChart.SignalRepresentation.Signal; break; case "2": signal = SecondChart.SignalRepresentation.Signal; break; case "3": signal = combinedSignal.Signal; break; default: throw new ArgumentException(); } DateTime start = DateTime.Now; SignalImplementation transformedSignal = transform.TransformSignal(signal); if (absoluteValue) { transformedSignal = SignalOperations.GetAbsoluteSignal(transformedSignal); } TimeSpan elapsedTime = DateTime.Now - start; MessageBox.Show("Czas wykonania algorytmu: " + elapsedTime.Minutes + "m " + elapsedTime.Seconds + "s " + elapsedTime.Milliseconds + "ms"); transformedSignal.StartingMoment = transformedSignal.Points[0].Item1; transformedSignal.EndingMoment = transformedSignal.Points[transformedSignal.Points.Count - 1].Item1; transformedSignal.CalculateTraits(); combinedSignal.Signal = transformedSignal; combinedTextProperties.AverageValueText = combinedSignal.Signal.AverageValue.ToString("N3"); combinedTextProperties.AbsouluteAverageValueText = combinedSignal.Signal.AbsouluteAverageValue.ToString("N3"); combinedTextProperties.AveragePowerText = combinedSignal.Signal.AveragePower.ToString("N3"); combinedTextProperties.VarianceText = combinedSignal.Signal.Variance.ToString("N3"); combinedTextProperties.EffectiveValueText = combinedSignal.Signal.EffectiveValue.ToString("N3"); OnPropertyChanged("CombinedTextProperties"); realCombinedSeries = new ScatterSeries(); imaginaryCombinedSeries = new ScatterSeries(); foreach (Tuple <double, Complex> tuple in transformedSignal.Points) { realCombinedSeries.Points.Add(new ScatterPoint(tuple.Item1, tuple.Item2.Real)); imaginaryCombinedSeries.Points.Add(new ScatterPoint(tuple.Item1, tuple.Item2.Imaginary)); } ClearPlot(); realCombinedSeries.MarkerType = MarkerType.Circle; imaginaryCombinedSeries.MarkerType = MarkerType.Circle; realCombinedSeries.MarkerSize = 2; imaginaryCombinedSeries.MarkerSize = 2; realCombinedSeries.MarkerFill = OxyColors.Green; imaginaryCombinedSeries.MarkerFill = OxyColors.Green; realPlotModel.Series.Add(realCombinedSeries); imaginaryPlotModel.Series.Add(imaginaryCombinedSeries); realPlotModel.InvalidatePlot(true); imaginaryPlotModel.InvalidatePlot(true); }