| | |
| | | using DevExpress.Spreadsheet; |
| | | using StackExchange.Profiling.Internal; |
| | | using Yw.Ahart; |
| | | using Yw.Geometry; |
| | | using Yw.Pump; |
| | | using Yw.WinFrmUI.Phart; |
| | |
| | | public PumpChartViewCtrl() |
| | | { |
| | | InitializeComponent(); |
| | | this.barCekEqVisible.Checked = true; |
| | | this.barCekEqulEffVisible.Checked = true; |
| | | this.bar2.Visible = false; |
| | | this.barCekEqulEffVisible.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; |
| | | this.barCekPowerVisible.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; |
| | | this.barCekEqVisible.Checked = true; |
| | | this.barCekEqVisible.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; |
| | | |
| | | |
| | | } |
| | | |
| | | private Yw.Vmo.PhartDiagramExGraphListVmo _vmo = null; |
| | | private Yw.WinFrmUI.Phart.PumpPerformCurveViewModel _model = null; |
| | | private Yw.WinFrmUI.Phart.PumpCurveViewModel _vm = null; |
| | | |
| | | private bool _default_visible = true; |
| | | private Yw.Vmo.PhartDiagramExGraphListVmo _vmo = null; |
| | | private List<Yw.WinFrmUI.Phart.PumpViewChartViewModel> _vm_list = null; |
| | | |
| | | private string _coordinate = null; |
| | | private bool _power_visible = true; |
| | | private bool _eff_visible = true; |
| | | private bool _equal_eff_visible = true; |
| | | private bool _split_panel = true; |
| | | private double _nr; |
| | | |
| | | /// <summary> |
| | | /// 数据变更事件 |
| | | /// </summary> |
| | | public event Action<Yw.Vmo.PhartDiagramExGraphListVmo> DataChangedEvent; |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | |
| | | { |
| | | _vmo = vmo; |
| | | _nr = nr; |
| | | _vm_list = null; |
| | | _coordinate = null; |
| | | if (vmo == null) |
| | | { |
| | | ClearBindingData(); |
| | | return; |
| | | } |
| | | var vm_list = vmo.GetPumpCurveViewMdoelList(); |
| | | if (vm_list == null || !vm_list.Any()) |
| | | |
| | | var vm_list = new List<Yw.WinFrmUI.Phart.PumpViewChartViewModel>(); |
| | | if (vmo.GraphList == null || !vmo.GraphList.Any()) |
| | | { |
| | | ClearBindingData(); |
| | | return; |
| | | } |
| | | _model = vmo.GetDefaultPumpCurveViewMdoel(); |
| | | if (_model == null) |
| | | return; |
| | | |
| | | var vm_equal_eff_list = vmo.GetCurveEqualEViewMdoelList(); |
| | | var vm_variable_speed_eff_list = vmo.GetVariableSpeedPumpCurveViewMdoelList(); |
| | | |
| | | var vm = new Yw.WinFrmUI.Phart.PumpCurveViewModel(); |
| | | vm.Id = ""; |
| | | vm.ColorQH = Color.Blue; |
| | | vm.ColorQE = Color.Green; |
| | | vm.ColorQP = Color.Red; |
| | | vm.CurveQHName = $"{_nr}rpm({50}hz)"; |
| | | vm.CurveQPName = $"{_nr}rpm({50}hz)"; |
| | | vm.CurveQH = _model.CurveQH.FeatCurve.GetPointList(50); |
| | | vm.CurveQE = _model.CurveQE?.FeatCurve.GetPointList(50); |
| | | vm.CurveQP = _model.CurveQP?.FeatCurve.GetPointList(50); |
| | | vm.PointListQH = vm.CurveQH; |
| | | vm.PointListQE = vm.CurveQE; |
| | | vm.PointListQP = vm.CurveQP; |
| | | vm.Equip = null; |
| | | if (vm_equal_eff_list != null && vm_equal_eff_list.Any()) |
| | | _coordinate = vmo.DispParas; |
| | | foreach (var graph in vmo.GraphList) |
| | | { |
| | | vm.EqualEffList = new(); |
| | | foreach (var item in vm_equal_eff_list) |
| | | bool is_default = false; |
| | | double hz = 50; |
| | | double n = nr; |
| | | double eff = -1; |
| | | var curve_type = (Yw.Ahart.eCurveType)graph.GraphType; |
| | | switch (curve_type) |
| | | { |
| | | var eff_vm = new Yw.WinFrmUI.Phart.PumpCurveEqualEffViewModel(); |
| | | eff_vm.Id = Guid.NewGuid().ToString(); |
| | | eff_vm.CurveName = $"{item.Eff:N1}"; |
| | | eff_vm.Color = Color.DarkGreen; |
| | | eff_vm.CurveEqualEff = item.DefinePoints; |
| | | eff_vm.Tension = item.Tension; |
| | | eff_vm.IsClosed = item.IsClosed; |
| | | vm.EqualEffList.Add(eff_vm); |
| | | case Yw.Ahart.eCurveType.QH: |
| | | { |
| | | var paras = PhartGraphHelper.GetGraphParas<Yw.WinFrmUI.Phart.QHGraphParasViewModel>(curve_type, graph.GraphParas); |
| | | hz = paras.Hz; |
| | | n = paras.N; |
| | | if (hz == 50) |
| | | is_default = true; |
| | | } |
| | | break; |
| | | case Yw.Ahart.eCurveType.QP: |
| | | { |
| | | var paras = PhartGraphHelper.GetGraphParas<Yw.WinFrmUI.Phart.QPGraphParasViewModel>(curve_type, graph.GraphParas); |
| | | hz = paras.Hz; |
| | | n = paras.N; |
| | | if (hz == 50) |
| | | is_default = true; |
| | | } |
| | | break; |
| | | case Yw.Ahart.eCurveType.QE: |
| | | { |
| | | var paras = PhartGraphHelper.GetGraphParas<Yw.WinFrmUI.Phart.QEGraphParasViewModel>(curve_type, graph.GraphParas); |
| | | hz = paras.Hz; |
| | | n = paras.N; |
| | | if (hz == 50) |
| | | is_default = true; |
| | | } |
| | | break; |
| | | case Yw.Ahart.eCurveType.EqualE: |
| | | { |
| | | var paras = PhartGraphHelper.GetGraphParas<EqualEGraphParasViewModel>(curve_type, graph.GraphParas); |
| | | eff = paras.Eff; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | var feat_curve = PhartGraphHelper.GetPerformCurve(curve_type, graph.GeometryInfo); |
| | | var geometry_paras = PhartGraphHelper.GetGeometryParas(curve_type, graph.GeometryParas); |
| | | var annotation_list = PhartGraphHelper.GetAnnotationParasList(curve_type, graph.AnnotationParas); |
| | | if (curve_type == eCurveType.QE) |
| | | annotation_list = null; |
| | | var vm = new Yw.WinFrmUI.Phart.PumpViewChartViewModel(); |
| | | vm.Id = graph.ID.ToString(); |
| | | vm.DbId = graph.ID; |
| | | vm.Hz = hz; |
| | | vm.N = n; |
| | | vm.Eff = eff; |
| | | vm.AnnotationList = annotation_list; |
| | | vm.CurveType = feat_curve.CurveType; |
| | | vm.FeatType = feat_curve.FeatType; |
| | | vm.DefPointList = geometry_paras?.DefinePoints; |
| | | vm.FitPointList = feat_curve.FeatCurve.GetPointList(100); |
| | | if (vm.CurveType == eCurveType.EqualE) |
| | | vm.FitPointList = feat_curve.FeatCurve.GetPointList(10); |
| | | |
| | | vm.IsDefault = is_default; |
| | | vm.GraphParas = graph.GraphParas; |
| | | vm_list.Add(vm); |
| | | } |
| | | |
| | | if (vm_variable_speed_eff_list != null && vm_variable_speed_eff_list.Any()) |
| | | _vm_list = vm_list; |
| | | var list = _vm_list.Select(x => x.Hz).OrderByDescending(x => x).ToList(); |
| | | list = list.Distinct().ToList(); |
| | | |
| | | this.repImgCmbCurveSel.BeginInit(); |
| | | this.repImgCmbCurveSel.Items.Clear(); |
| | | foreach (var hz in list) |
| | | { |
| | | vm.VariableSpeedList = new(); |
| | | var index = 0; |
| | | foreach (var item in vm_variable_speed_eff_list) |
| | | { |
| | | var vs_color = Yw.WinFrmUI.PhartColorHelper.Get(index); |
| | | var vs_vm = new Yw.WinFrmUI.Phart.PumpCurveVariableSpeedViewModel(); |
| | | vs_vm.Id = Guid.NewGuid().ToString(); |
| | | vs_vm.ColorQH = vs_color; |
| | | vs_vm.ColorQE = vs_color; |
| | | vs_vm.ColorQP = vs_color; |
| | | vs_vm.CurveQHName = $"{item.N}rpm({item.Hz}hz)"; |
| | | vs_vm.CurveQPName = $"{item.N}rpm({item.Hz}hz)"; |
| | | vs_vm.CurveQH = item.CurveQH.FeatCurve.GetPointList(30); |
| | | vs_vm.CurveQE = item.CurveQE.FeatCurve.GetPointList(30); |
| | | vs_vm.CurveQP = item.CurveQP.FeatCurve.GetPointList(30); |
| | | vs_vm.N = item.N; |
| | | vs_vm.Hz = item.Hz; |
| | | vm.VariableSpeedList.Add(vs_vm); |
| | | index++; |
| | | } |
| | | this.repImgCmbCurveSel.Items.Add($"{hz}hz", hz, -1); |
| | | } |
| | | this.repImgCmbCurveSel.EndInit(); |
| | | this.barImgCmbChartSel.EditValue = null; |
| | | |
| | | vm.VariableSpeedList = new List<PumpCurveVariableSpeedViewModel>(); |
| | | vm.EqualEffList = new List<PumpCurveEqualEffViewModel>(); |
| | | vm.EqualPowerList = new(); |
| | | |
| | | SetBindingData(vm, _default_visible, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | SetColor(_vm_list); |
| | | SetBindingData(_vm_list, _coordinate, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | private void SetColor(List<Yw.WinFrmUI.Phart.PumpViewChartViewModel> vm_list) |
| | | { |
| | | if (vm_list == null || !vm_list.Any()) |
| | | return; |
| | | var group = vm_list.GroupBy(x => x.Hz); |
| | | if (group.Count() > 1) |
| | | { |
| | | for (int i = 0; i < group.Count(); i++) |
| | | { |
| | | var color = Yw.WinFrmUI.PhartColorHelper.Get(i); |
| | | var item = group.ElementAt(i); |
| | | foreach (var vm in item) |
| | | { |
| | | vm.Color = color; |
| | | if (vm.CurveType == eCurveType.EqualE) |
| | | vm.Color = Color.DarkGreen; |
| | | } |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | var item = group.ElementAt(0); |
| | | foreach (var vm in item) |
| | | { |
| | | switch (vm.CurveType) |
| | | { |
| | | case Yw.Ahart.eCurveType.QH: vm.Color = Yw.WinFrmUI.Phart.PumpChartDisplay.CurveColorQH; break; |
| | | case Yw.Ahart.eCurveType.QP: vm.Color = Yw.WinFrmUI.Phart.PumpChartDisplay.CurveColorQP; break; |
| | | case Yw.Ahart.eCurveType.QE: vm.Color = Yw.WinFrmUI.Phart.PumpChartDisplay.CurveColorQE; break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | public void SetBindingData(Yw.WinFrmUI.Phart.PumpCurveViewModel vm, bool default_visible, bool split_panel, bool eff_visible, bool power_visible, bool equal_eff_visible) |
| | | private void SetBindingData(List<Yw.WinFrmUI.Phart.PumpViewChartViewModel> vm_list, string coordinate, bool split_panel, bool eff_visible, bool power_visible, bool equal_eff_visible) |
| | | { |
| | | _vm = vm; |
| | | if (vm == null) |
| | | if (IsInvalidData()) |
| | | { |
| | | ClearBindingData(); |
| | | return; |
| | | } |
| | | if (vm.VariableSpeedList != null && vm.VariableSpeedList.Any()) |
| | | var list = new List<Yw.WinFrmUI.Phart.PumpViewChartViewModel>(); |
| | | foreach (var item in vm_list) |
| | | { |
| | | vm.ColorQH = vm.ColorQE = vm.ColorQP = Color.Black; |
| | | if (!eff_visible) |
| | | { |
| | | if (item.CurveType == eCurveType.QE) |
| | | { |
| | | continue; |
| | | }; |
| | | } |
| | | |
| | | if (!power_visible) |
| | | { |
| | | if (item.CurveType == eCurveType.QP) |
| | | { |
| | | continue; |
| | | }; |
| | | } |
| | | |
| | | if (!equal_eff_visible) |
| | | { |
| | | if (item.CurveType == eCurveType.EqualE) |
| | | { |
| | | continue; |
| | | }; |
| | | } |
| | | |
| | | list.Add(item); |
| | | } |
| | | this.pumpViewChart1.SetBindingData(vm, default_visible, split_panel, eff_visible, power_visible, equal_eff_visible); |
| | | |
| | | this.pumpViewChart1.SetBindingData(list, coordinate, split_panel, eff_visible, power_visible, equal_eff_visible); |
| | | } |
| | | |
| | | //是否是无效数据 |
| | | private bool IsInvalidData() |
| | | { |
| | | if (_vm_list == null || !_vm_list.Any()) |
| | | { |
| | | TipFormHelper.ShowInfo("无数据"); |
| | | return true; |
| | | } |
| | | if (!_vm_list.Exists(x => x.CurveType == Yw.Ahart.eCurveType.QH)) |
| | | { |
| | | TipFormHelper.ShowInfo("无数据"); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 清空绑定数据 |
| | | /// </summary> |
| | | public void ClearBindingData() |
| | | { |
| | | this.pumpViewChart1.ClearBindingData(); |
| | | this.pumpViewChart1.Clear(); |
| | | } |
| | | |
| | | |
| | | private void SetEquip() |
| | | { |
| | | if (_vm == null) |
| | | if (_vmo == null) |
| | | return; |
| | | if (!_vm.IsValid()) |
| | | if (_vm_list == null || !_vm_list.Any()) |
| | | return; |
| | | if (this.barTxtStartHead.EditValue == null) |
| | | return; |
| | |
| | | if (this.barTxtPipeQ.EditValue == null) |
| | | return; |
| | | |
| | | var qh50 = _vm_list.Find(x => x.Hz == 50 && x.CurveType == Yw.Ahart.eCurveType.QH); |
| | | if (qh50 == null) |
| | | return; |
| | | |
| | | var start_head = Convert.ToDouble(this.barTxtStartHead.EditValue); |
| | | var pipe_head = Convert.ToDouble(this.barTxtPipeHead.EditValue); |
| | | var pipe_flow = Convert.ToDouble(this.barTxtPipeQ.EditValue); |
| | | |
| | | var equip_pt = new Yw.Geometry.Point2d(pipe_flow, pipe_head); |
| | | var qh_line = new Yw.Ahart.CurveQH(Yw.Ahart.eFeatType.Cubic, _vm.CurveQH); |
| | | var equip_line = Yw.Pump.PerformParabolaHelper.GetEquipCurvePointListByQH(qh_line, equip_pt, start_head, 30, true, out Yw.Geometry.Point2d sect_pt); |
| | | if (equip_line == null || sect_pt == null) |
| | | var equip_pt_list = Yw.Pump.PerformParabolaHelper.GetEquipCurvePointListByQH(qh50.FitPointList, equip_pt, start_head, 30, true, out Yw.Geometry.Point2d sect_pt); |
| | | if (equip_pt_list == null || sect_pt == null) |
| | | { |
| | | XtraMessageBox.Show("计算失败,设计点不合理!"); |
| | | return; |
| | | } |
| | | |
| | | _vm.Equip = new Yw.WinFrmUI.Phart.PumpCurveEquipViewModel(); |
| | | _vm.Equip.Id = Guid.NewGuid().ToString(); |
| | | _vm.Equip.Color = Color.Black; |
| | | _vm.Equip.StartH = start_head; |
| | | _vm.Equip.PipeQ = pipe_flow; |
| | | _vm.Equip.PipeH = pipe_head; |
| | | var pump_sect_pt = new Yw.WinFrmUI.Phart.PumpSectPointViewModel(); |
| | | pump_sect_pt.Q = sect_pt.X; |
| | | pump_sect_pt.H = sect_pt.Y; |
| | | |
| | | _vm.Equip.SectQ = sect_pt.X; |
| | | _vm.Equip.SectH = sect_pt.Y; |
| | | |
| | | if (_vm.CurveQP != null && _vm.CurveQP.Any()) |
| | | var qe50 = _vm_list.Find(x => x.Hz == 50 && x.CurveType == Yw.Ahart.eCurveType.QE); |
| | | if (qe50 != null) |
| | | { |
| | | _vm.Equip.SectP = _vm.CurveQP.GetInterPointsY(sect_pt.X)?.FirstOrDefault(); |
| | | pump_sect_pt.E = qe50?.FitPointList?.GetInterPointsY(sect_pt.X)?.FirstOrDefault(); |
| | | } |
| | | |
| | | if (_vm.CurveQE != null && _vm.CurveQE.Any()) |
| | | var qp50 = _vm_list.Find(x => x.Hz == 50 && x.CurveType == Yw.Ahart.eCurveType.QP); |
| | | if (qp50 != null) |
| | | { |
| | | _vm.Equip.SectE = _vm.CurveQE.GetInterPointsY(sect_pt.X)?.FirstOrDefault(); |
| | | pump_sect_pt.P = qp50?.FitPointList?.GetInterPointsY(sect_pt.X)?.FirstOrDefault(); |
| | | } |
| | | |
| | | _vm.Equip.CurveEquip = equip_line.GetPointList(Yw.Ahart.eFeatType.Cubic); |
| | | SetBindingData(_vm, _default_visible, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | this.pumpViewChart1.SetEquip(equip_pt_list, pump_sect_pt); |
| | | } |
| | | |
| | | |
| | | private void barImgCmbChartSel_EditValueChanged(object sender, EventArgs e) |
| | | { |
| | | if (this.barImgCmbChartSel.EditValue==null) |
| | | { |
| | | return; |
| | | } |
| | | var hz = Convert.ToDouble(this.barImgCmbChartSel.EditValue); |
| | | _vm_list.ForEach(x => x.IsSelect = false); |
| | | foreach (var vm in _vm_list) |
| | | { |
| | | if (vm.Hz != hz) |
| | | continue; |
| | | switch (vm.CurveType) |
| | | { |
| | | case Yw.Ahart.eCurveType.QH: |
| | | { |
| | | vm.IsSelect = true; |
| | | } |
| | | break; |
| | | case Yw.Ahart.eCurveType.QP: |
| | | { |
| | | vm.IsSelect = true; |
| | | } |
| | | break; |
| | | case Yw.Ahart.eCurveType.QE: |
| | | { |
| | | vm.IsSelect = true; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | SetBindingData(_vm_list, _coordinate, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | } |
| | | private void barCekLineVisible_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | this.pumpViewChart1.LineVisible=this.barCekLineVisible.Checked; |
| | | } |
| | | private void barCekEffVisible_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | _eff_visible = this.barCekEffVisible.Checked; |
| | | SetBindingData(_vm, _default_visible, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | SetBindingData(_vm_list, _coordinate, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | } |
| | | |
| | | private void barCekPowerVisible_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | _power_visible = this.barCekPowerVisible.Checked; |
| | | SetBindingData(_vm, _default_visible, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | SetBindingData(_vm_list, _coordinate, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | } |
| | | |
| | | private void barCekSplitPanel_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | _split_panel = this.barCekSplitPanel.Checked; |
| | | SetBindingData(_vm, _default_visible, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | SetBindingData(_vm_list, _coordinate, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | } |
| | | |
| | | private void barCekEqVisible_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | |
| | | } |
| | | else |
| | | { |
| | | _vm.Equip = null; |
| | | SetBindingData(_vm, _default_visible, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | this.pumpViewChart1.SetEquip(null, null); |
| | | } |
| | | } |
| | | |
| | | private void barCekEqulEffVisible_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | _equal_eff_visible = this.barCekEqulEffVisible.Checked; |
| | | SetBindingData(_vm, _default_visible, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | SetBindingData(_vm_list, _coordinate, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | } |
| | | |
| | | private void barBtnEqClear_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | |
| | | this.barTxtStartHead.EditValue = 0; |
| | | this.barTxtPipeQ.EditValue = null; |
| | | this.barTxtPipeHead.EditValue = null; |
| | | |
| | | _vm.Equip = null; |
| | | SetBindingData(_vm, _default_visible, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | this.pumpViewChart1.SetEquip(null, null); |
| | | } |
| | | |
| | | private void barBtnSetEqPt_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | |
| | | AddByEff(); |
| | | } |
| | | |
| | | private void barBtnDeleteVariableSpeed_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (IsInvalidData()) |
| | | { |
| | | return; |
| | | } |
| | | if (!_vm_list.Exists(x => x.Hz != 50)) |
| | | { |
| | | TipFormHelper.ShowInfo("无变速线"); |
| | | return; |
| | | } |
| | | var list = _vm_list.Where(x => x.Hz != 50).Select(x => (x.Hz, x.N)).ToList(); |
| | | var dlg = new DeleteVariableSpeedDlg(); |
| | | dlg.SetBindingData(list); |
| | | dlg.ReloadDataEvent += (del_list) => |
| | | { |
| | | var del_info_list = _vm_list.Where(x => del_list.Contains(x.Hz)).Select(x => (x.DbId, x.Hz)).ToList(); |
| | | Delete(del_info_list); |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | private void barBtnDeleteEqualEff_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (IsInvalidData()) |
| | | { |
| | | return; |
| | | } |
| | | if (!_vm_list.Exists(x => x.CurveType == eCurveType.EqualE)) |
| | | { |
| | | TipFormHelper.ShowInfo("无等效线"); |
| | | return; |
| | | } |
| | | var _vm_eff_list = _vm_list.Where(x => x.CurveType == eCurveType.EqualE).ToList(); |
| | | var list = _vm_eff_list.Select(x => x.Eff).ToList(); |
| | | var dlg = new DeleteEqualEDlg(); |
| | | dlg.SetBindingData(list); |
| | | dlg.ReloadDataEvent += (del_list) => |
| | | { |
| | | var del_info_list = _vm_eff_list.Where(x => del_list.Contains(x.Eff)).Select(x => (x.DbId, x.Eff)).ToList(); |
| | | Delete(del_info_list); |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | |
| | | } |
| | | |
| | | |
| | | private void AddByN() |
| | | { |
| | | if (_vm == null) |
| | | if (IsInvalidData()) |
| | | return; |
| | | var dlg = new SetValueDlg(); |
| | | var qh50 = _vm_list.Find(x => x.Hz == 50 && x.CurveType == Yw.Ahart.eCurveType.QH); |
| | | if (qh50 == null) |
| | | return; |
| | | var qe50 = _vm_list.Find(x => x.Hz == 50 && x.CurveType == Yw.Ahart.eCurveType.QE); |
| | | var qp50 = _vm_list.Find(x => x.Hz == 50 && x.CurveType == Yw.Ahart.eCurveType.QP); |
| | | |
| | | var dlg = new Yw.WinFrmUI.Phart.SetValueDlg(); |
| | | dlg.SetBindingData(_nr); |
| | | dlg.VerifyValueChanged += (speed) => |
| | | { |
| | |
| | | { |
| | | return false; |
| | | } |
| | | if (_vm_list.Exists(x => x.N == speed)) |
| | | { |
| | | TipFormHelper.ShowWarn("转速已存在"); |
| | | return false; |
| | | } |
| | | hz = Math.Round(hz, 1); |
| | | |
| | | var index = _vm.VariableSpeedList?.Count + 1 ?? 1; |
| | | var vs_color = Yw.WinFrmUI.PhartColorHelper.Get(index); |
| | | var vs_vm = new Yw.WinFrmUI.Phart.PumpCurveVariableSpeedViewModel(); |
| | | vs_vm.Id = Guid.NewGuid().ToString(); |
| | | vs_vm.ColorQH = vs_color; |
| | | vs_vm.ColorQE = vs_color; |
| | | vs_vm.ColorQP = vs_color; |
| | | vs_vm.CurveQHName = $"{speed}rpm({hz}hz)"; |
| | | vs_vm.CurveQPName = $"{speed}rpm({hz}hz)"; |
| | | vs_vm.CurveQH = _vm.CurveQH.GetQHPointListByN(50, hz); |
| | | vs_vm.CurveQE = _vm.CurveQE.GetQEPointListByN(50, hz); |
| | | vs_vm.CurveQP = _vm.CurveQP.GetQEPointListByN(50, hz); |
| | | vs_vm.N = speed; |
| | | vs_vm.Hz = hz; |
| | | _vm.VariableSpeedList.Add(vs_vm); |
| | | SetBindingData(_vm, _default_visible, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | var pt_qh_list = qh50.FitPointList.GetQHPointListByN(50, hz); |
| | | var pt_qe_list = qe50?.FitPointList?.GetQEPointListByN(50, hz); |
| | | var pt_qp_list = qp50?.FitPointList?.GetQPPointListByN(50, hz); |
| | | |
| | | //this.DataChangedEvent?.Invoke(); |
| | | Insert(hz, speed, pt_qh_list, pt_qe_list, pt_qp_list); |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | |
| | | |
| | | private void AddByHz() |
| | | { |
| | | if (_vm == null) |
| | | if (IsInvalidData()) |
| | | return; |
| | | var dlg = new SetValueDlg(); |
| | | |
| | | var qh50 = _vm_list.Find(x => x.Hz == 50 && x.CurveType == Yw.Ahart.eCurveType.QH); |
| | | if (qh50 == null) |
| | | return; |
| | | var qe50 = _vm_list.Find(x => x.Hz == 50 && x.CurveType == Yw.Ahart.eCurveType.QE); |
| | | var qp50 = _vm_list.Find(x => x.Hz == 50 && x.CurveType == Yw.Ahart.eCurveType.QP); |
| | | |
| | | var dlg = new Yw.WinFrmUI.Phart.SetValueDlg(); |
| | | dlg.VerifyValueChanged += (hz) => |
| | | { |
| | | if (hz > 50 || hz < 10) |
| | | { |
| | | return false; |
| | | } |
| | | if (_vm_list.Exists(x => x.Hz == hz)) |
| | | { |
| | | TipFormHelper.ShowWarn("频率已存在"); |
| | | return false; |
| | | } |
| | | var speed = Math.Round(hz / 50 * _nr); |
| | | var index = _vm.VariableSpeedList?.Count + 1 ?? 1; |
| | | var vs_color = Yw.WinFrmUI.PhartColorHelper.Get(index); |
| | | var vs_vm = new Yw.WinFrmUI.Phart.PumpCurveVariableSpeedViewModel(); |
| | | vs_vm.Id = Guid.NewGuid().ToString(); |
| | | vs_vm.ColorQH = vs_color; |
| | | vs_vm.ColorQE = vs_color; |
| | | vs_vm.ColorQP = vs_color; |
| | | vs_vm.CurveQHName = $"{speed}rpm({hz}hz)"; |
| | | vs_vm.CurveQPName = $"{speed}rpm({hz}hz)"; |
| | | vs_vm.CurveQH = _vm.CurveQH.GetQHPointListByN(50, hz); |
| | | vs_vm.CurveQE = _vm.CurveQE.GetQEPointListByN(50, hz); |
| | | vs_vm.CurveQP = _vm.CurveQP.GetQEPointListByN(50, hz); |
| | | vs_vm.N = speed; |
| | | vs_vm.Hz = hz; |
| | | _vm.VariableSpeedList.Add(vs_vm); |
| | | SetBindingData(_vm, _default_visible, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | speed = Math.Round(speed, 1); |
| | | |
| | | |
| | | var pt_qh_list = qh50.FitPointList.GetQHPointListByN(50, hz); |
| | | var pt_qe_list = qe50?.FitPointList?.GetQEPointListByN(50, hz); |
| | | var pt_qp_list = qp50?.FitPointList?.GetQPPointListByN(50, hz); |
| | | |
| | | Insert(hz, speed, pt_qh_list, pt_qe_list, pt_qp_list); |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | |
| | | |
| | | private void AddByPoint() |
| | | { |
| | | if (_vm == null) |
| | | if (IsInvalidData()) |
| | | return; |
| | | if (!_vm.IsValid()) |
| | | |
| | | var qh50 = _vm_list.Find(x => x.Hz == 50 && x.CurveType == Yw.Ahart.eCurveType.QH); |
| | | if (qh50 == null) |
| | | return; |
| | | var dlg = new SetPointDlg(); |
| | | var qe50 = _vm_list.Find(x => x.Hz == 50 && x.CurveType == Yw.Ahart.eCurveType.QE); |
| | | var qp50 = _vm_list.Find(x => x.Hz == 50 && x.CurveType == Yw.Ahart.eCurveType.QP); |
| | | |
| | | var dlg = new Yw.WinFrmUI.Phart.SetPointDlg(); |
| | | dlg.SetBindingData(); |
| | | dlg.VerifyValueChanged += (x, y) => |
| | | { |
| | | var pt = new Yw.Geometry.Point2d(x, y); |
| | | var sect_pt = Yw.Pump.PerformParabolaHelper.GetQHSectPoint(_model.CurveQH, pt); |
| | | var curve = new Yw.Pump.CurveQH(qh50.FeatType, qh50.DefPointList); |
| | | var sect_pt = Yw.Pump.PerformParabolaHelper.GetQHSectPoint(curve, pt); |
| | | if (sect_pt == null || sect_pt.IsZeroPoint()) |
| | | return false; |
| | | |
| | |
| | | return false; |
| | | } |
| | | speed = Math.Round(speed, 1); |
| | | var index = _vm.VariableSpeedList?.Count + 1 ?? 1; |
| | | var vs_color = Yw.WinFrmUI.PhartColorHelper.Get(index); |
| | | var vs_vm = new Yw.WinFrmUI.Phart.PumpCurveVariableSpeedViewModel(); |
| | | vs_vm.Id = Guid.NewGuid().ToString(); |
| | | vs_vm.ColorQH = vs_color; |
| | | vs_vm.ColorQE = vs_color; |
| | | vs_vm.ColorQP = vs_color; |
| | | vs_vm.CurveQHName = $"{speed}rpm({hz}hz)"; |
| | | vs_vm.CurveQPName = $"{speed}rpm({hz}hz)"; |
| | | vs_vm.CurveQH = _vm.CurveQH.GetQHPointListByN(50, hz); |
| | | vs_vm.CurveQE = _vm.CurveQE.GetQEPointListByN(50, hz); |
| | | vs_vm.CurveQP = _vm.CurveQP.GetQEPointListByN(50, hz); |
| | | vs_vm.N = speed; |
| | | vs_vm.Hz = hz; |
| | | _vm.VariableSpeedList.Add(vs_vm); |
| | | SetBindingData(_vm, _default_visible, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | if (_vm_list.Exists(x => x.N == speed)) |
| | | { |
| | | TipFormHelper.ShowWarn("转速已存在"); |
| | | return false; |
| | | } |
| | | var pt_qh_list = qh50.FitPointList.GetQHPointListByN(50, hz); |
| | | var pt_qe_list = qe50?.FitPointList?.GetQEPointListByN(50, hz); |
| | | var pt_qp_list = qp50?.FitPointList?.GetQPPointListByN(50, hz); |
| | | |
| | | Insert(hz, speed, pt_qh_list, pt_qe_list, pt_qp_list); |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | |
| | | |
| | | private void AddByEff() |
| | | { |
| | | if (_vm == null) |
| | | if (IsInvalidData()) |
| | | return; |
| | | if (!_vm.IsValid()) |
| | | var qh50 = _vm_list.Find(x => x.Hz == 50 && x.CurveType == Yw.Ahart.eCurveType.QH); |
| | | if (qh50 == null) |
| | | return; |
| | | if (_vm.CurveQE == null || !_vm.CurveQE.Any()) |
| | | var qe50 = _vm_list.Find(x => x.Hz == 50 && x.CurveType == Yw.Ahart.eCurveType.QE); |
| | | if (qe50 == null) |
| | | return; |
| | | |
| | | var dlg = new SetEffDlg(); |
| | | dlg.SetBindingData(); |
| | | dlg.VerifyValueChanged += (eff_double_list) => |
| | | { |
| | | double max_hz = 50; |
| | | double min_hz = 30; |
| | | if (_vm.VariableSpeedList != null && _vm.VariableSpeedList.Any()) |
| | | { |
| | | max_hz = Math.Max(max_hz, _vm.VariableSpeedList.Max(x => x.Hz)); |
| | | min_hz = Math.Min(min_hz, _vm.VariableSpeedList.Min(x => x.Hz)); |
| | | } |
| | | |
| | | max_hz = Math.Max(max_hz, _vm_list.Max(x => x.Hz)); |
| | | min_hz = Math.Min(min_hz, _vm_list.Min(x => x.Hz)); |
| | | |
| | | var qh = new Yw.Pump.CurveQH(qh50.FeatType, qh50.DefPointList); |
| | | var qe = new Yw.Pump.CurveQE(qe50.FeatType, qe50.DefPointList); |
| | | |
| | | foreach (var eff in eff_double_list) |
| | | { |
| | | var eff_list = EqualParaCurveEListHelper.CalcEqualParaCurveE(_model.CurveQH, _model.CurveQE, max_hz, min_hz, eff); |
| | | if (_vm_list.Exists(x => x.Eff == eff)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var eff_list = EqualParaCurveEListHelper.CalcEqualParaCurveE(qh, qe, max_hz, min_hz, eff); |
| | | if (eff_list != null && eff_list.Any()) |
| | | { |
| | | foreach (var item in eff_list) |
| | | { |
| | | var def_pt_list = item.DefinePoints; |
| | | var eff_vm = new Yw.WinFrmUI.Phart.PumpCurveEqualEffViewModel(); |
| | | eff_vm.Id = Guid.NewGuid().ToString(); |
| | | eff_vm.CurveName = $"{item.Eff:N1}"; |
| | | eff_vm.Color = Color.DarkGreen; |
| | | eff_vm.CurveEqualEff = item.DefinePoints; |
| | | eff_vm.Tension = item.Tension; |
| | | eff_vm.IsClosed = item.IsClosed; |
| | | _vm.EqualEffList.Add(eff_vm); |
| | | Insert(item.Eff, item.Tension, item.IsClosed, item.IsUShaped, item.DefinePoints); |
| | | } |
| | | } |
| | | } |
| | | |
| | | SetBindingData(_vm, _default_visible, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | |
| | | } |
| | | |
| | | private async void Insert(double hz, double speed, List<Yw.Geometry.Point2d> pt_qh_list, List<Yw.Geometry.Point2d> pt_qe_list, List<Yw.Geometry.Point2d> pt_qp_list) |
| | | { |
| | | var list = new List<Yw.Vmo.PhartGraphVmo>(); |
| | | var graph_qh = new Yw.Vmo.PhartGraphVmo() |
| | | { |
| | | Name = "扬程线", |
| | | GraphType = (int)Yw.Ahart.eCurveType.QH, |
| | | GraphParas = new QHGraphParasViewModel() |
| | | { |
| | | Hz = hz, |
| | | N = speed, |
| | | }.ToJson(), |
| | | GeometryParas = new Yw.WinFrmUI.Phart.CurveGeometryParasViewModel |
| | | { |
| | | DefinePoints = pt_qh_list |
| | | }.ToJson(), |
| | | GeometryStyle = (int)HStation.PhartRelation.eGeometryStyle.FeatCurve, |
| | | GeometryInfo = pt_qh_list.ToDbString(Yw.Ahart.eCurveType.QH, Yw.Ahart.eFeatType.Cubic), |
| | | AnnotationParas = new List<Yw.WinFrmUI.Phart.AnnotationParasViewModel>() |
| | | { |
| | | new () |
| | | { |
| | | X = pt_qh_list.Last().X, |
| | | Y = pt_qh_list.Last().Y, |
| | | Text = $"{speed}rpm({hz}hz)", |
| | | Aligment = eTextAligment.Right |
| | | } |
| | | }.ToJson() |
| | | }; |
| | | |
| | | list.Add(graph_qh); |
| | | if (pt_qe_list != null && pt_qe_list.Any()) |
| | | { |
| | | var graph_qe = new Yw.Vmo.PhartGraphVmo() |
| | | { |
| | | Name = "效率线", |
| | | GraphType = (int)Yw.Ahart.eCurveType.QE, |
| | | GraphParas = new QEGraphParasViewModel() |
| | | { |
| | | Hz = hz, |
| | | N = speed, |
| | | }.ToJson(), |
| | | GeometryParas = new Yw.WinFrmUI.Phart.CurveGeometryParasViewModel |
| | | { |
| | | DefinePoints = pt_qe_list |
| | | }.ToJson(), |
| | | GeometryStyle = (int)HStation.PhartRelation.eGeometryStyle.FeatCurve, |
| | | GeometryInfo = pt_qe_list.ToDbString(Yw.Ahart.eCurveType.QE, Yw.Ahart.eFeatType.Cubic), |
| | | AnnotationParas = new List<Yw.WinFrmUI.Phart.AnnotationParasViewModel>() |
| | | { |
| | | new () |
| | | { |
| | | X = pt_qe_list.Last().X, |
| | | Y = pt_qe_list.Last().Y, |
| | | Text = $"{speed}rpm({hz}hz)", |
| | | Aligment = eTextAligment.Right |
| | | } |
| | | }.ToJson() |
| | | }; |
| | | |
| | | list.Add(graph_qe); |
| | | } |
| | | |
| | | |
| | | if (pt_qp_list != null && pt_qp_list.Any()) |
| | | { |
| | | var graph_qp = new Yw.Vmo.PhartGraphVmo() |
| | | { |
| | | Name = "功率线", |
| | | GraphType = (int)Yw.Ahart.eCurveType.QP, |
| | | GraphParas = new QPGraphParasViewModel() |
| | | { |
| | | Hz = hz, |
| | | N = speed, |
| | | }.ToJson(), |
| | | GeometryParas = new Yw.WinFrmUI.Phart.CurveGeometryParasViewModel |
| | | { |
| | | DefinePoints = pt_qp_list |
| | | }.ToJson(), |
| | | GeometryStyle = (int)HStation.PhartRelation.eGeometryStyle.FeatCurve, |
| | | GeometryInfo = pt_qp_list.ToDbString(Yw.Ahart.eCurveType.QP, Yw.Ahart.eFeatType.Cubic), |
| | | AnnotationParas = new List<Yw.WinFrmUI.Phart.AnnotationParasViewModel>() |
| | | { |
| | | new () |
| | | { |
| | | X = pt_qp_list.Last().X, |
| | | Y = pt_qp_list.Last().Y, |
| | | Text = $"{speed}rpm({hz}hz)", |
| | | Aligment = eTextAligment.Right |
| | | } |
| | | }.ToJson() |
| | | }; |
| | | |
| | | list.Add(graph_qp); |
| | | } |
| | | |
| | | |
| | | list.ForEach(x => x.DiagramID = _vmo.ID); |
| | | var bol = await new Yw.BLL.PhartGraph().Inserts(list); |
| | | if (!bol) |
| | | { |
| | | TipFormHelper.ShowWarn("添加失败!"); |
| | | return; |
| | | } |
| | | |
| | | var newVmo = await new Yw.BLL.PhartDiagramExtensions().GetByID(_vmo.ID); |
| | | if (newVmo == null) |
| | | { |
| | | TipFormHelper.ShowWarn("获取失败!"); |
| | | return; |
| | | } |
| | | |
| | | SetBindingData(newVmo, _nr); |
| | | SetEquip(); |
| | | } |
| | | |
| | | private async void Insert(double eff, double tension, bool is_closed, bool is_u, List<Yw.Geometry.Point2d> pt_equal_e_list) |
| | | { |
| | | if (tension <= 0) |
| | | { |
| | | tension = 0.5; |
| | | } |
| | | var list = new List<Yw.Vmo.PhartGraphVmo>(); |
| | | var graph_equal_e = new Yw.Vmo.PhartGraphVmo() |
| | | { |
| | | Name = "扬程线", |
| | | GraphType = (int)Yw.Ahart.eCurveType.EqualE, |
| | | GraphParas = new EqualEGraphParasViewModel() |
| | | { |
| | | Eff = eff, |
| | | Tension = tension, |
| | | IsClosed = is_closed, |
| | | }.ToJson(), |
| | | GeometryParas = new Yw.WinFrmUI.Phart.CurveGeometryParasViewModel |
| | | { |
| | | DefinePoints = pt_equal_e_list |
| | | }.ToJson(), |
| | | GeometryStyle = (int)HStation.PhartRelation.eGeometryStyle.FeatCurve, |
| | | GeometryInfo = pt_equal_e_list.ToDbString(Yw.Ahart.eCurveType.EqualE, Yw.Ahart.eFeatType.Cubic), |
| | | |
| | | }; |
| | | |
| | | var annotation_list = new List<Yw.WinFrmUI.Phart.AnnotationParasViewModel>(); |
| | | annotation_list.Add(new() |
| | | { |
| | | X = pt_equal_e_list.Last().X, |
| | | Y = pt_equal_e_list.Last().Y, |
| | | Text = $"{eff}%", |
| | | Aligment = eTextAligment.Right |
| | | }); |
| | | if (is_u) |
| | | { |
| | | var first = pt_equal_e_list.First(); |
| | | annotation_list.Add(new() |
| | | { |
| | | X = first.X, |
| | | Y = first.Y, |
| | | Text = $"{eff}%", |
| | | Aligment = eTextAligment.Right |
| | | }); |
| | | } |
| | | graph_equal_e.AnnotationParas = annotation_list.ToJson(); |
| | | list.Add(graph_equal_e); |
| | | list.ForEach(x => x.DiagramID = _vmo.ID); |
| | | var bol = await new Yw.BLL.PhartGraph().Inserts(list); |
| | | if (!bol) |
| | | { |
| | | TipFormHelper.ShowWarn("添加失败!"); |
| | | return; |
| | | } |
| | | |
| | | var newVmo = await new Yw.BLL.PhartDiagramExtensions().GetByID(_vmo.ID); |
| | | if (newVmo == null) |
| | | { |
| | | TipFormHelper.ShowWarn("获取失败!"); |
| | | return; |
| | | } |
| | | |
| | | SetBindingData(newVmo, _nr); |
| | | SetEquip(); |
| | | } |
| | | |
| | | private async void Delete(List<(long Id, double Basis)> graph_ids) |
| | | { |
| | | if (graph_ids == null || !graph_ids.Any()) |
| | | { |
| | | return; |
| | | } |
| | | var bll = new Yw.BLL.PhartGraph(); |
| | | var err_hz_list = new List<double>(); |
| | | foreach (var graph_info in graph_ids) |
| | | { |
| | | var bol = await bll.DeleteByID(graph_info.Id); |
| | | if (!bol) |
| | | { |
| | | err_hz_list.Add(graph_info.Basis); |
| | | return; |
| | | } |
| | | } |
| | | if (err_hz_list != null && err_hz_list.Any()) |
| | | { |
| | | var info = Yw.Untity.DoubleListHelper.ToString(err_hz_list); |
| | | TipFormHelper.ShowError($"{info}删除失败!"); |
| | | } |
| | | |
| | | var newVmo = await new Yw.BLL.PhartDiagramExtensions().GetByID(_vmo.ID); |
| | | if (newVmo == null) |
| | | { |
| | | TipFormHelper.ShowWarn("获取失败!"); |
| | | return; |
| | | } |
| | | |
| | | SetBindingData(newVmo, _nr); |
| | | SetEquip(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | return new Yw.Vmo.PhartDiagramExGraphListVmo(); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |