using Yw.WinFrmUI.Bimface;
|
|
namespace HStation.WinFrmUI
|
{
|
/// <summary>
|
/// 计算结果标签辅助类
|
/// </summary>
|
public class SimulationCalcuResultLabelHelper
|
{
|
/// <summary>
|
///
|
/// </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;//视图列表
|
|
/// <summary>
|
/// 可见性
|
/// </summary>
|
public bool Visible
|
{
|
get { return _visible; }
|
set { _visible = value; }
|
}
|
private bool _visible = false;
|
|
/// <summary>
|
/// 设置
|
/// </summary>
|
public void Set()
|
{
|
if (this.Visible)
|
{
|
var labels = GetLabels();
|
_views.ForEach(x => x.SetLogicCalcuCustomLabels(labels));
|
}
|
else
|
{
|
_views.ForEach(x => x.ClearLogicCalcuCustomLabels());
|
}
|
}
|
|
|
//获取计算标签
|
private List<LogicCalcuCustomLabel> GetLabels()
|
{
|
var hydroInfo = _visualListHelper.HydroInfo;
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
var allCalcuResultVisualDict = _calcuResultHelper.GetVisualDict();
|
var allCalcuLabels = new List<LogicCalcuCustomLabel>();
|
hydroInfo.Pumps?.ForEach(x =>
|
{
|
var hz = Math.Round(x.RatedHz * x.SpeedRatio);
|
var calcuPumpResult = allCalcuResultVisualDict.GetValue(x.Code) as HydroCalcuLinkResult;
|
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.Data = new List<LogicCalcuCustomLabelItem>()
|
{
|
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"},
|
};
|
allCalcuLabels.Add(pumpCustomLabel);
|
}
|
});
|
|
hydroInfo.GetAllEmitters()?.ForEach(x =>
|
{
|
var calcuEmitter = allCalcuResultVisualDict.GetValue(x.Code) as HydroCalcuNodeResult;
|
var emitterCustomLabel = new LogicCalcuCustomLabel();
|
emitterCustomLabel.Id = x.Code;
|
emitterCustomLabel.Distance = 30000;
|
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"}
|
};
|
allCalcuLabels.Add(emitterCustomLabel);
|
});
|
return allCalcuLabels;
|
}
|
|
|
|
}
|
}
|