Shuxia Ning
2024-12-03 ce65365b03d49fc6c6961e0c690768b93c4a4c7c
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/02-operation/PumpOperationChart.cs
@@ -44,7 +44,7 @@
        private bool _initial_data = false; 
        private PumpOperationViewModel _operation_vm = null;
        private PumpOperationViewModel _vm = null;
        #endregion
@@ -154,7 +154,7 @@
        {
            if (e is not DXCustomPaintEventArgs dxArgs)
                return;
            if (_operation_vm == null)
            if (_vm == null)
                return;
            if (_equip_line != null && _equip_sect_pt != null && _equip_visible)
@@ -162,9 +162,9 @@
                using Pen pen = new(Color.Black, 2);
                pen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot; 
                DrawEquipPoint(dxArgs.Cache, pen, _equip_sect_pt, _operation_vm.CurveQE, _operation_vm.CurveQP);
                DrawEquipPoint(dxArgs.Cache, pen, _equip_sect_pt, _vm.CurveQE, _vm.CurveQP);
                if (_current_equip_sect_pt != null)
                    DrawEquipPoint(dxArgs.Cache, pen, _current_equip_sect_pt, _operation_vm.CurrentCurveQE, _operation_vm.CurrentCurveQP);
                    DrawEquipPoint(dxArgs.Cache, pen, _current_equip_sect_pt, _vm.CurrentCurveQE, _vm.CurrentCurveQP);
                DrawEquipLine(dxArgs.Cache, pen, _equip_line); 
            }
@@ -212,7 +212,7 @@
            }
            if (qp != null && _qp_visible)
            {
                var qp_y = qe.GetPointY(qh_x);
                var qp_y = qp.GetPointY(qh_x);
                var qp_pt = _diagram.DiagramToPoint(qh_x, qp_y, _axis_x_flow, _axis_y_power);
                var qp_pt_x = qp_pt.Point.X;
                var qp_pt_y = qp_pt.Point.Y;
@@ -240,7 +240,7 @@
        /// </summary> 
        public void SetBindingData(PumpOperationViewModel vm)
        {
            _operation_vm = vm;
            _vm = vm;
            _initial_data = vm != null;
            UpdateChart(true);
        }
@@ -254,14 +254,14 @@
            _equip_line = null;
            _equip_sect_pt = null;
            _current_equip_sect_pt = null;
            if (_operation_vm == null)
            if (_vm == null)
            {
                this.DesignPointChangedEvent?.Invoke(null);
                return;
            }
            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);
            var equip_line = Yw.Geometry.EquipCurveHelper.CalcEquipCurve(_vm.CurveQH, _equip_pt, start_head.Value, out Yw.Geometry.Point2d sect_pt);
            if (equip_line == null || sect_pt == null)
                return;
@@ -271,62 +271,62 @@
            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)
            head = _vm.CurveQH.GetPointY(flow);
            if (_vm.CurveQP != null)
            {
                power = _operation_vm.CurveQP.GetPointY(flow);
                power = _vm.CurveQP.GetPointY(flow);
                eff = PumpCalcHelper.CalculateE(flow, head, power.Value);
            }
            else if (_operation_vm.CurveQE != null)
            else if (_vm.CurveQE != null)
            {
                eff = _operation_vm.CurveQE.GetPointY(flow);
                eff = _vm.CurveQE.GetPointY(flow);
                power = PumpCalcHelper.CalculateP(flow, head, eff.Value);
            }
             
            var design_pt_list = new List<PumpDesignPointViewModel>
            {
                new() {
                    Id = _operation_vm.Id + "额定",
                    Name = _operation_vm.Name + "(额定)",
                    Id = _vm.Id + "额定",
                    Name = _vm.Name + "(额定)",
                    Q = flow,
                    H = head,
                    E = eff,
                    P = power,
                    Hz = _operation_vm.RatedHz,
                    N = _operation_vm.RatedN
                    Hz = _vm.RatedHz,
                    N = _vm.RatedN
                }
            }; 
            if (_operation_vm.CurrentStatus)
            if (_vm.CurrentStatus)
            {
                var current_equip_line = Yw.Geometry.EquipCurveHelper.CalcEquipCurve(_operation_vm.CurrentCurveQH, _equip_pt, start_head.Value, out Yw.Geometry.Point2d current_sect_pt);
                var current_equip_line = Yw.Geometry.EquipCurveHelper.CalcEquipCurve(_vm.CurrentCurveQH, _equip_pt, start_head.Value, out Yw.Geometry.Point2d current_sect_pt);
                if ( current_sect_pt == null)
                    return;
                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)
                current_head = _vm.CurrentCurveQH.GetPointY(current_flow);
                if (_vm.CurrentCurveQP != null)
                {
                    current_power = _operation_vm.CurrentCurveQP.GetPointY(current_flow);
                    current_power = _vm.CurrentCurveQP.GetPointY(current_flow);
                    current_eff = PumpCalcHelper.CalculateE(current_flow, current_head, current_power.Value);
                }
                else if (_operation_vm.CurrentCurveQE != null)
                else if (_vm.CurrentCurveQE != null)
                {
                    current_eff = _operation_vm.CurrentCurveQE.GetPointY(current_flow);
                    current_eff = _vm.CurrentCurveQE.GetPointY(current_flow);
                    current_power = PumpCalcHelper.CalculateP(current_flow, current_head, current_eff.Value);
                } 
                design_pt_list.Add(new()
                {
                    Id = _operation_vm.Id,
                    Name = _operation_vm.Name,
                    Id = _vm.Id,
                    Name = _vm.Name,
                    Q = current_flow,
                    H = current_head,
                    E = current_eff,
                    P = current_power,
                    Hz = _operation_vm.CurrentHz,
                    N = _operation_vm.CurrentN
                    Hz = _vm.CurrentHz,
                    N = _vm.CurrentN
                });
            } 
@@ -351,7 +351,7 @@
        {
            if (vm == null)
                return;
            _operation_vm = vm;
            _vm = vm;
            _initial_data = true;
            UpdateChart(true);
        }
@@ -362,7 +362,7 @@
        /// </summary> 
        public void Delete()
        {
            _operation_vm = null;
            _vm = null;
            UpdateChart(true);
            _initial_data = false;
        }
