ÎļþÃû´Ó WinFrmUI/Yw.WinFrmUI.Phart.Core/01-perform/99-models/02-group_point/PumpPerformGroupPoint.cs ÐÞ¸Ä |
| | |
| | | namespace Yw.WinFrmUI.Phart |
| | | { |
| | | public class PumpPerformGroupPoint : ICloneable |
| | | public class PumpGroupPt : ICloneable |
| | | { |
| | | private int id = 0; |
| | | public int ID { get { return id; } set { id = value; } } |
| | |
| | | public double P { get; set; } |
| | | public double NPSH { get { return _npsh; } set { _npsh = value; } } |
| | | private double _npsh = -1; |
| | | public PumpPerformGroupPoint() { } |
| | | public PumpPerformGroupPoint(PumpPerformGroupPoint rhs) |
| | | public PumpGroupPt() { } |
| | | public PumpGroupPt(PumpGroupPt rhs) |
| | | { |
| | | this.ID = rhs.ID; |
| | | this.Q = rhs.Q; |
| | |
| | | this.P = rhs.P; |
| | | this.NPSH = rhs.NPSH; |
| | | } |
| | | public PumpPerformGroupPoint(string dsString) |
| | | public PumpGroupPt(string dsString) |
| | | { |
| | | ResetParas(dsString); |
| | | } |
| | |
| | | NPSH = Convert.ToDouble(paras[5]); |
| | | return true; |
| | | } |
| | | public static PumpPerformGroupPoint ToParameter(string dsString) |
| | | public static PumpGroupPt ToParameter(string dsString) |
| | | { |
| | | if (string.IsNullOrEmpty(dsString)) return null; |
| | | if (dsString.Contains("|")) |
| | |
| | | if (iCount < 2) |
| | | return null; |
| | | |
| | | return PumpPerformGroupPoint.ToParameter(strParas[1]);//åé»è®¤ç¬¬ä¸ä¸ªæåå³å¯ |
| | | return PumpGroupPt.ToParameter(strParas[1]);//åé»è®¤ç¬¬ä¸ä¸ªæåå³å¯ |
| | | } |
| | | |
| | | var paras = dsString.Split(','); |
| | | if (paras.Count() < 5) |
| | | return null; |
| | | PumpPerformGroupPoint pt = new PumpPerformGroupPoint(); |
| | | PumpGroupPt pt = new (); |
| | | pt.ID = Convert.ToInt32(paras[0]); |
| | | pt.Q = Convert.ToDouble(paras[1]); |
| | | pt.H = Convert.ToDouble(paras[2]); |
| | |
| | | } |
| | | |
| | | |
| | | public PumpPerformGroupPoint(int id, double q, double h, double e, double p) |
| | | public PumpGroupPt(int id, double q, double h, double e, double p) |
| | | { |
| | | ID = id; |
| | | Q = q; |
| | |
| | | E = e; |
| | | P = p; |
| | | } |
| | | public PumpPerformGroupPoint(int id, double q, double h, double e, double p, double npsh) |
| | | public PumpGroupPt(int id, double q, double h, double e, double p, double npsh) |
| | | { |
| | | ID = id; |
| | | Q = q; |
| | |
| | | return string.Format("{0},{1},{2},{3},{4},{5}", ID, Q, H, E, P, NPSH); |
| | | } |
| | | |
| | | public PumpPerformGroupPoint RoundAll(int decimals) |
| | | public PumpGroupPt RoundAll(int decimals) |
| | | { |
| | | this.Q = Math.Round(this.Q, decimals); |
| | | this.H = Math.Round(this.H, decimals); |
| | |
| | | this.NPSH = Math.Round(this.NPSH, decimals); |
| | | return this; |
| | | } |
| | | public PumpPerformGroupPoint RoundAll_Small(int decimals, double small = 2) |
| | | public PumpGroupPt RoundAll_Small(int decimals, double small = 2) |
| | | { |
| | | if (this.Q < small) |
| | | this.Q = Math.Round(this.Q, 3); |
| | |
| | | } |
| | | |
| | | #region Clone |
| | | public PumpPerformGroupPoint Clone() //坹夿ä¾ä¸ä¸ªå建èªèº«çæµ
è¡¨å¯æ¬çè½å |
| | | public PumpGroupPt Clone() //坹夿ä¾ä¸ä¸ªå建èªèº«çæµ
è¡¨å¯æ¬çè½å |
| | | { |
| | | return (PumpPerformGroupPoint)this.MemberwiseClone(); |
| | | return (PumpGroupPt)this.MemberwiseClone(); |
| | | } |
| | | object ICloneable.Clone() |
| | | { |
| | |
| | | } |
| | | |
| | | //æåºæ¹æ³ |
| | | public class Comparer : IComparer<PumpPerformGroupPoint> |
| | | public class Comparer : IComparer<PumpGroupPt> |
| | | { |
| | | private eSortType sortType; |
| | | public Comparer(eSortType type = eSortType.Q) |
| | |
| | | } |
| | | |
| | | #region IComparer<GroupPoint> æå |
| | | int IComparer<PumpPerformGroupPoint>.Compare(PumpPerformGroupPoint obj1, PumpPerformGroupPoint obj2) |
| | | int IComparer<PumpGroupPt>.Compare(PumpGroupPt obj1, PumpGroupPt obj2) |
| | | { |
| | | if (sortType == eSortType.ID) |
| | | { |
| | |
| | | } |
| | | |
| | | //æ¯è¾ç¸å:主è¦ç¨ä¸LISTçContainsæ¹æ³ |
| | | public class EqualComparer : IEqualityComparer<PumpPerformGroupPoint> |
| | | public class EqualComparer : IEqualityComparer<PumpGroupPt> |
| | | { |
| | | private double ignoreDis = 0.001; |
| | | public EqualComparer() |
| | |
| | | { |
| | | ignoreDis = dis; |
| | | } |
| | | public bool Equals(PumpPerformGroupPoint lhs, PumpPerformGroupPoint rhs) |
| | | public bool Equals(PumpGroupPt lhs, PumpGroupPt rhs) |
| | | { |
| | | if (Math.Abs(lhs.Q - rhs.Q) < ignoreDis && Math.Abs(lhs.H - rhs.H) < ignoreDis) |
| | | return true; |
| | |
| | | return false; |
| | | } |
| | | |
| | | public int GetHashCode(PumpPerformGroupPoint obj) |
| | | public int GetHashCode(PumpGroupPt obj) |
| | | { |
| | | return 0; |
| | | // return obj.H.GetHashCode() + obj.Q.GetHashCode(); |