lixiaojun
2024-12-03 62bcbdb29fe358fbb01237f7fb2aca211fd2b67a
WinFrmUI/Yw.WinFrmUI.Phart.Core/v3/02-pump/02-multi/01-parallel/PumpParallelChart.cs
@@ -173,13 +173,13 @@
                dxArgs.Cache.DrawLine(pen, new Point((int)c_pt_qh.Point.X, (int)c_pt_qh.Point.Y - 10), new Point((int)c_pt_qh.Point.X, (int)c_pt_qh.Point.Y + 10));
                if (_qe_visible)
                {
                    var y_qe = _paralle_vm.CurrentCurveQE.GetPointY(_equip_sect_pt.X);
                    var y_qe = _paralle_vm.CurrentCurveQE.GetPointYUnlimited(_equip_sect_pt.X);
                    var c_pt_qe = _diagram.DiagramToPoint(_equip_sect_pt.X, y_qe, _axis_x_flow, _axis_y_eff);
                    dxArgs.Cache.DrawLine(pen, new Point((int)c_pt_qe.Point.X, (int)c_pt_qe.Point.Y - 10), new Point((int)c_pt_qe.Point.X, (int)c_pt_qe.Point.Y + 10));
                }
                if (_qp_visible)
                {
                    var y_qp = _paralle_vm.CurrentCurveQP.GetPointY(_equip_sect_pt.X);
                    var y_qp = _paralle_vm.CurrentCurveQP.GetPointYUnlimited(_equip_sect_pt.X);
                    var c_pt_qp = _diagram.DiagramToPoint(_equip_sect_pt.X, y_qp, _axis_x_flow, _axis_y_power);
                    dxArgs.Cache.DrawLine(pen, new Point((int)c_pt_qp.Point.X, (int)c_pt_qp.Point.Y - 10), new Point((int)c_pt_qp.Point.X, (int)c_pt_qp.Point.Y + 10));
                }
@@ -214,7 +214,7 @@
                    {
                        if (pt_list.Count == 1)
                        {
                            var max_flow_head = vm.CurrentCurveQH.GetPointY(max_flow);
                            var max_flow_head = vm.CurrentCurveQH.GetPointYUnlimited(max_flow);
                            pt_list.Add(new Yw.Geometry.Point2d(max_flow, max_flow_head));
                        }
                        var pt_c_list = new List<PointF>();
@@ -239,7 +239,7 @@
                    {
                        if (pt_list.Count == 1)
                        {
                            var max_flow_eff = vm.CurrentCurveQE.GetPointY(max_flow);
                            var max_flow_eff = vm.CurrentCurveQE.GetPointYUnlimited(max_flow);
                            pt_list.Add(new Yw.Geometry.Point2d(max_flow, max_flow_eff));
                        }
                        var pt_c_list = new List<PointF>();
@@ -264,7 +264,7 @@
                    {
                        if (pt_list.Count == 1)
                        {
                            var max_flow_power = vm.CurrentCurveQP.GetPointY(max_flow);
                            var max_flow_power = vm.CurrentCurveQP.GetPointYUnlimited(max_flow);
                            pt_list.Add(new Yw.Geometry.Point2d(max_flow, max_flow_power));
                        }
                        var pt_c_list = new List<PointF>();
@@ -337,28 +337,30 @@
                double flow = 0, head = 0;
                double? eff = null, power = null;
                flow = sect_pt.X;
                head = vm.CurrentCurveQH.GetPointY(flow);
                head = vm.CurrentCurveQH.GetPointYUnlimited(flow);
                if (vm.CurrentCurveQP != null)
                {
                    power = vm.CurrentCurveQP.GetPointY(flow);
                    power = vm.CurrentCurveQP.GetPointYUnlimited(flow);
                    eff = PumpCalcHelper.CalculateE(flow, head, power.Value);
                }
                else if (vm.CurrentCurveQE != null)
                {
                    eff = vm.CurrentCurveQE.GetPointY(flow);
                    eff = vm.CurrentCurveQE.GetPointYUnlimited(flow);
                    power = PumpCalcHelper.CalculateP(flow, head, eff.Value);
                }
                var design_pt = new PumpDesignPointViewModel();
                design_pt.Id = vm.Id;
                design_pt.Q = flow;
                design_pt.H = head;
                design_pt.E = eff;
                design_pt.P = power;
                design_pt.Hz = vm.CurrentHz;
                design_pt.N = vm.CurrentN;
                design_pt_list.Add(design_pt);
                design_pt_list.Add(new PumpDesignPointViewModel
                {
                    Id = vm.Id,
                    Name = vm.Name,
                    Q = flow,
                    H = head,
                    E = eff,
                    P = power,
                    Hz = vm.CurrentHz,
                    N = vm.CurrentN
                });
            }
            this.DesignPointChangedEvent?.Invoke(design_pt_list);
@@ -380,13 +382,13 @@
        /// </summary>s
        public void UpdateChart(bool calc_coordinate = false)
        {
            CalcSeries();
            if (calc_coordinate || _coordinate == null)
            {
                //不强迫计算,就用上次更新的坐标系
                CalcCoordinate();
            }
            CalcSeries();
            CalcChartAxis();
@@ -437,9 +439,13 @@
            double _scaleMinH = 1, _scaleMaxH = 1;
            foreach (var vm in _vm_list)
            {
                var qh_pt_list = vm.CurrentCurveQH.GetPointList();
                var qh_pt_list = vm.CurveQH.GetPointList();
                if (vm.CurrentCurveQH != null)
                    qh_pt_list.AddRange(vm.CurrentCurveQH.GetPointList());
                var xxx = qh_pt_list.Select(x => x.X);
                var yyy = qh_pt_list.Select(x => x.Y);
@@ -453,20 +459,56 @@
            foreach (PumpParallelViewModel vm in _vm_list)
            {
                if (vm.CurrentCurveQE == null)
                    continue;
                var qe_pt_list = vm.CurrentCurveQE.GetPointList();
                var qe_pt_list = vm.CurveQE.GetPointList();
                if (vm.CurrentCurveQE != null)
                    qe_pt_list.AddRange(vm.CurrentCurveQE.GetPointList());
                var yyy = qe_pt_list.Select(x => x.Y);
                _min_eff = Math.Max(_min_eff, yyy.Min());
                _max_eff = Math.Max(_max_eff, yyy.Max());
            }
            foreach (PumpParallelViewModel vm in _vm_list)
            {
                if (vm.CurrentCurveQP == null)
                    continue;
                var yyy = vm.CurrentCurveQP.GetPointList().Select(x => x.Y);
                var qe_pt_list = vm.CurveQP.GetPointList();
                if (vm.CurrentCurveQP != null)
                    qe_pt_list.AddRange(vm.CurrentCurveQP.GetPointList());
                var yyy = qe_pt_list.Select(x => x.Y);
                _min_power = Math.Min(_min_power, yyy.Min());
                _max_power = Math.Max(_max_power, yyy.Max());
            }
            if (_paralle_vm != null)
            {
                {
                    var qh_pt_list = _paralle_vm.CurveQH.GetPointList();
                    var xxx = qh_pt_list.Select(x => x.X);
                    var yyy = qh_pt_list.Select(x => x.Y);
                    _min_flow = Math.Min(_min_flow, xxx.Min());
                    _max_flow = Math.Max(_max_flow, xxx.Max());
                    _min_head = Math.Min(_min_head, yyy.Min());
                    _max_head = Math.Max(_max_head, yyy.Max());
                }
                if (_paralle_vm.CurveQE != null)
                {
                    var qe_pt_list = _paralle_vm.CurveQE.GetPointList();
                    var yyy = qe_pt_list.Select(x => x.Y);
                    _min_eff = Math.Max(_min_eff, yyy.Min());
                    _max_eff = Math.Max(_max_eff, yyy.Max());
                }
                if (_paralle_vm.CurveQP != null)
                {
                    var qp_pt_list = _paralle_vm.CurveQP.GetPointList();
                    var yyy = qp_pt_list.Select(x => x.Y);
                    _min_power = Math.Min(_min_power, yyy.Min());
                    _max_power = Math.Max(_max_power, yyy.Max());
                }
            }
            _coordinate = PumpCoordinate.CalcCoordinate(_min_flow,
@@ -633,8 +675,12 @@
        private void CalcParallelSeries(List<PumpParallelViewModel> list)
        {
            _paralle_vm = null;
            this.barCekLineVisible.Enabled = false;
            if (list == null || !list.Any())
            {
                LineVisible = false;
                return; 
            }
            var helper = new Yw.WinFrmUI.Phart.PumpParallelConnectionHelper();
            foreach (var item in list)
@@ -652,6 +698,7 @@
            var calc_staus = helper.CalculateParallel(out calc_pt_qh_list, out calc_pt_qe_list, out calc_pt_qp_list);
            if (!calc_staus || calc_pt_qh_list.Count < 4)
            {
                LineVisible = false;
                this.ParallelStatusChangedEvent?.Invoke(false, "并联失败!");
                return;
            }
@@ -676,6 +723,8 @@
            _paralle_vm.CurveQP = qp;
            CreateLineSeries(_paralle_vm);
            this.barCekLineVisible.Enabled = true;
        }
        /// <summary>
@@ -683,8 +732,8 @@
        /// </summary>
        private void CalcTextAnchorPoint()
        {
            var x = this.chartControl1.Location.X + this.chartControl1.Width - (100);
            var y = this.chartControl1.Location.Y + 100;
            var x = this.chartControl1.Location.X + this.chartControl1.Width - (50);
            var y = this.chartControl1.Location.Y;
            (_anno_txt_query_info.AnchorPoint as ChartAnchorPoint).X = x;
            (_anno_txt_query_info.AnchorPoint as ChartAnchorPoint).Y = y;
@@ -725,16 +774,16 @@
            double? paralle_eff = null, paralle_power = null;
            paralle_flow = x_flow.Value;
            paralle_head = _paralle_vm.CurrentCurveQH.GetPointY(paralle_flow);
            paralle_head = _paralle_vm.CurrentCurveQH.GetPointYUnlimited(paralle_flow);
            if (_paralle_vm.CurrentCurveQP != null)
            {
                paralle_power = _paralle_vm.CurrentCurveQP.GetPointY(paralle_flow);
                paralle_power = _paralle_vm.CurrentCurveQP.GetPointYUnlimited(paralle_flow);
                paralle_eff = PumpCalcHelper.CalculateE(paralle_flow, paralle_head, paralle_power.Value);
            }
            else if (_paralle_vm.CurrentCurveQE != null)
            {
                paralle_eff = _paralle_vm.CurrentCurveQE.GetPointY(paralle_flow);
                paralle_eff = _paralle_vm.CurrentCurveQE.GetPointYUnlimited(paralle_flow);
                paralle_power = PumpCalcHelper.CalculateP(paralle_flow, paralle_head, paralle_eff.Value);
            }
@@ -748,18 +797,19 @@
                flow = vm.CurrentCurveQH.GetPointsX(head).LastOrDefault();
                if (vm.CurrentCurveQP != null)
                {
                    power = _paralle_vm.CurrentCurveQP.GetPointY(flow);
                    power = vm.CurrentCurveQP.GetPointYUnlimited(flow);
                    eff = PumpCalcHelper.CalculateE(flow, head, power.Value);
                }
                else if (vm.CurrentCurveQE != null)
                {
                    eff = _paralle_vm.CurrentCurveQE.GetPointY(flow);
                    eff = vm.CurrentCurveQE.GetPointYUnlimited(flow);
                    power = PumpCalcHelper.CalculateP(flow, head, eff.Value);
                }
                 
                query_pt_list.Add(new()
                {
                    Id = vm.Id,
                    Name=vm.Name,
                    Q = flow,
                    H = head,
                    E = eff,