tx
8 天以前 e0b138b3e057de6f57021e6c8963868f5c5acc5a
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
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using TProduct.Model;
 
namespace TProduct.WinFrmUI.TPump
{
    /// <summary>
    /// 性能测试
    /// </summary>
    public partial class FeatTestIngMainPage : TestIngBaseMainPage
    {
        private TestRecordOperateBaseCtrl _recordOperateCtrl;
        //初始化实时测点数据表
        private void InitialMonitorGrid(
            List<TProduct.Model.WorkBenchMonitorPoint> allMonitorList)
        {
            if (_monitorGridCtrl == null)
            {
                _monitorGridCtrl = new GridFeatMonitorRecordCtrl();
                _monitorGridCtrl.Name = "GridFeatTestCtrl";
                _monitorGridCtrl.Dock = DockStyle.Fill;
                _monitorGridCtrl.OnDeleteRecord += (record) =>
                {
                    if (record != null)
                        DeleteFeatTestRecord(record);
                };
                _monitorGridCtrl.OnEditRecord += (record) =>
                {
                    if (record != null)
                        EditFeatTestRecord(record);
                };
                _monitorGridCtrl.OnEmptyAllRecord += () =>
                {
                    EmptyAllRecord();
                };
 
                tabPageGrid.Controls.Add(_monitorGridCtrl);
            }
            _monitorGridCtrl.SetBindingData(allMonitorList);
            _monitorGridCtrl.RefreshData(this._allRecords);
            if (_correctPtGridCtrl != null)
                _correctPtGridCtrl.RefreshData(this._allRecords);
        }
 
        //初始化自动测试数据表 
        private void InitialAutoTestGrid(
            List<TProduct.Model.WorkBenchMonitorPoint> allMonitorList)
        {
            if (_testItem.AutoTestInfo == null || !_testItem.AutoTestInfo.IsHave)
            {
                tabPageAutoTest.PageVisible = false;
                return;
            }
 
            if (_autoTestInfoCtrl == null)
            {
                _autoTestInfoCtrl = new FeatTestAutoParasCtrl();
                _autoTestInfoCtrl.Name = "FeatTestAutoParasCtrl";
                _autoTestInfoCtrl.Dock = DockStyle.Fill;
                tabPageAutoTest.Controls.Add(_autoTestInfoCtrl);
 
                if (!_autoTestInfoCtrl.IntialTestInfo(this._testItem))
                {
                    tabControlRight.SelectedTabPageIndex = 1;
                }
            }
        }
 
        private FeatTestRealTimeChart _realTimeChart;
        private GridFeatCorrectPtCtrl _correctPtGridCtrl = null;
        private void InitialCorrentPtGrid()
        {
            if (TProduct.UserSetting.Setting.PumpTest.IsDispCorrectPtGrid)
            {
                if (_correctPtGridCtrl == null)
                {
                    _correctPtGridCtrl = new GridFeatCorrectPtCtrl();
                    _correctPtGridCtrl.Name = "GridFeatCorrectPtCtrl";
                    _correctPtGridCtrl.Dock = DockStyle.Fill;
                    tabPageFeatCorrectPt.Controls.Add(_correctPtGridCtrl);
                }
 
                _correctPtGridCtrl.RefreshData(this._allRecords);
            }
            else
            {
                _correctPtGridCtrl = null;
                tabPageFeatCorrectPt.PageVisible = false;
            }
 
 
            if ( _monitorValveIngRecordHelper != null &&
                TProduct.UserSetting.Setting.PumpTest.IsDispRealTimeChart)
            {
                if (TProduct.UserSetting.Setting.PumpTest.RealTimeChartPosi==0)
                { 
                    _realTimeChart = new FeatTestRealTimeChart();
                    _realTimeChart.Dock = DockStyle.Fill;
                    _realTimeChart.Name = "ReatTimeDataCtrl"; 
                    if(_realTimeChart.SetBindingData(
                        this._allMonitorPointList, _monitorValveIngRecordHelper))
                    {
                        tabPageRealTimeRight.PageVisible = false; 
                        tabPageRealTimeLeft.PageVisible = true;
                        tabPageRealTimeLeft.Controls.Add(_realTimeChart); 
                    }
                    else
                    {
                        _realTimeChart = null;
                        tabPageRealTimeRight.PageVisible = false;
                        tabPageRealTimeLeft.PageVisible = false;
                    }
                }
                else 
                {
                    _realTimeChart = new FeatTestRealTimeChart();
                    _realTimeChart.Dock = DockStyle.Fill;
                    _realTimeChart.Name = "ReatTimeDataCtrl";
                    if (_realTimeChart.SetBindingData(
                        this._allMonitorPointList, _monitorValveIngRecordHelper))
                    {
                        tabPageRealTimeRight.Controls.Add(_realTimeChart);
                        tabPageRealTimeRight.PageVisible = true;
                        tabPageRealTimeLeft.PageVisible = false;
                    }
                    else
                    {
                        _realTimeChart = null;
                        tabPageRealTimeRight.PageVisible = false;
                        tabPageRealTimeLeft.PageVisible = false;
                    }
                }
            }
            else
            {
                _realTimeChart = null;
                tabPageRealTimeRight.PageVisible = false;
                tabPageRealTimeLeft.PageVisible = false;
            }
        }
 
 
        private bool InitialRecordOperateCtrl()
        {
            if (TProduct.CorpConfig.Instance.CorpFlag == eCorpFlag.LIFU)
            {
                var autoOperateCtrl = new TestRecordOperate4LifuCtrl();
                autoOperateCtrl.Name = "OperateValveDegreeCtrl";
                autoOperateCtrl.Dock = DockStyle.Fill;
                autoOperateCtrl.SetBindingData(_workBenchInfo, _testItem);
                autoOperateCtrl.SetLinkHelper(this._linkHelper);
                panelValve.Controls.Add(autoOperateCtrl);
                tableLayoutRight.RowStyles[1].Height = 0;
                this._recordOperateCtrl = autoOperateCtrl;
 
                autoOperateCtrl.OnChangePanelStatus += (isExpand) =>
                {
                    if (isExpand)
                    {
                        if (_correctPtGridCtrl == null && _realTimeChart == null && _autoTestInfoCtrl == null)
                            tableLayoutRight.RowStyles[1].Height = tableLayoutRight.Height - 65;
                        else
                            tableLayoutRight.RowStyles[1].Height = 300;
                    }
                    else
                    {
                        tableLayoutRight.RowStyles[1].Height = 0;
                    }
                };
            }
            else
            {
                var autoOperateCtrl = new TestRecordOperate4Wh701Ctrl();
                autoOperateCtrl.Name = "OperateValveDegreeCtrl";
                autoOperateCtrl.Dock = DockStyle.Fill;
                autoOperateCtrl.SetBindingData(_workBenchInfo, _testItem);
                autoOperateCtrl.SetLinkHelper(this._linkHelper);
                panelValve.Controls.Add(autoOperateCtrl);
                tableLayoutRight.RowStyles[1].Height = 0;
                this._recordOperateCtrl = autoOperateCtrl;
 
                autoOperateCtrl.OnChangePanelStatus += (isExpand) =>
                {
                    if (isExpand)
                    {
                        if (_correctPtGridCtrl == null && _realTimeChart == null && _autoTestInfoCtrl == null)
                            tableLayoutRight.RowStyles[1].Height = tableLayoutRight.Height - 65;
                        else
                            tableLayoutRight.RowStyles[1].Height = 165;
                    }
                    else
                    {
                        tableLayoutRight.RowStyles[1].Height = 0;
                    }
                };
            }
            //_recordOperateCtrl.OnChangeValveDegree += (prop, degree) =>
            //{
            //    this.theCalcDataDlg.SetValveDegree(prop, degree);
            //    if (_featTestHelper != null)
            //    {
            //        _featTestHelper.SetValveDegree(prop, degree);
            //    }
            //};
 
            _recordOperateCtrl.OnGetRecord += (para, type) =>
            {//获取数据
                NewFeatTestRecord(para, type);
            };
            _recordOperateCtrl.OnStartAutoTest += () =>
            {//开始自动测试
                TProduct.WinFrmUI.AlertTool.ShowInfo(TProduct.WinFrmUI.GlobeParas.MainForm, "提示", "自动测试已开始...");
                StartAutoTest();
            };
            _recordOperateCtrl.OnStopAutoTest += () =>
            {//停止自动测试 
                StopAutoTest();
            };
            _recordOperateCtrl.OnFinishAutoTest += () =>
            {//结束自动测试 
                TProduct.WinFrmUI.AlertTool.ShowInfo(TProduct.WinFrmUI.GlobeParas.MainForm, "提示", "自动测试已结束...");
                StopAutoTest();
                JudgeTestResult();//判断一下合格性
            };
            _recordOperateCtrl.OnChangePanelSize += (height) =>
            {
                tableLayoutRight.RowStyles[1].Height = height;
            };
            if (_monitorValveIngRecordHelper != null)
            {
                _monitorValveIngRecordHelper.OnInitialValveDegree += (tag, degree) =>
                {
                    if (tag == TProduct.Model.MonitorTypeProperty.出口)
                    {
                        if(degree > 1)
                        {
                            this.Invoke(new Action(() =>
                            {
                                _recordOperateCtrl.SetValveDegree出口(degree);
                            }));
                        }
 
                        return true;
                    }
                    else
                    {
                        return false;
                    }
             
                };
            }
            return true;
        }
 
        private void InitialFeatTestHelper()
        {
            if (_featTestHelper == null)
            {
                _featTestHelper = new FeatTestHelper();
                _featTestHelper.SetPumpInfo(
                    this._currentPumpSeries,
                    this._currentPump );
                if (_currentMotor != null && !string.IsNullOrEmpty(_currentMotor.RatedParas))
                {
                    var rated_motor = TProduct.Model.RatedParas4Motor.ToModel(_currentMotor.RatedParas);
                    _featTestHelper.SetMotorInfo(rated_motor.E_Self, _currentMotor.EtaCurve);
                }
                _featTestHelper.SetParallelInfo(this._parallelInfo);
                _featTestHelper.SetTestInfo(
                    this._workBenchInfo,
                    this._testItem,
                    this._allMonitorPointList);
            }
        }
        /// <summary>
        /// 是否操控过测试记录
        /// </summary>
        private bool _isModifyTestRecord = false;
        public bool IsModifyTestRecord
        {
            get { return _isModifyTestRecord; }
        }
        #region 自动测试
        //开始自动测试
        FeatTestHelper _featTestHelper = null;
        private void StartAutoTest()
        {
            InitialFeatTestHelper();
            //不让关闭COM口
            tableLayoutRight.RowStyles[2].Height = 0;
 
 
            bsiOperateInfo.Caption = "自动测试开始";
        }
        private void StopAutoTest()
        {
            tableLayoutRight.RowStyles[2].Height = 50;
 
            bsiOperateInfo.Caption = "自动测试停止";
        }
        #endregion
 
 
        #region 添加记录
        /// <summary>
        /// 获取有效点(添加记录):
        /// </summary>
        /// <param name="paras">操作参数 , 手动时,没用, 自动时, 输入开度</param>
        /// <param name="type">type 0 自动  1 手动</param>
        private void NewFeatTestRecord(string paras,
            TProduct.WinFrmUI.TPump.TestRecordOperateBaseCtrl.eGetRecordType type)
        {
            _isModifyTestRecord = true;
            if (type == TestRecordOperateBaseCtrl.eGetRecordType.手动)
            {// 1 手动
                #region 手动,对话框
                //防止重复点击,否则会报错
                if (theCalcDataDlg.Visible)
                    return;
 
                //获取仪表的测量值
                List<TProduct.Model.MonitorPointValuePure> valueList = this._monitorValveIngRecordHelper.GetAverageValueList();
 
                theCalcDataDlg.NewTestRecord(valueList, true);
                if (this._recordOperateCtrl != null)
                {
                    theCalcDataDlg.SetValveDegree("进口", this._recordOperateCtrl.GetValveDegree进口());
                    theCalcDataDlg.SetValveDegree("出口", this._recordOperateCtrl.GetValveDegree出口());
                }
 
                theCalcDataDlg.Show(this);
                #endregion
            }
            else if (type == TestRecordOperateBaseCtrl.eGetRecordType.自动)
            {//自动
                List<TProduct.Model.MonitorPointValuePure> valueList =
                    this._monitorValveIngRecordHelper.GetAverageValueList();
                if (string.IsNullOrEmpty(paras))
                    return;
 
                if (_featTestHelper == null)
                {
                    InitialFeatTestHelper();
                }
                var degree = Convert.ToDouble(paras);
                string error_info = "";
                var record = _featTestHelper.NewTestRecord(valueList, degree,
                    out error_info);
                if (this._recordOperateCtrl != null)
                {
                    _featTestHelper.SetValveDegree("进口", this._recordOperateCtrl.GetValveDegree进口());
                    _featTestHelper.SetValveDegree("出口", this._recordOperateCtrl.GetValveDegree出口());
                }
 
                if (record == null)
                {
                    _autoTestInfoCtrl.SetErrorRecord(degree, error_info);
 
                    var info = string.Format("获取{0}度的数据时, 出错了,请检查,具体原因是:{1}", degree,
                        error_info);
                    bsiOperateInfo.Caption = info;
                    TProduct.WinFrmUI.AlertTool.ShowInfo(TProduct.WinFrmUI.GlobeParas.MainForm,
                        "错误提示", info);
                }
                else
                {
                    _autoTestInfoCtrl.SetNormalRecord(degree, record);
 
                    //保存
                    SaveTestRecord(record, 1);
 
                    //
                    string info = string.Format("自动获取特征点({0}度),Q:{1},H:{2}", degree, record.CorrectPtQ, record.CorrectPtH);
                    bsiOperateInfo.Caption = info;
 
                    TProduct.WinFrmUI.AlertTool.ShowInfo(TProduct.WinFrmUI.GlobeParas.MainForm, "提示", info);
                }
 
            }
        }
 
        #endregion
 
 
        #region 编辑记录
        /// <summary>
        /// 
        /// </summary>
        /// <param name="record"></param>
        private void EditFeatTestRecord(TProduct.Model.PumpFeatTestRecordViewModel record)
        {
            _isModifyTestRecord = true;
            //防止重复点击,否则会报错
            if (theCalcDataDlg.Visible)
                return;
 
            theCalcDataDlg.EditTestRecord(record);
 
            theCalcDataDlg.Show(this);
        }
        #endregion
 
 
        #region 删除记录
        /// <summary>
        /// 单条删除
        /// </summary>
        /// <param name="record"></param>
        private void DeleteFeatTestRecord(TProduct.Model.PumpFeatTestRecordViewModel record)
        {
            if (this._allRecords == null)
                return;
            var f = this._allRecords.Find(x => x.ID == record.ID);
            if (f == null)
                return;
 
            _isModifyTestRecord = true;
 
            new BLL.PumpFeatTestRecord().Delete(this._testItem, f.ID);
            this._allRecords.Remove(f);
 
 
            _monitorGridCtrl.RefreshData(this._allRecords);
            _chartMainCtrl.SetRecordPoint(this._allRecords);
            if (_correctPtGridCtrl != null)
                _correctPtGridCtrl.RefreshData(this._allRecords);
 
            RefreshItemPointNumber();
        }
 
