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();
|
}
|
}
|
|
}
|