lixiaojun
2024-12-11 be1dcb30e552fff6a2cf733d6577b103665edded
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();