lixiaojun
2025-02-19 aaac84e4ed86d089c01c5b180e4249db73cc78d7
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
using Mapster;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yw.Pump;
using Yw.WinFrmUI.Phart;
 
namespace HStation.WinFrmUI
{
    /// <summary>
    /// 水泵分析辅助类
    /// </summary>
    public class SimulationPrintPumpAnalyHelper
    {
        /// <summary>
        /// 创建
        /// </summary>
        public static SimulationPrintPumpAnalyViewModel Create
            (
                Yw.Model.HydroModelInfo hydroInfo,
                Yw.Vmo.HydroWorkingVmo working,
                HydroCalcuResult calcuResult = null,
                bool isHead = false,
                List<Yw.Vmo.HydroEvaluationVmo> allEvaluationList = null
            )
        {
            var vm = new SimulationPrintPumpAnalyViewModel();
 
            //验证
            if (hydroInfo == null)
            {
                return vm;
            }
            if (working == null)
            {
                return vm;
            }
 
 
            //赋值模型信息,避免干扰
            //var newHydroInfo = hydroInfo.Adapt<Yw.Model.HydroModelInfo>();
            //newHydroInfo.UpdateWorkingInfo(working.WorkingInfo);
            if (hydroInfo.Pumps == null || hydroInfo.Pumps.Count < 1)
            {
                return vm;
            }
 
            //计算结果
            if (calcuResult == null)
            {
                calcuResult = hydroInfo.Calcu(Yw.EPAnet.CalcuMode.MinorLoss, isHead, allEvaluationList);
                if (!calcuResult.Succeed)
                {
                    return vm;
                }
            }
            var allCalcuVisualDict = calcuResult.GetVisualDict();
 
            //遍历水泵
            vm.Items = new List<SimulationPrintPumpAnalyItemViewModel>();
            foreach (var pump in hydroInfo.Pumps)
            {
                var item = new SimulationPrintPumpAnalyItemViewModel();
                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;
                    }
                }
 
            }
 
            return vm;
        }
 
 
    }
}