duheng
2025-03-07 467578cbe7f027c14ceba0aed16fb827b94e2c65
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/11-pump/01-parallel/SimulationPumpParallelCtrl.cs
@@ -1,20 +1,12 @@
using DevExpress.PivotGrid.PivotTable;
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Yw.Geometry;
using System.Data;
using Yw.Pump;
using Yw.WinFrmUI.Phart;
namespace HStation.WinFrmUI
{
    /// <summary>
    ///
    /// </summary>
    public partial class SimulationPumpParallelCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public SimulationPumpParallelCtrl()
@@ -37,16 +29,16 @@
        /// </summary>
        public event Action<bool, string> ParallelStatusChangedEvent;
        private List<HydroPumpListItemExtendViewModel> _allPumpList = null;//所有水泵列表
        /// <summary>
        /// 绑定列表
        /// </summary>
        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo)
        {
            this.hydroPumpListExtendGridCtrl1.SetBindingData(hydroInfo);
            var allStateList = this.hydroPumpListExtendGridCtrl1.GetStateList();
            var allVmList = CreateParallelViewModels(allStateList);
            this.pumpParallelChart1.SetBindingData(allVmList);
            var allPumpList = hydroInfo?.Pumps?.Select(x => new HydroPumpListItemExtendViewModel(x, hydroInfo.Pumps, hydroInfo)).ToList();
            InitialGroups(allPumpList);
        }
        //状态改变事件
@@ -54,6 +46,39 @@
        {
            var allVmList = CreateParallelViewModels(allStateList);
            this.pumpParallelChart1.SetBindingData(allVmList);
        }
        //初始化所有分组
        private void InitialGroups(List<HydroPumpListItemExtendViewModel> allStateList)
        {
            _allPumpList = allStateList?.ToList();
            var groups = _allPumpList?.Select(x => x.BeginGroup).Distinct().ToList();
            this.itemForPumpGroup.Visibility = groups != null && groups.Count > 1 ? DevExpress.XtraLayout.Utils.LayoutVisibility.Always
                : DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            this.imageComboBoxEdit1.Properties.BeginUpdate();
            this.imageComboBoxEdit1.Properties.Items.Clear();
            groups?.ForEach(x =>
            {
                this.imageComboBoxEdit1.Properties.Items.Add(x, x, -1);
            });
            this.imageComboBoxEdit1.SelectedIndex = groups != null && groups.Count > 0 ? 0 : -1;
            this.imageComboBoxEdit1.Properties.EndUpdate();
        }
        //分组选择改变
        private void imageComboBoxEdit1_SelectedValueChanged(object sender, EventArgs e)
        {
            var item = this.imageComboBoxEdit1.SelectedItem as ImageComboBoxItem;
            if (item == null)
            {
                return;
            }
            var allBindingList = _allPumpList?.Where(x => x.BeginGroup == item.Value?.ToString()).ToList();
            if (allBindingList == null)
            {
                allBindingList = new List<HydroPumpListItemExtendViewModel>();
            }
            this.hydroPumpListExtendGridCtrl1.SetBindingData(allBindingList);
        }
        //保存
