From be1dcb30e552fff6a2cf733d6577b103665edded Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期三, 11 十二月 2024 17:31:32 +0800
Subject: [PATCH] 增加能耗分析图片

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/08-working/XhsProjectSimulationWorkingPage.cs |  230 +++++++++++++++++++++------------------------------------
 1 files changed, 84 insertions(+), 146 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/08-working/XhsProjectSimulationWorkingPage.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/08-working/XhsProjectSimulationWorkingPage.cs
index 3da1ec5..01db1af 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/08-working/XhsProjectSimulationWorkingPage.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/08-working/XhsProjectSimulationWorkingPage.cs
@@ -111,7 +111,7 @@
                 {//榧犳爣宸﹂敭鐐瑰嚮浜嬩欢
                     var visualListHelper = GetVisualListHelper();
                     var visual = visualListHelper.GetVisual(code);
-                    SelectVisual(visual, eVisualSource.Bimface);
+                    SelectVisual(visual, eSimulationVisualSource.Bimface);
                 };
             }
             return _bimfaceCtrl;
@@ -148,7 +148,7 @@
                 {
                     var visualListHelper = GetVisualListHelper();
                     var visuals = visualListHelper.GetVisualList(codes);
-                    SelectVisual(visuals?.LastOrDefault(), eVisualSource.Q3d);
+                    SelectVisual(visuals?.LastOrDefault(), eSimulationVisualSource.Q3d);
                 };
             }
             return _q3dCtrl;
@@ -183,7 +183,7 @@
                 _propertyCtrl.AllowEdit = false;
                 _propertyCtrl.HydroViewEvent += (visual) =>
                 {
-                    SelectVisual(visual, eVisualSource.Property);
+                    SelectVisual(visual, eSimulationVisualSource.Property);
                 };
                 _propertyCtrl.BlinkLinkNodeEvent += async (link, linkNodeCode) =>
                 { //寮鸿皟杩炴帴鑺傜偣
@@ -280,83 +280,74 @@
 
         #region 閫夋嫨鏋勪欢
 
-        //鍙鏉ユ簮
-        protected enum eVisualSource
-        {
-            None,
-            Bimface,
-            Q3d,
-            Property,
-            List,
-            Search,
-            Monitor,
-            Check,
-            Calcu,
-            Warning,
-        }
-
         //閫夋嫨鏋勪欢
         private Yw.Model.HydroVisualInfo _visual = null;
 
         //閫夋嫨鏋勪欢
-        private void SelectVisual(HydroVisualInfo visual, eVisualSource source)
+        private void SelectVisual(HydroVisualInfo visual, eSimulationVisualSource source)
         {
             _visual = visual;
             switch (source)
             {
-                case eVisualSource.None:
+                case eSimulationVisualSource.None:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                         SetPropertyCtrl(visual);
                     }
                     break;
-                case eVisualSource.Bimface:
+                case eSimulationVisualSource.Bimface:
                     {
                         SetPropertyCtrl(visual);
                     }
                     break;
-                case eVisualSource.Q3d:
+                case eSimulationVisualSource.Q3d:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                         SetPropertyCtrl(visual);
                     }
                     break;
-                case eVisualSource.Property:
+                case eSimulationVisualSource.Property:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                     }
                     break;
-                case eVisualSource.List:
+                case eSimulationVisualSource.List:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                         SetPropertyCtrl(visual);
                     }
                     break;
-                case eVisualSource.Search:
+                case eSimulationVisualSource.Set:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                         SetPropertyCtrl(visual);
                     }
                     break;
-                case eVisualSource.Monitor:
+                case eSimulationVisualSource.Search:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                         SetPropertyCtrl(visual);
                     }
                     break;
-                case eVisualSource.Check:
+                case eSimulationVisualSource.Monitor:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                         SetPropertyCtrl(visual);
                     }
                     break;
-                case eVisualSource.Calcu:
+                case eSimulationVisualSource.Check:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                         SetPropertyCtrl(visual);
                     }
                     break;
-                case eVisualSource.Warning:
+                case eSimulationVisualSource.Calcu:
+                    {
+                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
+                        SetPropertyCtrl(visual);
+                    }
+                    break;
+                case eSimulationVisualSource.Warning:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                         SetPropertyCtrl(visual);
@@ -364,6 +355,13 @@
                     break;
                 default: break;
             }
+        }
+
+        //閫夋嫨鏋勪欢
+        private void SelectVisual(string code, eSimulationVisualSource source)
+        {
+            var visual = GetVisual(code);
+            SelectVisual(visual, source);
         }
 
         #endregion
@@ -471,7 +469,7 @@
                 _visualListCtrl.Dock = DockStyle.Fill;
                 _visualListCtrl.HydroClickInfoEvent += (visual) =>
                 {
-                    SelectVisual(visual, eVisualSource.List);
+                    SelectVisual(visual, eSimulationVisualSource.List);
                 };
             }
             return _visualListCtrl;
@@ -628,12 +626,12 @@
                 _searchCtrl.InitialData(allVisualVmList);
                 _searchCtrl.HydroClickInfoEvent += (visual) =>
                 {
-                    SelectVisual(visual, eVisualSource.Check);
+                    SelectVisual(visual, eSimulationVisualSource.Check);
                 };
                 _searchCtrl.HydroSearchInfoEvent += (list) =>
                 {
                     var visual = list?.FirstOrDefault();
-                    SelectVisual(visual, eVisualSource.Search);
+                    SelectVisual(visual, eSimulationVisualSource.Search);
                 };
             }
             return _searchCtrl;
@@ -896,6 +894,13 @@
             return _monitorHelper;
         }
 
+        //鑾峰彇鐩戞祴鐐瑰垪琛�
+        private async Task<List<HydroMonitorVmo>> GetMonitorList()
+        {
+            var helper = GetMonitorHelper();
+            return await helper.Get();
+        }
+
         #endregion
 
         #region 鐩戞祴鍊�
@@ -934,7 +939,7 @@
                 {
                     var visualListHelper = GetVisualListHelper();
                     var visual = visualListHelper.GetVisual(code);
-                    SelectVisual(visual, eVisualSource.Monitor);
+                    SelectVisual(visual, eSimulationVisualSource.Monitor);
                 };
             }
             return _monitorValueListCtrl;
@@ -1033,7 +1038,7 @@
                 {
                     var visualListHelper = GetVisualListHelper();
                     var visual = visualListHelper.GetVisual(code);
-                    SelectVisual(visual, eVisualSource.Check);
+                    SelectVisual(visual, eSimulationVisualSource.Check);
                 };
             }
             return _checkCtrl;
@@ -1186,7 +1191,7 @@
                 {
                     var visualListHelper = GetVisualListHelper();
                     var visual = visualListHelper.GetVisual(code);
-                    SelectVisual(visual, eVisualSource.Warning);
+                    SelectVisual(visual, eSimulationVisualSource.Warning);
                 };
             }
             return _calcuWarningCtrl;
@@ -1532,129 +1537,50 @@
             {
                 if (sources.Count == 1)
                 {
-                    SelectVisual(sources[0], eVisualSource.None);
+                    SelectVisual(sources[0], eSimulationVisualSource.None);
                 }
                 else
                 {
                     var source = sources.FirstOrDefault(x => x.Flags.Contains(HStation.Xhs.Flags.杩涘彛));
                     if (source != null)
                     {
-                        SelectVisual(source, eVisualSource.None);
+                        SelectVisual(source, eSimulationVisualSource.None);
                     }
                 }
             }
         }
 
+        //姘存车鍒嗘瀽
+        private void barBtnPumpAnaly_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            var workingHelper = GetWorkingHelper();
+            if (!workingHelper.Initialized)
+            {
+                TipFormHelper.ShowError("宸ュ喌璁$畻澶辫触锛�");
+                return;
+            }
+            var dlg = new SimulationSingleWorkingPumpAnalyDlg();
+            dlg.SetBindingData(workingHelper.HydroInfo, workingHelper.CalcuResult);
+            dlg.ShowDialog();
+        }
+
         //绮惧害璇勪及
         private async void barBtnWorkingEvaluation_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
