using DevExpress.Diagram.Core.Native;
|
using DevExpress.Mvvm.Native;
|
using HStation.WinFrmUI.PhartRelation;
|
using NPOI.SS.Formula.Functions;
|
using System.Diagnostics;
|
using Yw.Hydro;
|
using Yw.Model;
|
using Yw.Vmo;
|
using Yw.WinFrmUI.Q3d;
|
using Yw.EPAnet;
|
using Mapster;
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
namespace HStation.WinFrmUI
|
{
|
public partial class XhsProjectSimulationWorkingPage : DocumentPage
|
{
|
public XhsProjectSimulationWorkingPage()
|
{
|
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,
|
XhsSchemeVmo scheme,
|
Yw.Model.HydroModelInfo hydroInfo,
|
HydroWorkingVmo working
|
)
|
{
|
_project = project;
|
_projectSite = projectSite;
|
_scheme = scheme;
|
_hydroInfo = hydroInfo.Adapt<Yw.Model.HydroModelInfo>();
|
_working = working;
|
_hydroInfo.UpdateWorkingInfo(_working.WorkingInfo);
|
if (_scheme == null)
|
{
|
this.PageTitle.Caption = $"水力模拟\r\n{_working.Name}";
|
}
|
else
|
{
|
this.PageTitle.Caption = $"{scheme.Name}\r\n{_working.Name}";
|
}
|
}
|
|
/// <summary>
|
/// 初始化数据
|
/// </summary>
|
public override void InitialDataSource()
|
{
|
base.InitialDataSource();
|
ShowBimfaceCtrl();
|
ShowQ3dCtrl();
|
ShowPropertyCtrl();
|
}
|
|
#region BIM控件
|
|
//bimface控件
|
private SimulationBimfaceCtrl _bimfaceCtrl = null;
|
|
//获取 bimface 控件
|
private async Task<SimulationBimfaceCtrl> GetBimfaceCtrl()
|
{
|
if (_hydroInfo == null)
|
{
|
return default;
|
}
|
if (_bimfaceCtrl == null)
|
{
|
_bimfaceCtrl = new SimulationBimfaceCtrl();
|
_bimfaceCtrl.Dock = DockStyle.Fill;
|
await _bimfaceCtrl.InitialData(_project, _projectSite);
|
_bimfaceCtrl.LoadCompletedEvent += async () =>
|
{//view加载完成事件
|
if (_hydroInfo == null)
|
{
|
return;
|
}
|
await InitialWorking();
|
this.barCkDecorator.Checked = false;
|
this.barCkMonitor.Checked = true;
|
this.barCkGrading.Checked = true;
|
this.barCkCalcu.Checked = true;
|
|
};
|
_bimfaceCtrl.HydroMouseLeftClickEvent += (code) =>
|
{//鼠标左键点击事件
|
var visualListHelper = GetVisualListHelper();
|
var visual = visualListHelper.GetVisual(code);
|
SelectVisual(visual, eSimulationVisualSource.Bimface);
|
};
|
}
|
return _bimfaceCtrl;
|
}
|
|
//显示 bimface 控件
|
private async void ShowBimfaceCtrl()
|
{
|
var bimfaceCtrl = await GetBimfaceCtrl();
|
this.tabPageBimface.Controls.Clear();
|
this.tabPageBimface.Controls.Add(bimfaceCtrl);
|
}
|
|
#endregion
|
|
#region Q3d控件
|
|
//Q3d 控件
|
private XhsProjectSimulationQ3dCtrl _q3dCtrl = null;
|
|
//获取 Q3d 控件
|
private XhsProjectSimulationQ3dCtrl GetQ3dCtrl()
|
{
|
if (_hydroInfo == null)
|
{
|
return default;
|
}
|
if (_q3dCtrl == null)
|
{
|
_q3dCtrl = new XhsProjectSimulationQ3dCtrl();
|
_q3dCtrl.Dock = DockStyle.Fill;
|
_q3dCtrl.InitialData(() => _hydroInfo);
|
_q3dCtrl.SelectedPartersChangedEvent += (codes) =>
|
{
|
var visualListHelper = GetVisualListHelper();
|
var visuals = visualListHelper.GetVisualList(codes);
|
SelectVisual(visuals?.LastOrDefault(), eSimulationVisualSource.Q3d);
|
};
|
}
|
return _q3dCtrl;
|
}
|
|
//显示 Q3d 控件
|
private void ShowQ3dCtrl()
|
{
|
var q3dCtrl = GetQ3dCtrl();
|
this.tabPageQ3d.Controls.Clear();
|
this.tabPageQ3d.Controls.Add(q3dCtrl);
|
}
|
|
#endregion
|
|
#region 属性控件
|
|
//属性控件
|
private SimulationPropertyCtrl _propertyCtrl = null;
|
|
//获取属性控件
|
private SimulationPropertyCtrl GetPropertyCtrl()
|
{
|
if (_hydroInfo == null)
|
{
|
return default;
|
}
|
if (_propertyCtrl == null)
|
{
|
_propertyCtrl = new SimulationPropertyCtrl();
|
_propertyCtrl.Dock = DockStyle.Fill;
|
_propertyCtrl.AllowEdit = false;
|
_propertyCtrl.HydroViewEvent += (visual) =>
|
{
|
SelectVisual(visual, eSimulationVisualSource.Property);
|
};
|
_propertyCtrl.BlinkLinkNodeEvent += async (link, linkNodeCode) =>
|
{ //强调连接节点
|
if (link == null)
|
{
|
return;
|
}
|
var visualListHelper = GetVisualListHelper();
|
var linkNode = visualListHelper.GetVisual(linkNodeCode);
|
if (linkNode == null)
|
{
|
return;
|
}
|
var blinkCodes = new List<string>();
|
if (linkNode.GetType() == typeof(HydroJunctionInfo))
|
{
|
var allLinkList = visualListHelper.GetLinkList();
|
if (allLinkList == null || allLinkList.Count < 1)
|
{
|
return;
|
}
|
var linkList = allLinkList.Where(x => (x.StartCode == linkNodeCode || x.EndCode == linkNodeCode) && x.Code != linkNodeCode).ToList();
|
if (linkList == null || linkList.Count < 1)
|
{
|
return;
|
}
|
blinkCodes.AddRange(linkList.Select(x => x.Code));
|
}
|
else
|
{
|
blinkCodes.Add(linkNodeCode);
|
}
|
|
await _bimfaceCtrl?.ClearBlinkComponents();
|
await _bimfaceCtrl?.SetBlinkComponents(blinkCodes);
|
await Task.Delay(5000);
|
await _bimfaceCtrl?.ClearBlinkComponents();
|
};
|
}
|
return _propertyCtrl;
|
}
|
|
//属性控件是否可见
|
private bool IsPropertyCtrlVisible
|
{
|
get
|
{
|
if (this.docPnlRight.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible)
|
{
|
if (this.controlContainerRight.Controls.Count > 0)
|
{
|
if (this.controlContainerRight.Controls[0] is SimulationPropertyCtrl)
|
{
|
return true;
|
}
|
}
|
}
|
return false;
|
}
|
}
|
|
//显示属性控件
|
private void ShowPropertyCtrl()
|
{
|
if (IsPropertyCtrlVisible)
|
{
|
return;
|
}
|
var propertyCtrl = GetPropertyCtrl();
|
this.controlContainerRight.Controls.Clear();
|
this.controlContainerRight.Controls.Add(propertyCtrl);
|
this.docPnlRight.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
|
this.docPnlRight.Text = "属性";
|
this.docPnlRight.Width = 300;
|
}
|
|
//设置属性控件
|
private void SetPropertyCtrl(HydroVisualInfo visual)
|
{
|
ShowPropertyCtrl();
|
var visualVmListHelper = GetVisualVmListHelper();
|
var vm = visualVmListHelper.GetVisual(visual);
|
_propertyCtrl.SelectedObject = vm;
|
}
|
|
//更新属性控件
|
private void UpdatePropertyCtrl()
|
{
|
_propertyCtrl?.UpdateRows();
|
}
|
|
|
#endregion
|
|
#region 选择构件
|
|
//选择构件
|
private Yw.Model.HydroVisualInfo _visual = null;
|
|
//选择构件
|
private void SelectVisual(HydroVisualInfo visual, eSimulationVisualSource source)
|
{
|
_visual = visual;
|
switch (source)
|
{
|
case eSimulationVisualSource.None:
|
{
|
_bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
|
SetPropertyCtrl(visual);
|
}
|
break;
|
case eSimulationVisualSource.Bimface:
|
{
|
SetPropertyCtrl(visual);
|
}
|
break;
|
case eSimulationVisualSource.Q3d:
|
{
|
_bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
|
SetPropertyCtrl(visual);
|
}
|
break;
|
case eSimulationVisualSource.Property:
|
{
|
_bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
|
}
|
break;
|
case eSimulationVisualSource.List:
|
{
|
_bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
|
SetPropertyCtrl(visual);
|
}
|
break;
|
case eSimulationVisualSource.Set:
|
{
|
_bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
|
SetPropertyCtrl(visual);
|
}
|
break;
|
case eSimulationVisualSource.Search:
|
{
|
_bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
|
SetPropertyCtrl(visual);
|
}
|
break;
|
case eSimulationVisualSource.Monitor:
|
{
|
_bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
|
SetPropertyCtrl(visual);
|
}
|
break;
|
case eSimulationVisualSource.Check:
|
{
|
_bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
|
SetPropertyCtrl(visual);
|
}
|
break;
|
case eSimulationVisualSource.Calcu:
|
{
|
_bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
|
SetPropertyCtrl(visual);
|
}
|
break;
|
case eSimulationVisualSource.Warning:
|
{
|
_bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
|
SetPropertyCtrl(visual);
|
}
|
break;
|
default: break;
|
}
|
}
|
|
//选择构件
|
private void SelectVisual(string code, eSimulationVisualSource source)
|
{
|
var visual = GetVisual(code);
|
SelectVisual(visual, source);
|
}
|
|
#endregion
|
|
#region 构件明细
|
|
#region 可见列表
|
|
//可见列表辅助类
|
private SimulationVisualListHelper _visualListHelper = null;
|
|
//获取可见列表辅助类
|
private SimulationVisualListHelper GetVisualListHelper()
|
{
|
if (_visualListHelper == null)
|
{
|
_visualListHelper = new SimulationVisualListHelper();
|
_visualListHelper.InitialData(_hydroInfo);
|
}
|
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 视图列表
|
|
//可见视图列表辅助类
|
private SimulationVisualVmListHelper _visualVmListHelper = null;
|
|
//获取可见视图列表辅助类
|
private SimulationVisualVmListHelper GetVisualVmListHelper()
|
{
|
if (_hydroInfo == null)
|
{
|
return default;
|
}
|
if (_visualVmListHelper == null)
|
{
|
var visualListHelper = GetVisualListHelper();
|
var calcuResultHelper = GetCalcuResultHelper();
|
_visualVmListHelper = new SimulationVisualVmListHelper(visualListHelper, calcuResultHelper);
|
}
|
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 明细控件
|
|
//构件明细控件
|
private Yw.WinFrmUI.HydroVisualListCtrl _visualListCtrl = null;
|
|
//获取构件明细控件
|
private Yw.WinFrmUI.HydroVisualListCtrl GetVisualListCtrl()
|
{
|
if (_visualListCtrl == null)
|
{
|
_visualListCtrl = new HydroVisualListCtrl();
|
_visualListCtrl.Dock = DockStyle.Fill;
|
_visualListCtrl.HydroClickInfoEvent += (visual) =>
|
{
|
SelectVisual(visual, eSimulationVisualSource.List);
|
};
|
}
|
return _visualListCtrl;
|
}
|
|
//构件明细控件是否可见
|
private bool IsVisualListCtrlVisible
|
{
|
get
|
{
|
if (this.docPnlBottom.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible)
|
{
|
if (this.controlContainerBottom.Controls.Count > 0)
|
{
|
if (this.controlContainerBottom.Controls[0] is HydroVisualListCtrl)
|
{
|
return true;
|
}
|
}
|
}
|
return false;
|
}
|
}
|
|
//显示构件明细控件
|
private void ShowVisualListCtrl()
|
{
|
if (_hydroInfo == null)
|
{
|
return;
|
}
|
var visualListCtrl = GetVisualListCtrl();
|
if (!IsVisualListCtrlVisible)
|
{
|
this.controlContainerBottom.Controls.Clear();
|
this.controlContainerBottom.Controls.Add(visualListCtrl);
|
this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
|
this.docPnlBottom.Text = "构件明细";
|
this.docPnlBottom.Height = 350;
|
}
|
var visualVmListHelper = GetVisualVmListHelper();
|
var allVisualVmList = visualVmListHelper.GetVisualList();
|
visualListCtrl.SetBindingData(allVisualVmList);
|
visualListCtrl.SetResultView();
|
}
|
|
//更新构件明细控件
|
private void UpdateVisualListCtrl()
|
{
|
if (!IsVisualListCtrlVisible)
|
{
|
return;
|
}
|
_visualListCtrl?.UpdateBindingData();
|
}
|
|
//构件明细
|
private void barBtnVisualList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
ShowVisualListCtrl();
|
}
|
|
#endregion
|
|
#region 构件显示
|
|
//构件可见辅助类
|
private SimulationVisualVisibleHelper _visualVisibleHelper = null;
|
|
//获取构件可见辅助类
|
private async Task<SimulationVisualVisibleHelper> GetVisualVisibleHelper()
|
{
|
if (_hydroInfo == null)
|
{
|
return default;
|
}
|
if (_visualVisibleHelper == null)
|
{
|
var visualListHelper = GetVisualListHelper();
|
var bimfaceCtrl = await GetBimfaceCtrl();
|
_visualVisibleHelper = new SimulationVisualVisibleHelper(visualListHelper, bimfaceCtrl);
|
_visualVisibleHelper.InitialData(_hydroInfo);
|
}
|
return _visualVisibleHelper;
|
}
|
|
//设置构件可见性
|
private async void SetVisualVisible()
|
{
|
if (_hydroInfo == null)
|
{
|
return;
|
}
|
var visualVisibleHelper = await GetVisualVisibleHelper();
|
var allVisibleList = visualVisibleHelper.Items;
|
var dlg = new SetHydroVisualVisibleDlg();
|
dlg.SetBindingData(allVisibleList);
|
dlg.ReloadDataEvent += (list) =>
|
{
|
visualVisibleHelper.Items = list;
|
visualVisibleHelper.Set();
|
};
|
dlg.ShowDialog();
|
}
|
|
//设置构件显示
|
private void barBtnSetVisualVisible_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
SetVisualVisible();
|
}
|
|
#endregion
|
|
#endregion
|
|
#region 一键显隐
|
|
//设置装饰件可见性
|
private async void SetDecoratorVisible(bool isDecoratorVisible)
|
{
|
var codes = _hydroInfo.Decorators?.Select(x => x.Code).Distinct().ToList();
|
if (isDecoratorVisible)
|
{
|
await _bimfaceCtrl?.ShowComponents(codes);
|
}
|
else
|
{
|
await _bimfaceCtrl?.HideComponents(codes);
|
}
|
}
|
|
//设置
|
private void barCkDecorator_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
SetDecoratorVisible(this.barCkDecorator.Checked);
|
}
|
|
#endregion
|
|
#region 构件查询
|
|
//查询组件
|
private HydroVisualSearchListCtrl _searchCtrl = null;
|
|
//获取查询组件
|
private HydroVisualSearchListCtrl GetSearchCtrl()
|
{
|
if (_searchCtrl == null)
|
{
|
var visualVmListHelper = GetVisualVmListHelper();
|
var allVisualVmList = visualVmListHelper.GetVisualList();
|
_searchCtrl = new HydroVisualSearchListCtrl();
|
_searchCtrl.Dock = DockStyle.Fill;
|
_searchCtrl.InitialData(allVisualVmList);
|
_searchCtrl.HydroClickInfoEvent += (visual) =>
|
{
|
SelectVisual(visual, eSimulationVisualSource.Check);
|
};
|
_searchCtrl.HydroSearchInfoEvent += (list) =>
|
{
|
var visual = list?.FirstOrDefault();
|
SelectVisual(visual, eSimulationVisualSource.Search);
|
};
|
}
|
return _searchCtrl;
|
}
|
|
//查询控件是否可见
|
private bool IsSearchCtrlVisible
|
{
|
get
|
{
|
if (this.docPnlBottom.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible)
|
{
|
if (this.controlContainerBottom.Controls.Count > 0)
|
{
|
if (this.controlContainerBottom.Controls[0] is HydroVisualSearchListCtrl)
|
{
|
return true;
|
}
|
}
|
}
|
return false;
|
}
|
}
|
|
//显示查询控件
|
private void ShowSearchCtrl(string content)
|
{
|
if (IsSearchCtrlVisible)
|
{
|
return;
|
}
|
var searchCtrl = GetSearchCtrl();
|
searchCtrl.SetBindingData(content);
|
this.controlContainerBottom.Controls.Clear();
|
this.controlContainerBottom.Controls.Add(searchCtrl);
|
this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
|
this.docPnlBottom.Text = "构件查询";
|
this.docPnlBottom.Height = 350;
|
}
|
|
//显示查询窗体
|
private void ShowSearchDlg()
|
{
|
if (IsSearchCtrlVisible)
|
{
|
return;
|
}
|
var dlg = new InputHydroVisualSearchListDlg();
|
dlg.SearchEvent += (content) =>
|
{
|
if (string.IsNullOrEmpty(content))
|
{
|
return;
|
}
|
ShowSearchCtrl(content);
|
};
|
dlg.SetBindingData();
|
dlg.ShowDialog();
|
}
|
|
//查询
|
private void barBtnSearch_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
ShowSearchDlg();
|
}
|
|
#endregion
|
|
#region 模型标注
|
|
//标注辅助类
|
private SimulationMarkHelper _markHelper = null;
|
|
//获取标注辅助类
|
private async Task<SimulationMarkHelper> GetMarkHelper()
|
{
|
if (_markHelper == null)
|
{
|
var visualListHelper = GetVisualListHelper();
|
var calcuResultHelper = GetCalcuResultHelper();
|
var bimfaceCtrl = await GetBimfaceCtrl();
|
_markHelper = new SimulationMarkHelper(visualListHelper, calcuResultHelper, bimfaceCtrl);
|
}
|
return _markHelper;
|
}
|
|
//显示标注列表
|
private async void ShowMarkList()
|
{
|
if (_hydroInfo == null)
|
{
|
return;
|
}
|
var markHelper = await GetMarkHelper();
|
var dlg = new SetHydroMarkDlg();
|
dlg.SetBindingData(markHelper.Sets);
|
dlg.ReloadDataEvent += (list) =>
|
{
|
markHelper.Sets = list;
|
markHelper.Set();
|
};
|
dlg.ShowDialog();
|
}
|
|
//设置标注
|
private void barBtnSetMark_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
ShowMarkList();
|
}
|
|
//是否显示
|
private async void barCkMark_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var markHelper = await GetMarkHelper();
|
markHelper.Visible = this.barCkMark.Checked;
|
markHelper.Set();
|
}
|
|
#endregion
|
|
#region 颜色分级
|
|
//颜色分级辅助类
|
private SimulationGradingHelper _gradingHelper = null;
|
|
//获取颜色分级辅助类
|
private async Task<SimulationGradingHelper> GetGradingHelper()
|
{
|
if (_gradingHelper == null)
|
{
|
var visualListHelper = GetVisualListHelper();
|
var calcuResultHelper = GetCalcuResultHelper();
|
var bimfaceCtrl = await GetBimfaceCtrl();
|
_gradingHelper = new SimulationGradingHelper(visualListHelper, calcuResultHelper, bimfaceCtrl);
|
}
|
return _gradingHelper;
|
}
|
|
//应用颜色分级列表
|
private async void ApplyGradingList()
|
{
|
if (_hydroInfo == null)
|
{
|
return;
|
}
|
var gradingHelper = await GetGradingHelper();
|
var dlg = new ApplyHydroGradingDlg();
|
dlg.SetBindingData(gradingHelper.Applies);
|
dlg.ReloadDataEvent += (list) =>
|
{
|
gradingHelper.Applies = list;
|
gradingHelper.Set();
|
};
|
dlg.ShowDialog();
|
}
|
|
//应用颜色分级
|
private void barBtnApplyGradingList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
ApplyGradingList();
|
}
|
|
//颜色分级展示
|
private async void barCkGrading_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var gradingHelper = await GetGradingHelper();
|
gradingHelper.Visible = this.barCkGrading.Checked;
|
gradingHelper.Set();
|
}
|
|
#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);
|
Stopwatch sw = new Stopwatch();
|
sw.Start();
|
_hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID);
|
sw.Stop();
|
TimeSpan ts2 = sw.Elapsed;
|
Console.WriteLine("Stopwatch总共花费{0}ms.", ts2.TotalMilliseconds);
|
_visual = null;
|
await _bimfaceCtrl?.ZoomAndSelectComponents(null);
|
//ShowSelectedProperty();
|
TipFormHelper.ShowSucceed("数据已刷新");
|
|
var visualListHelper = GetVisualListHelper();
|
visualListHelper.InitialData(_hydroInfo);
|
}
|
}
|
|
#endregion
|
|
#region 水流动画
|
|
//水流动画辅助类
|
private SimulationFlowEffectHelper _flowEffectHelper = null;
|
|
//获取水流动画辅助类
|
private async Task<SimulationFlowEffectHelper> GetFlowEffectHelper()
|
{
|
if (_hydroInfo == null)
|
{
|
return default;
|
}
|
if (_flowEffectHelper == null)
|
{
|
var visualListHelper = GetVisualListHelper();
|
var bimfaceCtrl = await GetBimfaceCtrl();
|
_flowEffectHelper = new SimulationFlowEffectHelper(visualListHelper, bimfaceCtrl);
|
var calcuResult = GetCalcuResult();
|
_flowEffectHelper.InitialData(calcuResult);
|
}
|
return _flowEffectHelper;
|
}
|
|
//水流动画是否可见
|
private async void barCkFlowEffect_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var flowEffectHelper = await GetFlowEffectHelper();
|
flowEffectHelper.Visible = this.barCkFlowEffect.Checked;
|
flowEffectHelper.Set();
|
}
|
|
#endregion
|
|
#region 监测列表
|
|
#region 监测点
|
|
//监测点辅助类
|
private SimulationMonitorHelper _monitorHelper = null;
|
|
//获取监测点辅助类
|
private SimulationMonitorHelper GetMonitorHelper()
|
{
|
if (_hydroInfo == null)
|
{
|
return default;
|
}
|
if (_monitorHelper == null)
|
{
|
var visualListHelper = GetVisualListHelper();
|
_monitorHelper = new SimulationMonitorHelper(visualListHelper);
|
}
|
return _monitorHelper;
|
}
|
|
//获取监测点列表
|
private async Task<List<HydroMonitorVmo>> GetMonitorList()
|
{
|
var helper = GetMonitorHelper();
|
return await helper.GetAll();
|
}
|
|
#endregion
|
|
#region 监测值
|
|
//监测值辅助类
|
private SimulationMonitorValueHelper _monitorValueHelper = null;
|
|
//获取监测值辅助类
|
private SimulationMonitorValueHelper GetMonitorValueHelper()
|
{
|
if (_monitorValueHelper == null)
|
{
|
var visualListHelper = GetVisualListHelper();
|
var monitorHelper = GetMonitorHelper();
|
var calcuResultHelper = GetCalcuResultHelper();
|
_monitorValueHelper = new SimulationMonitorValueHelper(visualListHelper, monitorHelper, calcuResultHelper);
|
}
|
return _monitorValueHelper;
|
}
|
|
#endregion
|
|
#region 监测值控件
|
|
//监测值列表控件
|
private HydroMonitorValueListCtrl _monitorValueListCtrl = null;
|
|
//获取监测值列表控件
|
private HydroMonitorValueListCtrl GetMonitorValueListCtrl()
|
{
|
if (_monitorValueListCtrl == null)
|
{
|
_monitorValueListCtrl = new HydroMonitorValueListCtrl();
|
_monitorValueListCtrl.Dock = DockStyle.Fill;
|
_monitorValueListCtrl.SetViewBoard();
|
_monitorValueListCtrl.HydroViewEvent += (code) =>
|
{
|
var visualListHelper = GetVisualListHelper();
|
var visual = visualListHelper.GetVisual(code);
|
SelectVisual(visual, eSimulationVisualSource.Monitor);
|
};
|
}
|
return _monitorValueListCtrl;
|
}
|
|
//监测值列表控件是否可见
|
private bool IsMonitorValueListCtrlVisible
|
{
|
get
|
{
|
if (this.docPnlBottom.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible)
|
{
|
if (this.controlContainerBottom.Controls.Count > 0)
|
{
|
if (this.controlContainerBottom.Controls[0] is HydroMonitorValueListCtrl)
|
{
|
return true;
|
}
|
}
|
}
|
return false;
|
}
|
}
|
|
//显示监测值列表控件
|
private async void ShowMonitorValueListCtrl()
|
{
|
var monitorValueListCtrl = GetMonitorValueListCtrl();
|
if (!IsMonitorValueListCtrlVisible)
|
{
|
this.controlContainerBottom.Controls.Clear();
|
this.controlContainerBottom.Controls.Add(monitorValueListCtrl);
|
this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
|
this.docPnlBottom.Text = "监测值";
|
this.docPnlBottom.Height = 350;
|
}
|
var monitorValueHelper = GetMonitorValueHelper();
|
var allMonitorValueList = await monitorValueHelper.GetAll();
|
monitorValueListCtrl.SetBindingData(allMonitorValueList);
|
}
|
|
//显示监测值
|
private void barBtnShowMonitorValue_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
ShowMonitorValueListCtrl();
|
}
|
|
#endregion
|
|
#region 监测点标记
|
|
//监测标记辅助类
|
private SimulationMonitorMarkerHelper _monitorMarkerHelper = null;
|
|
//获取监测标记辅助类
|
private async Task<SimulationMonitorMarkerHelper> GetMonitorMarkerHelper()
|
{
|
if (_monitorMarkerHelper == null)
|
{
|
var monitorHelper = GetMonitorHelper();
|
var bimfaceCtrl = await GetBimfaceCtrl();
|
_monitorMarkerHelper = new SimulationMonitorMarkerHelper(monitorHelper, bimfaceCtrl);
|
}
|
return _monitorMarkerHelper;
|
}
|
|
//显示状态改变
|
private async void barCkMonitor_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var monitorMarkerHelper = await GetMonitorMarkerHelper();
|
monitorMarkerHelper.Visible = this.barCkMonitor.Checked;
|
monitorMarkerHelper.Set();
|
}
|
|
#endregion
|
|
#endregion
|
|
#region 模型检查
|
|
//检查控件
|
private HydroCheckResultCtrl _checkCtrl = null;
|
|
//获取检查控件
|
private HydroCheckResultCtrl GetCheckCtrl()
|
{
|
if (_hydroInfo == null)
|
{
|
return default;
|
}
|
if (_checkCtrl == null)
|
{
|
_checkCtrl = new HydroCheckResultCtrl();
|
_checkCtrl.Dock = DockStyle.Fill;
|
_checkCtrl.HydroClickEvent += (code) =>
|
{
|
var visualListHelper = GetVisualListHelper();
|
var visual = visualListHelper.GetVisual(code);
|
SelectVisual(visual, eSimulationVisualSource.Check);
|
};
|
}
|
return _checkCtrl;
|
}
|
|
//检查控件是否可见
|
private bool IsCheckCtrlVisible
|
{
|
get
|
{
|
if (this.docPnlBottom.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible)
|
{
|
if (this.controlContainerBottom.Controls.Count > 0)
|
{
|
if (this.controlContainerBottom.Controls[0] is HydroCheckResultCtrl)
|
{
|
return true;
|
}
|
}
|
}
|
return false;
|
}
|
}
|
|
//显示检查控件
|
private void ShowCheckCtrl(HydroCheckResult checkResult)
|
{
|
if (checkResult == null)
|
{
|
return;
|
}
|
var checkCtrl = GetCheckCtrl();
|
if (!IsCheckCtrlVisible)
|
{
|
this.controlContainerBottom.Controls.Clear();
|
this.controlContainerBottom.Controls.Add(checkCtrl);
|
this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
|
this.docPnlBottom.Text = "检查结果";
|
this.docPnlBottom.Height = 350;
|
}
|
checkCtrl.SetBindingData(checkResult);
|
}
|
|
//显示检查控件
|
private void ShowCheckCtrl()
|
{
|
var checkResult = GetCheckResult();
|
ShowCheckCtrl(checkResult);
|
}
|
|
#endregion
|
|
#region 模型计算
|
|
#region 计算结果
|
|
//计算结果辅助类
|
private SimulationCalcuResultHelper _calcuResultHelper = null;
|
|
//获取计算结果辅助类
|
private SimulationCalcuResultHelper GetCalcuResultHelper()
|
{
|
if (_calcuResultHelper == null)
|
{
|
var workingHelper = GetWorkingHelper();
|
_calcuResultHelper = new SimulationCalcuResultHelper(workingHelper);
|
}
|
return _calcuResultHelper;
|
}
|
|
#endregion
|
|
#region 计算失败
|
|
//计算失败控件
|
private HydroCalcuFailedCtrl _calcuFailedCtrl = null;
|
|
//获取计算失败控件
|
private HydroCalcuFailedCtrl GetCalcuFailedCtrl()
|
{
|
if (_calcuFailedCtrl == null)
|
{
|
_calcuFailedCtrl = new HydroCalcuFailedCtrl();
|
_calcuFailedCtrl.Dock = DockStyle.Fill;
|
}
|
return _calcuFailedCtrl;
|
}
|
|
//计算失败控件是否可见
|
private bool IsCalcuFailedCtrlVisible
|
{
|
get
|
{
|
if (this.docPnlBottom.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible)
|
{
|
if (this.controlContainerBottom.Controls.Count > 0)
|
{
|
if (this.controlContainerBottom.Controls[0] is HydroCalcuFailedCtrl)
|
{
|
return true;
|
}
|
}
|
}
|
return false;
|
}
|
}
|
|
//显示计算失败控件
|
private void ShowCalcuFailedCtrl(HydroCalcuResult calcuResult)
|
{
|
if (_hydroInfo == null)
|
{
|
return;
|
}
|
if (calcuResult == null)
|
{
|
return;
|
}
|
if (calcuResult.Succeed)
|
{
|
return;
|
}
|
var calcuFailedCtrl = GetCalcuFailedCtrl();
|
if (!IsCalcuFailedCtrlVisible)
|
{
|
this.controlContainerBottom.Controls.Clear();
|
this.controlContainerBottom.Controls.Add(calcuFailedCtrl);
|
this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
|
this.docPnlBottom.Text = "计算失败原因";
|
this.docPnlBottom.Height = 350;
|
}
|
calcuFailedCtrl.SetBindingData(calcuResult.FailedList);
|
}
|
|
#endregion
|
|
#region 计算警告
|
|
//计算警告控件
|
private HydroCalcuWarningCtrl _calcuWarningCtrl = null;
|
|
//获取计算警告控件
|
private HydroCalcuWarningCtrl GetCalcuWarningCtrl()
|
{
|
if (_calcuWarningCtrl == null)
|
{
|
_calcuWarningCtrl = new HydroCalcuWarningCtrl();
|
_calcuWarningCtrl.Dock = DockStyle.Fill;
|
_calcuWarningCtrl.HydroClickEvent += (code) =>
|
{
|
var visualListHelper = GetVisualListHelper();
|
var visual = visualListHelper.GetVisual(code);
|
SelectVisual(visual, eSimulationVisualSource.Warning);
|
};
|
}
|
return _calcuWarningCtrl;
|
}
|
|
//计算警告控件是否可见
|
private bool IsCalcuWarningCtrlVisible
|
{
|
get
|
{
|
if (this.docPnlBottom.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible)
|
{
|
if (this.controlContainerBottom.Controls.Count > 0)
|
{
|
if (this.controlContainerBottom.Controls[0] is HydroCalcuWarningCtrl)
|
{
|
return true;
|
}
|
}
|
}
|
return false;
|
}
|
}
|
|
//显示计算警告控件
|
private void ShowCalcuWarningCtrl(HydroCalcuResult calcuResult)
|
{
|
if (_hydroInfo == null)
|
{
|
return;
|
}
|
if (calcuResult == null)
|
{
|
return;
|
}
|
if (!calcuResult.Succeed)
|
{
|
return;
|
}
|
var calcuWaringCtrl = GetCalcuWarningCtrl();
|
if (!IsCalcuWarningCtrlVisible)
|
{
|
this.controlContainerBottom.Controls.Clear();
|
this.controlContainerBottom.Controls.Add(calcuWaringCtrl);
|
this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
|
this.docPnlBottom.Text = "计算警告";
|
this.docPnlBottom.Height = 350;
|
}
|
var visualListHelper = GetVisualListHelper();
|
var allVisualDict = visualListHelper.GetVisualDict();
|
calcuWaringCtrl.SetBindingData(calcuResult.WainingList, allVisualDict);
|
}
|
|
#endregion
|
|
#region 计算标签
|
|
//计算标签辅助类
|
private SimulationCalcuResultLabelHelper _calcuResultLabelHelper = null;
|
|
//获取计算标签辅助类
|
private async Task<SimulationCalcuResultLabelHelper> GetCalcuResultLabelHelper()
|
{
|
if (_calcuResultLabelHelper == null)
|
{
|
var calcuResultHelper = GetCalcuResultHelper();
|
var bimfaceCtrl = await GetBimfaceCtrl();
|
_calcuResultLabelHelper = new SimulationCalcuResultLabelHelper(calcuResultHelper, bimfaceCtrl);
|
}
|
return _calcuResultLabelHelper;
|
}
|
|
//设置计算标签是否显示
|
private async void barCkCalcu_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var calcuResultLabelHelper = await GetCalcuResultLabelHelper();
|
calcuResultLabelHelper.Visible = this.barCkCalcu.Checked;
|
calcuResultLabelHelper.Set();
|
}
|
|
#endregion
|
|
#endregion
|
|
#region 管网修复
|
|
//修复管网
|
private void Repair()
|
{
|
if (_hydroInfo == null)
|
{
|
return;
|
}
|
var checkResult = _hydroInfo.Check();
|
if (!checkResult.Succeed)
|
{
|
ShowCheckCtrl(checkResult);
|
TipFormHelper.ShowWarn("检查失败导致无法进行试算,停止管网修复!");
|
return;
|
}
|
var calcuResult = _hydroInfo.Calcu(Yw.EPAnet.CalcuMode.Simple);
|
if (!calcuResult.Succeed)
|
{
|
ShowCalcuFailedCtrl(calcuResult);
|
TipFormHelper.ShowWarn("试算失败,停止管网修复!");
|
return;
|
}
|
var visualListHelper = GetVisualListHelper();
|
var allLinkList = visualListHelper.GetLinkList();
|
if (allLinkList != null && allLinkList.Count < 1)
|
{
|
TipFormHelper.ShowError("模型中未包含管段信息,停止管网修复!");
|
return;
|
}
|
int count = 0;
|
foreach (var link in allLinkList)
|
{
|
var calcuLink = calcuResult.LinkList?.Find(x => x.Code == link.Code);
|
if (calcuLink == null)
|
{
|
continue;
|
}
|
if (!calcuLink.CalcuFlow.HasValue)
|
{
|
continue;
|
}
|
if (calcuLink.CalcuFlow.Value < 0)
|
{
|
var tempCode = link.StartCode;
|
link.StartCode = link.EndCode;
|
link.EndCode = tempCode;
|
count++;
|
}
|
}
|
var visualVmListHelper = GetVisualVmListHelper();
|
visualVmListHelper.UpdateProperty();
|
UpdateVisualListCtrl();
|
UpdatePropertyCtrl();
|
TipFormHelper.ShowSucceed($"修复完成,共修复管段({count})个!");
|
}
|
|
//管网修复
|
private void barBtnRepair_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
Repair();
|
}
|
|
#endregion
|
|
#region 导出INP
|
|
//导出INP文件
|
private void barBtnExportInp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
if (_hydroInfo == null)
|
{
|
return;
|
}
|
var fileName = FileDialogHelper.SaveInp("导出Inp文件");
|
if (string.IsNullOrEmpty(fileName))
|
{
|
return;
|
}
|
var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo);
|
var json = JsonHelper.Object2Json(netWork);
|
var result = netWork.ToInpString();
|
File.WriteAllText(fileName, result);
|
TipFormHelper.ShowSucceed("导出成功");
|
}
|
|
#endregion
|
|
#region 并联模拟
|
|
//并联分析
|
private void ParallelAnalysis()
|
{
|
if (_hydroInfo == null)
|
{
|
return;
|
}
|
var pumps = _hydroInfo.Pumps;
|
if (pumps == null || pumps.Count < 1)
|
{
|
XtraMessageBox.Show("无水泵信息");
|
return;
|
}
|
var vmList = new List<XhsSinglePumpViewModel>();
|
foreach (var pump in 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, 1);
|
vm.CurveQH = qhPtList;
|
vm.CurveQE = qePtList;
|
vm.CurveQP = qpPtList;
|
|
}
|
|
//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();
|
}
|
|
//并联分析
|
private void barBtnParallel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
ParallelAnalysis();
|
}
|
|
#endregion
|
|
#region 当前工况
|
|
//工况辅助类
|
private SimulationWorkingHelper _workingHelper = null;
|
|
//获取工况辅助类
|
private SimulationWorkingHelper GetWorkingHelper()
|
{
|
if (_workingHelper == null)
|
{
|
_workingHelper = new SimulationWorkingHelper();
|
}
|
return _workingHelper;
|
}
|
|
//获取工况
|
private HydroWorkingVmo GetWorking()
|
{
|
var workingHelper = GetWorkingHelper();
|
return workingHelper.Working;
|
}
|
|
//获取检查结果
|
private HydroCheckResult GetCheckResult()
|
{
|
var workingHelper = GetWorkingHelper();
|
return workingHelper.CheckResult;
|
}
|
|
//获取计算结果
|
private HydroCalcuResult GetCalcuResult()
|
{
|
var workingHelper = GetWorkingHelper();
|
return workingHelper.CalcuResult;
|
}
|
|
//初始化工况
|
private async Task InitialWorking()
|
{
|
if (_hydroInfo == null)
|
{
|
return;
|
}
|
if (_working == null)
|
{
|
return;
|
}
|
_hydroInfo.UpdateWorkingInfo(_working.WorkingInfo);
|
var monitorValueHelper = GetMonitorValueHelper();
|
var allMonitorValueList = await monitorValueHelper.GetAll();
|
allMonitorValueList.UpdateMonitorValue(_working.MonitorInfo);
|
|
var workingHelper = GetWorkingHelper();
|
//校验
|
var checkResult = _hydroInfo.Check();
|
if (!checkResult.Succeed)
|
{
|
workingHelper.InitialData(_hydroInfo, _working, checkResult, null);
|
ShowCheckCtrl(checkResult);
|
TipFormHelper.ShowError("校验失败!");
|
return;
|
}
|
//计算
|
var calcuResult = _hydroInfo.Calcu(Yw.EPAnet.CalcuMode.MinorLoss);
|
workingHelper.InitialData(_hydroInfo, _working, checkResult, calcuResult);
|
if (calcuResult.Succeed)
|
{
|
if (calcuResult.WainingList != null && calcuResult.WainingList.Count > 0)
|
{
|
ShowCalcuWarningCtrl(calcuResult);
|
}
|
}
|
else
|
{
|
ShowCalcuFailedCtrl(calcuResult);
|
TipFormHelper.ShowError("计算失败!");
|
}
|
|
}
|
|
#endregion
|
|
#region 工况分析
|
|
//选择进口水源
|
private void SelectInputSource()
|
{
|
var sources = GetSourceList();
|
if (sources != null)
|
{
|
if (sources.Count == 1)
|
{
|
SelectVisual(sources[0], eSimulationVisualSource.None);
|
}
|
else
|
{
|
var source = sources.FirstOrDefault(x => x.Flags.Contains(HStation.Xhs.Flags.进口));
|
if (source != null)
|
{
|
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 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 async void barBtnWorkingPower_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var workingHelper = GetWorkingHelper();
|
if (!workingHelper.Initialized)
|
{
|
TipFormHelper.ShowWarn("工况计算失败!");
|
return;
|
}
|
var allMonitorList = await GetMonitorList();
|
var dlg = new SimulationSingleWorkingEnergyDlg();
|
dlg.SetBindingData(workingHelper.Working, workingHelper.HydroInfo, allMonitorList, 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;
|
}
|
|
HydroVisualInfo visual = _visual;
|
if (_visual is HydroLinkInfo link)
|
{
|
visual = GetVisual(link.StartCode);
|
}
|
|
var dlg = new HydroSingleWorkingLossCurveDlg();
|
dlg.HydroClickEvent += (code) =>
|
{
|
SelectVisual(code, eSimulationVisualSource.None);
|
};
|
dlg.SetBindingData(workingHelper.HydroInfo, workingHelper.CalcuResult, visual);
|
dlg.ShowDialog();
|
}
|
|
//损失统计
|
private void barBtnWorkingLossStatistics_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var workingHelper = GetWorkingHelper();
|
if (!workingHelper.Initialized)
|
{
|
TipFormHelper.ShowError("工况计算失败!");
|
return;
|
}
|
var dlg = new HydroSingleWorkingLossStatisticsDlg();
|
dlg.SetBindingData(workingHelper.HydroInfo, workingHelper.CalcuResult);
|
dlg.ShowDialog();
|
}
|
|
//综合分析
|
private async void barBtnWorkingAnaly_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var workingHelper = GetWorkingHelper();
|
if (!workingHelper.Initialized)
|
{
|
TipFormHelper.ShowError("工况计算失败!");
|
return;
|
}
|
if (_visual == null)
|
{
|
if (_visual == null)
|
{
|
SelectInputSource();
|
if (_visual == null)
|
{
|
TipFormHelper.ShowWarn("请选择构件后重试!");
|
return;
|
}
|
}
|
}
|
|
HydroVisualInfo visual = _visual;
|
if (_visual is HydroLinkInfo linkInfo)
|
{
|
var visualListHelper = GetVisualListHelper();
|
visual = visualListHelper.GetVisual(linkInfo.StartCode);
|
}
|
|
var allMonitorList = await GetMonitorList();
|
|
var dlg = new SimulationSingleWorkingAnalyDlg();
|
dlg.SetBindingData(workingHelper.HydroInfo, allMonitorList, workingHelper.Working, workingHelper.CalcuResult, visual);
|
dlg.ShowDialog();
|
}
|
|
#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
|
|
|
}
|
}
|