| | |
| | | using DevExpress.PivotGrid.PivotTable; |
| | | using DevExpress.Xpo.Helpers; |
| | | 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; |
| | | |
| | |
| | | { |
| | | InitializeComponent(); |
| | | this.layoutControl1.SetupLayoutControl(); |
| | | this.pumpOperationChart1.AllowEditCurve = true; |
| | | this.pumpOperationChart1.DesignPointChangedEvent += PumpParallelChart1_DesignPointChangedEvent; |
| | | this.pumpOperationChart1.QueryPointChangedEvent += PumpParallelChart1_QueryPointChangedEvent; |
| | | this.pumpOperationChart1.EditCurveEvent += PumpOperationChart1_EditCurveEvent; |
| | | this.hydroSinglePumpListExtendGridCtrl1.StateChangedEvent += HydroSinglePumpListExtendGridCtrl1_StateChangedEvent; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 保存事件 |
| | |
| | | |
| | | private Yw.Model.HydroModelInfo _hydroInfo = null; |
| | | private Yw.Model.HydroPumpInfo _pumpInfo = null; |
| | | |
| | | private HydroCalcuResult _calcuResult = null;//计算结果 |
| | | private double _head = 0; |
| | | private PumpOperationViewModel _vm = null;//所有操作列表 |
| | | private HydroChangeHelper _changeHelper = null;//改变辅助类 |
| | | private HydroPropStatusHelper _propStatusHelper = null;//属性状态辅助类 |
| | | |
| | | /// <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, |
| | | HydroChangeHelper changeHelper, |
| | | HydroPropStatusHelper propStatusHelper |
| | | ) |
| | | { |
| | | if (hydroInfo == null) |
| | | { |
| | |
| | | } |
| | | _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); |
| | | _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(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //状态改变事件 |
| | |
| | | { |
| | | return; |
| | | } |
| | | var vm = CreateViewModel(allStateList); |
| | | this.pumpOperationChart1.SetBindingData(vm); |
| | | _vm = CreateViewModel(allStateList); |
| | | this.pumpOperationChart1.SetBindingData(_vm); |
| | | } |
| | | |
| | | //保存 |
| | |
| | | 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; |
| | |
| | | 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(rated.Hz, current.Hz); |
| | | vm.CurrentCurveQH = new CubicSpline2d(qh_current_pts); |
| | | vm.CurrentCurveQH = qh_current_pts; |
| | | } |
| | | } |
| | | |
| | | var curveqp = _hydroInfo.Curves?.Find(x => x.Code == _pumpInfo.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(rated.Hz, current.Hz); |
| | | vm.CurrentCurveQP = new CubicSpline2d(sqppts); |
| | | vm.CurveQP = qp_pts; |
| | | var qp_current_pts = qp_pts.GetQPPointListByN(rated.Hz, current.Hz); |
| | | vm.CurrentCurveQP = qp_current_pts; |
| | | } |
| | | } |
| | | |
| | | var curveqe = _hydroInfo.Curves?.Find(x => x.Code == _pumpInfo.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(rated.Hz, current.Hz); |
| | | vm.CurrentCurveQE = new CubicSpline2d(sqepts); |
| | | vm.CurveQE = qe_pts; |
| | | var qe_current_pts = qe_pts.GetQEPointListByN(rated.Hz, current.Hz); |
| | | vm.CurrentCurveQE = qe_current_pts; |
| | | } |
| | | } |
| | | |
| | |
| | | this.hydroSinglePumpQueryPointListGridCtrl1.SetBindingData(vmList); |
| | | } |
| | | |
| | | //编辑曲线 |
| | | private void PumpOperationChart1_EditCurveEvent() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | if (_pumpInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var curveqh = _hydroInfo.Curves?.Find(x => x.Code == _pumpInfo.CurveQH); |
| | | if (curveqh == null) |
| | | { |
| | | return; |
| | | } |
| | | var qh_pts = curveqh.CurveData?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList(); |
| | | var curveqp = _hydroInfo.Curves?.Find(x => x.Code == _pumpInfo.CurveQP); |
| | | if (curveqp == null) |
| | | { |
| | | return; |
| | | } |
| | | var qp_pts = curveqp.CurveData?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList(); |
| | | var curveqe = _hydroInfo.Curves?.Find(x => x.Code == _pumpInfo.CurveQE); |
| | | if (curveqe == null) |
| | | { |
| | | return; |
| | | } |
| | | var qe_pts = curveqe.CurveData?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList(); |
| | | |
| | | var dlg = new SimulationPumpCurveEditDlg(); |
| | | dlg.SetBindingData(qh_pts, qp_pts, qe_pts); |
| | | dlg.ReloadDataEvent += (curveqh_rhs, curveqp_rhs, curveqe_rhs) => |
| | | { |
| | | curveqh.CurveData = curveqh_rhs.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); |
| | | _changeHelper?.Append(curveqh, eChangeType.Update); |
| | | curveqp.CurveData = curveqp_rhs.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); |
| | | _changeHelper?.Append(curveqp, eChangeType.Update); |
| | | curveqe.CurveData = curveqe_rhs.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); |
| | | _changeHelper?.Append(curveqe, eChangeType.Update); |
| | | var allStateList = this.hydroSinglePumpListExtendGridCtrl1.GetStateList(); |
| | | _vm = CreateViewModel(allStateList); |
| | | this.pumpOperationChart1.SetBindingData(_vm); |
| | | |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //设计点 |
| | | private void btnDesign_Click(object sender, EventArgs e) |
| | | { |
| | | Design(); |
| | | } |
| | | |
| | | //设计 |
| | | private void Design() |
| | | { |
| | | var qtext = this.txtDesignQ.Text.Trim(); |
| | | if (string.IsNullOrEmpty(qtext)) |
| | |
| | | } |
| | | var q = double.Parse(qtext); |
| | | var h = double.Parse(htext); |
| | | this.pumpOperationChart1.SetDesignPoint(q, h); |
| | | this.pumpOperationChart1.SetDesignPoint(q, h, _head); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | if (this.hydroSinglePumpListExtendGridCtrl1.HasChanged) |
| | | { |
| | | this.hydroSinglePumpListExtendGridCtrl1.HasChanged = false; |
| | | var result = XtraMessageBox.Show("是否使用现有状态更新模型?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes; |
| | | if (!result) |
| | | { |
| | |
| | | LinkStatus = _pumpInfo.LinkStatus, |
| | | CurrentHz = allStateList[1].Hz |
| | | }; |
| | | |
| | | this.SaveEvent?.Invoke(working); |
| | | } |
| | | } |