-            var monitorHelper = GetMonitorHelper();
-            var allMonitorList = await monitorHelper.Get();
-
             var workingHelper = GetWorkingHelper();
             if (!workingHelper.Initialized)
             {
                 TipFormHelper.ShowWarn("宸ュ喌璁$畻澶辫触锛�");
                 return;
             }
+            var allMonitorList = await GetMonitorList();
             var dlg = new HydroSingleWorkingEvaluationDlg();
             dlg.SetBindingData(workingHelper.HydroInfo, allMonitorList, workingHelper.Working, workingHelper.CalcuResult);
             dlg.ShowDialog();
         }
 
-        //姘存车鍒嗘瀽
-        private void barBtnPumpAnaly_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
-        {
-            if (_hydroInfo == null)
-            {
-                return;
-            }
-            if (_hydroInfo.Pumps == null || _hydroInfo.Pumps.Count < 1)
-            {
-                return;
-            }
-
-            var calcuResultHelper = GetCalcuResultHelper();
-            var vmList = new List<XhsSinglePumpViewModel>();
-            foreach (var pump in _hydroInfo.Pumps)
-            {
-                if (!pump.RatedN.HasValue)
-                {
-                    continue;
-                }
-                var qh = _hydroInfo.Curves?.Find(t => t.Code == pump.CurveQH)?.CurveData;
-                var qe = _hydroInfo.Curves?.Find(t => t.Code == pump.CurveQE)?.CurveData;
-                var qp = _hydroInfo.Curves?.Find(t => t.Code == pump.CurveQP)?.CurveData;
-                if (qh == null)
-                {
-                    continue;
-                }
-
-                var qhPtList = qh.Select(x => new XhsSplinePointViewModel(x.X, x.Y)).ToList();
-                var qePtList = qe?.Select(x => new XhsSplinePointViewModel(x.X, x.Y)).ToList();
-                var qpPtList = qp?.Select(x => new XhsSplinePointViewModel(x.X, x.Y)).ToList();
-
-                var vm = new XhsSinglePumpViewModel();
-                vmList.Add(vm);
-                vm.ID = pump.ID;
-                vm.Name = pump.Name;
-                vm.Code = pump.Code;
-                vm.IsBp = true;
-                vm.RunStatus = pump.LinkStatus == Yw.Hydro.LinkStatus.Open;
-                vm.RatedHz = pump.RatedHz;
-                vm.CurrentHz = Math.Round(pump.RatedHz * pump.SpeedRatio, 1);
-                vm.RatedSpeed = pump.RatedN.Value;
-                vm.CurrentSpeed = Math.Round(pump.RatedN.Value * pump.SpeedRatio);
-                vm.CurveQH = qhPtList;
-                vm.CurveQE = qePtList;
-                vm.CurveQP = qpPtList;
-
-                var calcuResultVisualDict = calcuResultHelper.GetVisualDict();
-                if (calcuResultVisualDict != null && calcuResultVisualDict.Count > 0)
-                {
-                    //var calcuResult = allCalcuResultList.Find(x => x.Code == pump.Code) as HydroCalcuLinkResult;
-                    //if (calcuResult != null)
-                    //{
-                    //    if (calcuResult.CalcuFlow.HasValue)
-                    //    {
-                    //        vm.CalcuQ = Math.Abs(calcuResult.CalcuFlow.Value);
-                    //    }
-
-                    //    var calcuResultStart = allCalcuResultList.Find(x => x.Code == pump.StartCode) as HydroCalcuNodeResult;
-                    //    var calcuResultEnd = allCalcuResultList.Find(x => x.Code == pump.EndCode) as HydroCalcuNodeResult;
-                    //    if (calcuResultStart != null && calcuResultEnd != null)
-                    //    {
-                    //        if (calcuResultStart.CalcuHead.HasValue && calcuResultEnd.CalcuHead.HasValue)
-                    //        {
-                    //            vm.CalcuH = Math.Round(Math.Abs(calcuResultStart.CalcuHead.Value - calcuResultEnd.CalcuHead.Value), 4);
-                    //        }
-                    //    }
-                    //}
-                }
-
-            }
-
-            //var dlg = new PumpParallelAnalyDlg();
-            //dlg.SetBindingData(vmList);
-            //dlg.ReloadDataEvent += (list) =>
-            //{
-            //    list?.ForEach(x =>
-            //    {
-            //        var pump = _hydroInfo.Pumps?.Find(t => t.Code == x.Code);
-            //        if (pump != null)
-            //        {
-            //            pump.LinkStatus = x.RunStatus ? Yw.Hydro.PumpStatus.Open : Yw.Hydro.PumpStatus.Closed;
-            //            pump.SpeedRatio = Math.Round(x.CurrentHz / pump.RatedHz, 1);
-            //        }
-            //    });
-            //    //ShowSelectedProperty();
-            //    return true;
-            //};
-            //dlg.ShowDialog();
-        }
-
         //鑳芥晥鍒嗘瀽
