tangxu
2024-04-24 1c5fa983ae3506c2edaa88c51a959d46685c1ba1
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
using DevExpress.XtraCharts;
using DevExpress.XtraEditors;
using IStation.Unit;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace IStation.WinFrmUI.River
{
    public partial class RiverWaterLevelDropByPumpCountCtrl : XtraUserControl
    {
        public RiverWaterLevelDropByPumpCountCtrl()
        {
            InitializeComponent();
           
            //this.mainChart.BoxSelCompleteEvent += TimeValueEasyChartView1_BoxSelCompleteEvent;
        }
        public class ChartViewModel
        {
            public DateTime Time { get; set; }
            public double RiverHeight { get; set; }
            public double BoxHeight { get; set; }
            public double Drop  { get; set; } 
        }
        public class GridViewModel
        {
            public string Name { get; set; }
            public double Averay { get; set; }
            public double Percent { get; set; } 
        }
 
 
        List<ChartViewModel> _allBindList1 = null;
        List<ChartViewModel> _allBindList2 = null;
        List<ChartViewModel> _allBindList3 = null;
        List<ChartViewModel> _allBindList4 = null;
        List<ChartViewModel> _allBindList5 = null;
 
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(List<Model.MonthSignalRecordPacket> allPacketList)
        {
   
 
 
            _allBindList1 = new List<ChartViewModel>();
            _allBindList2 = new List<ChartViewModel>();
            _allBindList3 = new List<ChartViewModel>();
            _allBindList4 = new List<ChartViewModel>();
            _allBindList5 = new List<ChartViewModel>();
            List<GridViewModel> grids = new List<GridViewModel>(5)
            {
                new GridViewModel(){ Name="一台",Averay=0,Percent=0},
                new GridViewModel(){ Name="两台",Averay=0,Percent=0},
                new GridViewModel(){ Name="三台",Averay=0,Percent=0},
                new GridViewModel(){ Name="四台",Averay=0,Percent=0},
                new GridViewModel(){ Name="五台",Averay=0,Percent=0},
            };
 
 
 
            foreach (var packet in allPacketList)
            {
                foreach (var r in packet.StationSignalRecords)
                {
                    if (r.PumpRunCount <= 0) continue;
                    if (r.ChangJiangWL == null) continue;
                    if (r.QianChiWL == null) continue;
                    if (r.ChangJiangWL <= -100  ) continue;
                    if (r.QianChiWL <= -100  ) continue;
                    var b = new ChartViewModel()
                    {
                        Time = r.Time,
                        RiverHeight = r.ChangJiangWL.Value,
                        BoxHeight = r.QianChiWL.Value,
                    };
                    b.Drop = Math.Round( b.RiverHeight - b.BoxHeight,2);
                    if (b.Drop > 8.5) continue;
                    double flow = 0;
                    foreach (var p in r.PumpSignalRecords)
                        flow += p.FlowRate == null ? 0 : p.FlowRate.Value;
 
                    if (flow < 20000)
                        continue;
 
                    if (r.PumpRunCount == 1)
                        _allBindList1.Add(b);
                    if (r.PumpRunCount == 2)
                        _allBindList2.Add(b);
                    if (r.PumpRunCount == 3)
                        _allBindList3.Add(b);
                    if (r.PumpRunCount == 4)
                        _allBindList4.Add(b);
                    if (r.PumpRunCount == 5)
                        _allBindList5.Add(b);
                }
            }
            int total_count =
                _allBindList1.Count + _allBindList2.Count +
                 _allBindList3.Count + _allBindList4.Count
                 + _allBindList5.Count;
 
            List<DevExpress.XtraCharts.Series> sss = new List<Series>(5);
            this.chartControl1.Series.Clear();
 
            if(_allBindList1.Count > 0)
            {
                DevExpress.XtraCharts.LineSeriesView lineSeriesView1 = new DevExpress.XtraCharts.LineSeriesView();
 
                DevExpress.XtraCharts.Series series = new DevExpress.XtraCharts.Series();
                series.Name = "开一台泵";
                series.View = lineSeriesView1;
                series.CrosshairLabelPattern = "开一台泵 {A}  落差: {V}";
 
                foreach(var t in _allBindList1)
                {
                    series.Points.Add(new DevExpress.XtraCharts.SeriesPoint(
                                t.Time,
                                new double[] { t.Drop }));
                }
                grids[0].Averay = Math.Round((from x in _allBindList1 select x.Drop).Average(), 2);
                grids[0].Percent = Math.Round(_allBindList1.Count * 100.0 / total_count, 1);
                sss.Add(series);
            }
 
 
            if (_allBindList2.Count > 0)
            {
                DevExpress.XtraCharts.LineSeriesView lineSeriesView1 = new DevExpress.XtraCharts.LineSeriesView();
 
                DevExpress.XtraCharts.Series series = new DevExpress.XtraCharts.Series();
                series.Name = "开两台泵";
                series.View = lineSeriesView1;
                series.CrosshairLabelPattern = "开两台泵 {A}  落差: {V}";
 
                foreach (var t in _allBindList2)
                {
                    series.Points.Add(new DevExpress.XtraCharts.SeriesPoint(
                                t.Time,
                                new double[] { t.Drop }));
                }
                sss.Add(series);
 
                grids[1].Averay = Math.Round((from x in _allBindList2 select x.Drop).Average(), 2);
                grids[1].Percent = Math.Round(_allBindList2.Count * 100.0 / total_count, 1);
            }
 
 
 
 
            if (_allBindList3.Count > 0)
            {
                DevExpress.XtraCharts.LineSeriesView lineSeriesView1 = new DevExpress.XtraCharts.LineSeriesView();
 
                DevExpress.XtraCharts.Series series = new DevExpress.XtraCharts.Series();
                series.Name = "开三台泵";
                series.View = lineSeriesView1;
                series.CrosshairLabelPattern = "开三台泵 {A}  落差: {V}";
 
                foreach (var t in _allBindList3)
                {
                    series.Points.Add(new DevExpress.XtraCharts.SeriesPoint(
                                t.Time,
                                new double[] { t.Drop }));
                }
                sss.Add(series);
 
                grids[2].Averay = Math.Round((from x in _allBindList3 select x.Drop).Average(), 2);
                grids[2].Percent = Math.Round(_allBindList3.Count * 100.0 / total_count, 1);
            }
 
 
 
 
 
 
 
            if (_allBindList4.Count > 0)
            {
                DevExpress.XtraCharts.LineSeriesView lineSeriesView1 = new DevExpress.XtraCharts.LineSeriesView();
 
                DevExpress.XtraCharts.Series series = new DevExpress.XtraCharts.Series();
                series.Name = "开四台泵";
                series.View = lineSeriesView1;
                series.CrosshairLabelPattern = "开四台泵 {A}  落差: {V}";
 
                foreach (var t in _allBindList4)
                {
                    series.Points.Add(new DevExpress.XtraCharts.SeriesPoint(
                                t.Time,
                                new double[] { t.Drop }));
                }
                sss.Add(series);
 
                grids[3].Averay = Math.Round((from x in _allBindList4 select x.Drop).Average(), 2);
                grids[3].Percent = Math.Round(_allBindList4.Count * 100.0 / total_count, 1);
            }
 
 
 
 
            if (_allBindList5.Count > 0)
            {
                DevExpress.XtraCharts.LineSeriesView lineSeriesView1 = new DevExpress.XtraCharts.LineSeriesView();
 
                DevExpress.XtraCharts.Series series = new DevExpress.XtraCharts.Series();
                series.Name = "开五台泵";
                series.View = lineSeriesView1;
                series.CrosshairLabelPattern = "开五台泵 {A}  落差: {V}";
 
                foreach (var t in _allBindList5)
                {
                    series.Points.Add(new DevExpress.XtraCharts.SeriesPoint(
                                t.Time,
                                new double[] { t.Drop }));
                }
                sss.Add(series);
 
                grids[4].Averay = Math.Round((from x in _allBindList5 select x.Drop).Average(), 2);
                grids[4].Percent = Math.Round(_allBindList5.Count * 100.0 / total_count, 1);
            }
 
 
 
 
 
 
 
 
 
 
 
            this.bindingSource1.DataSource = grids;
 
 
 
 
            this.chartControl1.SeriesSerializable = sss.ToArray();
        }
    }
 
}