| | |
| | | using HStation.WinFrmUI.PhartRelation; |
| | | using SqlSugar; |
| | | using Yw.WinFrmUI.Phart; |
| | | |
| | | namespace HStation.WinFrmUI.Xhs |
| | | { |
| | |
| | | InitChart(); |
| | | } |
| | | |
| | | #region Init |
| | | |
| | | private void InitChart() |
| | | { |
| | | this.pumpVariableSpeedChart1.LineVisible = true; |
| | | this.pumpVariableSpeedChart1.LineNameShowHz = true; |
| | | this.singlePumpAnalyInfoCtrl1.SetEvent += (id, hz, ex_ratio, qh, qe, qp) => |
| | | { |
| | | this.pumpVariableSpeedChart1.Set(id, hz, ex_ratio, qh, qe, qp); |
| | |
| | | ResetSectPointGrid(); |
| | | }; |
| | | |
| | | |
| | | this.singlePumpAnalyInfoCtrl1.SetDesignPointEvent += (q, h) => |
| | | { |
| | | this.pumpVariableSpeedChart1.SetDesignPt(q,h); |
| | | { |
| | | this.pumpVariableSpeedChart1.SetDesignPt(q, h); |
| | | ResetSectPointGrid(); |
| | | }; |
| | | |
| | |
| | | { |
| | | this.singlePumpAnalyInfoCtrl1.SetQueryInfo(id, pt); |
| | | }; |
| | | void ResetSectPointGrid() |
| | | |
| | | this.pumpVariableSpeedChart1.AddBySpeedEvent += () => |
| | | { |
| | | var vm_list = this.pumpVariableSpeedChart1.GetList(); |
| | | ///this.singlePumpAnalyInfoCtrl1.SetSectPoint(vm_list); |
| | | } |
| | | AddBySpeed(); |
| | | ResetSectPointGrid(); |
| | | }; |
| | | |
| | | this.pumpVariableSpeedChart1.AddByHzEvent += () => |
| | | { |
| | | AddByHz(); |
| | | ResetSectPointGrid(); |
| | | }; |
| | | |
| | | this.pumpVariableSpeedChart1.AddByPointEvent += () => |
| | | { |
| | | AddByPoint(); |
| | | ResetSectPointGrid(); |
| | | }; |
| | | } |
| | | |
| | | private void ResetSectPointGrid() |
| | | { |
| | | var vm_list = this.pumpVariableSpeedChart1.GetSectPointList(); |
| | | this.singlePumpAnalyInfoCtrl1.SetSectPointList(vm_list); |
| | | } |
| | | |
| | | private void AddBySpeed() |
| | | { |
| | | var list = this.singlePumpAnalyInfoCtrl1.GetList(); |
| | | if (list == null || list.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | 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 SinglePumpAnalyViewModel(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.IsDefault = false; |
| | | vm.Calc(); |
| | | |
| | | this.singlePumpAnalyInfoCtrl1.Add(vm); |
| | | this.pumpVariableSpeedChart1.Add(vm.ToInfo()); |
| | | |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | private void AddByHz() |
| | | { |
| | | var list = this.singlePumpAnalyInfoCtrl1.GetList(); |
| | | if (list == null || list.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | 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 SinglePumpAnalyViewModel(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.IsDefault = false; |
| | | vm.Calc(); |
| | | |
| | | this.singlePumpAnalyInfoCtrl1.Add(vm); |
| | | this.pumpVariableSpeedChart1.Add(vm.ToInfo()); |
| | | |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | private void AddByPoint() |
| | | { |
| | | var list = this.singlePumpAnalyInfoCtrl1.GetList(); |
| | | if (list == null || list.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | var index = list.Count; |
| | | var vm_def = list.First(); |
| | | 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 SinglePumpAnalyViewModel(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.IsDefault = false; |
| | | vm.Calc(); |
| | | |
| | | this.singlePumpAnalyInfoCtrl1.Add(vm); |
| | | this.pumpVariableSpeedChart1.Add(vm.ToInfo()); |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | private Color GetRandomColor(int count) |
| | | { |
| | | var color_list = new List<Color>() |
| | | { |
| | | Color.Red, Color.Blue, Color.Green,Color.DodgerBlue, |
| | | Color.Fuchsia, Color.MidnightBlue, Color.Maroon, Color.Aquamarine, |
| | | Color.Bisque,Color.BurlyWood |
| | | }; |
| | | |
| | | if (count < color_list.Count) |
| | | { |
| | | return color_list[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 |
| | | |
| | | public void SetBindindData(PumpMatchingViewModel pump_matching) |
| | | { |
| | | InitChartData(pump_matching); |
| | | SetChart(pump_matching); |
| | | } |
| | | |
| | | private SinglePumpAnalyViewModel _working_vm = null; |
| | | private async void InitChartData(PumpMatchingViewModel pump_matching) |
| | | private async void SetChart(PumpMatchingViewModel pump_matching) |
| | | { |
| | | if (!long.TryParse(pump_matching.DbId, out long pump_main_id)) |
| | | { |
| | |
| | | var qe = new Yw.Geometry.CubicSpline2d(points_qe); |
| | | var qp = new Yw.Geometry.CubicSpline2d(points_qp); |
| | | |
| | | |
| | | |
| | | |
| | | var def_vm = new SinglePumpAnalyViewModel(); |
| | | def_vm.Id = "def"; |
| | | def_vm.Name = "50"; |
| | |
| | | def_vm.Qe = qe; |
| | | def_vm.Qp = qp; |
| | | def_vm.Calc(); |
| | | //_def_vm.QhCalc = qh; |
| | | //_def_vm.QeCalc = qe; |
| | | //_def_vm.QpCalc = qp; |
| | | |
| | | //_def_vm.SectQ = string.Empty; |
| | | //_def_vm.SectH = string.Empty; |
| | | //_def_vm.SectE = string.Empty; |
| | | //_def_vm.SectP = string.Empty; |
| | | var working_vm = new SinglePumpAnalyViewModel(); |
| | | working_vm.Id = "working"; |
| | | working_vm.Name = pump_matching.CurrentHz.ToString(); |
| | | working_vm.RatedSpeed = pump_main.RatedSpeed; |
| | | working_vm.CurrentSpeed = Math.Round(pump_matching.CurrentHz / 50 * pump_main.RatedSpeed, 1); |
| | | working_vm.CurrentHz = pump_matching.CurrentHz; |
| | | working_vm.IsDefault = false; |
| | | working_vm.Color = Color.Red; |
| | | working_vm.ExtendRatio = 100; |
| | | working_vm.Qh = qh; |
| | | working_vm.Qe = qe; |
| | | working_vm.Qp = qp; |
| | | working_vm.Calc(); |
| | | |
| | | //_def_vm.QueryQ = string.Empty; |
| | | //_def_vm.QueryH = string.Empty; |
| | | //_def_vm.QueryE = string.Empty; |
| | | //_def_vm.QueryP = string.Empty; |
| | | |
| | | _working_vm = new SinglePumpAnalyViewModel(); |
| | | _working_vm.Id = "working"; |
| | | _working_vm.Name = pump_matching.CurrentHz.ToString(); |
| | | _working_vm.RatedSpeed = pump_main.RatedSpeed; |
| | | _working_vm.CurrentSpeed = Math.Round(pump_matching.CurrentHz / 50 * pump_main.RatedSpeed, 1); |
| | | _working_vm.CurrentHz = pump_matching.CurrentHz; |
| | | _working_vm.IsDefault = false; |
| | | _working_vm.Color = Color.Red; |
| | | _working_vm.ExtendRatio = 100; |
| | | _working_vm.Qh = qh; |
| | | _working_vm.Qe = qe; |
| | | _working_vm.Qp = qp; |
| | | _working_vm.Calc(); |
| | | var calcQ = pump_matching.CalcuQ; |
| | | var calcH = pump_matching.CalcuH; |
| | | |
| | | |
| | | var list = new List<SinglePumpAnalyViewModel>() { def_vm, _working_vm }; |
| | | var list = new List<SinglePumpAnalyViewModel>() { def_vm, working_vm }; |
| | | var list_yw = list.Select(x => x.ToInfo()).ToList(); |
| | | |
| | | this.singlePumpAnalyInfoCtrl1.SetBindingData(list); |
| | | this.pumpVariableSpeedChart1.Add(list_yw); |
| | | |
| | | if (calcQ.HasValue && calcH.HasValue) |
| | | { |
| | | var flow = Math.Round(calcQ.Value, 1); |
| | | var head = Math.Round(calcH.Value, 1); |
| | | |
| | | this.singlePumpAnalyInfoCtrl1.SetDesignPoint(flow, head); |
| | | this.pumpVariableSpeedChart1.SetDesignPt(flow, head); |
| | | ResetSectPointGrid(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | } |