using DevExpress.XtraEditors;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Windows.Forms;
|
|
|
namespace TProduct.WinFrmUI.TPump
|
{
|
//
|
internal partial class CalcFeatTestData1Dlg : CalcFeatTestBaseDlg
|
{
|
public CalcFeatTestData1Dlg() : base()
|
{
|
InitializeComponent();
|
|
btnOK.Enabled = false;
|
|
this.btnCorrect.SetCalcButtonColor();
|
this.btnOK.SetConfirmButtonColor();
|
this.btnCancel.SetCancelButtonColor();
|
|
this.gridViewMain.OptionsDetail.ShowDetailTabs = false;//不显示TAB名
|
this.gridViewMain.OptionsView.ShowGroupPanel = false;//隐藏最上面的GroupPanel
|
this.gridViewMain.OptionsSelection.MultiSelect = false;//单选
|
//this.gridViewMain.OptionsBehavior.Editable = false;//只读
|
this.gridViewMain.BestFitColumns();
|
this.gridViewMain.IndicatorWidth = 2;
|
this.gridViewMain.RowHeight = 25;
|
//this.gridViewMain.CustomUnboundColumnData += new DevExpress.XtraGrid.Views.Base.CustomColumnDataEventHandler(this.GridViewMain_CustomUnboundColumnData);
|
|
|
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;
|
|
lblCorrectQ.Text = string.Format("修正流量({0})", Eventech.Common.UnitQHelper.GetEnUnitName(flow_unit));
|
lblTestQ.Text = string.Format("测量流量({0})", Eventech.Common.UnitQHelper.GetEnUnitName(flow_unit));
|
|
lblCorrectH.Text = string.Format("修正扬程({0})", Eventech.Common.UnitHHelper.GetEnUnitName(head_unit));
|
lblTestH.Text = string.Format("测量扬程({0})", Eventech.Common.UnitHHelper.GetEnUnitName(head_unit));
|
|
lblCorrectP.Text = string.Format("修正功率({0})", Eventech.Common.UnitPHelper.GetEnUnitName(power_unit));
|
lblTestP.Text = string.Format("测量功率({0})", Eventech.Common.UnitPHelper.GetEnUnitName(power_unit));
|
|
}
|
|
|
|
private void CalcTestData1Dlg_Load(object sender, EventArgs e)
|
{
|
|
}
|
public class CurrentViewModel
|
{
|
public CurrentViewModel() { }
|
public TProduct.Model.WorkBenchMonitorPoint Entity { get; set; }
|
public long ID { get; set; }
|
public string MonitorName { get; set; }
|
public string UnitName { get; set; }//单位
|
public double? DispValue { get; set; }//单位换算后的
|
public DateTime Time { get; set; }
|
public bool IsByCalc { get; set; } = false;//是否是计算得到的
|
}
|
|
List<CurrentViewModel> _bindingData = null;
|
public override void InitialMonitorInfo(List<TProduct.Model.WorkBenchMonitorPoint> allMonitorList)
|
{
|
this._bindingData = new List<CurrentViewModel>();
|
foreach (var monitor in allMonitorList)
|
{
|
CurrentViewModel v = new CurrentViewModel();
|
v.Entity = monitor;
|
v.ID = monitor.ID;
|
v.MonitorName = monitor.Name;
|
v.UnitName = GetUnitName(monitor);
|
|
//
|
v.DispValue = null;
|
if (monitor.MonitorType == TProduct.Model.eMonitorType.转速)
|
{
|
if (monitor.SourceType == TProduct.Model.eMonitorPointSourceType.额定参数)
|
{
|
v.DispValue = this._pumpRatedN;
|
}
|
}
|
if (monitor.MonitorType == TProduct.Model.eMonitorType.电机效率)
|
{
|
if (monitor.SourceType == TProduct.Model.eMonitorPointSourceType.额定参数)
|
{
|
if (this._motorRatedEta > 1)
|
{
|
v.DispValue = this._motorRatedEta;
|
}
|
}
|
}
|
if (monitor.MonitorType == TProduct.Model.eMonitorType.电机效率)
|
{
|
if (this._motorRatedEta > 1)
|
{
|
v.DispValue = this._motorRatedEta;
|
}
|
}
|
|
_bindingData.Add(v);
|
}
|
}
|
|
//
|
private TProduct.Model.PumpFeatTestRecordViewModel _currentRecord = null;
|
//
|
public override bool NewTestRecord(
|
List<TProduct.Model.MonitorPointValuePure> valueList, bool isAutoCalc)
|
{
|
if (_bindingData == null)
|
return false ;
|
if (valueList == null || valueList.Count() == 0)
|
{
|
foreach (var bd in _bindingData)
|
{
|
if (bd.Entity.SourceType == TProduct.Model.eMonitorPointSourceType.计算量)
|
continue;
|
if (bd.Entity.SourceType == TProduct.Model.eMonitorPointSourceType.额定参数)
|
continue;
|
if (bd.Entity.MonitorType == TProduct.Model.eMonitorType.阀门开度)
|
continue;
|
if (bd.Entity.MonitorType == TProduct.Model.eMonitorType.电机效率)
|
continue;
|
if (bd.Entity.MonitorType == TProduct.Model.eMonitorType.介质温度)
|
continue;
|
bd.DispValue = null;
|
}
|
}
|
else
|
{
|
foreach (var bd in _bindingData)
|
{
|
var f = valueList.Find(x => x.ID == bd.ID);
|
if (f == null || f.Value == null)
|
{
|
if (bd.Entity.SourceType == TProduct.Model.eMonitorPointSourceType.计算量)
|
continue;
|
if (bd.Entity.SourceType == TProduct.Model.eMonitorPointSourceType.额定参数)
|
continue;
|
if (bd.Entity.MonitorType == TProduct.Model.eMonitorType.阀门开度)
|
continue;
|
if (bd.Entity.MonitorType == TProduct.Model.eMonitorType.电机效率)
|
continue;
|
if (bd.Entity.MonitorType == TProduct.Model.eMonitorType.介质温度)
|
continue;
|
bd.DispValue = null;
|
continue;
|
}
|
double rMeasureValue = f.Value.Value;
|
if (bd.Entity.MonitorType == Model.eMonitorType.功率)
|
{
|
rMeasureValue = Eventech.Common.UnitPHelper.fromKW(
|
power_unit, rMeasureValue);
|
}
|
else if (bd.Entity.MonitorType == Model.eMonitorType.流量)
|
{
|
rMeasureValue = Math.Round(Eventech.Common.UnitQHelper.fromM3H(
|
flow_unit, rMeasureValue), 4);
|
}
|
else if (bd.Entity.MonitorType == Model.eMonitorType.压力)
|
{
|
rMeasureValue = Eventech.Common.UnitHHelper.fromMPa(
|
press_unit, rMeasureValue);
|
}
|
|
bd.DispValue = rMeasureValue;
|
bd.Time = f.Time;
|
}
|
}
|
|
bindingSource1.DataSource = _bindingData;
|
bindingSource1.ResetBindings(false);
|
btnOK.Enabled = false;
|
|
_currentRecord = new Model.PumpFeatTestRecordViewModel();
|
_currentRecord.TestItemID = this._testItemID;
|
_currentRecord.Time = DateTime.Now;
|
_currentRecord.RecordType = this._recordType;
|
|
if (isAutoCalc)
|
{
|
return CalcCorrectPt(false);
|
}
|
else
|
{
|
return true;
|
}
|
}
|
|
public override bool NewTestRecord4Save(List<TProduct.Model.MonitorPointValuePure> valueList)
|
{
|
if (NewTestRecord(valueList, true) == false)
|
return false;
|
|
if (this._testE < -0.1)
|
{
|
XtraMessageBox.Show("效率不正常,是否是进出口压力表搞错?");
|
return false;
|
}
|
if (TProduct.UserSetting.Setting.PumpTest.IsCheckErrorEta100 && this._testE > 99)
|
{
|
XtraMessageBox.Show("效率不正常?");
|
return false;
|
}
|
if (this._currentRecord == null)
|
return false;
|
|
_currentRecord.Time = DateTime.Now;
|
RefreshDsRecord();// 不含时间
|
|
if (this.OnSaveRecord == null)
|
return false;
|
var bll = new BLL.PumpFeatTestRecord();
|
// operateType表示操作类型 1 表示添加 2 表示更新 3表示删除
|
|
_currentRecord.ID = bll.Add(this._testItem, _currentRecord);
|
OnSaveRecord(_currentRecord, 1);
|
|
return true;
|
}
|
public override void EditTestRecord(TProduct.Model.PumpFeatTestRecordViewModel record)
|
{
|
if (record == null)
|
return;
|
foreach (var bd in _bindingData)
|
{
|
var f = record.MonitorRecordList.Find(x => x.ID == bd.ID);
|
if (f == null || string.IsNullOrEmpty(f.Value))
|
{
|
if (bd.Entity.SourceType == TProduct.Model.eMonitorPointSourceType.计算量)
|
continue;
|
if (bd.Entity.SourceType == TProduct.Model.eMonitorPointSourceType.额定参数)
|
continue;
|
if (bd.Entity.MonitorType == TProduct.Model.eMonitorType.阀门开度)
|
continue;
|
if (bd.Entity.MonitorType == TProduct.Model.eMonitorType.电机效率)
|
continue;
|
if (bd.Entity.MonitorType == TProduct.Model.eMonitorType.介质温度)
|
continue;
|
bd.DispValue = null;
|
}
|
else
|
{
|
double rMeasureValue = Convert.ToDouble(f.Value);
|
if (bd.Entity.MonitorType == Model.eMonitorType.功率)
|
{
|
rMeasureValue = Eventech.Common.UnitPHelper.fromKW(
|
power_unit, rMeasureValue);
|
}
|
else if (bd.Entity.MonitorType == Model.eMonitorType.流量)
|
{
|
rMeasureValue = Eventech.Common.UnitQHelper.fromM3H(
|
flow_unit, rMeasureValue);
|
}
|
else if (bd.Entity.MonitorType == Model.eMonitorType.压力)
|
{
|
rMeasureValue = Eventech.Common.UnitHHelper.fromMPa(
|
press_unit, rMeasureValue);
|
}
|
|
bd.DispValue = rMeasureValue;
|
bd.Time = record.Time;
|
}
|
}
|
this._currentRecord = record;
|
txtTestQ.Text = TProduct.Common.RoundHelper.GetDispValueFlow(
|
Eventech.Common.UnitQHelper.fromM3H(flow_unit, record.TestPtQ)).ToString();
|
txtTestH.Text = TProduct.Common.RoundHelper.GetDispValueHead(
|
Eventech.Common.UnitHHelper.fromM(head_unit, record.TestPtH)).ToString();
|
txtTestE.Text = TProduct.Common.RoundHelper.GetDispValueEta(record.TestPtE.Value).ToString();
|
|
if (record.TestPtP != null)
|
{
|
txtTestP.Text = TProduct.Common.RoundHelper.GetDispValuePower(
|
Eventech.Common.UnitPHelper.fromKW(power_unit, record.TestPtP.Value)).ToString();
|
}
|
|
|
txtCorrectQ.Text = TProduct.Common.RoundHelper.GetDispValueFlow(
|
Eventech.Common.UnitQHelper.fromM3H(flow_unit, record.CorrectPtQ)).ToString();
|
txtCorrectH.Text = TProduct.Common.RoundHelper.GetDispValueHead(
|
Eventech.Common.UnitHHelper.fromM(head_unit, record.CorrectPtH)).ToString();
|
txtCorrectE.Text = TProduct.Common.RoundHelper.GetDispValueEta(record.CorrectPtE.Value).ToString();
|
if (record.CorrectPtP != null)
|
{
|
txtCorrectP.Text = TProduct.Common.RoundHelper.GetDispValuePower(
|
Eventech.Common.UnitPHelper.fromKW(power_unit, record.CorrectPtP.Value)).ToString();
|
}
|
|
|
bindingSource1.DataSource = _bindingData;
|
bindingSource1.ResetBindings(false);
|
btnOK.Enabled = false;
|
}
|
|
|
//参数
|
private double _testQ, _testH, _testE, _testP;//测量值(都是标准单位)
|
private double _correctQ, _correctH, _correctE, _correctP;//修正值(都是标准单位)
|
private double _rMeasureSpeed, _rMeasureHz;
|
|
//计算
|
private void btnCorrect_Click(object sender, EventArgs e)
|
{
|
CalcCorrectPt(true);
|
}
|
private bool CalcCorrectPt(bool isShowError)
|
{
|
btnOK.Enabled = false;
|
|
try
|
{
|
if (!CalcMeasurePara(isShowError))
|
return false ;
|
|
if (_testH < 0)
|
{
|
if (isShowError)
|
MessageBox.Show("进出口压力测点是否搞反了");
|
return false ;
|
}
|
txtTestQ.Text = TProduct.Common.RoundHelper.GetDispValueFlow(
|
Eventech.Common.UnitQHelper.fromM3H(flow_unit, _testQ)).ToString();
|
txtTestH.Text = TProduct.Common.RoundHelper.GetDispValueHead(
|
Eventech.Common.UnitHHelper.fromM(head_unit, _testH)).ToString();
|
txtTestE.Text = TProduct.Common.RoundHelper.GetDispValueEta(_testE).ToString();
|
txtTestP.Text = TProduct.Common.RoundHelper.GetDispValuePower(
|
Eventech.Common.UnitPHelper.fromKW(power_unit, _testP)).ToString();
|
|
txtCorrectQ.Text = TProduct.Common.RoundHelper.GetDispValueFlow(
|
Eventech.Common.UnitQHelper.fromM3H(flow_unit, _correctQ)).ToString();
|
txtCorrectH.Text = TProduct.Common.RoundHelper.GetDispValueHead(
|
Eventech.Common.UnitHHelper.fromM(head_unit, _correctH)).ToString();
|
txtCorrectE.Text = TProduct.Common.RoundHelper.GetDispValueEta(_correctE).ToString();
|
txtCorrectP.Text = TProduct.Common.RoundHelper.GetDispValuePower(
|
Eventech.Common.UnitPHelper.fromKW(power_unit, _correctP)).ToString();
|
}
|
catch (Exception ex)
|
{
|
if (isShowError)
|
XtraMessageBox.Show(ex.Message, "Error:169");
|
return false ;
|
}
|
|
btnOK.Enabled = true;
|
return true;
|
}
|
|
#region 计算
|
/// <summary>
|
///
|
/// </summary>
|
/// <returns></returns>
|
private bool CalcMeasurePara(bool isShowError)
|
{
|
if (_pumpRatedParas == null)
|
{
|
_speedSimuMethod = Model.eSpeedSimuMethod.不换算;
|
// if (isShowError)
|
// XtraMessageBox.Show("未设置泵额定参数?", "问题确认",
|
//MessageBoxButtons.OK, MessageBoxIcon.Question);
|
// return false;
|
}
|
|
#region 转速,流量
|
_rMeasureHz = 0;
|
var moinitor_hz = this._bindingData.Find(x => x.Entity.MonitorType == Model.eMonitorType.频率);
|
if (moinitor_hz != null && moinitor_hz.DispValue != null)
|
{
|
this._rMeasureHz = moinitor_hz.DispValue.Value;
|
}
|
else if (_speedSimuMethod == Model.eSpeedSimuMethod.频率换算)
|
{
|
if (isShowError)
|
XtraMessageBox.Show("请输入电机频率?", "问题确认",
|
MessageBoxButtons.OK, MessageBoxIcon.Question);
|
}
|
//测量转速(最先获取,因为轴功率可能用到)
|
var moinitor_speed = this._bindingData.Find(x => x.Entity.MonitorType == Model.eMonitorType.转速);
|
if (moinitor_speed == null || moinitor_speed.DispValue == null)
|
{
|
if (moinitor_speed != null &&
|
moinitor_speed.Entity.SourceType == TProduct.Model.eMonitorPointSourceType.额定参数)
|
{
|
this._rMeasureSpeed = this._pumpRatedN;
|
this._rMeasureHz = 50;
|
}
|
else if (_speedSimuMethod == Model.eSpeedSimuMethod.转速换算)
|
{
|
if (isShowError)
|
XtraMessageBox.Show("请输入电机转速?", "问题确认",
|
MessageBoxButtons.OK, MessageBoxIcon.Question);
|
return false;
|
}
|
else if (_speedSimuMethod == Model.eSpeedSimuMethod.频率换算)
|
{
|
this._rMeasureSpeed = Math.Round(this._pumpRatedN * this._rMeasureHz / 50, 0);
|
}
|
else if (_speedSimuMethod == Model.eSpeedSimuMethod.不换算)
|
{
|
this._rMeasureSpeed = this._pumpRatedN;
|
}
|
else
|
{
|
this._rMeasureSpeed = this._pumpRatedN;
|
}
|
}
|
else
|
{
|
this._rMeasureSpeed = moinitor_speed.DispValue.Value;
|
}
|
|
|
//测量流量
|
double total_flow_m3h = 0;
|
var moinitor_flows = this._bindingData.Where(x => x.Entity.MonitorType == Model.eMonitorType.流量);
|
if (moinitor_flows == null || moinitor_flows.Count() == 0)
|
{
|
if (isShowError)
|
XtraMessageBox.Show("请输入流量?", "问题确认",
|
MessageBoxButtons.OK, MessageBoxIcon.Question);
|
return false;
|
}
|
else if (moinitor_flows.Count() == 1)
|
{
|
var moinitor_flow = moinitor_flows.First();
|
if (moinitor_flow == null || moinitor_flow.DispValue == null)
|
{
|
if (isShowError)
|
XtraMessageBox.Show("请输入流量?", "问题确认",
|
MessageBoxButtons.OK, MessageBoxIcon.Question);
|
return false;
|
}
|
total_flow_m3h = Eventech.Common.UnitQHelper.toM3H(flow_unit, moinitor_flow.DispValue.Value);
|
}
|
else
|
{//多个流量计
|
total_flow_m3h = 0;
|
foreach (var moinitor_flow in moinitor_flows)
|
{
|
if (moinitor_flow == null || moinitor_flow.DispValue == null)
|
{
|
continue;
|
}
|
total_flow_m3h = total_flow_m3h + moinitor_flow.DispValue.Value * moinitor_flow.Entity.SumCalcCoeff;
|
}
|
total_flow_m3h = Eventech.Common.UnitQHelper.toM3H(flow_unit, total_flow_m3h);
|
}
|
|
|
#endregion
|
|
#region 功率/扭矩
|
double total_axis_power = 0;
|
if (_powerTestMethod == TProduct.Model.ePowerTestMethod.扭矩)
|
{
|
var moinitor_扭矩 = this._bindingData.Find(x => x.Entity.MonitorType == TProduct.Model.eMonitorType.扭矩);
|
if (moinitor_扭矩 == null || moinitor_扭矩.DispValue == null)
|
{
|
if (isShowError)
|
XtraMessageBox.Show("请输入扭矩值?", "问题确认",
|
MessageBoxButtons.OK, MessageBoxIcon.Question);
|
return false;
|
}
|
total_axis_power = Math.Round(moinitor_扭矩.DispValue.Value * _rMeasureSpeed / 9550, 3);
|
}
|
else
|
{//电机功率
|
double motor_eff = _motorRatedEta;
|
var moinitor_motor_eff = this._bindingData.Find(x =>
|
x.Entity.MonitorType == TProduct.Model.eMonitorType.电机效率);
|
if (moinitor_motor_eff != null && moinitor_motor_eff.DispValue != null)
|
{
|
motor_eff = moinitor_motor_eff.DispValue.Value;
|
}
|
|
var moinitor_power = this._bindingData.Find(x =>
|
x.Entity.MonitorType == TProduct.Model.eMonitorType.功率
|
&& (string.IsNullOrEmpty(x.Entity.Property) || x.Entity.Property == TProduct.Model.MonitorTypeProperty.总));
|
if (moinitor_power == null)
|
{
|
if (isShowError)
|
XtraMessageBox.Show("请先设置电机功率测点?", "问题确认",
|
MessageBoxButtons.OK, MessageBoxIcon.Question);
|
return false;
|
}
|
|
if (moinitor_power.DispValue == null ||
|
Eventech.Common.UnitPHelper.toKW(power_unit,
|
moinitor_power.DispValue.Value) < 0.0001 || bci自动计算电机功率.Checked)
|
{
|
var calc_power = CalcPowerByUI();
|
if (calc_power != null)
|
{
|
bci自动计算电机功率.Checked = true;
|
moinitor_power.IsByCalc = true;
|
moinitor_power.DispValue = calc_power;
|
this.bindingSource1.ResetBindings(false);
|
}
|
else
|
{
|
if (isShowError)
|
XtraMessageBox.Show("请输入电机功率?", "问题确认",
|
MessageBoxButtons.OK, MessageBoxIcon.Question);
|
return false;
|
}
|
}
|
double rMotorPower = Eventech.Common.UnitPHelper.toKW(power_unit,
|
moinitor_power.DispValue.Value);
|
|
if (motor_eff > 1)
|
total_axis_power = rMotorPower * motor_eff / 100.0;//乘以电机效率
|
else
|
total_axis_power = rMotorPower;
|
}
|
|
#endregion
|
|
#region 计算扬程
|
double OtherPressCoeff = 4 * 1000 / Math.PI / 3.6;
|
double rPipeInV = 0;
|
|
double p1m = 0;
|
double height_inlet = 0;
|
if (_isInlet清水池)
|
{
|
CurrentViewModel moinitor_press_inlet =
|
this._bindingData.Find(x => x.Entity.MonitorType == Model.eMonitorType.水位 &&
|
x.Entity.Property == TProduct.Model.MonitorTypeProperty.进口);
|
|
if (moinitor_press_inlet != null &&
|
moinitor_press_inlet.Entity != null &&
|
moinitor_press_inlet.Entity.Elevation != null)
|
{
|
height_inlet = moinitor_press_inlet.Entity.Elevation.Value;
|
}
|
|
if (moinitor_press_inlet != null && moinitor_press_inlet.DispValue != null)
|
{
|
p1m = moinitor_press_inlet.DispValue.Value;
|
}
|
}
|
else
|
{
|
CurrentViewModel moinitor_press_inlet =
|
this._bindingData.Find(x => x.Entity.MonitorType == Model.eMonitorType.压力 &&
|
x.Entity.Property == TProduct.Model.MonitorTypeProperty.进口);
|
|
if (moinitor_press_inlet != null &&
|
moinitor_press_inlet.Entity != null &&
|
moinitor_press_inlet.Entity.PipeDia != null &&
|
moinitor_press_inlet.Entity.PipeDia > 10)
|
{
|
double mm_inlet_dia = moinitor_press_inlet.Entity.PipeDia.Value;
|
rPipeInV = OtherPressCoeff * total_flow_m3h / mm_inlet_dia / mm_inlet_dia;
|
}
|
|
if (moinitor_press_inlet != null &&
|
moinitor_press_inlet.Entity != null &&
|
moinitor_press_inlet.Entity.Elevation != null)
|
{
|
height_inlet = moinitor_press_inlet.Entity.Elevation.Value;
|
}
|
|
if (_pumpRatedParas != null && _pumpRatedParas.IsInletPress)
|
{
|
if (moinitor_press_inlet == null || moinitor_press_inlet.DispValue == null)
|
{
|
if (isShowError)
|
XtraMessageBox.Show("请输入进口压力?", "问题确认",
|
MessageBoxButtons.OK, MessageBoxIcon.Question);
|
return false;
|
}
|
|
double p1mpa = Eventech.Common.UnitHHelper.toMPa(press_unit,
|
moinitor_press_inlet.DispValue.Value);
|
p1m = UnitConvert_MPa2M(p1mpa);
|
}
|
else
|
{
|
if (moinitor_press_inlet != null && moinitor_press_inlet.DispValue != null)
|
{
|
double p1mpa = Eventech.Common.UnitHHelper.toMPa(press_unit,
|
moinitor_press_inlet.DispValue.Value);
|
p1m = UnitConvert_MPa2M(p1mpa);
|
}
|
}
|
}
|
|
|
|
|
|
var moinitor_press_outlet = this._bindingData.Find(x => x.Entity.MonitorType == Model.eMonitorType.压力 && x.Entity.Property == TProduct.Model.MonitorTypeProperty.出口);
|
if (moinitor_press_outlet == null || moinitor_press_outlet.DispValue == null)
|
{
|
if (isShowError)
|
XtraMessageBox.Show("请输入出口压力?", "问题确认",
|
MessageBoxButtons.OK, MessageBoxIcon.Question);
|
return false;
|
}
|
|
double p2mpa = Eventech.Common.UnitHHelper.toMPa(
|
press_unit, moinitor_press_outlet.DispValue.Value);
|
double p2m = UnitConvert_MPa2M(p2mpa);
|
double rPipeOutV = 0;
|
double height_oulet = 0;
|
if (moinitor_press_outlet.Entity.PipeDia != null && moinitor_press_outlet.Entity.PipeDia > 5)
|
{
|
double mm_outlet_dia = moinitor_press_outlet.Entity.PipeDia.Value;
|
rPipeOutV = OtherPressCoeff * total_flow_m3h / mm_outlet_dia / mm_outlet_dia;// OtherPressCoeff = 4 * 1000 / Math.PI / 3.6;
|
}
|
if (moinitor_press_outlet.Entity.Elevation != null)
|
{
|
height_oulet = moinitor_press_outlet.Entity.Elevation.Value;
|
}
|
|
|
|
double gc = height_oulet - height_inlet;//高差
|
double rVDif = (rPipeOutV * rPipeOutV - rPipeInV * rPipeInV) / (TProduct.ConstantParas.g * 2.0);
|
double total_head = Math.Round(p2m - p1m + rVDif + gc, 2);
|
|
#endregion
|
|
this._testQ = TProduct.Common.RoundHelper.GetDispValueFlow(total_flow_m3h);
|
this._testH = TProduct.Common.RoundHelper.GetDispValueHead(total_head);
|
this._testP = TProduct.Common.RoundHelper.GetDispValuePower(total_axis_power);
|
this._testE = CalculateE(_testQ, _testH, _testP);
|
|
if (TProduct.UserSetting.Setting.PumpTest.IsCheckErrorEta100 && this._testE > 99)
|
{
|
if (isShowError)
|
XtraMessageBox.Show("效率已超过100%,请确认数据是否正常?", "问题确认",
|
MessageBoxButtons.OK, MessageBoxIcon.Question);
|
return false;
|
}
|
|
//计算测试修正值
|
if (!CalculeCorrectPara(isShowError))
|
{
|
return false;
|
}
|
|
//温度换算
|
if (!CalculeByTemperature(isShowError))
|
{
|
return false;
|
}
|
|
return true;
|
}
|
|
/// <summary>
|
/// 根据电流电压计算功率
|
/// </summary>
|
/// <returns></returns>
|
private double? CalcPowerByUI()
|
{
|
var moinitor_相电压 = this._bindingData.Find(x =>
|
x.Entity.MonitorType == TProduct.Model.eMonitorType.相电压
|
&& (string.IsNullOrEmpty(x.Entity.Property) || x.Entity.Property == TProduct.Model.MonitorTypeProperty.总));
|
if (moinitor_相电压 == null || moinitor_相电压.DispValue == null)
|
return null;
|
|
var moinitor_相电流 = this._bindingData.Find(x =>
|
x.Entity.MonitorType == TProduct.Model.eMonitorType.相电流
|
&& (string.IsNullOrEmpty(x.Entity.Property) || x.Entity.Property == TProduct.Model.MonitorTypeProperty.总));
|
if (moinitor_相电流 == null || moinitor_相电流.DispValue == null)
|
return null;
|
if (this._supplyCurrentType == Model.eSupplyCurrentType.直流)
|
{//暂时只考虑直流
|
return moinitor_相电压.DispValue.Value * moinitor_相电流.DispValue.Value;
|
}
|
return null;
|
}
|
/// <summary>
|
/// 根据测试参数,计算测试修正值(输入进来的单位都是标准单位)
|
/// </summary>
|
/// <returns></returns>
|
public bool CalculeCorrectPara(bool isShowError)
|
{
|
_correctQ = _correctH = _correctE = _correctP = 0;
|
//测量转速
|
if (_speedSimuMethod == Model.eSpeedSimuMethod.转速换算)
|
{
|
if (this._rMeasureSpeed <= 20)
|
{
|
if (isShowError)
|
XtraMessageBox.Show("请输入转速?", "问题确认", MessageBoxButtons.OK, MessageBoxIcon.Question);
|
return false;
|
}
|
}
|
else if (_speedSimuMethod == Model.eSpeedSimuMethod.频率换算)
|
{
|
this._rMeasureSpeed = Math.Round(this._pumpRatedN * this._rMeasureHz / 50, 0);
|
}
|
else if (_speedSimuMethod == Model.eSpeedSimuMethod.不换算)
|
{
|
if (this._rMeasureSpeed <= 20)
|
{
|
this._rMeasureSpeed = this._pumpRatedN;
|
}
|
}
|
|
|
|
|
try
|
{
|
bool isZeroQ = false;
|
if (this._pumpRatedParas == null)
|
{
|
if (this._testQ < 0.1)
|
{
|
this._testQ = 0;
|
isZeroQ = true;
|
}
|
}
|
else
|
{
|
if (this._testQ < this._pumpRatedParas.Q / 50)
|
{
|
this._testQ = 0;
|
isZeroQ = true;
|
}
|
}
|
|
if (_speedSimuMethod == Model.eSpeedSimuMethod.转速换算 ||
|
_speedSimuMethod == Model.eSpeedSimuMethod.频率换算)
|
{
|
if (Math.Abs(this._rMeasureSpeed - this._pumpRatedN) < 3)
|
{
|
_correctQ = this._testQ;
|
_correctH = this._testH;
|
_correctE = this._testE;
|
_correctP = this._testP;
|
}
|
else
|
{
|
double rTestSpeed = this._rMeasureSpeed;
|
|
|
//得到相似换算值
|
double xshsFlow = this._testQ * this._pumpRatedN / rTestSpeed;
|
double xshsHead = this._testH * this._pumpRatedN * this._pumpRatedN / rTestSpeed / rTestSpeed;
|
|
//效率进行修正
|
double xshsEffice = GetSpeedE(this._testE, rTestSpeed, this._pumpRatedN);
|
|
//功率
|
double xshsPower = 0;
|
if (isZeroQ)
|
{//零流量点的功率
|
xshsPower = this._testP * this._pumpRatedN * this._pumpRatedN * this._pumpRatedN / rTestSpeed / rTestSpeed / rTestSpeed;
|
}
|
else
|
{//一般点的功率用效率计算
|
xshsPower = CalculateP(xshsFlow, xshsHead, xshsEffice);
|
}
|
|
_correctQ = TProduct.Common.RoundHelper.GetDispValueFlow(xshsFlow);
|
_correctH = TProduct.Common.RoundHelper.GetDispValueHead(xshsHead);
|
_correctE = TProduct.Common.RoundHelper.GetDispValueEta(xshsEffice);
|
_correctP = TProduct.Common.RoundHelper.GetDispValuePower(xshsPower);
|
}
|
}
|
else
|
{
|
_correctQ = this._testQ;
|
_correctH = this._testH;
|
_correctE = this._testE;
|
_correctP = this._testP;
|
}
|
|
|
}
|
catch (Exception ex)
|
{
|
if (isShowError)
|
XtraMessageBox.Show(ex.ToString());
|
return false;
|
}
|
return true;
|
}
|
|
/// <summary>
|
/// 温度换算
|
/// </summary>
|
/// <returns></returns>
|
private bool CalculeByTemperature(bool isShowError)
|
{
|
//温度换算
|
if (this._isTemperatureTrn && _correctQ > 0.1)
|
{
|
double jiezhi_wendu = 20;
|
double origin_eta = _correctE;//模型效率
|
double origin_wendu = 20;//模型温度
|
var moinitor_jiezhi_wendu = this._bindingData.Find(x => x.Entity.MonitorType == TProduct.Model.eMonitorType.介质温度);
|
if (moinitor_jiezhi_wendu == null || moinitor_jiezhi_wendu.DispValue == null)
|
{
|
if (_testParas == null)
|
{
|
if (isShowError)
|
XtraMessageBox.Show("请输入介质温度?", "问题确认",
|
MessageBoxButtons.OK, MessageBoxIcon.Question);
|
return false;
|
}
|
|
jiezhi_wendu = _testParas.JzWenDu;
|
}
|
else
|
{
|
jiezhi_wendu = moinitor_jiezhi_wendu.DispValue.Value;
|
}
|
|
if (jiezhi_wendu > -10)
|
{
|
_correctE = Math.Round((origin_eta * 100 / (origin_eta * 1 + (100 - origin_eta) * Math.Pow((origin_wendu / jiezhi_wendu), -0.07))), 2);
|
|
_correctP = CalculateP(_correctH, _correctQ, _correctE);
|
}
|
}
|
|
return true;
|
}
|
#endregion
|
|
private void btnOK_Click(object sender, EventArgs e)
|
{
|
if (this._bindingData == null)
|
return;
|
|
if (this._testE < -0.1)
|
{
|
XtraMessageBox.Show("效率不正常,是否是进出口压力表搞错?");
|
return;
|
}
|
if (TProduct.UserSetting.Setting.PumpTest.IsCheckErrorEta100 && this._testE > 99)
|
{
|
XtraMessageBox.Show("效率不正常?");
|
return;
|
}
|
if (this._currentRecord == null)
|
return;
|
try
|
{
|
_currentRecord.Time = DateTime.Now;
|
RefreshDsRecord();// 不含时间
|
|
if (this.OnSaveRecord == null)
|
return;
|
var bll = new BLL.PumpFeatTestRecord();
|
// operateType表示操作类型 1 表示添加 2 表示更新 3表示删除
|
if (_currentRecord.ID == 0)
|
{
|
_currentRecord.ID = bll.Add(this._testItem, _currentRecord);
|
OnSaveRecord(_currentRecord, 1);
|
}
|
else
|
{
|
bll.Update(this._testItem, _currentRecord);
|
OnSaveRecord(_currentRecord, 2);
|
}
|
}
|
catch (Exception ex)
|
{
|
XtraMessageBox.Show(ex.Message, "Error:184");
|
return;
|
}
|
if (isAutoClose)
|
{
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
this.Close();
|
}
|
else
|
{//注意:此对话框不会关闭,只是隐藏,如果要关闭需要外部关闭
|
txtCorrectQ.Text = "";
|
txtCorrectH.Text = "";
|
txtCorrectE.Text = "";
|
txtCorrectP.Text = "";
|
|
txtTestQ.Text = "";
|
txtTestH.Text = "";
|
txtTestE.Text = "";
|
txtTestP.Text = "";
|
|
this.Hide();//不要关闭可能要再次打开
|
}
|
}
|
|
private void RefreshDsRecord()
|
{
|
_currentRecord.Speed = this._rMeasureSpeed;
|
//_testQ , _correctQ已经是标准单位了
|
_currentRecord.TestPtQ = TProduct.Common.RoundHelper.GetDispValueFlow(this._testQ);
|
_currentRecord.TestPtH = TProduct.Common.RoundHelper.GetDispValueHead(this._testH);
|
_currentRecord.TestPtE = TProduct.Common.RoundHelper.GetDispValueEta(this._testE);
|
_currentRecord.TestPtP = TProduct.Common.RoundHelper.GetDispValuePower(this._testP);
|
_currentRecord.CorrectPtQ = TProduct.Common.RoundHelper.GetDispValueFlow(this._correctQ);
|
_currentRecord.CorrectPtH = TProduct.Common.RoundHelper.GetDispValueHead(this._correctH);
|
_currentRecord.CorrectPtE = TProduct.Common.RoundHelper.GetDispValueEta(this._correctE);
|
_currentRecord.CorrectPtP = TProduct.Common.RoundHelper.GetDispValuePower(this._correctP);
|
|
TProduct.Model.MonitorRecord4DsList monitorRecord4Ds = new TProduct.Model.MonitorRecord4DsList();
|
foreach (var bd in _bindingData)
|
{
|
if (bd.DispValue != null)
|
{
|
double rMeasureValue = bd.DispValue.Value;
|
if (bd.Entity.MonitorType == Model.eMonitorType.功率)
|
{
|
rMeasureValue = Eventech.Common.UnitPHelper.toKW(
|
power_unit, rMeasureValue);
|
}
|
else if (bd.Entity.MonitorType == Model.eMonitorType.流量)
|
{
|
rMeasureValue = Eventech.Common.UnitQHelper.toM3H(
|
flow_unit, rMeasureValue);
|
}
|
else if (bd.Entity.MonitorType == Model.eMonitorType.压力)
|
{
|
rMeasureValue = Eventech.Common.UnitHHelper.toMPa(
|
press_unit, rMeasureValue);
|
}
|
monitorRecord4Ds.Add(new TProduct.Model.MonitorRecord4Ds(bd.ID, rMeasureValue.ToString()));
|
}
|
|
}
|
_currentRecord.MonitorRecordList = monitorRecord4Ds;
|
_currentRecord.MonitorRecords = monitorRecord4Ds.ToDsString();
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="motor"></param>
|
public override void SetMotorInfo(TProduct.Model.ProductMainExMotor motor)
|
{
|
if (motor == null || motor.Ratedn == null || motor.Ratedn <= 1)
|
return;
|
if (!string.IsNullOrEmpty(motor.RatedParas))
|
{
|
var motor_ratedParas = TProduct.Model.RatedParas4Motor.ToModel(motor.RatedParas);
|
this._motorRatedEta = motor_ratedParas.E_Self;
|
if (_bindingData != null)
|
{
|
var f = this._bindingData.Find(x => x.Entity.MonitorType == TProduct.Model.eMonitorType.电机效率);
|
if (f != null)
|
{
|
f.Time = DateTime.Now;
|
f.DispValue = this._motorRatedEta;
|
bindingSource1.DataSource = _bindingData;
|
bindingSource1.ResetBindings(false);
|
}
|
}
|
}
|
}
|
/// <summary>
|
/// 外部更新效率,并保存数据
|
/// </summary>
|
/// <param name="eta"></param>
|
/// <returns></returns>
|
public override bool RefreshMotorEta(double eta)
|
{
|
if (_bindingData == null)
|
return false;
|
|
var f = this._bindingData.Find(x => x.Entity.MonitorType == TProduct.Model.eMonitorType.电机效率);
|
if (f == null)
|
{
|
return false;
|
}
|
if (f.DispValue == eta)
|
return true;
|
f.DispValue = eta;
|
bindingSource1.DataSource = _bindingData;
|
bindingSource1.ResetBindings(false);
|
|
|
if (!CalcMeasurePara(false ))
|
return false;
|
|
RefreshDsRecord();// 不含时间
|
|
|
var bll = new BLL.PumpFeatTestRecord();
|
bll.Update(this._testItem, _currentRecord);
|
|
return true;
|
}
|
/// <summary>
|
/// 外部修改了额定转速, 刷新数据
|
/// </summary>
|
/// <param name="eta"></param>
|
/// <returns></returns>
|
public override bool RefreshRatedn(double speed)
|
{
|
if (_bindingData == null)
|
return false;
|
|
this._pumpRatedN = speed;
|
|
|
if (!CalcMeasurePara(false))
|
return false;
|
|
RefreshDsRecord();// 不含时间
|
|
|
var bll = new BLL.PumpFeatTestRecord();
|
bll.Update(this._testItem, _currentRecord);
|
|
return true;
|
}
|
|
/// <summary>
|
/// 设置阀门开度
|
/// </summary>
|
/// <param name="prop"></param>
|
/// <param name="paras"></param>
|
/// <returns></returns>
|
public override void SetValveDegree(string prop, double paras)
|
{
|
if (_bindingData != null)
|
{
|
var f = this._bindingData.Find(x => x.Entity.MonitorType == TProduct.Model.eMonitorType.阀门开度 && x.Entity.Property == prop);
|
if (f != null)
|
{
|
f.Time = DateTime.Now;
|
f.DispValue = paras;
|
}
|
bindingSource1.DataSource = _bindingData;
|
bindingSource1.ResetBindings(false);
|
}
|
}
|
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void btnCancel_Click(object sender, EventArgs e)
|
{
|
if (isAutoClose)
|
{
|
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
this.Close();
|
}
|
else
|
{//注意:此对话框不会关闭,只是隐藏,如果要关闭需要外部关闭
|
this.Hide();
|
}
|
}
|
|
|
private void GridViewMain_CustomDrawGroupRow(object sender, DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs e)
|
{
|
//DevExpress.XtraGrid.Views.Grid.ViewInfo.GridGroupRowInfo group = e.Info as DevExpress.XtraGrid.Views.Grid.ViewInfo.GridGroupRowInfo;
|
//if (Convert.ToBoolean(group.EditValue))
|
//{
|
// group.GroupText = "仪表获取";
|
//}
|
//else
|
//{
|
// group.GroupText = "手动输入";
|
//}
|
}
|
|
private void GridViewMain_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
|
{
|
//if (e.Column == colUnitName)
|
//{
|
// e.Value = "";
|
// var mv = e.Row as TProduct.Model.MonitorPointValue;
|
// if (mv == null)
|
// return;
|
// e.Value = TProduct.Common.MonitorTypeHelper.GetUnitName(mv.MonitorType);
|
//}
|
}
|
|
|
internal override void SetPumpInfo(TProduct.Model.ProductSeries series, TProduct.Model.ProductMainExPump pump)
|
{
|
base.SetPumpInfo(series, pump);
|
|
bci转速换算.Enabled = false;
|
if(pump == null)
|
{
|
bci转速换算.Checked = false;
|
_speedSimuMethod = Model.eSpeedSimuMethod.不换算;
|
}
|
else
|
{
|
if (_speedSimuMethod == Model.eSpeedSimuMethod.不换算)
|
{
|
bci转速换算.Checked = false;
|
}
|
else
|
{
|
bci转速换算.Checked = true;
|
}
|
}
|
|
}
|
|
|
|
|
|
|
}
|
}
|