using Yw.Geometry;
|
|
namespace HStation.WinFrmUI.PhartRelation
|
{
|
public partial class PumpPerform2dMultiViewDlg : XtraForm
|
{
|
public PumpPerform2dMultiViewDlg()
|
{
|
InitializeComponent();
|
}
|
|
|
|
public string SetBindingData(List<Perform2dMultiViewModel> list, PerformPoint2dViewModel design_pt, bool only_line, bool is_parallel = true)
|
{
|
if (list == null || !list.Any())
|
{
|
return "数据为空!";
|
}
|
var vm_list = new List<Yw.WinFrmUI.Phart.PumpSerialParallelViewModel>();
|
var helper = new Yw.WinFrmUI.Phart.PumpParallelConnectionHelper();
|
foreach (var item in list)
|
{
|
var id = item.Id;
|
var name = item.Name;
|
var hz = item.SpeedRatio * 50;
|
var point_list_qh = item.PointsQH;
|
var point_list_qe = item.PointsQE;
|
var point_list_qp = item.PointsQP;
|
|
if (point_list_qh == null)
|
{
|
continue;
|
}
|
|
List<Yw.Geometry.Point2d> pt_qh_list = null, pt_qe_list = null, pt_qp_list = null;
|
pt_qh_list = point_list_qh?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
|
pt_qe_list = point_list_qe?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
|
pt_qp_list = point_list_qp?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
|
|
|
Yw.Geometry.CubicSpline2d cubic_spline_qh = null, cubic_spline_qe = null, cubic_spline_qp = null;
|
cubic_spline_qh = new Yw.Geometry.CubicSpline2d(pt_qh_list);
|
if (pt_qe_list != null)
|
cubic_spline_qe = new Yw.Geometry.CubicSpline2d(pt_qe_list);
|
if (pt_qp_list != null)
|
cubic_spline_qp = new Yw.Geometry.CubicSpline2d(pt_qp_list);
|
|
cubic_spline_qh = Yw.WinFrmUI.Phart.PumpCalcHelper.CalculateSimilarQH(cubic_spline_qh, 50, hz);
|
cubic_spline_qe = Yw.WinFrmUI.Phart.PumpCalcHelper.CalculateSimilarQE(cubic_spline_qe, 50, hz);
|
cubic_spline_qp = Yw.WinFrmUI.Phart.PumpCalcHelper.CalculateSimilarQP(cubic_spline_qp, 50, hz);
|
|
if (!only_line)
|
{
|
var color = ColorHelper.GetRandomColor();
|
var vm = new Yw.WinFrmUI.Phart.PumpSerialParallelViewModel();
|
vm.Id = id;
|
vm.Name = name;
|
vm.Qh = cubic_spline_qh;
|
vm.Qe = cubic_spline_qe;
|
vm.Qp = cubic_spline_qp;
|
vm_list.Add(vm);
|
}
|
|
helper.Add(cubic_spline_qh, cubic_spline_qp);
|
}
|
|
var calc_bol = false;
|
var line_name = "";
|
List<Yw.Geometry.Point2d> calc_pt_qh_list;
|
List<Yw.Geometry.Point2d> calc_pt_qe_list;
|
List<Yw.Geometry.Point2d> calc_pt_qp_list;
|
if (is_parallel)
|
{
|
line_name = "并联曲线";
|
calc_bol = helper.CalculateParallel(out calc_pt_qh_list, out calc_pt_qe_list, out calc_pt_qp_list);
|
}
|
else
|
{
|
line_name = "串联曲线";
|
calc_bol = helper.CalculateSeries(out calc_pt_qh_list, out calc_pt_qe_list, out calc_pt_qp_list);
|
}
|
|
if (!calc_bol)
|
{
|
return "无法计算串并联曲线!";
|
}
|
var min_q = calc_pt_qh_list.Min(x => x.X);
|
var max_q = calc_pt_qh_list.Max(x => x.X);
|
|
var min_h = calc_pt_qh_list.Min(x => x.Y);
|
var max_h = calc_pt_qh_list.Max(x => x.Y);
|
if (design_pt != null)
|
{
|
if (design_pt.X > max_q || design_pt.X < min_q)
|
{
|
return "设计流量无效!";
|
}
|
|
if (design_pt.Y > max_h || design_pt.Y < min_h)
|
{
|
return "设计扬程无效!";
|
}
|
}
|
else
|
{
|
var design_q = calc_pt_qh_list.Max(x => x.X) / 2;
|
var design_h = calc_pt_qh_list.GetInterPointsY(design_q).Last();
|
design_pt = new PerformPoint2dViewModel(design_q, design_h);
|
}
|
|
|
var vm_sp = new Yw.WinFrmUI.Phart.PumpSerialParallelInfoViewModel();
|
vm_sp.Id = "-1";
|
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.IsBp = true;
|
vm_list.Add(vm_sp);
|
this.xtrPerform2dMultiChart1.Add(vm_sp, new Yw.Geometry.Point2d(design_pt.X, design_pt.Y));
|
|
return string.Empty;
|
}
|
|
|
|
}
|
}
|