        /// <summary>
        /// 全部删除
        /// </summary>
        private void EmptyAllRecord()
        {
            if (this._allRecords == null || this._allRecords.Count() == 0)
                return;
            DialogResult result1 = MessageBox.Show("请问是否清空测试数据", "询问",
System.Windows.Forms.MessageBoxButtons.YesNo,
System.Windows.Forms.MessageBoxIcon.Warning);
            if (result1 != DialogResult.Yes)
            {
                return;
            }
 
            DialogResult result2 = MessageBox.Show("请问是否清空测试数据,删除后, 数据无法恢复,请再次确认", "询问",
System.Windows.Forms.MessageBoxButtons.YesNo,
System.Windows.Forms.MessageBoxIcon.Warning);
            if (result2 != DialogResult.Yes)
            {
                return;
            }
            _isModifyTestRecord = true;
 
            new TProduct.BLL.PumpFeatTestRecord().ClearAllRecord(this._testItem);
            this._allRecords.Clear();
            this._monitorGridCtrl.ClearData();
            this._chartMainCtrl.EmptyRecordPoint();
            if (_correctPtGridCtrl != null)
                this._correctPtGridCtrl.ClearData();
        }
 
        #endregion
 
 
        #region 保存记录
        /// <summary>
        /// 保存记录 operateType表示操作类型 1 表示添加  2 表示更新  3表示删除
        /// </summary>
        /// <param name="record"></param>
        private void SaveTestRecord(TProduct.Model.PumpFeatTestRecordViewModel record,
            int operateType)
        {
            if (operateType == 1)
            {
                if (this._allRecords == null)
                    this._allRecords = new List<TProduct.Model.PumpFeatTestRecordViewModel>();
 
                this._allRecords.Add(record);
            }
            if (this._allRecords == null || this._allRecords.Count == 0)
            {
                RefreshItemPointNumber();
                return;
            }
            RefreshItemPointNumber();
 
            _isModifyTestRecord = true;
 
            _monitorGridCtrl.RefreshData(this._allRecords);
            _chartMainCtrl.SetRecordPoint(this._allRecords);
            if (_correctPtGridCtrl != null)
                _correctPtGridCtrl.RefreshData(this._allRecords);
        }
        /// <summary>
        /// 保存记录点数
        /// </summary>
        private void RefreshItemPointNumber()
        {
            this._testItem.TestEndTime = DateTime.Now;
            if (this._allRecords == null || this._allRecords.Count == 0)
            {
                if (this._testItem.PointNumber != 0)
                {
                    this._testItem.PointNumber = 0;
                    new BLL.TestProjectItem().UpdatePointNumberAndTime(this._testItem.ItemID,
                        this._testItem.PointNumber);
 
                    if (OnChangeTestInfo != null)
                    {
                        OnChangeTestInfo(this._testItem);
                    }
                }
                return;
            }
            else
            {
                if (this._testItem.PointNumber != this._allRecords.Count)
                {
                    this._testItem.PointNumber = this._allRecords.Count;
                    new BLL.TestProjectItem().UpdatePointNumberAndTime(this._testItem.ItemID,
                        this._testItem.PointNumber);
 
                    if (OnChangeTestInfo != null)
                    {
                        OnChangeTestInfo(this._testItem);
                    }
                }
            }
        }
 
        #endregion
 
 
        #region 对话框操作
        private CalcFeatTestBaseDlg theCalcDataDlg = null;
        //初始化计算对话框
        private bool InitialCalcDialog(
            TProduct.Model.ProductSeries pump_series,
            TProduct.Model.ProductMainExPump pump,
            TProduct.Model.ProductMainExMotor motor,
            TProduct.Model.WorkBenchBase workBenchParas,
            TProduct.Model.TestProjectItemView item,
            List<TProduct.Model.WorkBenchMonitorPoint> allMonitorList)
        {
            if (this._allMonitorPointList == null || this._allMonitorPointList.Count < 1)
                return false;
 
            if (pump != null && pump.Ratedn == null)
            {
                MessageBox.Show("泵参数还未设置额定转速");
                return false;
            }
 
            CalcFeatTestData1Dlg theCalc1Dlg = new CalcFeatTestData1Dlg();
            theCalc1Dlg.SetPumpInfo(pump_series,pump);
            theCalc1Dlg.SetMotorInfo(motor);
            theCalc1Dlg.SetTestInfo(workBenchParas, item);
            theCalc1Dlg.InitialMonitorInfo(allMonitorList);
            theCalc1Dlg.Name = "CalcFeatTestDataDlg";
            theCalc1Dlg.OnSaveRecord += (record, operateType) =>
            {//operateType表示操作类型 1 表示添加  2 表示更新  3表示删除
                SaveTestRecord(record, operateType);
            };
 
            theCalcDataDlg = theCalc1Dlg;
 
            return true;
        }
 
        #endregion
 
 
        #region 初始化通讯设备
        private bool InitialLink()
        {
            if (this._workBenchInfo.LinkType == Model.eLinkType.ShunZhou)
            {
                #region 顺舟
                var shunlinkHelper = new Link.Shun.LinkHelper();
                this._linkHelper = shunlinkHelper;
 
                //使用事件接收 
                shunlinkHelper.OnReceiveMonitorValue += (s, e) =>
                {
                    this.Invoke(new MethodInvoker(delegate
                    {
                        //测点信息
                        ReceiveIntrumentMonitorValue(e.MonitorValues );
                        //附加信息
                        RefreshAdditionInfo(e.AdditionInfos);
                    }));
                };
                TProduct.Model.WorkBenchInstrumentShunBundle bundles_shun =
                    new BLL.WorkBenchInstrumentShun().GetShunBundle(this._workBenchInfo);
                if (bundles_shun == null || bundles_shun.MonitorPointList == null || bundles_shun.MonitorPointList.Count == 0)
                {
                    MessageBox.Show("初始化测试台bundles失败");
                    return false;
                }
                // 初始化监控点(会根据当前设置修改 监控点 的信息)
                this._allMonitorPointList =
                    ResetMonitorPoint(bundles_shun.MonitorPointList);
 
                string error_info;
                if (!shunlinkHelper.InitialData(
                    this._currentPump,
                    this._currentMotor,
                    this._testItem,
                    bundles_shun, out error_info))
                {
                    MessageBox.Show(error_info);
                    return false;
                }
                //初始化步骤控件
                var com_names = (from x in bundles_shun.Sz02List where x.UseStatus == TProduct.Model.eUseStatus.Enable select x.ComPortName).Distinct();
                if (!InitialCommConnectCtrl(com_names.ToList()))
                {
                    MessageBox.Show("初始化步骤控件失败,请确认Comm口");
                    return false;
                }
                #endregion
            }
            else if (this._workBenchInfo.LinkType == Model.eLinkType.KeDi)
            {
                #region 科迪 KD
                var allPressMeter = new TProduct.BLL.PressureMeter().GetAll();
                var allFlowMeter = new TProduct.BLL.FlowMeter().GetAll();
                var kdlinkHelper = new TProduct.Link.Kedi.LinkHelper();
                kdlinkHelper.SetMeterInfo(allPressMeter, allFlowMeter);
 
                this._linkHelper = kdlinkHelper;
                //使用事件接收 _linkHelper.OnReceiveMsg += OnReceiveMessage;
                kdlinkHelper.OnReceiveMonitorValue += (s, e) =>
                {//子线程会操作界面, 需用委托
                    this.Invoke(new MethodInvoker(delegate
                    {
                        //测点信息
                        ReceiveIntrumentMonitorValue(e.MonitorValues );
                        //附加信息
                        RefreshAdditionInfo(e.AdditionInfos);
                    }));
                };
                List<Model.WorkBenchInstrumentKedi> listInstructs =
                    new BLL.WorkBenchInstrumentKedi().GetByBenchID(this._workBenchInfo.ID);
                if (listInstructs == null || listInstructs.Count() == 0)
                {
                    MessageBox.Show("初始化测试台bundles失败");
                    return false;
                }
                // 在软件里面 是否可以操控泵的开启挺
                ribbonPageGroup开停机.Visible = TProduct.CorpSetting.PumpTest. IsOperatePumpAble;
                
                // 初始化监控点(会根据当前设置修改 监控点 的信息)
                this._allMonitorPointList = ResetMonitorPoint(new BLL.WorkBenchMonitorPoint().GetByBenchID(this._workBenchInfo.ID));
                if (this._allMonitorPointList == null || this._allMonitorPointList.Count() == 0)
                {
                    MessageBox.Show("初始化测试台失败,未配备测点");
                    return false;
                }
 
 
                //初始化数据(此时可能时间会比较长,需要设置CT和PT)
                string error_info;
                if (!kdlinkHelper.InitialData(
                    this._currentPump,
                    this._currentMotor,
                    this._workBenchInfo, this._testItem,
                    listInstructs,
                    this._allMonitorPointList, out error_info))
                {
                    MessageBox.Show(error_info);
                    return false;
                }
 
                //初始化步骤控件
                var com_names = (from x in listInstructs select x.ComPortName).Distinct().ToList();
                if (!InitialCommConnectCtrl(com_names))
                {
                    MessageBox.Show("初始化步骤控件失败,请确认Comm口");
                    return false;
                }
                #endregion
            }
            else if (this._workBenchInfo.LinkType == Model.eLinkType.RandomValue)
            {
                #region 随机数
                var kdlinkHelper = new TProduct.Link.RandomLinkHelper();
 
                this._linkHelper = kdlinkHelper;
                //使用事件接收 _linkHelper.OnReceiveMsg += OnReceiveMessage;
                kdlinkHelper.OnReceiveMonitorValue += (s, e) =>
                {//子线程会操作界面, 需用委托
                    this.Invoke(new MethodInvoker(delegate
                    {
                        //测点信息
                        ReceiveIntrumentMonitorValue(e.MonitorValues);
                        //附加信息
                        RefreshAdditionInfo(e.AdditionInfos);
                    }));
                };
                List<Model.WorkBenchInstrumentKedi> listInstructs =
                    new BLL.WorkBenchInstrumentKedi().GetByBenchID(this._workBenchInfo.ID);
                if (listInstructs == null || listInstructs.Count() == 0)
                {
                    MessageBox.Show("初始化测试台bundles失败");
                    return false;
                }
 
 
                this._allMonitorPointList = ResetMonitorPoint(new BLL.WorkBenchMonitorPoint().GetByBenchID(this._workBenchInfo.ID));
                if (this._allMonitorPointList == null || this._allMonitorPointList.Count() == 0)
                {
                    MessageBox.Show("初始化测试台失败,未配备测点");
                    return false;
                }
                string error_info;
                if (!kdlinkHelper.InitialData(
                    this._currentPump,
                    this._currentMotor,
                    this._workBenchInfo, this._testItem,
                    listInstructs,
                    this._allMonitorPointList, out error_info))
                {
                    MessageBox.Show(error_info);
                    return false;
                }
                //初始化步骤控件
                var com_names = new List<string>() { "ComX" };
                if (!InitialCommConnectCtrl(com_names))
                {
                    MessageBox.Show("初始化步骤控件失败,请确认Comm口");
                    return false;
                }
                #endregion
            }
 
            else
            {
                MessageBox.Show("暂时不支持此类型的链接");
                return false;
            }
 
            return true;
        }
 
        #endregion
 
 
        #region 通讯日志
 
        TProduct.WinFrmUI.TBase.LinkLogListCtrl _linkLogCtrl = null;
        /// <summary>
        /// 通讯日志
        /// </summary>
        private void InitialLinkLogCtrl()
        {
            if (this._testItem == null)
                return;
            if (!TProduct.UserSetting.Setting.Disp.IsShowLog)
            {
                this.tabPageLinkLog.PageVisible = false;
                return;
            }
 
 
            if (_linkLogCtrl == null)
            {
                _linkLogCtrl = new TBase.LinkLogListCtrl();
                _linkLogCtrl.Name = "TestItemLogContentCtrl";
                _linkLogCtrl.Dock = DockStyle.Fill;
 
                this.tabPageLinkLog.Controls.Add(_linkLogCtrl);
 
                this._linkHelper.OnShowMsg += (arg) =>
                {//子线程会操作界面, 需用委托
                    this.Invoke(new MethodInvoker(delegate
                    {
                        _linkLogCtrl.AddMsg(arg);
                    }));
                };
 
 
            }
        }
 
 
 
        #endregion
 
    }
}