Esempio n. 1
0
        public ChartController()
        {
            FirstChart = new ChartRepresentation
            {
                SelectedIndex        = -1,
                SignalRepresentation = new SignalRepresentation(),
                SignalProperties     = new SignalTextProperties(),
                PlotColor            = OxyColors.Blue,
                RealSeries           = new ScatterSeries(),
                ImaginarySeries      = new ScatterSeries()
            };
            SecondChart = new ChartRepresentation
            {
                SelectedIndex        = -1,
                SignalRepresentation = new SignalRepresentation(),
                SignalProperties     = new SignalTextProperties(),
                PlotColor            = OxyColors.Red,
                RealSeries           = new ScatterSeries(),
                ImaginarySeries      = new ScatterSeries()
            };

            NumberOfIntervals = 5;

            combinedSignal = new SignalRepresentation
            {
                Signal = new SignalImplementation()
            };
            combinedSignal.Signal.Points = new List <Tuple <double, Complex> >();

            CombinedTextProperties = new SignalTextProperties();

            realCombinedSeries      = new ScatterSeries();
            imaginaryCombinedSeries = new ScatterSeries();
            realHistogramSeries     = new ColumnSeries();

            realPlotModel          = new PlotModel();
            imaginaryPlotModel     = new PlotModel();
            realHistogramPlotModel = new PlotModel();

            RealPlotModel.Series.Add(FirstChart.RealSeries);
            RealPlotModel.Series.Add(SecondChart.RealSeries);
            ImaginaryPlotModel.Series.Add(FirstChart.ImaginarySeries);
            ImaginaryPlotModel.Series.Add(SecondChart.ImaginarySeries);
            realHistogramPlotModel.Series.Add(realHistogramSeries);
        }
 internal bool CanDraw(int id, SignalTextProperties properties)
 {
     if (id == -1)
     {
         return(false);
     }
     if (id == 0)
     {
         if (!double.TryParse(properties.FrequencyText, out frequency))
         {
             return(false);
         }
         if (!double.TryParse(properties.AmplitudeText, out amplitude))
         {
             return(false);
         }
         if (!double.TryParse(properties.StartingMomentText, out startingMoment))
         {
             return(false);
         }
         if (!double.TryParse(properties.DurationText, out duration))
         {
             return(false);
         }
     }
     if (id == 1)
     {
         if (!double.TryParse(properties.FrequencyText, out frequency))
         {
             return(false);
         }
         if (!double.TryParse(properties.AmplitudeText, out amplitude))
         {
             return(false);
         }
         if (!double.TryParse(properties.StartingMomentText, out startingMoment))
         {
             return(false);
         }
         if (!double.TryParse(properties.DurationText, out duration))
         {
             return(false);
         }
     }
     if (id == 2)
     {
         if (!double.TryParse(properties.FrequencyText, out frequency))
         {
             return(false);
         }
         if (!double.TryParse(properties.AmplitudeText, out amplitude))
         {
             return(false);
         }
         if (!double.TryParse(properties.PeriodText, out period))
         {
             return(false);
         }
         if (!double.TryParse(properties.StartingMomentText, out startingMoment))
         {
             return(false);
         }
         if (!double.TryParse(properties.DurationText, out duration))
         {
             return(false);
         }
     }
     if (id == 3)
     {
         if (!double.TryParse(properties.FrequencyText, out frequency))
         {
             return(false);
         }
         if (!double.TryParse(properties.AmplitudeText, out amplitude))
         {
             return(false);
         }
         if (!double.TryParse(properties.PeriodText, out period))
         {
             return(false);
         }
         if (!double.TryParse(properties.StartingMomentText, out startingMoment))
         {
             return(false);
         }
         if (!double.TryParse(properties.DurationText, out duration))
         {
             return(false);
         }
     }
     if (id == 4)
     {
         if (!double.TryParse(properties.FrequencyText, out frequency))
         {
             return(false);
         }
         if (!double.TryParse(properties.AmplitudeText, out amplitude))
         {
             return(false);
         }
         if (!double.TryParse(properties.PeriodText, out period))
         {
             return(false);
         }
         if (!double.TryParse(properties.StartingMomentText, out startingMoment))
         {
             return(false);
         }
         if (!double.TryParse(properties.DurationText, out duration))
         {
             return(false);
         }
     }
     if (id == 5)
     {
         if (!double.TryParse(properties.FrequencyText, out frequency))
         {
             return(false);
         }
         if (!double.TryParse(properties.AmplitudeText, out amplitude))
         {
             return(false);
         }
         if (!double.TryParse(properties.PeriodText, out period))
         {
             return(false);
         }
         if (!double.TryParse(properties.StartingMomentText, out startingMoment))
         {
             return(false);
         }
         if (!double.TryParse(properties.DurationText, out duration))
         {
             return(false);
         }
         if (!double.TryParse(properties.DutyCycleText, out dutyCycle))
         {
             return(false);
         }
     }
     if (id == 6)
     {
         if (!double.TryParse(properties.FrequencyText, out frequency))
         {
             return(false);
         }
         if (!double.TryParse(properties.AmplitudeText, out amplitude))
         {
             return(false);
         }
         if (!double.TryParse(properties.PeriodText, out period))
         {
             return(false);
         }
         if (!double.TryParse(properties.StartingMomentText, out startingMoment))
         {
             return(false);
         }
         if (!double.TryParse(properties.DurationText, out duration))
         {
             return(false);
         }
         if (!double.TryParse(properties.DutyCycleText, out dutyCycle))
         {
             return(false);
         }
     }
     if (id == 7)
     {
         if (!double.TryParse(properties.FrequencyText, out frequency))
         {
             return(false);
         }
         if (!double.TryParse(properties.AmplitudeText, out amplitude))
         {
             return(false);
         }
         if (!double.TryParse(properties.PeriodText, out period))
         {
             return(false);
         }
         if (!double.TryParse(properties.StartingMomentText, out startingMoment))
         {
             return(false);
         }
         if (!double.TryParse(properties.DurationText, out duration))
         {
             return(false);
         }
         if (!double.TryParse(properties.DutyCycleText, out dutyCycle))
         {
             return(false);
         }
     }
     if (id == 8)
     {
         if (!double.TryParse(properties.FrequencyText, out frequency))
         {
             return(false);
         }
         if (!double.TryParse(properties.AmplitudeText, out amplitude))
         {
             return(false);
         }
         if (!double.TryParse(properties.StartingMomentText, out startingMoment))
         {
             return(false);
         }
         if (!double.TryParse(properties.DurationText, out duration))
         {
             return(false);
         }
         if (!double.TryParse(properties.TimeOfStepText, out timeOfStep))
         {
             return(false);
         }
     }
     if (id == 9)
     {
         if (!double.TryParse(properties.FrequencyText, out frequency))
         {
             return(false);
         }
         if (!double.TryParse(properties.AmplitudeText, out amplitude))
         {
             return(false);
         }
         if (!double.TryParse(properties.StartingMomentText, out startingMoment))
         {
             return(false);
         }
         if (!int.TryParse(properties.NumberOfAllSamplesText, out numberOfAllSamples))
         {
             return(false);
         }
         if (!int.TryParse(properties.NumberOfSampleText, out numberOfSample))
         {
             return(false);
         }
     }
     if (id == 10)
     {
         if (!double.TryParse(properties.FrequencyText, out frequency))
         {
             return(false);
         }
         if (!double.TryParse(properties.AmplitudeText, out amplitude))
         {
             return(false);
         }
         if (!double.TryParse(properties.StartingMomentText, out startingMoment))
         {
             return(false);
         }
         if (!double.TryParse(properties.DurationText, out duration))
         {
             return(false);
         }
         if (!double.TryParse(properties.ProbabilityText, out probability))
         {
             return(false);
         }
     }
     if (frequency == 0)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 3
0
        private void CombineSignals(Func <ISignal, ISignal, SignalImplementation> func, SignalTextProperties textTraits)
        {
            SignalImplementation outputSignal = func(firstChart.SignalRepresentation.Signal, secondChart.SignalRepresentation.Signal);

            realPlotModel.Axes.Clear();
            imaginaryPlotModel.Axes.Clear();

            realCombinedSeries      = new ScatterSeries();
            imaginaryCombinedSeries = new ScatterSeries();

            realCombinedSeries.MarkerType      = MarkerType.Circle;
            imaginaryCombinedSeries.MarkerType = MarkerType.Circle;
            realCombinedSeries.MarkerFill      = OxyColors.Purple;
            imaginaryCombinedSeries.MarkerFill = OxyColors.Purple;
            realCombinedSeries.MarkerSize      = 1;
            imaginaryCombinedSeries.MarkerSize = 1;

            foreach (Tuple <double, Complex> tuple in outputSignal.Points)
            {
                realCombinedSeries.Points.Add(new ScatterPoint(tuple.Item1, tuple.Item2.Real));
                imaginaryCombinedSeries.Points.Add(new ScatterPoint(tuple.Item1, tuple.Item2.Imaginary));
            }

            ClearPlot();

            outputSignal.StartingMoment = outputSignal.Points[0].Item1;
            outputSignal.EndingMoment   = outputSignal.Points[outputSignal.Points.Count - 1].Item1;
            outputSignal.CalculateTraits();
            combinedSignal.Signal = outputSignal;

            textTraits.AverageValueText          = combinedSignal.Signal.AverageValue.ToString("N3");
            textTraits.AbsouluteAverageValueText = combinedSignal.Signal.AbsouluteAverageValue.ToString("N3");
            textTraits.AveragePowerText          = combinedSignal.Signal.AveragePower.ToString("N3");
            textTraits.VarianceText       = combinedSignal.Signal.Variance.ToString("N3");
            textTraits.EffectiveValueText = combinedSignal.Signal.EffectiveValue.ToString("N3");

            OnPropertyChanged("TextProperties3");

            realPlotModel.Series.Add(realCombinedSeries);
            imaginaryPlotModel.Series.Add(imaginaryCombinedSeries);

            realPlotModel.InvalidatePlot(true);
            imaginaryPlotModel.InvalidatePlot(true);

            double min            = outputSignal.Points.Min(d => d.Item2.Real);
            double max            = outputSignal.Points.Max(d => d.Item2.Real);
            double universumWidth = max - min;
            double intervalWidth  = universumWidth / NumberOfIntervals;

            int[] histogramUniversum = new int[NumberOfIntervals];

            for (int k = 0; k < outputSignal.Points.Count; k++)
            {
                int interval = (int)Math.Floor((outputSignal.Points[k].Item2.Real - min) / (intervalWidth + 0.0001));
                histogramUniversum[interval]++;
            }

            List <int> realHisogramUniversum = histogramUniversum.ToList();

            realCombinedHistogramSeries = new ColumnSeries();
            foreach (int elem in realHisogramUniversum)
            {
                realCombinedHistogramSeries.Items.Add(new ColumnItem(elem));
            }

            realHistogramPlotModel.Axes.Clear();
            realHistogramPlotModel.Series.Clear();
            realCombinedHistogramSeries.FillColor = OxyColors.Purple;
            realHistogramPlotModel.Series.Add(realCombinedHistogramSeries);
            realHistogramPlotModel.InvalidatePlot(true);

            firstChart.SignalRepresentation.Signal  = null;
            secondChart.SignalRepresentation.Signal = null;
        }