ningshuxia
2025-04-03 4917fb959e2befec07a693e72d7010c09494ec7c
02-desktop/WinFrmUI/IStation.WinFrmUI.Monitor/03-WorkingConditionAnalysis/04-ModelCorrection/ModelCorrectionPage.cs
@@ -21,41 +21,41 @@
        public ModelCorrectionPage()
        {
            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, 1, 1);
            this.barEditDateEnd.EditValue = new DateTime(2024, 9, 1);
            repositoryItemDateEdit1.SetOnlyShowYearMonth();
            repositoryItemDateEdit2.SetOnlyShowYearMonth();
            barEditDateStart.EditValue = new DateTime(2024, 1, 1);
            barEditDateEnd.EditValue = new DateTime(2024, 9, 1);
            this.cmbFlag.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            cmbFlag.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            // this.barCekUseFlow.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            this.barCekUseFlow.Checked = true;
            barCekUseFlow.Checked = true;
            this.stationListCtrl1.FocusedChangedEvent += StationListCtrl1_FocusedChangedEvent;
            this.monitorDataSourcesTreeList1.FocusedChangedEvent += MonitorDataSourcesListCtrl1_FocusedChangedEvent;
            this.timeValueSwiftPlotChartView1.SetTimeAxisX(DevExpress.XtraCharts.DateTimeMeasureUnit.Minute);
            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 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;//窗格的对齐方式 
@@ -126,7 +126,7 @@
        }
        public class ModelDiffViewModel
        {
        {
            [Display(Name = "时间")]
            public DateTime Date { get; set; }
@@ -176,13 +176,13 @@
            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);
                }
            }
@@ -194,9 +194,9 @@
            public CurveQhdPoint(double q, double h, double pd)
            {
                this.Q = q;
                this.H = h;
                this.Pd = pd;
                Q = q;
                H = h;
                Pd = pd;
            }
            public CurveQhdPoint() { }
            public double Q { get; set; }
@@ -216,7 +216,7 @@
        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>
        /// 清空数据
@@ -225,22 +225,22 @@
        {
            _pump_vm_list = new List<PumpViewModel>();
            _model_diff_vm_list = new List<ModelDiffViewModel>();
            this.cmbFlag.SelectedItem = null;
            this.cmbFlag.Properties.Items.Clear();
            this.modelTimeViewModelBindingSource.DataSource = new List<ModelDiffViewModel>();
            this.pumpFactorViewModelBindingSource.DataSource = new List<PumpFactorViewModel>();
            this.pumpViewModelBindingSource.DataSource = new List<PumpViewModel>();
            cmbFlag.SelectedItem = null;
            cmbFlag.Properties.Items.Clear();
            modelTimeViewModelBindingSource.DataSource = new List<ModelDiffViewModel>();
            pumpFactorViewModelBindingSource.DataSource = new List<PumpFactorViewModel>();
            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>
@@ -248,8 +248,8 @@
        /// </summary>
        public override void InitialDataSource()
        {
            this.stationListCtrl1.SetBindingData();
            this.monitorDataSourcesTreeList1.SetBindingData();
            stationListCtrl1.SetBindingData();
            monitorDataSourcesTreeList1.SetBindingData();
        }
        //泵站变换
@@ -283,15 +283,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())
@@ -304,7 +304,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, "分析");
@@ -317,7 +317,7 @@
            }
            var pipe_flow_id_list = GlobalHelper.GetPipeFlowIdList(station.SortCode);
            var pipe_pressure_id_list = GlobalHelper.GetPipePressureIdList(station.SortCode);
            SetBindingData(_model_file, pipe_flow_id_list, pipe_pressure_id_list, flag_pump_dict, record_list, ana_factor_list, this.barCekUseAnalysisFactor.Checked);
            SetBindingData(_model_file, pipe_flow_id_list, pipe_pressure_id_list, flag_pump_dict, record_list, ana_factor_list, barCekUseAnalysisFactor.Checked);
        }
@@ -401,6 +401,7 @@
                {
                    throw new Exception($"ENsetcurve:{err}");
                }
            }
            foreach (var item in model_mapping_list)
