duheng
2025-03-20 bc0ed5b6cfda6c72c06f451b77da8518c41ab210
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
namespace Yw.WinFrmUI
{
    /// <summary>
    /// 水泵分析辅助类
    /// </summary>
    public class HydroPumpAnalyHelper
    {
        /// <summary>
        /// 创建
        /// </summary>
        public static HydroPumpAnalyViewModel Create
            (
                Yw.Model.HydroModelInfo hydroInfo,
                Yw.Vmo.HydroWorkingVmo working,
                HydroCalcuResult calcuResult = null,
                bool isHead = false,
                List<Yw.Vmo.HydroEvaluationVmo> allEvaluationList = null
            )
        {
            //验证
            if (hydroInfo == null)
            {
                return default;
            }
            if (working == null)
            {
                return default;
            }
 
            //计算结果
            if (calcuResult == null)
            {
                hydroInfo.UpdateWorkingInfo(working.WorkingInfo);
                calcuResult = hydroInfo.Calcu(Yw.EPAnet.CalcuMode.MinorLoss, isHead, allEvaluationList);
                if (!calcuResult.Succeed)
                {
                    return default;
                }
            }
            var allCalcuVisualDict = calcuResult.GetVisualDict();
 
            var vm = new HydroPumpAnalyViewModel();
 
            //遍历水泵
            if (hydroInfo.Pumps != null && hydroInfo.Pumps.Count > 0)
            {
                vm.Items = new List<HydroPumpAnalyItemViewModel>();
                foreach (var pump in hydroInfo.Pumps)
                {
                    var item = new HydroPumpAnalyItemViewModel();
                    vm.Items.Add(item);
                    item.BeginGroup = string.IsNullOrEmpty(pump.BeginGroup) ? string.Empty : pump.BeginGroup;
                    item.Name = pump.Name;
                    item.Code = pump.Code;
                    item.RatedQ = pump.RatedQ;
                    item.RatedH = pump.RatedH;
                    item.RatedP = pump.RatedP;
                    item.RatedN = pump.RatedN;
                    item.RatedHz = pump.RatedHz;
                    var curveqh = hydroInfo.Curves?.Find(x => x.Code == pump.CurveQH);
                    if (curveqh != null)
                    {
                        var qh_pts = curveqh.CurveData?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                        if (qh_pts != null && qh_pts.Count > 3)
                        {
                            item.RatedCurveQH = qh_pts;
                        }
                    }
                    var curveqp = hydroInfo.Curves?.Find(x => x.Code == pump.CurveQP);
                    if (curveqp != null)
                    {
                        var qp_pts = curveqp.CurveData?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                        if (qp_pts != null && qp_pts.Count > 3)
                        {
                            item.RatedCurveQP = qp_pts;
                        }
                    }
                    var curveqe = hydroInfo.Curves?.Find(x => x.Code == pump.CurveQE);
                    if (curveqe != null)
                    {
                        var qe_pts = curveqe.CurveData?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                        if (qe_pts != null && qe_pts.Count > 3)
                        {
                            item.RatedCurveQE = qe_pts;
                        }
                    }
 
                    item.LinkStatus = pump.LinkStatus;
                    if (item.LinkStatus == Yw.Hydro.LinkStatus.Open)
                    {
                        item.CurrentN = Math.Round(item.RatedN * pump.SpeedRatio, 1);
                        item.CurrentHz = Math.Round(item.RatedHz * pump.SpeedRatio, 1);
                        var calcuPumpResult = allCalcuVisualDict?.GetValue(pump.Code) as HydroCalcuPumpResult;
                        if (calcuPumpResult != null)
                        {
                            item.CurrentQ = calcuPumpResult.CalcuQ;
                            item.CurrentH = calcuPumpResult.CalcuH;
                            item.CurrentP = calcuPumpResult.CalcuP;
                            item.CurrentE = calcuPumpResult.CalcuE;
                        }
                        if (item.RatedCurveQH != null)
                        {
                            var qh_pts = item.RatedCurveQH;
                            var qh_run_pts = qh_pts.GetQHPointListByN(item.RatedHz, item.CurrentHz);
                            item.CurrentCurveQH = qh_run_pts;
                        }
 
                        if (item.RatedCurveQP != null)
                        {
                            var qp_pts = item.RatedCurveQP;
                            var qp_run_pts = qp_pts.GetQPPointListByN(item.RatedHz, item.CurrentHz);
                            item.CurrentCurveQP = qp_pts;
                        }
 
                        if (item.RatedCurveQE != null)
                        {
                            var qe_pts = item.RatedCurveQE;
                            var qe_run_pts = qe_pts.GetQEPointListByN(item.RatedHz, item.CurrentHz);
                            item.CurrentCurveQE = qe_run_pts;
                        }
                    }
                }
                vm.Parallel = new HydroPumpAnalyParallelViewModel(vm.Items);
            }
 
            return vm;
        }
 
 
    }
}