tangxu
2024-01-27 29a6de30e328c46cbbcae15066f449b0660c2db1
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Text;
 
namespace Yw.Coordinate
{
    public class LxpCoordinateParas
    {
        public LxpCoordinateParas() { }
 
        public LxpCoordinateParas(string strChartCoord)
        {
            try
            {
                if (string.IsNullOrEmpty(strChartCoord))
                {
                    isNull = true;
                    return;
                }
 
                string[] coords = strChartCoord.Split('|');
                if (coords.Count() < 6)
                {
                    isNull = true;
                    return;
                }
 
                //
                string sbQ = coords[0];
                string[] coordParasQ = sbQ.Split(',');
                //coordParasQ[0] =1 表示均匀 默认就是均匀的
                //this.UnitQ = Convert.ToInt32(coordParasQ[1]);
                this.GridNumberX = Convert.ToInt32(coordParasQ[2]);
                this.CoordMinQ = Convert.ToDouble(coordParasQ[3]);
                this.CoordSpaceQ = Convert.ToDouble(coordParasQ[4]);
 
 
                //
                string sbY = coords[1];
                string[] coordParasY = sbY.Split(',');
                //coordParasQ[0] =1 表示均匀:默认就是均匀的
                this.GridNumberY = Convert.ToInt32(coordParasY[1]);
 
                //H
                string sbH = coords[2];
                string[] coordParasH = sbH.Split(',');
                //this.UnitH = (UnitH)Convert.ToInt32(coordParasH[0]);
                this.CoordMinH =  Convert.ToDouble(coordParasH[1]) ;
                this.CoordSpaceH = Convert.ToDouble(coordParasH[2]);
                this.StartLineNoH = Convert.ToInt32(coordParasH[3]);
                this.EndLineNoH = Convert.ToInt32(coordParasH[4]);
 
                //Eff
                string sbE = coords[3];
                string[] coordParasE = sbE.Split(',');
                // this.UnitE = (UnitE)Convert.ToInt32(coordParasE[0]);
                this.CoordMinE =  Convert.ToDouble(coordParasE[1]) ;
                this.CoordSpaceE = Convert.ToDouble(coordParasE[2]);
                this.StartLineNoE = Convert.ToInt32(coordParasE[3]);
                this.EndLineNoE = Convert.ToInt32(coordParasE[4]);
                if (this.CoordSpaceE < 0.01)
                    this.CoordSpaceE = 10;
                if (this.EndLineNoE == 0)
                    this.EndLineNoE = 10;
 
                //Power
                string sbP = coords[4];
                string[] coordParasP = sbP.Split(',');
                // paras.UnitP = (UnitE)Convert.ToInt32(coordParasP[0]);
                this.CoordMinP =  Convert.ToDouble(coordParasP[1]) ;
                this.CoordSpaceP = Convert.ToDouble(coordParasP[2]);
                this.StartLineNoP = Convert.ToInt32(coordParasP[3]);
                this.EndLineNoP = Convert.ToInt32(coordParasP[4]);
                if (this.CoordSpaceP < 0.001)
                    this.CoordSpaceP = 10;
                if (this.EndLineNoP == 0)
                    this.EndLineNoP = 5;
 
                //QNPSH
                string sbNPSH = coords[5];
                string[] coordParasNPSH = sbNPSH.Split(',');
                // this.UnitNPSH = (UnitH)Convert.ToInt32(coordParasNPSH[0]);
                this.CoordMinNPSH = Convert.ToDouble(coordParasNPSH[1]);
                this.CoordSpaceNPSH = Convert.ToDouble(coordParasNPSH[2]);
                this.StartLineNoNPSH = Convert.ToInt32(coordParasNPSH[3]);
                this.EndLineNoNPSH = Convert.ToInt32(coordParasNPSH[4]);
                if (this.CoordSpaceNPSH < 0.1)
                    this.CoordSpaceNPSH = 1;
                if (this.EndLineNoNPSH == 0)
                    this.EndLineNoNPSH = 5;
 
                if (coords.Count() > 6)
                {//大于6
                    string sbPanel = coords[6];
                    string[] coordParasPanel = sbPanel.Split(',');
                    this.DispStyle = Convert.ToInt32(coordParasPanel[0]);
                    var num1 = Convert.ToInt32(coordParasPanel[1]);
                    if (num1 > 0)//不能是0 为了兼容老数据, 老的数据里面是0
                        this.DislocationNumUp = num1;
 
                    var num2 = Convert.ToInt32(coordParasPanel[2]);
                    if (num2 > 0)
                        this.DislocationNumDown = num2;
                }
            }
            catch (Exception)
            {
                isNull = true;
                return;
            }
        }
 
        public LxpCoordinateParas(LxpCoordinateParas rhs)
        {
            if (rhs == null)
            {
                return;
            }
 
 
            this.UnitQ = rhs.UnitQ;
            this.GridNumberX = rhs.GridNumberX;
            this.CoordMinQ = rhs.CoordMinQ;
            this.CoordSpaceQ = rhs.CoordSpaceQ;
 
            //
            this.GridNumberY = rhs.GridNumberY;
 
            //H
            this.UnitH = rhs.UnitH;
            this.CoordMinH = rhs.CoordMinH;
            this.CoordSpaceH = rhs.CoordSpaceH;
            this.StartLineNoH = rhs.StartLineNoH;
            this.EndLineNoH = rhs.EndLineNoH;
 
            //Eff
            this.CoordMinE = rhs.CoordMinE;
            this.CoordSpaceE = rhs.CoordSpaceE;
            this.StartLineNoE = rhs.StartLineNoE;
            this.EndLineNoE = rhs.EndLineNoE;
 
 
            //Power
            this.CoordMinP = rhs.CoordMinP;
            this.CoordSpaceP = rhs.CoordSpaceP;
            this.StartLineNoP = rhs.StartLineNoP;
            this.EndLineNoP = rhs.EndLineNoP;
 
 
            //QNPSH
            this.CoordMinNPSH = rhs.CoordMinNPSH;
            this.CoordSpaceNPSH = rhs.CoordSpaceNPSH;
            this.StartLineNoNPSH = rhs.StartLineNoNPSH;
            this.EndLineNoNPSH = rhs.EndLineNoNPSH;
 
            this.DispStyle = rhs.DispStyle;
            this.DislocationNumUp = rhs.DislocationNumUp;
            this.DislocationNumDown = rhs.DislocationNumDown;
        }
 
 
        //得到空白的坐标值
        public static LxpCoordinateParas GetBlankCoordinate()
        {
            LxpCoordinateParas para = new LxpCoordinateParas();
            para.GridNumberX = 30;
            para.GridNumberY = 16;
 
            //显示的坐标线号
            para.StartLineNoH = 10;
            para.EndLineNoH = 15;
 
            para.StartLineNoE = 0;
            para.EndLineNoE = 10;
 
            para.StartLineNoP = 2;
            para.EndLineNoP = 9;
 
            //坐标最小值和间隔
            para.CoordMinQ = 0; para.CoordSpaceQ = 1000;
            para.CoordMinH = 10; para.CoordSpaceH = 100;
            para.CoordMinE = 0; para.CoordSpaceE = 100;
            para.CoordMinP = 10; para.CoordSpaceP = 100;
 
            return para;
        }
 
 
        //坐标间隔数,坐标线会比坐标间隔数多一
        public int GridNumberX = 30;//X坐标
        public int GridNumberY = 16;//Y坐标
 
        //显示的坐标线号
        public int StartLineNoH;
        public int EndLineNoH;
 
        public int StartLineNoE;
        public int EndLineNoE;
 
        public int StartLineNoP;
        public int EndLineNoP;
 
        public int StartLineNoNPSH;
        public int EndLineNoNPSH;
 
        //面板显示设置
        public int DispStyle = 0;//显示风格 0 跟随系统: 以后拓展
        public int DislocationNumUp = 2;//扬程效率刻度 错位数  (QH和QE坐标的错位) 就是QH下面的空格数 
        public int DislocationNumDown = 1;//气蚀功率刻度 错位数
 
 
        //坐标最小值和间隔
        public double CoordMinQ, CoordSpaceQ;
        public double CoordMinH, CoordSpaceH;
        public double CoordMinE, CoordSpaceE;
        public double CoordMinP, CoordSpaceP;
        public double CoordMinNPSH, CoordSpaceNPSH;
 
        //
        public double DispMaxQ()
        {
            return this.CoordMinQ + this.GridNumberX * this.CoordSpaceQ;
        }
 
        public double DispMinH()
        {
            return this.CoordMinH + this.StartLineNoH * this.CoordSpaceH;
        }
        public double DispMaxH()
        {
            return this.CoordMinH + this.EndLineNoH * this.CoordSpaceH;
        }
        public double DispMinE()
        {
            return this.CoordMinE + this.StartLineNoE * this.CoordSpaceE;
        }
        public double DispMaxE()
        {
            return this.CoordMinE + this.EndLineNoE * this.CoordSpaceE;
        }
        public double DispMinP()
        {
            return this.CoordMinP + this.StartLineNoP * this.CoordSpaceP;
        }
        public double DispMaxP()
        {
            return this.CoordMinP + this.EndLineNoP * this.CoordSpaceP;
        }
        public double DispMinNPSH()
        {
            return this.CoordMinNPSH + this.StartLineNoNPSH * this.CoordSpaceNPSH;
        }
        public double DispMaxNPSH()
        {
            return this.CoordMinNPSH + this.EndLineNoNPSH * this.CoordSpaceNPSH;
        }
        // 
        public int? UnitQ
        {
            get { return _unitQ; }
            set
            {
                _unitQ = value; 
            }
        }
        private int? _unitQ = null;
 
