| | |
| | | global using Yw.EPAnet; |
| | | using DevExpress.Mvvm.Native; |
| | | using DevExpress.XtraRichEdit.Layout; |
| | | using DevExpress.XtraSpreadsheet.Commands; |
| | | using HStation.WinFrmUI.PhartRelation; |
| | | using Yw.Pump; |
| | | using Yw.WinFrmUI.Bimface; |
| | | using Yw.WinFrmUI.Hydro; |
| | | |
| | |
| | | this.PageTitle.Caption = "水力模拟"; |
| | | this.PageTitle.HeaderSvgImage = this.svgImg32[0]; |
| | | this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; |
| | | this.docPnlRight.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; |
| | | RegistBulkSetEvents(); |
| | | } |
| | | |
| | |
| | | /// <summary> |
| | | /// 初始化数据 |
| | | /// </summary> |
| | | public override async void InitialDataSource() |
| | | public override void InitialDataSource() |
| | | { |
| | | base.InitialDataSource(); |
| | | if (_project == null) |
| | |
| | | return; |
| | | } |
| | | this.PageTitle.Caption = $"{_project.Name}\r\n水力模拟"; |
| | | var bimfaceCtrl = GetBimfaceCtrl(); |
| | | this.tabPageBimface.Controls.Clear(); |
| | | this.tabPageBimface.Controls.Add(bimfaceCtrl); |
| | | await bimfaceCtrl.InitialData(_project, _projectSite, () => _hydroInfo); |
| | | var q3dCtrl = GetQ3dCtrl(); |
| | | this.tabPageQ3d.Controls.Clear(); |
| | | this.tabPageQ3d.Controls.Add(q3dCtrl); |
| | | q3dCtrl.InitialData(() => _hydroInfo); |
| | | ShowBimfaceCtrl(); |
| | | ShowQ3dCtrl(); |
| | | ShowPropertyCtrl(); |
| | | |
| | | } |
| | |
| | | private XhsProjectSimulationBimfaceCtrl _bimfaceCtrl = null; |
| | | |
| | | //获取 bimface 控件 |
| | | private XhsProjectSimulationBimfaceCtrl GetBimfaceCtrl() |
| | | private async Task<XhsProjectSimulationBimfaceCtrl> GetBimfaceCtrl() |
| | | { |
| | | if (_bimfaceCtrl == null) |
| | | { |
| | | _bimfaceCtrl = new XhsProjectSimulationBimfaceCtrl(); |
| | | _bimfaceCtrl.Dock = DockStyle.Fill; |
| | | _bimfaceCtrl.LoadCompletedEvent += async () => |
| | | await _bimfaceCtrl.InitialData(_project, _projectSite, () => _hydroInfo); |
| | | _bimfaceCtrl.LoadCompletedEvent += () => |
| | | {//view加载完成事件 |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var elementIds = new List<string>(); |
| | | var pumps = _hydroInfo.Pumps?.Where(x => x.LinkStatus == Yw.Hydro.PumpStatus.Open).ToList(); |
| | | pumps?.ForEach(x => elementIds.Add(x.Code)); |
| | | var valves = _hydroInfo.Valves?.Where(x => x.LinkStatus == Yw.Hydro.ValveStatus.Open).ToList(); |
| | | valves?.ForEach(x => elementIds.Add(x.Code)); |
| | | await _bimfaceCtrl?.SetOpenComponentsColor(elementIds); |
| | | }; |
| | | _bimfaceCtrl.HydroMouseLeftClickEvent += (obj) => |
| | | {//鼠标左键点击事件 |
| | |
| | | } |
| | | _parter = obj; |
| | | ShowProperty(); |
| | | SetBimfaceLinkColor(); |
| | | }; |
| | | } |
| | | return _bimfaceCtrl; |
| | | } |
| | | |
| | | |
| | | |
| | | //设置Bimface连接颜色 |
| | | private async void SetBimfaceLinkColor() |
| | | //显示 bimface 控件 |
| | | private async void ShowBimfaceCtrl() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | if (_parter != null) |
| | | { |
| | | if (_parter is Yw.Model.HydroLinkInfo link) |
| | | { |
| | | await _bimfaceCtrl?.RestoreLinkComponentsColor(); |
| | | |
| | | var allVisualList = _hydroInfo.GetAllVisuals(); |
| | | var allLinkList = _hydroInfo.GetAllLinks(); |
| | | var startParter = allVisualList?.Find(x => x.Code == link.StartCode); |
| | | if (startParter != null) |
| | | { |
| | | var startElementIds = new List<string>(); |
| | | if (startParter.GetType() == typeof(Yw.Model.HydroJunctionInfo)) |
| | | { |
| | | var startLinkList = allLinkList?.Where(x => x.StartCode == startParter.Code || x.EndCode == startParter.Code && x.Code != _parter.Code).ToList(); |
| | | if (startLinkList != null && startLinkList.Count > 0) |
| | | { |
| | | startElementIds.AddRange(startLinkList.Select(x => x.Code)); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | startElementIds.Add(startParter.Code); |
| | | } |
| | | if (startElementIds.Count > 0) |
| | | { |
| | | await _bimfaceCtrl?.SetLinkStartComponentsColor(startElementIds); |
| | | } |
| | | } |
| | | var endParter = allVisualList?.Find(x => x.Code == link.EndCode); |
| | | if (endParter != null) |
| | | { |
| | | var endElementIds = new List<string>(); |
| | | if (endParter.GetType() == typeof(Yw.Model.HydroJunctionInfo)) |
| | | { |
| | | var endLinkList = allLinkList?.Where(x => x.StartCode == endParter.Code || x.EndCode == endParter.Code && x.Code != _parter.Code).ToList(); |
| | | if (endLinkList != null && endLinkList.Count > 0) |
| | | { |
| | | endElementIds.AddRange(endLinkList.Select(x => x.Code)); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | endElementIds.Add(endParter.Code); |
| | | } |
| | | if (endElementIds.Count > 0) |
| | | { |
| | | await _bimfaceCtrl?.SetLinkEndComponentsColor(endElementIds); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | var bimfaceCtrl = await GetBimfaceCtrl(); |
| | | this.tabPageBimface.Controls.Clear(); |
| | | this.tabPageBimface.Controls.Add(bimfaceCtrl); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Q3d |
| | | |
| | | //获取Q3d控件 |
| | | //Q3d 控件 |
| | | private XhsProjectSimulationQ3dCtrl _q3dCtrl = null; |
| | | |
| | | //获取 Q3d 控件 |
| | | private XhsProjectSimulationQ3dCtrl GetQ3dCtrl() |
| | | { |
| | | if (_q3dCtrl == null) |
| | | { |
| | | _q3dCtrl = new XhsProjectSimulationQ3dCtrl(); |
| | | _q3dCtrl.Dock = DockStyle.Fill; |
| | | _q3dCtrl.InitialData(() => _hydroInfo); |
| | | _q3dCtrl.SelectedPartersChangedEvent += (obj) => |
| | | { |
| | | if (_hydroInfo == null) |
| | |
| | | return _q3dCtrl; |
| | | } |
| | | |
| | | //Q3d控件 |
| | | private XhsProjectSimulationQ3dCtrl _q3dCtrl = null; |
| | | //显示 Q3d 控件 |
| | | private void ShowQ3dCtrl() |
| | | { |
| | | var q3dCtrl = GetQ3dCtrl(); |
| | | this.tabPageQ3d.Controls.Clear(); |
| | | this.tabPageQ3d.Controls.Add(q3dCtrl); |
| | | } |
| | | |
| | | #endregion Q3d |
| | | #endregion |
| | | |
| | | #region 属性面板 |
| | | #region 构件属性 |
| | | |
| | | //属性控件 |
| | | private XhsProjectSimulationPropertyCtrl _propertyCtrl = null; |
| | |
| | | { |
| | | ShowPropertyCtrl(); |
| | | } |
| | | |
| | | if (_parter == null) |
| | | { |
| | | _propertyCtrl?.SelectParter(null); |
| | | return; |
| | | } |
| | | |
| | | _propertyCtrl?.SelectParter(_parter.Code); |
| | | if (_calcuResult != null) |
| | | { |
| | | if (_calcuResult.Succeed) |
| | | { |
| | | var allCalcuParterList = _calcuResult.GetParterList(); |
| | | var calcuParter = allCalcuParterList.Find(x => x.Id == _parter.Code); |
| | | if (calcuParter != null) |
| | | { |
| | | IHydroCalcuResult calcuProperty = null; |
| | | if (calcuParter is Yw.EPAnet.CalcuNode calcuNode) |
| | | { |
| | | var calcuNodeProperty = new Yw.WinFrmUI.HydroCalcuNodeResult(); |
| | | calcuNodeProperty.Code = _parter.Code; |
| | | calcuNodeProperty.CalcuPress = calcuNode.Press; |
| | | calcuNodeProperty.CalcuDemand = calcuNode.Demand; |
| | | calcuNodeProperty.CalcuHead = calcuNode.Head; |
| | | calcuProperty = calcuNodeProperty; |
| | | } |
| | | else if (calcuParter is Yw.EPAnet.CalcuLink calcuLink) |
| | | { |
| | | var calcuLinkProperty = new Yw.WinFrmUI.HydroCalcuLinkResult(); |
| | | calcuLinkProperty.Code = _parter.Code; |
| | | calcuLinkProperty.CalcuHeadLoss = calcuLink.Headloss; |
| | | calcuLinkProperty.CalcuFlow = calcuLink.Flow; |
| | | calcuLinkProperty.CalcuVelocity = calcuLink.Velocity; |
| | | calcuProperty = calcuLinkProperty; |
| | | } |
| | | |
| | | if (calcuProperty != null) |
| | | { |
| | | _propertyCtrl?.UpdateCalcuProperty(calcuProperty); |
| | | } |
| | | } |
| | | var allCalcuResultList = GetAllCalcuResultList(); |
| | | if (allCalcuResultList != null && allCalcuResultList.Count > 0) |
| | | { |
| | | var calcuResult = allCalcuResultList.Find(x => x.Code == _parter.Code); |
| | | if (calcuResult != null) |
| | | { |
| | | _propertyCtrl?.UpdateCalcuProperty(calcuResult); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | #endregion |
| | |
| | | } |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds); |
| | | ShowProperty(); |
| | | SetBimfaceLinkColor(); |
| | | }; |
| | | _matchingListCtrl.ApplyMatchingEvent += (output) => |
| | | { |
| | |
| | | this.docPnlBottom.Height = 350; |
| | | } |
| | | |
| | | #endregion 自动匹配 |
| | | #endregion |
| | | |
| | | #region 未匹配列表 |
| | | |
| | |
| | | var elementIds = new List<string>() { parter.Code }; |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds); |
| | | ShowProperty(); |
| | | SetBimfaceLinkColor(); |
| | | }; |
| | | _unMatchingListCtrl.ViewModelEvent += async (parters) =>//查看模型 |
| | | { |
| | |
| | | this.docPnlBottom.Height = 350; |
| | | } |
| | | |
| | | #endregion 未匹配列表 |
| | | #endregion |
| | | |
| | | #region 一键显隐 |
| | | |
| | |
| | | } |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds); |
| | | ShowProperty(); |
| | | SetBimfaceLinkColor(); |
| | | }; |
| | | } |
| | | return _checkCtrl; |
| | | } |
| | | |
| | | //显示校验控件 |
| | | //显示检查控件 |
| | | private void ShowCheckCtrl() |
| | | { |
| | | if (_checkResult == null) |
| | |
| | | this.controlContainerBottom.Controls.Clear(); |
| | | this.controlContainerBottom.Controls.Add(checkCtrl); |
| | | this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; |
| | | this.docPnlBottom.Text = "校验结果"; |
| | | this.docPnlBottom.Text = "检查结果"; |
| | | this.docPnlBottom.Height = 350; |
| | | |
| | | } |
| | | |
| | | //水力验证 |
| | | //水力检查 |
| | | private void barBtnHydroCheck_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (_hydroInfo == null) |
| | |
| | | ShowCheckCtrl(); |
| | | } |
| | | |
| | | #endregion 水力校验 |
| | | #endregion |
| | | |
| | | #region 保存信息 |
| | | |
| | |
| | | TipFormHelper.ShowSucceed("保存成功!"); |
| | | } |
| | | |
| | | #endregion 保存水力信息 |
| | | #endregion |
| | | |
| | | #region 构件明细 |
| | | |
| | |
| | | _parter = allParterList?.Find(x => x.Code == parter.Code); |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _parter.Code }); |
| | | ShowProperty(); |
| | | SetBimfaceLinkColor(); |
| | | }; |
| | | } |
| | | return _parterListCtrl; |
| | |
| | | ShowParterListCtrl(); |
| | | } |
| | | |
| | | #endregion 构件明细 |
| | | #endregion |
| | | |
| | | #region INP导出 |
| | | |
| | |
| | | //闷头 |
| | | this.barBtnSetBluntheadList.ItemClick += delegate |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroBluntheadBulkSetListDlg(); |
| | | dlg.ShowDialog(); |
| | | }; |
| | | //弯头 |
| | | this.barBtnSetElbowsList.ItemClick += delegate |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroElbowBulkSetListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | | //三通 |
| | | this.barBtnSetThreelinkList.ItemClick += delegate |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroThreelinkBulkSetListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | | //四通 |
| | | this.barBtnSetFourlinkList.ItemClick += delegate |
| | | { |
| | | |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroFourlinkBulkSetListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | | //水表 |
| | | this.barBtnSetMeterList.ItemClick += delegate |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroMeterBulkSetListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | | //流量计 |
| | | this.barBtnSetFlowmeterList.ItemClick += delegate |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroFlowmeterBulkSetListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | | //压力表 |
| | | this.barBtnSetPressmeterList.ItemClick += delegate |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroPressmeterBulkSetListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | | //管道 |
| | | this.barBtnSetPipeList.ItemClick += delegate |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroPipeBulkSetListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | | //水泵 |
| | | this.barBtnSetPumpList.ItemClick += delegate |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroPumpBulkSetListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | | //阀门 |
| | | this.barBtnSetValveList.ItemClick += delegate |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroValveBulkSetListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | var dlg = new PumpParallelChartDlg(); |
| | | 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); |
| | | } |
| | | }); |
| | | ShowProperty(); |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | |
| | | |
| | | #region 水力计算 |
| | | |
| | | //计算控件 |
| | | private SetHydroCalcuPrefixCtrl _calcuCtrl = null; |
| | | |
| | | //获取计算控件 |
| | | private SetHydroCalcuPrefixCtrl GetCalcuCtrl() |
| | | #region 前提条件 |
| | | |
| | | //显示计算前提条件窗体 |
| | | private async void ShowCalcuPrefixDlg() |
| | | { |
| | | if (_calcuCtrl == null) |
| | | if (_hydroInfo == null) |
| | | { |
| | | _calcuCtrl = new SetHydroCalcuPrefixCtrl(); |
| | | _calcuCtrl.Dock = DockStyle.Fill; |
| | | _calcuCtrl.InitialData(() => _hydroInfo); |
| | | _calcuCtrl.HydroViewEvent += async (parter) => |
| | | {//水力查看事件 |
| | | if (parter == null) |
| | | { |
| | | return; |
| | | } |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { parter.Code }); |
| | | }; |
| | | _calcuCtrl.HydroCalcuEvent += async () => |
| | | {//水力计算事件 |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | //校验 |
| | | _checkResult = _hydroInfo.Check(); |
| | | if (!_checkResult.Succeed) |
| | | { |
| | | ShowCheckCtrl(); |
| | | TipFormHelper.ShowWarn("校验失败,请检查后重试"); |
| | | return; |
| | | } |
| | | |
| | | var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo); |
| | | _calcuResult = netWork.Calcu(); |
| | | if (_calcuResult.Succeed) |
| | | { |
| | | this.docPnlRight.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; |
| | | await _bimfaceCtrl?.SetLogicCalcuCustomLabels(_calcuResult); |
| | | TipFormHelper.ShowSucceed("计算成功!"); |
| | | } |
| | | else |
| | | { |
| | | _calcuCtrl.SetFailedList(_calcuResult.FailedList); |
| | | this.docPnlRight.Text = "失败原因"; |
| | | this.docPnlRight.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; |
| | | TipFormHelper.ShowError("计算失败"); |
| | | } |
| | | }; |
| | | return; |
| | | } |
| | | return _calcuCtrl; |
| | | var dlg = new SetHydroCalcuPrefixDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.HydroViewEvent += async (parter) => |
| | | { |
| | | _parter = parter; |
| | | if (_parter != null) |
| | | { |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _parter.Code }); |
| | | } |
| | | ShowProperty(); |
| | | }; |
| | | dlg.HydroCalcuEvent += async () => |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | //校验 |
| | | _checkResult = _hydroInfo.Check(); |
| | | if (!_checkResult.Succeed) |
| | | { |
| | | ShowCheckCtrl(); |
| | | TipFormHelper.ShowWarn("校验失败,请检查后重试"); |
| | | return; |
| | | } |
| | | |
| | | var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo); |
| | | _calcuResult = netWork.Calcu(); |
| | | if (_calcuResult.Succeed) |
| | | { |
| | | GetAllCalcuResultList(false); |
| | | await _bimfaceCtrl?.SetLogicCalcuCustomLabels(_calcuResult); |
| | | TipFormHelper.ShowSucceed("计算成功!"); |
| | | } |
| | | else |
| | | { |
| | | ShowCalcuFailedCtrl(); |
| | | TipFormHelper.ShowError("计算失败!"); |
| | | } |
| | | |
| | | }; |
| | | if (dlg.ShowDialog() == DialogResult.Cancel) |
| | | { |
| | | await _bimfaceCtrl?.ClearLogicCalcuCustomLabels(); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 计算失败 |
| | | |
| | | //计算失败控件 |
| | | private HydroCalcuFailedCtrl _calcuFailedCtrl = null; |
| | | |
| | | //获取计算失败控件 |
| | | private HydroCalcuFailedCtrl GetCalcuFailedCtrl() |
| | | { |
| | | if (_calcuFailedCtrl == null) |
| | | { |
| | | _calcuFailedCtrl = new HydroCalcuFailedCtrl(); |
| | | _calcuFailedCtrl.Dock = DockStyle.Fill; |
| | | } |
| | | return _calcuFailedCtrl; |
| | | } |
| | | |
| | | //显示计算失败控件 |
| | | private void ShowCalcuFailedCtrl() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | if (_calcuResult == null) |
| | | { |
| | | return; |
| | | } |
| | | if (_calcuResult.Succeed) |
| | | { |
| | | return; |
| | | } |
| | | var calcuFailedCtrl = GetCalcuFailedCtrl(); |
| | | calcuFailedCtrl.SetBindingData(_calcuResult.FailedList); |
| | | this.controlContainerBottom.Controls.Clear(); |
| | | this.controlContainerBottom.Controls.Add(calcuFailedCtrl); |
| | | this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; |
| | | this.docPnlBottom.Text = "计算失败原因"; |
| | | this.docPnlBottom.Height = 350; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 计算结果 |
| | | |
| | | //所有计算结果列表 |
| | | private List<HydroCalcuResult> _allCalcuResultList = null; |
| | | |
| | | //获取计算结果 |
| | | private List<IHydroCalcuResult> GetAllCalcuResultList() |
| | | //true 使用缓存,false 不使用缓存 |
| | | private List<HydroCalcuResult> GetAllCalcuResultList(bool isCache = true) |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | |
| | | { |
| | | return default; |
| | | } |
| | | var list = new List<IHydroCalcuResult>(); |
| | | if (isCache) |
| | | { |
| | | return _allCalcuResultList; |
| | | } |
| | | |
| | | _allCalcuResultList = new List<HydroCalcuResult>(); |
| | | |
| | | //节点 |
| | | var allNodeList = _hydroInfo.GetAllNodes(); |
| | | if (allNodeList != null && allNodeList.Count > 0) |
| | | { |
| | | var allCalcuNodeList = _calcuResult.NodeList; |
| | | if (allCalcuNodeList != null && allCalcuNodeList.Count > 0) |
| | | foreach (var node in allNodeList) |
| | | { |
| | | foreach (var node in allNodeList) |
| | | var calcuNode = _calcuResult.NodeList?.Find(x => x.Id == node.Code); |
| | | if (calcuNode != null) |
| | | { |
| | | var calcuNode = allCalcuNodeList.Find(x => x.Id == node.Code); |
| | | if (calcuNode != null) |
| | | var calcuResult = new HydroCalcuNodeResult() |
| | | { |
| | | var calcuResult = new HydroCalcuNodeResult() |
| | | { |
| | | Code = node.Code, |
| | | CalcuPress = calcuNode.Press, |
| | | CalcuHead = calcuNode.Head, |
| | | CalcuDemand = calcuNode.Demand |
| | | }; |
| | | list.Add(calcuResult); |
| | | } |
| | | Code = node.Code, |
| | | CalcuPress = calcuNode.Press, |
| | | CalcuHead = calcuNode.Head, |
| | | CalcuDemand = calcuNode.Demand |
| | | }; |
| | | _allCalcuResultList.Add(calcuResult); |
| | | } |
| | | } |
| | | } |
| | | |
| | | var allListList = _hydroInfo.GetAllLinks(); |
| | | if (allListList != null && allListList.Count > 0) |
| | | //管段 |
| | | var allLinkList = _hydroInfo.GetAllLinks(); |
| | | if (allLinkList != null && allLinkList.Count > 0) |
| | | { |
| | | var allCalcuLinkList = _calcuResult.LinkList; |
| | | if (allCalcuLinkList != null && allCalcuLinkList.Count > 0) |
| | | foreach (var link in allLinkList) |
| | | { |
| | | foreach (var link in allListList) |
| | | var calcuLink = _calcuResult.LinkList?.Find(x => x.Id == link.Code); |
| | | if (calcuLink != null) |
| | | { |
| | | var calcuLink = allCalcuLinkList.Find(x => x.Id == link.Code); |
| | | if (calcuLink != null) |
| | | var calcuResult = new HydroCalcuLinkResult() |
| | | { |
| | | var calcuResult = new HydroCalcuLinkResult() |
| | | { |
| | | Code = link.Code, |
| | | CalcuFlow = calcuLink.Flow, |
| | | CalcuVelocity = calcuLink.Velocity, |
| | | CalcuHeadLoss = calcuLink.Headloss |
| | | }; |
| | | list.Add(calcuResult); |
| | | } |
| | | Code = link.Code, |
| | | CalcuFlow = calcuLink.Flow, |
| | | CalcuVelocity = calcuLink.Velocity, |
| | | CalcuHeadLoss = calcuLink.Headloss |
| | | }; |
| | | _allCalcuResultList.Add(calcuResult); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return list; |
| | | //流量计 |
| | | var allFlowmeterList = _hydroInfo.Flowmeters; |
| | | if (allFlowmeterList != null && allFlowmeterList.Count > 0) |
| | | { |
| | | foreach (var flowmeter in allFlowmeterList) |
| | | { |
| | | var calcuFlowmeterResult = _allCalcuResultList.Find(x => x.Code == flowmeter.Code) as HydroCalcuNodeResult; |
| | | if (calcuFlowmeterResult != null) |
| | | { |
| | | var calcuFlowmeterNewResult = new HydroCalcuFlowmeterResult(calcuFlowmeterResult); |
| | | var calcuFlowmeterLinkResultList = new List<HydroCalcuLinkResult>(); |
| | | var flowmeterLinkList = allLinkList?.Where(x => x.StartCode == flowmeter.Code || x.EndCode == flowmeter.Code).ToList(); |
| | | if (flowmeterLinkList != null && flowmeterLinkList.Count > 0) |
| | | { |
| | | foreach (var flowmeterLink in flowmeterLinkList) |
| | | { |
| | | var calcuFlowmeterLinkResult = _allCalcuResultList.Find(x => x.Code == flowmeterLink.Code) as HydroCalcuLinkResult; |
| | | if (calcuFlowmeterLinkResult != null) |
| | | { |
| | | calcuFlowmeterLinkResultList.Add(calcuFlowmeterLinkResult); |
| | | } |
| | | } |
| | | } |
| | | if (calcuFlowmeterLinkResultList.Exists(x => x.CalcuFlow.HasValue)) |
| | | { |
| | | calcuFlowmeterNewResult.CalcuQ = calcuFlowmeterLinkResultList.Where(x => x.CalcuFlow.HasValue).Average(x => x.CalcuFlow.Value); |
| | | } |
| | | _allCalcuResultList.Remove(calcuFlowmeterResult); |
| | | _allCalcuResultList.Add(calcuFlowmeterNewResult); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //压力表 |
| | | var allPressmeterList = _hydroInfo.Pressmeters; |
| | | if (allPressmeterList != null && allPressmeterList.Count > 0) |
| | | { |
| | | foreach (var pressmeter in allPressmeterList) |
| | | { |
| | | var calcuPressmeterResult = _allCalcuResultList.Find(x => x.Code == pressmeter.Code) as HydroCalcuNodeResult; |
| | | if (calcuPressmeterResult != null) |
| | | { |
| | | var calcuPressmeterNewResult = new HydroCalcuPressmeterResult(calcuPressmeterResult); |
| | | calcuPressmeterNewResult.CalcuPr = calcuPressmeterResult.CalcuPress; |
| | | _allCalcuResultList.Remove(calcuPressmeterResult); |
| | | _allCalcuResultList.Add(calcuPressmeterNewResult); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //水泵 |
| | | var allPumpList = _hydroInfo.Pumps; |
| | | if (allPumpList != null && allPumpList.Count > 0) |
| | | { |
| | | foreach (var pump in allPumpList) |
| | | { |
| | | var calcuPumpResult = _allCalcuResultList.Find(x => x.Code == pump.Code) as HydroCalcuLinkResult; |
| | | if (calcuPumpResult != null) |
| | | { |
| | | var calcuPumpNewResult = new HydroCalcuPumpResult(calcuPumpResult); |
| | | calcuPumpNewResult.CalcuQ = calcuPumpResult.CalcuFlow; |
| | | if (calcuPumpNewResult.CalcuQ.HasValue) |
| | | { |
| | | var calcuNodeStartResult = _allCalcuResultList.Find(x => x.Code == pump.StartCode) as HydroCalcuNodeResult; |
| | | var calcuNodeEndResult = _allCalcuResultList.Find(x => x.Code == pump.EndCode) as HydroCalcuNodeResult; |
| | | if (calcuNodeStartResult != null && calcuNodeEndResult != null) |
| | | { |
| | | if (calcuNodeStartResult.CalcuPress.HasValue && calcuNodeEndResult.CalcuPress.HasValue) |
| | | { |
| | | calcuPumpNewResult.CalcuH = Math.Abs(calcuNodeStartResult.CalcuPress.Value - calcuNodeEndResult.CalcuPress.Value); |
| | | } |
| | | if (pump.LinkStatus == Yw.Hydro.PumpStatus.Open && pump.RatedN.HasValue) |
| | | { |
| | | var curveqp = _hydroInfo.Curves?.Find(x => x.Code == pump.CurveQP); |
| | | if (curveqp != null) |
| | | { |
| | | if (curveqp.CurveData != null && curveqp.CurveData.Count > 3) |
| | | { |
| | | var point2dList = curveqp.CurveData.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList(); |
| | | var point2dSimularList = point2dList.GetQPPointListByN(pump.RatedN.Value, pump.RatedN.Value * pump.SpeedRatio); |
| | | var pumpCurveQp = new Yw.Pump.CurveQP(eFeatType.Cubic, point2dSimularList); |
| | | calcuPumpNewResult.CalcuP = pumpCurveQp.FeatCurve.GetPointY(calcuPumpNewResult.CalcuQ.Value); |
| | | } |
| | | } |
| | | } |
| | | if (calcuPumpNewResult.CalcuH.HasValue && calcuPumpNewResult.CalcuP.HasValue) |
| | | { |
| | | calcuPumpNewResult.CalcuE = Yw.Pump.CalculationHelper.CalcuE(calcuPumpNewResult.CalcuQ.Value, calcuPumpNewResult.CalcuH.Value, calcuPumpNewResult.CalcuP.Value); |
| | | } |
| | | } |
| | | } |
| | | _allCalcuResultList.Remove(calcuPumpResult); |
| | | _allCalcuResultList.Add(calcuPumpNewResult); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return _allCalcuResultList; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | //水力计算 |
| | | private void barBtnHydroCalcu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var calcuPrefixCtrl = GetCalcuCtrl(); |
| | | calcuPrefixCtrl.SetBindingData(); |
| | | this.controlContainerRight.Controls.Clear(); |
| | | this.controlContainerRight.Controls.Add(calcuPrefixCtrl); |
| | | this.docPnlRight.Text = "前提条件"; |
| | | this.docPnlRight.Width = SetHydroCalcuPrefixCtrl.ControlMinWidth; |
| | | this.docPnlRight.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; |
| | | ShowCalcuPrefixDlg(); |
| | | } |
| | | |
| | | #endregion |
| | |
| | | } |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds); |
| | | ShowProperty(); |
| | | SetBimfaceLinkColor(); |
| | | }; |
| | | } |
| | | return _searchCtrl; |
| | |
| | | { |
| | | _allGradingCodeList = obj?.Select(x => x.Code).Distinct().ToList(); |
| | | var objGroupList = obj?.GroupBy(x => x.Color).ToList(); |
| | | objGroupList.ForEach(async x => |
| | | objGroupList?.ForEach(async x => |
| | | { |
| | | await _bimfaceCtrl?.OverrideComponentsColor(x.Select(t => t.Code).Distinct().ToList(), x.Key, 1); |
| | | }); |
| | | }; |
| | | if (dlg.ShowDialog() != DialogResult.OK) |
| | | if (dlg.ShowDialog() == DialogResult.Cancel) |
| | | { |
| | | await _bimfaceCtrl?.RestoreComponentsColor(_allGradingCodeList); |
| | | } |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region 人工刷新 |
| | | |
| | | //刷新 |
| | | private async void barBtnRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (XtraMessageBox.Show("刷新后将丢失当前水力信息更改,是否继续刷新?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes) |
| | | { |
| | | if (_project == null) |
| | | { |
| | | return; |
| | | } |
| | | if (_projectSite == null) |
| | | { |
| | | return; |
| | | } |
| | | var hydroRelation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance |
| | | .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation); |
| | | _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID); |
| | | _parter = null; |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(null); |
| | | ShowProperty(); |
| | | TipFormHelper.ShowSucceed("数据已刷新"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | #endregion |
| | | } |
| | | } |