@@ -64,12 +89,11 @@
            {
                return;
            }
            var allStateList = this.hydroPumpListExtendGridCtrl1.GetStateList();
            if (allStateList == null || allStateList.Count < 1)
            if (_allPumpList == null || _allPumpList.Count < 1)
            {
                return;
            }
            var allSaveList = allStateList.Select(x => new SimulationPumpParallelSaveItemViewModel()
            var allSaveList = _allPumpList.Select(x => new SimulationPumpParallelSaveItemViewModel()
            {
                Code = x.Code,
                LinkStatus = x.RunStatus ? Yw.Hydro.PumpStatus.Open : Yw.Hydro.PumpStatus.Closed,
@@ -92,10 +116,10 @@
                var vm = new PumpParallelViewModel();
                vm.Id = item.Code;
                vm.Name = item.Name;
                vm.RatedQ = item.Vmo.RatedQ.HasValue ? item.Vmo.RatedQ.Value : 0;
                vm.RatedH = item.Vmo.RatedH.HasValue ? item.Vmo.RatedH.Value : 0;
                vm.RatedQ = item.Vmo.RatedQ;
                vm.RatedH = item.Vmo.RatedH;
                vm.RatedP = item.Vmo.RatedP;
                vm.RatedN = item.Vmo.RatedN.HasValue ? item.Vmo.RatedN.Value : 0;
                vm.RatedN = item.Vmo.RatedN;
                vm.RatedHz = item.Vmo.RatedHz;
                vm.CurrentHz = item.Hz;
                vm.CurrentN = Math.Round(item.Hz / item.Vmo.RatedHz * vm.RatedN, 1);
@@ -109,15 +133,15 @@
                    var qh_pts = curveqh.CurveData?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                    if (qh_pts != null && qh_pts.Count > 3)
                    {
                        vm.CurveQH = new CubicSpline2d(qh_pts);
                        vm.CurveQH = qh_pts;
                        var qh_current_pts = qh_pts.GetQHPointListByN(item.Vmo.RatedHz, item.Hz);
                        vm.CurrentCurveQH = new CubicSpline2d(qh_current_pts);
                        vm.CurrentCurveQH = qh_current_pts;
                        if (item.Extend > 100)
                        {
                            vm.CurrentExtendFlow = vm.CurrentCurveQH.MaxX;
                            vm.CurrentExtendFlow = vm.CurrentCurveQH.Max(x => x.X);
                            extend = item.Extend / 100;
                            var qh_current_extend_pts = vm.CurrentCurveQH.GetPointListByXRatioRange(1, extend, 20);
                            vm.CurrentCurveQH = new CubicSpline2d(qh_current_extend_pts);
                            var qh_current_extend_pts = vm.CurrentCurveQH.GetExpandPointList(Yw.Ahart.eFeatType.Cubic, 1, extend, 20);
                            vm.CurrentCurveQH = qh_current_extend_pts;
                        }
                    }
                }
@@ -125,16 +149,16 @@
                var curveqp = item.HydroInfo.Curves?.Find(x => x.Code == item.Vmo.CurveQP);
                if (curveqp != null)
                {
                    var qppts = curveqp.CurveData?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                    if (qppts != null && qppts.Count > 3)
                    var qp_pts = curveqp.CurveData?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                    if (qp_pts != null && qp_pts.Count > 3)
                    {
                        vm.CurveQP = new CubicSpline2d(qppts);
                        var sqppts = qppts.GetQHPointListByN(item.Vmo.RatedHz, item.Hz);
                        vm.CurrentCurveQP = new CubicSpline2d(sqppts);
                        vm.CurveQP = qp_pts;
                        var qp_current_pts = qp_pts.GetQPPointListByN(item.Vmo.RatedHz, item.Hz);
                        vm.CurrentCurveQP = qp_current_pts;
                        if (extend > 1)
                        {
                            var qp_current_extend_pts = vm.CurrentCurveQP.GetPointListByXRatioRange(1, extend, 20);
                            vm.CurrentCurveQP = new CubicSpline2d(qp_current_extend_pts);
                            var qp_current_extend_pts = vm.CurrentCurveQP.GetExpandPointList(Yw.Ahart.eFeatType.Cubic, 1, extend, 20);
                            vm.CurrentCurveQP = qp_current_extend_pts;
                        }
                    }
                }
@@ -142,16 +166,16 @@
                var curveqe = item.HydroInfo.Curves?.Find(x => x.Code == item.Vmo.CurveQE);
                if (curveqe != null)
                {
                    var qepts = curveqe.CurveData?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                    if (qepts != null && qepts.Count > 3)
                    var qe_pts = curveqe.CurveData?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                    if (qe_pts != null && qe_pts.Count > 3)
                    {
                        vm.CurveQE = new CubicSpline2d(qepts);
                        var sqepts = qepts.GetQHPointListByN(item.Vmo.RatedHz, item.Hz);
                        vm.CurrentCurveQE = new CubicSpline2d(sqepts);
                        vm.CurveQE = qe_pts;
                        var qe_current_pts = qe_pts.GetQEPointListByN(item.Vmo.RatedHz, item.Hz);
                        vm.CurrentCurveQE = qe_current_pts;
                        if (extend > 1)
                        {
                            var qe_current_extend_pts = vm.CurrentCurveQE.GetPointListByXRatioRange(1, extend, 20);
                            vm.CurrentCurveQE = new CubicSpline2d(qe_current_extend_pts);
                            var qe_current_extend_pts = vm.CurrentCurveQE.GetExpandPointList(Yw.Ahart.eFeatType.Cubic, 1, extend, 20);
                            vm.CurrentCurveQE = qe_current_extend_pts;
                        }
                    }
                }
@@ -218,5 +242,6 @@
            this.pumpParallelChart1.SetDesignPoint(q, h);
        }
    }
}