ningshuxia
2025-04-03 4917fb959e2befec07a693e72d7010c09494ec7c
02-desktop/WinFrmUI/IStation.WinFrmUI.Monitor/03-WorkingConditionAnalysis/06-ModelCorrectionCompare/ModelCorrectionCompare.cs
@@ -1,5 +1,4 @@
using DevExpress.XtraCharts;
using IStation.Epanet;
using IStation.Epanet;
using IStation.Epanet.Enums;
using IStation.Model;
using IStation.Untity;
@@ -19,23 +18,23 @@
        public ModelCorrectionComparePage()
        {
            InitializeComponent();
            this.PageTitle.Caption = "模型修正对比";
            this.repositoryItemDateEdit1.SetOnlyShowYearMonth();
            this.repositoryItemDateEdit2.SetOnlyShowYearMonth();
            this.barEditDateStart.EditValue = new DateTime(2024, 9, 1);
            this.barEditDateEnd.EditValue = new DateTime(2024, 9, 1);
            PageTitle.Caption = "模型修正对比";
            this.barCekUseFlow.Checked = true;
            this.stationListCtrl1.FocusedChangedEvent += StationListCtrl1_FocusedChangedEvent;
            this.monitorDataSourcesTreeList1.FocusedChangedEvent += MonitorDataSourcesListCtrl1_FocusedChangedEvent;
            this.timeValueSwiftPlotChartView1.SetTimeAxisX(DevExpress.XtraCharts.DateTimeMeasureUnit.Minute);
            repositoryItemDateEdit1.SetOnlyShowYearMonth();
            repositoryItemDateEdit2.SetOnlyShowYearMonth();
            barEditDateStart.EditValue = new DateTime(2024, 9, 1);
            barEditDateEnd.EditValue = new DateTime(2024, 9, 1);
            barCekUseFlow.Checked = true;
            stationListCtrl1.FocusedChangedEvent += StationListCtrl1_FocusedChangedEvent;
            monitorDataSourcesTreeList1.FocusedChangedEvent += MonitorDataSourcesListCtrl1_FocusedChangedEvent;
            timeValueSwiftPlotChartView1.SetTimeAxisX(DevExpress.XtraCharts.DateTimeMeasureUnit.Minute);
        }
        #region ViewModel  
@@ -125,7 +124,7 @@
        {
            public string Time { get; set; }
            public string RunFlags { get; set; }
            public double TotalFlow { get; set; }
            public double TotalFlow { get; set; }
            public Dictionary<int, double> PressureDiffDevDict { get; set; }
        }
@@ -149,19 +148,19 @@
            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
@@ -174,7 +173,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>
        /// 清空数据
@@ -182,18 +181,18 @@
        public void Clear()
        {
            _pump_vm_list = new List<PumpViewModel>();
            _model_diff_vm_list = new List<StationViewModel>();
            this.timeValueSwiftPlotChartView1.ClearSeries();
            _model_diff_vm_list = new List<StationViewModel>();
            timeValueSwiftPlotChartView1.ClearSeries();
        }
        /// <summary>
        /// 初始化数据
        /// </summary>
        public override void InitialDataSource()
        {
            this.stationListCtrl1.SetBindingData();
            this.monitorDataSourcesTreeList1.SetBindingData();
            stationListCtrl1.SetBindingData();
            monitorDataSourcesTreeList1.SetBindingData();
        }
        //泵站变换
@@ -227,15 +226,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())
@@ -247,7 +246,7 @@
                return;
            }
            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();
            var flag_list = _pump_list.Select(x => x.SortCode).OrderBy(x => x).ToList();
            var record_list = packets.SelectMany(x => x.StationSignalRecords).ToList();
            var root_folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "分析");
