lixiaojun
2024-12-20 44c67892cddc9b7f7091e446fc2030f0b22a82b3
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
using Yw.WinFrmUI.Bimface;
 
namespace HStation.WinFrmUI
{
    /// <summary>
    /// 计算结果标签辅助类
    /// </summary>
    public class SimulationCalcuResultLabelHelper
    {
        /// <summary>
        /// 
        /// </summary>
        public SimulationCalcuResultLabelHelper
            (
                SimulationCalcuResultHelper calcuResultHelper,
                ISimulationCalcuResultLabelView view
            )
        {
            _calcuResultHelper = calcuResultHelper;
            _views = new List<ISimulationCalcuResultLabelView>() { view };
        }
 
        private SimulationCalcuResultHelper _calcuResultHelper = null;//计算结果辅助类
        private List<ISimulationCalcuResultLabelView> _views = null;//视图列表
 
        /// <summary>
        /// 可见性
        /// </summary>
        public bool Visible
        {
            get { return _visible; }
            set { _visible = value; }
        }
        private bool _visible = false;
 
        /// <summary>
        /// 设置
        /// </summary>
        public void Set()
        {
            if (this.Visible)
            {
                var labels = GetLabels();
                if (labels != null && labels.Count > 0)
                {
                    _views.ForEach(async x => await x.SetLogicCalcuCustomLabels(labels));
                    return;
                }
            }
            _views.ForEach(async x => await x.ClearLogicCalcuCustomLabels());
        }
 
        //获取计算标签
        private List<LogicCalcuCustomLabel> GetLabels()
        {
            if (!_calcuResultHelper.Initialized)
            {
                return default;
            }
            var allCalcuResultVisualDict = _calcuResultHelper.GetVisualDict();
 
            var allCalcuLabels = new List<LogicCalcuCustomLabel>();
 
 
            #region 水泵
 
            _calcuResultHelper.HydroInfo.Pumps?.ForEach(x =>
            {
                var hz = Math.Round(x.RatedHz * x.SpeedRatio);
                var calcuPumpResult = allCalcuResultVisualDict.GetValue(x.Code) as HydroCalcuPumpResult;
                if (calcuPumpResult != null)
                {
                    var pumpCustomLabel = new LogicCalcuCustomLabel();
                    pumpCustomLabel.Id = x.Code;
                    pumpCustomLabel.Distance = 50000;
                    pumpCustomLabel.Data = new List<LogicCalcuCustomLabelItem>()
                        {
                                    new LogicCalcuCustomLabelItem(){ Name="状态",Value=HydroLinkStatusHelper.GetStatusName(x.LinkStatus),Unit=string.Empty},
                                    new LogicCalcuCustomLabelItem(){ Name="频率",Value=x.LinkStatus==Yw.Hydro.PumpStatus.Open?hz.ToString():"0",Unit="hz"},
                                    new LogicCalcuCustomLabelItem(){ Name="流量",Value=Math.Round(calcuPumpResult.CalcuQ.Value,1).ToString(),Unit="m³/h"},
                                    new LogicCalcuCustomLabelItem(){ Name="进口压力",Value=Math.Round(calcuPumpResult.CalcuPr1.Value,2).ToString(),Unit="m"},
                                    new LogicCalcuCustomLabelItem(){ Name="出口压力",Value=Math.Round(calcuPumpResult.CalcuPr2.Value,2).ToString(),Unit="m"},
                        };
                    allCalcuLabels.Add(pumpCustomLabel);
                }
            });
 
            #endregion
 
            #region 扩散器
 
            _calcuResultHelper.HydroInfo.GetAllEmitters()?.ForEach(x =>
            {
                var calcuEmitter = allCalcuResultVisualDict.GetValue(x.Code) as HydroCalcuEmitterResult;
                var emitterCustomLabel = new LogicCalcuCustomLabel();
                emitterCustomLabel.Id = x.Code;
                emitterCustomLabel.Distance = 50000;
                emitterCustomLabel.Data = new List<LogicCalcuCustomLabelItem>()
                    {
                          new LogicCalcuCustomLabelItem(){ Name="流量",Value=Math.Round(calcuEmitter.CalcuQ.Value,1).ToString(),Unit="m³/h"},
                          new LogicCalcuCustomLabelItem(){ Name="压力",Value=Math.Round(calcuEmitter.CalcuPr.Value,2).ToString(),Unit="m"}
                    };
                allCalcuLabels.Add(emitterCustomLabel);
            });
 
            #endregion
 
 
            return allCalcuLabels;
 
 
        }
 
 
 
    }
}