lixiaojun
2024-10-16 00f80abcfbf890ab3718d960550380389c64cea3
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs
@@ -1,7 +1,6 @@
global using Yw.EPAnet;
using DevExpress.XtraMap.Drawing;
using NetTaste;
using Org.BouncyCastle.Crypto.Engines;
using Yw.WinFrmUI.Bimface;
using Yw.WinFrmUI.Hydro;
namespace HStation.WinFrmUI
{
@@ -13,7 +12,6 @@
            this.PageTitle.Caption = "水力模拟";
            this.PageTitle.HeaderSvgImage = this.svgImg32[0];
            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden;
        }
        private HStation.Vmo.XhsProjectVmo _project = null;//项目
@@ -68,8 +66,14 @@
            this.tabPageBimface.Controls.Clear();
            this.tabPageBimface.Controls.Add(bimfaceCtrl);
            await bimfaceCtrl.InitialData(_project, _projectSite, () => _hydroInfo);
            this.xhsProjectSimulationQ3dCtrl1.SetBindingData(_hydroInfo);
            this.xhsProjectSimulationPropertyCtrl1.InitialData(() => _hydroInfo);
            var q3dCtrl = GetQ3dCtrl();
            this.tabPageQ3d.Controls.Clear();
            this.tabPageQ3d.Controls.Add(q3dCtrl);
            q3dCtrl.InitialData(() => _hydroInfo);
            var propertyCtrl = GetPropertyCtrl();
            this.controlContainerRight.Controls.Clear();
            this.controlContainerRight.Controls.Add(propertyCtrl);
            propertyCtrl.InitialData(() => _hydroInfo);
        }
        #region Bimface
@@ -107,6 +111,7 @@
            }
            return _bimfaceCtrl;
        }
        //bimface控件
        private XhsProjectSimulationBimfaceCtrl _bimfaceCtrl = null;
@@ -171,29 +176,52 @@
            }
        }
        #endregion
        #endregion Bimface
        #region Q3d
        //点击事件
        private void xhsProjectSimulationQ3dCtrl1_ClickParterEvent(string code)
        //获取Q3d控件
        private XhsProjectSimulationQ3dCtrl GetQ3dCtrl()
        {
            if (_hydroInfo == null)
            if (_q3dCtrl == null)
            {
                return;
                _q3dCtrl = new XhsProjectSimulationQ3dCtrl();
                _q3dCtrl.Dock = DockStyle.Fill;
                _q3dCtrl.SelectedPartersChangedEvent += (obj) =>
                {
                    if (_hydroInfo == null)
                    {
                        return;
                    }
                    var allParterList = _hydroInfo.GetAllParters();
                    _parter = allParterList?.Find(x => x.Code == obj?.FirstOrDefault());
                    ShowProperty();
                };
            }
            var allParterList = _hydroInfo.GetAllParters();
            _parter = allParterList?.Find(x => x.Code == code);
            ShowProperty();
            return _q3dCtrl;
        }
        #endregion
        //Q3d控件
        private XhsProjectSimulationQ3dCtrl _q3dCtrl = null;
        #endregion Q3d
        #region 属性面板
        //获取属性控件
        private XhsProjectSimulationPropertyCtrl GetPropertyCtrl()
        {
            if (_propertyCtrl == null)
            {
                _propertyCtrl = new XhsProjectSimulationPropertyCtrl();
                _propertyCtrl.Dock = DockStyle.Fill;
            }
            return _propertyCtrl;
        }
        private XhsProjectSimulationPropertyCtrl _propertyCtrl = null;//属性控件
        #endregion
        #endregion 属性面板
        #region 自动匹配
@@ -232,6 +260,7 @@
            }
            return _matchingListCtrl;
        }
        //匹配列表控件
        private XhsProjectSimulationMatchingListCtrl _matchingListCtrl = null;
@@ -252,8 +281,7 @@
            this.docPnlBottom.Height = 350;
        }
        #endregion
        #endregion 自动匹配
        #region 未匹配列表
@@ -291,6 +319,7 @@
            }
            return _unMatchingListCtrl;
        }
        private XhsProjectSimulationUnMatchingListCtrl _unMatchingListCtrl = null;//未匹配列表
        //未匹配列表