@@ -273,10 +272,10 @@
            var pump_mapping_dict = pump_mapping_list.ToDictionary(x => x.Flag, x => x);
            var flag_qh_curve_dict = GetFlagCurveDict();
            Set(_model_file, record_list, station_mapping_list, pump_mapping_dict, flag_pump_dict, flag_qh_curve_dict,ana_factor_list, ana_deviation_list);
            Set(_model_file, record_list, station_mapping_list, pump_mapping_dict, flag_pump_dict, flag_qh_curve_dict, ana_factor_list, ana_deviation_list);
        }
        #region Color
@@ -319,7 +318,7 @@
            return true;
        }
        private Dictionary<int, Model.CurveExpress> GetFlagCurveDict()
        {
            var dict = new Dictionary<int, Model.CurveExpress>();
@@ -347,7 +346,7 @@
            return dict;
        }
        //加载
        private void barCekLoad_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
@@ -382,7 +381,7 @@
             List<AnalysisHelper.AnalysisFactorDto> ana_factor_list,
             List<AnalysisHelper.AnalysisDeviationDto> ana_deviation_list
            )
        {
        {
            if (ana_factor_list == null || !ana_factor_list.Any())
            {
                Clear();
@@ -399,7 +398,7 @@
            var second_vm_pump_list = second_tuple.Item1;
            var second_vm_station_list = second_tuple.Item2;
            if (ana_deviation_list == null || !ana_deviation_list.Any())
            {
                Clear();
@@ -418,7 +417,7 @@
            int first_count = 0;
            int second_count = 0;
            var second_group = second_vm_station_list.GroupBy(x => x.Name);
            for (int i = 0; i < second_group.Count(); i++)
            {
@@ -439,14 +438,14 @@
                      .Select(x => new TimeValue(x.Date, x.PressureDiff))
                      .ToList();
                this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(修正)", "压力", list);
            }
                timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(修正)", "压力", list);
            }
            second_count = second_group.Count();
            var third_group = third_vm_station_list.GroupBy(x => x.Name);
            for (int i = 0; i < third_group.Count(); i++)
            {
                var color = GetRandomColor(i + first_count+second_count);
                var color = GetRandomColor(i + first_count + second_count);
                var item = third_group.ElementAt(i);
                var name = item.Key;
                var pressure_diff_list = item.Select(x => x.PressureDiff).ToList();
@@ -463,7 +462,7 @@
                      .Select(x => new TimeValue(x.Date, x.PressureDiff))
                      .ToList();
                this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(二次修正)", "压力", list);
                timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(二次修正)", "压力", list);
            }
@@ -577,7 +576,7 @@
                    continue;
                }
                //设置模式
                foreach (var pattern in pattern_id_dict)
@@ -604,7 +603,7 @@
                    {
                        var run_flags = pump_record_list.Select(x => x.Flag).OrderBy(x => x).ToList();
                        ana_dev = ana_dev_list.Find(x => x.RunFlags.SequenceEqual(run_flags));
                    }
                    }
                    foreach (var pump_record in pump_record_list)
                    {
                        var flag = pump_record.Flag;
@@ -829,7 +828,7 @@
                        var diff_V = Model.CurveCalcuHelper.CalculateOtherPress(flow_std_dev_pop_head_avg, pump.Ic, pump.Oc, null, null);
                        var head_diff_avg = -(pressure_diff_std_dev_pop_head_avg + diff_V);
                        diff_avg = head_diff_avg;
                    }
@@ -973,8 +972,8 @@
        public List<AnalysisDeviationDto> AnalysisDeviationSet
            (
            Dictionary<int, Model.Pump> flag_pump_dict,
            List<Tuple<string, double, Dictionary<int, double>>> run_flags_flow_pressure_diff_dev_dict,
            Dictionary<int, Model.Pump> flag_pump_dict,
            List<Tuple<string, double, Dictionary<int, double>>> run_flags_flow_pressure_diff_dev_dict,
            double minQ = 0,
            double maxQ = 100000,
            double spaceQ = 1000
@@ -1036,13 +1035,13 @@
                    vm.Count = item_run_flags.Count();
                    vm.PressureDiff = dev_dict;
                    list.Add(vm);
                }
                }
            }
            return list;
        }
    }
}