private Traces MakeData() { var function = new TraceReal { Pen = new System.Drawing.Pen(System.Drawing.Color.SkyBlue), Name = "Ft, C2, Transistor, T240", IsGistogram = true, IsVisibleInMarker = true, Visible = true, GraphIndex = 0, CoordinateSystemType = CoordinateSystemType.Rectangle, ArgumentQuantityType = PhysicalQuantityType.Frequencies }; var symbol = new MarkerSymbol { Type = MarkerSymbolType.Circle, Visible = false }; function.Symbol = symbol; function.SymbolInterval = 1; function.SymbolsAutoInterval = false; var values = new[] { 38603499999.999992, 32817999999.999996, 36808000000.0, 40000000000.0, 31820499999.999996, 40000000000.0, 32817999999.999996, 40000000000.0, 40000000000.0, 40000000000.0, 37606000000.0, 40000000000.0, 40000000000.0, 40000000000.0, 40000000000.0, 40000000000.0, 32418999999.999996, 40000000000.0, 40000000000.0, 27431500000.0 }; var gistogram = Calculations.Gistogram(values); if (gistogram.Keys.Count == 1) { var dataSector = new GraphDataSectorReal { new PointValueReal(gistogram.Keys.ElementAt(0), gistogram[gistogram.Keys.ElementAt(0)]) }; function.Add(dataSector); } else { for (int i = 0; i < gistogram.Keys.Count - 1; i++) { var dataSector = new GraphDataSectorReal(); dataSector.Add(new PointValueReal(gistogram.Keys.ElementAt(i), gistogram[gistogram.Keys.ElementAt(i + 1)])); dataSector.Add(new PointValueReal(gistogram.Keys.ElementAt(i + 1), gistogram[gistogram.Keys.ElementAt(i + 1)])); function.Add(dataSector); } } var result = new Traces(); result.RealFunctions.Add(function); var meanFunction = new TraceReal { Pen = new System.Drawing.Pen(System.Drawing.Color.Green), Name = "Mean Ft, C2, Transistor, T240", IsGistogram = true, IsVisibleInMarker = true, Visible = true, GraphIndex = 0, CoordinateSystemType = CoordinateSystemType.Rectangle, ArgumentQuantityType = PhysicalQuantityType.Frequencies }; var meanSymbol = new MarkerSymbol { Type = MarkerSymbolType.Circle, Visible = true }; meanFunction.Symbol = meanSymbol; meanFunction.SymbolInterval = 1; meanFunction.SymbolsAutoInterval = false; var meanValue = Calculations.MeanValue(values); var maxDiapason = Calculations.MaxDiapasonValue(values); var meanDataSector = new GraphDataSectorReal { new PointValueReal(meanValue, maxDiapason) }; meanFunction.Add(meanDataSector); result.RealFunctions.Add(meanFunction); var sigmaFunction = new TraceReal { Pen = new System.Drawing.Pen(System.Drawing.Color.Blue), Name = "3 sigma Ft, C2, Transistor, T240", IsGistogram = true, IsVisibleInMarker = true, Visible = true, GraphIndex = 0, CoordinateSystemType = CoordinateSystemType.Rectangle, ArgumentQuantityType = PhysicalQuantityType.Frequencies }; sigmaFunction.Symbol = meanSymbol; sigmaFunction.SymbolInterval = 1; sigmaFunction.SymbolsAutoInterval = false; var sigma = Calculations.Sigma(values); var sigmaDataSector = new GraphDataSectorReal { new PointValueReal(meanValue - 3 * sigma, maxDiapason) }; sigmaFunction.Add(sigmaDataSector); sigmaDataSector = new GraphDataSectorReal { new PointValueReal(meanValue + 3 * sigma, maxDiapason) }; sigmaFunction.Add(sigmaDataSector); result.RealFunctions.Add(sigmaFunction); var gausFunction = new TraceReal { Pen = new System.Drawing.Pen(System.Drawing.Color.Red), Name = "Gaus Ft, C2, Transistor, T240", IsGistogram = false, IsVisibleInMarker = true, Visible = true, GraphIndex = 0, CoordinateSystemType = CoordinateSystemType.Rectangle, ArgumentQuantityType = PhysicalQuantityType.Frequencies }; gausFunction.Symbol = symbol; gausFunction.SymbolInterval = 1; gausFunction.SymbolsAutoInterval = false; var gausDataSector = new GraphDataSectorReal(); var gaus = Calculations.Gaussian(values); foreach (var valueReal in gaus) { gausDataSector.Add(valueReal); } gausFunction.Add(gausDataSector); result.RealFunctions.Add(gausFunction); return result; }
private Traces MakeData(ShewharMeasurement measurement) { var symbol = new MarkerSymbol { Type = MarkerSymbolType.Circle, Visible = true }; var function = new TraceReal { Pen = new System.Drawing.Pen(System.Drawing.Color.Green) { Width = 1 }, Name = "Shewhart", IsGistogram = false, IsVisibleInMarker = true, Visible = true, GraphIndex = 0, Approximator = null, ArgumentQuantityType = PhysicalQuantityType.Scalar, SymbolInterval = 1, SymbolsAutoInterval = false, Symbol = symbol }; var noneSymbol = new MarkerSymbol { Type = MarkerSymbolType.None, Visible = false }; var meanFunction = new TraceReal { Pen = new System.Drawing.Pen(System.Drawing.Color.Blue), Name = "Mean", IsGistogram = false, IsVisibleInMarker = true, Visible = true, GraphIndex = 0, Approximator = null, ArgumentQuantityType = PhysicalQuantityType.Scalar, Symbol = noneSymbol }; var uclSymbol = new MarkerSymbol { Type = MarkerSymbolType.TriangleUp, Visible = true }; var uclFunction = new TraceReal { Pen = new System.Drawing.Pen(System.Drawing.Color.Red), Name = "UCL", IsGistogram = false, IsVisibleInMarker = true, Visible = true, GraphIndex = 0, Approximator = null, ArgumentQuantityType = PhysicalQuantityType.Scalar, Symbol = noneSymbol }; var cUpFunction = new TraceReal { Pen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(255, 192, 192)) { DashPattern = new[] { 4.0F, 8.0F } }, Name = "C above mean", Visible = true, GraphIndex = 0, Approximator = null, ArgumentQuantityType = PhysicalQuantityType.Scalar, Symbol = noneSymbol }; var bUpFunction = new TraceReal { Pen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(255, 128, 128)) { DashPattern = new[] { 4.0F, 8.0F } }, Name = "B above mean", Visible = true, GraphIndex = 0, Approximator = null, ArgumentQuantityType = PhysicalQuantityType.Scalar, Symbol = noneSymbol }; var lclSymbol = new MarkerSymbol { Type = MarkerSymbolType.TriangleDown, Visible = true }; var lclFunction = new TraceReal { Pen = new System.Drawing.Pen(System.Drawing.Color.Red), Name = "LCL", IsGistogram = false, IsVisibleInMarker = true, Visible = true, GraphIndex = 0, Approximator = null, ArgumentQuantityType = PhysicalQuantityType.Scalar, Symbol = noneSymbol }; var cDownFunction = new TraceReal { Pen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(255, 192, 192)) { DashPattern = new[] { 4.0F, 8.0F } }, Name = "C below mean", Visible = true, GraphIndex = 0, Approximator = null, ArgumentQuantityType = PhysicalQuantityType.Scalar, Symbol = noneSymbol }; var bDownFunction = new TraceReal { Pen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(255, 128, 128)) { DashPattern = new[] { 4.0F, 8.0F } }, Name = "B below mean", Visible = true, GraphIndex = 0, Approximator = null, ArgumentQuantityType = PhysicalQuantityType.Scalar, Symbol = noneSymbol }; var minSpecFunction = new TraceReal { Pen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(64, 64, 64)), Name = "Min spec", Visible = true, GraphIndex = 0, Approximator = null, ArgumentQuantityType = PhysicalQuantityType.Scalar, Symbol = noneSymbol }; var maxSpecFunction = new TraceReal { Pen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(64, 64, 64)), Name = "Max spec", Visible = true, GraphIndex = 0, Approximator = null, ArgumentQuantityType = PhysicalQuantityType.Scalar, Symbol = noneSymbol }; var nominalSpecFunction = new TraceReal { Pen = new System.Drawing.Pen(System.Drawing.Color.Black), Name = "Nominal spec", Visible = true, GraphIndex = 0, Approximator = null, ArgumentQuantityType = PhysicalQuantityType.Scalar, Symbol = noneSymbol }; var functionDataSector = new GraphDataSectorReal(); var meanDataSector = new GraphDataSectorReal(); var uclDataSector = new GraphDataSectorReal(); var cUpDataSector = new GraphDataSectorReal(); var bUpDataSector = new GraphDataSectorReal(); var lclDataSector = new GraphDataSectorReal(); var cDownDataSector = new GraphDataSectorReal(); var bDownDataSector = new GraphDataSectorReal(); var minSpecDataSector = new GraphDataSectorReal(); var maxSpecDataSector = new GraphDataSectorReal(); var nominalSpecDataSector = new GraphDataSectorReal(); var values = new List<double> {378, 376, 375, 370, 371, 388, 389, 390, 388, 400, 391, 392, 386, 382, 378, 374, 370, 380, 381, 387}; var meanvalue = 382.3; var sigma = 8.25; var uclValue = meanvalue + 3*sigma; var bUpValue = meanvalue + 2*sigma; var cUpValue = meanvalue + sigma; var lclValue = meanvalue - 3*sigma; var bDownValue = meanvalue - 2*sigma; var cDownValue = meanvalue - sigma; double? usersMinSpec = 340; double? usersMaxSpec = 420; double? usersNominalSpec = 380; for (int i = 0; i < values.Count; i++) { functionDataSector.Add(new PointValueReal(i, values[i])); meanDataSector.Add(new PointValueReal(i, meanvalue)); uclDataSector.Add(new PointValueReal(i, uclValue)); bUpDataSector.Add(new PointValueReal(i, bUpValue)); cUpDataSector.Add(new PointValueReal(i, cUpValue)); lclDataSector.Add(new PointValueReal(i, lclValue)); bDownDataSector.Add(new PointValueReal(i, bDownValue)); cDownDataSector.Add(new PointValueReal(i, cDownValue)); if (usersMinSpec.HasValue) minSpecDataSector.Add(new PointValueReal(i, usersMinSpec.Value)); if (usersMaxSpec.HasValue) maxSpecDataSector.Add(new PointValueReal(i, usersMaxSpec.Value)); if (usersNominalSpec.HasValue) nominalSpecDataSector.Add(new PointValueReal(i, usersNominalSpec.Value)); } function.Add(functionDataSector); meanFunction.Add(meanDataSector); uclFunction.Add(uclDataSector); bUpFunction.Add(bUpDataSector); cUpFunction.Add(cUpDataSector); lclFunction.Add(lclDataSector); bDownFunction.Add(bDownDataSector); cDownFunction.Add(cDownDataSector); minSpecFunction.Add(minSpecDataSector); maxSpecFunction.Add(maxSpecDataSector); nominalSpecFunction.Add(nominalSpecDataSector); var result = new Traces(); result.RealFunctions.Add(uclFunction); result.RealFunctions.Add(bUpFunction); result.RealFunctions.Add(cUpFunction); result.RealFunctions.Add(meanFunction); result.RealFunctions.Add(cDownFunction); result.RealFunctions.Add(bDownFunction); result.RealFunctions.Add(lclFunction); result.RealFunctions.Add(maxSpecFunction); result.RealFunctions.Add(nominalSpecFunction); result.RealFunctions.Add(minSpecFunction); result.RealFunctions.Add(function); var points = new List<PointValueReal>(); foreach (var sector in function) { foreach (var pointValueBase in sector) { points.Add((PointValueReal) pointValueBase); } } measurement.TrendManager.SetData(points.ToArray(), sigma, meanvalue); var Cp = (usersMaxSpec.Value - usersMinSpec.Value)/(6*sigma); var Cpk = Math.Min((usersMaxSpec.Value - meanvalue)/(3*sigma), (meanvalue - usersMinSpec.Value)/(3*sigma)); _graphPlotControl.GraphTitle += "\nCp = " + Cp; _graphPlotControl.GraphTitle += "\nCpk = " + Cpk; return result; }