| | |
| | | using Yw.WinFrmUI.Q3d; |
| | | using Yw.EPAnet; |
| | | using Mapster; |
| | | using Microsoft.CodeAnalysis.CSharp.Syntax; |
| | | namespace HStation.WinFrmUI |
| | | { |
| | | public partial class XhsProjectSimulationWorkingPage : DocumentPage |
| | |
| | | InitializeComponent(); |
| | | this.PageTitle.Caption = "水力模拟工况"; |
| | | this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 更新工况事件 |
| | | /// </summary> |
| | | public event Action<HydroWorkingVmo> UpdateWorkingEvent; |
| | | /// <summary> |
| | | /// 移除工况事件 |
| | | /// </summary> |
| | | public event Action<HydroWorkingVmo> RemoveWorkingEvent; |
| | | |
| | | private HStation.Vmo.XhsProjectVmo _project = null;//项目 |
| | | private HStation.Vmo.XhsProjectSiteVmo _projectSite = null;//项目站 |
| | | private XhsSchemeVmo _scheme = null;//方案 |
| | | private Yw.Model.HydroModelInfo _hydroInfo = null;//水力信息 |
| | | private HydroWorkingVmo _working = null;//工况 |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | public void SetBindingData |
| | | ( |
| | | XhsProjectVmo project, |
| | | XhsProjectSiteVmo projectSite, |
| | | Yw.Model.HydroModelInfo hydroInfo, |
| | | HydroWorkingVmo working |
| | | ) |
| | | { |
| | | _project = project; |
| | | _projectSite = projectSite; |
| | | _hydroInfo = hydroInfo.Adapt<Yw.Model.HydroModelInfo>(); |
| | | _working = working; |
| | | _hydroInfo.UpdateWorkingInfo(_working.WorkingInfo); |
| | | this.PageTitle.Caption = $"水力模拟\r\n{_working.Name}"; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | |
| | | _hydroInfo = hydroInfo.Adapt<Yw.Model.HydroModelInfo>(); |
| | | _working = working; |
| | | _hydroInfo.UpdateWorkingInfo(_working.WorkingInfo); |
| | | this.PageTitle.Caption = $"{scheme.Name}\r\n{_working.Name}"; |
| | | if (_scheme == null) |
| | | { |
| | | this.PageTitle.Caption = $"水力模拟\r\n{_working.Name}"; |
| | | } |
| | | else |
| | | { |
| | | this.PageTitle.Caption = $"{scheme.Name}\r\n{_working.Name}"; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | #region BIM控件 |
| | | |
| | | //bimface控件 |
| | | private XhsProjectSimulationBimfaceCtrl _bimfaceCtrl = null; |
| | | private SimulationBimfaceCtrl _bimfaceCtrl = null; |
| | | |
| | | //获取 bimface 控件 |
| | | private async Task<XhsProjectSimulationBimfaceCtrl> GetBimfaceCtrl() |
| | | private async Task<SimulationBimfaceCtrl> GetBimfaceCtrl() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | |
| | | } |
| | | if (_bimfaceCtrl == null) |
| | | { |
| | | _bimfaceCtrl = new XhsProjectSimulationBimfaceCtrl(); |
| | | _bimfaceCtrl = new SimulationBimfaceCtrl(); |
| | | _bimfaceCtrl.Dock = DockStyle.Fill; |
| | | await _bimfaceCtrl.InitialData(_project, _projectSite); |
| | | _bimfaceCtrl.LoadCompletedEvent += async () => |
| | |
| | | #region 属性控件 |
| | | |
| | | //属性控件 |
| | | private XhsProjectSimulationPropertyCtrl _propertyCtrl = null; |
| | | private SimulationPropertyCtrl _propertyCtrl = null; |
| | | |
| | | //获取属性控件 |
| | | private XhsProjectSimulationPropertyCtrl GetPropertyCtrl() |
| | | private SimulationPropertyCtrl GetPropertyCtrl() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | |
| | | } |
| | | if (_propertyCtrl == null) |
| | | { |
| | | _propertyCtrl = new XhsProjectSimulationPropertyCtrl(); |
| | | _propertyCtrl = new SimulationPropertyCtrl(); |
| | | _propertyCtrl.Dock = DockStyle.Fill; |
| | | _propertyCtrl.AllowEdit = false; |
| | | _propertyCtrl.HydroViewEvent += (visual) => |
| | | { |
| | | SelectVisual(visual, eVisualSource.Property); |
| | |
| | | await Task.Delay(5000); |
| | | await _bimfaceCtrl?.ClearBlinkComponents(); |
| | | }; |
| | | _propertyCtrl.PropertyValueChangedEvent += async (visual) => |
| | | { |
| | | if (visual == null) |
| | | { |
| | | return; |
| | | } |
| | | UpdateVisualListCtrl(); |
| | | var gradingHelper = await GetGradingHelper(); |
| | | gradingHelper.Set(); |
| | | }; |
| | | _propertyCtrl.MarkPropertyValueChangedEvent += async (visual) => |
| | | { |
| | | //标注属性发生改变 |
| | | //判断当前是否有标注展示,若有则更新标注,最好是更新单个标注 |
| | | var markHelper = await GetMarkHelper(); |
| | | markHelper.Set(visual); |
| | | }; |
| | | _propertyCtrl.GradingPropertyValueChangedEvent += async (visual) => |
| | | { |
| | | //分级属性发生改变 |
| | | //判断当前是否有分级展示,若有则更新分级,最好是更新单个分级 |
| | | var gradingHelper = await GetGradingHelper(); |
| | | gradingHelper.Set(visual); |
| | | }; |
| | | _propertyCtrl.FlowEffectPropertyValueChangedEvent += async (visual) => |
| | | { |
| | | //流向属性发生改变 |
| | | //判断流向是否加载,如果加载则更新流向,最好是更新单个流向 |
| | | var flowEffectHelper = await GetFlowEffectHelper(); |
| | | flowEffectHelper.Set(visual); |
| | | }; |
| | | |
| | | } |
| | | return _propertyCtrl; |
| | | } |
| | |
| | | { |
| | | if (this.controlContainerRight.Controls.Count > 0) |
| | | { |
| | | if (this.controlContainerRight.Controls[0] is XhsProjectSimulationPropertyCtrl) |
| | | if (this.controlContainerRight.Controls[0] is SimulationPropertyCtrl) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | _propertyCtrl?.UpdateRows(); |
| | | } |
| | | |
| | | //清理属性控件 |
| | | private void ClearPropertyCtrl() |
| | | { |
| | | if (_propertyCtrl != null) |
| | | { |
| | | _propertyCtrl.SelectedObject = null; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | |
| | | return _visualListHelper; |
| | | } |
| | | |
| | | //重置可见列表 |
| | | private void ResetVisualList() |
| | | { |
| | | var helper = GetVisualListHelper(); |
| | | helper.InitialData(_hydroInfo); |
| | | } |
| | | |
| | | //获取可见构件 |
| | | private Yw.Model.HydroVisualInfo GetVisual(string code) |
| | | { |
| | | var helper = GetVisualListHelper(); |
| | | var visual = helper.GetVisual(code); |
| | | return visual; |
| | | } |
| | | |
| | | //获取可见列表 |
| | | private List<Yw.Model.HydroVisualInfo> GetVisualList() |
| | | { |
| | | var helper = GetVisualListHelper(); |
| | | return helper.GetVisualList(); |
| | | } |
| | | |
| | | //获取水源列表 |
| | | private List<Yw.Model.HydroSourceInfo> GetSourceList() |
| | | { |
| | | var helper = GetVisualListHelper(); |
| | | return helper.GetSourceList(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 视图列表 |
| | |
| | | return _visualVmListHelper; |
| | | } |
| | | |
| | | //获取可见视图 |
| | | private HydroVisualViewModel GetVisualViewModel(string code) |
| | | { |
| | | if (string.IsNullOrEmpty(code)) |
| | | { |
| | | return default; |
| | | } |
| | | var visualVmListHelper = GetVisualVmListHelper(); |
| | | return visualVmListHelper.GetVisual(code); |
| | | } |
| | | |
| | | //获取可见视图 |
| | | private HydroVisualViewModel GetVisualViewModel(Yw.Model.HydroVisualInfo visual) |
| | | { |
| | | return GetVisualViewModel(visual?.Code); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 明细控件 |
| | |
| | | _visualListCtrl.HydroClickInfoEvent += (visual) => |
| | | { |
| | | SelectVisual(visual, eVisualSource.List); |
| | | }; |
| | | _visualListCtrl.HydroChangedInfoEvent += (visualList) => |
| | | { |
| | | SelectVisual(_visual, eVisualSource.List); |
| | | }; |
| | | } |
| | | return _visualListCtrl; |
| | |
| | | var visualVmListHelper = GetVisualVmListHelper(); |
| | | var allVisualVmList = visualVmListHelper.GetVisualList(); |
| | | visualListCtrl.SetBindingData(allVisualVmList); |
| | | var calcuResult = GetCalcuResult(); |
| | | if (calcuResult != null && calcuResult.Succeed) |
| | | { |
| | | visualListCtrl.SetCalcuView(); |
| | | } |
| | | else |
| | | { |
| | | visualListCtrl.SetNormalView(); |
| | | } |
| | | visualListCtrl.SetResultView(); |
| | | } |
| | | |
| | | //更新构件明细控件 |
| | |
| | | |
| | | } |
| | | |
| | | var dlg = new PumpParallelAnalyDlg(); |
| | | dlg.SetBindingData(vmList); |
| | | dlg.ReloadDataEvent += (list) => |
| | | { |
| | | list?.ForEach(x => |
| | | { |
| | | var pump = pumps.Find(t => t.Code == x.Code); |
| | | if (pump != null) |
| | | { |
| | | pump.LinkStatus = x.RunStatus ? Yw.Hydro.PumpStatus.Open : Yw.Hydro.PumpStatus.Closed; |
| | | pump.SpeedRatio = x.CurrentHz / pump.RatedHz; |
| | | } |
| | | }); |
| | | var codes = list?.Select(x => x.Code).ToList(); |
| | | //UpdateVisualViewModelProperty(codes); |
| | | //ShowSelectedProperty(); |
| | | UpdateVisualListCtrl(); |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | //var dlg = new PumpParallelAnalyDlg(); |
| | | //dlg.SetBindingData(vmList); |
| | | //dlg.ReloadDataEvent += (list) => |
| | | //{ |
| | | // list?.ForEach(x => |
| | | // { |
| | | // var pump = pumps.Find(t => t.Code == x.Code); |
| | | // if (pump != null) |
| | | // { |
| | | // pump.LinkStatus = x.RunStatus ? Yw.Hydro.PumpStatus.Open : Yw.Hydro.PumpStatus.Closed; |
| | | // pump.SpeedRatio = x.CurrentHz / pump.RatedHz; |
| | | // } |
| | | // }); |
| | | // var codes = list?.Select(x => x.Code).ToList(); |
| | | // //UpdateVisualViewModelProperty(codes); |
| | | // //ShowSelectedProperty(); |
| | | // UpdateVisualListCtrl(); |
| | | // return true; |
| | | //}; |
| | | //dlg.ShowDialog(); |
| | | } |
| | | |
| | | //并联分析 |
| | |
| | | |
| | | #region 工况分析 |
| | | |
| | | //选择进口水源 |
| | | private void SelectInputSource() |
| | | { |
| | | var sources = GetSourceList(); |
| | | if (sources != null) |
| | | { |
| | | if (sources.Count == 1) |
| | | { |
| | | SelectVisual(sources[0], eVisualSource.None); |
| | | } |
| | | else |
| | | { |
| | | var source = sources.FirstOrDefault(x => x.Flags.Contains(HStation.Xhs.Flags.进口)); |
| | | if (source != null) |
| | | { |
| | | SelectVisual(source, eVisualSource.None); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //精度评估 |
| | | private async void barBtnWorkingEvaluation_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | |
| | | |
| | | } |
| | | |
| | | 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(); |
| | | //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(); |
| | | } |
| | | |
| | | //能效分析 |
| | |
| | | return; |
| | | } |
| | | var dlg = new SimulationSingleWorkingEnergyDlg(); |
| | | dlg.SetBindingData(workingHelper.HydroInfo, workingHelper.CalcuResult); |
| | | //dlg.SetBindingData(workingHelper.Working, workingHelper.HydroInfo, workingHelper.CalcuResult); |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //损失曲线 |
| | | private void barBtnWorkingLossCurve_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (_visual == null) |
| | | { |
| | | SelectInputSource(); |
| | | if (_visual == null) |
| | | { |
| | | TipFormHelper.ShowWarn("请选择构件后重试!"); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | var workingHelper = GetWorkingHelper(); |
| | | if (!workingHelper.Initialized) |
| | | { |
| | | TipFormHelper.ShowError("工况计算失败!"); |
| | | return; |
| | | } |
| | | if (_visual == null) |
| | | { |
| | | TipFormHelper.ShowWarn("请选择构件!"); |
| | | return; |
| | | } |
| | | HydroVisualInfo visual = _visual; |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region 更新工况 |
| | | |
| | | //编辑 |
| | | private void barBtnEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | if (_working == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new EditHydroWorkingDlg(); |
| | | dlg.SetBindingData(_working); |
| | | dlg.ReloadDataEvent += (rhs) => |
| | | { |
| | | _working = rhs; |
| | | this.PageTitle.Caption = $"水力模拟\r\n{_working.Name}"; |
| | | UpdatePageTitle(this.PageGuid, this.PageTitle); |
| | | this.UpdateWorkingEvent?.Invoke(_working); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 删除工况 |
| | | |
| | | //删除 |
| | | private async void barBtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | if (_working == null) |
| | | { |
| | | return; |
| | | } |
| | | var bol = XtraMessageBox.Show("请问是否删除当前工况?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes; |
| | | if (!bol) |
| | | { |
| | | return; |
| | | } |
| | | bol = await BLLFactory<Yw.BLL.HydroWorking>.Instance.DeleteByID(_working.ID); |
| | | if (!bol) |
| | | { |
| | | TipFormHelper.ShowError("删除失败!"); |
| | | return; |
| | | } |
| | | this.RemoveWorkingEvent?.Invoke(_working); |
| | | TipFormHelper.ShowSucceed("删除成功!"); |
| | | ClosePage(this.PageGuid); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | } |