duheng
2024-04-22 a549072a040749f7c732c83d2d0f138614ac08e5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
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<IStation.Model.GroupPoint> points)
        {
            if (points == null || points.Count < 3)
            {
                return;
            }
            List<IStation.Model.CurvePoint> pointInfoQH = new List<IStation.Model.CurvePoint>();
            List<IStation.Model.CurvePoint> pointInfoQE = new List<IStation.Model.CurvePoint>();
            List<IStation.Model.CurvePoint> pointInfoQP = new List<IStation.Model.CurvePoint>();
            List<IStation.Model.CurvePoint> pointInfoNPSH = new List<IStation.Model.CurvePoint>();
 
            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<IStation.Model.CurvePoint> pointInfoQH,
             List<IStation.Model.CurvePoint> pointInfoQE, List<IStation.Model.CurvePoint> pointInfoQP,
             List<IStation.Model.CurvePoint> pointInfoNPSH, List<IStation.Model.CurvePoint> pointInfoNPSHmin = null)
        {
            SetCurveInfo(pointInfoQH, pointInfoQE, pointInfoQP, pointInfoNPSH, pointInfoNPSHmin);
        }
 
        public LxpCurveGroupExpress(
            List<IStation.Model.CurvePoint> pointInfoQH, IStation.Model.eCurveFitType fitTypeQH,
            List<IStation.Model.CurvePoint> pointInfoQE, IStation.Model.eCurveFitType fitTypeQE,
            List<IStation.Model.CurvePoint> pointInfoQP, IStation.Model.eCurveFitType fitTypeQP,
            List<IStation.Model.CurvePoint> pointInfoNPSH, List<IStation.Model.CurvePoint> pointInfoNPSHmin, IStation.Model.eCurveFitType fitTypeNPSH)
        {
            SetCurveInfo(pointInfoQH, fitTypeQH, pointInfoQE, fitTypeQE, pointInfoQP, fitTypeQP, pointInfoNPSH, pointInfoNPSHmin, fitTypeNPSH);
        }
 
        public void SetCurveInfo(List<IStation.Model.CurvePoint> pointInfoQH,
         List<IStation.Model.CurvePoint> pointInfoQE, List<IStation.Model.CurvePoint> pointInfoQP,
         List<IStation.Model.CurvePoint> pointInfoNPSH, List<IStation.Model.CurvePoint> 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<IStation.Model.CurvePoint> pointInfoQH, IStation.Model.eCurveFitType fitTypeQH,
    List<IStation.Model.CurvePoint> pointInfoQE, IStation.Model.eCurveFitType fitTypeQE,
    List<IStation.Model.CurvePoint> pointInfoQP, IStation.Model.eCurveFitType fitTypeQP,
    List<IStation.Model.CurvePoint> pointInfoNPSH, List<IStation.Model.CurvePoint> 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<GroupPoint> ToGroupPoints(int PointNumber)
        {
            double space = (this.CurveExpressQH.Max - this.CurveExpressQH.Min) / (PointNumber - 1);
            List<GroupPoint> points = new List<GroupPoint>();
            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<GroupPoint> 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<IStation.Model.CurvePoint> pointInfoQH = new List<CurvePoint>();
            List<IStation.Model.CurvePoint> pointInfoQE = new List<CurvePoint>();
            List<IStation.Model.CurvePoint> pointInfoQP = new List<CurvePoint>();
            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<IStation.Model.CurvePoint> pointInfoQH, List<IStation.Model.CurvePoint> pointInfoQE, List<IStation.Model.CurvePoint> pointInfoQP, List<IStation.Model.CurvePoint> pointInfoNPSH, List<IStation.Model.CurvePoint> 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());
        }
 
        /// <summary>
        /// 根据QH的最大流量点 切割 效率 功率 汽蚀线
        /// </summary>
        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;
            //}
        }
    }
}