From 97e1e604737e70a9df2e83897d3bbf68292d0d72 Mon Sep 17 00:00:00 2001 From: Shuxia Ning <NingShuxia0927@outlook.com> Date: 星期四, 19 十二月 2024 20:21:52 +0800 Subject: [PATCH] 代码修改 --- WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/09-energy/SimulationSingleWorkingEnergyCtrl.cs | 179 +++++++++-------------------------------------------------- 1 files changed, 27 insertions(+), 152 deletions(-) diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/09-energy/SimulationSingleWorkingEnergyCtrl.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/09-energy/SimulationSingleWorkingEnergyCtrl.cs index cc049b8..0c4cdaa 100644 --- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/09-energy/SimulationSingleWorkingEnergyCtrl.cs +++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/09-energy/SimulationSingleWorkingEnergyCtrl.cs @@ -12,6 +12,7 @@ using Yw.EPAnet; using Yw.Geometry; using Yw.Pump; +using Yw.Vmo; using Yw.WinFrmUI.Phart; namespace HStation.WinFrmUI @@ -22,38 +23,43 @@ { InitializeComponent(); this.layoutControl1.SetupLayoutControl(); - this.hydroPumpListStateViewCtrl1.SelectedChangedEvent += HydroPumpRunStatusListCtrl1_SelectedChangedEvent; } + private HydroWorkingVmo _working = null;//宸ュ喌 private Yw.Model.HydroModelInfo _hydroInfo = null;//姘村姏淇℃伅 + private List<HydroMonitorVmo> _allMonitorList = null;//鐩戞祴鍒楄〃 private Dictionary<string, HydroCalcuVisualResult> _allCalcuResultVisualDict = null;//鎵�鏈夎绠楃粨鏋滃彲瑙佸瓧鍏� /// <summary> /// 缁戝畾鏁版嵁 /// </summary> - public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, HydroCalcuResult calcuResult) + public void SetBindingData + ( + HydroWorkingVmo working, + Yw.Model.HydroModelInfo hydroInfo, + List<HydroMonitorVmo> allMonitorList, + HydroCalcuResult calcuResult + ) { - if (hydroInfo == null) - { - return; - } - if (calcuResult == null) - { - return; - } - if (!calcuResult.Succeed) - { - return; - } - var allCalcuResultVisualDict = calcuResult.GetVisualDict(); - SetBindingData(hydroInfo, allCalcuResultVisualDict); + var allCalcuResultVisualDict = calcuResult?.GetVisualDict(); + SetBindingData(working, hydroInfo, allMonitorList, allCalcuResultVisualDict); } /// <summary> /// 缁戝畾鏁版嵁 /// </summary> - public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict) + public void SetBindingData + ( + HydroWorkingVmo working, + Yw.Model.HydroModelInfo hydroInfo, + List<HydroMonitorVmo> allMonitorList, + Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict + ) { + if (working == null) + { + return; + } if (hydroInfo == null) { return; @@ -62,148 +68,17 @@ { return; } + _working = working; _hydroInfo = hydroInfo; + _allMonitorList = allMonitorList; _allCalcuResultVisualDict = allCalcuResultVisualDict; - this.hydroEnergyTotalViewCtrl1.SetBindingData(hydroInfo, allCalcuResultVisualDict); - this.hydroPumpListStateViewCtrl1.SetBindingData(hydroInfo); + this.hydroEnergyTotalHorizViewCtrl1.SetBindingData(_hydroInfo, _allCalcuResultVisualDict); + this.simulationSingleWorkingPumpCtrl1.SetBindingData(_working, _hydroInfo, _allMonitorList, _allCalcuResultVisualDict); } - //娉甸�夋嫨鏀瑰彉 - private void HydroPumpRunStatusListCtrl1_SelectedChangedEvent(Yw.Model.HydroPumpInfo pump) - { - if (_hydroInfo == null) - { - return; - } - if (_allCalcuResultVisualDict == null || _allCalcuResultVisualDict.Count < 1) - { - return; - } - if (pump == null) - { - return; - } - this.groupForSinglePumpInfo.Text = pump.Name; - this.txtQ.EditValue = null; - this.txtH.EditValue = null; - this.txtP.EditValue = null; - this.txtE.EditValue = null; - if (_allCalcuResultVisualDict.ContainsKey(pump.Code)) - { - var calcuResult = _allCalcuResultVisualDict[pump.Code] as HydroCalcuPumpResult; - if (calcuResult != null) - { - if (pump.LinkStatus == Yw.Hydro.PumpStatus.Open) - { - this.txtQ.EditValue = calcuResult.CalcuQ.HasValue ? $"{Math.Round(calcuResult.CalcuQ.Value, 1)}m鲁/h" : null; - this.txtH.EditValue = calcuResult.CalcuH.HasValue ? $"{Math.Round(calcuResult.CalcuH.Value, 2)}m" : null; - this.txtP.EditValue = calcuResult.CalcuP.HasValue ? $"{Math.Round(calcuResult.CalcuP.Value, 1)}kW" : null; - this.txtE.EditValue = calcuResult.CalcuE.HasValue ? $"{Math.Round(calcuResult.CalcuE.Value, 1)}%" : null; - } - var vm = CreateViewModel(pump); - this.pumpRunViewChart1.SetBindingData(vm); - } - } - } - //鍒涘缓 - private PumpRunViewViewModel CreateViewModel(Yw.Model.HydroPumpInfo pump) - { - if (_hydroInfo == null) - { - return default; - } - var vm = new PumpRunViewViewModel(); - vm.Id = pump.Code; - vm.Name = pump.Name; - vm.CurveName = $"棰濆畾鏇茬嚎({pump.RatedHz}hz)"; - vm.RatedQ = pump.RatedQ.HasValue ? pump.RatedQ.Value : 0; - vm.RatedH = pump.RatedH.HasValue ? pump.RatedH.Value : 0; - vm.RatedP = pump.RatedP; - vm.RatedN = pump.RatedN.HasValue ? pump.RatedN.Value : 0; - vm.RatedHz = pump.RatedHz; - vm.Color = Color.LightGray; - - var curveqh = _hydroInfo.Curves?.Find(x => x.Code == pump.CurveQH); - if (curveqh != null) - { - 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); - } - } - - var curveqp = _hydroInfo.Curves?.Find(x => x.Code == pump.CurveQP); - if (curveqp != null) - { - 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(qp_pts); - } - } - - var curveqe = _hydroInfo.Curves?.Find(x => x.Code == pump.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) - { - vm.CurveQE = new CubicSpline2d(qepts); - } - } - - if (pump.LinkStatus == Yw.Hydro.PumpStatus.Open) - { - vm.Items = new List<PumpRunViewItemViewModel>(); - var vmItem = new PumpRunViewItemViewModel(); - vm.Items.Add(vmItem); - vmItem.Id = string.Empty; - vmItem.Name = "杩愯"; - vmItem.Hz = Math.Round(pump.RatedHz * pump.SpeedRatio, 1); - vmItem.Color = Color.Green; - if (pump.RatedN.HasValue) - { - vmItem.N = Math.Round(pump.RatedN.Value * pump.SpeedRatio, 1); - } - var calcuResult = _allCalcuResultVisualDict?.GetValue(pump.Code) as HydroCalcuPumpResult; - if (calcuResult != null) - { - vmItem.Q = calcuResult.CalcuQ ?? 0; - vmItem.H = calcuResult.CalcuH ?? 0; - vmItem.P = calcuResult.CalcuP; - vmItem.E = calcuResult.CalcuE; - } - vmItem.CurveName = $"杩愯鏇茬嚎({vmItem.Hz}hz)"; - - if (vm.CurveQH != null) - { - var qh_pts = vm.CurveQH.GetPointList(20); - var qh_run_pts = qh_pts.GetQHPointListByN(vm.RatedHz, vmItem.Hz); - vmItem.CurveQH = new CubicSpline2d(qh_run_pts); - } - - if (vm.CurveQP != null) - { - var qp_pts = vm.CurveQP.GetPointList(20); - var qp_run_pts = qp_pts.GetQPPointListByN(vm.RatedHz, vmItem.Hz); - vmItem.CurveQP = new CubicSpline2d(qp_run_pts); - } - - if (vm.CurveQE != null) - { - var qe_pts = vm.CurveQE.GetPointList(20); - var qe_run_pts = qe_pts.GetQEPointListByN(vm.RatedHz, vmItem.Hz); - vmItem.CurveQE = new CubicSpline2d(qe_run_pts); - } - - } - - return vm; - } } } -- Gitblit v1.9.3