@@ -472,7 +473,7 @@
                if (pump_total_flow > 0 && Math.Abs(diff_flow) > 2000)
                {
                    continue;
                }
                }
                if (pump_record_list.Exists(x => x.Flag != 15 && x.Flag != 16 && x.Rpm < 1))
                {
                    continue;
@@ -589,7 +590,7 @@
                    {
                        throw new Exception($"ENgetnodevalue:{err}");
                    }
                    if (Math.Abs(model_flow) <1)
                    if (Math.Abs(model_flow) < 1)
                    {
                        break;
                    }
@@ -599,8 +600,8 @@
                    {
                        throw new Exception($"ENgetnodevalue:{err}");
                    }
                    if (Math.Abs(model_outlet_pressure)>45)
                    if (Math.Abs(model_outlet_pressure) > 45)
                    {
                        break;
                    }
@@ -696,7 +697,7 @@
            var vm_pump_facotr_list = new List<PumpFactorViewModel>();
            if (this.barCekUseFlow.Checked)
            if (barCekUseFlow.Checked)
            {
                var flag_hz_head_diff_flow_list = vm_list.Select(x => new Tuple<int, double, double, double>(x.Flag, x.Hz0, x.PressureDiffDev, x.ModelFlow)).ToList();
                var list_flow = GetAnalysisFactorDtoList(flag_pump_dict, flag_hz_head_diff_flow_list);
@@ -718,7 +719,7 @@
                var list = AnalysisHelper.GetAnalysisFactorDtoList(flag_pump_dict, flag_hz_head_diff_list);
                foreach (var item in list)
                {
                    var vm_pump_facotr = new PumpFactorViewModel();
                    var vm_pump_facotr = new PumpFactorViewModel();
                    vm_pump_facotr.Flag = item.Flag;
                    vm_pump_facotr.Hz = item.Hz;
                    vm_pump_facotr.STDP = item.HeadSTDP;
@@ -733,19 +734,19 @@
            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();
            this.pumpFactorViewModelBindingSource.DataSource = vm_pump_facotr_list;
            this.pumpFactorViewModelBindingSource.ResetBindings(false);
            this.gridView2.BestFitColumns();
            pumpFactorViewModelBindingSource.DataSource = vm_pump_facotr_list;
            pumpFactorViewModelBindingSource.ResetBindings(false);
            gridView2.BestFitColumns();
            GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
            GC.Collect(2, GCCollectionMode.Forced);
@@ -754,7 +755,7 @@
        private void SetBindingData(List<ModelDiffViewModel> vm_list)
        {
            this.timeValueSwiftPlotChartView1.ClearSeries();
            timeValueSwiftPlotChartView1.ClearSeries();
            if (vm_list == null || !vm_list.Any())
            {
                return;
@@ -775,8 +776,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);
@@ -784,7 +785,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);
            }
        }
@@ -866,7 +867,7 @@
            {
                return;
            }
            if (!int.TryParse(this.cmbFlag.Text, out int flag))
            if (!int.TryParse(cmbFlag.Text, out int flag))
            {
                return;
            }
@@ -875,7 +876,7 @@
            {
                return;
            }
            this.chartControl1.BeginInit();
            chartControl1.BeginInit();
            foreach (var vm in vm_list)
            {
                var time = vm.Time;
@@ -889,7 +890,7 @@
                _series_correct_curve_head.Points.Add(new SeriesPoint(time, Math.Round(diff, 2)));
            }
            this.chartControl1.EndInit();
            chartControl1.EndInit();
        }
@@ -926,7 +927,7 @@
            WaitFrmHelper.ShowWaitForm("正在导出");
            var bol = false;
            if (this.barCekUseFlow.Checked)
            if (barCekUseFlow.Checked)
            {
                var flag_hz_head_diff_flow_list = _pump_vm_list.Select(x => new Tuple<int, double, double, double>(x.Flag, x.Hz0, x.PressureDiffDev, x.ModelFlow)).ToList();
                bol = SaveAnalysisFactorDtoList(_station.SortCode, _pump_list, flag_hz_head_diff_flow_list);
@@ -1061,7 +1062,7 @@
                    continue;
                var flag = item.Key.Item1;
                var flag = item.Key.Item1;
                var pump = flag_pump_dict[flag];
                var head_diff_list = item.Select(x => x.Item3).ToList();
                var filter_std_dev_pop_tuple = AnalysisHelper.GetFilterBySTDP(head_diff_list.ToArray(), opt_std_dev_pop);
@@ -1163,8 +1164,8 @@
            all_analysis_factor_list = all_analysis_factor_list.OrderBy(x => x.Flag).ThenBy(x => x.Hz).ToList();
            return all_analysis_factor_list;
        }
    }
}