lixiaojun
2024-10-18 5043208b24f45b3e3c630a596b9e83373096a78a
WinFrmUI/Yw.WinFrmUI.Hydro.Core/11-prefix/02-pump/SetPumpCalcuPrefixCtrl.cs
@@ -8,6 +8,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Yw.EPAnet;
namespace Yw.WinFrmUI
{
@@ -17,16 +18,96 @@
        {
            InitializeComponent();
            this.layoutControl1.SetupLayoutControl();
            InitialPumpStatus();
        }
        private Yw.Model.HydroPumpInfo _pump = null;
        /// <summary>
        /// 查看事件
        /// </summary>
        public event Action<Yw.Model.HydroPumpInfo> ViewEvent;
        /// <summary>
        /// 查看曲线事件
        /// </summary>
        public event Action<Yw.Model.HydroPumpInfo> ViewCurveEvent;
        private Yw.Model.HydroPumpInfo _pump = null;//水泵
        /// <summary>
        /// 
        /// </summary>
        public void SetBindingData(Yw.Model.HydroPumpInfo pump)
        {
            _pump = pump;
            if (_pump == null)
            {
                return;
            }
            this.layoutGroupCaption.Text = "水泵";
            if (!string.IsNullOrEmpty(_pump.Name))
            {
                this.layoutGroupCaption.Text = _pump.Name;
            }
            this.imgCmbPumpStatus.EditValue = _pump.LinkStatus;
            this.txtCurrentHz.EditValue = _pump.RatedHz * _pump.SpeedRatio;
            this.txtRatedP.EditValue = _pump.RatedP;
            this.txtRatedQ.EditValue = _pump.RatedQ;
            this.txtRatedH.EditValue = _pump.RatedH;
            this.txtRatedN.EditValue = _pump.RatedN;
            this.txtRatedHz.EditValue = _pump.RatedHz;
            this.btnEditCurve.EditValue = string.IsNullOrEmpty(_pump.DbId) ? "未匹配" : "已匹配";
        }
        /// <summary>
        ///
        /// </summary>
        public void UpdateBindingData()
        {
            if (_pump == null)
            {
                return;
            }
            _pump.LinkStatus = this.imgCmbPumpStatus.EditValue?.ToString();
            _pump.RatedP = double.Parse(this.txtRatedP.EditValue?.ToString());
            _pump.RatedQ = this.txtRatedQ.EditValue == null ? null : double.Parse(this.txtRatedQ.EditValue.ToString());
            _pump.RatedH = this.txtRatedH.EditValue == null ? null : double.Parse(this.txtRatedH.EditValue.ToString());
            _pump.RatedN = this.txtRatedN.EditValue == null ? null : double.Parse(this.txtRatedN.EditValue.ToString());
            _pump.RatedHz = double.Parse(this.txtRatedHz.EditValue?.ToString());
        }
        //初始化水泵状态
        private void InitialPumpStatus()
        {
            this.imgCmbPumpStatus.Properties.BeginUpdate();
            this.imgCmbPumpStatus.Properties.Items.Clear();
            this.imgCmbPumpStatus.Properties.Items.Add(HydroLinkStatusHelper.GetStatusName(Yw.Hydro.PumpStatus.Open), Yw.Hydro.PumpStatus.Open, 0);
            this.imgCmbPumpStatus.Properties.Items.Add(HydroLinkStatusHelper.GetStatusName(Yw.Hydro.PumpStatus.Closed), Yw.Hydro.PumpStatus.Closed, 0);
            this.imgCmbPumpStatus.Properties.EndUpdate();
        }
        //查看曲线
        private void btnEditCurve_Properties_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (_pump == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(_pump.DbId))
            {
                TipFormHelper.ShowWarn("尚未匹配");
                return;
            }
            this.ViewCurveEvent?.Invoke(_pump);
        }
        //查看部件
        private void layoutGroupCaption_CustomButtonClick(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e)
        {
            if (_pump == null)
            {
                return;
            }
            this.ViewEvent?.Invoke(_pump);
        }
    }