| | |
| | | namespace HStation.WinFrmUI |
| | | using DevExpress.Spreadsheet; |
| | | using HStation.WinFrmUI.PhartRelation; |
| | | using Yw.WinFrmUI.Phart; |
| | | |
| | | namespace HStation.WinFrmUI |
| | | { |
| | | public partial class PumpFullInfoCtrl : DevExpress.XtraEditors.XtraUserControl |
| | | public partial class PumpFullInfoCtrl : DocumentPage |
| | | { |
| | | #region 构造函数和加载函数 |
| | | |
| | | public PumpFullInfoCtrl() |
| | | { |
| | | InitializeComponent(); |
| | | // |
| | | System.Windows.Forms.Form.CheckForIllegalCrossThreadCalls = false; |
| | | |
| | | this.navBarControlPara.GroupExpanded += new DevExpress.XtraNavBar.NavBarGroupEventHandler(this.NavBarControlPara_GroupExpanded); |
| | | this.navBarControlPara.GroupCollapsed += new DevExpress.XtraNavBar.NavBarGroupEventHandler(this.NavBarControlPara_GroupCollapsed); |
| | | this.navBarControlPara.ClientSizeChanged += new System.EventHandler(this.NavBarControlPara_ClientSizeChanged); |
| | | } |
| | | |
| | | private PumpMatchingViewModel _pump_mathing_vm = null; |
| | | |
| | | public void SetBindingData(PumpMatchingViewModel pumpMatchingViewModel) |
| | | { |
| | | _pump_mathing_vm = pumpMatchingViewModel; |
| | | pumpPropViewCtrl1.SetBindingData(pumpMatchingViewModel.DbId); |
| | | |
| | | if (long.TryParse(_pump_mathing_vm.DbId, out long pump_mian_id)) |
| | | { |
| | | InitData(pump_mian_id, null); |
| | | } |
| | | } |
| | | |
| | | private Yw.Geometry.CubicSpline2d _qh, _qe, _qp; |
| | | private Yw.Geometry.Point2d _work_pt; |
| | | private double _rated_speed; |
| | | |
| | | private async void InitData(long pump_main_id, Yw.Geometry.Point2d work_pt) |
| | | { |
| | | var pump_main = await new BLL.AssetsPumpMain().GetByID(pump_main_id); |
| | | if (pump_main == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var phart_list = await new BLL.XhsPumpMainPhartMappingExtensions().GetByPumpMainID(pump_main_id); |
| | | if (phart_list == null || !phart_list.Any()) |
| | | { |
| | | return; |
| | | } |
| | | var phart = phart_list.OrderBy(x => x.Importance).First(); |
| | | var diagram = phart.Diagram; |
| | | if (diagram == null) |
| | | { |
| | | return; |
| | | } |
| | | var graph_list = diagram.GraphList; |
| | | if (graph_list == null || !graph_list.Any()) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var graph_qh = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQH); |
| | | var graph_qe = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQE); |
| | | var graph_qp = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQP); |
| | | if (graph_qh == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | List<Yw.Geometry.Point2d> points_qh = null, points_qe = null, points_qp = null; |
| | | points_qh = PhartPerformCurveHelper.GetFeatPointList(graph_qh.GraphType, graph_qh.GeometryInfo, 12, null); |
| | | if (graph_qe != null) |
| | | points_qe = PhartPerformCurveHelper.GetFeatPointList(graph_qe.GraphType, graph_qe.GeometryInfo, 12, null); |
| | | if (graph_qp != null) |
| | | points_qp = PhartPerformCurveHelper.GetFeatPointList(graph_qp.GraphType, graph_qp.GeometryInfo, 12, null); |
| | | |
| | | var qh = new Yw.Geometry.CubicSpline2d(points_qh); |
| | | var qe = new Yw.Geometry.CubicSpline2d(points_qe); |
| | | var qp = new Yw.Geometry.CubicSpline2d(points_qp); |
| | | |
| | | InitChart(qh, qe, qp, work_pt, pump_main.RatedSpeed); |
| | | } |
| | | |
| | | public void InitChart( |
| | | Yw.Geometry.CubicSpline2d qh, |
| | | Yw.Geometry.CubicSpline2d qe, |
| | | Yw.Geometry.CubicSpline2d qp, |
| | | Yw.Geometry.Point2d work_pt, |
| | | double rated_speed) |
| | | { |
| | | _qh = qh; |
| | | _qe = qe; |
| | | _qp = qp; |
| | | _work_pt = work_pt; |
| | | _rated_speed = rated_speed; |
| | | |
| | | this.pumpPerformCompareChart1.SetBindingData(_qh, _qe, _qp); |
| | | if (work_pt != null) |
| | | { |
| | | var calc_speed = PumpCalcHelper.GetSimuValue(qh, work_pt, rated_speed); |
| | | var calc_hz = calc_speed / rated_speed * 50; |
| | | calc_hz = Math.Round(calc_hz, 1); |
| | | this.pumpPerformCompareInfoCtrl1.SetDesignPoint(work_pt, calc_hz); |
| | | } |
| | | |
| | | var vm_vs = new Yw.WinFrmUI.Phart.PumpVariableSpeedInfoViewModel(); |
| | | vm_vs.Id = Guid.NewGuid().ToString(); |
| | | vm_vs.Name = rated_speed.ToString(); |
| | | vm_vs.RatedSpeed = rated_speed; |
| | | vm_vs.CurrentSpeed = rated_speed; |
| | | vm_vs.CurrentHz = 50; |
| | | vm_vs.Qh = _qh; |
| | | vm_vs.Qe = _qe; |
| | | vm_vs.Qp = _qp; |
| | | vm_vs.Color = Color.Black; |
| | | vm_vs.IsDefault = true; |
| | | vm_vs.Calc(); |
| | | |
| | | this.pumpVariableSpeedInfoCtrl1.SetBindingData(vm_vs, work_pt); |
| | | this.pumpVariableSpeedChart1.Add(vm_vs, work_pt); |
| | | } |
| | | |
| | | private void SetChart() |
| | | { |
| | | #region 曲线 |
| | | |
| | | this.pumpPerformCompareInfoCtrl1.SetDesignPointEvent += (q, h) => |
| | | { |
| | | _work_pt = new Yw.Geometry.Point2d(q, h); |
| | | var calc_speed = PumpCalcHelper.GetSimuValue(_qh, _work_pt, _rated_speed); |
| | | var calc_hz = calc_speed / _rated_speed * 50; |
| | | calc_hz = Math.Round(calc_hz, 1); |
| | | |
| | | var qh_wk = PumpCalcHelper.CalculateSimilarQH(_qh, 50, calc_hz); |
| | | var qe_wk = PumpCalcHelper.CalculateSimilarQE(_qe, 50, calc_hz); |
| | | var qp_wk = PumpCalcHelper.CalculateSimilarQP(_qp, 50, calc_hz); |
| | | this.pumpPerformCompareChart1.SetWkData(qh_wk, qe_wk, qp_wk); |
| | | this.pumpPerformCompareChart1.CalcDesignPointByQ(q, h); |
| | | |
| | | return calc_hz; |
| | | }; |
| | | |
| | | this.pumpPerformCompareInfoCtrl1.SetHzEvent += (hz) => |
| | | { |
| | | var qh_wk = PumpCalcHelper.CalculateSimilarQH(_qh, 50, hz); |
| | | var qe_wk = PumpCalcHelper.CalculateSimilarQE(_qe, 50, hz); |
| | | var qp_wk = PumpCalcHelper.CalculateSimilarQP(_qp, 50, hz); |
| | | this.pumpPerformCompareChart1.SetWkData(qh_wk, qe_wk, qp_wk); |
| | | if (_work_pt != null) |
| | | { |
| | | this.pumpPerformCompareChart1.CalcDesignPointByQ(_work_pt.X, _work_pt.Y); |
| | | } |
| | | }; |
| | | |
| | | this.pumpPerformCompareChart1.OnCalcQueryPoint += (gropu_pt) => |
| | | { |
| | | var vm_list = new List<Yw.WinFrmUI.Phart.PumpPointItmeViewModel>(); |
| | | vm_list.Add(new Yw.WinFrmUI.Phart.PumpPointItmeViewModel() |
| | | { |
| | | Group = "查询点", |
| | | Name = "流量", |
| | | Value = $"{gropu_pt.Q:N1}", |
| | | Unit = "m³/h" |
| | | }); |
| | | vm_list.Add(new Yw.WinFrmUI.Phart.PumpPointItmeViewModel() |
| | | { |
| | | Group = "查询点", |
| | | Name = "扬程", |
| | | Value = $"{gropu_pt.H:N1}", |
| | | Unit = "m" |
| | | }); |
| | | vm_list.Add(new Yw.WinFrmUI.Phart.PumpPointItmeViewModel() |
| | | { |
| | | Group = "查询点", |
| | | Name = "效率", |
| | | Value = $"{gropu_pt.E:N1}", |
| | | Unit = "%" |
| | | }); |
| | | vm_list.Add(new Yw.WinFrmUI.Phart.PumpPointItmeViewModel() |
| | | { |
| | | Group = "查询点", |
| | | Name = "功率", |
| | | Value = $"{gropu_pt.P:N1}", |
| | | Unit = "kW" |
| | | }); |
| | | this.pumpPerformCompareInfoCtrl1.SetBindingData(vm_list); |
| | | }; |
| | | |
| | | #endregion 曲线 |
| | | |
| | | #region 变速曲线 |
| | | |
| | | this.pumpVariableSpeedInfoCtrl1.SetEvent += (id, qh, qe, qp) => |
| | | { |
| | | this.pumpVariableSpeedChart1.Set(id, qh, qe, qp); |
| | | ResetSectPointGrid(); |
| | | }; |
| | | |
| | | this.pumpVariableSpeedInfoCtrl1.SetInfoEvent += (id, name, color) => |
| | | { |
| | | this.pumpVariableSpeedChart1.SetInfo(id, name, color); |
| | | ResetSectPointGrid(); |
| | | }; |
| | | |
| | | this.pumpVariableSpeedChart1.AddBySpeedEvent += () => |
| | | { |
| | | AddBySpeed(); |
| | | ResetSectPointGrid(); |
| | | }; |
| | | |
| | | this.pumpVariableSpeedChart1.AddByHzEvent += () => |
| | | { |
| | | AddByHz(); |
| | | ResetSectPointGrid(); |
| | | }; |
| | | |
| | | this.pumpVariableSpeedChart1.AddByPointEvent += () => |
| | | { |
| | | AddByPoint(); |
| | | ResetSectPointGrid(); |
| | | }; |
| | | |
| | | this.pumpVariableSpeedInfoCtrl1.SetDesignPointEvent += (q, h) => |
| | | { |
| | | this.pumpVariableSpeedChart1.SetDesignPt(new Yw.Geometry.Point2d(q, h)); |
| | | ResetSectPointGrid(); |
| | | }; |
| | | |
| | | this.pumpVariableSpeedChart1.OnCalcQueryPoint += (id, pt) => |
| | | { |
| | | this.pumpVariableSpeedInfoCtrl1.SetQueryInfo(id, pt); |
| | | }; |
| | | |
| | | void ResetSectPointGrid() |
| | | { |
| | | var vm_list = this.pumpVariableSpeedChart1.GetList(); |
| | | this.pumpVariableSpeedInfoCtrl1.SetSectPoint(vm_list); |
| | | } |
| | | |
| | | void AddBySpeed() |
| | | { |
| | | var list = this.pumpVariableSpeedInfoCtrl1.GetList(); |
| | | if (list == null || list.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | var design_pt = this.pumpVariableSpeedInfoCtrl1.GetDesignPoint(); |
| | | var index = list.Count; |
| | | var vm_def = list.First(); |
| | | var dlg = new SetValueDlg(); |
| | | dlg.SetBindingData(vm_def.RatedSpeed); |
| | | dlg.VerifyValueChanged += (speed) => |
| | | { |
| | | var hz = Math.Round(speed / vm_def.RatedSpeed * 50, 1); |
| | | if (hz > 50 || hz < 10) |
| | | { |
| | | return false; |
| | | } |
| | | var vm = new PumpVariableSpeedInfoViewModel(vm_def); |
| | | vm.Id = Guid.NewGuid().ToString(); |
| | | vm.Name = this.pumpVariableSpeedChart1.LineNameShowHz ? hz.ToString() : speed.ToString(); |
| | | vm.Color = GetRandomColor(index); |
| | | vm.CurrentHz = hz; |
| | | vm.CurrentSpeed = speed; |
| | | vm.Calc(); |
| | | |
| | | this.pumpVariableSpeedInfoCtrl1.Add(vm); |
| | | this.pumpVariableSpeedChart1.Add(vm, design_pt); |
| | | |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | void AddByHz() |
| | | { |
| | | var list = this.pumpVariableSpeedInfoCtrl1.GetList(); |
| | | if (list == null || list.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var design_pt = this.pumpVariableSpeedInfoCtrl1.GetDesignPoint(); |
| | | var index = list.Count; |
| | | var vm_def = list.First(); |
| | | var dlg = new SetValueDlg(); |
| | | dlg.VerifyValueChanged += (hz) => |
| | | { |
| | | if (hz > 50 || hz < 10) |
| | | { |
| | | return false; |
| | | } |
| | | var speed = Math.Round(hz / 50 * vm_def.RatedSpeed); |
| | | var vm = new PumpVariableSpeedInfoViewModel(vm_def); |
| | | vm.Id = Guid.NewGuid().ToString(); |
| | | vm.Name = this.pumpVariableSpeedChart1.LineNameShowHz ? hz.ToString() : speed.ToString(); |
| | | vm.Color = GetRandomColor(index); |
| | | vm.CurrentHz = hz; |
| | | vm.CurrentSpeed = speed; |
| | | vm.Calc(); |
| | | |
| | | this.pumpVariableSpeedInfoCtrl1.Add(vm); |
| | | this.pumpVariableSpeedChart1.Add(vm, design_pt); |
| | | |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | void AddByPoint() |
| | | { |
| | | var list = this.pumpVariableSpeedInfoCtrl1.GetList(); |
| | | if (list == null || list.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | var index = list.Count; |
| | | var vm_def = list.First(); |
| | | var design_pt = this.pumpVariableSpeedInfoCtrl1.GetDesignPoint(); |
| | | var dlg = new SetPointDlg(); |
| | | dlg.SetBindingData(); |
| | | dlg.VerifyValueChanged += (x, y) => |
| | | { |
| | | var pt = new Yw.Geometry.Point2d(x, y); |
| | | var speed = PumpCalcHelper.GetSimuValue(vm_def.Qh, pt, vm_def.RatedSpeed); |
| | | var hz = Math.Round(speed / vm_def.RatedSpeed * 50, 1); |
| | | if (hz > 50 || hz < 20) |
| | | { |
| | | return false; |
| | | } |
| | | var vm = new PumpVariableSpeedInfoViewModel(vm_def); |
| | | vm.Id = Guid.NewGuid().ToString(); |
| | | vm.Name = this.pumpVariableSpeedChart1.LineNameShowHz ? hz.ToString() : speed.ToString(); |
| | | vm.Color = GetRandomColor(index); |
| | | vm.CurrentHz = hz; |
| | | vm.CurrentSpeed = speed; |
| | | vm.Calc(); |
| | | |
| | | this.pumpVariableSpeedInfoCtrl1.Add(vm); |
| | | this.pumpVariableSpeedChart1.Add(vm, design_pt); |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | #endregion 变速曲线 |
| | | } |
| | | |
| | | private void OnFrmLoad(object sender, EventArgs e) |
| | |
| | | //else if (this._m3dDispCtrlType == Model.e3dDispCtrlType.CAD_51JM) |
| | | //{ |
| | | //} |
| | | SetChart(); |
| | | } |
| | | |
| | | #region Color |
| | | |
| | | private List<Color> _color_array = new List<Color>() |
| | | { |
| | | Color.Red, Color.Blue, Color.Green,Color.DodgerBlue, |
| | | Color.Fuchsia, Color.MidnightBlue, Color.Maroon, Color.Aquamarine, |
| | | Color.Bisque,Color.BurlyWood |
| | | }; |
| | | |
| | | /// <summary> |
| | | /// 获取随机颜色 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private Color GetRandomColor(int count) |
| | | { |
| | | if (count < _color_array.Count) |
| | | { |
| | | return _color_array[count]; |
| | | } |
| | | |
| | | var _random = new Random(); |
| | | int r = _random.Next(1, 256); |
| | | int g = _random.Next(1, 256); |
| | | int b = _random.Next(1, 256); |
| | | return Color.FromArgb(r, g, b); |
| | | } |
| | | |
| | | #endregion Color |
| | | |
| | | #region 走马灯提示 |
| | | |
| | |
| | | /// <param name="e"></param> |
| | | private void xtraTabCtrlMain_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e) |
| | | { |
| | | this._tabPage串并联曲线参数.PageVisible = false; |
| | | |
| | | // |
| | | if (e.Page == this._tabPage三维模型) |
| | | { |
| | |
| | | { |
| | | this.xtraTabControlRight.SelectedTabPage = this._tabPage多速度曲线参数; |
| | | } |
| | | if (e.Page == this._tabPage串并联曲线) |
| | | { |
| | | this._tabPage串并联曲线参数.PageVisible = true; |
| | | this.xtraTabControlRight.SelectedTabPage = this._tabPage串并联曲线参数; |
| | | } |
| | | |
| | | if (e.Page == this._tabPage性能曲线图1) |
| | | { |
| | | this.xtraTabControlRight.SelectedTabPage = this.tabPage基本参数; |
| | |
| | | |
| | | private void CalcBarHeight() |
| | | { |
| | | if (!navBarGroupPoint.Expanded) |
| | | return; |
| | | //if (!navBarGroupPoint.Expanded) |
| | | // return; |
| | | |
| | | int GroupTitleHeight = 55;//头部高度 |
| | | //int GroupTitleHeight = 55;//头部高度 |
| | | |
| | | var height = this.Size.Height - 18;//18 : TAB 头部高度 |
| | | //var height = this.Size.Height - 18;//18 : TAB 头部高度 |
| | | |
| | | if (navBarGroupPara.Expanded) |
| | | { |
| | | var grp_height = CalcGroupParaHeight(); |
| | | //if (row_count == 7) |
| | | //{ |
| | | // grp_height = 280; |
| | | //} |
| | | this.navBarGroupControlXPumpParas.Height = grp_height; |
| | | this.navBarGroupPara.Expanded = true; |
| | | this.navBarGroupPara.GroupClientHeight = grp_height; |
| | | height = height - GroupTitleHeight - grp_height - 3; |
| | | } |
| | | else |
| | | { |
| | | height = height - GroupTitleHeight; |
| | | } |
| | | //if (navBarGroupPara.Expanded) |
| | | //{ |
| | | // var grp_height = CalcGroupParaHeight(); |
| | | // //if (row_count == 7) |
| | | // //{ |
| | | // // grp_height = 280; |
| | | // //} |
| | | // this.navBarGroupControlXPumpParas.Height = grp_height; |
| | | // this.navBarGroupPara.Expanded = true; |
| | | // this.navBarGroupPara.GroupClientHeight = grp_height; |
| | | // height = height - GroupTitleHeight - grp_height - 3; |
| | | //} |
| | | //else |
| | | //{ |
| | | // height = height - GroupTitleHeight; |
| | | //} |
| | | |
| | | if (navBarGroupJieZhi.Expanded) |
| | | { |
| | | height = height - 150; |
| | | } |
| | | else |
| | | { |
| | | height = height - GroupTitleHeight; |
| | | } |
| | | //if (navBarGroupJieZhi.Expanded) |
| | | //{ |
| | | // height = height - 150; |
| | | //} |
| | | //else |
| | | //{ |
| | | // height = height - GroupTitleHeight; |
| | | //} |
| | | |
| | | if (height > 100) |
| | | {//294, 393 |
| | | height = height - GroupTitleHeight; |
| | | navBarGroupPoint.GroupClientHeight = height; |
| | | } |
| | | //if (height > 100) |
| | | //{//294, 393 |
| | | // height = height - GroupTitleHeight; |
| | | // navBarGroupPoint.GroupClientHeight = height; |
| | | //} |
| | | } |
| | | |
| | | #endregion 计算展示面板高度 |