lixiaojun
2024-12-09 725f20b576bdd40d57d9a1e806ce3f6f39181a84
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
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.Geometry;
using Yw.Pump;
using Yw.WinFrmUI.Phart;
 
namespace HStation.WinFrmUI
{
    public partial class SimulationPumpAnalyChartCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public SimulationPumpAnalyChartCtrl()
        {
            InitializeComponent();
        }
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData
            (
                Yw.Model.HydroModelInfo hydroInfo,
                HydroCalcuResult calcuResult,
                Yw.Model.HydroPumpInfo pumpInfo
            )
        {
            var allCalcuResultVisualDict = calcuResult?.GetVisualDict();
            SetBindingData(hydroInfo, allCalcuResultVisualDict, pumpInfo);
        }
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData
            (
                Yw.Model.HydroModelInfo hydroInfo,
                Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict,
                Yw.Model.HydroPumpInfo pumpInfo
            )
        {
            if (hydroInfo == null)
            {
                return;
            }
            if (pumpInfo == null)
            {
                return;
            }
 
            var vm = new PumpRunViewViewModel();
            vm.Id = pumpInfo.Code;
            vm.Name = pumpInfo.Name;
            vm.CurveName = $"额定曲线({pumpInfo.RatedHz}hz)";
            vm.RatedQ = pumpInfo.RatedQ ?? 0;
            vm.RatedH = pumpInfo.RatedH ?? 0;
            vm.RatedP = pumpInfo.RatedP;
            vm.RatedN = pumpInfo.RatedN ?? 0;
            vm.RatedHz = pumpInfo.RatedHz;
            vm.Color = Color.Black;
 
            var curveqh = hydroInfo.Curves?.Find(x => x.Code == pumpInfo.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)
                {
                    vm.CurveQH = new CubicSpline2d(qh_pts);
                }
            }
 
            var curveqp = hydroInfo.Curves?.Find(x => x.Code == pumpInfo.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)
                {
                    vm.CurveQP = new CubicSpline2d(qp_pts);
                }
            }
 
            var curveqe = hydroInfo.Curves?.Find(x => x.Code == pumpInfo.CurveQE);
            if (curveqe != null)
            {
                var qepts = curveqe.CurveData?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                if (qepts != null && qepts.Count > 3)
                {
                    vm.CurveQE = new CubicSpline2d(qepts);
                }
            }
 
            if (pumpInfo.LinkStatus == Yw.Hydro.PumpStatus.Open)
            {
                vm.Items = new List<PumpRunViewItemViewModel>();
                var vmItem = new PumpRunViewItemViewModel();
                vm.Items.Add(vmItem);
                vmItem.Id = string.Empty;
                vmItem.Name = "运行";
                vmItem.Hz = Math.Round(pumpInfo.RatedHz * pumpInfo.SpeedRatio, 1);
                vmItem.Color = Color.Blue;
                if (pumpInfo.RatedN.HasValue)
                {
                    vmItem.N = Math.Round(pumpInfo.RatedN.Value * pumpInfo.SpeedRatio, 1);
                }
                var calcuResult = allCalcuResultVisualDict?.GetValue(pumpInfo.Code) as HydroCalcuPumpResult;
                if (calcuResult != null)
                {
                    vmItem.Q = calcuResult.CalcuQ ?? 0;
                    vmItem.H = calcuResult.CalcuH ?? 0;
                    vmItem.P = calcuResult.CalcuP;
                    vmItem.E = calcuResult.CalcuE;
                }
                vmItem.CurveName = $"运行曲线({vmItem.Hz}hz)";
 
                if (vm.CurveQH != null)
                {
                    var qh_pts = vm.CurveQH.GetPointList(20);
                    var qh_run_pts = qh_pts.GetQHPointListByN(vm.RatedHz, vmItem.Hz);
                    vmItem.CurveQH = new CubicSpline2d(qh_run_pts);
                }
 
                if (vm.CurveQP != null)
                {
                    var qp_pts = vm.CurveQP.GetPointList(20);
                    var qp_run_pts = qp_pts.GetQPPointListByN(vm.RatedHz, vmItem.Hz);
                    vmItem.CurveQP = new CubicSpline2d(qp_run_pts);
                }
 
                if (vm.CurveQE != null)
                {
                    var qe_pts = vm.CurveQE.GetPointList(20);
                    var qe_run_pts = qe_pts.GetQEPointListByN(vm.RatedHz, vmItem.Hz);
                    vmItem.CurveQE = new CubicSpline2d(qe_run_pts);
                }
            }
 
            SetBindingData(vm);
        }
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(PumpRunViewViewModel vm)
        {
            this.pumpRunViewChart1.SetBindingData(vm);
            //this.barCheckE.Checked=this.pumpRunViewChart1.
        }
 
        //效率线
        private void barCheckE_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //this.pumpRunViewChart1.SetEQVisible
        }
 
        //功率线
        private void barCheckP_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
 
        }
 
        //设置坐标轴
        private void barBtnCoord_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            this.pumpRunViewChart1.SetChartAxis();
        }
 
 
    }
}