コード例 #1
0
        // Adds a entry to the graphing form. If data transformation is required, its handled here.
        public void AddGraphingEntry(GraphingEntry entry)
        {
            if (Series1EnabledCheckbox.Checked)
            {
                series1Values.Add(entry);

                // Add series 1 set-point values if they are enabled
                if (currentYAxis1 == ControlEnums.AXISOPTIONS.POSITION)
                {
                    setLine1Values.Add(new GraphingLine(entry.uptime, positionLineY));
                }
                if (currentYAxis1 == ControlEnums.AXISOPTIONS.VELOCITY)
                {
                    setLine1Values.Add(new GraphingLine(entry.uptime, velocityLineY));
                }
                if (currentYAxis1 == ControlEnums.AXISOPTIONS.ACCELERATION)
                {
                    setLine1Values.Add(new GraphingLine(entry.uptime, accelerationLineY));
                    setLine3Values.Add(new GraphingLine(entry.uptime, -accelerationLineY));
                    setLine3.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 33, 149, 242));
                }
            }
            if (Series2EnabledCheckbox.Checked)
            {
                series2Values.Add(entry);

                // Add series 2 set-point values if they are enabled
                if (currentYAxis2 == ControlEnums.AXISOPTIONS.POSITION)
                {
                    setLine2Values.Add(new GraphingLine(entry.uptime, positionLineY));
                }
                if (currentYAxis2 == ControlEnums.AXISOPTIONS.VELOCITY)
                {
                    setLine2Values.Add(new GraphingLine(entry.uptime, velocityLineY));
                }
                if (currentYAxis2 == ControlEnums.AXISOPTIONS.ACCELERATION)
                {
                    setLine2Values.Add(new GraphingLine(entry.uptime, accelerationLineY));
                    setLine3Values.Add(new GraphingLine(entry.uptime, -accelerationLineY));
                    setLine3.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 243, 67, 54));
                }
            }

            // If the number of points in any series exceeds the maximum, remove the first point.
            if (series1Values.Count > numDataPoints)
            {
                series1Values.RemoveAt(0);
            }
            if (setLine1Values.Count > numDataPoints)
            {
                setLine1Values.RemoveAt(0);
            }
            if (series2Values.Count > numDataPoints)
            {
                series2Values.RemoveAt(0);
            }
            if (setLine2Values.Count > numDataPoints)
            {
                setLine2Values.RemoveAt(0);
            }
            if (setLine3Values.Count > numDataPoints)
            {
                setLine3Values.RemoveAt(0);
            }
        }