From 7d4e037243ed4977a16fa5f1946fd6baeec3c8be Mon Sep 17 00:00:00 2001
From: Shuxia Ning <NingShuxia0927@outlook.com>
Date: 星期一, 02 十二月 2024 17:10:54 +0800
Subject: [PATCH] 图表修改

---
 WinFrmUI/Yw.WinFrmUI.Phart.Core/v3/02-pump/01-single/02-operation/PumpOperationChart.cs |  245 +++++++++++++++++++++++++-----------------------
 1 files changed, 127 insertions(+), 118 deletions(-)

diff --git a/WinFrmUI/Yw.WinFrmUI.Phart.Core/v3/02-pump/01-single/02-operation/PumpOperationChart.cs b/WinFrmUI/Yw.WinFrmUI.Phart.Core/v3/02-pump/01-single/02-operation/PumpOperationChart.cs
index 76bb27e..fcc43d7 100644
--- a/WinFrmUI/Yw.WinFrmUI.Phart.Core/v3/02-pump/01-single/02-operation/PumpOperationChart.cs
+++ b/WinFrmUI/Yw.WinFrmUI.Phart.Core/v3/02-pump/01-single/02-operation/PumpOperationChart.cs
@@ -255,74 +255,75 @@
                 return;
             }
 
-            start_head ??= _coordinate.DispMinH();
-
-            var equip_line_reated = Yw.Geometry.EquipCurveHelper.CalcEquipCurve(_operation_vm.CurveQH, _equip_pt, start_head.Value, out Yw.Geometry.Point2d sect_pt_rated);
-            if (equip_line_reated == null || sect_pt_rated == null)
+            start_head ??= _coordinate.DispMinH(); 
+            var equip_line = Yw.Geometry.EquipCurveHelper.CalcEquipCurve(_operation_vm.CurveQH, _equip_pt, start_head.Value, out Yw.Geometry.Point2d sect_pt);
+            if (equip_line == null || sect_pt == null)
                 return;
 
-            _equip_line = equip_line_reated;
-            _equip_sect_pt = sect_pt_rated;
+            _equip_line = equip_line;
+            _equip_sect_pt = sect_pt;
        
-            double flow_rated = 0, head_rated = 0;
-            double? eff_rated = null, power_rated = null;
-            flow_rated = sect_pt_rated.X;
-            head_rated = _operation_vm.CurveQH.GetPointY(flow_rated);
+            double flow = 0, head = 0;
+            double? eff = null, power = null;
+            flow = sect_pt.X;
+            head = _operation_vm.CurveQH.GetPointY(flow);
             if (_operation_vm.CurveQP != null)
             {
-                power_rated = _operation_vm.CurveQP.GetPointY(flow_rated);
-                eff_rated = PumpCalcHelper.CalculateE(flow_rated, head_rated, power_rated.Value);
+                power = _operation_vm.CurveQP.GetPointY(flow);
+                eff = PumpCalcHelper.CalculateE(flow, head, power.Value);
             }
             else if (_operation_vm.CurveQE != null)
             {
-                eff_rated = _operation_vm.CurveQE.GetPointY(flow_rated);
-                power_rated = PumpCalcHelper.CalculateP(flow_rated, head_rated, eff_rated.Value);
+                eff = _operation_vm.CurveQE.GetPointY(flow);
+                power = PumpCalcHelper.CalculateP(flow, head, eff.Value);
             }
