Shuxia Ning
2024-11-19 a01861a95ede48fa4979a47b24f21616e362e534
WinFrmUI/HStation.WinFrmUI.PhartRelation.Core/99-common/PumpParallelChartDlg.cs
@@ -9,12 +9,13 @@
            InitializeComponent();
            this.Text = "并联分析";
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
            this.pumpSerialParallelChart.LineVisible = true;
            this.pumpParallelInfoCtrl1.SetEvent += (id, qh, qe, qp) =>
            {
                var list = this.pumpParallelInfoCtrl1.GetRunList();
                SetParallel(list);
            };
            };
            this.pumpParallelInfoCtrl1.SetInfoEvent += (id, name, color) =>
            {
                this.pumpSerialParallelChart.SetInfo(id, name, color);
@@ -46,7 +47,7 @@
                var list = this.pumpParallelInfoCtrl1.GetRunList();
                SetParallel(list);
            };
            this.pumpParallelInfoCtrl1.SaveEvent +=   () =>
            this.pumpParallelInfoCtrl1.SaveEvent += () =>
            {
                var run_list = this.pumpParallelInfoCtrl1.GetRunList();
                var list = new List<XhsSingleResultViewModel>();
@@ -64,12 +65,16 @@
                        list.Add(vm);
                    }
                }
                this.ReloadDataEvent?.Invoke(list);
                var bol = this.ReloadDataEvent?.Invoke(list);
                if (bol.HasValue && bol.Value)
                {
                    this.Close();
                }
            };
        }
        private string _parallel_id = "parallel";
        public event Func<List<XhsSingleResultViewModel>, Task<bool>> ReloadDataEvent;
        private string _parallel_id = "parallel";
        public event Func<List<XhsSingleResultViewModel>, bool> ReloadDataEvent;
        /// <summary>
@@ -95,7 +100,7 @@
                }
                var vm = new Yw.WinFrmUI.Phart.PumpSerialParallelInfoViewModel();
                vm.ID= x.ID;
                vm.ID = x.ID;
                vm.Id = x.ID.ToString();
                vm.Name = x.Name;
                vm.Code = x.Code;
@@ -122,38 +127,42 @@
                vm.Calc();
                vm_list.Add(vm);
            }
            }
            this.pumpParallelInfoCtrl1.SetBindingData(vm_list, null);
            var run_list = this.pumpParallelInfoCtrl1.GetRunList();
            var run_list = this.pumpParallelInfoCtrl1.GetRunList();
            var msg = SetParallel(run_list);
            if (!string.IsNullOrEmpty(msg))
            {
                //TipFormHelper.ShowWarn(msg);
                return msg;
            }
            return string.Empty;
        }
        private string SetParallel(List<Yw.WinFrmUI.Phart.PumpSerialParallelInfoViewModel> list)
        {
            this.pumpSerialParallelChart.Delete();
            if (list == null || !list.Any())
            {
                return "无数据!";
            }
            }
            if (list.Count < 2)
            {
                Set(list);
                return "无法计算 并联曲线!";
            }
            var msg = string.Empty;
            var vm_parallel = CalcParallel(list);
            if (vm_parallel != null)
            {
                list.Add(vm_parallel);
                Set(list);
                return string.Empty;
            }
            else
            {
                return "无法计算 并联曲线!";
                msg = "无法计算 并联曲线!";
            }
            Set(list);
            return msg;
        }
@@ -180,12 +189,31 @@
                return default;
            }
            Yw.Geometry.CubicSpline2d qh = new Yw.Geometry.CubicSpline2d(calc_pt_qh_list);
            Yw.Geometry.CubicSpline2d qe = new Yw.Geometry.CubicSpline2d(calc_pt_qe_list);
            Yw.Geometry.CubicSpline2d qp = new Yw.Geometry.CubicSpline2d(calc_pt_qp_list);
            var total_flow = list.Sum(x => x.Qh.MaxX);
            var parallel_flow = calc_pt_qh_list.Max(x => x.X);
            if (total_flow > parallel_flow * 1.05)
            {
                var ex_ratio = total_flow / parallel_flow;
                if (qh != null)
                    qh.MaxX = qh.MaxX * ex_ratio;
                if (qe != null)
                    qe.MaxX = qe.MaxX * ex_ratio;
                if (qp != null)
                    qp.MaxX = qp.MaxX * ex_ratio;
            }
            var vm_sp = new Yw.WinFrmUI.Phart.PumpSerialParallelInfoViewModel();
            vm_sp.Id = _parallel_id;
            vm_sp.Name = line_name;
            vm_sp.Qh = new Yw.Geometry.CubicSpline2d(calc_pt_qh_list);
            vm_sp.Qe = new Yw.Geometry.CubicSpline2d(calc_pt_qe_list);
            vm_sp.Qp = new Yw.Geometry.CubicSpline2d(calc_pt_qp_list);
            vm_sp.Qh = qh;
            vm_sp.Qe = qe;
            vm_sp.Qp = qp;
            vm_sp.QhCalc = vm_sp.Qh;
            vm_sp.QeCalc = vm_sp.Qe;
            vm_sp.QpCalc = vm_sp.Qp;
@@ -193,7 +221,6 @@
            vm_sp.IsBp = true;
            vm_sp.IsDefault = true;
            var pt_list = vm_sp.Qp.GetPointList(12);
            return vm_sp;
        }