| | |
| | | /// </summary> |
| | | public SimulationCalcuResultLabelHelper |
| | | ( |
| | | SimulationVisualListHelper visualListHelper, |
| | | SimulationCalcuResultHelper calcuResultHelper, |
| | | ISimulationCalcuResultLabelView view |
| | | ) |
| | | { |
| | | _visualListHelper = visualListHelper; |
| | | _calcuResultHelper = calcuResultHelper; |
| | | _views = new List<ISimulationCalcuResultLabelView>() { view }; |
| | | } |
| | | |
| | | private SimulationVisualListHelper _visualListHelper = null;//可见列表辅助类 |
| | | private SimulationCalcuResultHelper _calcuResultHelper = null;//计算结果辅助类 |
| | | private List<ISimulationCalcuResultLabelView> _views = null;//视图列表 |
| | | |
| | |
| | | if (this.Visible) |
| | | { |
| | | var labels = GetLabels(); |
| | | _views.ForEach(x => x.SetLogicCalcuCustomLabels(labels)); |
| | | if (labels != null && labels.Count > 0) |
| | | { |
| | | _views.ForEach(async x => await x.SetLogicCalcuCustomLabels(labels)); |
| | | return; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _views.ForEach(x => x.ClearLogicCalcuCustomLabels()); |
| | | } |
| | | _views.ForEach(async x => await x.ClearLogicCalcuCustomLabels()); |
| | | } |
| | | |
| | | |
| | | //获取计算标签 |
| | | private List<LogicCalcuCustomLabel> GetLabels() |
| | | { |
| | | var hydroInfo = _visualListHelper.HydroInfo; |
| | | if (hydroInfo == null) |
| | | if (!_calcuResultHelper.Initialized) |
| | | { |
| | | return default; |
| | | } |
| | | var allCalcuResultVisualDict = _calcuResultHelper.GetVisualDict(); |
| | | |
| | | var allCalcuLabels = new List<LogicCalcuCustomLabel>(); |
| | | hydroInfo.Pumps?.ForEach(x => |
| | | |
| | | #region 水池 |
| | | |
| | | _calcuResultHelper.HydroInfo.GetAllTanks()?.ForEach(x => |
| | | { |
| | | var calcuTankResult = allCalcuResultVisualDict.GetValue(x.Code) as HydroCalcuTankResult; |
| | | var customLabel = new LogicCalcuCustomLabel(); |
| | | customLabel.Id = x.Code; |
| | | customLabel.Distance = 50000; |
| | | customLabel.Data = new List<LogicCalcuCustomLabelItem>() |
| | | { |
| | | new LogicCalcuCustomLabelItem(){ Name="水位",Value=Math.Round(calcuTankResult.CalcuL.Value,2).ToString(),Unit="m"}, |
| | | }; |
| | | allCalcuLabels.Add(customLabel); |
| | | }); |
| | | |
| | | #endregion |
| | | |
| | | #region 水泵 |
| | | |
| | | _calcuResultHelper.HydroInfo.Pumps?.ForEach(x => |
| | | { |
| | | var hz = Math.Round(x.RatedHz * x.SpeedRatio); |
| | | var calcuPumpResult = allCalcuResultVisualDict.GetValue(x.Code) as HydroCalcuLinkResult; |
| | | var calcuPumpResult = allCalcuResultVisualDict.GetValue(x.Code) as HydroCalcuPumpResult; |
| | | if (calcuPumpResult != null) |
| | | { |
| | | var calcuPumpStartResult = allCalcuResultVisualDict.GetValue(x.StartCode) as HydroCalcuNodeResult; |
| | | var calcuPumpEndResult = allCalcuResultVisualDict.GetValue(x.EndCode) as HydroCalcuNodeResult; |
| | | var pumpCustomLabel = new LogicCalcuCustomLabel(); |
| | | pumpCustomLabel.Id = x.Code; |
| | | pumpCustomLabel.Distance = 20000; |
| | | pumpCustomLabel.Distance = 50000; |
| | | pumpCustomLabel.Data = new List<LogicCalcuCustomLabelItem>() |
| | | { |
| | | new LogicCalcuCustomLabelItem(){ Name="状态",Value=HydroLinkStatusHelper.GetStatusName(x.LinkStatus),Unit=string.Empty}, |
| | | new LogicCalcuCustomLabelItem(){ Name="频率",Value=x.LinkStatus==Yw.Hydro.PumpStatus.Open?hz.ToString():"0",Unit="hz"}, |
| | | new LogicCalcuCustomLabelItem(){ Name="流量",Value=Math.Round(calcuPumpResult.CalcuQ.Value,1).ToString(),Unit="m³/h"}, |
| | | new LogicCalcuCustomLabelItem(){ Name="进口压力",Value=Math.Round(calcuPumpResult.CalcuPr1.Value,2).ToString(),Unit="m"}, |
| | | new LogicCalcuCustomLabelItem(){ Name="出口压力",Value=Math.Round(calcuPumpResult.CalcuPr2.Value,2).ToString(),Unit="m"}, |
| | | }; |
| | | if (x.Paras != null && x.Paras.Count > 0) |
| | | { |
| | | new LogicCalcuCustomLabelItem(){ Name="状态",Value=HydroLinkStatusHelper.GetStatusName(x.LinkStatus),Unit=string.Empty}, |
| | | new LogicCalcuCustomLabelItem(){ Name="频率",Value=hz.ToString(),Unit=string.Empty}, |
| | | new LogicCalcuCustomLabelItem(){ Name="流量",Value=Math.Round(calcuPumpResult.CalcuFlow.Value,1).ToString(),Unit="m³/h"}, |
| | | new LogicCalcuCustomLabelItem(){ Name="进口压力",Value=Math.Round(calcuPumpStartResult.CalcuHead.Value,4).ToString(),Unit="m"}, |
| | | new LogicCalcuCustomLabelItem(){ Name="出口压力",Value=Math.Round(calcuPumpEndResult.CalcuHead.Value,4).ToString(),Unit="m"}, |
| | | }; |
| | | foreach (var item in x.Paras) |
| | | { |
| | | pumpCustomLabel.Data.Add(new LogicCalcuCustomLabelItem() |
| | | { |
| | | Name = item.Key, |
| | | Value = item.Value, |
| | | Unit = string.Empty |
| | | }); |
| | | } |
| | | } |
| | | allCalcuLabels.Add(pumpCustomLabel); |
| | | } |
| | | }); |
| | | |
| | | hydroInfo.GetAllEmitters()?.ForEach(x => |
| | | #endregion |
| | | |
| | | #region 阀门 |
| | | |
| | | //_calcuResultHelper.HydroInfo.Valves?.ForEach(x => |
| | | //{ |
| | | // var calcuResult = allCalcuResultVisualDict.GetValue(x.Code) as HydroCalcuValveResult; |
| | | // var customLabel = new LogicCalcuCustomLabel(); |
| | | // customLabel.Id = x.Code; |
| | | // customLabel.Distance = 50000; |
| | | // customLabel.Data = new List<LogicCalcuCustomLabelItem>() |
| | | // { |
| | | // new LogicCalcuCustomLabelItem(){ Name="流量",Value=Math.Round(calcuResult.CalcuQ.Value,1).ToString(),Unit="m³/h"}, |
| | | // new LogicCalcuCustomLabelItem(){ Name="进口压力",Value=Math.Round(calcuResult.CalcuPr1.Value,2).ToString(),Unit="m"}, |
| | | // new LogicCalcuCustomLabelItem(){ Name="出口压力",Value=Math.Round(calcuResult.CalcuPr2.Value,2).ToString(),Unit="m"}, |
| | | // new LogicCalcuCustomLabelItem(){ Name="阀门开度",Value=Math.Round(x.OpeningDegree,0).ToString(),Unit="°"} |
| | | // }; |
| | | // allCalcuLabels.Add(customLabel); |
| | | //}); |
| | | |
| | | #endregion |
| | | |
| | | #region 扩散器 |
| | | |
| | | _calcuResultHelper.HydroInfo.GetAllEmitters()?.ForEach(x => |
| | | { |
| | | var calcuEmitter = allCalcuResultVisualDict.GetValue(x.Code) as HydroCalcuNodeResult; |
| | | var calcuEmitter = allCalcuResultVisualDict.GetValue(x.Code) as HydroCalcuEmitterResult; |
| | | var emitterCustomLabel = new LogicCalcuCustomLabel(); |
| | | emitterCustomLabel.Id = x.Code; |
| | | emitterCustomLabel.Distance = 30000; |
| | | emitterCustomLabel.Distance = 50000; |
| | | emitterCustomLabel.Data = new List<LogicCalcuCustomLabelItem>() |
| | | { |
| | | new LogicCalcuCustomLabelItem(){ Name="流量",Value=Math.Round(calcuEmitter.CalcuDemand.Value,1).ToString(),Unit="m³/h"}, |
| | | new LogicCalcuCustomLabelItem(){ Name="压力",Value=Math.Round(calcuEmitter.CalcuDemand.Value,4).ToString(),Unit="m"} |
| | | new LogicCalcuCustomLabelItem(){ Name="流量",Value=Math.Round(calcuEmitter.CalcuQ.Value,1).ToString(),Unit="m³/h"}, |
| | | new LogicCalcuCustomLabelItem(){ Name="压力",Value=Math.Round(calcuEmitter.CalcuPr.Value,2).ToString(),Unit="m"} |
| | | }; |
| | | if (x.Paras != null && x.Paras.Count > 0) |
| | | { |
| | | foreach (var item in x.Paras) |
| | | { |
| | | emitterCustomLabel.Data.Add(new LogicCalcuCustomLabelItem() |
| | | { |
| | | Name = item.Key, |
| | | Value = item.Value, |
| | | Unit = string.Empty |
| | | }); |
| | | } |
| | | } |
| | | allCalcuLabels.Add(emitterCustomLabel); |
| | | }); |
| | | |
| | | #endregion |
| | | |
| | | #region 水力阻件 |
| | | |
| | | _calcuResultHelper.HydroInfo.GetAllResistances()?.ForEach(x => |
| | | { |
| | | var calcuResistanceResult = allCalcuResultVisualDict.GetValue(x.Code) as HydroCalcuResistanceResult; |
| | | var resistanceCustomLabel = new LogicCalcuCustomLabel(); |
| | | resistanceCustomLabel.Id = x.Code; |
| | | resistanceCustomLabel.Distance = 50000; |
| | | resistanceCustomLabel.Data = new List<LogicCalcuCustomLabelItem>() |
| | | { |
| | | new LogicCalcuCustomLabelItem(){ Name="流量",Value=Math.Round(calcuResistanceResult.CalcuQ.Value,1).ToString(),Unit="m³/h"}, |
| | | new LogicCalcuCustomLabelItem(){ Name="进口压力",Value=Math.Round(calcuResistanceResult.CalcuPr1.Value,2).ToString(),Unit="m"}, |
| | | new LogicCalcuCustomLabelItem(){ Name="出口压力",Value=Math.Round(calcuResistanceResult.CalcuPr2.Value,2).ToString(),Unit="m"} |
| | | }; |
| | | if (x.Paras != null && x.Paras.Count > 0) |
| | | { |
| | | foreach (var item in x.Paras) |
| | | { |
| | | resistanceCustomLabel.Data.Add(new LogicCalcuCustomLabelItem() |
| | | { |
| | | Name = item.Key, |
| | | Value = item.Value, |
| | | Unit = string.Empty |
| | | }); |
| | | } |
| | | } |
| | | allCalcuLabels.Add(resistanceCustomLabel); |
| | | }); |
| | | |
| | | #endregion |
| | | |
| | | |
| | | return allCalcuLabels; |
| | | |
| | | |
| | | } |
| | | |
| | | |