Shuxia Ning
2025-01-03 5e776f1884d4d865c8d3d037a1fb10fb083f37ed
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/11-pump/02-feat/SimulationSinglePumpFeatCtrl.cs
@@ -12,6 +12,7 @@
using System.Windows.Forms;
using Yw.Geometry;
using Yw.Pump;
using Yw.Vmo;
using Yw.WinFrmUI.Phart;
namespace HStation.WinFrmUI
@@ -35,12 +36,19 @@
        private Yw.Model.HydroModelInfo _hydroInfo = null;
        private Yw.Model.HydroPumpInfo _pumpInfo = null;
        private HydroCalcuResult _calcuResult = null;
        private double _head = 0;//
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroPumpInfo pumpInfo)
        public void SetBindingData
            (
                Yw.Model.HydroModelInfo hydroInfo,
                Yw.Model.HydroPumpInfo pumpInfo,
                HydroCalcuResult calcuResult
            )
        {
            if (hydroInfo == null)
            {
@@ -52,10 +60,32 @@
            }
            _hydroInfo = hydroInfo;
            _pumpInfo = pumpInfo;
            _calcuResult = calcuResult;
            _head = _hydroInfo.GetHead();
            this.hydroSinglePumpListExtendGridCtrl1.SetBindingData(pumpInfo);
            var allStateList = this.hydroSinglePumpListExtendGridCtrl1.GetStateList();
            var vm = CreateViewModel(allStateList);
            this.pumpOperationChart1.SetBindingData(vm);
            if (calcuResult != null)
            {
                var allCalcuVisualDict = calcuResult.GetVisualDict();
                var calcuVisualResult = allCalcuVisualDict?.GetValue(pumpInfo.Code) as HydroCalcuPumpResult;
                if (calcuVisualResult != null)
                {
                    if (calcuVisualResult.CalcuQ.HasValue)
                    {
                        this.txtDesignQ.EditValue = Math.Round(calcuVisualResult.CalcuQ.Value, 1);
                    }
                    if (calcuVisualResult.CalcuH.HasValue)
                    {
                        this.txtDesignH.EditValue = Math.Round(calcuVisualResult.CalcuH.Value, 2);
                    }
                    if (calcuVisualResult.CalcuQ.HasValue && calcuVisualResult.CalcuH.HasValue)
                    {
                        Design();
                    }
                }
            }
        }
        //状态改变事件
@@ -101,11 +131,11 @@
            var vm = new PumpOperationViewModel();
            vm.Id = _pumpInfo.Code;
            vm.Name = _pumpInfo.Name;
            vm.RatedQ = _pumpInfo.RatedQ.HasValue ? _pumpInfo.RatedQ.Value : 0;
            vm.RatedH = _pumpInfo.RatedH.HasValue ? _pumpInfo.RatedH.Value : 0;
            vm.RatedQ = _pumpInfo.RatedQ;
            vm.RatedH = _pumpInfo.RatedH;
            vm.RatedP = _pumpInfo.RatedP;
            vm.RatedN = rated.N;
            vm.RatedHz = rated.Hz;
            vm.RatedN = _pumpInfo.RatedN;
            vm.RatedHz = _pumpInfo.RatedHz;
            vm.CurrentHz = current.Hz;
            vm.CurrentN = current.N;
            vm.CurrentStatus = _pumpInfo.LinkStatus == Yw.Hydro.PumpStatus.Open;
@@ -184,6 +214,12 @@
        //设计点
        private void btnDesign_Click(object sender, EventArgs e)
        {
            Design();
        }
        //设计
        private void Design()
        {
            var qtext = this.txtDesignQ.Text.Trim();
            if (string.IsNullOrEmpty(qtext))
            {
@@ -198,7 +234,7 @@
            }
            var q = double.Parse(qtext);
            var h = double.Parse(htext);
            this.pumpOperationChart1.SetDesignPoint(q, h);
            this.pumpOperationChart1.SetDesignPoint(q, h, _head);
        }
        /// <summary>
@@ -208,6 +244,7 @@
        {
            if (this.hydroSinglePumpListExtendGridCtrl1.HasChanged)
            {
                this.hydroSinglePumpListExtendGridCtrl1.HasChanged = false;
                var result = XtraMessageBox.Show("是否使用现有状态更新模型?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes;
                if (!result)
                {
@@ -223,6 +260,7 @@
                    LinkStatus = _pumpInfo.LinkStatus,
                    CurrentHz = allStateList[1].Hz
                };
                this.SaveEvent?.Invoke(working);
            }
        }