| | |
| | | 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"); |
| | |
| | | _series_default_head.CrosshairLabelPattern = "监测压力:{V}"; |
| | | _series_curve_head.CrosshairLabelPattern = "模型压力:{V}"; |
| | | _series_correct_curve_head.CrosshairLabelPattern = "压力偏差:{V}"; |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | 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; } |
| | | |
| | |
| | | |
| | | 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 |
| | | |
| | |
| | | |
| | | 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; |
| | | |
| | | private string _model_file = System.IO.Path.Combine |
| | | (Settings.File.RootDirectory, Settings.File.DataFolder, "ch2_v3_20240801(Clear).inp"); |
| | | (SettingsD.File.RootDirectory, SettingsD.File.DataFolder, "ch2_v3_20240801(Clear).inp"); |
| | | |
| | | /// <summary> |
| | | /// 清空数据 |
| | |
| | | _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(); |
| | | } |
| | |
| | | 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> |
| | |
| | | /// </summary> |
| | | public override void InitialDataSource() |
| | | { |
| | | this.stationListCtrl1.SetBindingData(); |
| | | this.monitorDataSourcesTreeList1.SetBindingData(); |
| | | stationListCtrl1.SetBindingData(); |
| | | monitorDataSourcesTreeList1.SetBindingData(); |
| | | } |
| | | |
| | | //泵站变换 |
| | |
| | | { |
| | | 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()) |
| | |
| | | } |
| | | 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, "分析"); |
| | |
| | | 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); |
| | | } |
| | | |
| | | |
| | |
| | | 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, |
| | |
| | | |
| | | var curve_point_count = 100; |
| | | var flag_qh_curve_dict = GetFlagCurveDict(); |
| | | var pipe_flow_id_list = GlobalHelperW.GetPipeFlowIdList(station_index); |
| | | var pipe_pressure_id_list = GlobalHelperW.GetPipePressureIdList(station_index); |
| | | |
| | | var pump_model_mapping_list = AnalysisHelper.GetPumpModelMappingList(); |
| | | var model_mapping_list = AnalysisHelper.GetStationMappingList(); |
| | |
| | | continue; |
| | | pattern_id_dict.Add(id, index); |
| | | } |
| | | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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) |
| | |
| | | rpm = pump.Nr; |
| | | if (rpm == 0) |
| | | break; |
| | | |
| | | |
| | | var hz = Math.Round(rpm / pump.Nr * 50, 2); |
| | | if (hz > 50) |
| | | hz = 50; |
| | |
| | | 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)); |
| | | } |
| | | |
| | | |
| | |
| | | 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; |
| | |
| | | |
| | | //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); |
| | |
| | | |
| | | // 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); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | return; |
| | | } |
| | | if (!int.TryParse(this.cmbFlag.Text, out int flag)) |
| | | if (!int.TryParse(cmbFlag.Text, out int flag)) |
| | | { |
| | | return; |
| | | } |
| | |
| | | { |
| | | return; |
| | | } |
| | | this.chartControl1.BeginInit(); |
| | | chartControl1.BeginInit(); |
| | | foreach (var vm in vm_list) |
| | | { |
| | | var time = vm.Time; |
| | |
| | | _series_correct_curve_head.Points.Add(new SeriesPoint(time, Math.Round(diff, 2))); |
| | | } |
| | | |
| | | this.chartControl1.EndInit(); |
| | | chartControl1.EndInit(); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | WaitFrmHelper.ShowWaitForm("正在导出"); |
| | | 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) |
| | | { |
| | |
| | | WaitFrmHelper.HideWaitForm(); |
| | | AlertTool.ShowInfo(System.Windows.Forms.Application.OpenForms[0], "提示", "导出完成!"); |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |