|
using System;
|
using System.Collections.Generic;
|
using System.Drawing;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace IStation.WinFrmUI.CalcErQu.ViewModel
|
{
|
internal class PumpCurveInfo
|
{
|
public int PumpIndex { get; set; }
|
public long ID { get; set; }
|
public string Name { get; set; }
|
public int Status { get; set; }
|
|
|
public IStation.Model.CurveExpress CurveExpressQH { get; set; }
|
public IStation.Model.CurveExpress CurveExpressQE { get; set; }
|
public IStation.Model.CurveExpress CurveExpressQP { get; set; }
|
|
public List<IStation.Model.CurvePoint> PointsQH { get; set; }
|
public List<IStation.Model.CurvePoint> PointsQE { get; set; }
|
public List<IStation.Model.CurvePoint> PointsQP { get; set; }
|
|
public bool IsDispCurveName { get; set; } = false;
|
|
public IStation.Model.CurvePoint LabelPosiName { get; set; }
|
|
|
|
public string CurveName { get; set; }
|
public Color CurveColor
|
{
|
get
|
{
|
return _curveColor;
|
}
|
set
|
{
|
_curveColor = value;
|
}
|
}
|
protected Color _curveColor = Color.Black;
|
|
|
|
|
/// <summary>
|
///
|
/// </summary>
|
public IStation.Model.Pump RatedParas { get; set; }
|
/// <summary>
|
/// 曲线信息
|
/// </summary>
|
public IStation.Model.FeatCurveExpressGroup CurveInfo { get; set; }
|
/// <summary>
|
///
|
/// </summary>
|
public List<IStation.Model.GroupPoint> GroupPoints { get { return _grpPoints; } set {
|
_grpPoints = value;
|
maxHead = (from yyy in _grpPoints select yyy.H).Max();
|
minHead = (from yyy in _grpPoints select yyy.H).Min();
|
groupPointCount = _grpPoints.Count;
|
} }
|
double maxHead, minHead;
|
int groupPointCount = 0;
|
List<IStation.Model.GroupPoint> _grpPoints = null;
|
public IStation.Model.GroupPoint GetPointByH(double h)
|
{
|
//在范围内
|
if (h <= maxHead && h >= minHead)
|
{
|
return GetInterPointExX(h);
|
}
|
|
//判断是否在前面的延长部分
|
double x_start = IStation.Untity.LineHelper.GetXbyY(_grpPoints[0].Q, _grpPoints[0].H, _grpPoints[1].Q, _grpPoints[1].H, h);
|
if (x_start <= _grpPoints[0].Q)
|
{
|
if (x_start > 0 && x_start > _grpPoints[0].Q * 0.5)//放一点余量
|
{
|
IStation.Model.GroupPoint grpPt = new IStation.Model.GroupPoint();
|
grpPt.Q = x_start;
|
grpPt.H = h;
|
grpPt.P = _grpPoints[0].P;
|
return grpPt;
|
}
|
}
|
|
//判断是否在后面的延长部分:U型曲线 是前后都有
|
double x_end = IStation.Untity.LineHelper.GetXbyY(_grpPoints[_grpPoints.Count - 2].Q, _grpPoints[_grpPoints.Count - 2].H, _grpPoints[_grpPoints.Count - 1].Q, _grpPoints[_grpPoints.Count - 1].H, h);
|
if (x_end >= _grpPoints[_grpPoints.Count - 1].Q && x_end < _grpPoints[_grpPoints.Count - 1].Q * 2)//放一点余量
|
{
|
IStation.Model.GroupPoint grpPt = new IStation.Model.GroupPoint();
|
grpPt.Q = x_end;
|
grpPt.H = h;
|
grpPt.P = _grpPoints[_grpPoints.Count - 1].P;
|
return grpPt;
|
}
|
|
return null;
|
}
|
|
//获得Y值的坐标位置,可能有多个点(是线形插值,不是曲线上的点):会计算延长部分:而且要求_grpPoints点按照从小到大排序
|
public IStation.Model.GroupPoint GetInterPointExX( double H)
|
{
|
if (GroupPoints == null)
|
return null;
|
List<double> sect_pts = new List<double>();
|
foreach (var pt in GroupPoints)
|
{
|
if (Math.Abs(pt.H - H) < 0.02)
|
return pt ;
|
}
|
|
for (int i = 0; i < groupPointCount - 1; i++)//少一个点
|
{
|
if ((H >= _grpPoints[i].H && H <= _grpPoints[i + 1].H) || (H <= _grpPoints[i].H && H >= _grpPoints[i + 1].H))
|
{//直线插值
|
double Q;
|
if (Math.Abs(_grpPoints[i].H - _grpPoints[i + 1].H) < 0.01)
|
Q = (_grpPoints[i].Q + _grpPoints[i + 1].Q) * 0.5;
|
else
|
Q = _grpPoints[i].Q + (_grpPoints[i + 1].Q - _grpPoints[i].Q) * (H - _grpPoints[i].H) / (_grpPoints[i + 1].H - _grpPoints[i].H);
|
|
double P = _grpPoints[i].P + (_grpPoints[i + 1].P - _grpPoints[i].P) * (Q - _grpPoints[i].Q) / (_grpPoints[i + 1].Q - _grpPoints[i].Q);
|
|
return new Model.GroupPoint() { Q = Q, P = P , H= H };
|
}
|
}
|
|
|
|
return null ;
|
}
|
|
}
|
}
|