using AStation.Chart;
|
using AStation.Curve;
|
using DevExpress.XtraEditors;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel.DataAnnotations;
|
using System.Drawing;
|
using System.Linq;
|
using System.Windows.Forms;
|
|
namespace AStation.WinFrmUI.Chart
|
{
|
public partial class ImportCurveByPictureCtrl : XtraUserControl
|
{
|
public ImportCurveByPictureCtrl()
|
{
|
InitializeComponent();
|
this.curvePictureBoxCtrl1.ReloadPickPointsEvent += CurvePictureBoxCtrl1_ReloadPickPointsEvent;
|
this.curvePictureBoxCtrl1.ReloadBoundaryEvent += CurvePictureBoxCtrl1_ReloadBoundaryEvent;
|
InitialPictureSizeMode();
|
SetBindingData();
|
}
|
|
|
//初始化图片显示模式
|
private void InitialPictureSizeMode()
|
{
|
foreach (PictureBoxSizeMode sizeMode in Enum.GetValues(typeof(PictureBoxSizeMode)))
|
{
|
var barCheckItem = new DevExpress.XtraBars.BarCheckItem();
|
barCheckItem.Caption = sizeMode.ToString();
|
barCheckItem.Id = (int)sizeMode;
|
barCheckItem.Name = $"barBtn{barCheckItem.Caption}";
|
barCheckItem.ItemClick += (object sender, DevExpress.XtraBars.ItemClickEventArgs e) =>
|
{
|
foreach (DevExpress.XtraBars.BarCheckItemLink link in this.barSubPictureSizeMode.ItemLinks)
|
{
|
((DevExpress.XtraBars.BarCheckItem)link.Item).Checked = false;
|
}
|
var clickItem = (DevExpress.XtraBars.BarCheckItem)e.Item;
|
clickItem.Checked = true;
|
this.barSubPictureSizeMode.Caption = sizeMode.ToString();
|
this.curvePictureBoxCtrl1.SetPictureSizeMode(sizeMode);
|
};
|
|
this.barSubPictureSizeMode.AddItem(barCheckItem);
|
if (sizeMode == PictureBoxSizeMode.StretchImage)
|
{
|
barCheckItem.Checked = true;
|
this.barSubPictureSizeMode.Caption = sizeMode.ToString();
|
this.curvePictureBoxCtrl1.SetPictureSizeMode(sizeMode);
|
}
|
}
|
}
|
|
private enum eCurveGetWay
|
{
|
[Display(Name = "全部")]
|
All,
|
[Display(Name = "流量扬程/功率,分析效率")]
|
QhQpAnaQe,
|
[Display(Name = "流量扬程/效率,分析功率")]
|
QhQeAnaQp,
|
[Display(Name = "仅流量扬程线")]
|
OnlyQh
|
}
|
private eCurveGetWay _curveGetWay = eCurveGetWay.All;
|
|
private AStation.Chart.ePumpFeatType _curveType = AStation.Chart.ePumpFeatType.QH;
|
private List<AStation.Curve.CurvePoint> _picQHPoints = null;
|
private List<AStation.Curve.CurvePoint> _picQPPoints = null;
|
private List<AStation.Curve.CurvePoint> _picQEPoints = null;
|
|
private AStation.Curve.eFitType _fitTypeQH, _fitTypeQP, _fitTypeQE;
|
private Rectangle? _rectQH, _rectQP, _rectQE;
|
|
|
|
/// <summary>
|
/// 初始化数据
|
/// </summary>
|
public void SetBindingData()
|
{
|
this.repimgCmbGetWay.AddEnum(typeof(eCurveGetWay), false);
|
this.barEditImgCmbGetWay.EditValue = _curveGetWay;
|
|
this.repimgCmbSourceFrom.AddEnum(typeof(AStation.Chart.eSourceWay), false);
|
this.barEditImgCmbSourceFrom.EditValue = AStation.Chart.eSourceWay.厂家提供;
|
|
this.repImgCmbUnitQ.AddEnum(typeof(Unit.eUnitQ), false);
|
this.barEditImgCmbUnitQ.EditValue = this.curvePictureBoxCtrl1.UnitQ;
|
|
this.imgCmbQHFitType.Properties.AddEnum(typeof(AStation.Curve.eFitType), false);
|
this.imgCmbQHFitType.EditValue = AStation.Curve.eFitType.CubicCurve;
|
|
this.imgCmbQPFitType.Properties.AddEnum(typeof(AStation.Curve.eFitType), false);
|
this.imgCmbQPFitType.EditValue = AStation.Curve.eFitType.CubicCurve;
|
|
this.imgCmbQEFitType.Properties.AddEnum(typeof(AStation.Curve.eFitType), false);
|
this.imgCmbQEFitType.EditValue = AStation.Curve.eFitType.CubicCurve;
|
}
|
|
//曲线获取方法
|
private void repimgCmbGetWay_SelectedValueChanged(object sender, EventArgs e)
|
{
|
_curveGetWay = (eCurveGetWay)this.barEditImgCmbGetWay.EditValue;
|
switch (_curveGetWay)
|
{
|
case eCurveGetWay.QhQpAnaQe:
|
{
|
_rectQE = null;
|
_picQEPoints = null;
|
this.layoutControlGroupQH.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
|
this.layoutControlGroupQP.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
|
this.layoutControlGroupQE.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
|
}
|
break;
|
case eCurveGetWay.QhQeAnaQp:
|
{
|
_rectQP = null;
|
_picQPPoints = null;
|
this.layoutControlGroupQH.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
|
this.layoutControlGroupQP.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
|
this.layoutControlGroupQE.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
|
}
|
break;
|
case eCurveGetWay.OnlyQh:
|
{
|
_rectQE = null;
|
_rectQP = null;
|
_picQPPoints = null;
|
_picQEPoints = null;
|
this.layoutControlGroupQH.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
|
this.layoutControlGroupQP.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
|
this.layoutControlGroupQE.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
|
}
|
break;
|
case eCurveGetWay.All:
|
{
|
this.layoutControlGroupQH.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
|
this.layoutControlGroupQP.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
|
this.layoutControlGroupQE.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
|
}
|
break;
|
}
|
}
|
|
//流量单位变换
|
private void repImgCmbUnitQ_SelectedValueChanged(object sender, EventArgs e)
|
{
|
this.curvePictureBoxCtrl1.UnitQ = (Unit.eUnitQ)this.barEditImgCmbUnitQ.EditValue;
|
}
|
|
//导入图片
|
private void barBtnImportPicture_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var dlg = new OpenFileDialog();
|
dlg.Filter = "*.BMP;*.JPG;*.GIF;*.PNG|*.BMP;*.JPG;*.GIF;*.PNG";
|
if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
|
return;
|
this.curvePictureBoxCtrl1.SetBindingData(dlg.FileName);
|
this.curvePictureBoxCtrl1.Enabled = true;
|
}
|
|
//框选坐标
|
private void barBtnSetCoordinates_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
this.curvePictureBoxCtrl1.StartSelectionRange();
|
this.barCekPickPoint.Checked = false;
|
}
|
|
//坐标框选完成
|
private void CurvePictureBoxCtrl1_ReloadBoundaryEvent(System.Drawing.Rectangle? obj)
|
{
|
switch (_curveType)
|
{
|
case AStation.Chart.ePumpFeatType.QH:
|
_rectQH = obj;
|
break;
|
case AStation.Chart.ePumpFeatType.QE:
|
_rectQE = obj;
|
break;
|
case AStation.Chart.ePumpFeatType.QP:
|
_rectQP = obj;
|
break;
|
}
|
}
|
//抓取点
|
private void barCekPickPoint_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
if (this.barCekPickPoint.Checked)
|
{
|
if (!ReloadChartCoordinate())
|
{
|
this.barCekPickPoint.Checked = false;
|
XtraMessageBox.Show("请输入坐标!");
|
return;
|
}
|
this.curvePictureBoxCtrl1.StartPickPoint();
|
}
|
else
|
{
|
this.curvePictureBoxCtrl1.EndPickPoint();
|
}
|
}
|
|
//刷新图表坐标
|
private bool ReloadChartCoordinate()
|
{
|
if (this.barEditTxtMinQ.EditValue == null || this.barEditTxtMaxQ.EditValue == null)
|
return false;
|
this.curvePictureBoxCtrl1.ChartMinX = Convert.ToDouble(this.barEditTxtMinQ.EditValue);
|
this.curvePictureBoxCtrl1.ChartMaxX = Convert.ToDouble(this.barEditTxtMaxQ.EditValue);
|
switch (_curveType)
|
{
|
case AStation.Chart.ePumpFeatType.QH:
|
{
|
if (this.txtMaxH.EditValue == null || this.txtMinH.EditValue == null)
|
{
|
return false;
|
}
|
this.curvePictureBoxCtrl1.ChartMaxY = Convert.ToDouble(this.txtMaxH.EditValue);
|
this.curvePictureBoxCtrl1.ChartMinY = Convert.ToDouble(this.txtMinH.EditValue);
|
}
|
break;
|
case AStation.Chart.ePumpFeatType.QE:
|
{
|
if (this.txtMaxE.EditValue == null || this.txtMinE.EditValue == null)
|
{
|
return false;
|
}
|
this.curvePictureBoxCtrl1.ChartMaxY = Convert.ToDouble(this.txtMaxE.EditValue);
|
this.curvePictureBoxCtrl1.ChartMinY = Convert.ToDouble(this.txtMinE.EditValue);
|
}
|
break;
|
case AStation.Chart.ePumpFeatType.QP:
|
{
|
if (this.txtMaxP.EditValue == null || this.txtMinP.EditValue == null)
|
{
|
return false;
|
}
|
this.curvePictureBoxCtrl1.ChartMaxY = Convert.ToDouble(this.txtMaxP.EditValue);
|
this.curvePictureBoxCtrl1.ChartMinY = Convert.ToDouble(this.txtMinP.EditValue);
|
}
|
break;
|
}
|
return true;
|
}
|
|
//清空点
|
private void barBtnClear_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
this.curvePictureBoxCtrl1.ClearPickPoint();
|
}
|
|
//预览曲线
|
private void barBtnPreviewCurve_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
if (!GetCurve(out string curveCode, out AStation.Chart.eSourceWay eCurveSourceFrom, out Model.PumpCurveInfo featCurveExpressGroup))
|
return;
|
var dlg = new PreviewCurveDlg();
|
dlg.SetBindingData(featCurveExpressGroup);
|
dlg.ShowDialog();
|
}
|
|
//选择曲线变换时
|
private void tabbedControlGroup1_SelectedPageChanging(object sender, DevExpress.XtraLayout.LayoutTabPageChangingEventArgs e)
|
{
|
this.curvePictureBoxCtrl1.GetPicPoints(out List<AStation.Curve.CurvePoint> clickPoints);
|
if (e.PrevPage == this.layoutControlGroupQH)
|
{
|
_picQHPoints = clickPoints;
|
}
|
else if (e.PrevPage == this.layoutControlGroupQP)
|
{
|
_picQPPoints = clickPoints;
|
}
|
else if (e.PrevPage == this.layoutControlGroupQE)
|
{
|
_picQEPoints = clickPoints;
|
}
|
}
|
|
//选择曲线变换
|
private void tabbedControlGroup1_SelectedPageChanged(object sender, DevExpress.XtraLayout.LayoutTabPageChangedEventArgs e)
|
{
|
this.barCekPickPoint.Checked = false;
|
if (e.Page == this.layoutControlGroupQH)
|
{
|
_curveType = AStation.Chart.ePumpFeatType.QH;
|
ReloadChartCoordinate();
|
this.curvePictureBoxCtrl1.CurrentCaptureCruve = AStation.Chart.ePumpFeatType.QH;
|
this.curvePictureBoxCtrl1.CurrentCaptureCruveFitType = _fitTypeQH;
|
this.curvePictureBoxCtrl1.RefreshPictureShape(_picQHPoints, _rectQH);
|
|
}
|
else if (e.Page == this.layoutControlGroupQP)
|
{
|
_curveType = AStation.Chart.ePumpFeatType.QP;
|
ReloadChartCoordinate();
|
this.curvePictureBoxCtrl1.CurrentCaptureCruve = AStation.Chart.ePumpFeatType.QP;
|
this.curvePictureBoxCtrl1.CurrentCaptureCruveFitType = _fitTypeQP;
|
this.curvePictureBoxCtrl1.RefreshPictureShape(_picQPPoints, _rectQP);
|
|
}
|
else if (e.Page == this.layoutControlGroupQE)
|
{
|
_curveType = AStation.Chart.ePumpFeatType.QE;
|
ReloadChartCoordinate();
|
this.curvePictureBoxCtrl1.CurrentCaptureCruve = AStation.Chart.ePumpFeatType.QE;
|
this.curvePictureBoxCtrl1.CurrentCaptureCruveFitType = _fitTypeQE;
|
this.curvePictureBoxCtrl1.RefreshPictureShape(_picQEPoints, _rectQE);
|
}
|
}
|
|
//打点等效线
|
private void cekCaputueEtaPtInEqupCurve_CheckedChanged(object sender, EventArgs e)
|
{
|
this.curvePictureBoxCtrl1.IsCaputueEtaPtInEqupCurve = this.cekCaputueEtaPtInEqupCurve.Checked;
|
}
|
|
//打点更新数据
|
private void CurvePictureBoxCtrl1_ReloadPickPointsEvent(List<AStation.Curve.CurvePoint> list)
|
{
|
switch (_curveType)
|
{
|
case AStation.Chart.ePumpFeatType.QH:
|
_picQHPoints = list;
|
break;
|
case AStation.Chart.ePumpFeatType.QE:
|
_picQEPoints = list;
|
break;
|
case AStation.Chart.ePumpFeatType.QP:
|
_picQPPoints = list;
|
break;
|
}
|
}
|
|
|
public event Action<string, AStation.Chart.eSourceWay, Model.PumpCurveInfo> ReloadDataEvent;
|
|
private void barBtnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
if (!GetCurve(out string curveCode, out AStation.Chart.eSourceWay eCurveSourceFrom, out Model.PumpCurveInfo featCurveExpressGroup))
|
return;
|
this?.ReloadDataEvent.Invoke(curveCode, eCurveSourceFrom, featCurveExpressGroup);
|
}
|
|
#region 拟合方式下拉变换
|
|
private void imgCmbQHFitType_SelectedValueChanged(object sender, EventArgs e)
|
{
|
this.curvePictureBoxCtrl1.CurrentCaptureCruveFitType = _fitTypeQH = (AStation.Curve.eFitType)this.imgCmbQHFitType.EditValue;
|
}
|
|
private void imgCmbQPFitType_SelectedValueChanged(object sender, EventArgs e)
|
{
|
this.curvePictureBoxCtrl1.CurrentCaptureCruveFitType = _fitTypeQP = (AStation.Curve.eFitType)this.imgCmbQPFitType.EditValue;
|
}
|
|
private void imgCmbQEFitType_SelectedValueChanged(object sender, EventArgs e)
|
{
|
this.curvePictureBoxCtrl1.CurrentCaptureCruveFitType = _fitTypeQE = (AStation.Curve.eFitType)this.imgCmbQEFitType.EditValue;
|
}
|
|
|
#endregion
|
|
#region 方法
|
|
//获取曲线
|
public bool GetCurve(out string curveCode, out AStation.Chart.eSourceWay eCurveSourceFrom, out Model.PumpCurveInfo featCurveExpressGroup)
|
{
|
curveCode = null;
|
featCurveExpressGroup = null;
|
eCurveSourceFrom = eSourceWay.厂家提供;
|
if (this.barEditTxtCurveCode.EditValue == null)
|
{
|
XtraMessageBox.Show("请输入曲线编码!");
|
return false;
|
}
|
|
|
curveCode = this.barEditTxtCurveCode.EditValue.ToString();
|
eCurveSourceFrom = (AStation.Chart.eSourceWay)this.barEditImgCmbSourceFrom.EditValue;
|
switch (_curveGetWay)
|
{
|
case eCurveGetWay.All:
|
{
|
if (_picQHPoints == null || _picQHPoints.Count < 4)
|
{
|
XtraMessageBox.Show("请录入流量扬程点!");
|
return false;
|
}
|
|
if (_picQPPoints == null || _picQPPoints.Count < 4)
|
{
|
XtraMessageBox.Show("请录入流量功率点!");
|
return false;
|
}
|
if (_picQEPoints == null || _picQEPoints.Count < 4)
|
{
|
XtraMessageBox.Show("请录入流量效率点!");
|
return false;
|
}
|
}
|
break;
|
case eCurveGetWay.QhQpAnaQe:
|
{
|
if (_picQHPoints == null || _picQHPoints.Count < 4)
|
{
|
XtraMessageBox.Show("请录入流量扬程点!");
|
return false;
|
}
|
|
if (_picQPPoints == null || _picQPPoints.Count < 4)
|
{
|
XtraMessageBox.Show("请录入流量功率点!");
|
return false;
|
}
|
}
|
break;
|
case eCurveGetWay.QhQeAnaQp:
|
{
|
if (_picQHPoints == null || _picQHPoints.Count < 4)
|
{
|
XtraMessageBox.Show("请录入流量扬程点!");
|
return false;
|
}
|
|
if (_picQEPoints == null || _picQEPoints.Count < 4)
|
{
|
XtraMessageBox.Show("请录入流量效率点!");
|
return false;
|
}
|
}
|
break;
|
case eCurveGetWay.OnlyQh:
|
{
|
if (_picQHPoints == null || _picQHPoints.Count < 4)
|
{
|
XtraMessageBox.Show("请录入流量扬程点!");
|
return false;
|
}
|
}
|
break;
|
default:
|
break;
|
}
|
|
|
var fitTypeQH = (AStation.Curve.eFitType)this.imgCmbQHFitType.EditValue;
|
var fitTypeQP = (AStation.Curve.eFitType)this.imgCmbQPFitType.EditValue;
|
var fitTypeQE = (AStation.Curve.eFitType)this.imgCmbQEFitType.EditValue;
|
|
var curvePointsQH = new List<AStation.Curve.CurvePoint>();
|
var curvePointsQE = new List<AStation.Curve.CurvePoint>();
|
var curvePointsQP = new List<AStation.Curve.CurvePoint>();
|
|
var picPointsQH = new List<AStation.Curve.CurvePoint>();
|
var picPointsQE = new List<AStation.Curve.CurvePoint>();
|
var picPointsQP = new List<AStation.Curve.CurvePoint>();
|
|
|
|
var unitQ = this.curvePictureBoxCtrl1.UnitQ;
|
double MinQ = 0;
|
double MaxQ = 0;
|
|
if (this.curvePictureBoxCtrl1.ChartMinX == 0)
|
MinQ = 0;
|
else
|
MinQ = _picQHPoints.Min(x => x.X);
|
|
MaxQ = _picQHPoints.Max(x => x.X);
|
|
//换算单位
|
MinQ = Unit.UnitQHelper.Convert(unitQ, Unit.eUnitQ.M3H, MinQ);
|
MaxQ = Unit.UnitQHelper.Convert(unitQ, Unit.eUnitQ.M3H, MaxQ);
|
picPointsQH = ToM3H(unitQ, _picQHPoints);
|
picPointsQE = ToM3H(unitQ, _picQEPoints);
|
picPointsQP = ToM3H(unitQ, _picQPPoints);
|
|
|
int insert_num = 15;
|
double space = (MaxQ - MinQ) / (insert_num - 1);
|
int i = 0;
|
double Q = MinQ;
|
double H, E = 0, P = 0;
|
for (i = 1; i < insert_num - 1; i++)
|
{
|
Q = Q + space;
|
H = picPointsQH.GetFitPointY(fitTypeQH, Q);
|
curvePointsQH.Add(new AStation.Curve.CurvePoint(Q, H));
|
|
if (_curveGetWay != eCurveGetWay.OnlyQh)
|
{
|
switch (_curveGetWay)
|
{
|
case eCurveGetWay.All:
|
{
|
|
P = picPointsQP.GetFitPointY(fitTypeQP, Q);
|
E = picPointsQE.GetFitPointY(fitTypeQE, Q);
|
}
|
break;
|
case eCurveGetWay.QhQpAnaQe:
|
{
|
P = picPointsQP.GetFitPointY(fitTypeQP, Q);
|
E = AStation.Curve.PumpCalculateHelper.CalculateE(Q, H, P);
|
}
|
break;
|
case eCurveGetWay.QhQeAnaQp:
|
{
|
E = picPointsQE.GetFitPointY(fitTypeQE, Q);
|
P = AStation.Curve.PumpCalculateHelper.CalculateP(Q, H, E);
|
}
|
break;
|
}
|
|
curvePointsQP.Add(new AStation.Curve.CurvePoint(Q, P));
|
curvePointsQE.Add(new AStation.Curve.CurvePoint(Q, E));
|
}
|
}
|
|
if (_curveGetWay == eCurveGetWay.OnlyQh)
|
{
|
if (curvePointsQH.Count < 3)
|
{
|
XtraMessageBox.Show("未导入足够多的性能曲线点");
|
return false;
|
}
|
}
|
else
|
{
|
if (curvePointsQH.Count < 3 || curvePointsQE.Count < 3 || curvePointsQP.Count < 3)
|
{
|
curvePointsQH = null;
|
curvePointsQE = null;
|
curvePointsQP = null;
|
XtraMessageBox.Show("未导入足够多的性能曲线点");
|
return false;
|
}
|
}
|
|
|
|
#region 首尾两点的处理:因为首尾2点按流量扬程获取范围,而点击不一定正好首尾2点流量一样
|
//流量扬程首尾两点
|
double startH = AStation.Curve.CurveLineHelper.GetYbyX(curvePointsQH[0].X, curvePointsQH[0].Y, curvePointsQH[1].X, curvePointsQH[1].Y, MinQ);
|
curvePointsQH.Insert(0, new AStation.Curve.CurvePoint(MinQ, startH));
|
|
int point_num = curvePointsQH.Count;//不一定和insert_num一样
|
double endH = AStation.Curve.CurveLineHelper.GetYbyX(curvePointsQH[point_num - 2].X, curvePointsQH[point_num - 2].Y,
|
curvePointsQH[point_num - 1].X, curvePointsQH[point_num - 1].Y, MaxQ);
|
curvePointsQH.Add(new AStation.Curve.CurvePoint(MaxQ, endH));
|
|
if (curvePointsQE != null && curvePointsQE.Count > 0)
|
{
|
//流量效率首尾两点
|
double startE = 0;//起始点
|
if (MinQ > 0.2)
|
startE = AStation.Curve.CurveLineHelper.GetYbyX(curvePointsQE[0].X, curvePointsQE[0].Y, curvePointsQE[1].X, curvePointsQE[1].Y, MinQ);
|
else
|
startE = 0;
|
curvePointsQE.Insert(0, new AStation.Curve.CurvePoint(MinQ, startE));
|
|
point_num = curvePointsQE.Count;//末尾点
|
double endE = AStation.Curve.CurveLineHelper.GetYbyX(curvePointsQE[point_num - 2].X, curvePointsQE[point_num - 2].Y,
|
curvePointsQE[point_num - 1].X, curvePointsQE[point_num - 1].Y, MaxQ);
|
curvePointsQE.Add(new AStation.Curve.CurvePoint(MaxQ, endE));
|
}
|
|
if (curvePointsQP != null && curvePointsQP.Count > 0)
|
{
|
//流量功率首尾两点
|
double startP = AStation.Curve.CurveLineHelper.GetYbyX(curvePointsQP[0].X, curvePointsQP[0].Y, curvePointsQP[1].X, curvePointsQP[1].Y, MinQ);
|
curvePointsQP.Insert(0, new AStation.Curve.CurvePoint(MinQ, startP));
|
|
point_num = curvePointsQP.Count;
|
double endP = AStation.Curve.CurveLineHelper.GetYbyX(curvePointsQP[point_num - 2].X, curvePointsQP[point_num - 2].Y,
|
curvePointsQP[point_num - 1].X, curvePointsQP[point_num - 1].Y, MaxQ);
|
curvePointsQP.Add(new AStation.Curve.CurvePoint(MaxQ, endP));
|
}
|
#endregion
|
|
|
//圆整
|
curvePointsQH = Regulate(curvePointsQH, 2);
|
curvePointsQE = Regulate(curvePointsQE, 2);
|
curvePointsQP = Regulate(curvePointsQP, 2);
|
|
|
featCurveExpressGroup = new Model.PumpCurveInfo();
|
featCurveExpressGroup.CurveQH = AStation.Curve.FitHelper.BuildCurveExpress(curvePointsQH, fitTypeQH);
|
featCurveExpressGroup.CurveQE = AStation.Curve.FitHelper.BuildCurveExpress(curvePointsQE, fitTypeQE);
|
featCurveExpressGroup.CurveQP = AStation.Curve.FitHelper.BuildCurveExpress(curvePointsQP, fitTypeQP);
|
|
return true;
|
}
|
|
//单位换算
|
private List<AStation.Curve.CurvePoint> ToM3H(Unit.eUnitQ unit, List<AStation.Curve.CurvePoint> points)
|
{
|
if (unit == Unit.eUnitQ.M3H)
|
{
|
return points;
|
}
|
|
if (points == null)
|
{
|
return null;
|
}
|
|
var list = new List<AStation.Curve.CurvePoint>();
|
for (int i = 0; i < points.Count; i++)
|
{
|
var point = new AStation.Curve.CurvePoint(points[i]);
|
point.X = Unit.UnitQHelper.Convert(unit, Unit.eUnitQ.M3H, point.X);
|
list.Add(point);
|
}
|
return list;
|
}
|
|
//四舍五入圆整,如 0.44 -> 0.4 , 0.46 -> 0.5//flag--小数点后位数
|
public static List<AStation.Curve.CurvePoint> Regulate(List<AStation.Curve.CurvePoint> inPoints, int flag)
|
{
|
if (inPoints == null)
|
return null;
|
List<AStation.Curve.CurvePoint> outPoints = new List<AStation.Curve.CurvePoint>();
|
for (int i = 0; i < inPoints.Count(); i++)
|
{
|
outPoints.Add(new AStation.Curve.CurvePoint(Regulate(inPoints[i].X, flag), Regulate(inPoints[i].Y, flag)));
|
}
|
return outPoints;
|
}
|
|
//四舍五入圆整,如 0.44 -> 0.4 , 0.46 -> 0.5//flag--小数点后位数
|
public static double Regulate(double v, int flag)
|
{
|
bool isNegative = false;
|
//如果是负数
|
if (v < 0)
|
{
|
isNegative = true;
|
v = Math.Abs(v);
|
}
|
else
|
{
|
isNegative = false;
|
}
|
|
double value = Math.Round(v, flag);
|
if (isNegative)
|
{
|
value = -value;
|
}
|
return value;
|
}
|
|
#endregion
|
|
|
|
}
|
}
|