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
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
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using TProduct.Model;
 
namespace TProduct.WinFrmUI.TPump
{
    /// <summary>
    /// 性能测试
    /// </summary>
    public partial class FeatTestViewMainPage : DocumentPage
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pumpExPart"></param>
        /// <param name="item"></param>
        public void SetBindingData(
             TProduct.Model.ProductMainExPumpPart pumpExPart,
             TProduct.Model.TestProjectItemView item)
        {
            TProduct.Model.ProductMainExPump pump = new Model.ProductMainExPump(pumpExPart);
            var part = new BLL.PartBase().GetByID(pumpExPart.PartID);
            this.SetBindingData(
                pump, part, new List<TProduct.Model.TestProjectItemView>() { item });
        }
        /// <summary>
        /// 赋值
        /// </summary>
        /// <param name="project"></param>
        /// <param name="item"></param>
        /// <param name="workBench"></param>
        /// <param name="workBenchParas"></param>
        public void SetBindingData(
            TProduct.Model.ProductMainExPump pump,
            TProduct.Model.PartBase part,
            List<TProduct.Model.TestProjectItemView> items)
        {
            if (items == null || items.Count() == 0)
            {
                MessageBox.Show("还未设置project参数");
                return;
            }
            if (pump == null)
            {
                MessageBox.Show("还未设置pump参数");
                return;
            }
            if (part == null)
            {
                MessageBox.Show("还未设置part参数");
                return;
            }
            if (string.IsNullOrEmpty(pump.RatedParas))
            {
                MessageBox.Show("还未设置泵的额定参数");
                return;
            }
 
 
            this._currentPump = pump;
            this._currentPart = part;
            this._ratedParas = TProduct.Model.RatedParas4Pump.ToModel(pump.RatedParas);
            if (_currentPump.MotorMainID.HasValue && _currentPump.MotorMainID > 0)
            {
                _currentMotor = new BLL.ProductMotor().GetExByProductID((long)_currentPump.MotorMainID);
            }
            this._currentPumpSeries = new BLL.ProductSeries().GetByID(this._currentPump.SeriesID);
            if (this._currentPumpSeries == null)
            {
                MessageBox.Show("当前泵对应系列未找到");
                return;
            }
 
            this._testProject = new TestProjectBase(items.First());
            this._featTestItem = items.Find(x => x.TestType == eTestType.FeatTest);
            this._testItems = items;
 
            this._workBenchInfo = new BLL.WorkBenchBase().GetByID(this._featTestItem.BenchID);
            if (_workBenchInfo == null)
            {
                MessageBox.Show("还未设置测试台参数");
                return;
            }
            if (!string.IsNullOrEmpty(_featTestItem.ProjectName))
                this.PageTitle.Caption = "泵测试:" + _featTestItem.ProjectName;
            else if (!string.IsNullOrEmpty(_featTestItem.ProjectCode))
                this.PageTitle.Caption = "泵测试:" + _featTestItem.ProjectCode;
 
            // 初始化监控点(会根据当前设置修改 监控点 的信息)
            this._allMonitorPointList = ResetMonitorPoint(new BLL.WorkBenchMonitorPoint().GetByBenchID(_workBenchInfo.ID));
            //
            if (!InitialCalcDialog(this._currentPumpSeries, this._currentPump, _currentMotor, _workBenchInfo, this._featTestItem, _allMonitorPointList))
            {
                return;
            }
 
 
            //从数据库中获取以前的测试数据
            var allRecords4Ds = new BLL.PumpFeatTestRecord().GetByTestItem(this._featTestItem);
            this._allRecords = new List<PumpFeatTestRecordViewModel>();
            if (allRecords4Ds != null && allRecords4Ds.Count > 0)
            {
                foreach (var r in allRecords4Ds)
                {
                    this._allRecords.Add(new PumpFeatTestRecordViewModel(r) { MonitorRecordList = new MonitorRecord4DsList(r.MonitorRecords) });
                }
                if (this._featTestItem.PointNumber != allRecords4Ds.Count)
                {
                    this._featTestItem.PointNumber = allRecords4Ds.Count;
                    new BLL.TestProjectItem().UpdatePointNumberOnly(this._featTestItem.ItemID, this._featTestItem.PointNumber);
                }
            }
            else
            {
                if (this._featTestItem.PointNumber != 0)
                {
                    this._featTestItem.PointNumber = 0;
                    new BLL.TestProjectItem().UpdatePointNumberOnly(this._featTestItem.ItemID, this._featTestItem.PointNumber);
                }
            }
 
            //
            InitialJudgeItem();
 
 
            //
            InitialMonitorGrid( );
 
 
            //
            InitialTestInfoCtrl();
 
 
            //
            IntialPartInfoCtrl();
 
            //放在初始化性能图表之前, 因为需要此步骤,获取汽蚀点
            InitialNpshTestInfo(items);
 
            //
            IntialMainChart();
 
            //合格判断,放在后面
            JudgeTestResult();
 
            //
            InitialModel3d();
 
            //
            InitialDurabilityTest();
 
            //工艺图
            InitialProcessDrawing();
        }
 
        /// <summary>
        /// 设置测点
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        private List<TProduct.Model.WorkBenchMonitorPoint> ResetMonitorPoint(
            List<TProduct.Model.WorkBenchMonitorPoint> list)
        {
            if (list == null || list.Count() == 0)
            {
                return null;
            }
            // 
            var instrumentInfo = this._featTestItem.InstrumentInfo;
            if (instrumentInfo != null)
            {
                #region 出口压力
                var out_press_index = list.FindIndex(x => x.MonitorType == Model.eMonitorType.压力
        && x.Property == TProduct.Model.MonitorTypeProperty.出口);
                if (out_press_index >= 0)
                {
                    var monitor_outletPress = list[out_press_index];
 
                    //设置出口压力表量程 
                    if (instrumentInfo.OutletPressureMeterID > 0)
                    {
                        var meter = new BLL.PressureMeter().GetByID(instrumentInfo.OutletPressureMeterID);
                        if (meter != null)
                        {
                            if (monitor_outletPress.AnalogParas == null)
                                monitor_outletPress.AnalogParas = new Model.AnalogMonitorPointParas();
                            monitor_outletPress.AnalogParas.RangeMax = meter.RangeMax;
                            monitor_outletPress.AnalogParas.RangeMin = meter.RangeMin;
                            list[out_press_index] = monitor_outletPress;
                        }
                    }
                    if (instrumentInfo.OutletPressureMeterPipeDia > 0)
                    {//  暂时用不到, 都是从测点或者泵上获取的,代码暂时保留
                        if (monitor_outletPress.AnalogParas == null)
                            monitor_outletPress.AnalogParas = new Model.AnalogMonitorPointParas();
                        monitor_outletPress.PipeDia = instrumentInfo.OutletPressureMeterPipeDia;
                    }
                    if (instrumentInfo.InletPressureMeterElevation != 0)
                    {
                        if (monitor_outletPress.AnalogParas == null)
                            monitor_outletPress.AnalogParas = new Model.AnalogMonitorPointParas();
                        monitor_outletPress.Elevation = instrumentInfo.OutletPressureMeterElevation;
                    }
 
                    //1:来源泵口径
                    if (TProduct.UserSetting.Setting.PumpTest.OutletPressMonitorDiaStatus == 1 && _ratedParas != null)
                    {
                        if (this._ratedParas.OutletDia.HasValue && _ratedParas.OutletDia > 0)
                        {
                            if (monitor_outletPress.AnalogParas == null)
                                monitor_outletPress.AnalogParas = new Model.AnalogMonitorPointParas();
                            monitor_outletPress.PipeDia = this._ratedParas.OutletDia.Value;
                        }
                    }
                }
                #endregion
 
 
                #region 进口压力
                var inlet_press_index = list.FindIndex(x => x.MonitorType == Model.eMonitorType.压力
                    && x.Property == TProduct.Model.MonitorTypeProperty.进口);
                if (inlet_press_index >= 0)
                {
                    var monitor_inletPress = list[inlet_press_index];
 
                    if (instrumentInfo.InletPressureMeterID > 0)
                    {
                        var meter = new BLL.PressureMeter().GetByID(instrumentInfo.InletPressureMeterID);
                        if (meter != null)
                        {
                            if (monitor_inletPress.AnalogParas == null)
                                monitor_inletPress.AnalogParas = new Model.AnalogMonitorPointParas();
                            monitor_inletPress.AnalogParas.RangeMax = meter.RangeMax;
                            monitor_inletPress.AnalogParas.RangeMin = meter.RangeMin;
                            list[inlet_press_index] = monitor_inletPress;
                        }
                    }
                    if (instrumentInfo.InletPressureMeterPipeDia > 0)
                    {//  暂时用不到, 都是从测点或者泵上获取的,代码暂时保留
                        if (monitor_inletPress.AnalogParas == null)
                            monitor_inletPress.AnalogParas = new Model.AnalogMonitorPointParas();
                        monitor_inletPress.PipeDia = instrumentInfo.InletPressureMeterPipeDia;
                    }
                    if (instrumentInfo.InletPressureMeterElevation != 0)
                    {
                        if (monitor_inletPress.AnalogParas == null)
                            monitor_inletPress.AnalogParas = new Model.AnalogMonitorPointParas();
                        monitor_inletPress.Elevation = instrumentInfo.InletPressureMeterElevation;
                    }
 
                    //1:来源泵口径
                    if (TProduct.UserSetting.Setting.PumpTest.InletPressMonitorDiaStatus == 1 && _ratedParas != null)
                    {
                        if (this._ratedParas.InletDia.HasValue && _ratedParas.InletDia > 0)
                        {
                            if (monitor_inletPress.AnalogParas == null)
                                monitor_inletPress.AnalogParas = new Model.AnalogMonitorPointParas();
                            monitor_inletPress.PipeDia = this._ratedParas.InletDia.Value;
                        }
                    }
                }
 
                //清水池水位的标高也放在进口压力设置中
                var water_level_index = list.FindIndex(x => x.MonitorType == Model.eMonitorType.水位);
                if (water_level_index >= 0)
                {
                    var monitor_WaterLevel = list[water_level_index];
 
                    if (instrumentInfo.InletPressureMeterElevation != 0)
                    {
                        monitor_WaterLevel.Elevation = instrumentInfo.InletPressureMeterElevation;
                    }
                }
 
 
                #endregion
 
                #region 流量
                if (instrumentInfo.FlowMeterRangeMax > instrumentInfo.FlowMeterRangeMin)
                {
                    var flow_index = list.FindIndex(x => x.MonitorType == Model.eMonitorType.流量);
                    if (flow_index >= 0)
                    {
                        var monitor_flow = list[flow_index];
                        if (monitor_flow.AnalogParas == null)
                            monitor_flow.AnalogParas = new Model.AnalogMonitorPointParas();
                        monitor_flow.AnalogParas.RangeMax = instrumentInfo.FlowMeterRangeMax;
                        monitor_flow.AnalogParas.RangeMin = instrumentInfo.FlowMeterRangeMin;
                    }
                } 
                #endregion
 
            }
 
 
            return list;
        }
 
 
 
 
    }
}