| | |
| | | using DevExpress.XtraEditors; |
| | | using DevExpress.XtraGrid.Views.Grid.ViewInfo; |
| | | using MathNet.Numerics; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel.DataAnnotations; |
| | | using System.Drawing; |
| | | using System.Linq; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | |
| | | this.PageTitle.Caption = "数据整合"; |
| | | this.stationListCtrl1.FocusedChangedEvent += StationListCtrl1_FocusedChangedEvent; |
| | | this.monitorDataSourcesTreeList1.FocusedChangedEvent += MonitorDataSourcesListCtrl1_FocusedChangedEvent; |
| | | this.gridView1.SetNormalView(); |
| | | this.colTime.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; |
| | | this.colTime.DisplayFormat.FormatString = "G"; |
| | | this.timeValueSwiftPlotChartView1.SetTimeAxisX( DevExpress.XtraCharts.DateTimeMeasureUnit.Minute); |
| | | } |
| | | |
| | | public class CurrentViewModel |
| | |
| | | |
| | | private BLL.StationSignalRecordPacket _bll = new BLL.StationSignalRecordPacket(); |
| | | private Model.Station _station = null; |
| | | private Model.MonitorDataSources _monitorDataSources = null; |
| | | private List<CurrentViewModel> _allBindingList = null; |
| | | private Model.MonitorDataSources _monitorDataSources = null; |
| | | |
| | | /// <summary> |
| | | /// 清空数据 |
| | | /// </summary> |
| | | public void Clear() |
| | | { |
| | | _allBindingList = new List<CurrentViewModel>(); |
| | | this.currentViewModelBindingSource.DataSource = _allBindingList; |
| | | { |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | public void SetBindingData(Model.MonitorDataSources monitorDataSources, Model.Station station) |
| | | { |
| | | _allBindingList = new List<CurrentViewModel>(); |
| | | this.currentViewModelBindingSource.DataSource = _allBindingList; |
| | | { |
| | | if (monitorDataSources == null || station == null) |
| | | { |
| | | return; |
| | |
| | | /// </summary> |
| | | public void SetBindingData(List<Model.StationSignalRecordPacket> packets) |
| | | { |
| | | WaitFrmHelper.ShowWaitForm(); |
| | | _allBindingList = new List<CurrentViewModel>(); |
| | | WaitFrmHelper.ShowWaitForm(); |
| | | this.timeValueSwiftPlotChartView1.ClearSeries(); |
| | | if (packets != null && packets.Any()) |
| | | { |
| | | { |
| | | var total_flow_list = new List<TimeValue>(); |
| | | var total_pressure_list = new List<TimeValue>(); |
| | | var pump_total_flow_list = new List<TimeValue>(); |
| | | var diff_flow_list = new List<TimeValue>(); |
| | | foreach (var packet in packets) |
| | | { |
| | | var station_signal_records = packet.StationSignalRecords; |
| | | if (station_signal_records == null || !station_signal_records.Any()) |
| | | continue; |
| | | var year_month = $"{packet.Year}-{packet.Month}"; |
| | | foreach (var record in station_signal_records) |
| | | { |
| | | var pump_signal_records = record.PumpSignalRecords; |
| | | if (pump_signal_records == null || !pump_signal_records.Any()) |
| | | foreach (var station in station_signal_records) |
| | | { |
| | | var time = station.Time; |
| | | var total_flow = station.TotalFlow; |
| | | var total_pressure = station.TotalPressure; |
| | | var pump_total_flow = station.PumpSignalRecords.Sum(x => x.FlowRate); |
| | | var diff_flow = station.DiffFlow; |
| | | if (total_pressure < 0) |
| | | { |
| | | continue; |
| | | pump_signal_records = pump_signal_records.OrderBy(x => x.Flag).ToList(); |
| | | |
| | | var total_power = pump_signal_records.Sum(x => x.InstantaneousPower); |
| | | var run_flags = pump_signal_records.Select(x => x.Flag).ToList(); |
| | | var rpm_list = pump_signal_records.Select(x => |
| | | } |
| | | if (total_flow<=0&& pump_total_flow<=0) |
| | | { |
| | | if (x.Rpm == 0 && (x.Flag == 15 || x.Flag == 16)) |
| | | { |
| | | return 590; |
| | | } |
| | | return x.Rpm; |
| | | }).ToList(); |
| | | var head_list = pump_signal_records.Select(x => |
| | | continue; |
| | | } |
| | | if (pump_total_flow > 0 && Math.Abs(diff_flow) > 2000) |
| | | { |
| | | return Math.Round(x.Head, 2); |
| | | }).ToList(); |
| | | continue; |
| | | } |
| | | total_flow = Math.Round(total_flow, 1); |
| | | pump_total_flow = Math.Round(pump_total_flow, 1); |
| | | diff_flow = Math.Round(diff_flow, 1); |
| | | total_pressure = Math.Round(total_pressure,2); |
| | | |
| | | if (station.PumpSignalRecords.Exists(x=>x.Rpm<0)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | |
| | | |
| | | total_flow_list.Add(new TimeValue(time, total_flow)); |
| | | pump_total_flow_list.Add(new TimeValue(time, pump_total_flow)); |
| | | diff_flow_list.Add(new TimeValue(time, diff_flow)); |
| | | total_pressure_list.Add(new TimeValue(time, total_pressure)); |
| | | |
| | | |
| | | var vm = new CurrentViewModel(); |
| | | vm.YearMonth = year_month; |
| | | vm.Time = record.Time; |
| | | vm.RunFlags = IStation.Untity.IntListHelper.ToString(run_flags); |
| | | vm.RpmList = IStation.Untity.DoubleListHelper.ToString(rpm_list); |
| | | vm.HeadList = IStation.Untity.DoubleListHelper.ToString(head_list); |
| | | vm.TotalPower = Math.Round(total_power, 1); |
| | | _allBindingList.Add(vm); |
| | | } |
| | | |
| | | #region MyRegion |
| | | |
| | | //var year_month = $"{packet.Year}-{packet.Month}"; |
| | | //foreach (var record in station_signal_records) |
| | | //{ |
| | | // var pump_signal_records = record.PumpSignalRecords; |
| | | // if (pump_signal_records == null || !pump_signal_records.Any()) |
| | | // continue; |
| | | // pump_signal_records = pump_signal_records.OrderBy(x => x.Flag).ToList(); |
| | | |
| | | // var total_power = pump_signal_records.Sum(x => x.InstantaneousPower); |
| | | // var run_flags = pump_signal_records.Select(x => x.Flag).ToList(); |
| | | // var rpm_list = pump_signal_records.Select(x => |
| | | // { |
| | | // if (x.Rpm == 0 && (x.Flag == 15 || x.Flag == 16)) |
| | | // { |
| | | // return 590; |
| | | // } |
| | | // return x.Rpm; |
| | | // }).ToList(); |
| | | // var head_list = pump_signal_records.Select(x => |
| | | // { |
| | | // return Math.Round(x.Head, 2); |
| | | // }).ToList(); |
| | | |
| | | |
| | | // var vm = new CurrentViewModel(); |
| | | // vm.YearMonth = year_month; |
| | | // vm.Time = record.Time; |
| | | // vm.RunFlags = IStation.Untity.IntListHelper.ToString(run_flags); |
| | | // vm.RpmList = IStation.Untity.DoubleListHelper.ToString(rpm_list); |
| | | // vm.HeadList = IStation.Untity.DoubleListHelper.ToString(head_list); |
| | | // vm.TotalPower = Math.Round(total_power, 1); |
| | | // _allBindingList.Add(vm); |
| | | //} |
| | | #endregion |
| | | } |
| | | this.timeValueSwiftPlotChartView1.SetAxisYTitle("流量"); |
| | | this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries("总压力", Color.DarkGray, "总压力", "压力", total_pressure_list); |
| | | this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries("总管流量", Color.Red, "总管流量", "流量", total_flow_list); |
| | | this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries("泵总流量", Color.Blue, "泵总流量", "流量", pump_total_flow_list); |
| | | this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries("偏差流量", Color.Black, "偏差流量", "流量", diff_flow_list); |
| | | |
| | | } |
| | | |
| | | |
| | | this.currentViewModelBindingSource.DataSource = _allBindingList; |
| | | |
| | | WaitFrmHelper.HideWaitForm(); |
| | | } |
| | | |
| | |
| | | { |
| | | SetBindingData(_monitorDataSources, _station); |
| | | } |
| | | |
| | | |
| | | //自定义组名 |
| | | private void gridView1_CustomDrawGroupRow(object sender, DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs e) |
| | | { |
| | | var vm = this.gridView1.GetRow(e.RowHandle) as CurrentViewModel; |
| | | var grid = e.Info as GridGroupRowInfo; |
| | | if (grid.Level == 0) |
| | | { grid.GroupText = vm.YearMonth; |
| | | } |
| | | else if (grid.Level == 1) |
| | | { |
| | | grid.GroupText = vm.RunFlags; |
| | | } |
| | | } |
| | | |
| | | #region 菜单 |
| | | |
| | | //全部展开 |
| | | private void barBtnExpandAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | this.gridView1.ExpandAllGroups(); |
| | | } |
| | | |
| | | //全部折叠 |
| | | private void barBtnCollapseAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | this.gridView1.CollapseAllGroups(); |
| | | } |
| | | |
| | | //检索 |
| | | private void barCekSearch_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (this.barCekSearch.Checked) |
| | | this.gridView1.ShowFindPanel(); |
| | | else |
| | | this.gridView1.HideFindPanel(); |
| | | } |
| | | #region 菜单 |
| | | |
| | | // 刷新数据 |
| | | private void barBtnRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | InitialDataSource(); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | |
| | | private void barBtnExportEta_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (_monitorDataSources == null || _station == null) |
| | | { |
| | | XtraMessageBox.Show("无数据!"); |
| | | return; |
| | | } |
| | | EtaExportHelper.Export(_monitorDataSources.ID); |
| | | } |
| | | } |
| | | } |
| | | |