From 0f99d4d12f2eae29bbe343f4b3131f2faeccda5d Mon Sep 17 00:00:00 2001 From: Shuxia Ning <NingShuxia0927@outlook.com> Date: 星期二, 14 一月 2025 17:31:20 +0800 Subject: [PATCH] 泵曲线修改 --- WinFrmUI/Yw.WinFrmUI.Hydro.Core/00-core/05-extensions/HydroModelInfoExtensions.cs | 562 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 524 insertions(+), 38 deletions(-) diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/00-core/05-extensions/HydroModelInfoExtensions.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/00-core/05-extensions/HydroModelInfoExtensions.cs index 9817041..8d5ffd0 100644 --- a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/00-core/05-extensions/HydroModelInfoExtensions.cs +++ b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/00-core/05-extensions/HydroModelInfoExtensions.cs @@ -1,46 +1,113 @@ -锘縩amespace Yw.WinFrmUI +锘縰sing Yw.Hydro; +using Yw.Model; + +namespace Yw.WinFrmUI { /// <summary> - /// + /// 姘村姏淇℃伅鎷撳睍 /// </summary> public static class HydroModelInfoExtensions { + + #region 淇鍙傛暟 + + private const double _pipe_roughness_default = 110;//绠¢亾榛樿绮楃硻绯绘暟 + private const double _translation_roughness_default = 120;//杩囨浮浠堕粯璁ょ矖绯欑郴鏁� + private const double _translation_minorloss_default = 0.3;//杩囨浮浠堕粯璁ゅ眬闃荤郴鏁� + private const double _valve_minorloss_default = 0.3d; //闃�闂ㄩ粯璁ゅ眬闃荤郴鏁� + private const double _resistance_minorloss_default = 9d;//闃讳欢榛樿灞�闃荤郴鏁� + private const double _blunthead_minorloss_default = 0.1d;//闂峰ご灞�閮ㄩ樆鍔涚郴鏁� + private const double _cooling_coefficient_default = 100000d;//鍐峰嵈濉旀祦閲忕郴鏁� + /// <summary> - /// 鏇存柊宸ュ喌淇℃伅 + /// 淇鍙傛暟 /// </summary> - public static void UpdateWorkingInfo(this Yw.Model.HydroModelInfo hydroInfo, HydroWorkingInfoViewModel workingInfo) + public static void RepairParas + ( + this Yw.Model.HydroModelInfo hydroInfo, + HydroPropStatusHelper propStatusHelper, + out string msg + ) { + msg = string.Empty; if (hydroInfo == null) { return; } - if (workingInfo == null) + + var allNodes = hydroInfo.GetAllNodes(); + var allLinks = hydroInfo.GetAllLinks(); + + //绠¢亾 + if (hydroInfo.Pipes != null && hydroInfo.Pipes.Count > 0) { - return; - } - //姘寸 - if (hydroInfo.Waterboxs != null && hydroInfo.Waterboxs.Count > 0) - { - foreach (var parter in hydroInfo.Waterboxs) + foreach (var pipe in hydroInfo.Pipes) { - var parterWorkingInfo = workingInfo.Waterboxs?.Find(x => x.Code == parter.Code); - if (parterWorkingInfo != null) + if (pipe.Roughness <= 0) { - parter.InitLevel = parterWorkingInfo.InitLevel; + pipe.Roughness = _pipe_roughness_default; + propStatusHelper.UpdatePropStatus(pipe, nameof(pipe.Roughness), ePropStatus.Abnormal, "銆愮矖绯欑郴鏁般�戞暟鎹紓甯�"); } } } - //姘存车 - if (hydroInfo.Pumps != null && hydroInfo.Pumps.Count > 0) + //杩囨浮浠� + if (hydroInfo.Translations != null && hydroInfo.Translations.Count > 0) { - foreach (var parter in hydroInfo.Pumps) + foreach (var translation in hydroInfo.Translations) { - var parterWorkingInfo = workingInfo.Pumps?.Find(x => x.Code == parter.Code); - if (parterWorkingInfo != null) + double? tempDiameter = null; + var startNode = allNodes.Find(x => x.Code == translation.StartCode); + if (startNode != null) { - parter.LinkStatus = parterWorkingInfo.LinkStatus; - parter.SpeedRatio = Math.Round(parterWorkingInfo.CurrentHz / parter.RatedHz, 1); + var startLink = allLinks + .Find(x => (x.StartCode == startNode.Code || x.EndCode == startNode.Code) && x.Code != translation.Code); + if (startLink != null) + { + var startPipe = startLink as Yw.Model.HydroPipeInfo; + if (startPipe != null) + { + tempDiameter = startPipe.Diameter; + if (translation.StartDiameter != startPipe.Diameter) + { + translation.StartDiameter = startPipe.Diameter; + } + } + } + } + + var endNode = allNodes.Find(x => x.Code == translation.EndCode); + if (endNode != null) + { + var endLink = allLinks + .Find(x => (x.StartCode == endNode.Code || x.EndCode == endNode.Code) && x.Code != translation.Code); + if (endLink != null) + { + var endPipe = endLink as Yw.Model.HydroPipeInfo; + if (endPipe != null) + { + if (translation.EndDiameter != endPipe.Diameter) + { + tempDiameter = endPipe.Diameter; + translation.EndDiameter = endPipe.Diameter; + } + } + } + } + + if (translation.StartDiameter <= 0) + { + if (tempDiameter.HasValue) + { + translation.StartDiameter = tempDiameter.Value; + } + } + if (translation.EndDiameter <= 0) + { + if (tempDiameter.HasValue) + { + translation.EndDiameter = tempDiameter.Value; + } } } } @@ -48,46 +115,465 @@ //闃�闂� if (hydroInfo.Valves != null && hydroInfo.Valves.Count > 0) { - foreach (var parter in hydroInfo.Valves) + foreach (var valve in hydroInfo.Valves) { - var parterWorkingInfo = workingInfo.Valves?.Find(x => x.Code == parter.Code); - if (parterWorkingInfo != null) + if (valve.MinorLoss <= 0) { - parter.LinkStatus = parterWorkingInfo.LinkStatus; - parter.OpeningDegree = parterWorkingInfo.OpeningDegree; + valve.MinorLoss = _valve_minorloss_default; + } + if (valve.Diameter <= 0) + { + var startNode = allNodes.Find(x => x.Code == valve.StartCode); + if (startNode != null) + { + var startPipe = allLinks + .Find(x => (x.StartCode == startNode.Code || x.EndCode == startNode.Code) && x.Code != valve.Code) + as Yw.Model.HydroPipeInfo; + if (startPipe != null) + { + valve.Diameter = startPipe.Diameter; + } + else + { + var endNode = allNodes.Find(x => x.Code == valve.EndCode); + if (endNode != null) + { + var endPipe = allLinks + .Find(x => (x.StartCode == endNode.Code || x.EndCode == endNode.Code) && x.Code != valve.Code) + as Yw.Model.HydroPipeInfo; + if (endPipe != null) + { + valve.Diameter = endPipe.Diameter; + } + } + } + } } } } - //娴侀噺璁� - if (hydroInfo.Flowmeters != null && hydroInfo.Flowmeters.Count > 0) + //闃讳欢 + var allResistanceList = hydroInfo.GetAllResistances(); + if (allResistanceList != null && allResistanceList.Count > 0) { - foreach (var parter in hydroInfo.Flowmeters) + foreach (var resistance in allResistanceList) { - var parterWorkingInfo = workingInfo.Flowmeters?.Find(x => x.Code == parter.Code); - if (parterWorkingInfo != null) + if (resistance.MinorLoss <= 0) { - parter.CurrentFlow = parterWorkingInfo.CurrentFlow; + resistance.MinorLoss = _resistance_minorloss_default; + } + var startNode = allNodes.Find(x => x.Code == resistance.StartCode); + if (startNode != null) + { + var startPipe = allLinks + .Find(x => (x.StartCode == startNode.Code || x.EndCode == startNode.Code) && x.Code != resistance.Code) + as Yw.Model.HydroPipeInfo; + if (startPipe != null) + { + resistance.Diameter = startPipe.Diameter; + } + else + { + var endNode = allNodes.Find(x => x.Code == resistance.EndCode); + if (endNode != null) + { + var endPipe = allLinks + .Find(x => (x.StartCode == endNode.Code || x.EndCode == endNode.Code) && x.Code != resistance.Code) + as Yw.Model.HydroPipeInfo; + if (endPipe != null) + { + resistance.Diameter = endPipe.Diameter; + } + } + } } } } - //鍘嬪姏琛� - if (hydroInfo.Pressmeters != null && hydroInfo.Pressmeters.Count > 0) + //闂峰ご + if (hydroInfo.Bluntheads != null && hydroInfo.Bluntheads.Count > 0) { - foreach (var parter in hydroInfo.Pressmeters) + foreach (var visual in hydroInfo.Bluntheads) { - var parterWorkingInfo = workingInfo.Pressmeters?.Find(x => x.Code == parter.Code); - if (parterWorkingInfo != null) + if (visual.MinorLoss <= 0) { - parter.CurrentPress = parterWorkingInfo.CurrentPress; + visual.MinorLoss = _blunthead_minorloss_default; + } + if (visual.Caliber < 1) + { + var link = allLinks.Find(x => x.StartCode == visual.Code || x.EndCode == visual.Code); + if (link != null) + { + if (link is HydroResistanceInfo resistance) + { + visual.Caliber = resistance.Diameter; + } + else if (link is HydroValveInfo valve) + { + visual.Caliber = valve.Diameter; + } + else if (link is HydroTranslationInfo translation) + { + + } + else if (link is HydroPipeInfo pipe) + { + visual.Caliber = pipe.Diameter; + } + } + } + + } + } + + #region 寮ご + + if (hydroInfo.Elbows != null && hydroInfo.Elbows.Count > 0) + { + foreach (var visual in hydroInfo.Elbows) + { + if (visual.MinorLoss <= 0) + { + visual.MinorLoss = _blunthead_minorloss_default; + } + if (visual.Caliber < 1) + { + var link = allLinks.Find(x => x.StartCode == visual.Code || x.EndCode == visual.Code); + if (link != null) + { + if (link is HydroResistanceInfo resistance) + { + visual.Caliber = resistance.Diameter; + } + else if (link is HydroValveInfo valve) + { + visual.Caliber = valve.Diameter; + } + else if (link is HydroTranslationInfo translation) + { + + } + else if (link is HydroPipeInfo pipe) + { + visual.Caliber = pipe.Diameter; + } + } + } + + } + } + + #endregion + + #region 鍐峰嵈濉� + + if (hydroInfo.Coolings != null && hydroInfo.Coolings.Count > 0) + { + foreach (var cooling in hydroInfo.Coolings) + { + if (cooling.Coefficient < 1) + { + cooling.Coefficient = _cooling_coefficient_default; + propStatusHelper.UpdatePropStatus(cooling.Code, nameof(cooling.Coefficient), ePropStatus.Abnormal, $"銆愭祦閲忕郴鏁般�戞暟鎹紓甯革紝浣跨敤榛樿鍊糩{_cooling_coefficient_default}]淇"); + } + if (cooling.Caliber < 1) + { + var link = allLinks.Find(x => x.StartCode == cooling.Code || x.EndCode == cooling.Code); + if (link != null) + { + if (link is HydroPipeInfo pipe) + { + if (pipe.Diameter > 0) + { + cooling.Caliber = pipe.Diameter; + propStatusHelper.UpdatePropStatus(cooling.Code, nameof(cooling.Caliber), ePropStatus.Abnormal, $"銆愬彛寰勩�戞暟鎹紓甯革紝浣跨敤鐩搁偦绠¢亾淇"); + } + } + } } } } + + #endregion } + #endregion + + #region 瑁呯疆璁$畻 + + /// <summary> + /// 鑾峰彇寮�濮嬪帇鍔�(m) + /// </summary> + public static double GetStartHead(this Yw.Model.HydroModelInfo hydroInfo) + { + if (hydroInfo == null) + { + return default; + } + double startHeadValue = 0; + var allSourceList = hydroInfo.GetAllSources(); + if (allSourceList != null && allSourceList.Count > 0) + { + var startSource = allSourceList.Matching(new List<string>() + { + Yw.Hydro.Flags.姘存簮, + Yw.Hydro.Flags.濮嬬, + Yw.Hydro.Flags.榛樿 + }); + if (startSource == null) + { + startSource = allSourceList.Matching(new List<string>() + { + Yw.Hydro.Flags.姘存簮, + Yw.Hydro.Flags.濮嬬 + }); + } + if (startSource != null) + { + if (startSource is HydroTankInfo tank) + { + startHeadValue = tank.PoolElev + tank.InitLevel; + } + } + } + return startHeadValue; + } + + /// <summary> + /// 鑾峰彇缁撴潫鍘嬪姏(m) + /// </summary> + public static double GetEndHead(this Yw.Model.HydroModelInfo hydroInfo) + { + if (hydroInfo == null) + { + return default; + } + double endHeadValue = 0; + var allNodeList = hydroInfo.GetAllNodes(); + if (allNodeList != null && allNodeList.Count > 0) + { + var endSource = allNodeList.Matching(new List<string>() + { + Yw.Hydro.Flags.姘存簮, + Yw.Hydro.Flags.鏈, + Yw.Hydro.Flags.榛樿 + }); + if (endSource == null) + { + endSource = allNodeList.Matching(new List<string>() + { + Yw.Hydro.Flags.姘存簮, + Yw.Hydro.Flags.鏈 + }); + } + if (endSource != null) + { + if (endSource is HydroTankInfo tank) + { + endHeadValue = tank.PoolElev + tank.InitLevel; + } + else if (endSource is HydroEmitterInfo emitter) + { + endHeadValue = emitter.Elev; + } + } + } + return endHeadValue; + } + + /// <summary> + /// 鑾峰彇鎵▼ + /// </summary> + public static double GetHead(this Yw.Model.HydroModelInfo hydroInfo) + { + if (hydroInfo == null) + { + return default; + } + var startHeadValue = GetStartHead(hydroInfo); + var endHeadValue = GetEndHead(hydroInfo); + return endHeadValue - startHeadValue; + } + + /// <summary> + /// 鑾峰彇鎬荤娴侀噺 + /// </summary> + public static double? GetPipeQ(this Yw.Model.HydroModelInfo hydroInfo, HydroCalcuResult calcuResult) + { + return GetPipeQ(hydroInfo, calcuResult?.GetVisualDict()); + } + + /// <summary> + /// 鑾峰彇鎬荤娴侀噺 + /// </summary> + public static double? GetPipeQ(this Yw.Model.HydroModelInfo hydroInfo, Dictionary<string, HydroCalcuVisualResult> allCalcuVisualDict) + { + if (hydroInfo == null) + { + return default; + } + if (allCalcuVisualDict == null || allCalcuVisualDict.Count < 1) + { + return default; + } + var allLinkList = hydroInfo.GetAllLinks(); + if (allLinkList == null || allLinkList.Count < 1) + { + return default; + } + var link = allLinkList.Matching(new List<string>() + { + Yw.Hydro.Flags.鎬荤, + Yw.Hydro.Flags.鍑哄彛, + Yw.Hydro.Flags.榛樿 + }); + if (link == null) + { + link = allLinkList.Matching(new List<string>() + { + Yw.Hydro.Flags.鎬荤, + Yw.Hydro.Flags.鍑哄彛 + }); + } + if (link == null) + { + return default; + } + + var calcuVisualResult = allCalcuVisualDict.GetValue(link.Code); + if (calcuVisualResult == null) + { + return default; + } + var calcuValue = calcuVisualResult.GetCalcuValue(Yw.Hydro.VisualCalcuProp.CalcuFlow); + if (calcuValue == null) + { + return default; + } + return Math.Round(Math.Abs(calcuValue.Value), 1); + } + + /// <summary> + /// 鑾峰彇鎬荤缁撴潫鍘嬪姏锛堢粷瀵瑰帇鍔涳級 + /// </summary> + public static double? GetPipeEndHead(this Yw.Model.HydroModelInfo hydroInfo, Dictionary<string, HydroCalcuVisualResult> allCalcuVisualDict) + { + if (hydroInfo == null) + { + return default; + } + if (allCalcuVisualDict == null || allCalcuVisualDict.Count < 1) + { + return default; + } + var allNodeList = hydroInfo.GetAllNodes(); + if (allNodeList == null || allNodeList.Count < 1) + { + return default; + } + var node = allNodeList.Matching(new List<string>() + { + Yw.Hydro.Flags.鎬荤, + Yw.Hydro.Flags.鍑哄彛, + Yw.Hydro.Flags.榛樿 + }); + if (node == null) + { + node = allNodeList.Matching(new List<string>() + { + Yw.Hydro.Flags.鎬荤, + Yw.Hydro.Flags.鍑哄彛 + }); + } + if (node == null) + { + return default; + } + + var calcuVisualResult = allCalcuVisualDict.GetValue(node.Code); + if (calcuVisualResult == null) + { + return default; + } + var calcuValue = calcuVisualResult.GetCalcuValue(Yw.Hydro.VisualCalcuProp.CalcuHead); + if (calcuValue == null) + { + return default; + } + return Math.Round(calcuValue.Value, 2); + } + + /// <summary> + /// 鑾峰彇鎬荤缁撴潫鍘嬪姏锛堢粷瀵瑰帇鍔涳級 + /// </summary> + public static double? GetPipeEndHead(this Yw.Model.HydroModelInfo hydroInfo, HydroCalcuResult calcuResult) + { + return GetPipeEndHead(hydroInfo, calcuResult?.GetVisualDict()); + } + + /// <summary> + /// 鑾峰彇鎬荤鍘嬪姏锛堢粷瀵瑰帇鍔涳級 + /// </summary> + public static double? GetPipeHead(this Yw.Model.HydroModelInfo hydroInfo, HydroCalcuResult calcuResult) + { + return GetPipeHead(hydroInfo, calcuResult?.GetVisualDict()); + } + + /// <summary> + /// 鑾峰彇鎬荤鍘嬪姏锛堢粷瀵瑰帇鍔涳級 + /// </summary> + public static double? GetPipeHead(this Yw.Model.HydroModelInfo hydroInfo, Dictionary<string, HydroCalcuVisualResult> allCalcuVisualDict) + { + if (hydroInfo == null) + { + return default; + } + if (allCalcuVisualDict == null || allCalcuVisualDict.Count < 1) + { + return default; + } + var allNodeList = hydroInfo.GetAllNodes(); + if (allNodeList == null || allNodeList.Count < 1) + { + return default; + } + var node = allNodeList.Matching(new List<string>() + { + Yw.Hydro.Flags.鎬荤, + Yw.Hydro.Flags.鍑哄彛, + Yw.Hydro.Flags.榛樿 + }); + if (node == null) + { + node = allNodeList.Matching(new List<string>() + { + Yw.Hydro.Flags.鎬荤, + Yw.Hydro.Flags.鍑哄彛 + }); + } + if (node == null) + { + return default; + } + + var calcuVisualResult = allCalcuVisualDict.GetValue(node.Code); + if (calcuVisualResult == null) + { + return default; + } + var calcuValue = calcuVisualResult.GetCalcuValue(Yw.Hydro.VisualCalcuProp.CalcuHead); + if (calcuValue == null) + { + return default; + } + var endHeadValue = calcuValue.Value; + var startHeadValue = GetStartHead(hydroInfo); + return Math.Round(endHeadValue - startHeadValue, 2); + } + + #endregion } } -- Gitblit v1.9.3