From d321346f204a69b1929cc39098a5d88f44509e7b Mon Sep 17 00:00:00 2001 From: ningshuxia <ningshuxia0927@outlook.com> Date: 星期一, 31 三月 2025 17:29:05 +0800 Subject: [PATCH] .netformwork 升级 .netcore --- 02-desktop/WinFrmUI/IStation.WinFrmUI.Monitor/03-WorkingConditionAnalysis/05-ModelCorrectionCombine/ModelCorrectionCombinePage.cs | 231 +++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 149 insertions(+), 82 deletions(-) diff --git a/02-desktop/WinFrmUI/IStation.WinFrmUI.Monitor/03-WorkingConditionAnalysis/05-ModelCorrectionCombine/ModelCorrectionCombinePage.cs b/02-desktop/WinFrmUI/IStation.WinFrmUI.Monitor/03-WorkingConditionAnalysis/05-ModelCorrectionCombine/ModelCorrectionCombinePage.cs index f42b2cf..57fadad 100644 --- a/02-desktop/WinFrmUI/IStation.WinFrmUI.Monitor/03-WorkingConditionAnalysis/05-ModelCorrectionCombine/ModelCorrectionCombinePage.cs +++ b/02-desktop/WinFrmUI/IStation.WinFrmUI.Monitor/03-WorkingConditionAnalysis/05-ModelCorrectionCombine/ModelCorrectionCombinePage.cs @@ -19,48 +19,48 @@ public ModelCorrectionCombinePage() { InitializeComponent(); - this.PageTitle.Caption = "妯″瀷淇缁勫悎"; + PageTitle.Caption = "妯″瀷淇缁勫悎"; - this.gridView1.SetNormalView(); - this.gridView2.SetNormalView(); - this.gridView3.SetNormalView(); + gridView1.SetNormalView(); + gridView2.SetNormalView(); + gridView3.SetNormalView(); - this.colHz.Visible = false; - this.colRpm.Visible = false; - this.colWaterLevel.Visible = false; + colHz.Visible = false; + colRpm.Visible = false; + colWaterLevel.Visible = false; - this.repositoryItemDateEdit1.SetOnlyShowYearMonth(); - this.repositoryItemDateEdit2.SetOnlyShowYearMonth(); - this.barEditDateStart.EditValue = new DateTime(2024, 9, 1); - this.barEditDateEnd.EditValue = new DateTime(2024, 9, 1); - this.cmbFlag.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; - this.barCekUseFlow.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + repositoryItemDateEdit1.SetOnlyShowYearMonth(); + repositoryItemDateEdit2.SetOnlyShowYearMonth(); + barEditDateStart.EditValue = new DateTime(2024, 1, 1); + barEditDateEnd.EditValue = new DateTime(2024, 9, 1); - this.stationListCtrl1.FocusedChangedEvent += StationListCtrl1_FocusedChangedEvent; - this.monitorDataSourcesTreeList1.FocusedChangedEvent += MonitorDataSourcesListCtrl1_FocusedChangedEvent; - this.timeValueSwiftPlotChartView1.SetTimeAxisX(DevExpress.XtraCharts.DateTimeMeasureUnit.Minute); + cmbFlag.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; + barCekUseFlow.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + + stationListCtrl1.FocusedChangedEvent += StationListCtrl1_FocusedChangedEvent; + monitorDataSourcesTreeList1.FocusedChangedEvent += MonitorDataSourcesListCtrl1_FocusedChangedEvent; + timeValueSwiftPlotChartView1.SetTimeAxisX(DevExpress.XtraCharts.DateTimeMeasureUnit.Minute); InitialDiagarm(); } - + private Series _series_default_head; // private Series _series_curve_head; // private Series _series_correct_curve_head; // - private double _min_flow = 0; + private double _min_flow = 0; private double _max_flow = 100000; private double _space_flow = 500; private void InitialDiagarm() { - this.chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;//鏄惁鍦ㄥ浘琛ㄤ笂鏄剧ず鍥句緥 + chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;//鏄惁鍦ㄥ浘琛ㄤ笂鏄剧ず鍥句緥 - var diagram = (SwiftPlotDiagram)this.chartControl1.Diagram; + var diagram = (SwiftPlotDiagram)chartControl1.Diagram; diagram.EnableAxisXScrolling = true;//X杞存槸鍚﹀厑璁告粴鍔� diagram.EnableAxisXZooming = true;//X杞存槸鍚﹀厑璁哥缉鏀� diagram.PaneLayout.Direction = PaneLayoutDirection.Vertical;//绐楁牸鐨勫榻愭柟寮� diagram.AxisX.DateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Minute; - _series_default_head = chartControl1.GetSeriesByName("SeriesDefaultHead"); _series_curve_head = chartControl1.GetSeriesByName("SeriesCurveHead"); @@ -69,7 +69,6 @@ _series_default_head.CrosshairLabelPattern = "鐩戞祴鍘嬪姏:{V}"; _series_curve_head.CrosshairLabelPattern = "妯″瀷鍘嬪姏:{V}"; _series_correct_curve_head.CrosshairLabelPattern = "鍘嬪姏鍋忓樊:{V}"; - } @@ -128,15 +127,15 @@ public class ModelCombineViewModel { - public string Time { get; set; } + public string Time { get; set; } public string RunFlags { get; set; } public double ScadaTotalFlow { get; set; } public double ModelTotalFlow { get; set; } - public Dictionary<int, double> ModelDeviation { get; set; } + public List<Tuple<int, double, double>> ModelDeviation { get; set; } } public class ModelDiffViewModel - { + { [Display(Name = "鏃堕棿")] public DateTime Date { get; set; } @@ -210,18 +209,18 @@ public void Round() { - if (this.STDP.HasValue) + if (STDP.HasValue) { - this.STDP = Math.Round(this.STDP.Value, 5); + STDP = Math.Round(STDP.Value, 5); } - if (this.STDPHead.HasValue) + if (STDPHead.HasValue) { - this.STDPHead = Math.Round(this.STDPHead.Value, 5); + STDPHead = Math.Round(STDPHead.Value, 5); } } } - + #endregion @@ -231,7 +230,7 @@ private List<Model.Equipment<Model.Pump>> _pump_list = null; private List<ModelDiffViewModel> _model_diff_vm_list = null; - private List<ModelCombineViewModel> _model_combine_list=null; + private List<ModelCombineViewModel> _model_combine_list = null; private List<ModelCombineDiffViewModel> _model_combine_diff_vm_list = null; private List<PumpViewModel> _pump_vm_list = null; @@ -246,12 +245,12 @@ _pump_vm_list = new List<PumpViewModel>(); _model_diff_vm_list = new List<ModelDiffViewModel>(); _model_combine_list = new List<ModelCombineViewModel>(); - _model_combine_diff_vm_list=new List<ModelCombineDiffViewModel> (); - this.cmbFlag.SelectedItem = null; - this.cmbFlag.Properties.Items.Clear(); - this.modelTimeViewModelBindingSource.DataSource = new List<ModelDiffViewModel>(); - this.modelCombineDiffViewModelBindingSource.DataSource = new List<ModelCombineDiffViewModel>(); - this.pumpViewModelBindingSource.DataSource = new List<PumpViewModel>(); + _model_combine_diff_vm_list = new List<ModelCombineDiffViewModel>(); + cmbFlag.SelectedItem = null; + cmbFlag.Properties.Items.Clear(); + modelTimeViewModelBindingSource.DataSource = new List<ModelDiffViewModel>(); + modelCombineDiffViewModelBindingSource.DataSource = new List<ModelCombineDiffViewModel>(); + pumpViewModelBindingSource.DataSource = new List<PumpViewModel>(); ClearChart(); } @@ -259,11 +258,11 @@ private void ClearChart() { - this.chartControl1.BeginInit(); + chartControl1.BeginInit(); _series_default_head.Points.Clear(); _series_curve_head.Points.Clear(); _series_correct_curve_head.Points.Clear(); - this.chartControl1.EndInit(); + chartControl1.EndInit(); } /// <summary> @@ -271,8 +270,8 @@ /// </summary> public override void InitialDataSource() { - this.stationListCtrl1.SetBindingData(); - this.monitorDataSourcesTreeList1.SetBindingData(); + stationListCtrl1.SetBindingData(); + monitorDataSourcesTreeList1.SetBindingData(); } //娉电珯鍙樻崲 @@ -306,15 +305,15 @@ { return; } - if (this.barCekLoad.Checked) + if (barCekLoad.Checked) { return; } var station_index = station.SortCode; - var dt_start = Convert.ToDateTime(this.barEditDateStart.EditValue); - var dt_end = Convert.ToDateTime(this.barEditDateEnd.EditValue); + var dt_start = Convert.ToDateTime(barEditDateStart.EditValue); + var dt_end = Convert.ToDateTime(barEditDateEnd.EditValue); var packets = _bll.Get(monitorDataSources.ID, station.ID); packets = packets?.Where(x => (x.Year >= dt_start.Year && x.Year <= dt_end.Year) && (x.Month >= dt_start.Month && x.Month <= dt_end.Month)).ToList(); if (packets == null || !packets.Any()) @@ -327,7 +326,7 @@ } var flag_pump_dict = _pump_list.ToDictionary(x => x.SortCode, x => x.RatedParas); var flag_list = _pump_list.Select(x => x.SortCode).OrderBy(x => x).ToList(); - this.cmbFlag.Properties.Items.AddRange(flag_list); + cmbFlag.Properties.Items.AddRange(flag_list); var record_list = packets.SelectMany(x => x.StationSignalRecords).ToList(); var root_folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "鍒嗘瀽"); @@ -339,7 +338,8 @@ ana_factor_list = JsonHelper.Json2Object<List<AnalysisHelper.AnalysisFactorDto>>(json); } - SetBindingData(_model_file, flag_pump_dict, record_list, ana_factor_list, this.barCekUseAnalysisFactor.Checked); + + SetBindingData(_model_file, station.SortCode, flag_pump_dict, record_list, ana_factor_list, barCekUseAnalysisFactor.Checked); } @@ -349,6 +349,7 @@ public void SetBindingData ( string model_inp, + int station_index, Dictionary<int, Model.Pump> flag_pump_dict, List<Model.StationSignalRecord> station_record_list, List<AnalysisHelper.AnalysisFactorDto> ana_factor_list, @@ -376,6 +377,8 @@ var curve_point_count = 100; var flag_qh_curve_dict = GetFlagCurveDict(); + var pipe_flow_id_list = GlobalHelper.GetPipeFlowIdList(station_index); + var pipe_pressure_id_list = GlobalHelper.GetPipePressureIdList(station_index); var pump_model_mapping_list = AnalysisHelper.GetPumpModelMappingList(); var model_mapping_list = AnalysisHelper.GetStationMappingList(); @@ -449,24 +452,71 @@ var run_flags = new List<int>() { 22, 23, 25 }; - var vm_list = new List<PumpViewModel>(); var vm_combine_list = new List<ModelCombineViewModel>(); var vm_diff_list = new List<ModelDiffViewModel>(); foreach (var station_record in station_record_list) { + var model_record_dict = station_record.ModelRecordDict; + var pipe_flow_err = true; + var pipe_pressure_err = true; + foreach (var id in pipe_flow_id_list) + { + if (model_record_dict[id] < 1) + { + pipe_flow_err = false; + break; + } + } + foreach (var id in pipe_pressure_id_list) + { + var value = model_record_dict[id]; + if (value < 1 || value > 40) + { + pipe_pressure_err = false; + break; + } + } + if (!pipe_flow_err || !pipe_pressure_err) + { + continue; + } + + var time = station_record.Time.ToString("G"); + var pump_record_list = station_record.PumpSignalRecords; + var total_flow = station_record.TotalFlow; + var total_pressure = station_record.TotalPressure; + var pump_total_flow = pump_record_list.Sum(x => x.FlowRate); + var diff_flow = station_record.DiffFlow; + //if (total_pressure < 20|| total_pressure>60) + //{ + // continue; + //} + if (total_pressure < 0) + { + continue; + } + if (total_flow <= 0 && pump_total_flow <= 0) + { + continue; + } + if (pump_total_flow > 0 && Math.Abs(diff_flow) > 2000) + { + continue; + } + //if (station_record.Time.Month==4&& station_record.Time.Day==17) + //{ + // continue; + //} + + //if (station_record.Time > new DateTime(2024,4,29)&& station_record.Time < new DateTime(2024, 5, 15)) //{ // continue; //} - var model_record_dict = station_record.ModelRecordDict; - var pump_record_list = station_record.PumpSignalRecords; - var pump_run_flags = pump_record_list.Select(x=>x.Flag).OrderBy(x=>x).ToList(); - //if (!pump_run_flags.SequenceEqual(run_flags)) - //{ - // continue; - //} + + var pump_run_flags = pump_record_list.Select(x => x.Flag).OrderBy(x => x).ToList(); if (pump_record_list.Exists(x => x.Flag != 15 && x.Flag != 16 && x.Rpm < 1)) { continue; @@ -480,10 +530,10 @@ if (pump_record_list.Exists(x => x.OutletPressure > 50)) { continue; - } - + } + if (ana_factor_list != null && ana_factor_list.Any() && use_ana_factor) - { + { foreach (var pump_record in pump_record_list) { var flag = pump_record.Flag; @@ -561,7 +611,7 @@ var vm_combine = new ModelCombineViewModel(); vm_combine.Time = time; vm_combine.RunFlags = IStation.Untity.IntListHelper.ToString(flags); - vm_combine.ModelDeviation = new Dictionary<int, double>(); + vm_combine.ModelDeviation = new List<Tuple<int, double, double>>(); vm_combine_list.Add(vm_combine); foreach (var pump_record in pump_record_list) @@ -575,7 +625,7 @@ rpm = pump.Nr; if (rpm == 0) break; - + var hz = Math.Round(rpm / pump.Nr * 50, 2); if (hz > 50) hz = 50; @@ -627,9 +677,12 @@ vm_list.Add(vm); + var calc_flow = flow > 0 ? flow : model_flow; + var dif_flow = flow - model_flow; + vm_combine.ScadaTotalFlow += flow < 1 ? model_flow : flow; vm_combine.ModelTotalFlow += model_flow; - vm_combine.ModelDeviation.Add(flag, pressure_diff_dev); + vm_combine.ModelDeviation.Add(new Tuple<int, double, double>(flag, calc_flow, pressure_diff_dev)); } @@ -692,45 +745,59 @@ return; } var run_flags_flow_pressure_diff_dict = vm_combine_list - .Select(x => new Tuple<string, double, Dictionary<int, double>>(x.RunFlags, x.ScadaTotalFlow, x.ModelDeviation)) + .Select(x => new Tuple<string, double, List<Tuple<int, double, double>>>(x.RunFlags, x.ScadaTotalFlow, x.ModelDeviation)) .ToList(); var ana_dev_list = AnalysisHelper.GetAnalysisDeviationDtoList(flag_pump_dict, run_flags_flow_pressure_diff_dict, _min_flow, _max_flow, _space_flow); + ////test + //if (station_index == 2) + //{ + // foreach (var item in ana_dev_list) + // { + // var count = item.PressureDiff.Count; + // for (int i = 0; i < count; i++) + // { + // var src_i = item.PressureDiff.ElementAt(i); + // var src_v = item.PressureDiff[src_i.Key]; + // item.PressureDiff[src_i.Key] = src_v < 0 ? Math.Abs(src_v) : -src_v; + // } + // } + //} var vm_combine_diff_list = ana_dev_list?.Select(x => new ModelCombineDiffViewModel() { RunFlags = IStation.Untity.IntListHelper.ToString(x.RunFlags), MinFlow = x.MinFlow, MaxFlow = x.MaxFlow, - ModelDeviation =JsonHelper.Object2Json(x.PressureDiff), + ModelDeviation = JsonHelper.Object2Json(x.PressureDiff), Count = x.Count }).ToList(); _model_combine_list = vm_combine_list; - SetBindingData(vm_diff_list); + //SetBindingData(vm_diff_list); _model_diff_vm_list = vm_diff_list; - this.modelTimeViewModelBindingSource.DataSource = _model_diff_vm_list; - this.modelTimeViewModelBindingSource.ResetBindings(false); - this.gridView3.BestFitColumns(); + modelTimeViewModelBindingSource.DataSource = _model_diff_vm_list; + modelTimeViewModelBindingSource.ResetBindings(false); + gridView3.BestFitColumns(); _pump_vm_list = vm_list; - this.pumpViewModelBindingSource.DataSource = vm_list; - this.pumpViewModelBindingSource.ResetBindings(false); - this.gridView1.BestFitColumns(); + pumpViewModelBindingSource.DataSource = vm_list; + pumpViewModelBindingSource.ResetBindings(false); + gridView1.BestFitColumns(); _model_combine_diff_vm_list = vm_combine_diff_list; - this.modelCombineDiffViewModelBindingSource.DataSource = vm_combine_diff_list; - this.modelCombineDiffViewModelBindingSource.ResetBindings(false); - this.gridView2.BestFitColumns(); + modelCombineDiffViewModelBindingSource.DataSource = vm_combine_diff_list; + modelCombineDiffViewModelBindingSource.ResetBindings(false); + gridView2.BestFitColumns(); } private void SetBindingData(List<ModelDiffViewModel> vm_list) { - this.timeValueSwiftPlotChartView1.ClearSeries(); + timeValueSwiftPlotChartView1.ClearSeries(); if (vm_list == null || !vm_list.Any()) { return; @@ -751,8 +818,8 @@ //var scada_pressure_list = item.Select(x => new TimeValue(x.Date, x.ScadaPressure)).ToList(); //var model_pressure_list = item.Select(x => new TimeValue(x.Date, x.MonitorPressure)).ToList(); - var pressure_diff_list = item.Where(x=>!(Math.Abs(x.PressureDiff) > 2)).Select(x => new TimeValue(x.Date, x.PressureDiff)).ToList(); - + var pressure_diff_list = item.Where(x => !(Math.Abs(x.PressureDiff) > 2)).Select(x => new TimeValue(x.Date, x.PressureDiff)).ToList(); + //this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(鐩戞祴娴侀噺)", "娴侀噺", scada_flow_list); //this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(妯″瀷娴侀噺)", "娴侀噺", model_flow_list); //this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(鍋忓樊娴侀噺)", "娴侀噺", flow_diff_list); @@ -760,7 +827,7 @@ // this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(鐩戞祴鍘嬪姏)", "鍘嬪姏", scada_pressure_list); //this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(妯″瀷鍘嬪姏)", "鍘嬪姏", model_pressure_list); - this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(鍋忓樊鍘嬪姏)", "鍘嬪姏", pressure_diff_list); + timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(鍋忓樊鍘嬪姏)", "鍘嬪姏", pressure_diff_list); } } @@ -842,7 +909,7 @@ { return; } - if (!int.TryParse(this.cmbFlag.Text, out int flag)) + if (!int.TryParse(cmbFlag.Text, out int flag)) { return; } @@ -851,7 +918,7 @@ { return; } - this.chartControl1.BeginInit(); + chartControl1.BeginInit(); foreach (var vm in vm_list) { var time = vm.Time; @@ -865,7 +932,7 @@ _series_correct_curve_head.Points.Add(new SeriesPoint(time, Math.Round(diff, 2))); } - this.chartControl1.EndInit(); + chartControl1.EndInit(); } @@ -901,8 +968,8 @@ WaitFrmHelper.ShowWaitForm("姝e湪瀵煎嚭"); var run_flags_flow_pressure_diff_dict = _model_combine_list - .Select(x => new Tuple<string, double, Dictionary<int, double>>(x.RunFlags, x.ScadaTotalFlow, x.ModelDeviation)) - .ToList(); + .Select(x => new Tuple<string, double, List<Tuple<int, double, double>>>(x.RunFlags, x.ScadaTotalFlow, x.ModelDeviation)) + .ToList(); var bol = AnalysisHelper.SaveAnalysisDeviationDtoList(_station.SortCode, _pump_list, run_flags_flow_pressure_diff_dict, _min_flow, _max_flow, _space_flow); if (!bol) { @@ -912,7 +979,7 @@ WaitFrmHelper.HideWaitForm(); AlertTool.ShowInfo(System.Windows.Forms.Application.OpenForms[0], "鎻愮ず", "瀵煎嚭瀹屾垚锛�"); - } + } } -- Gitblit v1.9.3