-
-
-            var design_pt_list = new List<PumpDesignPointViewModel>();
-
-            var design_pt_rated = new PumpDesignPointViewModel();
-            design_pt_rated.Id = _operation_vm.Id + "棰濆畾";
-            design_pt_rated.Name = _operation_vm.Name+"(棰濆畾)";
-            design_pt_rated.Q = flow_rated;
-            design_pt_rated.H = head_rated;
-            design_pt_rated.E = eff_rated;
-            design_pt_rated.P = power_rated;
-            design_pt_rated.Hz = _operation_vm.RatedHz;
-            design_pt_rated.N = _operation_vm.RatedN; 
-            design_pt_list.Add(design_pt_rated);
+             
+            var design_pt_list = new List<PumpDesignPointViewModel>
+            {
+                new() {
+                    Id = _operation_vm.Id + "棰濆畾",
+                    Name = _operation_vm.Name + "(棰濆畾)",
+                    Q = flow,
+                    H = head,
+                    E = eff,
+                    P = power,
+                    Hz = _operation_vm.RatedHz,
+                    N = _operation_vm.RatedN
+                }
+            }; 
 
             if (_operation_vm.CurrentStatus)
             {
-                var equip_line = Yw.Geometry.EquipCurveHelper.CalcEquipCurve(_operation_vm.CurrentCurveQH, _equip_pt, start_head.Value, out Yw.Geometry.Point2d sect_pt);
-                if (equip_line == null || sect_pt == null)
+                var current_equip_line = Yw.Geometry.EquipCurveHelper.CalcEquipCurve(_operation_vm.CurrentCurveQH, _equip_pt, start_head.Value, out Yw.Geometry.Point2d current_sect_pt);
+                if ( current_sect_pt == null)
                     return;
-                double flow = 0, head = 0;
-                double? eff = null, power = null;
-                flow = sect_pt.X;
-                head = _operation_vm.CurrentCurveQH.GetPointY(flow);
+                double current_flow = 0, current_head = 0;
+                double? current_eff = null, current_power = null;
+                current_flow = current_sect_pt.X;
+                current_head = _operation_vm.CurrentCurveQH.GetPointY(current_flow);
                 if (_operation_vm.CurrentCurveQP != null)
                 {
-                    power = _operation_vm.CurrentCurveQP.GetPointY(flow);
-                    eff = PumpCalcHelper.CalculateE(flow, head, power.Value);
+                    current_power = _operation_vm.CurrentCurveQP.GetPointY(current_flow);
+                    current_eff = PumpCalcHelper.CalculateE(current_flow, current_head, current_power.Value);
                 }
                 else if (_operation_vm.CurrentCurveQE != null)
                 {
-                    eff = _operation_vm.CurrentCurveQE.GetPointY(flow);
-                    power = PumpCalcHelper.CalculateP(flow, head, eff.Value);
-                }
+                    current_eff = _operation_vm.CurrentCurveQE.GetPointY(current_flow);
+                    current_power = PumpCalcHelper.CalculateP(current_flow, current_head, current_eff.Value);
+                } 
 
-                var design_pt = new PumpDesignPointViewModel();
-                design_pt.Id = _operation_vm.Id;
-                design_pt.Name = _operation_vm.Name;
-                design_pt.Q = flow;
-                design_pt.H = head;
-                design_pt.E = eff;
-                design_pt.P = power;
-                design_pt.Hz = _operation_vm.CurrentHz;
-                design_pt.N = _operation_vm.CurrentN;
-                design_pt_list.Add(design_pt);
+                design_pt_list.Add(new()
+                {
+                    Id = _operation_vm.Id,
+                    Name = _operation_vm.Name,
+                    Q = current_flow,
+                    H = current_head,
+                    E = current_eff,
+                    P = current_power,
+                    Hz = _operation_vm.CurrentHz,
+                    N = _operation_vm.CurrentN
+                });
+
             } 
 
             this.DesignPointChangedEvent?.Invoke(design_pt_list);
@@ -604,8 +605,8 @@
             this.chartControl1.BeginInit();
             this.chartControl1.Series.Clear();
 