@@ -309,9 +338,7 @@
            this.docPnlBottom.Height = 350;
        }
        #endregion
        #endregion 未匹配列表
        #region 一键显隐
@@ -341,7 +368,7 @@
            }
        }
        #endregion
        #endregion 一键显隐
        #region 水力校验
@@ -379,6 +406,7 @@
            }
            return _checkResultCtrl;
        }
        //校验结果控件
        private XhsProjectSimulationHydroCheckResultCtrl _checkResultCtrl = null;
@@ -399,7 +427,7 @@
            this.docPnlBottom.Height = 350;
        }
        #endregion
        #endregion 水力校验
        #region 保存水力信息
@@ -420,7 +448,7 @@
            TipFormHelper.ShowSucceed("保存成功!");
        }
        #endregion
        #endregion 保存水力信息
        #region 构件明细
@@ -446,6 +474,7 @@
            }
            return _parterListCtrl;
        }
        //构件明细控件
        private Yw.WinFrmUI.HydroParterListCtrl _parterListCtrl = null;
@@ -465,8 +494,7 @@
            this.docPnlBottom.Height = 350;
        }
        #endregion
        #endregion 构件明细
        #region INP导出
@@ -488,7 +516,7 @@
            TipFormHelper.ShowSucceed("导出成功");
        }
        #endregion
        #endregion INP导出
        #region 业务方法
@@ -499,12 +527,14 @@
            {
                return;
            }
            if (_parter == null)
            {
                this.xhsProjectSimulationPropertyCtrl1.SelectParter(null);
                _propertyCtrl?.SelectParter(null);
                return;
            }
            this.xhsProjectSimulationPropertyCtrl1.SelectParter(_parter.Code);
            _propertyCtrl?.SelectParter(_parter.Code);
            if (_calcuResult != null)
            {
                if (_calcuResult.Succeed)
@@ -535,14 +565,14 @@
                        if (calcuProperty != null)
                        {
                            this.xhsProjectSimulationPropertyCtrl1.UpdateCalcuProperty(calcuProperty);
                            _propertyCtrl?.UpdateCalcuProperty(calcuProperty);
                        }
                    }
                }
            }
        }
        #endregion
        #endregion 业务方法
        #region 配置
@@ -552,7 +582,7 @@
            this.rmSet.ShowPopup(MousePosition, true);
        }
        #endregion
        #endregion 配置
        #region 性能曲线
@@ -572,34 +602,56 @@
                return;
            }
            var pumps = _hydroInfo.Pumps;
            var curve_list = _hydroInfo.Curves;
            if (curve_list == null || !curve_list.Any())
            {
                return;
            }
            var vmList = new List<Yw.WinFrmUI.Phart.PumpSerialParallelViewModel>();
            foreach (var x in pumps)
            {
                if (!x.RatedN.HasValue)
                {
                    continue;
                }
                var qh = curve_list.Find(t => t.Code == x.CurveQH)?.CurveData;
                var qe = curve_list.Find(t => t.Code == x.CurveQE)?.CurveData;
                var qp = curve_list.Find(t => t.Code == x.CurveQP)?.CurveData;
                if (qh == null)
                {
                    continue;
                }
                var rated_speed = x.RatedN.Value;
                var speed_ratio = x.SpeedRatio ?? 1;
                var qh_pt_list = qh.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                var qe_pt_list = qe?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                var qp_pt_list = qp?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                var vm = new Yw.WinFrmUI.Phart.PumpSerialParallelViewModel();
                vm.Id = x.Code;
                vm.Name = x.Code;
                //vm.IsBp = ;
                //vm.RatedSpeed = 590;
                //vm.CurrentSpeed = 590;
                //vm.CurrentHz = 50;
                var PointsQH = _hydroInfo.Curves?.Find(t => t.Code == x.CurveQH)?.CurveData?.Select(z => new Yw.Geometry.Point2d() { X = z.X, Y = z.Y }).ToList();
                var PointsQP = _hydroInfo.Curves?.Find(t => t.Code == x.CurveQP)?.CurveData?.Select(z => new Yw.Geometry.Point2d { X = z.X, Y = z.Y }).ToList();
                var PointsQE = _hydroInfo.Curves?.Find(t => t.Code == x.CurveQE)?.CurveData?.Select(z => new Yw.Geometry.Point2d { X = z.X, Y = z.Y }).ToList();
                vm.RatedSpeed = rated_speed;
                vm.CurrentSpeed = Math.Round(rated_speed * speed_ratio);
                vm.CurrentHz = Math.Round(vm.CurrentSpeed / vm.RatedSpeed * 50, 1);
                vm.Qh = new Yw.Geometry.CubicSpline2d(PointsQH);
                vm.Qe = new Yw.Geometry.CubicSpline2d(PointsQE);
                vm.Qp = new Yw.Geometry.CubicSpline2d(PointsQP);
                vm.Qh = new Yw.Geometry.CubicSpline2d(qh_pt_list);
                vm.Qe = new Yw.Geometry.CubicSpline2d(qe_pt_list);
                vm.Qp = new Yw.Geometry.CubicSpline2d(qp_pt_list);
                vmList.Add(vm);
            }
            var dlg = new HStation.WinFrmUI.PhartRelation.PumpSerialParallelChartDlg();
            dlg.SetBindingData(vmList, null, true);
            dlg.ShowDialog();
        }
        #endregion
        #endregion 性能曲线
        #region 水力计算
        //获取计算控件
        private XhsProjectSimulationCalcuCtrl GetCalcuCtrl()
@@ -672,11 +724,11 @@
                            this.docPnlBottom.Height = 350;
                            TipFormHelper.ShowError("计算失败");
                        }
                    };
            }
            return _calcuCtrl;
        }
        private XhsProjectSimulationCalcuCtrl _calcuCtrl = null;//计算控件
        //水力计算
@@ -696,9 +748,7 @@
            this.docPnlBottom.Height = 350;
        }
        #endregion
        #endregion 水力计算
        #region 构件查询
@@ -735,6 +785,7 @@
            }
            return _searchCtrl;
        }
        private XhsProjectSimulationSearchCtrl _searchCtrl = null;//查询组件
        //查询
@@ -753,9 +804,78 @@
            this.docPnlBottom.Height = 350;
        }
        #endregion
        #endregion 构件查询
        #region 标注
        private List<HydroMarkSetViewModel> _allMarkList = null;
        //标注
        private void barBtnMark_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_hydroInfo == null)
            {
                return;
            }
            if (_allMarkList == null)
            {
                _allMarkList = new List<HydroMarkSetViewModel>();
                if (_hydroInfo.Waterboxs != null && _hydroInfo.Waterboxs.Count > 0)
                {
                    _allMarkList.Add(new HydroMarkSetViewModel()
                    {
                        Code = Yw.Hydro.ParterCatalog.Waterbox,
                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Waterbox),
                        MarkType = (int)eWaterboxMarkType.None
                    });
                }
                if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0)
                {
                    _allMarkList.Add(new HydroMarkSetViewModel()
                    {
                        Code = Yw.Hydro.ParterCatalog.Pump,
                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pump),
                        MarkType = (int)eWaterboxMarkType.None
                    });
                }
                if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0)
                {
                    _allMarkList.Add(new HydroMarkSetViewModel()
                    {
                        Code = Yw.Hydro.ParterCatalog.Valve,
                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Valve),
                        MarkType = (int)eWaterboxMarkType.None
                    });
                }
                if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0)
                {
                    _allMarkList.Add(new HydroMarkSetViewModel()
                    {
                        Code = Yw.Hydro.ParterCatalog.Pipe,
                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pipe),
                        MarkType = (int)eWaterboxMarkType.None
                    });
                }
                if (_hydroInfo.Nozzles != null && _hydroInfo.Nozzles.Count > 0)
                {
                    _allMarkList.Add(new HydroMarkSetViewModel()
                    {
                        Code = Yw.Hydro.ParterCatalog.Nozzle,
                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Nozzle),
                        MarkType = (int)eWaterboxMarkType.None
                    });
                }
            }
            var dlg = new SetHydroMarkDlg();
            dlg.SetBindingData(() => _hydroInfo, _allMarkList);
            dlg.ReloadDataEvent += async (obj) =>
            {
                var leadLabels = obj?.Select(x => new LeadLabel() { Id = x.Code, Text = x.Text }).ToList();
                await _bimfaceCtrl?.SetLeadLabels(leadLabels);
            };
            dlg.ShowDialog();
        }
        #endregion 标注
    }
}