| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel.DataAnnotations; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using static IStation.WinFrmUI.Monitor.ModelCorrectionCombinePage; |
| | | |
| | | namespace IStation.WinFrmUI |
| | | { |
| | |
| | | public double? Hz { get; set; } |
| | | public double? Hz0 { get; set; } |
| | | } |
| | | |
| | | |
| | | public class AnalysisFactorDto |
| | | { |
| | | /// <summary> |
| | |
| | | /// 运行组合 |
| | | /// </summary> |
| | | public List<int> RunFlags { get; set; } |
| | | |
| | | public int RunCount { get; set; } |
| | | |
| | | |
| | | public double MinFlow { get; set; } |
| | | |
| | | |
| | | public double MaxFlow { get; set; } |
| | | |
| | | |
| | | public Dictionary<int, double> PressureDiff { get; set; } |
| | | |
| | | public string Remark { get; set; } |
| | | |
| | | public int Count { get; set; } |
| | | } |
| | | |
| | | |
| | | |
| | | public class PumpMapping |
| | | { |
| | | public int Flag { get; set; } |
| | | public int Flag { get; set; } |
| | | public string PumpId { get; set; } |
| | | public string FlowId { get; set; } |
| | | public string PressureId { get; set; } |
| | | public string CurveId { get; set; } |
| | | public string CurveId { get; set; } |
| | | public int PumpIndex { get; set; } |
| | | public int FlowIndex { get; set; } |
| | | public int PressureIndex { get; set; } |
| | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | #region Function |
| | | |
| | | |
| | | public static bool SaveAnalysisFactorDtoList(int station_index, List<Model.Equipment<Model.Pump>> eq_list, List<Tuple<int, double, double>> flag_hz_head_diff_list) |
| | | { |
| | | if (eq_list == null || !eq_list.Any()) |
| | |
| | | { |
| | | return default; |
| | | } |
| | | all_list.ForEach(x=>x.Station=station_index); |
| | | all_list.ForEach(x => x.Station = station_index); |
| | | var root_folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "分析"); |
| | | if (!Directory.Exists(root_folder)) |
| | | { |
| | | Directory.CreateDirectory(root_folder); |
| | | } |
| | | List<AnalysisFactorDto> exist_list = null; |
| | | var fileName = root_folder + "\\" + "AnalysisFactor.json"; |
| | | var fileName = root_folder + "\\" + "AnalysisFactor.json"; |
| | | if (File.Exists(fileName)) |
| | | { |
| | | var exist_json = File.ReadAllText(fileName); |
| | |
| | | { |
| | | all_list.AddRange(exist_list); |
| | | } |
| | | all_list= all_list.OrderBy(x=>x.Flag).ThenBy(x=>x.Hz).ToList(); |
| | | all_list = all_list.OrderBy(x => x.Flag).ThenBy(x => x.Hz).ToList(); |
| | | var json = JsonHelper.Object2Json(all_list); |
| | | File.WriteAllText(fileName, json); |
| | | return true; |
| | |
| | | var exist = exist_all_analysis_factor_list.Find(x => x.Flag == item.Flag && x.Hz == item.Hz); |
| | | if (exist == null) |
| | | continue; |
| | | item.HeadDeviation += exist.HeadDeviation; |
| | | item.HeadDeviation += exist.HeadDeviation; |
| | | } |
| | | } |
| | | } |
| | |
| | | vm.MinFlow = current_minQ; |
| | | vm.MaxFlow = current_maxQ; |
| | | var dev_dict = new Dictionary<int, double>(); |
| | | List<Tuple<int,double, double>> tuple_list = item_run_flags.SelectMany(x => x.Item3).ToList(); |
| | | List<Tuple<int, double, double>> tuple_list = item_run_flags.SelectMany(x => x.Item3).ToList(); |
| | | var group_by_flag = tuple_list.GroupBy(x => x.Item1); |
| | | foreach (var flag_item in group_by_flag) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | return list; |
| | | return list; |
| | | } |
| | | |
| | | public static List<AnalysisDeviationDto> GetCalcFlowAnalysisDeviationDtoList(Dictionary<int, Model.Pump> flag_pump_dict, List<Tuple<string, double, List<Tuple<int, double, double>>>> run_flags_flow_pressure_diff_dict, double minQ = 0, double maxQ = 100000, double spaceQ = 1000) |
| | |
| | | vm.MinFlow = current_minQ; |
| | | vm.MaxFlow = current_maxQ; |
| | | var dev_dict = new Dictionary<int, double>(); |
| | | List<Tuple<int, double,double>> tuple_list = item_run_flags.SelectMany(x => x.Item3).ToList(); |
| | | List<Tuple<int, double, double>> tuple_list = item_run_flags.SelectMany(x => x.Item3).ToList(); |
| | | var group_by_flag = tuple_list.GroupBy(x => x.Item1); |
| | | foreach (var flag_item in group_by_flag) |
| | | { |
| | | var flag = flag_item.Key; |
| | | var pump = flag_pump_dict[flag]; |
| | | |
| | | var head_diff_list = flag_item.Select(x => x.Item3).ToList(); |
| | | var head_diff_list = flag_item.Select(x => x.Item3).ToList(); |
| | | var head_filter_tuple = AnalysisHelper.GetFilterBySTDP(head_diff_list.ToArray(), opt_std_dev_pop); |
| | | var head_filter_array = head_filter_tuple.Item1; |
| | | var head_std_dev_pop = head_filter_tuple.Item2; |
| | |
| | | |
| | | |
| | | |
| | | public static List<AnalysisFactorDto> GetAnalysisFactorDtoList(Dictionary<int, Model.Pump> flag_pump_dict , List<Tuple<int, double, double>> flag_hz_head_diff_list) |
| | | public static List<AnalysisFactorDto> GetAnalysisFactorDtoList(Dictionary<int, Model.Pump> flag_pump_dict, List<Tuple<int, double, double>> flag_hz_head_diff_list) |
| | | { |
| | | if (flag_pump_dict == null || !flag_pump_dict.Any()) |
| | | { |
| | |
| | | return default; |
| | | } |
| | | |
| | | var exist_data_analysis_factor_list = new List<AnalysisFactorDto>(); |
| | | var exist_data_analysis_factor_list = new List<AnalysisFactorDto>(); |
| | | var opt_std_dev_pop = 0.3; |
| | | |
| | | //分析5hz范围内的系数 |
| | |
| | | if (item.Count() < 5) |
| | | continue; |
| | | |
| | | |
| | | |
| | | 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 = GetFilterBySTDP(head_diff_list.ToArray(), opt_std_dev_pop); |
| | | var filter_std_dev_pop_array = filter_std_dev_pop_tuple.Item1; |
| | | var std_dev_pop = filter_std_dev_pop_tuple.Item2; |
| | | var std_dev_pop = filter_std_dev_pop_tuple.Item2; |
| | | var std_dev_pop_head_avg = filter_std_dev_pop_array.Average(); |
| | | var head_diff_avg = std_dev_pop_head_avg; |
| | | if (Math.Abs(head_diff_avg) > 5) |
| | | continue; |
| | | if (Math.Abs(std_dev_pop) > 1) |
| | | continue; |
| | | |
| | | |
| | | if (Math.Abs(std_dev_pop) > 0.5 && item.Count() < 10) |
| | | continue; |
| | | |
| | |
| | | var pump = pump_item.Value; |
| | | if (!pump.IsBp) |
| | | continue; |
| | | if(!flag_range5_hz_factor_dict.ContainsKey(flag)) |
| | | if (!flag_range5_hz_factor_dict.ContainsKey(flag)) |
| | | continue; |
| | | var range5_hz_item = flag_range5_hz_factor_dict[flag]; |
| | | for (int hz = 1; hz <= 50; hz++) |
| | |
| | | { |
| | | var hz_list = range5_hz_item.Select(x => x.Key).ToList(); |
| | | var similar_hz = hz_list.Where(x => x >= hz_key)?.OrderBy(x => x).FirstOrDefault(); |
| | | if (similar_hz == null|| similar_hz.Value==0) |
| | | if (similar_hz == null || similar_hz.Value == 0) |
| | | { |
| | | similar_hz = hz_list.OrderByDescending(x => x).FirstOrDefault(); |
| | | } |
| | |
| | | all_analysis_factor_list = all_analysis_factor_list.OrderBy(x => x.Flag).ThenBy(x => x.Hz).ToList(); |
| | | return all_analysis_factor_list; |
| | | } |
| | | |
| | | public static Tuple<double[], double> GetFilterBySTDP(double[] array, double min_dev=0.3, int start_index = 0, int max_iteration_count = 1) |
| | | |
| | | public static Tuple<double[], double> GetFilterBySTDP(double[] array, double min_dev = 0.3, int start_index = 0, int max_iteration_count = 1) |
| | | { |
| | | if (array == null || !array.Any()) |
| | | { |
| | |
| | | start_index++; |
| | | return GetFilterBySTDP(filter_array, min_dev, start_index, max_iteration_count); |
| | | } |
| | | |
| | | |
| | | public static List<StationMapping> GetStationMappingList() |
| | | { |
| | | var list = new List<StationMapping>(); |
| | |
| | | list.Add(dn2700); |
| | | return list; |
| | | } |
| | | |
| | | |
| | | public static List<PumpMapping> GetPumpModelMappingList() |
| | | { |
| | | var list=new List<PumpMapping>(); |
| | | var list = new List<PumpMapping>(); |
| | | |
| | | var pump11 = new PumpMapping(); |
| | | var pump12 = new PumpMapping(); |
| | |
| | | var pump26 = new PumpMapping(); |
| | | var pump27 = new PumpMapping(); |
| | | |
| | | pump11.Flag = GlobalHelper.Flag11; |
| | | pump12.Flag = GlobalHelper.Flag12; |
| | | pump13.Flag = GlobalHelper.Flag13; |
| | | pump14.Flag = GlobalHelper.Flag14; |
| | | pump15.Flag = GlobalHelper.Flag15; |
| | | pump16.Flag = GlobalHelper.Flag16; |
| | | pump17.Flag = GlobalHelper.Flag17; |
| | | pump18.Flag = GlobalHelper.Flag18; |
| | | pump21.Flag = GlobalHelper.Flag21; |
| | | pump22.Flag = GlobalHelper.Flag22; |
| | | pump23.Flag = GlobalHelper.Flag23; |
| | | pump24.Flag = GlobalHelper.Flag24; |
| | | pump25.Flag = GlobalHelper.Flag25; |
| | | pump26.Flag = GlobalHelper.Flag26; |
| | | pump27.Flag = GlobalHelper.Flag27; |
| | | |
| | | pump11.Flag = GlobalHelperW.Flag11; |
| | | pump12.Flag = GlobalHelperW.Flag12; |
| | | pump13.Flag = GlobalHelperW.Flag13; |
| | | pump14.Flag = GlobalHelperW.Flag14; |
| | | pump15.Flag = GlobalHelperW.Flag15; |
| | | pump16.Flag = GlobalHelperW.Flag16; |
| | | pump17.Flag = GlobalHelperW.Flag17; |
| | | pump18.Flag = GlobalHelperW.Flag18; |
| | | pump21.Flag = GlobalHelperW.Flag21; |
| | | pump22.Flag = GlobalHelperW.Flag22; |
| | | pump23.Flag = GlobalHelperW.Flag23; |
| | | pump24.Flag = GlobalHelperW.Flag24; |
| | | pump25.Flag = GlobalHelperW.Flag25; |
| | | pump26.Flag = GlobalHelperW.Flag26; |
| | | pump27.Flag = GlobalHelperW.Flag27; |
| | | |
| | | pump11.PumpId = "Pump11"; |
| | | pump12.PumpId = "Pump12"; |
| | | pump13.PumpId = "Pump13"; |
| | |
| | | list.Add(pump24); |
| | | list.Add(pump25); |
| | | list.Add(pump26); |
| | | list.Add(pump27); |
| | | list.Add(pump27); |
| | | return list; |
| | | } |
| | | |
| | | |
| | | public static List<string> GetPatternIdList() |
| | | { |
| | | var list = new List<string>(); |
| | | var list = new List<string>(); |
| | | list.Add("Pump11"); |
| | | list.Add("Pump12"); |
| | | list.Add("Pump13"); |
| | |
| | | wl_dict.Add("RPump25", 0); |
| | | wl_dict.Add("RPump26", 0); |
| | | wl_dict.Add("RPump27", 0); |
| | | |
| | | |
| | | |
| | | double? r1 = null, r2 = null; |
| | | foreach (var item in flag_pressure_diff_dev) |