| | |
| | | using DevExpress.Spreadsheet; |
| | | using Mapster; |
| | | using StackExchange.Profiling.Internal; |
| | | using Yw.Ahart; |
| | | using Yw.Geometry; |
| | |
| | | |
| | | namespace HStation.WinFrmUI |
| | | { |
| | | /// <summary> |
| | | /// 待整理 抽象到底层 |
| | | /// </summary> |
| | | public partial class PumpChartViewCtrl : DevExpress.XtraEditors.XtraUserControl |
| | | { |
| | | public PumpChartViewCtrl() |
| | | { |
| | | InitializeComponent(); |
| | | this.barCekEqVisible.Checked = true; |
| | | this.barCekEqulEffVisible.Checked = true; |
| | | this.barCekPowerVisible.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; |
| | | this.barCekEqVisible.Checked = true; |
| | | this.barCekEqVisible.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; |
| | | |
| | | this.barBtnAddVariableSpeedMenu.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; |
| | | this.barBtnAddEqualEffMenu.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; |
| | | this.barCekEqulEffVisible.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; |
| | | this.pumpViewChart1.AnnotationChangedEvent += PumpViewChart1_AnnotationChangedEvent; |
| | | } |
| | | |
| | | |
| | | |
| | | private Yw.Vmo.PhartDiagramExGraphListVmo _vmo = null; |
| | | private List<Yw.WinFrmUI.Phart.PumpViewChartViewModel> _vm_list = null; |
| | |
| | | private bool _eff_visible = true; |
| | | private bool _equal_eff_visible = true; |
| | | private bool _split_panel = true; |
| | | private double _nr; |
| | | private double _nr; |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | |
| | | ClearBindingData(); |
| | | return; |
| | | } |
| | | _coordinate = vmo.DispParas; |
| | | |
| | | _coordinate = vmo.DispParas; |
| | | foreach (var graph in vmo.GraphList) |
| | | { |
| | | 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 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 annotation_list = PhartGraphHelper.GetAnnotationParasList(curve_type, graph.AnnotationParas); |
| | | if (curve_type == eCurveType.QE) |
| | | annotation_list = null; |
| | | var vm = new Yw.WinFrmUI.Phart.PumpViewChartViewModel(); |
| | | 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) |
| | | if (vm.CurveType == eCurveType.EqualE) |
| | | vm.FitPointList = feat_curve.FeatCurve.GetPointList(10); |
| | | |
| | | vm.IsDefault = is_default; |
| | | vm.GraphParas = graph.GraphParas; |
| | | vm_list.Add(vm); |
| | | } |
| | | |
| | | |
| | | _vm_list = vm_list; |
| | | _vm_list[0].IsSelect = true; |
| | | |
| | | var list = _vm_list.Select(x => x.Hz).OrderByDescending(x => x).ToList(); |
| | | list = list.Distinct().ToList(); |
| | | |
| | | this.repImgCmbCurveSel.BeginInit(); |
| | | this.repImgCmbCurveSel.Items.Clear(); |
| | | this.repImgCmbCurveSel.Items.Add($"无", null, -1); |
| | | foreach (var hz in list) |
| | | { |
| | | this.repImgCmbCurveSel.Items.Add($"{hz}hz", hz, -1); |
| | | } |
| | | this.repImgCmbCurveSel.EndInit(); |
| | | this.barImgCmbChartSel.EditValue = null; |
| | | |
| | | |
| | | SetColor(_vm_list); |
| | | SetBindingData(_vm_list, _coordinate, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | SetBindingData(_vm_list, _coordinate, _split_panel, _eff_visible, _power_visible, _equal_eff_visible); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// |
| | |
| | | vm.Color = Color.DarkGreen; |
| | | } |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | var item = group.ElementAt(0); |
| | | foreach (var vm in item) |
| | | { |
| | |
| | | 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; |
| | | case Yw.Ahart.eCurveType.EqualE: vm.Color = Color.DarkGreen; break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | |
| | | { |
| | | 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; |
| | |
| | | { |
| | | this.pumpViewChart1.Clear(); |
| | | } |
| | | |
| | | |
| | | private void SetEquip() |
| | | { |
| | |
| | | this.pumpViewChart1.SetEquip(equip_pt_list, pump_sect_pt); |
| | | } |
| | | |
| | | private void PumpViewChart1_AnnotationChangedEvent((long DbId, string Tag, double X, double Y) info) |
| | | { |
| | | |
| | | Update(info); |
| | | } |
| | | |
| | | private void barImgCmbChartSel_EditValueChanged(object sender, EventArgs e) |
| | | { |
| | | if (this.barImgCmbChartSel.EditValue==null) |
| | | { |
| | | this.pumpViewChart1.LineVisible = false; |
| | | 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); |
| | | this.pumpViewChart1.SetAxisXValue(); |
| | | this.pumpViewChart1.LineVisible = true; |
| | | } |
| | | 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_list,_coordinate, _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_list,_coordinate, _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_list,_coordinate, _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 |
| | | { |
| | | this.pumpViewChart1.SetEquip(null,null); |
| | | this.pumpViewChart1.SetEquip(null, null); |
| | | } |
| | | } |
| | | |
| | | private void barCekEqulEffVisible_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | _equal_eff_visible = this.barCekEqulEffVisible.Checked; |
| | | SetBindingData(_vm_list,_coordinate, _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; |
| | | |
| | | this.pumpViewChart1.SetEquip(null, null); |
| | | } |
| | | |
| | |
| | | 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 (IsInvalidData()) |
| | |
| | | TipFormHelper.ShowWarn("转速已存在"); |
| | | return false; |
| | | } |
| | | hz = Math.Round(hz, 1); |
| | | hz = Math.Round(hz, 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); |
| | | Insert(hz, speed, pt_qh_list, pt_qe_list, pt_qp_list); |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | |
| | | } |
| | | var speed = Math.Round(hz / 50 * _nr); |
| | | 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); |
| | | var pt_qp_list = qp50?.FitPointList?.GetQPPointListByN(50, hz); |
| | | |
| | | Insert(hz, speed, pt_qh_list, pt_qe_list, pt_qp_list); |
| | | Insert(hz, speed, pt_qh_list, pt_qe_list, pt_qp_list); |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | |
| | | dlg.VerifyValueChanged += (x, y) => |
| | | { |
| | | var pt = new Yw.Geometry.Point2d(x, y); |
| | | var curve = new Yw.Pump. CurveQH(qh50.FeatType, qh50.DefPointList); |
| | | 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; |
| | |
| | | |
| | | foreach (var eff in eff_double_list) |
| | | { |
| | | 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) |
| | | { |
| | | Insert(item.Eff,item.Tension,item.IsClosed,item.IsUShaped,item.DefinePoints); |
| | | { |
| | | Insert(item.Eff, item.Tension, item.IsClosed, item.IsUShaped, item.DefinePoints); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | 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() |
| | | { |
| | |
| | | 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) |
| | | { |
| | |
| | | SetEquip(); |
| | | } |
| | | |
| | | private async void Insert(double eff, double tension, bool is_closed,bool is_u, List<Yw.Geometry.Point2d> pt_equal_e_list) |
| | | 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) |
| | | if (tension <= 0) |
| | | { |
| | | tension = 0.5; |
| | | } |
| | |
| | | }.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>(); |
| | |
| | | SetEquip(); |
| | | } |
| | | |
| | | private async void Update((long DbId, string Tag, double X, double Y) info) |
| | | { |
| | | |
| | | var bll = new Yw.BLL.PhartGraph(); |
| | | |
| | | var vm = _vm_list.Find(x => x.DbId == info.DbId); |
| | | if (vm == null) |
| | | return; |
| | | var annotation = vm.AnnotationList.Find(x => x.Tag == info.Tag); |
| | | if (annotation == null) |
| | | return; |
| | | annotation.X = info.X; |
| | | annotation.Y = info.Y; |
| | | var paras = vm.AnnotationList.ToJson(); |
| | | var bol = await bll.UpdateAnnotationParas(info.DbId, paras); |
| | | if (!bol) |
| | | { |
| | | TipFormHelper.ShowError($"{annotation.Text}更新失败!"); |
| | | 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); |
| | | continue; |
| | | } |
| | | } |
| | | 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> |
| | | /// 获取 |
| | | /// </summary> |
| | |
| | | return new Yw.Vmo.PhartDiagramExGraphListVmo(); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |