From 342fa8be89ce72d4a1f87fc857def22b41722dfc Mon Sep 17 00:00:00 2001
From: Shuxia Ning <NingShuxia0927@outlook.com>
Date: 星期日, 03 十一月 2024 14:43:19 +0800
Subject: [PATCH] 曲线 问题修改

---
 WinFrmUI/HStation.WinFrmUI.PhartRelation.Core/99-common/PumpParallelChartDlg.cs |   90 ++++++++++++++++++++++++++++++++-------------
 1 files changed, 64 insertions(+), 26 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.PhartRelation.Core/99-common/PumpParallelChartDlg.cs b/WinFrmUI/HStation.WinFrmUI.PhartRelation.Core/99-common/PumpParallelChartDlg.cs
index 0e2b2f3..1b183c8 100644
--- a/WinFrmUI/HStation.WinFrmUI.PhartRelation.Core/99-common/PumpParallelChartDlg.cs
+++ b/WinFrmUI/HStation.WinFrmUI.PhartRelation.Core/99-common/PumpParallelChartDlg.cs
@@ -7,14 +7,15 @@
         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 +42,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 +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;
+        public event Func<List<XhsSingleResultViewModel>, bool> ReloadDataEvent;
 
 
         /// <summary>
@@ -117,42 +127,42 @@
                 vm.Calc();
                 vm_list.Add(vm);
 
-            }
-             
-          
+            } 
             this.pumpParallelInfoCtrl1.SetBindingData(vm_list, null);
             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)
             {
-                CalcEqPoint(list);
-                this.pumpSerialParallelChart.Add(list);
+                Set(list);
                 return "鏃犳硶璁$畻 骞惰仈鏇茬嚎!";
             }
+            var msg = string.Empty;
             var vm_parallel = CalcParallel(list);
             if (vm_parallel != null)
             {
                 list.Add(vm_parallel);
-                CalcEqPoint(list); 
-                this.pumpSerialParallelChart.Add(list);
-                return string.Empty;
             }
             else
             {
-                return "鏃犳硶璁$畻 骞惰仈鏇茬嚎!";
+                msg = "鏃犳硶璁$畻 骞惰仈鏇茬嚎!";
             }
+            Set(list);
+            return msg;
         }
 
 
@@ -179,34 +189,62 @@
                 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;
             vm_sp.Color = Color.Black;
             vm_sp.IsBp = true;
             vm_sp.IsDefault = true;
-
-            var pt_list = vm_sp.Qp.GetPointList(12);
+             
             return vm_sp;
 
         }
 
-        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);
+            }
+
         }
 
 

--
Gitblit v1.9.3