using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.Security.Permissions; using System.Text; namespace IStation.Model { public class LxpCurveGroupExpress : ICloneable { #region 构造函数 public LxpCurveGroupExpress() { } public LxpCurveGroupExpress(LxpCurveGroupExpress rhs) { if (rhs._curveExpressQH != null) this._curveExpressQH = rhs._curveExpressQH.Clone(); if (rhs._curveExpressQE != null) this._curveExpressQE = rhs._curveExpressQE.Clone(); if (rhs._curveExpressQP != null) this._curveExpressQP = rhs._curveExpressQP.Clone(); if (rhs._curveExpressNPSH != null) this._curveExpressNPSH = rhs._curveExpressNPSH.Clone(); if (rhs._curveExpressNPSHmin != null) this._curveExpressNPSHmin = rhs._curveExpressNPSHmin.Clone(); this.Name = rhs.Name; } public LxpCurveGroupExpress(string strGroup) { if (string.IsNullOrEmpty(strGroup)) return; string[] strParas = strGroup.Split(new char[] { '|' }, StringSplitOptions.None);//不能去掉空格 int iCount = strParas.Count(); if (iCount < 5) return; this.Type = 1;//这个1 表示是离心泵性能曲线 (eCurveGroupType)Convert.ToInt32(strParas[1]); if (!string.IsNullOrEmpty(strParas[2])) this.CurveExpressQH = new CurveExpress(strParas[2]); if (!string.IsNullOrEmpty(strParas[3])) this.CurveExpressQE = new CurveExpress(strParas[3]); if (!string.IsNullOrEmpty(strParas[4])) this.CurveExpressQP = new CurveExpress(strParas[4]); if (!string.IsNullOrEmpty(strParas[5])) { this.CurveExpressNPSH = new CurveExpressStartLine(strParas[5]); } if (strParas.Count() >= 7) { if (!string.IsNullOrEmpty(strParas[6])) this.CurveExpressNPSHmin = new CurveExpressStartLine(strParas[6]); } if (strParas.Count() >= 8) { this.Name = strParas[7]; } } // public LxpCurveGroupExpress(List points) { if (points == null || points.Count < 3) { return; } List pointInfoQH = new List(); List pointInfoQE = new List(); List pointInfoQP = new List(); List pointInfoNPSH = new List(); for (int i = 0; i < points.Count; i++) { var pt = points[i]; pointInfoQH.Add(new IStation.Model.CurvePoint(pt.Q, pt.H)); if (pt.E >= 0) pointInfoQE.Add(new IStation.Model.CurvePoint(pt.Q, pt.E)); if (pt.E >= 0) pointInfoQP.Add(new IStation.Model.CurvePoint(pt.Q, pt.P)); if (pt.NPSH > 0) pointInfoNPSH.Add(new IStation.Model.CurvePoint(pt.Q, pt.NPSH)); } if (pointInfoNPSH.Count < 3) { SetCurveInfo(pointInfoQH, pointInfoQE, pointInfoQP, null, null); } else { SetCurveInfo(pointInfoQH, pointInfoQE, pointInfoQP, pointInfoNPSH, null); } } public LxpCurveGroupExpress(List pointInfoQH, List pointInfoQE, List pointInfoQP, List pointInfoNPSH, List pointInfoNPSHmin = null) { SetCurveInfo(pointInfoQH, pointInfoQE, pointInfoQP, pointInfoNPSH, pointInfoNPSHmin); } public LxpCurveGroupExpress( List pointInfoQH, IStation.Model.eCurveFitType fitTypeQH, List pointInfoQE, IStation.Model.eCurveFitType fitTypeQE, List pointInfoQP, IStation.Model.eCurveFitType fitTypeQP, List pointInfoNPSH, List pointInfoNPSHmin, IStation.Model.eCurveFitType fitTypeNPSH) { SetCurveInfo(pointInfoQH, fitTypeQH, pointInfoQE, fitTypeQE, pointInfoQP, fitTypeQP, pointInfoNPSH, pointInfoNPSHmin, fitTypeNPSH); } public void SetCurveInfo(List pointInfoQH, List pointInfoQE, List pointInfoQP, List pointInfoNPSH, List pointInfoNPSHmin = null) { this.Type = 1; this.CurveExpressQH = IStation.Model.CurveExpress.ToParameter(pointInfoQH); this.CurveExpressQE = IStation.Model.CurveExpress.ToParameter(pointInfoQE); this.CurveExpressQP = IStation.Model.CurveExpress.ToParameter(pointInfoQP); this.CurveExpressNPSH = IStation.Model.CurveExpressStartLine.ToParameter(pointInfoNPSH); this.CurveExpressNPSHmin = IStation.Model.CurveExpressStartLine.ToParameter(pointInfoNPSHmin); } public void SetCurveInfo( List pointInfoQH, IStation.Model.eCurveFitType fitTypeQH, List pointInfoQE, IStation.Model.eCurveFitType fitTypeQE, List pointInfoQP, IStation.Model.eCurveFitType fitTypeQP, List pointInfoNPSH, List pointInfoNPSHmin, IStation.Model.eCurveFitType fitTypeNPSH) { this.Type = 1; this.CurveExpressQH = IStation.Model.CurveExpress.ToParameter(pointInfoQH, fitTypeQH); this.CurveExpressQE = IStation.Model.CurveExpress.ToParameter(pointInfoQE, fitTypeQE); this.CurveExpressQP = IStation.Model.CurveExpress.ToParameter(pointInfoQP, fitTypeQP); this.CurveExpressNPSH = IStation.Model.CurveExpressStartLine.ToParameter(pointInfoNPSH, fitTypeNPSH); this.CurveExpressNPSHmin = IStation.Model.CurveExpressStartLine.ToParameter(pointInfoNPSHmin, fitTypeNPSH); } #endregion 构造函数 #region Model private CurveExpress _curveExpressQH = null; private CurveExpress _curveExpressQE = null; private CurveExpress _curveExpressQP = null; private CurveExpressStartLine _curveExpressNPSH = null; private CurveExpressStartLine _curveExpressNPSHmin = null; [DataMember] public int Type { get { return _type; } set { _type = value; } } private int _type; [DataMember] public CurveExpress CurveExpressQH { get { return _curveExpressQH; } set { _curveExpressQH = value; } } [DataMember] public CurveExpress CurveExpressQE { get { return _curveExpressQE; } set { _curveExpressQE = value; } } [DataMember] public CurveExpress CurveExpressQP { get { return _curveExpressQP; } set { _curveExpressQP = value; } } [DataMember] public CurveExpressStartLine CurveExpressNPSH { get { return _curveExpressNPSH; } set { _curveExpressNPSH = value; } } [DataMember] public CurveExpressStartLine CurveExpressNPSHmin { get { return _curveExpressNPSHmin; } set { _curveExpressNPSHmin = value; } } [DataMember] public string Name { get { return _name; } set { if (string.IsNullOrEmpty(value)) _name = null; else _name = value.Replace("|", "").Replace(",", ""); } } private string _name; #endregion Model public List ToGroupPoints(int PointNumber) { double space = (this.CurveExpressQH.Max - this.CurveExpressQH.Min) / (PointNumber - 1); List points = new List(); for (int i = 0; i < PointNumber; i++) { double q = space * i + this.CurveExpressQH.Min; double h = IStation.Model.FitCurveHelper.GetFitPointY(this.CurveExpressQH, q); double e = IStation.Model.FitCurveHelper.GetFitPointY(this.CurveExpressQE, q); double p = IStation.Model.FitCurveHelper.GetFitPointY(this.CurveExpressQP, q); points.Add(new GroupPoint(0, q, h, e, p)); } return points; } public static List ToGroupPoints(LxpCurveGroupExpress curve, int PointNumber) { if (curve == null) return null; return curve.ToGroupPoints(PointNumber); } //50HZ->60HZ public LxpCurveGroupExpress From50to60HZ() { return SimuBySpeed(1.2); } //相似换算(speed_ratio = 新的转速 除以 老的转速) public LxpCurveGroupExpress SimuBySpeed(double speed_ratio) { int PointNumber = 16; double space = (this.CurveExpressQH.Max - this.CurveExpressQH.Min) / (PointNumber - 1); //IStation.Common.SimuSpeedStdCalcer calc = new Common.SimuSpeedStdCalcer(); List pointInfoQH = new List(); List pointInfoQE = new List(); List pointInfoQP = new List(); for (int i = 0; i < PointNumber; i++) { double q50 = space * i + this.CurveExpressQH.Min; double h50 = IStation.Model.FitCurveHelper.GetFitPointY(this.CurveExpressQH, q50); double e50 = IStation.Model.FitCurveHelper.GetFitPointY(this.CurveExpressQE, q50); double p50 = IStation.Model.FitCurveHelper.GetFitPointY(this.CurveExpressQP, q50); double q60 = q50 * speed_ratio; double h60 = h50 * speed_ratio * speed_ratio; double e60 = e50; double p60 = p50 * speed_ratio * speed_ratio * speed_ratio; pointInfoQH.Add(new CurvePoint() { X = q60, Y = h60 }); pointInfoQE.Add(new CurvePoint() { X = q60, Y = e60 }); pointInfoQP.Add(new CurvePoint() { X = q60, Y = p60 }); } LxpCurveGroupExpress newCurve = new LxpCurveGroupExpress(); newCurve.CurveExpressQH = new CurveExpress(pointInfoQH); newCurve.CurveExpressQE = new CurveExpress(pointInfoQE); newCurve.CurveExpressQP = new CurveExpress(pointInfoQP); //if (this.CurveExpressNPSH != null) // newCurve.CurveExpressNPSH = this.CurveExpressNPSH.SimuBySpeed(eFeatCurveType.QNPSH, speed_ratio); //if (this.CurveExpressNPSHmin != null) // newCurve.CurveExpressNPSHmin = this.CurveExpressNPSHmin.SimuBySpeed(eFeatCurveType.QNPSH, speed_ratio); return newCurve; } #region Clone public LxpCurveGroupExpress Clone() { LxpCurveGroupExpress newGroup = new LxpCurveGroupExpress(); newGroup.Type = _type; if (_curveExpressQH != null) newGroup.CurveExpressQH = _curveExpressQH.Clone(); if (_curveExpressQE != null) newGroup.CurveExpressQE = _curveExpressQE.Clone(); if (_curveExpressQP != null) newGroup.CurveExpressQP = _curveExpressQP.Clone(); if (_curveExpressNPSH != null) newGroup.CurveExpressNPSH = _curveExpressNPSH.Clone(); if (_curveExpressNPSHmin != null) newGroup.CurveExpressNPSHmin = _curveExpressNPSHmin.Clone(); return newGroup; } object ICloneable.Clone() { return new LxpCurveGroupExpress(this); } #endregion Clone #region ToDsString public string ToDsString() { if (IsEmpty()) return null; return ToDsString(this); } public static string ToDsString(CurveExpress pointInfoQH, CurveExpress pointInfoQE, CurveExpress pointInfoQP, CurveExpressStartLine pointInfoNPSH, CurveExpressStartLine pointInfoNPSHmin, string name) { StringBuilder sb = new StringBuilder(); sb.Append("1|");//这个1 表示是离心泵性能曲线 int type = 1;//eCurveGroupType schema = GetGroupType(pointInfoQH, pointInfoQE, pointInfoQP, pointInfoNPSH, pointInfoNPSHmin); sb.Append((int)type); if (pointInfoQH == null) return null; sb.Append("|"); sb.Append(pointInfoQH.ToDsString()); sb.Append("|"); if (pointInfoQE != null) sb.Append(pointInfoQE.ToDsString()); sb.Append("|"); if (pointInfoQP != null) sb.Append(pointInfoQP.ToDsString()); sb.Append("|"); if (pointInfoNPSH != null) sb.Append(pointInfoNPSH.ToDsString()); sb.Append("|"); if (pointInfoNPSHmin != null) sb.Append(pointInfoNPSHmin.ToDsString()); sb.Append("|"); if (!string.IsNullOrEmpty(name)) sb.Append(name); return sb.ToString(); } public static string ToDsString(LxpCurveGroupExpress express) { if (express == null) return null; return ToDsString(express.CurveExpressQH, express.CurveExpressQE, express.CurveExpressQP, express.CurveExpressNPSH, express.CurveExpressNPSHmin, express.Name); } public static string ToDsString(List pointInfoQH, List pointInfoQE, List pointInfoQP, List pointInfoNPSH, List pointInfoNPSHmin) { StringBuilder sb = new StringBuilder(); sb.Append("1|");//这个1 表示是离心泵性能曲线 int type = 1;// GetGroupType(pointInfoQH, pointInfoQE, pointInfoQP, pointInfoNPSH, pointInfoNPSHmin); sb.Append((int)type); if (pointInfoQH == null || pointInfoQH.Count < 3) return null; sb.Append("|"); sb.Append(IStation.Model.CurveExpress.ToDsString(pointInfoQH)); sb.Append("|"); sb.Append(IStation.Model.CurveExpress.ToDsString(pointInfoQE)); sb.Append("|"); sb.Append(IStation.Model.CurveExpress.ToDsString(pointInfoQP)); sb.Append("|"); sb.Append(IStation.Model.CurveExpress.ToDsString(pointInfoNPSH)); sb.Append("|"); sb.Append(IStation.Model.CurveExpress.ToDsString(pointInfoNPSHmin)); return sb.ToString(); } #endregion ToDsString #region Serialization public const int schema = 11; protected LxpCurveGroupExpress(SerializationInfo info, StreamingContext context) { //int sch = info.GetInt32("schema"); this.Type = info.GetInt32("Type"); string strQH = info.GetString("QH"); if (!string.IsNullOrEmpty(strQH)) this.CurveExpressQH = new CurveExpress(strQH); string strQE = info.GetString("QE"); if (!string.IsNullOrEmpty(strQE)) this.CurveExpressQE = new CurveExpress(strQE); string strQP = info.GetString("QP"); if (!string.IsNullOrEmpty(strQP)) this.CurveExpressQP = new CurveExpress(strQP); string strNPSH = info.GetString("NPSH"); if (!string.IsNullOrEmpty(strNPSH)) this.CurveExpressNPSH = new CurveExpressStartLine(strNPSH); string strNPSHmin = info.GetString("NPSHmin"); if (!string.IsNullOrEmpty(strNPSHmin)) this.CurveExpressNPSH = new CurveExpressStartLine(strNPSHmin); this.Name = info.GetString("Name"); } [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("schema", schema); info.AddValue("Type", Type); info.AddValue("QH", CurveExpressQH == null ? "" : CurveExpressQH.ToDsString()); info.AddValue("QE", CurveExpressQE == null ? "" : CurveExpressQE.ToDsString()); info.AddValue("QP", CurveExpressQP == null ? "" : CurveExpressQP.ToDsString()); info.AddValue("NPSH", CurveExpressNPSH == null ? "" : CurveExpressNPSH.ToDsString()); info.AddValue("NPSHmin", CurveExpressNPSHmin == null ? "" : CurveExpressNPSHmin.ToDsString()); info.AddValue("Name", Name); } #endregion Serialization public bool IsEmpty() { if (_curveExpressQH == null && _curveExpressQE == null && _curveExpressQP == null && _curveExpressNPSH == null) return true; else return false; } public bool IsEqual(LxpCurveGroupExpress rhs) { if (rhs == null) return false; return this.ToDsString().Equals(rhs.ToDsString()); } /// /// 根据QH的最大流量点 切割 效率 功率 汽蚀线 /// public void AlignMaxFlowByQH() { if (this._curveExpressQH == null) return; if (this._curveExpressQH.FitType == eCurveFitType.ThroughPoint) return;//暂时只处理拟合的情况 var max_flow = this._curveExpressQH.Max; if (this._curveExpressQE != null && this._curveExpressQE.FitType == eCurveFitType.ConicCurve) { if (this._curveExpressQE.Max > max_flow) this._curveExpressQE.Max = max_flow; } if (this._curveExpressQP != null && this._curveExpressQP.FitType == eCurveFitType.ConicCurve) { if (this._curveExpressQP.Max > max_flow) this._curveExpressQP.Max = max_flow; } //if (this._curveExpressNPSH != null && this._curveExpressNPSH.FitType == eCurveFitType.ConicCurve) //{ // if (this._curveExpressNPSH.Max > max_flow) // this._curveExpressNPSH.Max = max_flow; //} } } }