ÎļþÃû´Ó WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/13-print/loss-curve/helper/SimulationPrintLossCurveHelper.cs ÐÞ¸Ä |
| | |
| | | using Mapster; |
| | | using Yw.EPAnet; |
| | | using Yw.EPAnet; |
| | | using Yw.Hydro; |
| | | using Yw.Model; |
| | | using Yw.Vmo; |
| | | |
| | | |
| | | namespace HStation.WinFrmUI |
| | | namespace Yw.WinFrmUI |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public class SimulationPrintLossCurveHelper |
| | | public class HydroLossCurveHelper |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// å建 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static SimulationPrintLossCurveViewModel Create |
| | | public static HydroLossCurveViewModel Create |
| | | ( |
| | | Yw.Model.HydroModelInfo hydroInfo, |
| | | HydroWorkingVmo working, |
| | | HydroVisualInfo visual, |
| | | HydroNodeInfo node, |
| | | HydroCalcuResult calcuResult = null, |
| | | bool isHead = false, |
| | | List<HydroEvaluationVmo> allEvaluationList = null |
| | | ) |
| | | { |
| | | var vm = new SimulationPrintLossCurveViewModel(); |
| | | |
| | | //éªè¯ |
| | | if (hydroInfo == null) |
| | | { |
| | | return vm; |
| | | return default; |
| | | } |
| | | if (working == null) |
| | | { |
| | | return vm; |
| | | return default; |
| | | } |
| | | if (visual == null) |
| | | if (node == null) |
| | | { |
| | | return vm; |
| | | return default; |
| | | } |
| | | |
| | | //èµå¼æ¨¡åä¿¡æ¯ï¼é¿å
å¹²æ° |
| | | //var newHydroInfo = hydroInfo.Adapt<Yw.Model.HydroModelInfo>(); |
| | | //newHydroInfo.UpdateWorkingInfo(working.WorkingInfo); |
| | | var vm = new HydroLossCurveViewModel(); |
| | | |
| | | //计ç®ç»æ |
| | | if (calcuResult == null) |
| | | { |
| | | hydroInfo.UpdateWorkingInfo(working.WorkingInfo); |
| | | calcuResult = hydroInfo.Calcu(Yw.EPAnet.CalcuMode.MinorLoss, isHead, allEvaluationList); |
| | | if (!calcuResult.Succeed) |
| | | { |
| | |
| | | } |
| | | var allCalcuVisualDict = calcuResult.GetVisualDict(); |
| | | |
| | | |
| | | |
| | | //管线 |
| | | var network = hydroInfo.ToNetwork(); |
| | | if (network == null) |
| | | { |
| | | return vm; |
| | | } |
| | | var node = network.GetAllNodes()?.Find(x => x.Id == visual.Code); |
| | | if (node == null) |
| | | var epaNode = network.GetAllNodes()?.Find(x => x.Id == node.Code); |
| | | if (epaNode == null) |
| | | { |
| | | return vm; |
| | | } |
| | | var allStartPathList = network.AnalyzeUpstreamPath(node, calcuResult.EPAnetCalcuResult); |
| | | var allStartPathList = network.AnalyzeUpstreamPath(epaNode, calcuResult.EPAnetCalcuResult); |
| | | if (allStartPathList == null) |
| | | { |
| | | allStartPathList = new List<Link>(); |
| | | } |
| | | |
| | | var allEndPathList = network.AnalyzeDownstreamPath(node, calcuResult.EPAnetCalcuResult); |
| | | var allEndPathList = network.AnalyzeDownstreamPath(epaNode, calcuResult.EPAnetCalcuResult); |
| | | if (allEndPathList == null) |
| | | { |
| | | allEndPathList = new List<Link>(); |
| | |
| | | return vm; |
| | | } |
| | | var allVisualDict = hydroInfo.GetVisualDict(); |
| | | vm.Items = new List<SimulationPrintLossCurveItemViewModel>(); |
| | | vm.Items = new List<HydroLossCurveItemViewModel>(); |
| | | foreach (var epaLoss in allEpaLossList) |
| | | { |
| | | var visualNode = allVisualDict.GetValue(epaLoss.Id); |
| | | if (visualNode != null) |
| | | { |
| | | var item = new SimulationPrintLossCurveItemViewModel(epaLoss, visualNode); |
| | | var item = new HydroLossCurveItemViewModel(epaLoss, visualNode); |
| | | vm.Items.Add(item); |
| | | } |
| | | } |
| | | |
| | | vm.Elev = new SimulationPrintLossCurveElevViewModel(vm.Items); |
| | | vm.Start = new SimulationPrintLossCurveStartViewModel(vm.Items); |
| | | vm.End = new SimulationPrintLossCurveEndViewModel(vm.Items); |
| | | vm.Total = new SimulationPrintLossCurveTotalViewModel(vm.Items); |
| | | vm.Elev = new HydroLossCurveElevViewModel(vm.Items); |
| | | vm.Start = new HydroLossCurveStartViewModel(vm.Items); |
| | | vm.End = new HydroLossCurveEndViewModel(vm.Items); |
| | | vm.Total = new HydroLossCurveTotalViewModel(vm.Items); |
| | | vm.Lower = new HydroLossCurveLowerViewModel(vm.Items); |
| | | |
| | | return vm; |
| | | |
| | | } |
| | | |
| | | |