        //
        public int? UnitH
        {
            get { return _unitH; }
            set
            {
                _unitH = value; 
            }
        }
        private int? _unitH = null;
    
        //
        public int? UnitP { get { return _unitP; } set { _unitP = value;  } }
        private int? _unitP = null;
 
 
        public Object Clone()  //对外提供一个创建自身的浅表副本的能力
        {
            return this.MemberwiseClone();
        }
 
        //坐标刻度的最小值
        public double TitleMinH { get { return CoordMinH + StartLineNoH * CoordSpaceH; } }
 
        //
        protected bool isNull = false;
        public bool IsNull
        {
            get { return isNull; }
        }
 
        public static LxpCoordinateParas ToParameter(string strChartCoord)
        {
            try
            {
                var paras = new LxpCoordinateParas(strChartCoord);
                if (paras.isNull)
                    return null;
                else
                    return paras;
            }
            catch (Exception)
            {
                return null;
            }
        }
 
        public string ToDsString()
        {
            return ToDsString(this);
        }
 
        public static string ToDsString(LxpCoordinateParas paras)
        {
            if (paras == null)
                return "";//为了ACCESS只能用""
 
            StringBuilder sbQ = new StringBuilder();
            sbQ.Append("1,");//1:表示均匀
            sbQ.Append(paras.UnitQ==null?"": paras.UnitQ.ToString()); sbQ.Append(",");
            sbQ.Append(paras.GridNumberX); sbQ.Append(",");
            sbQ.Append(paras.CoordMinQ); sbQ.Append(",");
            sbQ.Append(paras.CoordSpaceQ);
 
            //
            StringBuilder sbY = new StringBuilder();
            sbY.Append("1,");//1:表示均匀
            sbY.Append(paras.GridNumberY);
 
            //
            StringBuilder sbH = new StringBuilder();
            sbH.Append(paras.UnitH == null ? "" : paras.UnitH.ToString()); sbH.Append(",");//要保留小数, 因为单位原因
            sbH.Append(paras.CoordMinH); sbH.Append(",");
            sbH.Append(paras.CoordSpaceH); sbH.Append(",");
            sbH.Append(paras.StartLineNoH); sbH.Append(",");
            sbH.Append(paras.EndLineNoH);
 
            StringBuilder sbE = new StringBuilder();
            sbE.Append("0,");//暂时没有单位
 
            sbE.Append(paras.CoordMinE); sbE.Append(",");
            sbE.Append(paras.CoordSpaceE); sbE.Append(",");
            sbE.Append(paras.StartLineNoE); sbE.Append(",");
            sbE.Append(paras.EndLineNoE);
 
            StringBuilder sbP = new StringBuilder();
            sbP.Append(paras.UnitP == null ? "" : paras.UnitP.ToString()); sbP.Append(",");
            sbP.Append(paras.CoordMinP); sbP.Append(",");
            sbP.Append(paras.CoordSpaceP); sbP.Append(",");
            sbP.Append(paras.StartLineNoP); sbP.Append(",");
            sbP.Append(paras.EndLineNoP);
 
            StringBuilder sbNPSH = new StringBuilder();
            sbNPSH.Append(",");//暂时没有单位
            sbNPSH.Append(paras.CoordMinNPSH); sbNPSH.Append(",");
            sbNPSH.Append(paras.CoordSpaceNPSH); sbNPSH.Append(",");
            sbNPSH.Append(paras.StartLineNoNPSH); sbNPSH.Append(",");
            sbNPSH.Append(paras.EndLineNoNPSH);
 
            StringBuilder sbPanel = new StringBuilder();
            sbPanel.Append(paras.DispStyle); sbPanel.Append(",");
            sbPanel.Append(paras.DislocationNumUp); sbPanel.Append(",");
            sbPanel.Append(paras.DislocationNumDown);
 
            string strChartCoord = string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}",
                sbQ.ToString(), sbY.ToString(), sbH.ToString(), sbE.ToString(), sbP.ToString(), sbNPSH.ToString(),
                sbPanel.ToString());
 
            return strChartCoord;
        }
 
  
    }
}