示例#1
0
        private void LoadTrendData(DataLoadKind loadKind, DateTime aBeg, DateTime aEnd)
        {
            RefreshNavigation();

            if (loadKind == DataLoadKind.dlkByStart)
            {
                for (int i = 0; i < MAX_TRENDS; i++)
                {
                    TrendChart1[i].Clear();
                }
            }

            DateTime begDateTime = DateTime.Now;
            DateTime endDateTime = DateTime.Now;

            GetTimeRange(ref begDateTime, ref endDateTime);

            TrendChart1.BegDateTime = begDateTime;
            TrendChart1.EndDateTime = endDateTime;
            TrendChart1.ForeColor   = Color.Black;
            TrendChart1.RulerColor  = Color.Black;
            TrendChart1.XAxisColor  = Color.Black;
            TrendChart1.CrossRuler  = true;
            TrendChart1.DateCode    = 0;
            TrendChart1.DayCode     = 0;
            TrendChart1.MonthCode   = 0;
            TrendChart1.YearCode    = 0;
            TrendChart1.AroundZoom  = true;
            TrendChart1.Legend      = true;

            TrendChart1.BeginUpdate();
            for (int k = 0; k < MAX_TRENDS; k++)
            {
                int num2 = k / 4;
                int num3 = k % 4;

                TrendObj trendObj = TrendChart1[k];
                //if (trendObj == null) continue;

                switch (k)
                {
                case 0:
                    trendObj.Color = Color.Red;
                    break;

                case 1:
                    trendObj.Color = Color.Green;
                    break;

                case 2:
                    trendObj.Color = Color.Black;
                    break;

                case 3:
                    trendObj.Color = Color.Blue;
                    break;

                case 4:
                    trendObj.Color = Color.Fuchsia;
                    break;

                case 5:
                    trendObj.Color = Color.Navy;
                    break;

                case 6:
                    trendObj.Color = Color.Olive;
                    break;

                case 7:
                    trendObj.Color = Color.Purple;
                    break;
                }

                trendObj.AxisSign   = "[" + Convert.ToString(k) + "]";
                trendObj.ScaleIndex = num3 + 1;
                trendObj.PosY       = num2 + 1;

                if (!string.IsNullOrEmpty(trendObj.Tag))
                {
                    float zero, span;
                    PIBUtils.piLoadTrend(trendObj.Series, trendObj.Tag, (LoadFlags)0, aBeg, aEnd, out zero, out span);

                    double sum = 0.0;
                    if (trendObj.Series.Count > 0)
                    {
                        AnalitikMAX[k] = trendObj.Series[0].pValue;
                        AnalitikMIN[k] = trendObj.Series[0].pValue;
                    }
                    else
                    {
                        AnalitikMAX[k] = 0.0;
                        AnalitikMIN[k] = 0.0;
                    }

                    for (int i = 0; i < trendObj.Series.Count; i++)
                    {
                        TrendPoint trendPt = trendObj.Series[i];
                        sum = (sum + trendPt.pValue);
                        if (trendPt.pValue >= AnalitikMAX[k])
                        {
                            AnalitikMAX[k] = trendPt.pValue;
                        }
                        if (trendPt.pValue <= AnalitikMIN[k])
                        {
                            AnalitikMIN[k] = trendPt.pValue;
                        }
                    }

                    if (trendObj.Series.Count != 0)
                    {
                        AnalitikAVG[k] = (sum / (double)trendObj.Series.Count);
                    }
                    else
                    {
                        AnalitikAVG[k] = 0.0;
                    }

                    if (trendObj.Series.Count > 0)
                    {
                        fLastUpdate = trendObj.Series[trendObj.Series.Count - 1].pTime;
                    }
                    else
                    {
                        fLastUpdate = 0;
                    }
                }
                else
                {
                    trendObj.Visible = false;
                    AnalitikMAX[k]   = 0.0;
                    AnalitikMIN[k]   = 0.0;
                }
            }

            TrendChart1.FiltersApply();
            TrendChart1.DrawTrends();
            TrendChart1.EndUpdate();
            TrendChart1.Invalidate();
        }