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
using System;
using System.ComponentModel.DataAnnotations;
using System.Text;
 
namespace TProduct.Model
{
    public class PrjItemInstrumentSetting
    {
        public PrjItemInstrumentSetting() { }
 
        /// <summary>
        /// 出口压力计ID
        /// </summary>    
        [Display(Name = "出口压力计ID")]
        public long OutletPressureMeterID { get; set; }
 
        /// <summary>
        /// 出口压力计标高(暂时用不到, 都是从测点获取的)
        /// </summary>    
        [Display(Name = "出口压力计标高")]
        public double OutletPressureMeterElevation { get; set; }
 
        /// <summary>
        /// 出口压力计口径(暂时用不到, 都是从测点获取的)
        /// </summary>    
        [Display(Name = "出口压力计口径")]
        public double OutletPressureMeterPipeDia { get; set; }
 
        /// <summary>
        /// 进口压力计ID
        /// </summary>    
        [Display(Name = "进口压力计ID")]
        public long InletPressureMeterID { get; set; }
 
        /// <summary>
        /// 进口压力计标高(暂时用不到, 都是从测点获取的)
        /// </summary>    
        [Display(Name = "进口压力计标高")]
        public double InletPressureMeterElevation { get; set; }
 
        /// <summary>
        /// 进口压力计口径(暂时用不到, 都是从测点获取的)
        /// </summary>    
        [Display(Name = "进口压力计口径")]
        public double InletPressureMeterPipeDia { get; set; }
 
 
 
        /// <summary>
        /// 流量计量程最小值
        /// </summary>    
        [Display(Name = "流量计量程最小值")]
        public double FlowMeterRangeMin { get; set; }
 
        /// <summary>
        /// 流量计量程最大值
        /// </summary>    
        [Display(Name = "流量计量程最大值")]
        public double FlowMeterRangeMax { get; set; }
 
        /// <summary>
        /// To json
        /// </summary>
        public string ToDsString()
        {
            return JsonHelper.Object2Json(this);
        }
        /// <summary>
        /// To json
        /// </summary>
        public static string ToDsString(PrjItemInstrumentSetting model)
        {
            if (model == null)
                return "";
            StringBuilder sb = new StringBuilder();
            sb.Append("V1"); sb.Append("|");
            if (model.OutletPressureMeterID > 0 || model.OutletPressureMeterPipeDia>0)
            {
                sb.AppendFormat("OPMI:{0}|", model.OutletPressureMeterID);
                sb.AppendFormat("OPME:{0}|", model.OutletPressureMeterElevation);
                sb.AppendFormat("OPMP:{0}|", model.OutletPressureMeterPipeDia); 
            }
 
            if (model.InletPressureMeterID > 0 || model.InletPressureMeterPipeDia > 0)
            {
                sb.AppendFormat("IPMI:{0}|", model.InletPressureMeterID);
                sb.AppendFormat("IPME:{0}|", model.InletPressureMeterElevation);
                sb.AppendFormat("IPMP:{0}|", model.InletPressureMeterPipeDia);
            }
 
            if (model.FlowMeterRangeMax > model.FlowMeterRangeMin)
            {
                sb.AppendFormat("FMRA:{0}|", model.FlowMeterRangeMax);
                sb.AppendFormat("FMRI:{0}|", model.FlowMeterRangeMin);
            }
 
            return sb.ToString();
        }
        /// <summary>
        /// To model
        /// </summary>
        public static PrjItemInstrumentSetting ToParameter(string strPara)
        {
            if (string.IsNullOrEmpty(strPara))
                return null;
            if (!strPara.Contains("V1|"))
                return null;
            try
            {
                PrjItemInstrumentSetting model = new PrjItemInstrumentSetting();
                string[] strPara_split_array = strPara.Split('|');
                for (int i = 1; i < strPara_split_array.Length; i++)
                {
                    var s = strPara_split_array[i];
                    if (s.StartsWith("OPMI:"))
                    {
                        model.OutletPressureMeterID = Convert.ToInt64(s.Replace("OPMI:", ""));
                    }
                    if (s.StartsWith("OPME:"))
                    {
                        model.OutletPressureMeterElevation = Convert.ToDouble(s.Replace("OPME:", ""));
                    }
                    if (s.StartsWith("OPMP:"))
                    {
                        model.OutletPressureMeterPipeDia = Convert.ToDouble(s.Replace("OPMP:", ""));
                    }
 
                    if (s.StartsWith("IPMI:"))
                    {
                        model.InletPressureMeterID = Convert.ToInt64(s.Replace("IPMI:", ""));
                    }
                    if (s.StartsWith("IPME:"))
                    {
                        model.InletPressureMeterElevation = Convert.ToDouble(s.Replace("IPME:", ""));
                    }
                    if (s.StartsWith("IPMP:"))
                    {
                        model.InletPressureMeterPipeDia = Convert.ToDouble(s.Replace("IPMP:", ""));
                    }
 
                    if (s.StartsWith("FMRA:"))
                    {
                        model.FlowMeterRangeMax = Convert.ToDouble(s.Replace("FMRA:", ""));
                    }
                    if (s.StartsWith("FMRI:"))
                    {
                        model.FlowMeterRangeMin = Convert.ToDouble(s.Replace("FMRI:", ""));
                    }
                }
 
 
                return model;
            }
            catch
            {
                return null;
            }
 
        }
 
    }
}