| | |
| | | namespace HStation.WinFrmUI |
| | | using DevExpress.XtraBars; |
| | | using HStation.WinFrmUI.PhartRelation; |
| | | using System.Data; |
| | | |
| | | namespace HStation.WinFrmUI |
| | | { |
| | | public partial class SimulationPumpSingleMatchingDlg : DevExpress.XtraEditors.XtraForm |
| | | public partial class SimulationPumpSingleMatchingDlg : DevExpress.XtraBars.Ribbon.RibbonForm |
| | | { |
| | | public SimulationPumpSingleMatchingDlg() |
| | | { |
| | | InitializeComponent(); |
| | | this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon; |
| | | this.gridViewPumpMain.SetNormalView(); |
| | | this.gridViewCurve.SetNormalView(); |
| | | } |
| | | |
| | | public class PhartViewModel |
| | | { |
| | | public long ID { get; set; } |
| | | public string OtherName { get; set; } |
| | | public int Importance { get; set; } |
| | | public int SortCode { get; set; } |
| | | public PhartDiagramExGraphList Diagram { get; set; } |
| | | } |
| | | |
| | | private HydroPumpMatchingViewModel _pump_matching_vm = null; |
| | | private List<PumpSingleMatchingViewModel> _pump_mian_vm_list = null; |
| | | private List<PhartViewModel> _phart_vm_list = null; |
| | | |
| | | private readonly Lazy<BLL.AssetsPumpMain> _pump_main_bll = new(); |
| | | private readonly Lazy<BLL.XhsPumpMainPhartMappingExtensions> _phart_ex_bll = new(); |
| | | |
| | | public event Action<HydroPumpMatchingViewModel> ReloadDataEvent; |
| | | |
| | | private HydroPumpMatchingViewModel _pumpMatchingView = null; |
| | | |
| | | public void SetBindingData(HydroPumpMatchingViewModel pumpMatchingViewModel) |
| | | public async void SetBindingData(HydroPumpMatchingViewModel pump_matching_vm) |
| | | { |
| | | this.pumpSingleMatchingCtrl.SetBindingData(pumpMatchingViewModel); |
| | | _pumpMatchingView = pumpMatchingViewModel; |
| | | _pump_matching_vm = pump_matching_vm; |
| | | _pump_mian_vm_list = new List<PumpSingleMatchingViewModel>(); |
| | | |
| | | int sel_index = 0; |
| | | var pump_main_list = await _pump_main_bll.Value.GetAll(); |
| | | if (pump_main_list != null && pump_main_list.Any()) |
| | | { |
| | | for (int i = 0; i < pump_main_list.Count; i++) |
| | | { |
| | | var item = pump_main_list[i]; |
| | | var vm = new PumpSingleMatchingViewModel(item); |
| | | _pump_mian_vm_list.Add(vm); |
| | | if (vm.ID.ToString() == pump_matching_vm.DbId.ToString()) |
| | | { |
| | | sel_index = i; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //确定 |
| | | private void btnComplete_Click(object sender, EventArgs e) |
| | | this.gridControlPumpMain.DataSource = _pump_mian_vm_list; |
| | | this.gridControlPumpMain.RefreshDataSource(); |
| | | this.gridViewPumpMain.BestFitColumns(); |
| | | this.gridViewPumpMain.FocusedRowHandle = sel_index; |
| | | } |
| | | |
| | | private void barBtnOK_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (_pumpMatchingView.MatchingDbId == null || _pumpMatchingView.MatchingDbId == string.Empty) |
| | | var pump_mian = this.gridViewPumpMain.GetCurrentViewModel(_pump_mian_vm_list); |
| | | if (pump_mian == null) |
| | | { |
| | | TipFormHelper.ShowError("泵型号选择错误"); |
| | | TipFormHelper.ShowError("泵型号为空"); |
| | | return; |
| | | } |
| | | if (_pumpMatchingView.MatchingCurveDbId == null || _pumpMatchingView.MatchingCurveDbId == string.Empty) |
| | | var phart = this.gridViewCurve.GetCurrentViewModel(_phart_vm_list); |
| | | if (phart == null) |
| | | { |
| | | TipFormHelper.ShowError("曲线选择错误"); |
| | | TipFormHelper.ShowError("泵型号曲线为空"); |
| | | return; |
| | | } |
| | | ReloadDataEvent.Invoke(_pumpMatchingView); |
| | | |
| | | var diagram = phart.Diagram; |
| | | if (!OutPtList |
| | | (diagram, |
| | | out List<Yw.Geometry.Point2d> qh_pt_list, |
| | | out List<Yw.Geometry.Point2d> qe_pt_list, |
| | | out List<Yw.Geometry.Point2d> qp_pt_list |
| | | )) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | _pump_matching_vm.MatchingDbId = pump_mian.ID.ToString(); |
| | | _pump_matching_vm.MatchingModelType = pump_mian.Name.ToString(); |
| | | _pump_matching_vm.MatchingRatedH = pump_mian.RatedHead; |
| | | _pump_matching_vm.MatchingRatedN = pump_mian.RatedSpeed; |
| | | _pump_matching_vm.MatchingRatedP = pump_mian.RatedPower; |
| | | _pump_matching_vm.MatchingRatedQ = pump_mian.RatedFlow; |
| | | |
| | | _pump_matching_vm.MatchingCurveDbId = phart.ID.ToString(); |
| | | _pump_matching_vm.MatchingCurveQH = qh_pt_list.Select(x => new HydroCurvePointViewModel(x.X, x.Y)).ToList(); |
| | | _pump_matching_vm.MatchingCurveQE = qe_pt_list?.Select(x => new HydroCurvePointViewModel(x.X, x.Y)).ToList(); |
| | | _pump_matching_vm.MatchingCurveQP = qp_pt_list?.Select(x => new HydroCurvePointViewModel(x.X, x.Y)).ToList(); |
| | | |
| | | this.ReloadDataEvent?.Invoke(_pump_matching_vm); |
| | | this.Close(); |
| | | } |
| | | |
| | | private async void gridViewPumpMain_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) |
| | | { |
| | | _phart_vm_list = new List<PhartViewModel>(); |
| | | var pump_main = this.gridViewPumpMain.GetCurrentViewModel(_pump_mian_vm_list); |
| | | if (pump_main != null) |
| | | { |
| | | var phart_list = await _phart_ex_bll.Value.GetByPumpMainID(pump_main.ID); |
| | | if (phart_list != null && phart_list.Any()) |
| | | { |
| | | foreach (var item in phart_list) |
| | | { |
| | | var vm = new PhartViewModel(); |
| | | vm.ID = item.ID; |
| | | vm.OtherName = item.OtherName; |
| | | vm.Importance = item.Importance; |
| | | vm.SortCode = item.SortCode; |
| | | vm.Diagram = item.Diagram; |
| | | _phart_vm_list.Add(vm); |
| | | } |
| | | } |
| | | } |
| | | |
| | | this.gridViewCurve.FocusInvalidRow(); |
| | | this.gridControlCurve.DataSource = _phart_vm_list; |
| | | this.gridControlCurve.RefreshDataSource(); |
| | | } |
| | | |
| | | private void gridViewCurve_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) |
| | | { |
| | | var phart = this.gridViewCurve.GetCurrentViewModel(_phart_vm_list); |
| | | if (phart == null) |
| | | { |
| | | this.xtrPerform2dChart1.InitialChartData(); |
| | | return; |
| | | } |
| | | |
| | | var diagram = phart.Diagram; |
| | | if (!OutPtList |
| | | (diagram, |
| | | out List<Yw.Geometry.Point2d> qh_pt_list, |
| | | out List<Yw.Geometry.Point2d> qe_pt_list, |
| | | out List<Yw.Geometry.Point2d> qp_pt_list |
| | | )) |
| | | { |
| | | this.xtrPerform2dChart1.InitialChartData(); |
| | | return; |
| | | } |
| | | |
| | | var cubic_spline_qh = new Yw.Geometry.CubicSpline2d(qh_pt_list); |
| | | var cubic_spline_qe = new Yw.Geometry.CubicSpline2d(qe_pt_list); |
| | | var cubic_spline_qp = new Yw.Geometry.CubicSpline2d(qp_pt_list); |
| | | var disp_paras = diagram.DispParas; |
| | | var is_calc_disp_paras = string.IsNullOrWhiteSpace(disp_paras); |
| | | this.xtrPerform2dChart1.SetBindingData(cubic_spline_qh, cubic_spline_qe, cubic_spline_qp, disp_paras, is_calc_disp_paras); |
| | | } |
| | | |
| | | private bool OutPtList( |
| | | PhartDiagramExGraphList diagram, |
| | | out List<Yw.Geometry.Point2d> qh_pt_list, |
| | | out List<Yw.Geometry.Point2d> qe_pt_list, |
| | | out List<Yw.Geometry.Point2d> qp_pt_list |
| | | ) |
| | | { |
| | | qh_pt_list = null; |
| | | qe_pt_list = null; |
| | | qp_pt_list = null; |
| | | |
| | | var graph_qh = diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQH); |
| | | var graph_qe = diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQE); |
| | | var graph_qp = diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQP); |
| | | if (graph_qh == null) |
| | | { |
| | | this.xtrPerform2dChart1.InitialChartData(); |
| | | return false; |
| | | } |
| | | |
| | | qh_pt_list = PhartPerformCurveHelper.GetFeatPointList(graph_qh.GraphType, graph_qh.GeometryInfo, 100, null); |
| | | if (graph_qe != null) |
| | | { |
| | | qe_pt_list = PhartPerformCurveHelper.GetFeatPointList(graph_qe.GraphType, graph_qe.GeometryInfo, 100, null); |
| | | } |
| | | if (graph_qp != null) |
| | | { |
| | | qp_pt_list = PhartPerformCurveHelper.GetFeatPointList(graph_qp.GraphType, graph_qp.GeometryInfo, 100, null); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | } |
| | | } |