コード例 #1
0
ファイル: FitResult.cs プロジェクト: Volador17/OilCute
        protected override void addRow(object robj, NIR.Spectrum s, int rowNum, int numofId)
        {
            var r    = (FittingResult)robj;
            var node = new nodeRow(r);

            this.treeGridView1.Nodes.Add(node);
            node.Cells[0].Value = r.SpecOriginal.Name;
            node.Cells[1].Value = "";
            node.Cells[2].Value = r.TQ.ToString("F4");
            node.Cells[3].Value = r.SQ.ToString("F4");
            node.Cells[4].Value = r.Result;
            var cidx = 5;

            foreach (var c in r.SpecOriginal.Components)
            {
                node.Cells[cidx].Value = double.IsNaN(c.ActualValue) ? "" : c.ActualValue.ToString(string.Format("F{0}", c.Eps));
                cidx++;
            }
            node.HeaderCell.Value = rowNum.ToString();
            foreach (var d in r.Specs)
            {
                var ds = new List <object>();
                ds.Add(d.Spec.Name);
                ds.Add(d.Rate.ToString("F4"));
                ds.Add("");
                ds.Add("");
                ds.Add("");
                foreach (var c in d.Spec.Components)
                {
                    ds.Add(c.ActualValue.ToString(string.Format("F{0}", c.Eps)));
                }
                node.Nodes.Add(ds.ToArray());
            }
        }
コード例 #2
0
        protected override void addRow(object robj, NIR.Spectrum s, int rowNum, int numofId)
        {
            var r    = (IdentifyResult)robj;
            int num  = 5;
            var rtmp = IdentifyModel.GetPredictValue(r, num, numofId);

            var objs = new List <object>();

            objs.Add(rtmp.Spec.Name);
            objs.Add("");
            objs.Add("");
            objs.Add(rtmp.IsId);
            foreach (var c in rtmp.Components)
            {
                objs.Add(double.IsNaN(c.PredictedValue) ? "" : c.PredictedValue.ToString(c.EpsFormatString));
            }
            var node = this.treeGridView1.Nodes.Add(objs.ToArray());

            node.HeaderCell.Value = rowNum.ToString();
            for (int i = 0; i < num; i++)
            {
                if (rtmp.Items.Length > i)
                {
                    var row = new nodeRow(rtmp.Items[i]);
                    node.Nodes.Add(row);
                    row.Cells[0].Value = rtmp.Items[i].Spec.Name;
                    row.Cells[1].Value = rtmp.Items[i].TQ.ToString("F4");
                    row.Cells[2].Value = rtmp.Items[i].SQ.ToString("F4");
                    row.Cells[3].Value = rtmp.Items[i].Result ? "Yes" : "No";
                    var cidx = 4;
                    foreach (var c in rtmp.Items[i].Spec.Components)
                    {
                        row.Cells[cidx].Value = double.IsNaN(c.ActualValue) ? "" : c.ActualValue.ToString(string.Format("F{0}", c.Eps));
                        cidx++;
                    }
                }
            }
        }
コード例 #3
0
ファイル: IdentifyGridView.cs プロジェクト: Volador17/OilCute
        private void AddResult(IdentifyResult r, int num, int numOfId)
        {
            if (!this._inited)
            {
                this.Init();
            }
            if (r == null || num < 1)
            {
                return;
            }
            this._results.Add(r);
            if (!this._compShow)
            {
                var names = r.Components.Select(c => c.Name).ToArray();
                for (int i = 0; i < names.Length; i++)
                {
                    if (i < this._dColnum - 4 && this.Columns.Count > (4 + i))
                    {
                        this.Columns[4 + i].HeaderText = names[i];
                    }
                    else
                    {
                        this.Columns.Add(new DataGridViewTextBoxColumn()
                        {
                            Width      = 60,
                            HeaderText = names[i],
                            ReadOnly   = true,
                        });
                    }
                }
                this._compShow = true;
            }

            var rtmp = IdentifyModel.GetPredictValue(r, num, numOfId);

            var objs = new List <object>();

            objs.Add(rtmp.Spec.Name);
            objs.Add("");
            objs.Add("");
            objs.Add(rtmp.IsId);
            foreach (var c in rtmp.Components)
            {
                objs.Add(double.IsNaN(c.ActualValue) ? "" : c.ActualValue.ToString(string.Format("F{0}", c.Eps)));
            }
            TreeGridNode node;

            if (this.Nodes.Count <= (this._results.Count - 1) * 3)
            {
                node = this.Nodes.Add(objs.ToArray());
            }
            else
            {
                node = this.Nodes[(this._results.Count - 1) * 3];
                for (int i = 0; i < objs.Count; i++)
                {
                    if (node.Cells.Count > i)
                    {
                        node.Cells[i].Value = objs[i];
                    }
                }
            }
            for (int i = 0; i < num; i++)
            {
                if (rtmp.Items.Length > i)
                {
                    var row = new nodeRow(rtmp.Items[i]);
                    node.Nodes.Add(row);
                    row.Cells[0].Value = rtmp.Items[i].Spec.Name;
                    row.Cells[1].Value = rtmp.Items[i].TQ.ToString("F4");
                    row.Cells[2].Value = rtmp.Items[i].SQ.ToString("F4");
                    row.Cells[3].Value = rtmp.Items[i].Result ? "Yes" : "No";
                    var cidx = 4;
                    foreach (var c in rtmp.Items[i].Spec.Components)
                    {
                        row.Cells[cidx].Value = double.IsNaN(c.ActualValue) ? "" : c.ActualValue.ToString(string.Format("F{0}", c.Eps));
                        cidx++;
                    }
                }
            }

            //预测值
            objs = new List <object>();
            objs.Add("预测值");
            objs.Add("");
            objs.Add("");
            objs.Add("");
            foreach (var c in rtmp.Components)
            {
                objs.Add(double.IsNaN(c.PredictedValue) ? "" : c.PredictedValue.ToString(string.Format("F{0}", c.Eps)));
            }

            if (this.Nodes.Count <= (this._results.Count - 1) * 3 + 1)
            {
                this.Nodes.Add(objs.ToArray());
            }
            else
            {
                var tn = this.Nodes[(this._results.Count - 1) * 3 + 1];
                for (int i = 0; i < objs.Count; i++)
                {
                    if (tn.Cells.Count > i)
                    {
                        tn.Cells[i].Value = objs[i];
                    }
                }
            }

            //偏差
            objs = new List <object>();
            objs.Add("偏差");
            objs.Add("");
            objs.Add("");
            objs.Add("");
            if (rtmp.Components != null && rtmp.Components.Count > 0)
            {
                foreach (var c in rtmp.Components)
                {
                    objs.Add(double.IsNaN(c.Error) ? "" : c.Error.ToString(string.Format("F{0}", c.Eps)));
                }
            }
            if (this.Nodes.Count <= (this._results.Count - 1) * 3 + 2)
            {
                this.Nodes.Add(objs.ToArray());
            }
            else
            {
                var tn = this.Nodes[(this._results.Count - 1) * 3 + 2];
                for (int i = 0; i < objs.Count; i++)
                {
                    if (tn.Cells.Count > i)
                    {
                        tn.Cells[i].Value = objs[i];
                    }
                }
            }
        }
