lixiaojun
2024-10-17 4cb1f00f84d160f97afd0fb86cf600e1be667dd5
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
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
global using Yw.EPAnet;
using Yw.WinFrmUI.Bimface;
using Yw.WinFrmUI.Hydro;
 
namespace HStation.WinFrmUI
{
    public partial class XhsProjectSimulationCorePage : DocumentPage
    {
        public XhsProjectSimulationCorePage()
        {
            InitializeComponent();
            this.PageTitle.Caption = "水力模拟";
            this.PageTitle.HeaderSvgImage = this.svgImg32[0];
            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden;
        }
 
        private HStation.Vmo.XhsProjectVmo _project = null;//项目
        private HStation.Vmo.XhsProjectSiteVmo _projectSite = null;//项目站
        private Yw.Model.HydroModelInfo _hydroInfo = null;//水力信息
 
        private Yw.Model.HydroParterInfo _parter = null;
        private Yw.WinFrmUI.HydroCheckResult _checkResult = null;
        private Yw.EPAnet.CalcuResult _calcuResult = null;
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public async Task SetBindingData
            (
                HStation.Vmo.XhsProjectVmo project,
                HStation.Vmo.XhsProjectSiteVmo projectSite,
                Yw.Model.HydroModelInfo hydroInfo
            )
        {
            if (project == null)
            {
                return;
            }
            _project = project;
            _projectSite = projectSite;
            _hydroInfo = hydroInfo;
            if (_projectSite == null)
            {
                _projectSite = await BLLFactory<HStation.BLL.XhsProjectSite>.Instance.GetDefaultByProjectID(_project.ID);
            }
            if (_hydroInfo == null)
            {
                var hydroRelation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance
                    .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation);
                _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID);
            }
        }
 
        /// <summary>
        /// 初始化数据
        /// </summary>
        public override async void InitialDataSource()
        {
            base.InitialDataSource();
            if (_project == null)
            {
                return;
            }
            this.PageTitle.Caption = $"{_project.Name}\r\n水力模拟";
            var bimfaceCtrl = GetBimfaceCtrl();
            this.tabPageBimface.Controls.Clear();
            this.tabPageBimface.Controls.Add(bimfaceCtrl);
            await bimfaceCtrl.InitialData(_project, _projectSite, () => _hydroInfo);
            var q3dCtrl = GetQ3dCtrl();
            this.tabPageQ3d.Controls.Clear();
            this.tabPageQ3d.Controls.Add(q3dCtrl);
            q3dCtrl.InitialData(() => _hydroInfo);
            var propertyCtrl = GetPropertyCtrl();
            this.controlContainerRight.Controls.Clear();
            this.controlContainerRight.Controls.Add(propertyCtrl);
            propertyCtrl.InitialData(() => _hydroInfo);
        }
 
        #region Bimface
 
        //获取 bimface 控件
        private XhsProjectSimulationBimfaceCtrl GetBimfaceCtrl()
        {
            if (_bimfaceCtrl == null)
            {
                _bimfaceCtrl = new XhsProjectSimulationBimfaceCtrl();
                _bimfaceCtrl.Dock = DockStyle.Fill;
                _bimfaceCtrl.LoadCompletedEvent += async () =>
                {//view加载完成事件
                    if (_hydroInfo == null)
                    {
                        return;
                    }
                    var elementIds = new List<string>();
                    var pumps = _hydroInfo.Pumps?.Where(x => x.LinkStatus == Yw.Hydro.PumpStatus.Open).ToList();
                    pumps?.ForEach(x => elementIds.Add(x.Code));
                    var valves = _hydroInfo.Valves?.Where(x => x.LinkStatus == Yw.Hydro.ValveStatus.Open).ToList();
                    valves?.ForEach(x => elementIds.Add(x.Code));
                    await _bimfaceCtrl?.SetOpenComponentsColor(elementIds);
                };
                _bimfaceCtrl.HydroMouseLeftClickEvent += (obj) =>
                {//鼠标左键点击事件
                    if (_hydroInfo == null)
                    {
                        return;
                    }
                    _parter = obj;
                    ShowProperty();
                    SetBimfaceLinkColor();
                };
            }
            return _bimfaceCtrl;
        }
 
        //bimface控件
        private XhsProjectSimulationBimfaceCtrl _bimfaceCtrl = null;
 
        //设置Bimface连接颜色
        private async void SetBimfaceLinkColor()
        {
            if (_hydroInfo == null)
            {
                return;
            }
            if (_parter != null)
            {
                if (_parter is Yw.Model.HydroLinkInfo link)
                {
                    await _bimfaceCtrl?.RestoreLinkComponentsColor();
 
                    var allVisualList = _hydroInfo.GetAllVisuals();
                    var allLinkList = _hydroInfo.GetAllLinks();
                    var startParter = allVisualList?.Find(x => x.Code == link.StartCode);
                    if (startParter != null)
                    {
                        var startElementIds = new List<string>();
                        if (startParter.GetType() == typeof(Yw.Model.HydroJunctionInfo))
                        {
                            var startLinkList = allLinkList?.Where(x => x.StartCode == startParter.Code || x.EndCode == startParter.Code && x.Code != _parter.Code).ToList();
                            if (startLinkList != null && startLinkList.Count > 0)
                            {
                                startElementIds.AddRange(startLinkList.Select(x => x.Code));
                            }
                        }
                        else
                        {
                            startElementIds.Add(startParter.Code);
                        }
                        if (startElementIds.Count > 0)
                        {
                            await _bimfaceCtrl?.SetLinkStartComponentsColor(startElementIds);
                        }
                    }
                    var endParter = allVisualList?.Find(x => x.Code == link.EndCode);
                    if (endParter != null)
                    {
                        var endElementIds = new List<string>();
                        if (endParter.GetType() == typeof(Yw.Model.HydroJunctionInfo))
                        {
                            var endLinkList = allLinkList?.Where(x => x.StartCode == endParter.Code || x.EndCode == endParter.Code && x.Code != _parter.Code).ToList();
                            if (endLinkList != null && endLinkList.Count > 0)
                            {
                                endElementIds.AddRange(endLinkList.Select(x => x.Code));
                            }
                        }
                        else
                        {
                            endElementIds.Add(endParter.Code);
                        }
                        if (endElementIds.Count > 0)
                        {
                            await _bimfaceCtrl?.SetLinkEndComponentsColor(endElementIds);
                        }
                    }
                }
            }
        }
 
        #endregion Bimface
 
        #region Q3d
 
        //获取Q3d控件
        private XhsProjectSimulationQ3dCtrl GetQ3dCtrl()
        {
            if (_q3dCtrl == null)
            {
                _q3dCtrl = new XhsProjectSimulationQ3dCtrl();
                _q3dCtrl.Dock = DockStyle.Fill;
                _q3dCtrl.SelectedPartersChangedEvent += (obj) =>
                {
                    if (_hydroInfo == null)
                    {
                        return;
                    }
                    var allParterList = _hydroInfo.GetAllParters();
                    _parter = allParterList?.Find(x => x.Code == obj?.FirstOrDefault());
                    ShowProperty();
                };
            }
            return _q3dCtrl;
        }
 
        //Q3d控件
        private XhsProjectSimulationQ3dCtrl _q3dCtrl = null;
 
        #endregion Q3d
 
        #region 属性面板
 
        //获取属性控件
        private XhsProjectSimulationPropertyCtrl GetPropertyCtrl()
        {
            if (_propertyCtrl == null)
            {
                _propertyCtrl = new XhsProjectSimulationPropertyCtrl();
                _propertyCtrl.Dock = DockStyle.Fill;
            }
            return _propertyCtrl;
        }
 
        private XhsProjectSimulationPropertyCtrl _propertyCtrl = null;//属性控件
 
        #endregion 属性面板
 
        #region 自动匹配
 
        //获取匹配列表控件
        private XhsProjectSimulationMatchingListCtrl GetMatchingListCtrl()
        {
            if (_matchingListCtrl == null)
            {
                _matchingListCtrl = new XhsProjectSimulationMatchingListCtrl();
                _matchingListCtrl.Dock = DockStyle.Fill;
                _matchingListCtrl.HydroClickEvent += async (code) =>
                {
                    if (_hydroInfo == null)
                    {
                        return;
                    }
                    var allParterList = _hydroInfo.GetAllParters();
                    _parter = allParterList?.Find(x => x.Code == code);
                    var elementIds = new List<string>();
                    if (_parter != null)
                    {
                        elementIds.Add(_parter.Code);
                    }
                    await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
                    ShowProperty();
                    SetBimfaceLinkColor();
                };
                _matchingListCtrl.ApplyMatchingEvent += (output) =>
                {
                    if (_hydroInfo == null)
                    {
                        return false;
                    }
                    return AssetsMatchingParasHelper.Apply(_hydroInfo, output);
                };
            }
            return _matchingListCtrl;
        }
 
        //匹配列表控件
        private XhsProjectSimulationMatchingListCtrl _matchingListCtrl = null;
 
        //自动匹配
        private void barBtnMatchingList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_hydroInfo == null)
            {
                return;
            }
            this.controlContainerBottom.Controls.Clear();
            var matchingListCtrl = GetMatchingListCtrl();
            var input = AssetsMatchingParasHelper.Create(_hydroInfo);
            matchingListCtrl.SetBindingData(input);
            this.controlContainerBottom.Controls.Add(matchingListCtrl);
            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
            this.docPnlBottom.Text = "匹配列表";
            this.docPnlBottom.Height = 350;
        }
 
        #endregion 自动匹配
 
        #region 未匹配列表
 
        //获取未匹配列表控件
        private XhsProjectSimulationUnMatchingListCtrl GetUnMatchingListCtrl()
        {
            if (_unMatchingListCtrl == null)
            {
                _unMatchingListCtrl = new XhsProjectSimulationUnMatchingListCtrl();
                _unMatchingListCtrl.Dock = DockStyle.Fill;
                _unMatchingListCtrl.HydroClickEvent += async (parter) =>//行点击
                {
                    if (parter == null)
                    {
                        return;
                    }
                    if (_hydroInfo == null)
                    {
                        return;
                    }
                    var allParterList = _hydroInfo.GetAllParters();
                    _parter = allParterList?.Find(x => x.Code == parter.Code);
                    var elementIds = new List<string>() { parter.Code };
                    await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
                    ShowProperty();
                    SetBimfaceLinkColor();
                };
                _unMatchingListCtrl.ViewModelEvent += async (parters) =>//查看模型
                {
                    var codes = parters?.Select(x => x.Code).Distinct().ToList();
                    await _bimfaceCtrl?.ZoomAndSelectComponents(codes);
                    _parter = null;
                    ShowProperty();
                };
            }
            return _unMatchingListCtrl;
        }
 
        private XhsProjectSimulationUnMatchingListCtrl _unMatchingListCtrl = null;//未匹配列表
 
        //未匹配列表
        private void barBtnUnMatchingList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_hydroInfo == null)
            {
                return;
            }
            this.controlContainerBottom.Controls.Clear();
            var unMatchingListCtrl = GetUnMatchingListCtrl();
            unMatchingListCtrl.SetBindingData(_hydroInfo);
            this.controlContainerBottom.Controls.Add(unMatchingListCtrl);
            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
            this.docPnlBottom.Text = "未匹配列表";
            this.docPnlBottom.Height = 350;
        }
 
        #endregion 未匹配列表
 
        #region 一键显隐
 
        //显隐编码列表
        private List<string> _fastShowHideCodeList = null;
 
        //触发一键显隐
        private async void barBtnShowHide_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_hydroInfo == null)
            {
                return;
            }
            if (_hydroInfo.Decorators == null || _hydroInfo.Decorators.Count < 1)
            {
                return;
            }
            if (_fastShowHideCodeList == null)
            {
                _fastShowHideCodeList = _hydroInfo.Decorators.Select(x => x.Code).ToList();
                await _bimfaceCtrl?.HideComponents(_fastShowHideCodeList);
            }
            else
            {
                await _bimfaceCtrl?.ShowComponents(_fastShowHideCodeList);
                _fastShowHideCodeList = null;
            }
        }
 
        #endregion 一键显隐
 
        #region 水力校验
 
        //获取校验结果控件
        private XhsProjectSimulationHydroCheckResultCtrl GetCheckResultCtrl()
        {
            if (_checkResultCtrl == null)
            {
                _checkResultCtrl = new XhsProjectSimulationHydroCheckResultCtrl();
                _checkResultCtrl.Dock = DockStyle.Fill;
                _checkResultCtrl.HydroClickEvent += async (code) =>
                {
                    if (_hydroInfo == null)
                    {
                        return;
                    }
                    var elementIds = new List<string>();
                    if (string.IsNullOrEmpty(code))
                    {
                        _parter = null;
                    }
                    else
                    {
                        var allParterList = _hydroInfo.GetAllParters();
                        _parter = allParterList?.Find(x => x.Code == code);
                        if (_parter != null)
                        {
                            elementIds.Add(_parter.Code);
                        }
                    }
                    await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
                    ShowProperty();
                    SetBimfaceLinkColor();
                };
            }
            return _checkResultCtrl;
        }
 
        //校验结果控件
        private XhsProjectSimulationHydroCheckResultCtrl _checkResultCtrl = null;
 
        //水力验证
        private void barBtnHydroCheck_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_hydroInfo == null)
            {
                return;
            }
            _checkResult = _hydroInfo.Check();
            this.controlContainerBottom.Controls.Clear();
            var checkResultCtrl = GetCheckResultCtrl();
            checkResultCtrl.SetBindingData(_checkResult);
            this.controlContainerBottom.Controls.Add(checkResultCtrl);
            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
            this.docPnlBottom.Text = "校验结果";
            this.docPnlBottom.Height = 350;
        }
 
        #endregion 水力校验
 
        #region 保存水力信息
 
        //保存
        private async void barBtnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_hydroInfo == null)
            {
                return;
            }
            var id = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.Save(_hydroInfo);
            if (id < 1)
            {
                TipFormHelper.ShowError("保存失败!");
                return;
            }
            _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(id);
            TipFormHelper.ShowSucceed("保存成功!");
        }
 
        #endregion 保存水力信息
 
        #region 构件明细
 
        //获取构件明细控件
        private Yw.WinFrmUI.HydroParterListCtrl GetParterListCtrl()
        {
            if (_parterListCtrl == null)
            {
                _parterListCtrl = new HydroParterListCtrl();
                _parterListCtrl.Dock = DockStyle.Fill;
                _parterListCtrl.HydroClickEvent += async (parter) =>
                {
                    if (_hydroInfo == null)
                    {
                        return;
                    }
                    var allParterList = _hydroInfo.GetAllParters();
                    _parter = allParterList?.Find(x => x.Code == parter.Code);
                    await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _parter.Code });
                    ShowProperty();
                    SetBimfaceLinkColor();
                };
            }
            return _parterListCtrl;
        }
 
        //构件明细控件
        private Yw.WinFrmUI.HydroParterListCtrl _parterListCtrl = null;
 
        //水力构件列表
        private void barBtnHydroParterList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_hydroInfo == null)
            {
                return;
            }
            this.controlContainerBottom.Controls.Clear();
            var parterListCtrl = GetParterListCtrl();
            parterListCtrl.SetBindingData(_hydroInfo);
            this.controlContainerBottom.Controls.Add(parterListCtrl);
            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
            this.docPnlBottom.Text = "构件明细";
            this.docPnlBottom.Height = 350;
        }
 
        #endregion 构件明细
 
        #region INP导出
 
        //导出水力INP文件
        private void barBtnHydroExportInp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_hydroInfo == null)
            {
                return;
            }
            var fileName = Yw.WinFrmUI.FileDialogHelper.SaveInp("导出Inp文件");
            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }
            var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo);
            var result = netWork.ToInpString();
            File.WriteAllText(fileName, result);
            TipFormHelper.ShowSucceed("导出成功");
        }
 
        #endregion INP导出
 
        #region 业务方法
 
        //显示属性
        private void ShowProperty()
        {
            if (_hydroInfo == null)
            {
                return;
            }
 
            if (_parter == null)
            {
                _propertyCtrl?.SelectParter(null);
                return;
            }
 
            _propertyCtrl?.SelectParter(_parter.Code);
            if (_calcuResult != null)
            {
                if (_calcuResult.Succeed)
                {
                    var allCalcuParterList = _calcuResult.GetParterList();
                    var calcuParter = allCalcuParterList.Find(x => x.Id == _parter.Code);
                    if (calcuParter != null)
                    {
                        IHydroCalcuResult calcuProperty = null;
                        if (calcuParter is Yw.EPAnet.CalcuNode calcuNode)
                        {
                            var calcuNodeProperty = new Yw.WinFrmUI.HydroCalcuNodeResult();
                            calcuNodeProperty.Code = _parter.Code;
                            calcuNodeProperty.CalcuPress = calcuNode.Press;
                            calcuNodeProperty.CalcuDemand = calcuNode.Demand;
                            calcuNodeProperty.CalcuHead = calcuNode.Head;
                            calcuProperty = calcuNodeProperty;
                        }
                        else if (calcuParter is Yw.EPAnet.CalcuLink calcuLink)
                        {
                            var calcuLinkProperty = new Yw.WinFrmUI.HydroCalcuLinkResult();
                            calcuLinkProperty.Code = _parter.Code;
                            calcuLinkProperty.CalcuHeadLoss = calcuLink.Headloss;
                            calcuLinkProperty.CalcuFlow = calcuLink.Flow;
                            calcuLinkProperty.CalcuVelocity = calcuLink.Velocity;
                            calcuProperty = calcuLinkProperty;
                        }
 
                        if (calcuProperty != null)
                        {
                            _propertyCtrl?.UpdateCalcuProperty(calcuProperty);
                        }
                    }
                }
            }
        }
 
        #endregion 业务方法
 
        #region 配置
 
        //显示RadialMenu
        private void barBtnSetList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            this.rmSet.ShowPopup(MousePosition, true);
        }
 
        #endregion 配置
 
        #region 性能曲线
 
        //性能曲线
        private void barBtnFeatCurve_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_hydroInfo == null)
            {
                return;
            }
            if (_calcuResult == null)
            {
                return;
            }
            if (!_calcuResult.Succeed)
            {
                return;
            }
            var pumps = _hydroInfo.Pumps;
            var curve_list = _hydroInfo.Curves;
            if (curve_list == null || !curve_list.Any())
            {
                return;
            }
            var vmList = new List<Yw.WinFrmUI.Phart.PumpSerialParallelViewModel>();
            foreach (var x in pumps)
            {
                if (!x.RatedN.HasValue)
                {
                    continue;
                }
                var qh = curve_list.Find(t => t.Code == x.CurveQH)?.CurveData;
                var qe = curve_list.Find(t => t.Code == x.CurveQE)?.CurveData;
                var qp = curve_list.Find(t => t.Code == x.CurveQP)?.CurveData;
 
                if (qh == null)
                {
                    continue;
                }
 
                var rated_speed = x.RatedN.Value;
                var speed_ratio = x.SpeedRatio;
 
                var qh_pt_list = qh.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                var qe_pt_list = qe?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                var qp_pt_list = qp?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
 
                var vm = new Yw.WinFrmUI.Phart.PumpSerialParallelViewModel();
                vm.Id = x.Code;
                vm.Name = x.Code;
                //vm.IsBp = ;
                vm.RatedSpeed = rated_speed;
                vm.CurrentSpeed = Math.Round(rated_speed * speed_ratio);
                vm.CurrentHz = Math.Round(vm.CurrentSpeed / vm.RatedSpeed * 50, 1);
 
                vm.Qh = new Yw.Geometry.CubicSpline2d(qh_pt_list);
                vm.Qe = new Yw.Geometry.CubicSpline2d(qe_pt_list);
                vm.Qp = new Yw.Geometry.CubicSpline2d(qp_pt_list);
                vmList.Add(vm);
            }
 
            var dlg = new HStation.WinFrmUI.PhartRelation.PumpSerialParallelChartDlg();
            dlg.SetBindingData(vmList, null, true);
            dlg.ShowDialog();
        }
 
        #endregion 性能曲线
 
        #region 水力计算
 
        //获取计算控件
        private XhsProjectSimulationCalcuCtrl GetCalcuCtrl()
        {
            if (_calcuCtrl == null)
            {
                _calcuCtrl = new XhsProjectSimulationCalcuCtrl();
                _calcuCtrl.Dock = DockStyle.Fill;
                _calcuCtrl.CancelEvent += () =>
                    {
                        this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden;
                    };
                _calcuCtrl.OkEvent += async () =>
                    {
                        if (_hydroInfo == null)
                        {
                            return;
                        }
                        _checkResult = _hydroInfo.Check();
                        if (!_checkResult.Succeed)
                        {
                            this.controlContainerBottom.Controls.Clear();
                            var checkResultCtrl = GetCheckResultCtrl();
                            checkResultCtrl.SetBindingData(_checkResult);
                            this.controlContainerBottom.Controls.Add(checkResultCtrl);
                            TipFormHelper.ShowWarn("校验失败,请检查后重试");
                            return;
                        }
 
                        var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo);
                        _calcuResult = netWork.Calcu();
                        if (_calcuResult.Succeed)
                        {
                            this.controlContainerBottom.Controls.Clear();
                            var parterListCtrl = GetParterListCtrl();
                            var calcuResultList = new List<IHydroCalcuResult>();
                            _calcuResult.NodeList?.ForEach(x =>
                            {
                                calcuResultList.Add(new HydroCalcuNodeResult()
                                {
                                    Code = x.Id,
                                    CalcuPress = x.Press,
                                    CalcuHead = x.Head,
                                    CalcuDemand = x.Demand,
                                });
                            });
                            _calcuResult.LinkList?.ForEach(x =>
                            {
                                calcuResultList.Add(new HydroCalcuLinkResult()
                                {
                                    Code = x.Id,
                                    CalcuFlow = x.Flow,
                                    CalcuVelocity = x.Velocity,
                                    CalcuHeadLoss = x.Headloss
                                });
                            });
                            parterListCtrl.SetBindingData(_hydroInfo, calcuResultList);
                            parterListCtrl.SetCalcuView();
                            this.controlContainerBottom.Controls.Add(parterListCtrl);
                            this.docPnlBottom.Text = "计算结果";
                            ShowProperty();
                            await _bimfaceCtrl?.ShowCalcuCustomLabels(_calcuResult);
                            TipFormHelper.ShowSucceed("计算成功!");
                        }
                        else
                        {
                            _calcuCtrl.SetBindingData(_calcuResult.FailedList);
                            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
                            this.docPnlBottom.Text = "计算失败原因";
                            this.docPnlBottom.Height = 350;
                            TipFormHelper.ShowError("计算失败");
                        }
                    };
            }
            return _calcuCtrl;
        }
 
        private XhsProjectSimulationCalcuCtrl _calcuCtrl = null;//计算控件
 
        //水力计算
        private void barBtnHydroCalcu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_hydroInfo == null)
            {
                return;
            }
 
            this.controlContainerBottom.Controls.Clear();
            var calcuCtrl = GetCalcuCtrl();
            calcuCtrl.SetBindingData(_hydroInfo);
            this.controlContainerBottom.Controls.Add(calcuCtrl);
            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
            this.docPnlBottom.Text = "计算前提条件";
            this.docPnlBottom.Height = 350;
        }
 
        #endregion 水力计算
 
        #region 构件查询
 
        //获取查询组件
        private XhsProjectSimulationSearchCtrl GetSearchCtrl()
        {
            if (_searchCtrl == null)
            {
                _searchCtrl = new XhsProjectSimulationSearchCtrl();
                _searchCtrl.Dock = DockStyle.Fill;
                _searchCtrl.InitialData(() => _hydroInfo);
                _searchCtrl.ApplySearchEvent += async (list) =>
                {
                    if (_hydroInfo == null)
                    {
                        return;
                    }
                    var elementIds = new List<string>();
                    if (list != null && list.Count > 0)
                    {
                        var first = list.First();
                        var allParterList = _hydroInfo.GetAllParters();
                        _parter = allParterList?.Find(x => x.Code == first.Code);
                        list.ForEach(x => elementIds.Add(x.Code));
                    }
                    else
                    {
                        _parter = null;
                    }
                    await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
                    ShowProperty();
                    SetBimfaceLinkColor();
                };
            }
            return _searchCtrl;
        }
 
        private XhsProjectSimulationSearchCtrl _searchCtrl = null;//查询组件
 
        //查询
        private void barBtnSearch_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_hydroInfo == null)
            {
                return;
            }
 
            this.controlContainerBottom.Controls.Clear();
            var searchCtrl = GetSearchCtrl();
            this.controlContainerBottom.Controls.Add(searchCtrl);
            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
            this.docPnlBottom.Text = "模型构件查询";
            this.docPnlBottom.Height = 350;
        }
 
        #endregion 构件查询
 
        #region 标注
 
        private List<HydroMarkSetViewModel> _allMarkList = null;
 
        //标注
        private void barBtnMark_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_hydroInfo == null)
            {
                return;
            }
            if (_allMarkList == null)
            {
                _allMarkList = new List<HydroMarkSetViewModel>();
                if (_hydroInfo.Waterboxs != null && _hydroInfo.Waterboxs.Count > 0)
                {
                    _allMarkList.Add(new HydroMarkSetViewModel()
                    {
                        Code = Yw.Hydro.ParterCatalog.Waterbox,
                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Waterbox),
                        MarkType = (int)eWaterboxMarkType.None
                    });
                }
                if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0)
                {
                    _allMarkList.Add(new HydroMarkSetViewModel()
                    {
                        Code = Yw.Hydro.ParterCatalog.Pump,
                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pump),
                        MarkType = (int)eWaterboxMarkType.None
                    });
                }
                if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0)
                {
                    _allMarkList.Add(new HydroMarkSetViewModel()
                    {
                        Code = Yw.Hydro.ParterCatalog.Valve,
                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Valve),
                        MarkType = (int)eWaterboxMarkType.None
                    });
                }
                if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0)
                {
                    _allMarkList.Add(new HydroMarkSetViewModel()
                    {
                        Code = Yw.Hydro.ParterCatalog.Pipe,
                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pipe),
                        MarkType = (int)eWaterboxMarkType.None
                    });
                }
                if (_hydroInfo.Nozzles != null && _hydroInfo.Nozzles.Count > 0)
                {
                    _allMarkList.Add(new HydroMarkSetViewModel()
                    {
                        Code = Yw.Hydro.ParterCatalog.Nozzle,
                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Nozzle),
                        MarkType = (int)eWaterboxMarkType.None
                    });
                }
            }
            var dlg = new SetHydroMarkDlg();
            dlg.SetBindingData(() => _hydroInfo, _allMarkList);
            dlg.ReloadDataEvent += async (obj) =>
            {
                var leadLabels = obj?.Select(x => new LogicMarkLeadLabel() { Id = x.Code, Text = x.Text }).ToList();
                await _bimfaceCtrl?.SetLogicMarkLeadLabels(leadLabels);
            };
            dlg.ShowDialog();
        }
 
        #endregion 标注
    }
}