From aabff7f27021a23a433d50a74daba4f3888f82d5 Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期二, 10 十二月 2024 20:43:30 +0800
Subject: [PATCH] 优化工况问题

---
 WinFrmUI/HStation.WinFrmUI.PhartRelation.Core/99-common/PumpVariableSpeedChartDlg.cs |  185 ++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 155 insertions(+), 30 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.PhartRelation.Core/99-common/PumpVariableSpeedChartDlg.cs b/WinFrmUI/HStation.WinFrmUI.PhartRelation.Core/99-common/PumpVariableSpeedChartDlg.cs
index 114cf42..7a95229 100644
--- a/WinFrmUI/HStation.WinFrmUI.PhartRelation.Core/99-common/PumpVariableSpeedChartDlg.cs
+++ b/WinFrmUI/HStation.WinFrmUI.PhartRelation.Core/99-common/PumpVariableSpeedChartDlg.cs
@@ -1,4 +1,6 @@
-锘縰sing Yw.Geometry;
+锘縰sing DevExpress.Spreadsheet;
+using Yw.Geometry;
+using Yw.WinFrmUI.Phart;
 
 namespace HStation.WinFrmUI.PhartRelation
 {
@@ -8,34 +10,55 @@
         {
             InitializeComponent();
             this.Text = "鏇茬嚎瑙嗗浘";
+            this.WindowState = FormWindowState.Maximized;
 
-            this.pumpVariableSpeedInfoCtrl1.SetEvent += (id, qh, qe, qp) =>
+            this.pumpVariableSpeedChart.SetQeVisible(false);
+            this.pumpVariableSpeedInfoCtrl1.SetEvent += (id, hz, ex_ratio, qh, qe, qp) =>
             {
-                this.pumpVariableSpeedChart.Set(id, qh, qe, qp);
-                var list = this.pumpVariableSpeedInfoCtrl1.GetList();
-                SetSerialParallel(list, _design_pt, _is_parallel);
+                this.pumpVariableSpeedChart.Set(id, hz, ex_ratio, qh, qe, qp);
+                ResetSectPointGrid();
             };
 
-            this.pumpVariableSpeedInfoCtrl1.SetInfoEvent += (id, name, color) =>
+            this.pumpVariableSpeedInfoCtrl1.SetInfoEvent += (id, color) =>
             {
-                this.pumpVariableSpeedChart.SetInfo(id, name, color);
+                this.pumpVariableSpeedChart.SetInfo(id, color);
+                ResetSectPointGrid();
+            };
+
+            this.pumpVariableSpeedChart.AddBySpeedEvent += () =>
+            {
+                AddBySpeed();
+                ResetSectPointGrid();
+            };
+
+            this.pumpVariableSpeedChart.AddByHzEvent += () =>
+            {
+                AddByHz();
+                ResetSectPointGrid();
+            };
+
+            this.pumpVariableSpeedChart.AddByPointEvent += () =>
+            {
+                AddByPoint();
+                ResetSectPointGrid();
             };
 
             this.pumpVariableSpeedInfoCtrl1.SetDesignPointEvent += (q, h) =>
             {
                 _design_pt = new Point2d(q, h);
-                this.pumpVariableSpeedChart.SetDesignPt(new Point2d(q, h));
+                this.pumpVariableSpeedChart.SetEquipPt(_design_pt);
+                ResetSectPointGrid();
             };
 
             this.pumpVariableSpeedChart.OnCalcQueryPoint += (id, pt) =>
             {
                 this.pumpVariableSpeedInfoCtrl1.SetQueryInfo(id, pt);
             };
-        }
-         
-        private Yw.Geometry.Point2d _design_pt;
-        private bool _is_parallel;
 
+
+        }
+
+        private Yw.Geometry.Point2d _design_pt;
 
 
         /// <summary>
@@ -46,27 +69,19 @@
         /// <param name="is_parallel"></param>
         /// <returns></returns>
         public string SetBindingData(
-            List<Yw.WinFrmUI.Phart.PumpVariableSpeedViewModel> list,
-            Yw.Geometry.Point2d design_pt,
-            bool is_parallel = true)
+            Yw.WinFrmUI.Phart.PumpVariableSpeedViewModel vm,
+            Yw.Geometry.Point2d design_pt)
         {
-            if (list == null || !list.Any())
-            {
-                return "鏁版嵁涓虹┖!";
-            }
-
-            _is_parallel = is_parallel;
             _design_pt = design_pt;
             var vm_list = new List<Yw.WinFrmUI.Phart.PumpVariableSpeedInfoViewModel>();
-            for (int i = 0; i < list.Count; i++)
-            {
-                var x = list[i];
-                var vm = new Yw.WinFrmUI.Phart.PumpVariableSpeedInfoViewModel(x);
-                vm.Color = GetRandomColor(i);
-                vm.Calc();
-                vm_list.Add(vm);
-            }
 
+            var vm_info = new Yw.WinFrmUI.Phart.PumpVariableSpeedInfoViewModel(vm);
+            vm_info.IsDefault = true;
+            vm_info.Name = $"{vm.CurrentSpeed}({vm.CurrentHz}hz)";
+            vm_info.Color = GetRandomColor(0);
+            vm_info.Calc();
+            vm_list.Add(vm_info);
+             
             this.pumpVariableSpeedInfoCtrl1.SetBindingData(vm_list, _design_pt);
             this.pumpVariableSpeedChart.Add(vm_list, _design_pt);
 
@@ -74,7 +89,117 @@
         }
 
 
