예제 #1
0
 public void initXSPCFunctions()
 {
     SPCFunctions sPCFunctions = new SPCFunctions();
     sPCFunctions.setHistogramGroupNumber(this.SamplesByGroup.Length);
     this.MeaninSampleGroup = new double[this.SamplesByGroup.Length];
     this.RangeinSampleGroup = new double[this.SamplesByGroup.Length];
     this.StddevSampleGroup = new double[this.SamplesByGroup.Length];
     for (int i = 0; i < this.SamplesByGroup.Length; i++)
     {
         sPCFunctions.setSamples(this.SamplesByGroup[i]);
         this.MeaninSampleGroup[i] = sPCFunctions.SPCMean();
         this.RangeinSampleGroup[i] = sPCFunctions.SPCRange();
         this.StddevSampleGroup[i] = sPCFunctions.SPCStdDev();
     }
     sPCFunctions.setSamples(this.MeaninSampleGroup);
     this.Mean = sPCFunctions.SPCMean();
     sPCFunctions.setSamples(this.RangeinSampleGroup);
     this.Range = sPCFunctions.SPCRange();
     sPCFunctions.setSamples(this.StddevSampleGroup);
     this.Stddev = sPCFunctions.SPCStdDev();
     this.XrCL = this.Mean;
     double CLdiffer = (3.0 / (Math.Sqrt((double) this.SamplesByGroup[0].Length) * this.d2[this.SamplesByGroup[0].Length - 1])) * this.Range;
     this.XrUCL = this.Mean + CLdiffer;
     this.XrLCL = this.Mean - CLdiffer;
     this.RangeCL = this.Range;
     double d3byd2 = (3.0 * this.d3[this.SamplesByGroup[0].Length - 1]) / this.d2[this.SamplesByGroup[0].Length - 1];
     this.RangeUCL = (1.0 + d3byd2) * this.Range;
     this.RangeLCL = Math.Max((double) ((1.0 - d3byd2) * this.Range), (double) 0.0);
     this.XsCL = this.Mean;
     double a3s = (3.0 / (Math.Sqrt((double) this.SamplesByGroup[0].Length) * this.c4[this.SamplesByGroup[0].Length - 1])) * this.Stddev;
     this.XsUCL = this.Mean + a3s;
     this.XsLCL = this.Mean - a3s;
     this.StddevCL = this.Stddev;
     double b3b4 = (3.0 * Math.Sqrt(1.0 - Math.Pow(this.c4[this.SamplesByGroup[0].Length - 1], 2.0))) / this.c4[this.SamplesByGroup[0].Length - 1];
     this.StddevUCL = this.Stddev * (1.0 + b3b4);
     this.StddevLCL = Math.Max((double) (this.Stddev * (1.0 - b3b4)), (double) 0.0);
 }
예제 #2
0
        private void SPCFunction(HttpContext context)
        {
            DataTable spcindex = new DataTable();

            if (spcindex.Columns.Count < 1)
            {
                DataColumn fds = new DataColumn("Source", Type.GetType("System.String"));
                DataColumn fmean = new DataColumn("Mean", Type.GetType("System.String"));
                DataColumn frange = new DataColumn("Range", Type.GetType("System.String"));
                DataColumn fstd = new DataColumn("STD", Type.GetType("System.String"));
                DataColumn fcp = new DataColumn("Cp", Type.GetType("System.String"));
                DataColumn fcpk = new DataColumn("Cpk", Type.GetType("System.String"));
                DataColumn fucl = new DataColumn("Ucl", Type.GetType("System.String"));
                DataColumn flcl = new DataColumn("Lcl", Type.GetType("System.String"));
                spcindex.Dispose();
                spcindex.Columns.Add(fds);
                spcindex.Columns.Add(fstd);
                spcindex.Columns.Add(fmean);
                spcindex.Columns.Add(frange);
                spcindex.Columns.Add(fcp);
                spcindex.Columns.Add(fcpk);
                spcindex.Columns.Add(fucl);
                spcindex.Columns.Add(flcl);
            }

            var parameters = getParameters(context.Request);
            double[] datalist = new double[parameters.Count-4];
            for (int i = 0; i < parameters.Count - 4; i++)
            {
                datalist[i] = Convert.ToDouble(parameters[i+1].Substring(parameters[i+1].IndexOf(',') + 1));

            }
            double USL = Convert.ToDouble(parameters["KEY[USL]"]);
            double LSL =Convert.ToDouble( parameters["KEY[LSL]"]);
            SPCFunctions ar = new SPCFunctions(datalist, USL, LSL);

            double range = ar.SPCMax() - ar.SPCMin();

            DataRow ind = spcindex.NewRow();
            ind["Source"] = parameters["KEY[DS]"];
            ind["Cp"] = ar.SPCCp().ToString("f2");
            ind["Cpk"] = ar.SPCCpk().ToString("f2");
            ind["Mean"] = ar.SPCMean().ToString("f2");
            ind["Range"] = range.ToString("f2");
            ind["STD"] = ar.SPCStdDev().ToString("f2");
            ar.XbarChart();
            ind["Ucl"] = ar.getUCL().ToString("f2");
            ind["Lcl"] = ar.getLCL().ToString("f2");
            spcindex.Rows.Add(ind);
             //       double[][] a = ar.HistogramStepUpperLowerMidCountNormCumu();

            string  result = Dtb2Json(spcindex);
            context.Response.ContentType = "text/plain";
            context.Response.Write(result);
        }