Ejemplo n.º 1
0
        public void ShowGrid(BindResult r, int num, Spectrum spec, int numOfId)
        {
            this._spec = spec;
            this._num  = num;
            switch (r.MethodType)
            {
            case PredictMethod.Fitting:
                this.ShowfitGrid(r.GetResult <FittingResult>());
                break;

            case PredictMethod.Identify:
                this.ShowIdGrid(r.GetResult <IdentifyResult>(), num, numOfId);
                break;

            case PredictMethod.PLSBind:
                this.ShowPLSGrid(r.GetResult <List <PLS1Result> >());
                break;

            case PredictMethod.Integrate:
                this.ShowItgGrid(r.GetResult <List <IntegrateResultItem> >());
                break;

            default:
                this.gridFit.Visible = false;
                this.gridId.Visible  = false;
                this.gridItg.Visible = false;
                this.gridPLS.Visible = false;
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// API 2,根据混兑比例和切割方案获取数据
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        private OilInfoBEntity getByRate(Specs s, BindResult pr, ref List <PropertyTable> result)
        {
            var r = pr.GetResult <FittingResult>();

            if (r != null)
            {
                var oilApplyBll = new OilApplyAPIBll();

                //切割比率
                var cutOilRates = new List <CutOilRateEntity>();
                foreach (var l in r.Specs)
                {
                    cutOilRates.Add(new CutOilRateEntity()
                    {
                        crudeIndex = l.Spec.UUID,
                        rate       = (float)(l.Rate * 100)
                    });
                }
                var cuts = new List <CutMothedAPIEntity>();
                foreach (var t in this._initP)
                {
                    if (t.Table == PropertyType.NIR)
                    {
                        continue;
                    }
                    cuts.Add(new CutMothedAPIEntity()
                    {
                        ICP  = (int)t.BoilingStart,
                        ECP  = (int)t.BoilingEnd,
                        Name = this.convertEnum(t.Table)
                    });
                }
                try
                {
                    log.Info(string.Join(";", cutOilRates.Select(d => string.Format("{0},{1}", d.crudeIndex, d.rate))));
                    log.Info(string.Join(";", cuts.Select(d => string.Format("ICP={0},ECP={1},Name={2}", d.ICP, d.ECP, d.Name))));
                    var oil = oilApplyBll.GetCutResultAPI(cutOilRates, cuts);
                    if (oil != null)
                    {
                        var lst = oil.OilDataTableBAPIEntityList;
                        convertEntity(lst, ref result, IntegrateModel.GetConfidence(r.TQ, r.MinTQ, r.SQ, r.MinSQ));
                    }
                    return(oil);
                }
                catch (Exception ex)
                {
                    log.Error(ex.ToString());
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// API 1,根据原油名称的切割方案获取数据
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        private OilInfoBEntity getByName(Specs s, BindResult pr, ref List <PropertyTable> result)
        {
            var r = pr.GetResult <IdentifyResult>();

            if (r != null)
            {
                OilInfoBEntity oil         = new OilInfoBEntity(); //新建一条原油
                var            oilApplyBll = new OilApplyAPIBll();
                var            cuts        = new List <CutMothedAPIEntity>();
                foreach (var t in this._initP)
                {
                    if (t.Table == PropertyType.NIR)
                    {
                        continue;
                    }
                    cuts.Add(new CutMothedAPIEntity()
                    {
                        ICP  = (int)t.BoilingStart,
                        ECP  = (int)t.BoilingEnd,
                        Name = this.convertEnum(t.Table)
                    });
                }

                try
                {
                    log.Info(r.Items.First().Spec.UUID);
                    log.Info(string.Join(";", cuts.Select(d => string.Format("ICP={0},ECP={1},Name={2}", d.ICP, d.ECP, d.Name))));
                    oil = oilApplyBll.GetCutResultAPI(r.Items.First().Spec.UUID, cuts);
                    if (oil != null)
                    {
                        var lst = oil.OilDataTableBAPIEntityList;
                        convertEntity(lst, ref result, IntegrateModel.GetConfidence(r.Items.First().TQ, r.MinTQ, r.Items.First().SQ, r.MinSQ));
                        //写入值信度
                    }
                    else
                    {
                        log.ErrorFormat("GetCutResultAPI({0})", r.Items.First().Spec.UUID);
                    }
                    return(oil);
                }
                catch (Exception ex)
                {
                    log.Error(ex.ToString());
                }
            }
            return(null);
        }
Ejemplo n.º 4
0
        private OilPropertyAPIEntity getPropertyByNIR(BindResult pr)
        {
            if (pr == null)
            {
                return(null);
            }
            switch (pr.MethodType)
            {
            case PredictMethod.Integrate:
                var itgr = pr.GetResult <List <IntegrateResultItem> >();
                if (itgr != null)
                {
                    var ps = new OilPropertyAPIEntity();
                    //对9个性质进行赋值
                    foreach (var c in itgr)
                    {
                        switch (c.Comp.Name)
                        {
                        case "残炭":
                            ps.CCR = (float)c.Comp.PredictedValue;
                            break;

                        case "密度(20℃)":        //这里可能会出问题
                            ps.D20 = (float)c.Comp.PredictedValue;
                            break;

                        case "氮含量":
                            ps.N2 = (float)c.Comp.PredictedValue;
                            break;

                        case "蜡含量":
                            ps.WAX = (float)c.Comp.PredictedValue;
                            break;

                        case "硫含量":
                            ps.SUL = (float)c.Comp.PredictedValue;
                            break;

                        case "TBP140":
                            ps.TWY140 = (float)c.Comp.PredictedValue;
                            break;

                        case "TBP180":
                            ps.TWY180 = (float)c.Comp.PredictedValue;
                            break;

                        case "TBP240":
                            ps.TWY240 = (float)c.Comp.PredictedValue;
                            break;

                        case "TBP350":
                            ps.TWY350 = (float)c.Comp.PredictedValue;
                            break;

                        default:
                            break;
                        }
                    }
                    var clst    = itgr.Select(d => d.Comp).ToList();
                    var tbptemp = this.getTBPdata(clst, 140);
                    if (!double.IsNaN(tbptemp))
                    {
                        ps.TWY140 = (float)tbptemp;
                    }
                    tbptemp = this.getTBPdata(clst, 180);
                    if (!double.IsNaN(tbptemp))
                    {
                        ps.TWY180 = (float)tbptemp;
                    }
                    tbptemp = this.getTBPdata(clst, 240);
                    if (!double.IsNaN(tbptemp))
                    {
                        ps.TWY240 = (float)tbptemp;
                    }
                    tbptemp = this.getTBPdata(clst, 350);
                    if (!double.IsNaN(tbptemp))
                    {
                        ps.TWY350 = (float)tbptemp;
                    }
                    return(ps);
                }
                break;

            case PredictMethod.PLSBind:
                var r = pr.GetResult <List <PLS1Result> >();
                if (r != null)
                {
                    var ps = new OilPropertyAPIEntity();
                    //对9个性质进行赋值
                    foreach (var c in r)
                    {
                        switch (c.Comp.Name)
                        {
                        case "残炭":
                            ps.CCR = (float)c.Comp.PredictedValue;
                            break;

                        case "密度(20℃)":        //这里可能会出问题
                            ps.D20 = (float)c.Comp.PredictedValue;
                            break;

                        case "氮含量":
                            ps.N2 = (float)c.Comp.PredictedValue;
                            break;

                        case "蜡含量":
                            ps.WAX = (float)c.Comp.PredictedValue;
                            break;

                        case "硫含量":
                            ps.SUL = (float)c.Comp.PredictedValue;
                            break;

                        case "TBP140":
                            ps.TWY140 = (float)c.Comp.PredictedValue;
                            break;

                        case "TBP180":
                            ps.TWY180 = (float)c.Comp.PredictedValue;
                            break;

                        case "TBP240":
                            ps.TWY240 = (float)c.Comp.PredictedValue;
                            break;

                        case "TBP350":
                            ps.TWY350 = (float)c.Comp.PredictedValue;
                            break;

                        default:
                            break;
                        }
                    }
                    var clst    = r.Select(d => d.Comp).ToList();
                    var tbptemp = this.getTBPdata(clst, 140);
                    if (!double.IsNaN(tbptemp))
                    {
                        ps.TWY140 = (float)tbptemp;
                    }
                    tbptemp = this.getTBPdata(clst, 180);
                    if (!double.IsNaN(tbptemp))
                    {
                        ps.TWY180 = (float)tbptemp;
                    }
                    tbptemp = this.getTBPdata(clst, 240);
                    if (!double.IsNaN(tbptemp))
                    {
                        ps.TWY240 = (float)tbptemp;
                    }
                    tbptemp = this.getTBPdata(clst, 350);
                    if (!double.IsNaN(tbptemp))
                    {
                        ps.TWY350 = (float)tbptemp;
                    }
                    return(ps);
                }
                break;
            }
            return(null);
        }