コード例 #4
0
        private void AddResult(FittingResult r)
        {
            if (!this._inited)
            {
                this.Init();
            }
            if (r == null)
            {
                return;
            }
            this._results.Add(r);
            if (!this._compShow)
            {
                var names = r.FitSpec.Components.Select(c => c.Name).ToArray();
                for (int i = 0; i < names.Length; i++)
                {
                    if (i < this._dColnum - 5 && this.Columns.Count > (5 + i))
                    {
                        this.Columns[5 + i].HeaderText = names[i];
                    }
                    else
                    {
                        this.Columns.Add(new DataGridViewTextBoxColumn()
                        {
                            Width      = 60,
                            HeaderText = names[i],
                            ReadOnly   = true,
                        });
                    }
                }
                this._compShow = true;
            }



            nodeRow node;

            if (this.Nodes.Count <= (this._results.Count - 1) * 3)
            {
                node = new nodeRow(r);
                this.Nodes.Add(node);
            }
            else
            {
                node        = this.Nodes[(this._results.Count - 1) * 3] as nodeRow;
                node.Result = r;
            }
            node.Cells[0].Value = r.SpecOriginal.Name;
            node.Cells[1].Value = "";
            node.Cells[2].Value = r.TQ.ToString("F4");
            node.Cells[3].Value = r.SQ.ToString("F4");
            node.Cells[4].Value = r.Result;
            var cidx = 5;

            foreach (var c in r.SpecOriginal.Components)
            {
                node.Cells[cidx].Value = double.IsNaN(c.ActualValue) ? "" : c.ActualValue.ToString(string.Format("F{0}", c.Eps));
                cidx++;
            }


            foreach (var d in r.Specs)
            {
                var ds = new List <object>();
                ds.Add(d.Spec.Name);
                ds.Add(d.Rate.ToString("F4"));
                ds.Add("");
                ds.Add("");
                ds.Add("");
                foreach (var c in d.Spec.Components)
                {
                    ds.Add(c.ActualValue.ToString(string.Format("F{0}", c.Eps)));
                }
                node.Nodes.Add(ds.ToArray());
            }



            //预测值
            var objs = new List <object>();

            objs.Add("预测值");
            objs.Add("");
            objs.Add("");
            objs.Add("");
            objs.Add("");
            foreach (var c in r.FitSpec.Components)
            {
                objs.Add(double.IsNaN(c.PredictedValue) ? "" : c.PredictedValue.ToString(string.Format("F{0}", c.Eps)));
            }

            if (this.Nodes.Count <= (this._results.Count - 1) * 3 + 1)
            {
                this.Nodes.Add(objs.ToArray());
            }
            else
            {
                var tn = this.Nodes[(this._results.Count - 1) * 3 + 1];
                for (int i = 0; i < objs.Count; i++)
                {
                    if (tn.Cells.Count > i)
                    {
                        tn.Cells[i].Value = objs[i];
                    }
                }
            }

            //偏差

            objs = new List <object>();
            objs.Add("偏差");
            objs.Add("");
            objs.Add("");
            objs.Add("");
            objs.Add("");
            if (r.SpecOriginal.Components != null && r.FitSpec.Components.Count > 0)
            {
                for (int i = 0; i < r.FitSpec.Components.Count; i++)
                {
                    r.SpecOriginal.Components[i].Error = r.SpecOriginal.Components[i].ActualValue - r.FitSpec.Components[i].PredictedValue;

                    objs.Add(double.IsNaN(r.SpecOriginal.Components[i].Error) ? "" : r.SpecOriginal.Components[i].Error.ToString(string.Format("F{0}", r.SpecOriginal.Components[i].Eps)));
                }
            }
            if (this.Nodes.Count <= (this._results.Count - 1) * 3 + 2)
            {
                this.Nodes.Add(objs.ToArray());
            }
            else
            {
                var tn = this.Nodes[(this._results.Count - 1) * 3 + 2];
                for (int i = 0; i < objs.Count; i++)
                {
                    if (tn.Cells.Count > i)
                    {
                        tn.Cells[i].Value = objs[i];
                    }
                }
            }
        }