tx
2025-04-09 fa7510e1ed63df0366787fa4ed1b3db6426d2b46
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace Eventech.Model
{
    public class ValveCoordinateParas : ICloneable
    {
        public ValveCoordinateParas()
        {
 
        }
        public ValveCoordinateParas(ValveCoordinateParas rhs)
        {
            this.AxisLabelX = rhs.AxisLabelX;
            this.AxisLabelY = rhs.AxisLabelY;
 
            this._isNull = rhs.IsNull;
        }
        public ValveCoordinateParas(string strChartCoord)
        {
            if (string.IsNullOrEmpty(strChartCoord))
            {
                this._isNull = true;
                return;
            }
 
            string[] coords = strChartCoord.Split(new string[] { "|||" }, StringSplitOptions.None);
            if (coords.Count() < 3)
            {
                this._isNull = true;
                return;
            }
 
            this.AxisLabelX = new List<Tuple<string, string, List<double>>>();
 
            string[] slit_xxx = coords[1].Split('#');
            int count_x = Convert.ToInt32(slit_xxx[0]);
            for (int i = 0; i < count_x; i++)
            {
                var sss = slit_xxx[i + 1].Split(',');
                if (sss.Count() < 5)
                    continue;
                List<double> aaa = new List<double>();
                for (int j = 2; j < sss.Count(); j++)
                {
                    aaa.Add(Convert.ToDouble(sss[j]));
                }
 
                this.AxisLabelX.Add(new Tuple<string, string, List<double>>(sss[0], sss[1], aaa));
            }
 
 
 
            this.AxisLabelY = new List<Tuple<string, string, List<double>>>();
 
            string[] slit_yyy = coords[2].Split('#');
            int count_y = Convert.ToInt32(slit_yyy[0]);
            for (int i = 0; i < count_y; i++)
            {
                var sss = slit_yyy[i + 1].Split(',');
                if (sss.Count() < 5)
                    continue;
                List<double> aaa = new List<double>();
                for (int j = 2; j < sss.Count(); j++)
                {
                    aaa.Add(Convert.ToDouble(sss[j]));
                }
 
                this.AxisLabelY.Add(new Tuple<string, string, List<double>>(sss[0], sss[1], aaa));
            }
 
 
            this._isNull = false;
        }
 
 
        public List<Tuple<string, string, List<double>>> AxisLabelX = null;//流量
        public List<Tuple<string, string, List<double>>> AxisLabelY = null;//压力
 
 
        protected bool _isNull = false;
        public bool IsNull
        {
            get { return _isNull; }
        }
 
 
 
        #region Clone
        public ValveCoordinateParas Clone()  //对外提供一个创建自身的浅表副本的能力
        {
            return new ValveCoordinateParas(this);
        }
        object ICloneable.Clone()
        {
            return this.Clone();
        }
 
        #endregion
 
        public string ToDsString()
        {
            return ToDsString(this);
        }
        public static string ToDsString(ValveCoordinateParas paras)
        {
            if (paras == null)
                return "";
            if (paras.AxisLabelX == null || paras.AxisLabelX.Count < 1)
                return "";
            if (paras.AxisLabelY == null || paras.AxisLabelY.Count < 1)
                return "";
 
 
            StringBuilder sbX = new StringBuilder();
            sbX.AppendFormat("{0}", paras.AxisLabelX.Count()); //表示数量
            foreach (var axis in paras.AxisLabelX)
            {
                sbX.Append("#");
                sbX.Append(axis.Item1.Replace(",", "").Replace("|", "").Replace("#", ""));
                sbX.Append(",");
                sbX.Append(axis.Item2.Replace(",", "").Replace("|", "").Replace("#", ""));
                sbX.Append(",");
                sbX.Append(string.Join(",", axis.Item3));
            }
 
 
            StringBuilder sbY = new StringBuilder();
            sbY.AppendFormat("{0}", paras.AxisLabelY.Count()); //表示数量
            foreach (var axis in paras.AxisLabelY)
            {
                sbY.Append("#");
                sbY.Append(axis.Item1.Replace(",", "").Replace("|", "").Replace("#", ""));
                sbY.Append(",");
                sbX.Append(axis.Item2.Replace(",", "").Replace("|", "").Replace("#", ""));
                sbX.Append(",");
                sbY.Append(string.Join(",", axis.Item3));
            }
 
 
 
            return string.Format("V1|||{0}|||{1}", sbX.ToString(), sbY);
        }
 
 
 
 
        public static ValveCoordinateParas ToParameter(string strChartCoord)
        {
            try
            {
                var paras = new ValveCoordinateParas(strChartCoord);
                if (paras._isNull)
                    return null;
                else
                    return paras;
            }
            catch (Exception)
            {
                return null;
            }
        }
 
 
        public static void Alignment(ref List<double> list1, ref List<double> list2)
        {
            if (list1 == null)
                return;
            if (list2 == null)
                return;
            if (list1.Count == list2.Count)
                return;
            int count = Math.Max(list1.Count, list2.Count);
            if (count != list1.Count)
            {
                ComplementCount(ref list1, count);
            }
            if (count != list2.Count)
            {
                ComplementCount(ref list2, count);
            }
        }
 
        public static void ComplementCount(ref List<double> list1, int count)
        {
            if (list1 == null)
                return;
            if (list1.Count >= count)
                return;
            double space = list1[1] - list1[0];
            while (true)
            {
                if (list1.Count > count)
                    return;
                list1.Add(list1.Last() + space);
            }
 
        }
    }
}