namespace Yw.WinFrmUI
|
{
|
/// <summary>
|
/// 阀门视图
|
/// </summary>
|
public class HydroValveViewModel : HydroLinkViewModel, IHydroCalcuValveResult
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public HydroValveViewModel() { }
|
|
/// <summary>
|
///
|
/// </summary>
|
public HydroValveViewModel(Yw.Model.HydroValveInfo rhs, Yw.Model.HydroModelInfo hydroInfo) : base(rhs, hydroInfo)
|
{
|
this.LinkStatus = HydroValveStatusHelper.GetStatusName(rhs.LinkStatus);
|
this.Material = rhs.Material;
|
this.Diameter = rhs.Diameter;
|
this.MinorLoss = rhs.MinorLoss;
|
this.ValveType = HydroValveTypeHelper.GetTypeName(rhs.ValveType);
|
this.OpeningDegree = rhs.OpeningDegree;
|
this.ValveSetting = rhs.ValveSetting;
|
UpdateValveSetting();
|
}
|
|
|
/// <summary>
|
/// 阀门状态
|
/// </summary>
|
[Category("数据")]
|
[DisplayName("阀门状态")]
|
[Description("[默认]使用阀门设置;[开启]使用局阻系数")]
|
[PropertyOrder(1003)]
|
[Browsable(true)]
|
[TypeConverter(typeof(HydroValveStatusConverter))]
|
public override string LinkStatus { get; set; }
|
|
/// <summary>
|
/// 材料
|
/// </summary>
|
[Category("数据")]
|
[DisplayName("材料")]
|
[PropertyOrder(2001)]
|
[Browsable(true)]
|
public string Material { get; set; }
|
|
/// <summary>
|
/// 直径
|
/// </summary>
|
[Category("数据")]
|
[DisplayName("直径")]
|
[PropertyOrder(2002)]
|
[Browsable(true)]
|
[DisplayUnit("mm")]
|
public double Diameter { get; set; }
|
|
/// <summary>
|
/// 局阻系数
|
/// </summary>
|
[Category("数据")]
|
[DisplayName("局阻系数")]
|
[PropertyOrder(2003)]
|
[Browsable(true)]
|
public double MinorLoss { get; set; }
|
|
/// <summary>
|
/// 阀门类型
|
/// </summary>
|
[Category("数据")]
|
[DisplayName("阀门类型")]
|
[PropertyOrder(2004)]
|
[Browsable(true)]
|
[TypeConverter(typeof(HydroValveTypeConverter))]
|
public string ValveType { get; set; }
|
|
/// <summary>
|
/// 阀门开度
|
/// </summary>
|
[Category("数据")]
|
[DisplayName("阀门开度")]
|
[Range(10, 100, ErrorMessage = "阀门开度区间在【10,100】")]
|
[PropertyOrder(2005)]
|
[Browsable(true)]
|
public double OpeningDegree { get; set; }
|
|
/// <summary>
|
/// 阀门设置
|
/// </summary>
|
[Category("数据")]
|
[DisplayName("阀门设置")]
|
[PropertyOrder(2006)]
|
[Browsable(true)]
|
public string ValveSetting { get; set; }
|
|
/// <summary>
|
/// 压强设置
|
/// </summary>
|
[Category("数据")]
|
[DisplayName("压强设置")]
|
[Display(Name = "压强设置(m)")]
|
[DisplayUnit("m")]
|
[HydroRealPro("ValveSetting")]
|
[PropertyOrder(2007)]
|
[Browsable(true)]
|
public double? ValvePress { get; set; }
|
|
/// <summary>
|
/// 压强设置
|
/// </summary>
|
[Category("数据")]
|
[DisplayName("流量设置")]
|
[Display(Name = "流量设置(m³/h)")]
|
[DisplayUnit("m³/h")]
|
[HydroRealPro("ValveSetting")]
|
[PropertyOrder(2008)]
|
[Browsable(true)]
|
public double? ValveFlow { get; set; }
|
|
/// <summary>
|
/// 开度损失曲线
|
/// </summary>
|
[Category("数据")]
|
[DisplayName("开度损失曲线")]
|
[HydroRealPro("ValveSetting")]
|
[HydroCurvePro(HydroCurve.Valve, HydroCurveType.CurveOL)]
|
[PropertyOrder(2009)]
|
[Browsable(true)]
|
public string ValveOL { get; set; }
|
|
/// <summary>
|
/// 水头损失曲线
|
/// </summary>
|
[Category("数据")]
|
[DisplayName("水头损失曲线")]
|
[HydroRealPro("ValveSetting")]
|
[HydroCurvePro(HydroCurve.Valve, HydroCurveType.CurveQL)]
|
[PropertyOrder(2010)]
|
[Browsable(true)]
|
public string ValveQL { get; set; }
|
|
/// <summary>
|
/// 流量
|
/// </summary>
|
[Category("计算结果")]
|
[DisplayName("流量")]
|
[DisplayUnit("m³/h")]
|
[Display(Name = "流量(m³/h)")]
|
[PropertyOrder(11001)]
|
[HydroCalcuPro]
|
[ShowEditor(false)]
|
[Browsable(true)]
|
public virtual double? CalcuQ { get; set; }
|
|
/// <summary>
|
/// 进口压力
|
/// </summary>
|
[Category("计算结果")]
|
[DisplayName("进口压力")]
|
[DisplayUnit("m")]
|
[Display(Name = "进口压力(m)")]
|
[PropertyOrder(11002)]
|
[HydroCalcuPro]
|
[ShowEditor(false)]
|
[Browsable(true)]
|
public virtual double? CalcuPr1 { get; set; }
|
|
/// <summary>
|
/// 出口压力
|
/// </summary>
|
[Category("计算结果")]
|
[DisplayName("出口压力")]
|
[DisplayUnit("m")]
|
[Display(Name = "出口压力(m)")]
|
[PropertyOrder(11003)]
|
[HydroCalcuPro]
|
[ShowEditor(false)]
|
[Browsable(true)]
|
public virtual double? CalcuPr2 { get; set; }
|
|
/// <summary>
|
/// 局部损失
|
/// </summary>
|
[Category("计算结果")]
|
[DisplayName("局部损失")]
|
[DisplayUnit("m")]
|
[Display(Name = "局部损失(m)")]
|
[PropertyOrder(19008)]
|
[HydroCalcuPro]
|
[ShowEditor(false)]
|
[Browsable(true)]
|
public override double? CalcuMinorLoss { get; set; }
|
|
/// <summary>
|
///
|
/// </summary>
|
[Browsable(false)]
|
public new Yw.Model.HydroValveInfo Vmo
|
{
|
get { return _vmo as Yw.Model.HydroValveInfo; }
|
set { _vmo = value; }
|
}
|
|
|
/// <summary>
|
/// 更新属性
|
/// </summary>
|
public override void UpdateProperty()
|
{
|
base.UpdateProperty();
|
this.LinkStatus = HydroValveStatusHelper.GetStatusName(this.Vmo.LinkStatus);
|
this.Material = this.Vmo.Material;
|
this.Diameter = this.Vmo.Diameter;
|
this.MinorLoss = this.Vmo.MinorLoss;
|
this.ValveType = HydroValveTypeHelper.GetTypeName(this.Vmo.ValveType);
|
this.OpeningDegree = this.Vmo.OpeningDegree;
|
//this.ValveSetting = this.Vmo.ValveSetting;
|
UpdateValveSetting();
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public override void UpdateVmoProperty()
|
{
|
base.UpdateVmoProperty();
|
this.Vmo.LinkStatus = HydroValveStatusHelper.GetStatusCode(this.LinkStatus);
|
this.Vmo.Material = this.Material;
|
this.Vmo.Diameter = this.Diameter;
|
this.Vmo.MinorLoss = this.MinorLoss;
|
this.Vmo.ValveType = HydroValveTypeHelper.GetTypeCode(this.ValveType);
|
this.Vmo.OpeningDegree = this.OpeningDegree;
|
UpdateVmoValveSetting();
|
//this.Vmo.ValveSetting = this.ValveSetting;
|
}
|
|
/// <summary>
|
/// 更新计算属性
|
/// </summary>
|
public override void UpdateCalcuProperty(HydroCalcuVisualResult rhs)
|
{
|
base.UpdateCalcuProperty(rhs);
|
if (rhs is HydroCalcuValveResult calcuValveProperty)
|
{
|
this.CalcuQ = calcuValveProperty.CalcuQ.HasValue ? Math.Round(calcuValveProperty.CalcuQ.Value, 1) : null;
|
this.CalcuPr1 = calcuValveProperty.CalcuPr1.HasValue ? Math.Round(calcuValveProperty.CalcuPr1.Value, 2) : null;
|
this.CalcuPr2 = calcuValveProperty.CalcuPr2.HasValue ? Math.Round(calcuValveProperty.CalcuPr2.Value, 2) : null;
|
}
|
}
|
|
//更新阀门设置
|
//使用vmo更新自身属性时,再度更新阀门设置的其他属性
|
private void UpdateValveSetting()
|
{
|
switch (this.Vmo.ValveType)
|
{
|
case Yw.Hydro.ValveType.PSV:
|
{
|
if (double.TryParse(this.ValveSetting, out double press))
|
{
|
this.ValvePress = press;
|
}
|
}
|
break;
|
case Yw.Hydro.ValveType.PBV:
|
{
|
if (double.TryParse(this.ValveSetting, out double press))
|
{
|
this.ValvePress = press;
|
}
|
}
|
break;
|
case Yw.Hydro.ValveType.PRV:
|
{
|
if (double.TryParse(this.ValveSetting, out double press))
|
{
|
this.ValvePress = press;
|
}
|
}
|
break;
|
case Yw.Hydro.ValveType.FCV:
|
{
|
if (double.TryParse(this.ValveSetting, out double flow))
|
{
|
this.ValveFlow = flow;
|
}
|
}
|
break;
|
case Yw.Hydro.ValveType.TCV:
|
{
|
this.ValveOL = this.ValveSetting;
|
}
|
break;
|
case Yw.Hydro.ValveType.GPV:
|
{
|
this.ValveQL = this.ValveSetting;
|
}
|
break;
|
default: break;
|
}
|
}
|
|
//更新vmo阀门设置
|
//使用自身属性,更新vmo阀门设置
|
private void UpdateVmoValveSetting()
|
{
|
switch (this.Vmo.ValveType)
|
{
|
case Yw.Hydro.ValveType.PSV:
|
{
|
this.ValveSetting = this.ValvePress?.ToString();
|
}
|
break;
|
case Yw.Hydro.ValveType.PBV:
|
{
|
this.ValveSetting = this.ValvePress?.ToString();
|
}
|
break;
|
case Yw.Hydro.ValveType.PRV:
|
{
|
this.ValveSetting = this.ValvePress?.ToString();
|
}
|
break;
|
case Yw.Hydro.ValveType.FCV:
|
{
|
this.ValveSetting = this.ValveFlow?.ToString();
|
}
|
break;
|
case Yw.Hydro.ValveType.TCV:
|
{
|
this.ValveSetting = this.ValveOL;
|
}
|
break;
|
case Yw.Hydro.ValveType.GPV:
|
{
|
this.ValveSetting = this.ValveQL;
|
}
|
break;
|
default: break;
|
}
|
}
|
|
|
}
|
}
|