Exemple #1
0
        private void showChartOnStepStart(int stepIndex)
        {
            TestStep step = TestPlan.ManualConnectionList[TestPlan.currentConnIndex].TestStepList[stepIndex];

            windowChart.clearData();
            windowChart.Traces.Clear();
            Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { }));
            List <SymtChartLib.XAxis> lstXAxis = new List <SymtChartLib.XAxis>();
            int k = 0;

            if (step as LoopTestStep != null)
            {
                return;
            }
            foreach (TestTrace tr in step.ItemList.Where(x => x is TestTrace))
            {
                if (lstXAxis.Select(x => x.Start == tr.XAxisInfo.Start && x.Stop == tr.XAxisInfo.Stop && x.Unit == tr.XAxisInfo.Unit).Count() == 0)
                {
                    lstXAxis.Add(new SymtChartLib.XAxis()
                    {
                        Start = tr.XAxisInfo.Start, Stop = tr.XAxisInfo.Stop, Center = tr.XAxisInfo.Center
                    });
                }
                SymtChartLib.Trace trace = new SymtChartLib.Trace();

                k++;
                trace.Title     = step.Name + "_" + tr.TypeName;
                trace.AxisIndex = lstXAxis.FindIndex(x => x.Start == tr.XAxisInfo.Start && x.Stop == tr.XAxisInfo.Stop && x.Center == tr.XAxisInfo.Center);
                if (tr.ResultData != null)
                {
                    List <XYData> xyData = tr.ResultData;
                    if (xyData.Count > 0)
                    {
                        Point[] point = new Point[xyData.Count];
                        for (int i = 0; i < xyData.Count; i++)
                        {
                            Point p = new Point()
                            {
                                X = xyData[i].X, Y = xyData[i].Y
                            };
                            point[i] = p;
                        }

                        trace.TraceData = point;
                        windowChart.Traces.Add(trace);
                    }
                }
                if (tr.TestSpecList.Count > 0 && SpecIndex >= 0)
                {
                    XYTestLimit testLimit = tr.TestSpecList[SpecIndex].TestLimit;
                    if (testLimit != null)
                    {
                        if (testLimit.Enable)
                        {
                            foreach (var limit in testLimit.LimitLine)
                            {
                                SymtChartLib.LimitLineTypeEnum type = new SymtChartLib.LimitLineTypeEnum();
                                if (limit.Type == ModelBaseLib.LimitLineTypeEnum.Max)
                                {
                                    type = SymtChartLib.LimitLineTypeEnum.Max;
                                }
                                else if (limit.Type == ModelBaseLib.LimitLineTypeEnum.Min)
                                {
                                    type = SymtChartLib.LimitLineTypeEnum.Min;
                                }
                                else
                                {
                                    type = SymtChartLib.LimitLineTypeEnum.None;
                                }
                                trace.LimitLineList.Add(new SymtChartLib.LimitLine()
                                {
                                    X1 = limit.X1, Y1 = limit.Y1, X2 = limit.X2, Y2 = limit.Y2, Type = type
                                });
                            }
                        }
                        else
                        {
                            double?yValue = null;
                            if (tr.TestSpecList[SpecIndex].LowLimit == null && tr.TestSpecList[SpecIndex].UpLimit == null)
                            {
                            }
                            else
                            {
                                if (trace.TraceData != null)
                                {
                                    double x1 = trace.TraceData.Select((d, y) => d.X).Min();
                                    double x2 = trace.TraceData.Select((d, y) => d.X).Max();
                                    yValue = tr.TestSpecList[SpecIndex].LowLimit != null ? tr.TestSpecList[SpecIndex].LowLimit : tr.TestSpecList[SpecIndex].UpLimit;
                                    trace.LimitLineList.Add(new SymtChartLib.LimitLine()
                                    {
                                        X1 = x1, Y1 = Convert.ToDouble(yValue), X2 = x2, Y2 = Convert.ToDouble(yValue), Type = SymtChartLib.LimitLineTypeEnum.None
                                    });
                                }
                            }
                        }
                    }
                }
                trace.Scale             = tr.Scale;
                trace.DivisionCount     = tr.DivCount;
                trace.ReferenceLevel    = tr.RefValue;
                trace.Unit              = tr.Unit;
                trace.ReferencePosition = tr.RefPosition;
            }
            windowChart.XAxisList = lstXAxis;
            windowChart.UpdateData();
        }