-        
+        private void ResetSectPointGrid()
+        {
+            var vm_list = this.pumpVariableSpeedChart.GetVmList();
+            this.pumpVariableSpeedInfoCtrl1.SetSectPoint(vm_list);
+        }
+
+
+        private void AddBySpeed()
+        {
+            var list = this.pumpVariableSpeedInfoCtrl1.GetList();
+            if (list == null || list.Count < 1)
+            {
+                return;
+            }
+            var index = list.Count;
+            var vm_def = list.First();
+            var dlg = new SetValueDlg();
+            dlg.SetBindingData(vm_def.RatedSpeed);
+            dlg.VerifyValueChanged += (speed) =>
+            {
+                var hz = Math.Round(speed / vm_def.RatedSpeed * 50, 1);
+                if (hz > 50 || hz < 10)
+                {
+                    return false;
+                }
+                var vm = new PumpVariableSpeedInfoViewModel(vm_def);
+                vm.Id = Guid.NewGuid().ToString();
+                vm.Name = $"{speed}({hz}hz)";
+                vm.Color = GetRandomColor(index);
+                vm.CurrentHz = hz;
+                vm.CurrentSpeed = speed;
+                vm.Calc();
+
+                this.pumpVariableSpeedInfoCtrl1.Add(vm);
+                this.pumpVariableSpeedChart.Add(vm, _design_pt);
+
+                return true;
+            };
+            dlg.ShowDialog();
+
+        }
+
+        private void AddByHz()
+        {
+
+            var list = this.pumpVariableSpeedInfoCtrl1.GetList();
+            if (list == null || list.Count < 1)
+            {
+                return;
+            }
+            var index = list.Count;
+            var vm_def = list.First();
+            var dlg = new SetValueDlg();
+            dlg.VerifyValueChanged += (hz) =>
+            {
+                if (hz > 50 || hz < 10)
+                {
+                    return false;
+                }
+                var speed = Math.Round(hz / 50 * vm_def.RatedSpeed);
+                var vm = new PumpVariableSpeedInfoViewModel(vm_def);
+                vm.Id = Guid.NewGuid().ToString();
+                vm.Name = $"{speed}({hz}hz)";
+                vm.Color = GetRandomColor(index);
+                vm.CurrentHz = hz;
+                vm.CurrentSpeed = speed;
+                vm.Calc();
+
+                this.pumpVariableSpeedInfoCtrl1.Add(vm);
+                this.pumpVariableSpeedChart.Add(vm, _design_pt);
+
+                return true;
+            };
+            dlg.ShowDialog();
+        }
+
+        private void AddByPoint()
+        {
+            var list = this.pumpVariableSpeedInfoCtrl1.GetList();
+            if (list == null || list.Count < 1)
+            {
+                return;
+            }
+            var index = list.Count;
+            var vm_def = list.First();
+
+            var dlg = new SetPointDlg();
+            dlg.SetBindingData();
+            dlg.VerifyValueChanged += (x, y) =>
+            {
+                var pt = new Yw.Geometry.Point2d(x, y);
+                var speed = PumpCalcHelper.GetSimuValue(vm_def.Qh, pt, vm_def.RatedSpeed);
+                var hz = Math.Round(speed / vm_def.RatedSpeed * 50, 1);
+                if (hz > 50 || hz < 20)
+                {
+                    return false;
+                }
+                var vm = new PumpVariableSpeedInfoViewModel(vm_def);
+                vm.Id = Guid.NewGuid().ToString();
+                vm.Name = $"{speed}({hz}hz)";
+                vm.Color = GetRandomColor(index);
+                vm.CurrentHz = hz;
+                vm.CurrentSpeed = speed;
+                vm.Calc();
+
+                this.pumpVariableSpeedInfoCtrl1.Add(vm);
+                this.pumpVariableSpeedChart.Add(vm, _design_pt);
+                return true;
+            };
+            dlg.ShowDialog();
+        }
 
 
         #region Color

--
Gitblit v1.9.3