-            var annotationCount = this.chartControl1.AnnotationRepository.Count;
-            for (int i = annotationCount - 1; i > 0; i--)
+            var annotation_count = this.chartControl1.AnnotationRepository.Count;
+            for (int i = annotation_count - 1; i > 0; i--)
             {
                 if (i == 0)
                     break;
@@ -616,10 +617,10 @@
 
             if (_operation_vm!=null)
             {
-                CreateRatedLineSeries(_operation_vm);
+                CreateLineSeries(_operation_vm);
                 if (_operation_vm.CurrentStatus)
                 {
-                    CreateWorkingLineSeries(_operation_vm);
+                    CreateCurrentLineSeries(_operation_vm);
                 }
             }
 
@@ -659,68 +660,90 @@
 
             if (_operation_vm == null)
                 return;
-            Yw.Geometry.CubicSpline2d qh = null, qe = null, qp = null;
+
+            x_flow ??= _equip_pt?.X ?? _max_flow *0.8;
+            if (x_flow < _operation_vm.CurrentCurveQH.MinX || x_flow > _operation_vm.CurrentCurveQH.MaxX)
+                return;
+            var query_pt_list = new List<PumpQueryPointViewModel>();
+
+            double flow = 0, head = 0;
+            double? eff = null,  power = null;
+
+            flow = x_flow.Value;
+            head = _operation_vm.CurveQH.GetPointY(flow);
+            if (_operation_vm.CurveQP != null)
+            {
+                power = _operation_vm.CurveQP.GetPointY(flow);
+                eff = PumpCalcHelper.CalculateE(flow, head, power.Value);
+            }
+            else if (_operation_vm.CurveQE != null)
+            {
+                eff = _operation_vm.CurveQE.GetPointY(flow);
+                power = PumpCalcHelper.CalculateP(flow, head, eff.Value);
+            }
+             
+            query_pt_list.Add(new PumpQueryPointViewModel
+            {
+                Id = _operation_vm.Id,
+                Name = _operation_vm.Name + "棰濆畾",
+                Q = flow,
+                H = head,
+                E = eff,
+                P = power,
+                Hz = _operation_vm.RatedHz,
+                N = _operation_vm.RatedN
+            });
 
             if (_operation_vm.CurrentStatus)
             {
-                x_flow ??= _current_equip_sect_pt?.X ?? _operation_vm.CurrentCurveQH.MaxX / 3 * 2;
-                if (x_flow < _operation_vm.CurrentCurveQH.MinX || x_flow > _operation_vm.CurrentCurveQH.MaxX)
-                    return;
-
-                qh = _operation_vm.CurrentCurveQH;
-                qe = _operation_vm.CurrentCurveQE;
-                qp = _operation_vm.CurrentCurveQP;
+                flow = x_flow.Value;
+                head = _operation_vm.CurrentCurveQH.GetPointY(flow);
+                if (_operation_vm.CurrentCurveQP != null)
+                {
+                    power = _operation_vm.CurrentCurveQP.GetPointY(flow);
+                    eff = PumpCalcHelper.CalculateE(flow, head, power.Value);
+                }
+                else if (_operation_vm.CurrentCurveQE != null)
+                {
+                    eff = _operation_vm.CurrentCurveQE.GetPointY(flow);
+                    power = PumpCalcHelper.CalculateP(flow, head, eff.Value);
+                }
+                query_pt_list.Add(new PumpQueryPointViewModel()
+                {
+                    Id = _operation_vm.Id,
+                    Name = _operation_vm.Name,
+                    Q = flow,
+                    H = head,
+                    E = eff,
+                    P = power,
+                    Hz = _operation_vm.CurrentHz,
+                    N = _operation_vm.CurrentN
+                });
             }
-            else
-            {
-                x_flow ??= _equip_sect_pt?.X ?? _operation_vm.CurveQH.MaxX / 3 * 2;
-                if (x_flow < _operation_vm.CurveQH.MinX || x_flow > _operation_vm.CurveQH.MaxX)
-                    return;
-                qh = _operation_vm.CurveQH;
-                qe = _operation_vm.CurveQE;
-                qp = _operation_vm.CurveQP;
-            }
-
-            _anno_txt_query_info.Visible = true;
-
-            var work_pt = new PumpQueryPointViewModel();
-            work_pt.Q = x_flow.Value;
-            work_pt.H = qh.GetPointY(x_flow.Value);
 
             var work_info_str_builder = new StringBuilder();
-            work_info_str_builder.AppendLine($"娴侀噺:{work_pt.Q.ToString("N1")} ");
-            work_info_str_builder.AppendLine($"鎵▼:{work_pt.H.ToString("N1")} ");
-            if (qe != null)
-            {
-                if (qp != null)
-                {
-                    work_pt.P = qp.GetPointY(work_pt.Q);
-                    work_pt.E = PumpCalcHelper.CalculateE(work_pt.Q, work_pt.H, work_pt.P.Value);
-                }
-                else
-                {
-                    work_pt.E = qe.GetPointY(work_pt.Q);
-                }
-                work_info_str_builder.AppendLine($"鏁堢巼:{work_pt.E.Value.ToString("N2")} ");
-            }
-            if (qp != null)
-            {
-                work_pt.P = qp.GetPointY(work_pt.Q);
-                work_info_str_builder.Append($"鍔熺巼:{work_pt.P.Value.ToString("N1")} ");
-            }
+            work_info_str_builder.AppendLine($"娴侀噺:{flow:N2} ");
+            work_info_str_builder.AppendLine($"鎵▼:{head:N2} ");
+            if (eff.HasValue)
+                work_info_str_builder.AppendLine($"鏁堢巼:{eff:N2} ");
+            if (power.HasValue)
+                work_info_str_builder.Append($"鍔熺巼:{power:N2}");
+
+            _query_flow_line.AxisValue = x_flow;
+            _query_flow_line.Title.Text = $"{x_flow:N1}";
 
             _anno_txt_query_info.Text = work_info_str_builder.ToString();
             _anno_txt_query_info.AutoSize = true;
+            _anno_txt_query_info.Visible = true;
 
-            _query_flow_line.AxisValue = x_flow;
-            _query_flow_line.Title.Text = x_flow.Value.ToString("N1");
+            this.QueryPointChangedEvent?.Invoke(query_pt_list);
         }
 
 
         /// <summary>
         /// 鍒涘缓棰濆畾绾跨郴鍒�
         /// </summary> 