Exemple #2
0
        private void showChartOnPointFinish(int stepIndex, int traceIndex, int markerIndex)
        {
            windowChart.ClearTraceInfo();
            TestStep step = TestPlan.ManualConnectionList[TestPlan.currentConnIndex].TestStepList[stepIndex];

            foreach (TestTrace tr in step.ItemList.Where(x => x is TestTrace))
            {
                List <XYData>      xyData = tr.ResultData;
                SymtChartLib.Trace trace  = new SymtChartLib.Trace();

                trace.Title     = step.Name + "_" + tr.TypeName;
                trace.AxisIndex = windowChart.XAxisList.FindIndex(x => x.Start == tr.XAxisInfo.Start && x.Stop == tr.XAxisInfo.Stop && x.Center == tr.XAxisInfo.Center);
                if (xyData.Count > 0)
                {
                    Point[] point = new Point[xyData.Count];
                    for (int i = 0; i < xyData.Count; i++)
                    {
                        Point p = new Point()
                        {
                            X = xyData[i].X, Y = xyData[i].Y
                        };
                        point[i] = p;
                    }
                    trace.TraceData = point;
                    windowChart.Traces.Add(trace);
                }
                //添加Marker
                //foreach(XYTestMarker marker in tr.TestSpecList[SpecIndex].TestMarkerList)
                //{
                //    int index = tr.ResultData.Select((d, i) => { return new { value = d.X, valueIndex = i }; }).OrderBy(x => Math.Abs(x.value - marker.Start)).First().valueIndex;
                //}
                if (tr.TestSpecList.Count > 0 && SpecIndex >= 0)
                {
                    XYTestLimit testLimit = tr.TestSpecList[SpecIndex].TestLimit;
                    if (testLimit != null)
                    {
                        if (testLimit.Enable)
                        {
                            foreach (var limit in testLimit.LimitLine)
                            {
                                SymtChartLib.LimitLineTypeEnum type = new SymtChartLib.LimitLineTypeEnum();
                                if (limit.Type == ModelBaseLib.LimitLineTypeEnum.Max)
                                {
                                    type = SymtChartLib.LimitLineTypeEnum.Max;
                                }
                                else if (limit.Type == ModelBaseLib.LimitLineTypeEnum.Min)
                                {
                                    type = SymtChartLib.LimitLineTypeEnum.Min;
                                }
                                else
                                {
                                    type = SymtChartLib.LimitLineTypeEnum.None;
                                }
                                trace.LimitLineList.Add(new SymtChartLib.LimitLine()
                                {
                                    X1 = limit.X1, Y1 = limit.Y1, X2 = limit.X2, Y2 = limit.Y2, Type = type
                                });
                            }
                        }
                        else
                        {
                            double?yValue = null;
                            if (tr.TestSpecList[SpecIndex].LowLimit == null && tr.TestSpecList[SpecIndex].UpLimit == null)
                            {
                            }
                            else
                            {
                                if (trace.TraceData != null)
                                {
                                    double x1 = trace.TraceData.Select((d, y) => d.X).Min();
                                    double x2 = trace.TraceData.Select((d, y) => d.X).Max();
                                    yValue = tr.TestSpecList[SpecIndex].LowLimit != null ? tr.TestSpecList[SpecIndex].LowLimit : tr.TestSpecList[SpecIndex].UpLimit;
                                    trace.LimitLineList.Add(new SymtChartLib.LimitLine()
                                    {
                                        X1 = x1, Y1 = Convert.ToDouble(yValue), X2 = x2, Y2 = Convert.ToDouble(yValue), Type = SymtChartLib.LimitLineTypeEnum.None
                                    });
                                }
                            }
                        }
                    }
                }
                trace.Scale             = tr.Scale;
                trace.DivisionCount     = tr.DivCount;
                trace.ReferenceLevel    = tr.RefValue;
                trace.Unit              = tr.Unit;
                trace.ReferencePosition = tr.RefPosition;
            }
            windowChart.UpdatePointData(traceIndex);
        }