namespace Yw.EPAnet
|
{
|
/// <summary>
|
/// 管网检查拓展
|
/// </summary>
|
public static class NetworkCheckExtensions
|
{
|
/// <summary>
|
/// 根据Inp文件计算
|
/// </summary>
|
/// <returns></returns>
|
public static CheckResult Check(this Network network)
|
{
|
var result = new CheckResult();
|
if (network == null)
|
{
|
result.Succeed = false;
|
return result;
|
}
|
|
//验证水源
|
var allSourceList = network.GetAllSources();
|
if (allSourceList == null || allSourceList.Count < 1)
|
{
|
result.Succeed = false;
|
result.FailedList.Add(new CheckFailed()
|
{
|
ParterId = string.Empty,
|
FailType = eCheckFailType.LackSource,
|
FailReason = "缺少水源,至少需包含一座水库或水池"
|
});
|
}
|
|
//验证连接节点
|
var allJunctionList = network.GetAllJunctions();
|
if (allJunctionList == null || allJunctionList.Count < 1)
|
{
|
result.Succeed = false;
|
result.FailedList.Add(new CheckFailed()
|
{
|
ParterId = string.Empty,
|
FailType = eCheckFailType.LackJunction,
|
FailReason = "缺少连接节点,至少需包含一个连接节点"
|
});
|
}
|
|
//验证节点
|
var allNodeList = network.GetAllNodes();
|
foreach (var node in allNodeList)
|
{
|
if (node.Links == null || node.Links.Count < 1)
|
{
|
result.Succeed = false;
|
result.FailedList.Add(new CheckFailed()
|
{
|
ParterId = node.Id,
|
FailType = eCheckFailType.AloneNode,
|
FailReason = "孤立节点,没有任何管段连接"
|
});
|
}
|
else
|
{
|
if (node.Links.Exists(x => x is INode))
|
{
|
result.Succeed = false;
|
result.FailedList.Add(new CheckFailed()
|
{
|
ParterId = node.Id,
|
FailType = eCheckFailType.NodeAbnormalConnected,
|
FailReason = "节点异常连接,存在节点连接"
|
});
|
}
|
}
|
}
|
|
//验证管段
|
var allLinkList = network.GetAllLinks();
|
foreach (var link in allLinkList)
|
{
|
if (link.StartNode == null && link.EndNode == null)
|
{
|
result.Succeed = false;
|
result.FailedList.Add(new CheckFailed()
|
{
|
ParterId = link.Id,
|
FailType = eCheckFailType.AloneLink,
|
FailReason = "孤立管段,没有连接任何管段"
|
});
|
}
|
else
|
{
|
if (link.StartNode == null)
|
{
|
result.Succeed = false;
|
result.FailedList.Add(new CheckFailed()
|
{
|
ParterId = link.Id,
|
FailType = eCheckFailType.LinkLossNode,
|
FailReason = "管段缺少节点,缺少上游节点"
|
});
|
}
|
else if (link.EndNode == null)
|
{
|
result.Succeed = false;
|
result.FailedList.Add(new CheckFailed()
|
{
|
ParterId = link.Id,
|
FailType = eCheckFailType.LinkLossNode,
|
FailReason = "管段缺少节点,缺少下游节点"
|
});
|
}
|
else
|
{
|
if (link.StartNode.Id == link.EndNode.Id)
|
{
|
result.Succeed = false;
|
result.FailedList.Add(new CheckFailed()
|
{
|
ParterId = link.Id,
|
FailType = eCheckFailType.LinkAbnormalConnected,
|
FailReason = "管段异常连接,上游与下游节点相同"
|
});
|
}
|
if (link.StartNode is not INode)
|
{
|
result.Succeed = false;
|
result.FailedList.Add(new CheckFailed()
|
{
|
ParterId = link.Id,
|
FailType = eCheckFailType.LinkAbnormalConnected,
|
FailReason = "管段异常连接,上游未连接节点"
|
});
|
}
|
if (link.EndNode is not INode)
|
{
|
result.Succeed = false;
|
result.FailedList.Add(new CheckFailed()
|
{
|
ParterId = link.Id,
|
FailType = eCheckFailType.LinkAbnormalConnected,
|
FailReason = "管段异常连接,下游未连接节点"
|
});
|
}
|
}
|
}
|
|
//验证管道
|
if (link is Pipe pipe)
|
{
|
if (pipe.Length <= 0)
|
{
|
result.Succeed = false;
|
result.FailedList.Add(new CheckFailed()
|
{
|
ParterId = pipe.Id,
|
FailType = eCheckFailType.PropSetError,
|
FailReason = "属性设置错误,管道长度必须大于0"
|
});
|
}
|
if (pipe.Roughness <= 0.1 || pipe.Roughness > 10000)
|
{
|
result.Succeed = false;
|
result.FailedList.Add(new CheckFailed()
|
{
|
ParterId = pipe.Id,
|
FailType = eCheckFailType.PropSetError,
|
FailReason = "属性设置错误,粗糙系数区间(0.1,10000】"
|
});
|
}
|
if (pipe.Diameter <= 0.1 || pipe.Diameter > 10000)
|
{
|
result.Succeed = false;
|
result.FailedList.Add(new CheckFailed()
|
{
|
ParterId = pipe.Id,
|
FailType = eCheckFailType.PropSetError,
|
FailReason = "属性设置错误,管径区间(0.1,10000】"
|
});
|
}
|
}
|
}
|
|
return result;
|
}
|
|
|
}
|
}
|