Shuxia Ning
2024-10-23 47610ca1dd9075a2f0b58cbdb010b66aa95e78d2
WinFrmUI/HStation.WinFrmUI.PhartRelation.Core/99-common/PumpParallelChartDlg.cs
@@ -7,14 +7,14 @@
        public PumpParallelChartDlg()
        {
            InitializeComponent();
            this.Text = "并联分析";
            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);
@@ -41,7 +41,12 @@
            {
                this.pumpParallelInfoCtrl1.SetQueryInfo(id, pt);
            };
            this.pumpParallelInfoCtrl1.SaveEvent +=   () =>
            this.pumpParallelInfoCtrl1.ResetEvent += () =>
            {
                var list = this.pumpParallelInfoCtrl1.GetRunList();
                SetParallel(list);
            };
            this.pumpParallelInfoCtrl1.SaveEvent += () =>
            {
                var run_list = this.pumpParallelInfoCtrl1.GetRunList();
                var list = new List<XhsSingleResultViewModel>();
@@ -59,12 +64,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;
        public event Func<List<XhsSingleResultViewModel>, bool> ReloadDataEvent;
        /// <summary>
@@ -117,9 +126,7 @@
                vm.Calc();
                vm_list.Add(vm);
            }
            }
            this.pumpParallelInfoCtrl1.SetBindingData(vm_list, null);
            var run_list = this.pumpParallelInfoCtrl1.GetRunList();  
            var msg = SetParallel(run_list);
@@ -137,16 +144,14 @@
            } 
            if (list.Count < 2)
            {
                CalcEqPoint(list);
                this.pumpSerialParallelChart.Add(list);
                Set(list);
                return "无法计算 并联曲线!";
            }
            var vm_parallel = CalcParallel(list);
            if (vm_parallel != null)
            {
                list.Add(vm_parallel);
                CalcEqPoint(list);
                this.pumpSerialParallelChart.Add(list);
                Set(list);
                return string.Empty;
            }
            else
@@ -197,16 +202,26 @@
        }
        private  void CalcEqPoint(List<Yw.WinFrmUI.Phart.PumpSerialParallelInfoViewModel> list)
        private void Set(List<Yw.WinFrmUI.Phart.PumpSerialParallelInfoViewModel> list)
        {
            if (list == null || !list.Any())
            {
                this.pumpSerialParallelChart.InitialChartData();
                return;
            }
            double total_flow = list.Sum(x => x.CalcuQ ?? 0);
            double total_head = list.Average(x => x.CalcuH ?? 0);
            this.pumpParallelInfoCtrl1.SetDesignPoint(total_flow, total_head);
            this.pumpSerialParallelChart.Add(list);
            var run_list = list.Where(x => x.RunStatus).ToList();
            if (run_list != null && run_list.Any())
            {
                double total_flow = run_list.Sum(x => x.CalcuQ ?? 0);
                double total_head = run_list.Average(x => x.CalcuH ?? 0);
                total_flow = Math.Round(total_flow, 1);
                total_head = Math.Round(total_head, 1);
                this.pumpParallelInfoCtrl1.SetDesignPoint(total_flow, total_head);
                this.pumpSerialParallelChart.CalcWorkPointByQ(total_flow);
            }
        }