using System.Runtime.Serialization;
|
|
namespace IStation.Model
|
{
|
//两端有直线端延长:主要用于气蚀 , 气蚀开始端有一点直线
|
[DataContract]
|
public class CurveExpressStartLine : CurveExpress, ICloneable
|
{
|
#region 构造函数
|
public CurveExpressStartLine() { }
|
public CurveExpressStartLine(CurveExpressStartLine rhs)
|
{
|
this.fitPow = rhs.fitPow;
|
this.fitType = rhs.fitType;
|
this.Min = rhs.Min;
|
this.Max = rhs.Max;
|
this.Index0 = rhs.Index0;
|
this.Index1 = rhs.Index1;
|
this.Index2 = rhs.Index2;
|
this.Index3 = rhs.Index3;
|
|
this.StartLineX1 = rhs.StartLineX1;
|
this.StartLineY1 = rhs.StartLineY1;
|
this.StartLineX2 = rhs.StartLineX2;
|
this.StartLineY2 = rhs.StartLineY2;
|
|
this.DefinePoints = rhs.DefinePoints;
|
}
|
|
public CurveExpressStartLine(CurveExpress rhs)
|
{
|
if (rhs == null)
|
return;
|
this.fitPow = rhs.FitPow;
|
this.fitType = rhs.FitType;
|
this.Min = rhs.Min;
|
this.Max = rhs.Max;
|
this.Index0 = rhs.Index0;
|
this.Index1 = rhs.Index1;
|
this.Index2 = rhs.Index2;
|
this.Index3 = rhs.Index3;
|
if (rhs is CurveExpressStartLine)
|
{
|
var rhs2 = rhs as CurveExpressStartLine;
|
this.StartLineX1 = rhs2.StartLineX1;
|
this.StartLineY1 = rhs2.StartLineY1;
|
this.StartLineX2 = rhs2.StartLineX2;
|
this.StartLineY2 = rhs2.StartLineY2;
|
}
|
else
|
{
|
this.StartLineX1 = 0;
|
this.StartLineY1 = 0;
|
this.StartLineX2 = 0;
|
this.StartLineY2 = 0;
|
}
|
this.DefinePoints = rhs.DefinePoints;
|
}
|
public CurveExpressStartLine(List<IStation.Model.CurvePoint> pointInfo)
|
: base(pointInfo)
|
{
|
if (pointInfo == null || pointInfo.Count() < 4)
|
return;
|
this.StartLineX1 = 0;
|
this.StartLineY1 = 0;
|
this.StartLineX2 = 0;
|
this.StartLineY2 = 0;
|
|
var firstPtY = pointInfo.First().Y;
|
int sameXindex = 0;
|
for (int i = 1; i < pointInfo.Count; i++)
|
{
|
if (Math.Abs(pointInfo[i].Y - firstPtY) < 0.01)
|
sameXindex = i;
|
else
|
break;
|
}
|
if (sameXindex == 0)
|
return;
|
|
this.StartLineX1 = pointInfo[0].X;
|
this.StartLineY1 = firstPtY;
|
this.StartLineX2 = pointInfo[sameXindex].X;
|
this.StartLineY2 = firstPtY;
|
|
this.DefinePoints = new CurvePointList(pointInfo);
|
|
if (this.fitType == eCurveFitType.ThroughPoint && pointInfo != null && pointInfo.Count > 0)
|
{
|
this.Max = pointInfo.Last().X;
|
}
|
}
|
|
public CurveExpressStartLine(List<IStation.Model.CurvePoint> pointInfo, IStation.Model.eCurveFitType fitType)
|
: base(pointInfo, fitType)
|
{
|
if (pointInfo == null || pointInfo.Count() < 4)
|
return;
|
this.StartLineX1 = 0;
|
this.StartLineY1 = 0;
|
this.StartLineX2 = 0;
|
this.StartLineY2 = 0;
|
|
var firstPtY = pointInfo.First().Y;
|
int sameXindex = 0;
|
for (int i = 1; i < pointInfo.Count; i++)
|
{
|
if (Math.Abs(pointInfo[i].Y - firstPtY) < 0.01)
|
sameXindex = i;
|
else
|
break;
|
}
|
if (sameXindex == 0)
|
return;
|
|
this.StartLineX1 = pointInfo[0].X;
|
this.StartLineY1 = firstPtY;
|
this.StartLineX2 = pointInfo[sameXindex].X;
|
this.StartLineY2 = firstPtY;
|
|
this.DefinePoints = new CurvePointList(pointInfo);
|
|
if (this.fitType == eCurveFitType.ThroughPoint && pointInfo != null && pointInfo.Count > 0)
|
{
|
this.Max = pointInfo.Last().X;
|
}
|
}
|
public CurveExpressStartLine(string strExpress)
|
{
|
if (string.IsNullOrEmpty(strExpress))
|
{
|
isNull = true;
|
return;
|
}
|
|
string[] str_list = strExpress.Split(new string[] { Separator }, StringSplitOptions.RemoveEmptyEntries);
|
var count = str_list.Count();
|
if (count < 8)
|
{
|
this.IsNull = true;
|
return;
|
}
|
isNull = false;
|
|
this.IsNull = false;
|
this.FitPow = Convert.ToInt32(str_list[0]);
|
this.FitType = (eCurveFitType)Convert.ToInt32(str_list[1]);
|
this.Min = Convert.ToDouble(str_list[2]);
|
this.Max = Convert.ToDouble(str_list[3]);
|
this.Index0 = Convert.ToDouble(str_list[4]);
|
this.Index1 = Convert.ToDouble(str_list[5]);
|
this.Index2 = Convert.ToDouble(str_list[6]);
|
this.Index3 = Convert.ToDouble(str_list[7]);
|
|
if (count > 8)
|
{
|
this.DefinePoints = CurvePoint.ToList(str_list[8], new string[] { "DefinePointsStart", "DefinePointsStart" });
|
}
|
for (int i = 7; i < count; i++)
|
{
|
if (str_list[i] == "StartLineStart")
|
{
|
this.StartLineX1 = Convert.ToDouble(str_list[i + 1]);
|
this.StartLineY1 = Convert.ToDouble(str_list[i + 2]);
|
this.StartLineX2 = Convert.ToDouble(str_list[i + 3]);
|
this.StartLineY2 = Convert.ToDouble(str_list[i + 4]);
|
break;
|
}
|
|
if (str_list[i] == "StartLineEnd")
|
{
|
break;
|
}
|
}
|
for (int i = 7; i < count; i++)
|
{
|
if (str_list[i] == "DefinePointsStart")
|
{
|
this.DefinePoints = new CurvePointList();
|
for (int k = i + 1; k < count; k = k + 2)
|
{
|
if (str_list[k] == "DefinePointsEnd" || str_list[k + 1] == "DefinePointsEnd")
|
break;
|
this.DefinePoints.Add(new CurvePoint(Convert.ToDouble(str_list[k]), Convert.ToDouble(str_list[k + 1])));
|
}
|
if (this.Max < 0.001)
|
{
|
this.Max = (from x in this.DefinePoints select x.X).Max();
|
this.Min = (from x in this.DefinePoints select x.X).Min();
|
}
|
break;
|
}
|
if (str_list[i] == "DefinePointsEnd")
|
{
|
break;
|
}
|
}
|
|
if (this.fitType == eCurveFitType.ThroughPoint && this.DefinePoints != null && this.DefinePoints.Count > 0)
|
{
|
this.Max = this.DefinePoints.Last().X;
|
}
|
|
|
}
|
|
public static new CurveExpressStartLine ToParameter(List<IStation.Model.CurvePoint> pointInfoNPSH)
|
{
|
if (pointInfoNPSH == null || pointInfoNPSH.Count < 3)
|
return null;
|
|
if (pointInfoNPSH != null && pointInfoNPSH.Count >= 3)
|
{
|
if (pointInfoNPSH.Count == 3)
|
{
|
List<IStation.Model.CurvePoint> fivePtNPSH = IStation.Common.LxpFeatCurveHelper.ToFivePoints(pointInfoNPSH);
|
return new CurveExpressStartLine(fivePtNPSH);//IStation.Common.FitCurveHelper.GetFitPoints(fivePtNPSH);
|
}
|
else
|
{
|
return new CurveExpressStartLine(pointInfoNPSH);//IStation.Common.FitCurveHelper.GetFitPoints(fivePtNPSH);
|
}
|
}
|
else
|
{
|
return null;
|
}
|
}
|
|
public static new CurveExpressStartLine ToParameter(List<IStation.Model.CurvePoint> pointInfoNPSH, IStation.Model.eCurveFitType fitType)
|
{
|
if (pointInfoNPSH == null || pointInfoNPSH.Count < 3)
|
return null;
|
if (fitType == eCurveFitType.ThroughPoint)
|
{
|
return new CurveExpressStartLine(pointInfoNPSH, fitType);
|
}
|
if (pointInfoNPSH != null && pointInfoNPSH.Count >= 3)
|
{
|
if (pointInfoNPSH.Count == 3)
|
{
|
List<IStation.Model.CurvePoint> fivePtNPSH = IStation.Common.LxpFeatCurveHelper.ToFivePoints(pointInfoNPSH);
|
return new CurveExpressStartLine(fivePtNPSH);
|
}
|
else
|
{
|
return new CurveExpressStartLine(pointInfoNPSH, fitType);
|
}
|
}
|
else
|
{
|
return null;
|
}
|
}
|
|
#endregion
|
|
[DataMember]
|
public double StartLineX1 { get { return _startLineX1; } set { _startLineX1 = value; } }
|
private double _startLineX1 = 0;//前端直线部分的长度
|
|
[DataMember]
|
public double StartLineX2 { get { return _startLineX2; } set { _startLineX2 = value; } }
|
private double _startLineX2 = 0;//前端直线部分的长度
|
|
[DataMember]
|
public double StartLineY1 { get { return _startLineY1; } set { _startLineY1 = value; } }
|
private double _startLineY1 = 0;//前端直线部分的长度
|
|
[DataMember]
|
public double StartLineY2 { get { return _startLineY2; } set { _startLineY2 = value; } }
|
private double _startLineY2 = 0;//前端直线部分的长度
|
|
|
public bool IsHaveStartLine()
|
{
|
if (Math.Abs(this.StartLineY1 - this.StartLineY2) < 0.05)
|
{
|
if (this.StartLineX2 <= this.Max)
|
{
|
if (this.StartLineX1 < this.StartLineX2)
|
return true;
|
else
|
return false;
|
}
|
else
|
return false;
|
}
|
else
|
return false;
|
}
|
|
#region Clone
|
object ICloneable.Clone()
|
{
|
return Clone();
|
}
|
|
public new CurveExpressStartLine Clone()
|
{
|
return new CurveExpressStartLine(this);
|
}
|
#endregion
|
|
public new string ToDsString()
|
{
|
return ToDsString(this);
|
}
|
public static new string ToDsString(List<IStation.Model.CurvePoint> points)
|
{
|
if (points == null || points.Count < 3)
|
return null;
|
|
CurveExpressStartLine express = ToParameter(points);
|
return ToDsString(express);
|
}
|
public static string ToDsString(CurveExpressStartLine express)
|
{
|
if (express == null)
|
return null;
|
if (express.IsNull)
|
return null;
|
|
var str_list = new List<string>();
|
str_list.Add(express.FitPow.ToString());
|
str_list.Add(((int)express.FitType).ToString());
|
str_list.Add(express.Min.ToString());
|
str_list.Add(express.Max.ToString());
|
str_list.Add(express.Index0.ToString());
|
str_list.Add(express.Index1.ToString("0.00000"));
|
str_list.Add(express.Index2.ToString("0.0000000000"));
|
str_list.Add(express.Index3.ToString("0.00000000000000"));
|
if (express.DefinePoints != null && express.DefinePoints.Count > 0)
|
{
|
str_list.Add(express.DefinePoints.ToDsString());
|
}
|
|
if (express.DefinePoints != null && express.DefinePoints.Count > 1)
|
{
|
str_list.Add("DefinePointsStart");//加个标识,表示定义点开始
|
foreach (var pt in express.DefinePoints)
|
{
|
str_list.Add(pt.X.ToString());
|
str_list.Add(pt.Y.ToString());
|
}
|
str_list.Add("DefinePointsEnd");//加个标识,表示定义点已经结束
|
}
|
|
|
return string.Join(Separator, str_list);
|
|
|
}
|
|
public static new CurveExpressStartLine ToParameter(string strExpress)
|
{
|
if (string.IsNullOrEmpty(strExpress))
|
return null;
|
|
var exp = new Model.CurveExpressStartLine(strExpress);
|
if (exp.IsNull)
|
return null;
|
return exp;
|
}
|
|
public bool IsEuqal(CurveExpressStartLine rhs)
|
{
|
if (rhs == null)
|
return false;
|
if (rhs.ToDsString() == this.ToDsString())
|
return true;
|
else
|
return false;
|
}
|
|
|
public bool IsNoEuqal(CurveExpressStartLine rhs)
|
{
|
if (rhs == null)
|
return true;
|
if (rhs.ToDsString() == this.ToDsString())
|
return false;
|
else
|
return true;
|
}
|
public CurveExpressStartLine From50to60HZ(IStation.Model.eFeatCurveType type)
|
{
|
return SimuBySpeed(type, 1.2);
|
}
|
//相似换算(speed_ratio = 新的转速 除以 老的转速)
|
public CurveExpressStartLine SimuBySpeed(IStation.Model.eFeatCurveType type, double speed_ratio)
|
{
|
int PointNumber = 16;
|
double space = (this.Max - this.Min) / (PointNumber - 1);
|
|
List<IStation.Model.CurvePoint> pointInfo60 = new List<CurvePoint>();
|
for (int i = 0; i < PointNumber; i++)
|
{
|
double q50 = space * i + this.Min;
|
double Y50 = IStation.Model.FitCurveHelper.GetFitPointY(this, q50);
|
|
double q60 = q50 * speed_ratio;
|
|
pointInfo60.Add(new CurvePoint() { X = q60, Y = Y50 });
|
|
|
}
|
|
var new_curve = new IStation.Model.CurveExpressStartLine(pointInfo60);
|
if (this.DefinePoints != null && this.DefinePoints.Count > 0)
|
{
|
new_curve.DefinePoints = new CurvePointList();
|
foreach (var pt in this.DefinePoints)
|
{
|
new_curve.DefinePoints.Add(new CurvePoint() { X = pt.X * speed_ratio, Y = pt.Y });
|
}
|
}
|
|
|
return new_curve;
|
}
|
|
|
}
|
}
|