duheng
8 天以前 4de480ec624d3b79ca690dc906e10cd2fbdc9be7
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Windows.Forms; 
using DevExpress.XtraCharts;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraRichEdit.Utils;
using IStation.CalcModel; 
 
namespace IStation.WinFrmUI.CalcErQu
{
    public partial class AnaResultInfoManuCtrl : UserControl
    {
        DevExpress.XtraCharts.XYDiagram mainDiagram;
        //计算时间跨度
        //protected int _calcSpaceMinute = 10;
        //public int CalcSpaceMinute { get { return _calcSpaceMinute; } set { _calcSpaceMinute = Book_Minor; } }
 
        DevExpress.XtraCharts.ConstantLine _moveConstantLineIn实时数据 = null;
 
        public AnaResultInfoManuCtrl()
        {
            InitializeComponent();
 
            tabPage实时数据.PageVisible = false;
 
            this.chartControl实时数据.CustomPaint += new DevExpress.XtraCharts.CustomPaintEventHandler(this.ChartControl实时数据_CustomPaint);
            this.chartControl实时数据.MouseClick += ChartControl实时数据_MouseClick;
            this.mainDiagram = this.chartControl实时数据.Diagram as DevExpress.XtraCharts.XYDiagram;
 
 
            _moveConstantLineIn实时数据 = mainDiagram.AxisX.ConstantLines[0];
            _moveConstantLineIn实时数据.Visible = false;
 
            CraeteMaxMinLabel();
        }
 
 
 
        private void CraeteMaxMinLabel()
        {
            DevExpress.XtraCharts.PaneAnchorPoint paneAnchorPoint1 = new DevExpress.XtraCharts.PaneAnchorPoint();
            DevExpress.XtraCharts.PaneAnchorPoint paneAnchorPoint2 = new DevExpress.XtraCharts.PaneAnchorPoint();
            DevExpress.XtraCharts.TextAnnotation textAnnotation1 = new DevExpress.XtraCharts.TextAnnotation();
            DevExpress.XtraCharts.TextAnnotation textAnnotation2 = new DevExpress.XtraCharts.TextAnnotation();
            DevExpress.XtraCharts.RelativePosition relativePosition1 = new DevExpress.XtraCharts.RelativePosition();
            DevExpress.XtraCharts.RelativePosition relativePosition2 = new DevExpress.XtraCharts.RelativePosition();
 
            var axis_sw = mainDiagram.AxisY;
 
            paneAnchorPoint1.AxisXCoordinate.AxisValueSerializable = "09/10/2023 22:00:00.000";
            paneAnchorPoint1.AxisYCoordinate.AxisValueSerializable = "5.9";
            paneAnchorPoint1.AxisYCoordinate.Axis = axis_sw;
            paneAnchorPoint1.Pane = this.mainDiagram.DefaultPane;//.Panes[0];
 
            textAnnotation1.AnchorPoint = paneAnchorPoint1;
            textAnnotation1.AutoHeight = false;
            textAnnotation1.AutoSize = false;
            textAnnotation1.AutoWidth = false;
            textAnnotation1.Height = 23;
            textAnnotation1.Name = "Maximum";
            textAnnotation1.RuntimeAnchoring = true;
            textAnnotation1.RuntimeResizing = true;
            textAnnotation1.RuntimeRotation = true;
            textAnnotation1.RuntimeMoving = true;
            textAnnotation1.TextColor = Color.Magenta;
            relativePosition1.Angle = -45D;
 
            textAnnotation1.ShapePosition = relativePosition1;
            textAnnotation1.Text = "Maximum";
            textAnnotation1.Width = 77;
 
 
 
            paneAnchorPoint2.AxisXCoordinate.AxisValueSerializable = "09/10/2023 22:00:00.000";
            paneAnchorPoint2.AxisYCoordinate.AxisValueSerializable = "7.3";
            paneAnchorPoint2.AxisYCoordinate.Axis = axis_sw;
            paneAnchorPoint2.Pane = this.mainDiagram.DefaultPane;//this.mainDiagram.Panes[0];
            textAnnotation2.AnchorPoint = paneAnchorPoint2;
            textAnnotation2.AutoHeight = true;
            textAnnotation2.AutoWidth = true;
            textAnnotation2.Name = "Minimum";
            textAnnotation2.TextColor = Color.Magenta;
            relativePosition2.Angle = 135D;
            textAnnotation2.ShapePosition = relativePosition2;
            textAnnotation2.Text = "Minimum";
            textAnnotation2.RuntimeAnchoring = true;
            textAnnotation2.RuntimeResizing = true;
            textAnnotation2.RuntimeRotation = true;
            textAnnotation2.RuntimeMoving = true;
 
            this.chartControl实时数据.AnnotationRepository.AddRange(new DevExpress.XtraCharts.Annotation[] {
            textAnnotation1,
            textAnnotation2});
        }
        public void SetTipLineVisible(bool isShow)
        {
            _moveConstantLineIn实时数据.Visible = isShow;
        }
        public void SetTipLineValue(DateTime t)
        {
            _moveConstantLineIn实时数据.Title.Text = t.ToString("HH:mm");
            _moveConstantLineIn实时数据.AxisValueSerializable = t.ToString();
            //_moveConstantLineIn实时数据.Visible = isShow;
 
            //if (d == null || d.OpenPumpCount == 0)
            //    return;
            //chartPumpCurveParalCtrl1.SetPumpRun(d);
        }
      
 
        //
        IStation.CalcModel.AnaPrj _current_anaPrj = null;
 
        public IStation.CalcModel.AnaPrj GetAnaPrj()
        {
            return this._current_anaPrj;
        }
 
 
        //初始化 实时数据
        //List<IStation.CalcModel.AnaPrjPointTime> _realTimeDataList;
        //public List<IStation.CalcModel.AnaPrjPointTime> GetRealTimeDataList()
        //{
        //    return _realTimeDataList;
        //}
 
 
 
        /// <summary>
        /// 
        /// </summary> 
        /// <param name="current_anaPrj"></param>
        public void SetBindingData(
            IStation.CalcModel.AnaPrj current_anaPrj  )//前日
        {
            if (current_anaPrj == null)
                return;
 
 
            this._current_anaPrj = current_anaPrj; 
 
            InitialChart实时数据(current_anaPrj);
            InitialChart累计数据(current_anaPrj);
 
            tabPage今日开机策略.Text = string.Format("开机策略({0})", current_anaPrj.StartTime.ToString("yyyy-MM-dd"));
            blockTimeListDispCtrl1.SetBindingData(current_anaPrj);
 
 
 
            //tabPageYesterday2.Text = string.Format("开机策略({0})", current_anaPrj.StartTime.AddDays(-2).ToString("yyyy-MM-dd")); 
            //blockTimeListDispCtrl3.SetBindingData(prj_yesteday2);
 
        }
 
        #region 累计数据
        private void InitialChart累计数据(IStation.CalcModel.AnaPrj anaPrj)
        {
            var series累计流量 = chartControl累计数据.Series[0];
            var series累计电量 = chartControl累计数据.Series[1];
            var series累计电费 = chartControl累计数据.Series[2];
            var series用水量 = chartControl累计数据.Series[3];
 
            series累计流量.Points.Clear();
            series累计电量.Points.Clear();
            series累计电费.Points.Clear();
            series用水量.Points.Clear();
            double sumFlow = 0;
            double sumPower = 0;
            double sumMoney = 0;
 
            var allTime = _current_anaPrj.GetAllPointTimeList();
            for (int i = 0; i < allTime.Count; i++)
            {
                var time = allTime[i].Time;
 
                series累计流量.Points.Add(new SeriesPoint(time, new double[] { sumFlow }));
                series累计电量.Points.Add(new SeriesPoint(time, new double[] { sumPower }));
                series累计电费.Points.Add(new SeriesPoint(time, new double[] { sumMoney }));
                series用水量.Points.Add(new SeriesPoint(time, new double[] { allTime[i].ReservoirDropFlowTotal }));
 
                sumFlow += allTime[i].SumFlow;
                sumPower += allTime[i].SumPower;
                sumMoney += allTime[i].SumMoney;
            }
 
 
            var diagram =
                chartControl累计数据.Diagram as DevExpress.XtraCharts.XYDiagram;
            var axis = diagram.AxisX;
            axis.VisualRange.Auto = false;
            axis.WholeRange.Auto = false;
            axis.WholeRange.SideMarginsValue = 0;
            axis.VisualRange.SideMarginsValue = 0;
            axis.WholeRange.SetMinMaxValues(_current_anaPrj.StartTime, _current_anaPrj.EndTime);
            axis.VisualRange.SetMinMaxValues(_current_anaPrj.StartTime, _current_anaPrj.EndTime);
            axis.WholeRange.AlwaysShowZeroLevel = false;
 
 
            this.textEdit总供水量.Text = anaPrj.SumFlow4Disp.ToString();
            this.textEdit总用电量.Text = anaPrj.SumPower4Disp.ToString();
            this.textEdit千吨水能耗.Text = anaPrj.QDSLN.ToString();
            this.textEdit总电费.Text = anaPrj.SumMoney.ToString();
        }
        private void tabbedControlGroup2_CustomHeaderButtonClick(object sender, DevExpress.XtraTab.ViewInfo.CustomHeaderButtonEventArgs e)
        {
            if (chartControl实时数据.Legend.Visibility == DevExpress.Utils.DefaultBoolean.True)
            {
                chartControl实时数据.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
                chartControl累计数据.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
            }
            else
            {
                chartControl实时数据.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
                chartControl累计数据.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
            }
        }
        #endregion
 
 
        #region 实时数据
        double  max_flow = 0;
        double  max_power = 0;
        double min_sw = double.MaxValue, max_sw = 0;
        private void InitialChart实时数据(IStation.CalcModel.AnaPrj anaPrj)
        {
            IStation.CalcModel.AnaPrjPointTime max_level = null;
            IStation.CalcModel.AnaPrjPointTime min_level = null;
            var allTime = anaPrj.GetAllPointTimeList();
            for (int i = 0; i < allTime.Count; i++)
            {
                var sd = allTime[i];
                if (max_level == null || max_level.WaterLevelH < sd.WaterLevelH)
                {
                    max_level = sd;
                }
                if (min_level == null || min_level.WaterLevelH > sd.WaterLevelH)
                {
                    min_level = sd;
                }
            }
 
            DevExpress.XtraCharts.TextAnnotation textAnnotationMax = this.chartControl实时数据.AnnotationRepository[0] as DevExpress.XtraCharts.TextAnnotation;
            DevExpress.XtraCharts.PaneAnchorPoint paneAnchorPointMax = textAnnotationMax.AnchorPoint as DevExpress.XtraCharts.PaneAnchorPoint;
 
            DevExpress.XtraCharts.TextAnnotation textAnnotationMin = this.chartControl实时数据.AnnotationRepository[1] as DevExpress.XtraCharts.TextAnnotation;
            DevExpress.XtraCharts.PaneAnchorPoint paneAnchorPointMin = textAnnotationMin.AnchorPoint as DevExpress.XtraCharts.PaneAnchorPoint;
 
            paneAnchorPointMax.AxisXCoordinate.AxisValueSerializable = max_level.Time.ToString();
            paneAnchorPointMax.AxisYCoordinate.AxisValueSerializable = max_level.WaterLevelH.ToString();
            textAnnotationMax.Text = string.Format("max:{0}", Math.Round(max_level.WaterLevelH, 2));
 
            paneAnchorPointMin.AxisXCoordinate.AxisValueSerializable = min_level.Time.ToString();
            paneAnchorPointMin.AxisYCoordinate.AxisValueSerializable = min_level.WaterLevelH.ToString();
            textAnnotationMin.Text = string.Format("min:{0}", Math.Round(min_level.WaterLevelH, 2));
 
 
            DevExpress.XtraCharts.Series series长江水位 = this.chartControl实时数据.Series[0];
            DevExpress.XtraCharts.Series series前池水位 = this.chartControl实时数据.Series[1];
            DevExpress.XtraCharts.Series series水库水位 = this.chartControl实时数据.Series[2];
 
            DevExpress.XtraCharts.Series series流量 = this.chartControl实时数据.Series[3];
            DevExpress.XtraCharts.Series series功率 = this.chartControl实时数据.Series[4];
 
 
            (series长江水位.View).Color = IStation.Settings.DispSetting.ChartColor长江水位;
            (series前池水位.View).Color = IStation.Settings.DispSetting.ChartColor前池水位;
            (series水库水位.View).Color = IStation.Settings.DispSetting.ChartColor水库水位;
            (series流量.View).Color = IStation.Settings.DispSetting.ChartColor瞬时流量;
            (series功率.View).Color = IStation.Settings.DispSetting.ChartColor瞬时功率;
 
            series流量.Points.Clear();
            series功率.Points.Clear();
 
            series长江水位.Points.Clear();
            series前池水位.Points.Clear();
            series水库水位.Points.Clear();
 
             max_flow = 0;
            max_power = 0;
            min_sw = double.MaxValue; max_sw = 0;
 
 
 
 
 
            BuildRealTimeDataList(_current_anaPrj.GetAllPointTimeList());
 
 
 
            SetChartCoord实时数据(0, max_flow, min_sw, max_sw, 0, max_power);
 
 
        }
 
