From 1519533649b43337d214523f7cd075edf237b3f7 Mon Sep 17 00:00:00 2001 From: ningshuxia <ningshuxia0927@outlook.com> Date: 星期二, 22 四月 2025 13:57:42 +0800 Subject: [PATCH] 代码修改 --- 01-api/_Expand/IStation.Win.Schedule/bjMain.cs | 133 ++++++++++++++++++++++++-------------------- 1 files changed, 73 insertions(+), 60 deletions(-) diff --git a/01-api/_Expand/IStation.Win.Schedule/bjMain.cs b/01-api/_Expand/IStation.Win.Schedule/bjMain.cs index 3fda114..9c170ba 100644 --- a/01-api/_Expand/IStation.Win.Schedule/bjMain.cs +++ b/01-api/_Expand/IStation.Win.Schedule/bjMain.cs @@ -1,9 +1,12 @@ -锘縰sing IStation.Curve; +锘縰sing 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 { @@ -40,6 +43,7 @@ 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; @@ -83,14 +87,14 @@ { 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()) { @@ -145,15 +149,15 @@ 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}"); - } + } } } @@ -162,56 +166,6 @@ { 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); - } @@ -220,9 +174,47 @@ 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); @@ -631,6 +623,27 @@ 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() { -- Gitblit v1.9.3