using DevExpress.XtraEditors;
|
using Eventech.Model;
|
using System;
|
using System.Windows.Forms;
|
using TProduct.Model;
|
/// <summary>
|
/// 泵
|
/// </summary>
|
namespace TProduct.WinFrmUI.Data4Factory
|
{
|
public partial class SetPumpParasCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
protected Eventech.Model.UnitP power_unit = Eventech.Model.UnitP.KW;
|
protected Eventech.Model.UnitQ flow_unit = Eventech.Model.UnitQ.M3H;
|
protected Eventech.Model.UnitH head_unit = Eventech.Model.UnitH.M;
|
protected Eventech.Model.UnitH press_unit = Eventech.Model.UnitH.MPa;
|
public SetPumpParasCtrl()
|
{
|
InitializeComponent();
|
|
power_unit = TProduct.UserSetting.Setting.PumpTest.UnitPower;
|
flow_unit = TProduct.UserSetting.Setting.PumpTest.UnitFlow;
|
head_unit = TProduct.UserSetting.Setting.PumpTest.UnitHead;
|
press_unit = TProduct.UserSetting.Setting.PumpTest.UnitPress;
|
|
if (TProduct.UserSetting.Setting.Product.SupplyCurrentType == (int)Model.eSupplyCurrentType.直流)
|
{
|
imageComboBox供电方式.SelectedIndex = 1;
|
simpleLabelItemCalcp_ui.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
|
}
|
else
|
{
|
imageComboBox供电方式.SelectedIndex = 0;
|
simpleLabelItemCalcp_ui.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
|
}
|
|
if (!string.IsNullOrEmpty(TProduct.UserSetting.Setting.Product.Voltages))
|
{
|
var ss = TProduct.UserSetting.Setting.Product.Voltages.Split(',');
|
foreach (var s in ss)
|
{
|
TextEditRatedU.Properties.Items.Add(s);
|
}
|
TextEditRatedU.SelectedIndex = 0;
|
}
|
itemratedq.Text = string.Format("<color=red>*</color>额定流量 ({0})", Eventech.Common.UnitQHelper.GetEnUnitName(flow_unit));
|
|
itemmaxq.Text = string.Format("最大流量 ({0})", Eventech.Common.UnitQHelper.GetEnUnitName(flow_unit));
|
}
|
|
|
public void SetBindingData(Model.ProductSeries modelSeries)
|
{
|
if (modelSeries.Paras.SupplyCurrentType != null)
|
{
|
if (modelSeries.Paras.SupplyCurrentType == eSupplyCurrentType.交流)
|
{
|
imageComboBox供电方式.SelectedIndex = 0;
|
}
|
else if (modelSeries.Paras.SupplyCurrentType == eSupplyCurrentType.直流)
|
{
|
imageComboBox供电方式.SelectedIndex = 1;
|
}
|
}
|
}
|
|
public void SetBindingData(Model.ProductMainExPump modelPump)
|
{
|
if (modelPump == null)
|
return;
|
|
var ratedpara = modelPump.RatedParas;
|
if (!string.IsNullOrEmpty(ratedpara))
|
{
|
var _ratedParasPump = TProduct.Model.RatedParas4Pump.ToModel(ratedpara);
|
|
if (_ratedParasPump.Q > 0)
|
this.SetFlowRatedValue(_ratedParasPump.Q);
|
if (_ratedParasPump.MaxQ != null && _ratedParasPump.MaxQ > 0)
|
this.SetFlowMaxValue(_ratedParasPump.MaxQ.Value);
|
|
if (_ratedParasPump.H > 0)
|
this.textBoxRatedH.EditValue = _ratedParasPump.H;
|
if (_ratedParasPump.MaxH != null && _ratedParasPump.MaxH > 0)
|
this.textBoxMaxH.EditValue = _ratedParasPump.MaxH.Value;
|
|
if (_ratedParasPump.P > 0)
|
this.textBoxP.EditValue = _ratedParasPump.P;
|
if (_ratedParasPump.E > 0)
|
this.textBoxE.EditValue = _ratedParasPump.E;
|
if (_ratedParasPump.NPSHr > 0)
|
this.txtNPSHr.EditValue = _ratedParasPump.NPSHr;
|
if (_ratedParasPump.Voltage > 0)
|
{
|
TextEditRatedU.EditValue = _ratedParasPump.Voltage;
|
}
|
if (_ratedParasPump.CurrentI > 0)
|
{
|
TextEditRatedI.Text = _ratedParasPump.CurrentI.ToString();
|
}
|
|
|
|
this.txtStageNumber.EditValue = _ratedParasPump.StageNumber;
|
this.txtOutletCaliber.EditValue = _ratedParasPump.OutletDia <= 0 ? null : _ratedParasPump?.OutletDia;
|
this.txtInletCaliber.EditValue = _ratedParasPump.InletDia <= 0 ? null : _ratedParasPump?.InletDia;
|
this.cekIsFrequency.EditValue = _ratedParasPump.IsFrequency;
|
this.cekIsSxp.EditValue = _ratedParasPump.IsSxp;
|
this.checkEdit是否能测进口压力.Checked = _ratedParasPump.IsInletPress;
|
this.imageComboBox供电方式.EditValue = (int)_ratedParasPump.CurrentType;
|
this.textEdit汽蚀基准面Zd.EditValue = _ratedParasPump.NpshGaoChaZd;
|
}
|
this.TextEditD2.EditValue = modelPump.D2 <= 0 ? null : modelPump?.D2;
|
this.TextEditPosiAngle.EditValue = modelPump.PosiAngle <= 0 ? null : modelPump?.PosiAngle;
|
this.TextEditRatedn.EditValue = modelPump.Ratedn <= 0 ? null : modelPump?.Ratedn;
|
|
this.imageComboBoxFitTypeQH.EditValue = (int)modelPump.CurveFitTypeQH;
|
this.imageComboBoxFitTypeQE.EditValue = (int)modelPump.CurveFitTypeQE;
|
this.imageComboBoxFitTypeQP.EditValue = (int)modelPump.CurveFitTypeQP;
|
}
|
|
public bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (this.textBoxRatedQ.EditValue == null || string.IsNullOrEmpty(this.textBoxRatedQ.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.textBoxRatedQ, "必填项");
|
return false;
|
}
|
if (this.textBoxRatedH.EditValue == null || string.IsNullOrEmpty(this.textBoxRatedH.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.textBoxRatedH, "必填项");
|
return false;
|
}
|
if (this.textBoxRatedH.EditValue == null || string.IsNullOrEmpty(this.textBoxRatedH.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.textBoxE, "必填项");
|
return false;
|
}
|
if (this.textBoxP.EditValue == null || string.IsNullOrEmpty(this.textBoxP.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.textBoxP, "必填项");
|
return false;
|
}
|
if (this.txtInletCaliber.EditValue != null && !string.IsNullOrEmpty(this.txtInletCaliber.Text.Trim()))
|
{
|
if (Convert.ToDouble(this.txtInletCaliber.EditValue) < 10)
|
{
|
XtraMessageBox.Show("进口口径不能小于10mm");
|
return false;
|
}
|
}
|
if (this.txtOutletCaliber.EditValue != null && !string.IsNullOrEmpty(this.txtOutletCaliber.Text.Trim()))
|
{
|
if (Convert.ToDouble(this.txtOutletCaliber.EditValue) < 10)
|
{
|
XtraMessageBox.Show("出口口径不能小于10mm");
|
return false;
|
}
|
}
|
if (string.IsNullOrEmpty(this.TextEditRatedn.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.TextEditRatedn, "必填项");
|
return false;
|
}
|
return true;
|
}
|
|
public bool GetBindingData(ref Model.ProductMainExPump modelPump)
|
{
|
var ratedParas = new TProduct.Model.RatedParas4Pump();
|
if (!string.IsNullOrEmpty(this.textBoxRatedQ.Text.Trim()))
|
{
|
ratedParas.Q = GetFlowRatedValue();
|
}
|
else
|
{
|
ratedParas.Q = -1;
|
}
|
|
if (!string.IsNullOrEmpty(this.textBoxMaxQ.Text.Trim()))
|
{
|
ratedParas.MaxQ = GetFlowMaxValue();
|
}
|
else
|
{
|
ratedParas.MaxQ = null;
|
}
|
|
if (!string.IsNullOrEmpty(this.textBoxRatedH.Text.Trim()))
|
{
|
ratedParas.H = Convert.ToDouble(this.textBoxRatedH.EditValue);
|
}
|
else
|
{
|
ratedParas.H = -1;
|
}
|
|
if (!string.IsNullOrEmpty(this.textBoxMaxH.Text.Trim()))
|
{
|
ratedParas.MaxH = Convert.ToDouble(this.textBoxMaxH.EditValue);
|
}
|
else
|
{
|
ratedParas.MaxH = null;
|
}
|
|
if (!string.IsNullOrEmpty(this.textBoxP.Text.Trim()))
|
{
|
ratedParas.P = Convert.ToDouble(this.textBoxP.EditValue);
|
}
|
else
|
{
|
ratedParas.P = -1;
|
}
|
|
if (!string.IsNullOrEmpty(this.txtNPSHr.Text.Trim()))
|
{
|
ratedParas.NPSHr = Convert.ToDouble(this.txtNPSHr.EditValue);
|
}
|
else
|
{
|
ratedParas.NPSHr = null;
|
}
|
|
if (!string.IsNullOrEmpty(this.textBoxE.Text.Trim()))
|
{
|
ratedParas.E = Convert.ToDouble(this.textBoxE.EditValue);
|
}
|
else
|
{
|
ratedParas.E = -1;
|
}
|
|
if (!string.IsNullOrEmpty(this.TextEditRatedn.Text.Trim()))
|
{
|
modelPump.Ratedn = Convert.ToDouble(this.TextEditRatedn.EditValue);
|
}
|
else
|
{
|
modelPump.Ratedn = -1;
|
}
|
|
if (!string.IsNullOrEmpty(this.TextEditD2.Text.Trim()))
|
{
|
modelPump.D2 = Convert.ToDouble(this.TextEditD2.EditValue);
|
}
|
else
|
{
|
modelPump.D2 = -1;
|
}
|
|
if (!string.IsNullOrEmpty(this.TextEditPosiAngle.Text.Trim()))
|
{
|
modelPump.PosiAngle = Convert.ToDouble(this.TextEditPosiAngle.EditValue);
|
}
|
else
|
{
|
modelPump.PosiAngle = -1;
|
}
|
|
|
if (!string.IsNullOrEmpty(this.txtStageNumber.Text.Trim()))
|
ratedParas.StageNumber = Convert.ToInt32(this.txtStageNumber.EditValue);
|
|
|
if (string.IsNullOrEmpty(this.txtOutletCaliber.Text.Trim()))
|
{
|
ratedParas.OutletDia = null;
|
}
|
else if (this.txtOutletCaliber.EditValue != null && !string.IsNullOrEmpty(this.txtOutletCaliber.Text.Trim()))
|
{
|
ratedParas.OutletDia = Convert.ToDouble(this.txtOutletCaliber.EditValue);
|
}
|
|
if (string.IsNullOrEmpty(this.txtInletCaliber.Text.Trim()))
|
{
|
ratedParas.InletDia = null;
|
}
|
else if (this.txtInletCaliber.EditValue != null && !string.IsNullOrEmpty(this.txtInletCaliber.Text.Trim()))
|
{
|
ratedParas.InletDia = Convert.ToDouble(this.txtInletCaliber.EditValue);
|
}
|
|
if (string.IsNullOrEmpty(this.textEdit汽蚀基准面Zd.Text.Trim()))
|
{
|
ratedParas.NpshGaoChaZd = 0;
|
}
|
else
|
{
|
ratedParas.NpshGaoChaZd = Convert.ToDouble(this.textEdit汽蚀基准面Zd.EditValue);
|
}
|
|
|
ratedParas.CurrentType = (Model.eSupplyCurrentType)Convert.ToInt32(imageComboBox供电方式.EditValue);
|
ratedParas.IsFrequency = this.cekIsFrequency.Checked;
|
ratedParas.IsSxp = this.cekIsSxp.Checked;
|
ratedParas.IsInletPress = this.checkEdit是否能测进口压力.Checked;
|
|
ratedParas.Voltage = Convert.ToDouble(TextEditRatedU.EditValue);
|
|
if (!string.IsNullOrEmpty(TextEditRatedI.Text))
|
{
|
double ci = 0;
|
if (!double.TryParse(TextEditRatedI.Text, out ci))
|
{
|
MessageBox.Show("电流输入值不合理");
|
return false;
|
}
|
ratedParas.CurrentI = ci;
|
}
|
else
|
{
|
ratedParas.CurrentI = 0;
|
}
|
|
modelPump.RatedParas = ratedParas.ToJson();
|
|
|
modelPump.CurveFitTypeQH = (Eventech.Model.eCurveFitType)Convert.ToInt32(this.imageComboBoxFitTypeQH.EditValue);
|
modelPump.CurveFitTypeQE = (Eventech.Model.eCurveFitType)Convert.ToInt32(this.imageComboBoxFitTypeQE.EditValue);
|
modelPump.CurveFitTypeQP = (Eventech.Model.eCurveFitType)Convert.ToInt32(this.imageComboBoxFitTypeQP.EditValue);
|
return true;
|
}
|
|
private void SetFlowRatedValue(double m3h)
|
{
|
if (flow_unit == UnitQ.M3H)
|
this.textBoxRatedQ.EditValue = m3h;
|
else
|
this.textBoxRatedQ.EditValue = Math.Round(Eventech.Common.UnitQHelper.fromM3H(
|
flow_unit, m3h), 4);
|
}
|
|
private void SetFlowMaxValue(double m3h)
|
{
|
if (flow_unit == UnitQ.M3H)
|
this.textBoxMaxQ.EditValue = m3h;
|
else
|
this.textBoxMaxQ.EditValue = Math.Round(Eventech.Common.UnitQHelper.fromM3H(
|
flow_unit, m3h), 4);
|
}
|
|
private double GetFlowRatedValue()
|
{
|
if (flow_unit == UnitQ.M3H)
|
return Convert.ToDouble(this.textBoxRatedQ.EditValue);
|
else
|
return Eventech.Common.UnitQHelper.toM3H(
|
flow_unit, Convert.ToDouble(this.textBoxRatedQ.EditValue));
|
}
|
|
private double GetFlowMaxValue()
|
{
|
if (flow_unit == UnitQ.M3H)
|
return Convert.ToDouble(this.textBoxMaxQ.EditValue);
|
else
|
return Eventech.Common.UnitQHelper.toM3H(
|
flow_unit, Convert.ToDouble(this.textBoxMaxQ.EditValue));
|
}
|
|
private void btnCalcE_Click(object sender, EventArgs e)
|
{
|
#region 得到参数
|
double Q, H, P;
|
try
|
{
|
if (string.IsNullOrEmpty(textBoxRatedH.Text) || string.IsNullOrEmpty(textBoxRatedQ.Text) || string.IsNullOrEmpty(textBoxP.Text))
|
{
|
XtraMessageBox.Show("流量,扬程和效率,不能为空");
|
return;
|
}
|
H = double.Parse(textBoxRatedH.Text);
|
Q = GetFlowRatedValue();
|
P = double.Parse(textBoxP.Text);
|
}
|
catch
|
{
|
XtraMessageBox.Show("请输入数字");
|
return;
|
}
|
#endregion
|
|
double eta = Eventech.Common.PumpParaHelper.CalculateE(Q, H, P);
|
if (eta < 10)
|
textBoxE.Text = string.Format("{0:0.00}", eta);
|
else
|
textBoxE.Text = string.Format("{0:0.0}", eta);
|
}
|
|
private void btnCalcP_Click(object sender, EventArgs e)
|
{
|
#region 得到参数
|
double Q, H, E;
|
try
|
{
|
if (string.IsNullOrEmpty(textBoxRatedH.Text) || string.IsNullOrEmpty(textBoxRatedQ.Text) || string.IsNullOrEmpty(textBoxE.Text))
|
{
|
XtraMessageBox.Show("流量,扬程和功率,不能为空");
|
return;
|
}
|
H = double.Parse(textBoxRatedH.Text);
|
Q = GetFlowRatedValue();
|
E = double.Parse(textBoxE.Text);
|
|
//if (_isOutletPressReplaceH)
|
//{
|
// H = H * 100;
|
//}
|
//if (_seriesEntity.UnitQ() == Eventech.Model.UnitQ.LS)
|
//{
|
// Q = Q * 3.6;
|
//}
|
}
|
catch
|
{
|
XtraMessageBox.Show("请输入数字");
|
return;
|
}
|
#endregion
|
|
double p = Eventech.Common.PumpParaHelper.CalculateP(Q, H, E);
|
if (p < 0.1)
|
textBoxP.Text = string.Format("{0:0.0000}", p);
|
else if (p < 1)
|
textBoxP.Text = string.Format("{0:0.000}", p);
|
else if (p < 10)
|
textBoxP.Text = string.Format("{0:0.00}", p);
|
else
|
textBoxP.Text = string.Format("{0:0.0}", p);
|
}
|
|
private void btnGaochaView_Click(object sender, EventArgs e)
|
{
|
var HelpDlg = new TProduct.WinFrmUI.Data4Factory.NpshGaoChaHelpDlg();
|
HelpDlg.StartPosition = FormStartPosition.CenterParent;
|
HelpDlg.Show();
|
}
|
|
private void simpleLabelItemCalcp_ui_Click(object sender, EventArgs e)
|
{
|
var vol = Convert.ToInt32(TextEditRatedU.EditValue);
|
double ci = 0;
|
if (!string.IsNullOrEmpty(TextEditRatedI.Text))
|
{
|
if (!double.TryParse(TextEditRatedI.Text, out ci))
|
{
|
MessageBox.Show("电流输入值不合理");
|
return;
|
}
|
}
|
else
|
{
|
return;
|
}
|
var power = vol * ci / 1000;//KW
|
textBoxP.Text = power.ToString();
|
}
|
|
private void imageComboBox供电方式_SelectedIndexChanged(object sender, EventArgs e)
|
{
|
var CurrentType = (Model.eSupplyCurrentType)Convert.ToInt32(imageComboBox供电方式.EditValue);
|
if (CurrentType == eSupplyCurrentType.直流)
|
{
|
simpleLabelItemCalcp_ui.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
|
}
|
else
|
{
|
simpleLabelItemCalcp_ui.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
|
}
|
}
|
}
|
}
|