Shuxia Ning
2024-10-23 47610ca1dd9075a2f0b58cbdb010b66aa95e78d2
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
using HStation.WinFrmUI.PhartRelation;
using SqlSugar;
 
namespace HStation.WinFrmUI.Xhs
{
    public partial class SinglePumpAnalyDlg : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public SinglePumpAnalyDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
            InitChart();
        }
 
        private void InitChart()
        {
            this.singlePumpAnalyInfoCtrl1.SetEvent += (id, hz, ex_ratio, qh, qe, qp) =>
            {
                this.pumpVariableSpeedChart1.Set(id, hz, ex_ratio, qh, qe, qp);
                ResetSectPointGrid();
            };
 
            this.singlePumpAnalyInfoCtrl1.SetInfoEvent += (id, color) =>
            {
                this.pumpVariableSpeedChart1.SetInfo(id, color);
                ResetSectPointGrid();
            };
 
 
            this.singlePumpAnalyInfoCtrl1.SetDesignPointEvent += (q, h) =>
            { 
                this.pumpVariableSpeedChart1.SetDesignPt(q,h);
                ResetSectPointGrid();
            };
 
            this.pumpVariableSpeedChart1.OnCalcQueryPoint += (id, pt) =>
            {
                this.singlePumpAnalyInfoCtrl1.SetQueryInfo(id, pt);
            };
            void ResetSectPointGrid()
            {
                var vm_list = this.pumpVariableSpeedChart1.GetList();
                ///this.singlePumpAnalyInfoCtrl1.SetSectPoint(vm_list);
            }
        }
 
        public void SetBindindData(PumpMatchingViewModel pump_matching)
        {
            InitChartData(pump_matching);
        }
 
        private SinglePumpAnalyViewModel _working_vm = null;
        private async void InitChartData(PumpMatchingViewModel pump_matching)
        {
            if (!long.TryParse(pump_matching.DbId, out long pump_main_id))
            {
                return;
            }
            var pump_main = await new BLL.AssetsPumpMain().GetByID(pump_main_id);
            if (pump_main == null)
            {
                return;
            }
 
            var phart_list = await new BLL.XhsPumpMainPhartMappingExtensions().GetByPumpMainID(pump_main_id);
            if (phart_list == null || !phart_list.Any())
            {
                return;
            }
            var phart = phart_list.OrderBy(x => x.Importance).First();
            var diagram = phart.Diagram;
            if (diagram == null)
            {
                return;
            }
            var graph_list = diagram.GraphList;
            if (graph_list == null || !graph_list.Any())
            {
                return;
            }
 
            var graph_qh = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQH);
            var graph_qe = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQE);
            var graph_qp = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQP);
            if (graph_qh == null)
            {
                return;
            }
 
            List<Yw.Geometry.Point2d> points_qh = null, points_qe = null, points_qp = null;
            points_qh = PhartPerformCurveHelper.GetFeatPointList(graph_qh.GraphType, graph_qh.GeometryInfo, 12, null);
            if (graph_qe != null)
                points_qe = PhartPerformCurveHelper.GetFeatPointList(graph_qe.GraphType, graph_qe.GeometryInfo, 12, null);
            if (graph_qp != null)
                points_qp = PhartPerformCurveHelper.GetFeatPointList(graph_qp.GraphType, graph_qp.GeometryInfo, 12, null);
 
            var qh = new Yw.Geometry.CubicSpline2d(points_qh);
            var qe = new Yw.Geometry.CubicSpline2d(points_qe);
            var qp = new Yw.Geometry.CubicSpline2d(points_qp);
 
 
 
            var def_vm = new SinglePumpAnalyViewModel();
            def_vm.Id = "def";
            def_vm.Name = "50";
            def_vm.RatedSpeed = pump_main.RatedSpeed;
            def_vm.CurrentSpeed = pump_main.RatedSpeed;
            def_vm.CurrentHz = 50;
            def_vm.IsDefault = true;
            def_vm.Color = Color.Black;
            def_vm.ExtendRatio = 100;
            def_vm.Qh = qh;
            def_vm.Qe = qe;
            def_vm.Qp = qp;
            def_vm.Calc();
            //_def_vm.QhCalc = qh;
            //_def_vm.QeCalc = qe;
            //_def_vm.QpCalc = qp;
 
            //_def_vm.SectQ = string.Empty;
            //_def_vm.SectH = string.Empty;
            //_def_vm.SectE = string.Empty;
            //_def_vm.SectP = string.Empty;
 
            //_def_vm.QueryQ = string.Empty;
            //_def_vm.QueryH = string.Empty;
            //_def_vm.QueryE = string.Empty;
            //_def_vm.QueryP = string.Empty;
 
            _working_vm = new SinglePumpAnalyViewModel();
            _working_vm.Id = "working";
            _working_vm.Name = pump_matching.CurrentHz.ToString();
            _working_vm.RatedSpeed = pump_main.RatedSpeed;
            _working_vm.CurrentSpeed = Math.Round(pump_matching.CurrentHz / 50 * pump_main.RatedSpeed, 1);
            _working_vm.CurrentHz = pump_matching.CurrentHz;
            _working_vm.IsDefault = false;
            _working_vm.Color = Color.Red;
            _working_vm.ExtendRatio = 100;
            _working_vm.Qh = qh;
            _working_vm.Qe = qe;
            _working_vm.Qp = qp;
            _working_vm.Calc();
 
 
            var list = new List<SinglePumpAnalyViewModel>() { def_vm, _working_vm };
            var list_yw = list.Select(x => x.ToInfo()).ToList();
 
            this.singlePumpAnalyInfoCtrl1.SetBindingData(list);
            this.pumpVariableSpeedChart1.Add(list_yw);
 
        }
 
 
 
 
    }
}