namespace HStation.WinFrmUI
{
///
///
///
public class SimulationPrintLossStatisticsCategoryViewModel
{
///
///
///
public SimulationPrintLossStatisticsCategoryViewModel() { }
///
///
///
public SimulationPrintLossStatisticsCategoryViewModel
(
Yw.Model.HydroModelInfo hydroInfo,
HydroCalcuResult calcuResult,
List allItemList
)
{
if (hydroInfo == null)
{
return;
}
if (calcuResult == null || !calcuResult.Succeed)
{
return;
}
if (allItemList == null || allItemList.Count < 1)
{
return;
}
this.Items = new List();
var groupList = allItemList.GroupBy(x => x.EnergyType).ToList();
foreach (var group in groupList)
{
var item = new SimulationPrintLossStatisticsCategoryItemViewModel();
switch (group.Key)
{
case Yw.EPAnet.eEnergyType.Input:
{
item.EnergyType = Yw.WinFrmUI.eEnergyType.Input;
item.Name = "输入能量";
}
break;
case Yw.EPAnet.eEnergyType.Output:
{
item.EnergyType = Yw.WinFrmUI.eEnergyType.Output;
item.Name = "输出能量";
}
break;
case Yw.EPAnet.eEnergyType.Promote:
{
item.EnergyType = Yw.WinFrmUI.eEnergyType.Promote;
item.Name = "提升能量";
}
break;
case Yw.EPAnet.eEnergyType.MinorLoss:
{
item.EnergyType = Yw.WinFrmUI.eEnergyType.MinorLoss;
item.Name = "局部损失";
}
break;
case Yw.EPAnet.eEnergyType.FrictionalLoss:
{
item.EnergyType = Yw.WinFrmUI.eEnergyType.FrictionalLoss;
item.Name = "沿程损失";
}
break;
default: break;
}
item.Value = group.Sum(x => x.EnergyValue);
this.Items.Add(item);
}
double pumpLoss = 0;
if (hydroInfo.Pumps != null && hydroInfo.Pumps.Count > 0)
{
var allCalcuVisualDict = calcuResult.GetVisualDict();
foreach (var pump in hydroInfo.Pumps)
{
var calcuPumpResult = allCalcuVisualDict?.GetValue(pump.Code) as HydroCalcuPumpResult;
if (calcuPumpResult != null)
{
if (calcuPumpResult.CalcuP.HasValue && calcuPumpResult.CalcuE.HasValue)
{
pumpLoss += calcuPumpResult.CalcuP.Value * 1000 * (1 - calcuPumpResult.CalcuE.Value / 100);
}
}
}
}
var promoteItem = this.Items.Find(x => x.EnergyType == Yw.WinFrmUI.eEnergyType.Promote);
if (promoteItem != null)
{
promoteItem.Value += pumpLoss;
}
var minorLossItem = this.Items.Find(x => x.EnergyType == Yw.WinFrmUI.eEnergyType.MinorLoss);
if (minorLossItem != null)
{
minorLossItem.Value += pumpLoss;
}
}
///
/// 子级集合
///
public List Items { get; set; }
}
}