From 1519533649b43337d214523f7cd075edf237b3f7 Mon Sep 17 00:00:00 2001 From: ningshuxia <ningshuxia0927@outlook.com> Date: 星期二, 22 四月 2025 13:57:42 +0800 Subject: [PATCH] 代码修改 --- 02-desktop/Desktop/IStation.Test/Program.cs | 128 ++++++++++++++++++++---------------------- 1 files changed, 60 insertions(+), 68 deletions(-) diff --git a/02-desktop/Desktop/IStation.Test/Program.cs b/02-desktop/Desktop/IStation.Test/Program.cs index f707e4e..fa0a2cc 100644 --- a/02-desktop/Desktop/IStation.Test/Program.cs +++ b/02-desktop/Desktop/IStation.Test/Program.cs @@ -12,6 +12,7 @@ // 淇缁勫悎鍋忓樊 static void Main(string[] args) { + Console.WriteLine("start"); //Station1Helper.Start(); //1 鏁版嵁淇 //Station2Helper.Start(); //2 妯″瀷淇 // 3 python淇 ,鐩墠鏈変簺鏁版嵁闂杩橀渶瑕佽В鍐� @@ -20,16 +21,70 @@ //StationCombineHelper.Start(1);// 5 缁勫悎鍋忓樊淇 //StationCombineHelper.Start(2);// 5 缁勫悎鍋忓樊淇 - // 6 鍒嗘瀽娉甸璋辩郴鏁� - // 7 - // Station2TotalFlowDiffHelper.Start();// 8 琛ュ叏娴侀噺鍋忓樊 + python + // AnalysisDeviation(); // 6 鍒嗘瀽娉甸璋辩郴鏁� + // 7 + // Station2TotalFlowDiffHelper.Start();// 8 C# 瀵煎嚭鏁版嵁 琛ュ叏娴侀噺鍋忓樊 + python + + + //test + + StationTotalFlowPressureHelper.Start(); Console.WriteLine(); Console.WriteLine("ok"); Console.ReadKey(); } + public static void AnalysisDeviation() + { + var fullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "pumpcombine"); + var fileNameList = Directory.GetFiles(fullPath).Select(x => x).ToList(); + if (fileNameList == null || fileNameList.Count < 1) + return; + + var stationDict = new Dictionary<int, long> + { + { 1, 462958406303813 }, + { 2, 462958422204485 } + }; + + var bllEquipment = new IStation.BLL.Equipment(); + var bllCurve = new IStation.BLL.PumpCurve(); + var combineList = new List<ModelCombineViewModel>(); + + var minFlow = 0; + var maxFlow = 100000; + var spaceFlow = 100; + foreach (var fileName in fileNameList) + { + Console.WriteLine(Path.GetFileNameWithoutExtension(fileName) + ":Start"); + var indexStr = Path.GetFileNameWithoutExtension(fileName).Substring(0, 1); + var index = int.Parse(indexStr); + var stationId = stationDict[index]; + var pumpList = bllEquipment.GetPumpModelListByBelongTypeAndBelongID(IStation.ObjectType.Station, stationId); + var flagList = pumpList.Select(x => x.SortCode).OrderBy(x => x).ToList(); + var flagPumpDict = pumpList.ToDictionary(x => x.SortCode, x => x.RatedParas); + + + var json = File.ReadAllText(fileName); + var templist = JsonHelper.Json2Object<List<ModelCombineViewModel>>(json); + var run_flags_flow_pressure_diff_dict = templist + .Select(x => (x.RunFlags, x.ScadaTotalFlow, x.ModelDeviation)) + .ToList(); + var ana_dev_list = StationCombineHelper.GetAnalysisDeviationDtoList(flagPumpDict, run_flags_flow_pressure_diff_dict, minFlow, maxFlow, spaceFlow); + ana_dev_list.ForEach(x => x.Station = index); + var root_folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "pumpcombineana"); + if (!Directory.Exists(root_folder)) + { + Directory.CreateDirectory(root_folder); + } + var fileNameDev = Path.Combine(root_folder, $"AnalysisDeviation{spaceFlow}.json"); + StationCombineHelper.SaveAnalysisDeviationDtoList(index, ana_dev_list, fileNameDev); + Console.WriteLine(Path.GetFileNameWithoutExtension(fileName) + ":Save"); + } + + } public static void Completion() { @@ -137,72 +192,9 @@ } } + - - //static void Main(string[] args) - //{ - // var splineList = new List<CurvePoint>(); - // var measuredList = new List<CurvePoint>(); - - // var path = AppDomain.CurrentDomain.BaseDirectory; - // var lienPaht = path + @"\pumpcsv\23_44_old_curve.csv"; - // var measuredPath = path + @"\pumpcsv\23_44.csv"; - - // using (var fs = new FileStream(lienPaht, FileMode.Open, FileAccess.Read)) - // using (var sr = new StreamReader(fs, Encoding.UTF8)) - // { - // var strLine = string.Empty; - // sr.ReadLine(); - // while (!string.IsNullOrEmpty(strLine = sr.ReadLine())) - // { - // var strList = strLine.Split(','); - // var x = double.Parse(strList[0]); - // var y = double.Parse(strList[1]); - // splineList.Add(new CurvePoint(x, y)); - // } - // } - - // using (var fs = new FileStream(measuredPath, FileMode.Open, FileAccess.Read)) - // using (var sr = new StreamReader(fs, Encoding.UTF8)) - // { - // var strLine = string.Empty; - // sr.ReadLine(); - // while (!string.IsNullOrEmpty(strLine = sr.ReadLine())) - // { - // var strList = strLine.Split(','); - // var x = double.Parse(strList[4]); - // var y = double.Parse(strList[5]); - // measuredList.Add(new CurvePoint(x, y)); - // } - // } - - - // // 鏍锋潯鏇茬嚎澶勭悊 - // double[] splineX = splineList.Select(x => x.X).ToArray(); - // double[] splineY = splineList.Select(x => x.Y).ToArray(); - - // // 瀹炴祴鏁版嵁澶勭悊 - // double[] measuredXAll = measuredList.Select(x => x.X).ToArray(); - // double[] measuredYAll = measuredList.Select(x => x.Y).ToArray(); - - - - // var helper = new PumpCurveDataFusionCorrectorHelper(); - // (double[] mergedX, double[] mergedY, double[] optimizedX, double[] optimizedY) = helper.Corrent(splineX, splineY, measuredXAll, measuredYAll); - - // var pt_list = new List<CurvePoint>(); - // for (int i = 0; i < optimizedX.Length; i++) - // { - // var x = optimizedX[i]; - // var y = optimizedY[i]; - // pt_list.Add(new CurvePoint(x, y)); - // } - // var fullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "pumpcsv"); - // CsvHelper.ExportToCsv(pt_list, Path.Combine(fullPath, $"23_44_update_curve.csv")); - - // Console.WriteLine("ok"); - // Console.ReadKey(); - //} + private static Dictionary<int, IStation.Model.CurveExpress> GetFlagCurveDict() { -- Gitblit v1.9.3