duheng
2024-11-27 5d8b95b69c1bf800f2a2ebee62c6f7181c0bd7c8
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
using DevExpress.Office.Utils;
using DevExpress.Xpo.Helpers;
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Yw.EPAnet;
using Yw.WinFrmUI.Q3d;
 
namespace Yw.WinFrmUI
{
    public partial class HydroEnergyTotalViewCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public HydroEnergyTotalViewCtrl()
        {
            InitializeComponent();
            this.layoutControl1.SetupLayoutControl();
        }
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, HydroCalcuResult calcuResult)
        {
            if (hydroInfo == null)
            {
                return;
            }
            if (calcuResult == null)
            {
                return;
            }
            if (!calcuResult.Succeed)
            {
                return;
            }
 
            var allCalcuResultVisualDict = calcuResult.GetVisualDict();
            SetBindingData(hydroInfo, allCalcuResultVisualDict);
        }
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict)
        {
            if (hydroInfo == null)
            {
                return;
            }
            if (allCalcuResultVisualDict == null || allCalcuResultVisualDict.Count < 1)
            {
                return;
            }
 
            double? totalQ = null;
            double? totalP = null;
            var allEfficiList = new List<double>();
            if (hydroInfo.Pumps != null && hydroInfo.Pumps.Count > 0)
            {
                foreach (var pump in hydroInfo.Pumps)
                {
                    if (!allCalcuResultVisualDict.ContainsKey(pump.Code))
                    {
                        continue;
                    }
                    var calcuResult = allCalcuResultVisualDict[pump.Code] as HydroCalcuPumpResult;
                    if (calcuResult == null)
                    {
                        continue;
                    }
                    if (pump.LinkStatus == Yw.Hydro.PumpStatus.Open)
                    {
                        if (calcuResult.CalcuQ.HasValue)
                        {
                            if (!totalQ.HasValue)
                            {
                                totalQ = 0;
                            }
                            totalQ += calcuResult.CalcuQ.Value;
                        }
                        if (calcuResult.CalcuP.HasValue)
                        {
                            if (!totalP.HasValue)
                            {
                                totalP = 0;
                            }
                            totalP += calcuResult.CalcuP.Value;
                        }
                        if (calcuResult.CalcuE.HasValue)
                        {
                            allEfficiList.Add(calcuResult.CalcuE.Value);
                        }
                    }
                }
            }
            if (totalQ.HasValue)
            {
                this.txtQ.EditValue = $"{Math.Round(totalQ.Value, 1)}m³/h";
            }
            if (totalP.HasValue)
            {
                this.txtP.EditValue = $"{Math.Round(totalP.Value, 1)}kW";
            }
            if (allEfficiList.Count > 0)
            {
                this.txtE.EditValue = $"{Math.Round(allEfficiList.Average(), 1)}%";
            }
        }
 
    }
}