// When the chart is filled with points, this procedure
        // deletes and scrolls points to the left.
        private void DoScrollPoints()
        {
            double tmp, tmpMin, tmpMax;

            // Delete multiple points with a single call.
            // Much faster than deleting points using a loop.

            fastLine1.Delete(0, ScrollPoints);
            fastLine2.Delete(0, ScrollPoints);

            // Scroll horizontal bottom axis
            tmp = fastLine1.XValues.Last;
            tChart1.Axes.Bottom.SetMinMax(tmp - MaxPoints + ScrollPoints, tmp + ScrollPoints);

            // Scroll vertical left axis
            tmpMin = fastLine1.YValues.Minimum;
            if (fastLine2.YValues.Minimum < tmpMin)
            {
                tmpMin = fastLine2.YValues.Minimum;
            }

            tmpMax = fastLine1.YValues.Maximum;
            if (fastLine2.YValues.Maximum > tmpMax)
            {
                tmpMax = fastLine2.YValues.Maximum;
            }

            tChart1.Axes.Left.SetMinMax(tmpMin - tmpMin * 0.2, tmpMax + tmpMax * 0.2);

            // Do chart repaint after deleting and scrolling
            Application.DoEvents();
        }
 private void timer1_Tick(object sender, System.EventArgs e)
 {
     timer1.Enabled = false;
     try
     {
         fastLine1.Delete(0);
         Random r = new Random();
         fastLine1.Add(fastLine1.XValues.Last + 1.0,
                       fastLine1.YValues.Last + r.Next(100) - 50);
         fastLine2.CheckDataSource(); // <-- fill again the points
         fastLine3.CheckDataSource(); // <-- fill again the points
     }
     finally { timer1.Enabled = true; }
 }
Beispiel #3
0
        private void updatePoints(GatePacket gatePacket, int boardIndex)
        {
            int    sourceID = (int)gatePacket.head.id;
            int    curPosX = (int)gatePacket.tag.stampPos[0] + boardIndex * 20;
            int    port = (int)gatePacket.head.port;
            int    num = (int)gatePacket.tag.cellNum;
            double tmpYValue, preYValue;
            int    index;
            bool   isFinded;
            bool   isGood;

            if (points == null)
            {
                StackTrace st = new StackTrace(new StackFrame(true));
                LogHelper.WriteLog("The class for stroging the points is null!", st);
                return;
            }

            //Weather the boardIndex and sourceID are matched.
            isFinded = matchConfig(boardIndex, port, sourceID);
            if (!isFinded)
            {
                return;
            }

            if (gatePacket.tag.stampPos[0] == 0)
            {
                clear();
            }

            for (int i = 0; i < num; i++)
            {
                index     = ft.XValues.IndexOf(curPosX);
                tmpYValue = gatePacket.measureDate[i];

                //A new point.
                if (index < 0)
                {
                    isGood = addPoint(curPosX, tmpYValue);
                    ft.Add(curPosX, tmpYValue);
                    points.addPoint(curPosX, tmpYValue, boardIndex, isGood);
                }
                //An old point, need to check.
                else
                {
                    preYValue = ft.YValues[index];
                    if (Math.Abs(tmpYValue) > Math.Abs(preYValue))
                    {
                        deletePoint(curPosX, preYValue);
                        ft.Delete(index);
                        isGood = addPoint(curPosX, tmpYValue);
                        ft.Add(curPosX, tmpYValue);
                        points.addPoint(curPosX, tmpYValue, boardIndex, isGood);
                    }
                }

                curPosX += (int)gatePacket.tag.stampInc[0];


                maxAllowFt.Add(tchart.Axes.Bottom.MaxXValue, AscanMeasureMap.MaxSingleGateValue);
                minAllowFt.Add(tchart.Axes.Bottom.MaxXValue, AscanMeasureMap.MinSingleGateValue);
            }
        }