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