using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hydro.Core.Model
{
[Serializable]
public class LinkModel : BaseModel
{
public LinkModel() { }
public LinkModel(LinkModel model) : base(model)
{
this.Node1 = model.Node1;
this.Node2 = model.Node2;
this.Diameter = model.Diameter;
this.Length = model.Length;
this.Roughness = model.Roughness;
this.MinorLoss = model.MinorLoss;
}
///
/// Node1
///
public virtual string Node1 { get; set; }
///
/// Node2
///
public virtual string Node2 { get; set; }
///
/// 口径
///
public virtual float Diameter { get; set; }
///
/// 长度
///
public virtual float Length { get; set; }
///
/// 海森威廉系数
///
public virtual float Roughness { get; set; }
///
/// 局部阻力系数
///
public virtual float MinorLoss { get; set; }
public virtual string ToStatusString()
{
if (Status == ObjectEnum.StatusType.CLOSED)
{
return $"{ID}\tCLOSED\r\n";
}
return "";
}
}
[Serializable]
public class LinkCalcModel : LinkModel
{
public LinkCalcModel() { }
public LinkCalcModel(LinkCalcModel model) : base(model)
{
this.Node1 = model.Node1;
this.Node2 = model.Node2;
this.Diameter = model.Diameter;
this.Length = model.Length;
this.Roughness = model.Roughness;
this.MinorLoss = model.MinorLoss;
}
public string Node1
{
get
{
if (_StartNode != null) return _StartNode.ID;
return base.Node1;
}
set
{
base.Node1 = value;
}
}
public string Node2
{
get
{
if (_EndNode != null) return _EndNode.ID;
return base.Node2;
}
set
{
base.Node2 = value;
}
}
private NodeCalcModel _StartNode;
[JsonIgnore]
public NodeCalcModel StartNode {
get { return _StartNode; }
set { _StartNode = value; if (_StartNode != null) this.Node1 = _StartNode.ID; }
}
private NodeCalcModel _EndNode;
[JsonIgnore]
public NodeCalcModel EndNode {
get { return _EndNode; }
set { _EndNode = value; if (_EndNode!=null)this.Node2 = _EndNode.ID; }
}
///
/// 长度
///
public float Length
{
get
{
if (base.Length>0) return base.Length;
else
{
if (_StartNode!=null && _EndNode!=null)
{
////求_StartNode到_EndNode的距离
return (float)Math.Sqrt( Math.Pow(_StartNode.X-_EndNode.X, 2)+ Math.Pow(_StartNode.Y-_EndNode.Y,2)+Math.Pow(_StartNode.Elev-_EndNode.Elev,2));
}
else
{
return 0;
}
}
}
set
{
base.Length = value;
}
}
//实际需水量
[Category("计算结果")]
[DisplayName("1)流量(m³/h)")]
[Browsable(true)]
public float EN_FLOW { get; set; } = float.NaN;
//实际需水量
[Category("计算结果")]
[DisplayName("2)流速(m/s)")]
[Browsable(true)]
public float EN_VELOCITY { get; set; } = float.NaN;
//实际需水量
[Category("计算结果")]
[DisplayName("3)水头损失(m)")]
[Browsable(true)]
public float EN_HEADLOSS { get; set; } = float.NaN;
[Category("计算结果")]
[DisplayName("4)沿程水损(m)")]
[Browsable(true)]
public float EN_HEADLOSS_LINE { get; set; } = float.NaN;
[Category("计算结果")]
[DisplayName("5)局部水损(m)")]
[Browsable(true)]
public float EN_HEADLOSS_MINOR { get; set; } = float.NaN;
//实际需水量
[Category("计算结果")]
[DisplayName("5)当前状态")]
[Browsable(false)]
public float EN_STATUS { get; set; } = float.NaN;
[Category("其他参数")]
[Description("选中")]
[DisplayName("选中")]
[Browsable(false)]
public bool Selected { get; set; }
[Category("其他参数")]
[Description("鼠标悬于上方")]
[DisplayName("鼠标悬于上方")]
[Browsable(false)]
public bool Hovered { get; set; }
}
}