コード例 #1
0
ファイル: Form1.cs プロジェクト: 633k4hire/TraceCompare
        private void toolStripLabel1_Click(object sender, EventArgs e)
        {
            //var s = servoGraph.Series["Series1"];
            //double I = (servoGraph.ChartAreas[0].AxisX.Minimum /2)+ (servoGraph.ChartAreas[0].AxisX.Maximum / 2);
            //var a =s.FindValueOfXcursor(I);		max	0.030105249741495754	double
            try
            {
                var ydif = Overloads.CompareSeriesForVerticalDifferential(servoGraph.Series["Series1"], servoGraph.Series["Series2"], 1, 1, -0.9, 0.9);
                //check scale
                var min    = s1a2Min;
                var max    = s1a2Max;
                var height = (max - min);
                var a      = ydif[0].YValues[0];
                ydif.ThresholdY();
                var    ymin = ydif.MinY();
                var    ymax = ydif.MaxY();
                double high;
                if (Math.Abs(ymin) >= Math.Abs(ymax))
                {
                    high = ymin;
                }
                else
                {
                    high = ymax;
                }

                var factor = 1 / Math.Abs(high);

                var offset = height * 2;

                //ydif.ThresholdY();
                ydif.ScaleY(factor * 50);
                var shift = high * 2 + min - offset;
                ydif.ShiftY(shift);

                //check shift

                servoGraph.Series["Ydif"].Points.Clear();
                foreach (var dp in ydif)
                {
                    servoGraph.Series["Ydif"].Points.Add(dp);
                }
            }catch (Exception ex)
            {
                MessageBox.Show("Could Not Compare\r\n\r\n" + ex.ToString());
            }
            //var min = result.Min();
            //var max = result.Max();
            //var maxError = max - min;
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: 633k4hire/TraceCompare
        private void Show_click(object sender, EventArgs e)
        {
            try
            {
                servoGraph.Series["Series1"].Color = Color.FromArgb(120, 255, 0, 0);
                servoGraph.Series["Series2"].Color = Color.FromArgb(120, 0, 0, 255);
                makeSquare(servoGraph);
                if (s1a1.Nodes.Count < 1 || s1a2.Nodes.Count < 1 || s2a1.Nodes.Count < 1 || s2a2.Nodes.Count < 1)
                {
                    MessageBox.Show("Please Fill In Sample Data");
                    return;
                }
                if (s1a1.Nodes.Count > 1 || s1a2.Nodes.Count > 1 || s2a1.Nodes.Count > 1 || s2a2.Nodes.Count > 1)
                {
                    MessageBox.Show("Only (One) Item per Axis Sample is allowed");
                    return;
                }
                s1a1Points = GetPoints(s1a1.Tag as TraceSession.TraceData.DataFrame.DataSignal);
                s1a2Points = GetPoints(s1a2.Tag as TraceSession.TraceData.DataFrame.DataSignal);
                s2a1Points = GetPoints(s2a1.Tag as TraceSession.TraceData.DataFrame.DataSignal);
                s2a2Points = GetPoints(s2a2.Tag as TraceSession.TraceData.DataFrame.DataSignal);

                s1a1Min = s1a1Points.Min(sp => sp.YValues[0]);
                s1a1Max = s1a1Points.Max(sp => sp.YValues[0]);

                s1a2Min = s1a2Points.Min(sp => sp.YValues[0]);
                s1a2Max = s1a2Points.Max(sp => sp.YValues[0]);

                s2a1Min = s2a1Points.Min(sp => sp.YValues[0]);
                s2a1Max = s2a1Points.Max(sp => sp.YValues[0]);

                s2a2Min = s2a2Points.Min(sp => sp.YValues[0]);
                s2a2Max = s2a2Points.Max(sp => sp.YValues[0]);


                var a = servoGraph.ChartAreas["ChartArea1"].AxisX.Maximum = s1a1Max + (s1a1Max * .03);
                var b = servoGraph.ChartAreas["ChartArea1"].AxisX.Minimum = s1a1Min - (s1a1Min * .03);
                var c = servoGraph.ChartAreas["ChartArea1"].AxisY.Maximum; // = s1a2Max+10;
                var d = servoGraph.ChartAreas["ChartArea1"].AxisY.Minimum; // = s1a2Min-10;
                xmin.Text = b.ToString();
                xmax.Text = a.ToString();
                var change = a - b;

                c = servoGraph.ChartAreas["ChartArea1"].AxisY.Maximum = s1a2Min + change - (change / 2);
                d = servoGraph.ChartAreas["ChartArea1"].AxisY.Minimum = s1a2Min - (change / 2);

                ymax.Text = c.ToString();
                ymin.Text = d.ToString();

                servoGraph.Series["Series1"].ChartType = SeriesChartType.Line;
                servoGraph.Series["Series2"].ChartType = SeriesChartType.Line;
                //servoGraph.Series["Series1"].YValuesPerPoint = 32;
                servoGraph.Series["Series1"].YValueType = ChartValueType.Double;
                servoGraph.Series["Series1"].XValueType = ChartValueType.Double;
                // servoGraph.Series["Series2"].YValuesPerPoint = 32;
                servoGraph.Series["Series2"].YValueType = ChartValueType.Double;
                servoGraph.Series["Series2"].XValueType = ChartValueType.Double;

                //make pairs and draw it out, check time stamps and move on if no change then keep moving



                //this does not work
                servoGraph.Series["Series1"].Points.Clear();
                servoGraph.Series["Series2"].Points.Clear();
                //pair up
                var path1 = Overloads.Pair(s1a1Points, s1a2Points);
                var path2 = Overloads.Pair(s2a1Points, s2a2Points, true);

                foreach (var p in path1)
                {
                    servoGraph.Series["Series1"].Points.Add(p);
                }
                foreach (var p in path2)
                {
                    servoGraph.Series["Series2"].Points.Add(p);
                }



                // servoGraph.ChartAreas[0].RecalculateAxesScale();
            }
            catch
            {
            }
        }