@@ -403,7 +403,7 @@
        /// </summary>
        private void CalcCoordinate()
        {
            if (_operation_vm == null )
            if (_vm == null )
            {
                //设置成白板坐标
                _coordinate = new PumpCoordinate();
@@ -431,10 +431,10 @@
            double _scaleMinH = 1, _scaleMaxH = 1; 
            {
                var qh_pt_list = _operation_vm.CurveQH.GetPointList();
                if (_operation_vm.CurrentStatus)
                var qh_pt_list = _vm.CurveQH.GetPointList();
                if (_vm.CurrentStatus)
                { 
                    qh_pt_list.AddRange(_operation_vm.CurrentCurveQH.GetPointList());
                    qh_pt_list.AddRange(_vm.CurrentCurveQH.GetPointList());
                }
                var xxx = qh_pt_list.Select(x => x.X);
@@ -448,24 +448,24 @@
            }
            if (_operation_vm.CurveQE != null)
            if (_vm.CurveQE != null)
            {
                var yyy = _operation_vm.CurveQE.GetPointList().Select(x => x.Y).ToList();
                if (_operation_vm.CurrentStatus)
                var yyy = _vm.CurveQE.GetPointList().Select(x => x.Y).ToList();
                if (_vm.CurrentStatus)
                {
                    yyy.AddRange(_operation_vm.CurrentCurveQE.GetPointList().Select(x => x.Y));
                    yyy.AddRange(_vm.CurrentCurveQE.GetPointList().Select(x => x.Y));
                }
                _min_eff = Math.Min(_min_eff, yyy.Min());
                _max_eff = Math.Max(_max_eff, yyy.Max());
            }
            if (_operation_vm.CurveQP != null)
            if (_vm.CurveQP != null)
            {
                var yyy = _operation_vm.CurveQP.GetPointList().Select(x => x.Y).ToList();
                if (_operation_vm.CurrentStatus)
                var yyy = _vm.CurveQP.GetPointList().Select(x => x.Y).ToList();
                if (_vm.CurrentStatus)
                {
                    yyy.AddRange(_operation_vm.CurrentCurveQP.GetPointList().Select(x => x.Y));
                    yyy.AddRange(_vm.CurrentCurveQP.GetPointList().Select(x => x.Y));
                }
                _min_power = Math.Min(_min_power, yyy.Min());
                _max_power = Math.Max(_max_power, yyy.Max());
@@ -621,12 +621,12 @@
            this.chartControl1.Legend.CustomItems.Clear();
            if (_operation_vm!=null)
            if (_vm!=null)
            {
                CreateLineSeries(_operation_vm);
                if (_operation_vm.CurrentStatus)
                CreateLineSeries(_vm);
                if (_vm.CurrentStatus)
                {
                    CreateCurrentLineSeries(_operation_vm);
                    CreateCurrentLineSeries(_vm);
                }
            }
@@ -664,19 +664,19 @@
                _anno_txt_query_info.Visible = true;
            }
            if (_operation_vm == null)
            if (_vm == null)
                return;
            if (_operation_vm.CurrentStatus)
            if (_vm.CurrentStatus)
            {
                x_flow ??= _operation_vm.CurrentCurveQH.MaxX * 0.8;
                if (x_flow < _operation_vm.CurrentCurveQH.MinX || x_flow > _operation_vm.CurrentCurveQH.MaxX)
                x_flow ??= _vm.CurrentCurveQH.MaxX * 0.8;
                if (x_flow < _vm.CurrentCurveQH.MinX || x_flow > _vm.CurrentCurveQH.MaxX)
                    return;
            }
            else
            {
                x_flow ??= _operation_vm.CurveQH.MaxX * 0.8;
                if (x_flow < _operation_vm.CurveQH.MinX || x_flow > _operation_vm.CurveQH.MaxX)
                x_flow ??= _vm.CurveQH.MaxX * 0.8;
                if (x_flow < _vm.CurveQH.MinX || x_flow > _vm.CurveQH.MaxX)
                    return;
            }
           
@@ -685,54 +685,54 @@
            double? eff = null,  power = null;
            flow = x_flow.Value;
            head = _operation_vm.CurveQH.GetPointY(flow);
            if (_operation_vm.CurveQP != null)
            head = _vm.CurveQH.GetPointY(flow);
            if (_vm.CurveQP != null)
            {
                power = _operation_vm.CurveQP.GetPointY(flow);
                power = _vm.CurveQP.GetPointY(flow);
                eff = PumpCalcHelper.CalculateE(flow, head, power.Value);
            }
            else if (_operation_vm.CurveQE != null)
            else if (_vm.CurveQE != null)
            {
                eff = _operation_vm.CurveQE.GetPointY(flow);
                eff = _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 + "额定",
                Id = _vm.Id,
                Name = _vm.Name + "额定",
                Q = flow,
                H = head,
                E = eff,
                P = power,
                Hz = _operation_vm.RatedHz,
                N = _operation_vm.RatedN
                Hz = _vm.RatedHz,
                N = _vm.RatedN
            });
            if (_operation_vm.CurrentStatus)
            if (_vm.CurrentStatus)
            {
                flow = x_flow.Value;
                head = _operation_vm.CurrentCurveQH.GetPointY(flow);
                if (_operation_vm.CurrentCurveQP != null)
                head = _vm.CurrentCurveQH.GetPointY(flow);
                if (_vm.CurrentCurveQP != null)
                {
                    power = _operation_vm.CurrentCurveQP.GetPointY(flow);
                    power = _vm.CurrentCurveQP.GetPointY(flow);
                    eff = PumpCalcHelper.CalculateE(flow, head, power.Value);
                }
                else if (_operation_vm.CurrentCurveQE != null)
                else if (_vm.CurrentCurveQE != null)
                {
                    eff = _operation_vm.CurrentCurveQE.GetPointY(flow);
                    eff = _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,
                    Id = _vm.Id,
                    Name = _vm.Name,
                    Q = flow,
                    H = head,
                    E = eff,
                    P = power,
                    Hz = _operation_vm.CurrentHz,
                    N = _operation_vm.CurrentN
                    Hz = _vm.CurrentHz,
                    N = _vm.CurrentN
                });
            }
@@ -1117,7 +1117,7 @@
        #region Event
        private void barBtnSetAxisQValue_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_operation_vm == null)
            if (_vm == null)
                return;
            var dlg = new PumpAxisValueDlg();
            dlg.SetBindingData();