using DevExpress.XtraEditors;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Windows.Forms;
|
|
|
namespace IStation.WinFrmUI.Import
|
{
|
public partial class DrawLxpCurveOnePtCtrl : DocumentPage
|
{
|
|
//构造函数
|
public DrawLxpCurveOnePtCtrl()
|
{
|
InitializeComponent();
|
this.comboBoxType.SelectedIndex = 0;
|
this.txtQ.Focus();
|
this.txtQ.SelectAll();
|
}
|
|
double _ratedn = -1;
|
Eventech.Model.RatedParas _ratedParas = null;
|
List<Eventech.Model.FeatPoint> pointInfoQH = null;
|
List<Eventech.Model.FeatPoint> pointInfoQE = null;
|
List<Eventech.Model.FeatPoint> pointInfoQP = null;
|
List<Eventech.Model.FeatPoint> pointInfoNPSH = null;
|
Model.FeatCurveExpressGroup _featCurveExpressGroup = null;
|
|
/// <summary>
|
///
|
/// </summary>
|
public event Action OnCreateLxpCurve = null;
|
|
|
//计算转速比
|
private void CalcNs()
|
{
|
if (string.IsNullOrEmpty(this.txtQ.Text) ||
|
string.IsNullOrEmpty(this.txtH.Text) ||
|
string.IsNullOrEmpty(this.txtN.Text))
|
return;
|
|
var YLJS = Convert.ToInt32(this.spinEditYLJS.Text);
|
var Q = Convert.ToDouble(this.txtQ.Text);
|
var H = Convert.ToDouble(this.txtH.Text);
|
var N = Convert.ToDouble(this.txtN.Text);
|
|
double ns = 0;
|
if (this.checkEditSXB.Checked)
|
{
|
ns = Eventech.Common.PumpParaHelper.CalculateNs(Q / 2, H / YLJS, N);
|
}
|
else
|
{
|
ns = Eventech.Common.PumpParaHelper.CalculateNs(Q, H / YLJS, N);
|
}
|
|
this.txtNS.EditValue = Math.Round(ns, 2);
|
}
|
|
//产生曲线
|
private void CreateCurveCore()
|
{
|
_featCurveExpressGroup = null;
|
double? k0 = 0;
|
if (double.TryParse(this.txtK0.Text, out double value))
|
{
|
k0 = Convert.ToDouble(txtK0.Text);
|
if (k0 < 1.001)
|
{
|
XtraMessageBox.Show("关死点系数不能小于1");
|
return;
|
}
|
}
|
|
if (string.IsNullOrEmpty(this.txtQ.Text) || string.IsNullOrEmpty(this.txtH.Text))
|
{
|
MessageBox.Show("流量扬程不能为空");
|
return;
|
}
|
if (string.IsNullOrEmpty(this.txtN.Text))
|
{
|
MessageBox.Show("转速不能为空");
|
return;
|
}
|
|
_ratedn = double.Parse(this.txtN.Text);
|
if (_ratedn < 10)
|
{
|
MessageBox.Show("转速有这么小吗?");
|
return;
|
}
|
|
_ratedParas = new Eventech.Model.RatedParas();
|
_ratedParas.Q = double.Parse(this.txtQ.Text);
|
_ratedParas.H = double.Parse(this.txtH.Text);
|
if (_ratedParas.H < 1 || _ratedParas.Q < 1)
|
{
|
MessageBox.Show("流量扬程有这么小吗?");
|
return;
|
}
|
|
if (string.IsNullOrWhiteSpace(this.txtE.Text))
|
{
|
double ns = Eventech.Common.PumpParaHelper.CalculateNs(_ratedParas.Q, _ratedParas.H, _ratedn);
|
double eff = Eventech.Common.PumpParaHelper.GetRecommendEfficiency(_ratedParas.Q, _ratedParas.H, _ratedn, comboBoxType.SelectedIndex + 1);
|
|
_ratedParas.E = eff;
|
// this.txtE.Text = string.Format("{0:0.0}", eff);
|
this.txtE.EditValue = Math.Round(eff, 1);
|
}
|
else
|
{
|
_ratedParas.E = double.Parse(this.txtE.Text);
|
}
|
if (_ratedParas.E > 99)
|
{
|
MessageBox.Show("效率有这么大吗?");
|
return;
|
}
|
_ratedParas.P = Eventech.Common.PumpParaHelper.CalculateP(_ratedParas.Q, _ratedParas.H, _ratedParas.E);
|
if (string.IsNullOrWhiteSpace(this.txtP.Text))
|
{
|
this.txtP.EditValue = Math.Round(_ratedParas.P, 1);
|
}
|
//汽蚀
|
double NPSHr = 0;
|
if (!double.TryParse(this.txtNPSH.Text, out NPSHr))
|
{
|
NPSHr = Eventech.Common.PumpParaHelper.GetRecommendNPSHr(_ratedParas.Q, _ratedParas.H, _ratedn, comboBoxType.SelectedIndex + 1);//双吸离心泵
|
NPSHr = Math.Round(NPSHr, 1);
|
this.txtNPSH.EditValue = NPSHr;
|
}
|
_ratedParas.NPSHr = NPSHr;
|
|
//得到点位置
|
bool iOK = Eventech.Common.DimensionlessCurvesHelper.CalcPoints(_ratedParas, _ratedn, k0,
|
ref pointInfoQH, ref pointInfoQE, ref pointInfoQP, ref pointInfoNPSH, checkEditSXB.Checked, Convert.ToInt32(spinEditYLJS.Value));
|
if (!iOK)
|
{
|
XtraMessageBox.Show("Error:265");
|
return;
|
}
|
|
//消除驼峰
|
if (k0 == null || k0 < 0.1)
|
{
|
double spaceH = _ratedParas.H / 200;//200为预估值
|
|
for (int i = pointInfoQH.Count - 2; i >= 0; i--)
|
{
|
if (pointInfoQH[i].Y < pointInfoQH[i + 1].Y)
|
{
|
pointInfoQH[i].Y = pointInfoQH[i + 1].Y + spaceH;
|
}
|
}
|
}
|
|
if (!string.IsNullOrEmpty(txtMaxRatio.Text))
|
{
|
double qre = 0;
|
if (double.TryParse(txtMaxRatio.Text, out qre))
|
{
|
if (qre > 1.01 && qre < 1.8)
|
{
|
var ratio = _ratedParas.Q * qre / pointInfoQH.Last().X;
|
if (qre > 1.35)
|
{
|
var pointInfoQH2 = Eventech.Common.FitCurveHelper.GetFitPointsByExtend(pointInfoQH, ratio);
|
var maxPt_E = Eventech.Common.LineHelper.GetLineInsert(pointInfoQE[pointInfoQE.Count - 2].X, pointInfoQE[pointInfoQE.Count - 1].X, pointInfoQE[pointInfoQE.Count - 2].Y, pointInfoQE[pointInfoQE.Count - 1].Y, qre * _ratedParas.Q);
|
pointInfoQE.Add(new Eventech.Model.FeatPoint(qre * _ratedParas.Q, maxPt_E));
|
pointInfoQH = pointInfoQH2;
|
pointInfoQE = Eventech.Common.FitCurveHelper.GetFitPoints(pointInfoQE);
|
pointInfoQP = Eventech.Common.LxpFeatCurveHelper.CalculateP(pointInfoQH, pointInfoQE);
|
}
|
else
|
{
|
pointInfoQH = Eventech.Common.FitCurveHelper.GetFitPointsByExtend(pointInfoQH, ratio);
|
pointInfoQE = Eventech.Common.FitCurveHelper.GetFitPointsByExtend(pointInfoQE, ratio);
|
pointInfoQP = Eventech.Common.FitCurveHelper.GetFitPointsByExtend(pointInfoQP, ratio);
|
}
|
}
|
}
|
}
|
|
var qhPoints = pointInfoQH.Select(x => new Model.CurvePoint(x.X, x.Y)).ToList();
|
var qePoints = pointInfoQE.Select(x => new Model.CurvePoint(x.X, x.Y)).ToList();
|
var qpPoints = pointInfoQP.Select(x => new Model.CurvePoint(x.X, x.Y)).ToList();
|
|
var qhCurve = new Model.CurveExpress(qhPoints, Model.eCurveFitType.CubicCurve, true);
|
var qeCurve = new Model.CurveExpress(qePoints, Model.eCurveFitType.CubicCurve, true);
|
var qPCurve = new Model.CurveExpress(qpPoints, Model.eCurveFitType.CubicCurve, true);
|
_featCurveExpressGroup = new Model.FeatCurveExpressGroup(qhCurve, qeCurve, qPCurve);
|
|
this.chartFeatCurveViewCtrl1.SetBindingData(qhCurve, qeCurve, qPCurve);
|
if (OnCreateLxpCurve != null)
|
{
|
OnCreateLxpCurve.Invoke();
|
}
|
}
|
|
/// <summary>
|
/// 获取曲线组合
|
/// </summary>
|
/// <returns></returns>
|
public Model.FeatCurveExpressGroup GetFeatCurveExpressGroup()
|
{
|
CreateCurveCore();
|
return _featCurveExpressGroup;
|
}
|
|
#region 事件
|
|
private void txtQ_EditValueChanged(object sender, EventArgs e)
|
{
|
CalcNs();
|
}
|
|
private void txtH_EditValueChanged(object sender, EventArgs e)
|
{
|
CalcNs();
|
}
|
|
private void txtN_EditValueChanged(object sender, EventArgs e)
|
{
|
CalcNs();
|
}
|
|
private void spinEditYLJS_EditValueChanged(object sender, EventArgs e)
|
{
|
CalcNs();
|
}
|
|
private void labReckon_Click(object sender, EventArgs e)
|
{
|
//水力参数
|
try
|
{
|
if (string.IsNullOrEmpty(txtH.Text) || string.IsNullOrEmpty(txtQ.Text))
|
{
|
MessageBox.Show("流量扬程不能为空");
|
return;
|
}
|
//转速
|
if (string.IsNullOrEmpty(txtN.Text))
|
{
|
MessageBox.Show("转速不能为空");
|
return;
|
}
|
_ratedn = double.Parse(txtN.Text);
|
if (_ratedn < 10)
|
{
|
MessageBox.Show("转速有这么小吗?");
|
return;
|
}
|
_ratedParas = new Eventech.Model.RatedParas();
|
_ratedParas.Q = double.Parse(txtQ.Text);
|
_ratedParas.H = double.Parse(txtH.Text);
|
if (_ratedParas.H < 1 || _ratedParas.Q < 1)
|
{
|
MessageBox.Show("流量扬程有这么小吗?");
|
return;
|
}
|
|
}
|
catch
|
{
|
MessageBox.Show("请输入数字");
|
return;
|
}
|
|
//double ns = Eventech.Common.PumpParaHelper.CalculateNs(_ratedParas.Q, _ratedParas.H, _ratedn);
|
|
double eff = Eventech.Common.PumpParaHelper.GetRecommendEfficiency(_ratedParas.Q, _ratedParas.H, _ratedn, comboBoxType.SelectedIndex + 1);
|
txtE.Text = string.Format("{0:0.0}", eff);
|
_ratedParas.E = eff;
|
|
double NPSHr = Eventech.Common.PumpParaHelper.GetRecommendNPSHr(_ratedParas.Q, _ratedParas.H, _ratedn, comboBoxType.SelectedIndex + 1);//双吸离心泵
|
|
NPSHr = Math.Round(NPSHr, 1);
|
txtNPSH.Text = NPSHr.ToString();
|
}
|
|
private void labCalcuE_Click(object sender, EventArgs e)
|
{
|
#region 得到参数
|
double Q, H, P;
|
try
|
{
|
if (string.IsNullOrEmpty(txtH.Text) || string.IsNullOrEmpty(txtQ.Text) || string.IsNullOrEmpty(txtE.Text))
|
{
|
MessageBox.Show("流量,扬程和功率,不能为空");
|
return;
|
}
|
H = double.Parse(txtH.Text);
|
Q = double.Parse(txtQ.Text);
|
P = double.Parse(txtP.Text);
|
if (H < 1 || Q < 1 || P < 1)
|
{
|
MessageBox.Show("参数有这么小吗");
|
return;
|
}
|
}
|
catch
|
{
|
MessageBox.Show("请输入数字");
|
return;
|
}
|
#endregion
|
|
double E = Eventech.Common.PumpParaHelper.CalculateE(Q, H, P);
|
txtE.Text = string.Format("{0:0.0}", E);
|
|
if (E > 99)
|
{
|
MessageBox.Show("功率是否输入有误?");
|
return;
|
}
|
}
|
|
private void labCalcuP_Click(object sender, EventArgs e)
|
{
|
#region 得到参数
|
double Q, H, E;
|
try
|
{
|
if (string.IsNullOrEmpty(txtH.Text) || string.IsNullOrEmpty(txtQ.Text) || string.IsNullOrEmpty(txtE.Text))
|
{
|
MessageBox.Show("流量,扬程和功率,不能为空");
|
return;
|
}
|
H = double.Parse(txtH.Text);
|
Q = double.Parse(txtQ.Text);
|
E = double.Parse(txtE.Text);
|
if (H < 0.1 || Q < 0.1 || E < 1)
|
{
|
MessageBox.Show("参数有这么小吗");
|
return;
|
}
|
}
|
catch
|
{
|
MessageBox.Show("请输入数字");
|
return;
|
}
|
#endregion
|
|
double P = Eventech.Common.PumpParaHelper.CalculateP(Q, H, E);
|
if (P < 1)
|
{
|
txtP.Text = string.Format("{0:0.000}", P);
|
}
|
else if (P < 10)
|
{
|
txtP.Text = string.Format("{0:0.00}", P);
|
}
|
else if (P < 100)
|
{
|
txtP.Text = string.Format("{0:0.0}", P);
|
}
|
else
|
{
|
txtP.Text = string.Format("{0:N0}", P);
|
}
|
}
|
|
//生成曲线
|
private void btnCreate_Click(object sender, EventArgs e)
|
{
|
CreateCurveCore();
|
}
|
|
#endregion
|
|
}
|
}
|