        private void BuildRealTimeDataList(List<AnaPrjPointTime> realTimeDataList)
        {
            DevExpress.XtraCharts.Series series长江水位 = this.chartControl实时数据.Series[0];
            DevExpress.XtraCharts.Series series前池水位 = this.chartControl实时数据.Series[1];
            DevExpress.XtraCharts.Series series水库水位 = this.chartControl实时数据.Series[2];
 
            DevExpress.XtraCharts.Series series流量 = this.chartControl实时数据.Series[3];
            DevExpress.XtraCharts.Series series功率 = this.chartControl实时数据.Series[4];
            for (int i = 0; i < realTimeDataList.Count; i++)
            {
                var time = realTimeDataList[i].Time;
                series长江水位.Points.Add(new SeriesPoint(time, new double[] {
                    Math.Round( realTimeDataList[i].WaterLevelC, 2) }));
                series流量.Points.Add(new SeriesPoint(time, new double[] {
                       100 * ((int)( realTimeDataList[i].RealFlow/100 )) }));
                series功率.Points.Add(new SeriesPoint(time, new double[] {
                       10 * ((int)( realTimeDataList[i].RealPower / 10)) }));
                series前池水位.Points.Add(new SeriesPoint(time, new double[] {
                    Math.Round(realTimeDataList[i].WaterLevelQ, 2) }));
 
                series水库水位.Points.Add(new SeriesPoint(time, new double[] {
                    Math.Round(realTimeDataList[i].WaterLevelH, 4) }));
 
                //if (_realTimeDataList[i].WaterLevelQ < 0)
                //    isHaveNavigetLevel = true;
 
                min_sw = Math.Min(min_sw, realTimeDataList[i].WaterLevelQ);
                max_sw = Math.Max(max_sw, realTimeDataList[i].WaterLevelQ);
 
                min_sw = Math.Min(min_sw, realTimeDataList[i].WaterLevelC);
                max_sw = Math.Max(max_sw, realTimeDataList[i].WaterLevelC);
 
                min_sw = Math.Min(min_sw, realTimeDataList[i].WaterLevelH);
                max_sw = Math.Max(max_sw, realTimeDataList[i].WaterLevelH);
 
                if (realTimeDataList[i].RealFlow > 1000)
                {
                   // min_power = Math.Min(min_power, realTimeDataList[i].RealPower);
                    max_power = Math.Max(max_power, realTimeDataList[i].RealPower);
 
                  //  min_flow = Math.Min(min_flow, realTimeDataList[i].RealFlow);
                    max_flow = Math.Max(max_flow, realTimeDataList[i].RealFlow);
                }
            } 
        }
 
