| | |
| | | using IStation.Curve; |
| | | using IStation.Application; |
| | | using IStation.Curve; |
| | | using IStation.Model; |
| | | using MathNet.Numerics.LinearAlgebra; |
| | | using MathNet.Numerics.LinearAlgebra.Double; |
| | | using System.IO; |
| | | using System.Text; |
| | | using Yw.Untity; |
| | | using static IStation.Service.ScheduleHelper; |
| | | |
| | | namespace IStation.Win.Schedule |
| | | { |
| | |
| | | |
| | | private static readonly IStation.Service.MonitorRecord _service_monitor_record = new(); |
| | | private static readonly Service.AnalysisDeviation _service_analysis_deviation = new(); |
| | | private static readonly Service.FlowDeviation _service_flow_deviation = new(); |
| | | |
| | | private long _last_request_id = 0; |
| | | private bool _use_debug_scada = true; |
| | |
| | | { |
| | | return; |
| | | } |
| | | var deline = new DateTime(2025,2,12); |
| | | var deline2 = new DateTime(2025,5,1); |
| | | var time_list = _schedule_request_list.Where(x=>x.ReceptionTime>=deline&&x.ReceptionTime<= deline2).Select(x => x.ReceptionTime).OrderBy(x => x).ToList(); |
| | | |
| | | var deline = new DateTime(2025, 4, 18); |
| | | var deline2 = new DateTime(2025, 5, 1); |
| | | var time_list = _schedule_request_list.Where(x => x.ReceptionTime >= deline && x.ReceptionTime <= deline2).Select(x => x.ReceptionTime).OrderBy(x => x).ToList(); |
| | | |
| | | foreach (var item in time_list) |
| | | { |
| | | this.repImgDate.Items.Add(item.ToString("G"), item, -1); |
| | | } |
| | | } |
| | | var monitor_record_list = _service_monitor_record.GetByReceiptTimeRange(deline, deline2); |
| | | if (monitor_record_list == null || !monitor_record_list.Any()) |
| | | { |
| | |
| | | if (_monitor_record_dict != null && _monitor_record_dict.ContainsKey(time)) |
| | | { |
| | | var valid_record_list = _monitor_record_dict[time]; |
| | | var station_scada_dict = GetStationScadaDict(monitor_record_list); |
| | | var station_scada_dict = GetStationScadaDict(monitor_record_list); |
| | | |
| | | var validRealTimePressure = station_scada_dict[IStation.eDockingStation.Ch1s][0].Item2 ; |
| | | var validRealTimePressure = station_scada_dict[IStation.eDockingStation.Ch1s][0].Item2; |
| | | if (validRealTimePressure.HasValue) |
| | | { |
| | | var validRealTimePressureDiff = validRealTimePressure.Value - target_pressure1; |
| | | target_pressure1 += validRealTimePressureDiff; |
| | | AlertTool.ShowInfo(this, "填补压力缺失", $"{validRealTimePressureDiff:N3}"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | station2_target_flow_diff = new Service.FlowDeviation().GetFlowDiff(target_pressure2); |
| | | AlertTool.ShowInfo(this, "预测流量缺失", $"{station2_target_flow_diff:N1}"); |
| | | //var ptList = new List<CurvePoint>(); |
| | | //try |
| | | //{ |
| | | // var filePath = @"D:\WorkCode\Project\ChDt1\Schedule.Ch.V1.0\02-desktop\Desktop\IStation.Test\bin\Debug\net6.0-windows\stationcsv\characteristic_curve.csv"; |
| | | // using (StreamReader reader = new StreamReader(filePath)) |
| | | // { |
| | | // reader.ReadLine(); |
| | | // string line; |
| | | // while ((line = reader.ReadLine()) != null) |
| | | // { |
| | | // // 按逗号分隔每一行 |
| | | // string[] values = line.Split(','); |
| | | // var xStr = values[0]; |
| | | // var yStr = values[1]; |
| | | |
| | | // var pX = double.Parse(xStr); |
| | | // var pY = double.Parse(yStr); |
| | | |
| | | // pY = Math.Abs(pY); |
| | | // ptList.Add(new CurvePoint(pX, pY)); |
| | | |
| | | // } |
| | | // } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // Console.WriteLine("读取文件时出错: " + ex.Message); |
| | | //} |
| | | |
| | | //var x = ptList.Select(x => x.X).ToArray(); |
| | | //var y = ptList.Select(x => x.Y).ToArray(); |
| | | |
| | | //// 多项式回归的阶数(例如,二次多项式) |
| | | //int degree = 3; |
| | | |
| | | //// 拟合多项式回归模型 |
| | | //double[] coefficients = NonlinearRegressionHelper.FitPolynomial(x, y, degree); |
| | | |
| | | //// 使用模型进行预测 |
| | | //double xNew = target_pressure2; |
| | | //double yPredicted = NonlinearRegressionHelper.PredictPolynomial(xNew, coefficients); |
| | | |
| | | //station2_target_flow_diff = yPredicted; |
| | | //AlertTool.ShowInfo(this, "预测流量缺失", $"{yPredicted:N1}"); |
| | | |
| | | |
| | | //// 计算 R² 和 MSE |
| | | //double rSquared = NonlinearRegressionHelper.CalculateRSquared(x, y, coefficients); |
| | | //double mse = NonlinearRegressionHelper.CalculateMSE(x, y, coefficients); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | GlobalHelper.GetStationFlagStateList(monitor_record_list, out List<int> station1_maintenance_flag_list, out List<int> station2_maintenance_flag_list, out List<int> station1_priority_flag_list, out List<int> station2_priority_flag_list); |
| | | GlobalHelper.GetFlagInletWaterLevelDict(monitor_record_list, out Dictionary<int, double> station1_flag_inlet_water_level_dict, out Dictionary<int, double> station2_flag_inlet_water_level_dict); |
| | | |
| | | station1_schedule_config.MaintenanceFlagList = new List<int>(); |
| | | station2_schedule_config.MaintenanceFlagList = new List<int>(); |
| | | station1_schedule_config.PriorityOpenFlagList = new List<int>(); |
| | | station2_schedule_config.PriorityOpenFlagList = new List<int>(); |
| | | if (station1_maintenance_flag_list != null && station1_maintenance_flag_list.Any()) |
| | | { |
| | | station1_schedule_config.MaintenanceFlagList.AddRange(station1_maintenance_flag_list); |
| | | } |
| | | if (station2_maintenance_flag_list != null && station2_maintenance_flag_list.Any()) |
| | | { |
| | | station2_schedule_config.MaintenanceFlagList.AddRange(station2_maintenance_flag_list); |
| | | } |
| | | |
| | | if (station1_priority_flag_list != null && station1_priority_flag_list.Any()) |
| | | { |
| | | station1_schedule_config.PriorityOpenFlagList.AddRange(station1_priority_flag_list); |
| | | } |
| | | if (station2_priority_flag_list != null && station2_priority_flag_list.Any()) |
| | | { |
| | | station2_schedule_config.PriorityOpenFlagList.AddRange(station2_priority_flag_list); |
| | | } |
| | | |
| | | |
| | | |
| | | var helper = new Service.ScheduleHelper(); |
| | | helper.Initial(station1_open_flag_list, station1_schedule_config, analysis_deviation_list); |
| | | var optimal_combine1 = helper.GetOptAnaCombine(station1, station1_flag_inlet_water_level_dict, target_flow1, target_pressure1); |
| | | //var optimal_combine1 = helper.GetOptAnaCombine(station1, station1_flag_inlet_water_level_dict, target_flow1, target_pressure1); |
| | | AnaCombine optimal_combine1 = null; |
| | | |
| | | |
| | | var limit_info = VerifyWaterSupplyLimit(station1_schedule_config.WaterSupplyLimitList, station1_open_flag_list, target_flow1); |
| | | if (!string.IsNullOrEmpty(limit_info)) |
| | | { |
| | | AlertTool.ShowInfo(this,"供水限制",limit_info); |
| | | } |
| | | |
| | | limit_info = VerifyWaterSupplyLimit(station2_schedule_config.WaterSupplyLimitList, station2_open_flag_list, target_flow2); |
| | | if (!string.IsNullOrEmpty(limit_info)) |
| | | { |
| | | AlertTool.ShowInfo(this, "供水限制", limit_info); |
| | | } |
| | | |
| | | helper.Initial(station2_open_flag_list, station2_schedule_config, analysis_deviation_list, station2_target_flow_diff); |
| | | var optimal_combine2 = helper.GetOptAnaCombine(station2, station2_flag_inlet_water_level_dict, target_flow2, target_pressure2); |
| | |
| | | this.pumpScheduleVmBindingSource1.ResetBindings(false); |
| | | } |
| | | |
| | | private string VerifyWaterSupplyLimit(List<WaterSupplyLimit> waterSupplyLimits, List<int> station_open_flag_list, double targetFlow) |
| | | { |
| | | if (waterSupplyLimits != null && waterSupplyLimits.Any()) |
| | | { |
| | | if (station_open_flag_list != null && station_open_flag_list.Any()) |
| | | { |
| | | var pumpCount = station_open_flag_list.Count; |
| | | var exist_limit = waterSupplyLimits.Find(x => x.PumpCount == pumpCount); |
| | | if (exist_limit != null) |
| | | { |
| | | if (targetFlow < exist_limit.Min || targetFlow > exist_limit.Max) |
| | | { |
| | | var flags = Yw.Untity.IntListHelper.ToString(station_open_flag_list); |
| | | return $"[{flags}]:目标流量:{targetFlow},供水限制:{exist_limit.Min}-{exist_limit.Max}"; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | |
| | | private void Reset() |
| | | { |