| | |
| | | using System.Data; |
| | | using Yw.Geometry; |
| | | using Yw.WinFrmUI.Phart; |
| | | |
| | | namespace HStation.WinFrmUI.PhartRelation |
| | | { |
| | |
| | | public PumpParallelAnalyDlg() |
| | | { |
| | | InitializeComponent(); |
| | | this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon; |
| | | this.pumpSerialParallelChart.LineVisible = true; |
| | | this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon; |
| | | this.pumpSerialParallelChart.SetQeVisible(false); |
| | | this.pumpParallelInfoCtrl1.SetEvent += (id, qh, qe, qp) => |
| | | { |
| | | var list = this.pumpParallelInfoCtrl1.GetRunList(); |
| | |
| | | }; |
| | | this.pumpParallelInfoCtrl1.SetInfoEvent += (id, name, color) => |
| | | { |
| | | this.pumpSerialParallelChart.SetInfo(id, name, color); |
| | | this.pumpSerialParallelChart.Set(id, name, color); |
| | | }; |
| | | |
| | | this.pumpParallelInfoCtrl1.SetDesignPointEvent += (q, h) => |
| | | { |
| | | this.pumpSerialParallelChart.SetDesignPt(new Point2d(q, h)); |
| | | this.pumpSerialParallelChart.SetDesignPoint(new Point2d(q, h)); |
| | | }; |
| | | |
| | | this.pumpParallelInfoCtrl1.AddEvent += (vm) => |
| | |
| | | SetParallel(list); |
| | | }; |
| | | |
| | | this.pumpSerialParallelChart.OnCalcQueryPoint += (id, pt) => |
| | | this.pumpSerialParallelChart.QueryPointChangedEvent += (id, pt) => |
| | | { |
| | | this.pumpParallelInfoCtrl1.SetQueryInfo(id, pt); |
| | | }; |
| | |
| | | var list = this.pumpParallelInfoCtrl1.GetRunList(); |
| | | SetParallel(list); |
| | | }; |
| | | |
| | | this.pumpParallelInfoCtrl1.SaveEvent += () => |
| | | { |
| | | var run_list = this.pumpParallelInfoCtrl1.GetRunList(); |
| | |
| | | |
| | | private string _parallel_id = "parallel"; |
| | | public event Func<List<XhsSingleResultViewModel>, bool> ReloadDataEvent; |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 设置 |
| | |
| | | vm.Name = x.Name; |
| | | vm.Code = x.Code; |
| | | vm.IsBp = x.IsBp; |
| | | vm.RatedSpeed = x.RatedSpeed; |
| | | vm.CurrentSpeed = x.CurrentSpeed; |
| | | vm.RatedN = x.RatedSpeed; |
| | | vm.CurrentN = x.CurrentSpeed; |
| | | vm.RunStatus = x.RunStatus; |
| | | vm.CurrentHz = x.CurrentHz; |
| | | var qh_pt_list = x.CurveQH.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList(); |
| | | vm.Qh = new CubicSpline2d(qh_pt_list); |
| | | vm.CurveQH = new CubicSpline2d(qh_pt_list); |
| | | if (x.CurveQE != null && x.CurveQE.Any()) |
| | | { |
| | | var qe_pt_list = x.CurveQE.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList(); |
| | | vm.Qe = new CubicSpline2d(qe_pt_list); |
| | | vm.CurveQE = new CubicSpline2d(qe_pt_list); |
| | | } |
| | | if (x.CurveQP != null && x.CurveQP.Any()) |
| | | { |
| | | var qp_pt_list = x.CurveQP.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList(); |
| | | vm.Qp = new CubicSpline2d(qp_pt_list); |
| | | vm.CurveQP = new CubicSpline2d(qp_pt_list); |
| | | } |
| | | |
| | | vm.CalcuQ = x.CalcuQ; |
| | | vm.CalcuH = x.CalcuH; |
| | | vm.Color = GetRandomColor(i); |
| | | vm.Calc(); |
| | | vm_list.Add(vm); |
| | | |
| | | if (!x.RunStatus) |
| | | continue; |
| | | |
| | | if (!x.CalcuQ.HasValue || !x.CalcuH.HasValue) |
| | | continue; |
| | | var calc_flow = x.CalcuQ.Value; |
| | | var calc_head = x.CalcuH.Value; |
| | | |
| | | var max_flow = vm.CurveQH.MaxX; |
| | | var max_flow_head = vm.CurveQH.GetPointY(max_flow); |
| | | |
| | | var min_flow = vm.CurveQH.MinX; |
| | | var min_flow_head = vm.CurveQH.GetPointY(min_flow); |
| | | |
| | | if (max_flow_head < calc_head && min_flow_head > calc_head) |
| | | continue; |
| | | |
| | | var extend_ratio = 1m; |
| | | var extend_success = false; |
| | | for (decimal num = 0.01m; num <= 5; num += 0.01m) |
| | | { |
| | | extend_ratio += num; |
| | | var ex_pt_list = qh_pt_list.GetExpandFitPointList((double)extend_ratio); |
| | | var ex_x_array = ex_pt_list.GetInterPointsX(calc_head); |
| | | if (ex_x_array != null && ex_x_array.Any()) |
| | | { |
| | | extend_success = true; |
| | | vm.ExtendRatio = Math.Round((double)extend_ratio * 100, 1); |
| | | vm.Calc(); |
| | | break; |
| | | } |
| | | } |
| | | if (!extend_success) |
| | | { |
| | | |
| | | } |
| | | } |
| | | |
| | | this.pumpParallelInfoCtrl1.SetBindingData(vm_list, null); |
| | | var run_list = this.pumpParallelInfoCtrl1.GetRunList(); |
| | | var msg = SetParallel(run_list); |
| | |
| | | private string SetParallel(List<Yw.WinFrmUI.Phart.PumpSerialParallelInfoViewModel> list) |
| | | { |
| | | var msg = "并联成功"; |
| | | this.pumpSerialParallelChart.Delete(); |
| | | this.pumpSerialParallelChart.Clear(); |
| | | if (list == null || !list.Any()) |
| | | { |
| | | msg = "无数据"; |
| | |
| | | Set(list); |
| | | this.barInfo.Caption = $"<b><color=red>{msg}</color></b>"; |
| | | return msg; |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | line_name = "并联曲线"; |
| | | calc_bol = helper.CalculateParallel(out calc_pt_qh_list, out calc_pt_qe_list, out calc_pt_qp_list); |
| | | |
| | | if (!calc_bol || calc_pt_qh_list.Count < 3) |
| | | if (!calc_bol || calc_pt_qh_list.Count < 4) |
| | | { |
| | | return default; |
| | | } |
| | | double total_flow = list.Sum(x => x.CalcuQ ?? 0); |
| | | double total_head = list.Average(x => x.CalcuH ?? 0); |
| | | |
| | | var qh = new Yw.Geometry.CubicSpline2d(calc_pt_qh_list); |
| | | var qe = new Yw.Geometry.CubicSpline2d(calc_pt_qe_list); |
| | | var qp = new Yw.Geometry.CubicSpline2d(calc_pt_qp_list); |
| | | |
| | | |
| | | var vm_sp = new Yw.WinFrmUI.Phart.PumpSerialParallelInfoViewModel(); |
| | | vm_sp.Id = _parallel_id; |
| | | vm_sp.Name = line_name; |
| | | vm_sp.Qh = new Yw.Geometry.CubicSpline2d(calc_pt_qh_list); |
| | | vm_sp.Qe = new Yw.Geometry.CubicSpline2d(calc_pt_qe_list); |
| | | vm_sp.Qp = new Yw.Geometry.CubicSpline2d(calc_pt_qp_list); |
| | | vm_sp.QhCalc = vm_sp.Qh; |
| | | vm_sp.QeCalc = vm_sp.Qe; |
| | | vm_sp.QpCalc = vm_sp.Qp; |
| | | vm_sp.CurveQH = qh; |
| | | vm_sp.CurveQE = qe; |
| | | vm_sp.CurveQP = qp; |
| | | |
| | | vm_sp.QhCalc = qh; |
| | | vm_sp.QeCalc = qe; |
| | | vm_sp.QpCalc = qp; |
| | | |
| | | vm_sp.CalcuH = total_head; |
| | | vm_sp.CalcuQ = total_flow; |
| | | |
| | | |
| | | vm_sp.Color = Color.Black; |
| | | vm_sp.IsBp = true; |
| | | vm_sp.IsDefault = true; |
| | | |
| | | var pt_list = vm_sp.Qp.GetPointList(12); |
| | | return vm_sp; |
| | | |
| | | } |