Ejemplo n.º 1
0
        //响应点计算
        public ActionResult ResponsePointCalculate(double fq, double favg, double fsigma, int langlryExpTableId)
        {
            LangleyExperimentTable langlryExpTable = dbDrive.GetLangleyExperimentTable(langlryExpTableId);
            var lr = LangleyPublic.SelectState(langlryExpTable);

            return(Json(lr.ResponsePointCalculate(fq, favg, fsigma).ToString("f6")));
        }
Ejemplo n.º 2
0
        // GET: LangleyExperiment
        public ActionResult LangleyExperiment(int let_id)
        {
            LangleyExperimentTable langlryExpTable = dbDrive.GetLangleyExperimentTable(let_id);

            ViewData["langlryExpTableId"] = langlryExpTable.let_Id;
            ViewData["langLeyStringName"] = langlryExpTable.let_ProductName;
            ViewData["langLeyNameString"] = LangleyPublic.DistributionState(langlryExpTable) + "/" + LangleyPublic.Correction(langlryExpTable.let_Correction);
            return(View());
        }
Ejemplo n.º 3
0
        //撤销
        public ActionResult RevocationData(int id, int langlryExpTableId)
        {
            LangleyDataTable        langleyDataTable  = new LangleyDataTable();
            List <LangleyDataTable> langleyDataTables = dbDrive.GetAllLangleyDataTable(langlryExpTableId);

            langleyDataTable.ldt_Id = langleyDataTables[langleyDataTables.Count - 1].ldt_Id;
            bool isTure    = dbDrive.Delete(langleyDataTable);
            var  xOrVArray = LangleyPublic.XAndVArrays(langleyDataTables);

            string[] value = { isTure.ToString(), (xOrVArray.xArray.Length - 1).ToString(), xOrVArray.xArray[xOrVArray.xArray.Length - 2].ToString() };
            return(Json(value));
        }
Ejemplo n.º 4
0
        //批量区间估计
        public ActionResult BatchIntervalCalculation(double BatchConfidenceLevel, double yMin, double yMax, int Y_Axis, int intervalTypeSelection, double favg, double fsigma, int langlryExpTableId)
        {
            LangleyExperimentTable  langlryExpTable = dbDrive.GetLangleyExperimentTable(langlryExpTableId);
            List <LangleyDataTable> ldts            = dbDrive.GetAllLangleyDataTable(langlryExpTable.let_Id);

            ldts.RemoveRange(ldts.Count - 1, 1);
            var xOrVArray = LangleyPublic.XAndVArrays(ldts);

            xOrVArray.vArray = LangleyPublic.IsFlipTheResponse(langlryExpTable, xOrVArray.vArray);
            var lr  = LangleyPublic.SelectState(langlryExpTable);
            var srd = lr.BatchIntervalCalculate(yMax, yMin, Y_Axis, BatchConfidenceLevel, favg, fsigma, xOrVArray.xArray, xOrVArray.vArray, intervalTypeSelection);

            LangleyPublic.sideReturnData = srd;
            LangleyPublic.aArray.Clear();
            LangleyPublic.bArray.Clear();
            LangleyPublic.cArray.Clear();
            double ceiling = srd.responsePoints.Min();
            double lower   = srd.responsePoints.Max();

            for (int i = 0; i < srd.responseProbability.Length; i++)
            {
                LangleyPublic.aArray.Add("[" + srd.responsePoints[i] + "," + srd.responseProbability[i] + "]");
                if (double.IsInfinity(srd.Y_Ceilings[i]))
                {
                    LangleyPublic.bArray.Add("[" + lower + "," + srd.responseProbability[i] + "]");
                }
                else
                {
                    LangleyPublic.bArray.Add("[" + srd.Y_Ceilings[i] + "," + srd.responseProbability[i] + "]");
                }
                if (double.IsInfinity(srd.Y_LowerLimits[i]))
                {
                    LangleyPublic.cArray.Add("[" + ceiling + "," + srd.responseProbability[i] + "]");
                }
                else
                {
                    LangleyPublic.cArray.Add("[" + srd.Y_LowerLimits[i] + "," + srd.responseProbability[i] + "]");
                }
            }
            if (intervalTypeSelection == 0)
            {
                LangleyPublic.incredibleIntervalType = "拟然比区间计算-单侧置信区间";
            }
            else
            {
                LangleyPublic.incredibleIntervalType = "拟然比区间计算-双侧置信区间";
            }
            LangleyPublic.incredibleLevelName = BatchConfidenceLevel.ToString();
            return(Json(true));
        }
Ejemplo n.º 5
0
        public ActionResult PointCalculate(int langlryExpTableId)
        {
            LangleyExperimentTable  langlryExpTable = dbDrive.GetLangleyExperimentTable(langlryExpTableId);
            List <LangleyDataTable> ldts            = dbDrive.GetAllLangleyDataTable(langlryExpTable.let_Id);

            ldts.RemoveRange(ldts.Count - 1, 1);
            var xOrVArray = LangleyPublic.XAndVArrays(ldts);
            var lr        = LangleyPublic.SelectState(langlryExpTable);
            LangleyDataTable langleyDataTable = LangleyPublic.UpdateLangleyDataTable(langlryExpTable, lr, xOrVArray.xArray, xOrVArray.vArray, ldts[ldts.Count - 1]);

            langleyDataTable.ldt_Mean = double.Parse(langleyDataTable.ldt_Mean.ToString("f13"));
            string[] value = { lr.Precs(langleyDataTable.ldt_Mean, langleyDataTable.ldt_StandardDeviation)[0].ToString("f6"), lr.Precs(langleyDataTable.ldt_Mean, langleyDataTable.ldt_StandardDeviation)[1].ToString("f6"), langleyDataTable.ldt_Mean.ToString("f6"), langleyDataTable.ldt_StandardDeviation.ToString("f6"), lr.GetConversionNumber(xOrVArray.vArray), (xOrVArray.xArray.Length).ToString(), lr.GetNM(xOrVArray.xArray, xOrVArray.vArray) };
            dbDrive.Update(langleyDataTable);
            return(Json(value));
        }
Ejemplo n.º 6
0
        public ActionResult ResponsePointIntervalEstimate(double reponseProbability2, double confidenceLevel2, double cjl, double favg, double fsigma, int langlryExpTableId)
        {
            LangleyExperimentTable  langlryExpTable = dbDrive.GetLangleyExperimentTable(langlryExpTableId);
            List <LangleyDataTable> ldts            = dbDrive.GetAllLangleyDataTable(langlryExpTable.let_Id);

            ldts.RemoveRange(ldts.Count - 1, 1);
            var xOrVArray = LangleyPublic.XAndVArrays(ldts);

            xOrVArray.vArray = LangleyPublic.IsFlipTheResponse(langlryExpTable, xOrVArray.vArray);
            var lr  = LangleyPublic.SelectState(langlryExpTable);
            var ies = lr.ResponsePointIntervalEstimate(xOrVArray.xArray, xOrVArray.vArray, reponseProbability2, confidenceLevel2, cjl, favg, fsigma);

            string[] value = { "(" + ies[0].Confidence.Down.ToString("f6") + "," + ies[0].Confidence.Up.ToString("f6") + ")", "(" + ies[0].Mu.Down.ToString("f6") + "," + ies[0].Mu.Up.ToString("f6") + ")", "(" + ies[0].Sigma.Down.ToString("f6") + "," + ies[0].Sigma.Up.ToString("f6") + ")", "(" + ies[1].Confidence.Down.ToString("f6") + "," + ies[1].Confidence.Up.ToString("f6") + ")", "(" + ies[1].Mu.Down.ToString("f6") + "," + ies[1].Mu.Up.ToString("f6") + ")", "(" + ies[1].Sigma.Down.ToString("f6") + "," + ies[1].Sigma.Up.ToString("f6") + ")" };
            return(Json(value));
        }
        //名称、时间查询
        public ActionResult Langley_query(string productName, string startTime, string endTime)
        {
            List <LangleyExperimentTable> lets = new List <LangleyExperimentTable>();

            if (startTime != "" && endTime != "")
            {
                DateTime st = Convert.ToDateTime(startTime);
                DateTime et = Convert.ToDateTime(endTime);
                lets = dbDrive.QueryLangleyExperimentTable(productName, st, et.AddDays(1), LangleyPublic.adminId);
            }
            else
            {
                lets = dbDrive.QueryLangleyExperimentTable(productName, LangleyPublic.adminId);
            }
            return(Json(new { code = 0, msg = "", count = lets.Count, data = LangleyPublic.Langley_lists(dbDrive, lets) }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 8
0
        public ActionResult InsertData(string response, string sq, int langlryExpTableId)
        {
            LangleyExperimentTable  langlryExpTable   = dbDrive.GetLangleyExperimentTable(langlryExpTableId);
            List <LangleyDataTable> langleyDataTables = dbDrive.GetAllLangleyDataTable(langlryExpTable.let_Id);
            var xOrVArray = LangleyPublic.XAndVArrays(langleyDataTables);

            if (sq != null && sq != "")
            {
                xOrVArray.xArray[langleyDataTables.Count - 1] = double.Parse(sq);
            }
            if (response != null && response != "")
            {
                xOrVArray.vArray[langleyDataTables.Count - 1] = int.Parse(response);
            }
            else
            {
                xOrVArray.vArray[langleyDataTables.Count - 1] = 0;
            }
            var lr = LangleyPublic.SelectState(langlryExpTable);

            dbDrive.Update(LangleyPublic.UpdateLangleyDataTable(langlryExpTable, lr, xOrVArray.xArray, xOrVArray.vArray, langleyDataTables[langleyDataTables.Count - 1]));

            //增加一条新数据
            double StimulusQuantity = lr.CalculateStimulusQuantity(xOrVArray.xArray, xOrVArray.vArray, langlryExpTable.let_StimulusQuantityCeiling, langlryExpTable.let_StimulusQuantityFloor, langlryExpTable.let_PrecisionInstruments);
            var    isTrue           = dbDrive.Insert(LangleyPublic.LangleyDataTables(langlryExpTableId, dbDrive, double.Parse(StimulusQuantity.ToString("f6"))));
            var    xOrVArray2       = LangleyPublic.XAndVArrays(dbDrive.GetAllLangleyDataTable(langlryExpTable.let_Id));

            xOrVArray2.vArray = LangleyPublic.IsFlipTheResponse(langlryExpTable, xOrVArray2.vArray);
            if (langlryExpTable.let_FlipTheResponse == 1)
            {
                for (int i = 0; i < xOrVArray2.vArray.Length - 1; i++)
                {
                    if (xOrVArray2.vArray[i] == 0)
                    {
                        xOrVArray2.vArray[i] = 1;
                    }
                    else
                    {
                        xOrVArray2.vArray[i] = 0;
                    }
                }
            }
            string[] value = { isTrue.ToString(), (xOrVArray2.xArray.Length - 1).ToString(), lr.GetNM(xOrVArray2.xArray, xOrVArray2.vArray), StimulusQuantity.ToString() };
            return(Json(value));
        }
Ejemplo n.º 9
0
        public JsonResult LanglieParameterSettingsJson()
        {
            double[]               xArray = new double[] { };
            int[]                  vArray = new int[] { };
            var                    str    = new StreamReader(Request.InputStream);
            var                    stream = str.ReadToEnd();
            JavaScriptSerializer   js     = new JavaScriptSerializer();
            LangleyExperimentTable let    = js.Deserialize <LangleyExperimentTable>(stream);

            let.let_RecordEmployeeId = LangleyPublic.adminId;
            let.let_ExperimentalDate = DateTime.Now;
            dbDrive.Insert(let);
            double sq     = LangleyPublic.SelectState(let).CalculateStimulusQuantity(xArray, vArray, let.let_StimulusQuantityCeiling, let.let_StimulusQuantityFloor, let.let_PrecisionInstruments);
            bool   isTure = dbDrive.Insert(LangleyPublic.LangleyDataTables(let.let_Id, dbDrive, sq));
            string name   = let.let_ProductName;

            string[] value = { isTure.ToString(), let.let_Id.ToString(), name };
            return(Json(value));
        }
Ejemplo n.º 10
0
        //获取let_id全部兰利法表并分页显示
        public ActionResult GetAllLangleys(int id, int page = 1, int limit = 20)
        {
            LangleyExperimentTable  langlryExpTable = dbDrive.GetLangleyExperimentTable(id);
            List <LangleyDataTable> ldts            = dbDrive.GetAllLangleyDataTable(id);
            List <LangleyDataTable> PagesLdt        = new List <LangleyDataTable>();
            int last  = ldts.Count - (page - 1) * limit;
            int first = 0;

            if (page * limit < ldts.Count)
            {
                first = ldts.Count - page * limit;
            }
            for (int i = first; i < last; i++)
            {
                PagesLdt.Add(ldts[i]);
            }
            if (page == 1)
            {
                PagesLdt.RemoveRange(PagesLdt.Count - 1, 1);
            }
            return(Json(new { code = 0, msg = "", count = ldts.Count - 1, data = LangleyPublic.Langleys(langlryExpTable, PagesLdt, first, ldts.Count) }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 11
0
        //修改分析参数
        public JsonResult UpdateParameter()
        {
            var str    = new StreamReader(Request.InputStream);
            var stream = str.ReadToEnd();
            JavaScriptSerializer   js  = new JavaScriptSerializer();
            LangleyExperimentTable let = dbDrive.GetLangleyExperimentTable(js.Deserialize <LangleyExperimentTable>(stream).let_Id);

            let.let_DistributionState = js.Deserialize <LangleyExperimentTable>(stream).let_DistributionState;
            let.let_Correction        = js.Deserialize <LangleyExperimentTable>(stream).let_Correction;
            dbDrive.Update(let);
            List <LangleyDataTable> ldts = dbDrive.GetAllLangleyDataTable(let.let_Id);

            ldts.RemoveRange(ldts.Count - 1, 1);
            var xOrVArray = LangleyPublic.XAndVArrays(ldts);
            var lr        = LangleyPublic.SelectState(let);
            LangleyDataTable langleyDataTable = new LangleyDataTable();
            bool             isTure           = false;

            for (int i = 1; i <= ldts.Count; i++)
            {
                double[] xArray = new double[i];
                int[]    vArray = new int[i];
                for (int j = 0; j < i; j++)
                {
                    xArray[j] = xOrVArray.xArray[j];
                    vArray[j] = xOrVArray.vArray[j];
                }
                langleyDataTable = LangleyPublic.UpdateLangleyDataTable(let, lr, xArray, vArray, ldts[i - 1]);
                isTure           = dbDrive.Update(langleyDataTable);
                if (isTure == false)
                {
                    break;
                }
            }
            string[] value = { isTure.ToString(), lr.Precs(langleyDataTable.ldt_Mean, langleyDataTable.ldt_StandardDeviation)[0].ToString("f6"), lr.Precs(langleyDataTable.ldt_Mean, langleyDataTable.ldt_StandardDeviation)[1].ToString("f6"), langleyDataTable.ldt_Mean.ToString("f6"), langleyDataTable.ldt_StandardDeviation.ToString("f6") };
            return(Json(value));
        }
        //获取全部的兰利法实验并分页显示(前台带参访问)
        public ActionResult GetAllLangleysExperiment(int page = 1, int limit = 20)
        {
            List <LangleyExperimentTable> lets     = dbDrive.GetAllLangleyExperimentTables(LangleyPublic.adminId);
            List <LangleyExperimentTable> PagesLet = new List <LangleyExperimentTable>();
            int last  = lets.Count - (page - 1) * limit;
            int first = 0;

            if (page * limit < lets.Count)
            {
                first = lets.Count - page * limit;
            }
            for (int i = first; i < last; i++)
            {
                PagesLet.Add(lets[i]);
            }
            return(Json(new { code = 0, msg = "", fenye = 5, count = lets.Count, data = LangleyPublic.Langley_lists(dbDrive, PagesLet, first) }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 13
0
        public static string LangleyFreeSpireExcel(LangleyExperimentTable langlryExpTable, List <LangleyDataTable> ldts)
        {
            var lr = LangleyPublic.SelectState(langlryExpTable);

            ldts.RemoveRange(ldts.Count - 1, 1);
            var       xOrVArray  = LangleyPublic.XAndVArrays(ldts);
            Workbook  book       = new Workbook();
            Worksheet sheet      = book.Worksheets[0];
            var       iCellcount = 1;

            //1.设置表头
            sheet.Range[1, iCellcount++].Text = "兰利法感度试验数据记录及处理结果";
            sheet.Range["A1:H1"].Merge();
            sheet.Range["A1:H1"].Style.HorizontalAlignment = HorizontalAlignType.Center;
            sheet.Range["E2"].Text    = "打印时间";
            sheet.Range["F2:H2"].Text = DateTime.Now.ToString("yyyy-MM-dd");
            sheet.Range["F2:H2"].Merge();
            sheet.Range["A3"].Text    = "样本名称";
            sheet.Range["B3:D3"].Text = langlryExpTable.let_ProductName;
            sheet.Range["B3:D3"].Merge();
            sheet.Range["E3"].Text    = "试验时间";
            sheet.Range["F3:H3"].Text = langlryExpTable.let_ExperimentalDate.ToString("yyyy-MM-dd HH:mm");
            sheet.Range["F3:H3"].Merge();
            sheet.Range["A4"].Text    = "实验数量";
            sheet.Range["B4"].Text    = ldts.Count.ToString();
            sheet.Range["C4"].Text    = "分辨率";
            sheet.Range["D4"].Text    = langlryExpTable.let_PrecisionInstruments.ToString();
            sheet.Range["E4"].Text    = "发布选择";
            sheet.Range["F4:H4"].Text = LangleyPublic.DistributionState(langlryExpTable);
            sheet.Range["F4:H4"].Merge();
            sheet.Range["A5"].Text    = "刺激量上限";
            sheet.Range["B5"].Text    = langlryExpTable.let_StimulusQuantityCeiling.ToString();
            sheet.Range["C5"].Text    = "刺激量下限";
            sheet.Range["D5"].Text    = langlryExpTable.let_StimulusQuantityFloor.ToString();
            sheet.Range["E5"].Text    = "标准差修正";
            sheet.Range["F5"].Text    = langlryExpTable.let_Correction == 0 ? "是" : "否";
            sheet.Range["G5"].Text    = "翻转响应";
            sheet.Range["H5"].Text    = langlryExpTable.let_FlipTheResponse == 1 ? "是" : "否";
            sheet.Range["A6"].Text    = "技术条件";
            sheet.Range["B6:H6"].Text = langlryExpTable.let_TechnicalConditions;
            sheet.Range["B6:H6"].Merge();
            if (langlryExpTable.let_FlipTheResponse == 0)
            {
                if (langlryExpTable.let_Correction == 1)
                {
                    sheet.Range["A7:H7"].Text = "标记:发火:“1”,不发火:“0” 点估计标准差计算结果为最大拟然估计结果";
                }
                else
                {
                    sheet.Range["A7:H7"].Text = "标记:发火:“1”,不发火:“0” 点估计标准差计算结果为按照GJB377修正结果";
                }
            }
            else
            if (langlryExpTable.let_Correction == 1)
            {
                sheet.Range["A7:H7"].Text = "标记:发火:“0”,不发火:“1” 点估计标准差计算结果为最大拟然估计结果";
            }
            else
            {
                sheet.Range["A7:H7"].Text = "标记:发火:“0”,不发火:“1” 点估计标准差计算结果为按照GJB377修正结果";
            }
            TableHead(sheet);
            int count = 9;

            for (int i = 0; i < ldts.Count; i++)
            {
                sheet.Range["A" + count + ""].Text = (i + 1).ToString();
                sheet.Range["B" + count + ":C" + count + ""].Text = ldts[i].ldt_StimulusQuantity.ToString();
                sheet.Range["B" + count + ":C" + count + ""].Merge();
                sheet.Range["D" + count + ""].Text = ldts[i].ldt_Response.ToString();
                sheet.Range["E" + count + ":F" + count + ""].Text = ldts[i].ldt_Mean.ToString();
                sheet.Range["E" + count + ":F" + count + ""].Merge();
                sheet.Range["G" + count + ":H" + count + ""].Text = ldts[i].ldt_StandardDeviation.ToString();
                sheet.Range["G" + count + ":H" + count + ""].Merge();
                count++;
            }
            sheet.Range["A" + count + ""].Text = "点估计:";
            sheet.Range["B" + count + ":D" + count + ""].Text = "均值:" + ldts[ldts.Count - 1].ldt_Mean + "";
            sheet.Range["B" + count + ":D" + count + ""].Merge();
            sheet.Range["E" + count + ":H" + count + ""].Text = "标准差:" + ldts[ldts.Count - 1].ldt_StandardDeviation + "";
            sheet.Range["E" + count + ":H" + count + ""].Merge();
            count++;
            var ignition99   = LangleyIgnition(ldts, lr, 0.99);
            var ignition1    = LangleyIgnition(ldts, lr, 0.01);
            var ignition999  = LangleyIgnition(ldts, lr, 0.999);
            var ignition01   = LangleyIgnition(ldts, lr, 0.001);
            var ignition9999 = LangleyIgnition(ldts, lr, 0.9999);
            var ignition001  = LangleyIgnition(ldts, lr, 0.0001);

            count = PointCalculation(count, ignition99, ignition1, ignition999, ignition01, ignition9999, ignition001, sheet);
            var ie   = lr.GetIntervalEstimationValue(lr.DoubleSideEstimation(xOrVArray.xArray, xOrVArray.vArray, 0.999, 0.8));
            var ie01 = lr.GetIntervalEstimationValue(lr.DoubleSideEstimation(xOrVArray.xArray, xOrVArray.vArray, 0.001, 0.8));

            count = IntervalEstimation(count, sheet, ie, ie01, 0.8);

            ie    = lr.GetIntervalEstimationValue(lr.DoubleSideEstimation(xOrVArray.xArray, xOrVArray.vArray, 0.999, 0.95));
            ie01  = lr.GetIntervalEstimationValue(lr.DoubleSideEstimation(xOrVArray.xArray, xOrVArray.vArray, 0.001, 0.95));
            count = IntervalEstimation(count, sheet, ie, ie01, 0.95);

            ie    = lr.GetIntervalEstimationValue(lr.DoubleSideEstimation(xOrVArray.xArray, xOrVArray.vArray, 0.999, 0.99));
            ie01  = lr.GetIntervalEstimationValue(lr.DoubleSideEstimation(xOrVArray.xArray, xOrVArray.vArray, 0.001, 0.99));
            count = IntervalEstimation(count, sheet, ie, ie01, 0.99);

            sheet.Range["A3:H" + count + ""].BorderInside(LineStyleType.Thin, Color.Black);
            sheet.Range["A3:H" + count + ""].BorderAround(LineStyleType.Medium, Color.Black);
            count++;
            sheet.Range["B" + count + ""].Text = "复查人";
            sheet.Range["F" + count + ""].Text = "试验人";
            //设置行宽
            sheet.Range["A1:H1"].RowHeight = 20;
            var strFullName = @"C:\兰利法\" + "兰利法" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".xlsx";

            book.SaveToFile(strFullName, ExcelVersion.Version2010);
            return(strFullName);
        }