-        private void CreateRatedLineSeries(PumpOperationViewModel vm)
+        private void CreateLineSeries(PumpOperationViewModel vm)
         {
             var series_qh = new DevExpress.XtraCharts.Series();
             series_qh.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
@@ -728,8 +751,7 @@
             series_qh.Name = _tag_qh + vm.Id.ToString() + "nr";
             series_qh.ShowInLegend = false;
             series_qh.CrosshairEnabled = DefaultBoolean.False;
-            series_qh.Tag = vm.Id.ToString() + "nr";
-            series_qh.ShowInLegend = true;
+            series_qh.Tag = vm.Id.ToString() + "nr"; 
             series_qh.LegendTextPattern = vm.Name;
 
 
@@ -857,7 +879,7 @@
         /// <summary>
         /// 鍒涘缓宸ュ喌绾跨郴鍒�
         /// </summary> 
-        private void CreateWorkingLineSeries(PumpOperationViewModel vm)
+        private void CreateCurrentLineSeries(PumpOperationViewModel vm)
         {
             var series_qh = new DevExpress.XtraCharts.Series();
             series_qh.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
@@ -865,8 +887,7 @@
             series_qh.Name = _tag_qh + vm.Id.ToString();
             series_qh.ShowInLegend = false;
             series_qh.CrosshairEnabled = DefaultBoolean.False;
-            series_qh.Tag = vm.Id.ToString();
-            series_qh.ShowInLegend = true;
+            series_qh.Tag = vm.Id.ToString(); 
             series_qh.LegendTextPattern = vm.Name;
 
 
@@ -1029,17 +1050,7 @@
                     _rightClickObj = null;
                 }
             }
-            else if (e.Button == MouseButtons.Right)
-            {
-                if (hitInfo.InConstantLine)
-                {
-                    this.popMenuLine.ShowPopup(MousePosition);
-                }
-                else
-                {
-                    //this.popMenuChart.ShowPopup(MousePosition);
-                }
-            }
+             
         }
 
         private void chartControl1_MouseMove(object sender, MouseEventArgs e)
@@ -1182,9 +1193,7 @@
         /// 璁剧疆鏁堢巼鏇茬嚎鏄剧ず
         /// </summary>
         public void SetQeVisible(bool visible)
-        {
-            //if (!_initial_data)
-            //    return;
+        { 
             this.barCekCurveQEVisible.Checked = visible;
         }
 

--
Gitblit v1.9.3