        double rang_up_firstAxis = 0;
        double rang_down_firstAxis = 0;
        double rang_min_firstAxis = 0;
        private void SetChartCoord实时数据(
            double min_flow, double max_flow,
            double min_sw, double max_sw,
            double min_power, double max_power)
        {
            if (this.mainDiagram == null)
                return;
 
            var axis_time = this.mainDiagram.AxisX;
            axis_time.VisualRange.Auto = false;
            axis_time.WholeRange.Auto = false;
            axis_time.WholeRange.SideMarginsValue = 0;
            axis_time.VisualRange.SideMarginsValue = 0;
            axis_time.WholeRange.SetMinMaxValues(_current_anaPrj.StartTime, _current_anaPrj.EndTime);
            axis_time.VisualRange.SetMinMaxValues(_current_anaPrj.StartTime, _current_anaPrj.EndTime);
            axis_time.WholeRange.AlwaysShowZeroLevel = false;
 
 
 
 
            double coord_space_flow = max_flow / 6;
            coord_space_flow = Math.Max(5000, 5000 * (int)(coord_space_flow / 5000));
            double coord_min_flow = -coord_space_flow;
            var coord_flows = new List<CustomAxisLabel>();
            double disp_flow = coord_min_flow;
            for (int i = 0; i < 20; i++)
            {
                if (disp_flow < 0)
                {
                    coord_flows.Add(new CustomAxisLabel("", disp_flow));
                }
                else
                {
                    coord_flows.Add(new CustomAxisLabel((disp_flow / 10000).ToString(), disp_flow));
                }
 
 
                if (disp_flow > max_flow + coord_space_flow)
                    break;
 
                disp_flow = disp_flow + coord_space_flow;
            }
 
 
 
            double coord_max_power = 500 * ((int)(max_power / 500));
            double coord_space_power = coord_max_power / 6;
            coord_space_power = Math.Max(1000, 1000 * (int)(coord_space_power / 1000));
            double coord_min_power = -coord_space_power;
            List<CustomAxisLabel> coord_powers = new List<CustomAxisLabel>();
            double disp_power = coord_min_power;
            for (int i = 0; i < 20; i++)
            {
                if (disp_power < 0)
                {
                    coord_powers.Add(new CustomAxisLabel("", disp_power));
                }
                else
                {
                    coord_powers.Add(new CustomAxisLabel(disp_power.ToString(), disp_power));
                }
 
 
                if (disp_power > coord_max_power + coord_space_power)
                    break;
 
                disp_power = disp_power + coord_space_power;
            }
 
 
 
            if (coord_powers.Count < coord_flows.Count)
            {
                for (int i = 0; i < 20; i++)
                {
                    disp_power = disp_power + coord_space_power;
                    coord_powers.Add(new CustomAxisLabel(disp_power.ToString(), disp_power));
                    if (coord_powers.Count == coord_flows.Count)
                        break;
 
                }
            }
            if (coord_powers.Count > coord_flows.Count)
            {
                for (int i = 0; i < 20; i++)
                {
                    disp_flow = disp_flow + coord_space_flow;
                    coord_flows.Add(new CustomAxisLabel((disp_flow / 10000).ToString(), disp_flow));
                    if (coord_powers.Count == coord_flows.Count)
                        break;
 
                }
            }
 
            int start_level = 0;
            if (min_sw < 0)
            {
                start_level = (int)min_sw - 1;
            }
               
            List<CustomAxisLabel> coord_sw = new List<CustomAxisLabel>();
            for (int i = start_level; i < 20; i++)
            {
                var h = i * 1;
                coord_sw.Add(new CustomAxisLabel(h.ToString(), h));
                if (h > max_sw + 3)
                    break;
            }
 
            rang_up_firstAxis = Convert.ToDouble(
                coord_sw[coord_sw.Count - 1].AxisValue);
            rang_down_firstAxis = Convert.ToDouble(
                coord_sw[coord_sw.Count - 2].AxisValue);
            rang_down_firstAxis = rang_up_firstAxis + (rang_up_firstAxis - rang_down_firstAxis) / 3;
            rang_min_firstAxis = Convert.ToDouble(coord_sw[0].AxisValue);
 
 
 
 
            var axis_sw = mainDiagram.AxisY;
            axis_sw.CustomLabels.Clear();
            axis_sw.CustomLabels.AddRange(coord_sw.ToArray());
            axis_sw.VisualRange.Auto = false;
            axis_sw.WholeRange.Auto = false;
            axis_sw.WholeRange.SideMarginsValue = 0;
            axis_sw.VisualRange.SideMarginsValue = 0;
            axis_sw.WholeRange.AutoSideMargins = false;
            axis_sw.VisualRange.AutoSideMargins = false;
            axis_sw.WholeRange.SetMinMaxValues(coord_sw.FirstOrDefault().AxisValue, coord_sw.Last().AxisValue);
            axis_sw.VisualRange.SetMinMaxValues(coord_sw.FirstOrDefault().AxisValue, coord_sw.Last().AxisValue);
            axis_sw.WholeRange.AlwaysShowZeroLevel = false;
 
 
 
            var axis_flow = this.mainDiagram.SecondaryAxesY.GetAxisByName("SecondaryLL");
            axis_flow.CustomLabels.Clear();
            axis_flow.CustomLabels.AddRange(coord_flows.ToArray()); 
            axis_flow.NumericScaleOptions.AutoGrid = false;
            axis_flow.VisualRange.Auto = false;
            axis_flow.WholeRange.Auto = false;
            axis_flow.WholeRange.SideMarginsValue = 0;
            axis_flow.VisualRange.SideMarginsValue = 0;
            axis_flow.WholeRange.AutoSideMargins = false;
            axis_flow.VisualRange.AutoSideMargins = false;
            axis_flow.WholeRange.SetMinMaxValues(coord_min_flow, coord_min_flow + (coord_flows.Count - 1) * coord_space_flow);
            axis_flow.VisualRange.SetMinMaxValues(coord_min_flow, coord_min_flow + (coord_flows.Count - 1) * coord_space_flow);
            axis_flow.WholeRange.AlwaysShowZeroLevel = false;
            axis_flow.Color = IStation.Settings.DispSetting.ChartColor瞬时流量;
            axis_flow.Title.TextColor = IStation.Settings.DispSetting.ChartColor瞬时流量;
            axis_flow.Label.TextColor = IStation.Settings.DispSetting.ChartColor瞬时流量;
 
 
 
 
            var axis_power = mainDiagram.SecondaryAxesY.GetAxisByName("SecondaryGL");
            axis_power.CustomLabels.Clear();
            axis_power.CustomLabels.AddRange(coord_powers.ToArray());
 
            axis_power.NumericScaleOptions.AutoGrid = false;
            axis_power.VisualRange.Auto = false;
            axis_power.WholeRange.Auto = false;
            axis_power.WholeRange.SideMarginsValue = 0;
            axis_power.VisualRange.SideMarginsValue = 0;
            axis_power.WholeRange.AutoSideMargins = false;
            axis_power.VisualRange.AutoSideMargins = false;
            axis_power.WholeRange.SetMinMaxValues(coord_min_power, coord_min_power + (coord_powers.Count - 1) * coord_space_power);
            axis_power.VisualRange.SetMinMaxValues(coord_min_power, coord_min_power + (coord_powers.Count - 1) * coord_space_power);
            axis_power.WholeRange.AlwaysShowZeroLevel = false;
            axis_power.Color = IStation.Settings.DispSetting.ChartColor瞬时功率;
            axis_power.Title.TextColor = IStation.Settings.DispSetting.ChartColor瞬时功率;
            axis_power.Label.TextColor = IStation.Settings.DispSetting.ChartColor瞬时功率;
        }
        private void ChartControl实时数据_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                contextMenuChart.Show(chartControl实时数据, e.Location);
            } 
        }
        private void ChartControl实时数据_CustomPaint(object sender, CustomPaintEventArgs e)
        {
            if (_current_anaPrj == null || mainDiagram == null) return;
            Graphics g = e.Graphics;
            //g.SetClip(CalculateDiagramBounds());
            g.SmoothingMode = SmoothingMode.AntiAlias;
            using (Font font水位 = new Font("Tahoma", 9, FontStyle.Regular))
            using (Font font时间 = new Font("Tahoma", 12, FontStyle.Regular))
            using (Font font台数 = new Font("黑体", 9, FontStyle.Italic))
            using (SolidBrush brushText时间 = new SolidBrush(Color.Black))
            {
 
                foreach (var item in this._current_anaPrj.BlockTimes)
                {
                    if (item.OpenPumpCount <= 0) continue;
 
                    var pump_count = item.OpenPumpCount;
                    Color textColor = Color.Black;
                    if (item.OpenPumpCount == 4)
                        textColor = Color.White;
                    List<string> list_draws = new List<string>();
                    list_draws.Add("00:00");
 
                    using (SolidBrush brushText台数 = new SolidBrush(textColor))
                    using (SolidBrush brush背景 = new SolidBrush(
                        PumpCountColorHelper.GetColor(pump_count)))
                    {
                        var pt1 = mainDiagram.DiagramToPoint(item.StartTime, rang_up_firstAxis);
                        var pt2 = mainDiagram.DiagramToPoint(item.EndTime, rang_up_firstAxis);
                        var height = 25;// Math.Max(15, Math.Abs(pt1.Point.Y - pt2.Point.Y));
 
                        g.FillRectangle(brush背景, pt1.Point.X, pt1.Point.Y - height,
                            Math.Abs(pt1.Point.X - pt2.Point.X), height);
                        g.DrawString(string.Format("{0}台", pump_count), font台数, brushText台数,
                            new Point(pt1.Point.X, pt1.Point.Y - 16));
                        var sss_start = item.StartTime.ToString("HH:mm");
                        if (!list_draws.Contains(sss_start))
                        {
                            list_draws.Add(sss_start);
                            g.DrawString(sss_start, font时间, brushText时间,    new Point(pt1.Point.X - 20, pt1.Point.Y - height - 19));
 
                            var pt = _current_anaPrj.FindPointTime(item.StartTime);
                            if (pt != null)
                            {
                                g.DrawString(string.Format("{0}m", Math.Round(pt.WaterLevelH, 2) ), font水位, brushText时间, new Point(pt1.Point.X - 20, pt1.Point.Y + 5));
                            }
                            else
                            {
 
                            }
                        }
                        var sss_end = item.EndTime.ToString("HH:mm");
                        if (!list_draws.Contains(sss_end))
                        {
                            list_draws.Add(sss_end);
                            g.DrawString(sss_end, font时间, brushText时间,  new Point(pt2.Point.X - 20, pt1.Point.Y - height - 19));
 
                            var pt = _current_anaPrj.FindPointTime(item.EndTime);
                            if (pt != null)
                            {
                                g.DrawString(string.Format("{0}m", Math.Round(pt.WaterLevelH, 2)), font水位, brushText时间, new Point(pt2.Point.X - 20, pt2.Point.Y + 5));
                            }
                            else
                            {
 
                            }
                        }
                    }
                }
            }
 
 
        }
 
        #endregion
 
 
 
 
 
        private void MenuItem显示曲线提示_Click(object sender, EventArgs e)
        {
            MenuItem显示曲线提示.Checked = !MenuItem显示曲线提示.Checked;
            chartControl实时数据.Legend.Visibility =
                MenuItem显示曲线提示.Checked ?
                DevExpress.Utils.DefaultBoolean.True :
                DevExpress.Utils.DefaultBoolean.False;
        }
 
        private void xtraTabControl1_CustomHeaderButtonClick(object sender, DevExpress.XtraTab.ViewInfo.CustomHeaderButtonEventArgs e)
        {
            if (tabPage实时数据.PageVisible == false)
            {
                tabPage实时数据.PageVisible = true;
                pointTimeListDispCtrl1.SetBindingData(_current_anaPrj);
            } 
        }
 
        public void ExportSpanGrid()
        {
            this.blockTimeListDispCtrl1.ExportSpanGrid();
        }
 
        internal void ClearContent()
        {
            textEdit总供水量.Text = "";
            textEdit总电费.Text = "";
            textEdit总用电量.Text = "";
            textEdit千吨水能耗.Text = "";
            _current_anaPrj = null;
            this.Invalidate();
 
            DevExpress.XtraCharts.Series series长江水位 = this.chartControl实时数据.Series[0];
            DevExpress.XtraCharts.Series series前池水位 = this.chartControl实时数据.Series[1];
            DevExpress.XtraCharts.Series series水库水位 = this.chartControl实时数据.Series[2];
 
            DevExpress.XtraCharts.Series series流量 = this.chartControl实时数据.Series[3];
            DevExpress.XtraCharts.Series series功率 = this.chartControl实时数据.Series[4];
 
            series长江水位.Points.Clear();
            series前池水位.Points.Clear();
            series水库水位.Points.Clear();
            series流量.Points.Clear();
            series功率.Points.Clear();
 
        }
    }
}