Пример #1
0
        public void LoadCompleted(DataSerie serie, ref List <pointXY> liveData, List <pointXY> dataLoggerData)
        {
            if (dataLoggerData.Count <= 0)
            {
                return;
            }

            if (liveData.Count > 0)
            {
                double lastTimeStamp = dataLoggerData[dataLoggerData.Count - 1].x;
                int    n             = 0;
                while ((n < liveData.Count) && (lastTimeStamp >= liveData[n].x))
                {
                    n++;
                }
                if (n > 0)
                {
                    liveData.RemoveRange(0, n);
                }
            }

            liveData = (List <pointXY>)dataLoggerData.Concat(liveData).ToList();


            MonitorGraph.DisableRedraw();
            serie.clear();
            serie.InsertPoints(liveData.ToArray());
            MonitorGraph.AllowRedraw();
        }
 private void deriv_CheckedChanged(object sender, EventArgs e)
 {
     chart.DisableRedraw();
     rawWData.clear();
     if (deriv.Checked)
     {
         for (int i = 24; i < count; i++)
         {
             rawWData.AddPoint(new pointXY()
             {
                 x = stamp[i], y = rawW[i] - rawW[i - 24]
             });
         }
     }
     else
     {
         for (int i = 0; i < count; i++)
         {
             rawWData.AddPoint(new pointXY()
             {
                 x = stamp[i], y = rawW[i]
             });
         }
     }
     this.recomputeError(true);
     chart.AllowRedraw();
 }
        public void recomputeAvgTemp(bool refresh)
        {
            if (refresh)
            {
                chart.DisableRedraw();
            }
            if (refresh)
            {
                avgTempData.clear();
            }

            double ratio = aRatio * 0.001;
            double compt = temp[0];

            for (int i = 1; i < count; i++)
            {
                double dt = temp[i] - compt;
                compt     += ratio * dt;
                avgTemp[i] = compt;
                if (refresh)
                {
                    avgTempData.AddPoint(new pointXY()
                    {
                        x = stamp[i], y = avgTemp[i]
                    });
                }
            }
            this.estimateAlpha();
            this.estimateOffset(refresh);

            if (refresh)
            {
                chart.AllowRedraw();
            }
        }
        public void recomputeError(bool refresh)
        {
            double sumSq = 0;

            for (int i = 1; i < count; i++)
            {
                pred[i] = alpha * avgTemp[i] + beta * deltaTemp[i] + autoOffset;
                sumSq  += (rawW[i] - pred[i]) * (rawW[i] - pred[i]);
            }
            avgSqError = sumSq / (count - 1);

            if (refresh)
            {
                rmsError.Text = (Math.Round(Math.Sqrt(avgSqError) * 10000) / 10000).ToString();
                chart.DisableRedraw();
                predData.clear();
                errorData.clear();
                if (deriv.Checked)
                {
                    for (int i = 25; i < count; i++)
                    {
                        predData.AddPoint(new pointXY()
                        {
                            x = stamp[i], y = pred[i] - pred[i - 24]
                        });
                    }
                }
                else
                {
                    for (int i = 1; i < count; i++)
                    {
                        predData.AddPoint(new pointXY()
                        {
                            x = stamp[i], y = pred[i]
                        });
                    }
                }
                for (int i = 1; i < count; i++)
                {
                    errorData.AddPoint(new pointXY()
                    {
                        x = stamp[i], y = rawW[i] - pred[i]
                    });
                }
                chart.AllowRedraw();
            }
        }
        public void recomputeDeltaTemp(bool refresh)
        {
            if (refresh)
            {
                chart.DisableRedraw();
            }
            if (refresh)
            {
                deltaTempData.clear();
            }

            double ratio = bRatio * 0.001;
            double compt = temp[0];

            for (int i = 1; i < count; i++)
            {
                double dt = temp[i] - compt;
                compt       += ratio * dt;
                deltaTemp[i] = dt;
                if (refresh)
                {
                    deltaTempData.AddPoint(new pointXY()
                    {
                        x = stamp[i], y = deltaTemp[i]
                    });
                }
            }
            this.estimateBeta();
            this.estimateAvgRate(refresh);
            this.recomputeAvgTemp(refresh);

            if (refresh)
            {
                chart.AllowRedraw();
            }
        }