Esempio n. 1
0
 public void RefreshPoints()
 {
     if (PointCache != null)
     {
         int k = PointCache.FindRelativeXCoordinateInCache(BottomAxis.ActualMinimum);
         if (k < 0)
         {
             k = ~k;
         }
         ResetSeries();
         CurrentRelativeCacheIndex = k + NumPointsPerPlot;
         if (CurrentRelativeCacheIndex > PointCache.RelativeCount)
         {
             CurrentRelativeCacheIndex = PointCache.RelativeCount;
         }
         if (k < PointCache.RelativeCount)
         {
             List <double> q = PointCache.RelativeGetAt(k);
             if (q != null)
             {
                 int maxDataSeries = q.Count - 1;
                 if (q == null)
                 {
                     return;
                 }
                 if (NumSeries == 0)
                 {
                     SetSeries(maxDataSeries);
                 }
                 int maxNumSeries = NumSeries < maxDataSeries ? NumSeries : maxDataSeries;
                 PointCache.RefreshMinMax();
                 for (int h = 0; h < maxNumSeries; h++)
                 {
                     MapLineSeries s = PlotModel.Series[h] as MapLineSeries;
                     s.RefreshMinMax();
                     for (int i = k; i < CurrentRelativeCacheIndex; i++)
                     {
                         List <double> p = PointCache.RelativeGetAt(i);
                         if (p == null)
                         {
                             return;
                         }
                         s.Points.Add(new DataPoint(p[0], s.Map(p[1 + h])));
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
0
 public void UpdatePlot()
 {
     if (PointCache != null)
     {
         if (Dispatcher.CheckAccess())
         {
             while (IsRealTime && PointCache.RelativeCount > CurrentRelativeCacheIndex)
             {
                 List <double> p = PointCache.RelativeGetAt(CurrentRelativeCacheIndex++);
                 if (p == null)
                 {
                     break;
                 }
                 int maxDataSeries = p.Count - 1;
                 if (NumSeries == 0)
                 {
                     SetSeries(maxDataSeries);
                 }
                 int numPlotableSeries = NumSeries < maxDataSeries ? NumSeries : maxDataSeries;
                 for (int h = 0; h < numPlotableSeries; h++)
                 {
                     MapLineSeries s = PlotModel.Series[h] as MapLineSeries;
                     if (s.Points.Count >= NumPointsPerPlot)
                     {
                         s.Points.RemoveAt(0);
                     }
                     s.Points.Add(new DataPoint(p[0], s.Map(p[1 + h])));
                 }
             }
         }
         else
         {
             Dispatcher.Invoke((Action)(() => { UpdatePlot(); }));
         }
     }
 }