-        private void barBtnWorkingPower_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        private async void barBtnWorkingPower_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
             var workingHelper = GetWorkingHelper();
             if (!workingHelper.Initialized)
@@ -1662,8 +1588,9 @@
                 TipFormHelper.ShowWarn("宸ュ喌璁$畻澶辫触锛�");
                 return;
             }
+            var allMonitorList = await GetMonitorList();
             var dlg = new SimulationSingleWorkingEnergyDlg();
-            dlg.SetBindingData(workingHelper.Working, workingHelper.HydroInfo, workingHelper.CalcuResult);
+            dlg.SetBindingData(workingHelper.Working, workingHelper.HydroInfo, allMonitorList, workingHelper.CalcuResult);
             dlg.ShowDialog();
         }
 
@@ -1686,14 +1613,18 @@
                 TipFormHelper.ShowError("宸ュ喌璁$畻澶辫触锛�");
                 return;
             }
+
             HydroVisualInfo visual = _visual;
-            if (_visual is HydroLinkInfo linkInfo)
+            if (_visual is HydroLinkInfo link)
             {
-                var visualListHelper = GetVisualListHelper();
-                visual = visualListHelper.GetVisual(linkInfo.StartCode);
+                visual = GetVisual(link.StartCode);
             }
 
             var dlg = new HydroSingleWorkingLossCurveDlg();
+            dlg.HydroClickEvent += (code) =>
+            {
+                SelectVisual(code, eSimulationVisualSource.None);
+            };
             dlg.SetBindingData(workingHelper.HydroInfo, workingHelper.CalcuResult, visual);
             dlg.ShowDialog();
         }
@@ -1715,11 +1646,25 @@
         //缁煎悎鍒嗘瀽
         private async void barBtnWorkingAnaly_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
-            if (_visual == null)
+            var workingHelper = GetWorkingHelper();
+            if (!workingHelper.Initialized)
             {
-                TipFormHelper.ShowWarn("璇烽�夋嫨鏋勪欢鍚庨噸璇曪紒");
+                TipFormHelper.ShowError("宸ュ喌璁$畻澶辫触锛�");
                 return;
             }
+            if (_visual == null)
+            {
+                if (_visual == null)
+                {
+                    SelectInputSource();
+                    if (_visual == null)
+                    {
+                        TipFormHelper.ShowWarn("璇烽�夋嫨鏋勪欢鍚庨噸璇曪紒");
+                        return;
+                    }
+                }
+            }
+
             HydroVisualInfo visual = _visual;
             if (_visual is HydroLinkInfo linkInfo)
             {
@@ -1727,15 +1672,8 @@
                 visual = visualListHelper.GetVisual(linkInfo.StartCode);
             }
 
-            var monitorHelper = GetMonitorHelper();
-            var allMonitorList = await monitorHelper.Get();
+            var allMonitorList = await GetMonitorList();
 
-            var workingHelper = GetWorkingHelper();
-            if (!workingHelper.Initialized)
-            {
-                TipFormHelper.ShowWarn("宸ュ喌璁$畻澶辫触锛�");
-                return;
-            }
             var dlg = new SimulationSingleWorkingAnalyDlg();
             dlg.SetBindingData(workingHelper.HydroInfo, allMonitorList, workingHelper.Working, workingHelper.CalcuResult, visual);
             dlg.ShowDialog();

--
Gitblit v1.9.3