|
using System.Text;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
|
namespace Hydro.HydraulicModel
|
{
|
//public enum NodeValueType
|
//{
|
// EN_ELEVATION = 0, // { Mode parameters }
|
// EN_BASEDEMAND = 1,
|
// EN_PATTERN = 2,
|
// EN_EMITTER = 3,
|
// EN_INITQUAL = 4,
|
// EN_SOURCEQUAL = 5,
|
// EN_SOURCEPAT = 6,
|
// EN_SOURCETYPE = 7,
|
// EN_TANKLEVEL = 8,
|
// EN_DEMAND = 9,
|
// EN_HEAD = 10,
|
// EN_PRESSURE = 11,
|
// EN_QUALITY = 12,
|
// EN_SOURCEMASS = 13,
|
// EN_INITVOLUME = 14,
|
// EN_MIXMODEL = 15,
|
// EN_MIXZONEVOL = 16,
|
//}
|
//public enum LinkValueType
|
//{
|
// EN_DIAMETER = 0, // { Link parameters }
|
// EN_LENGTH = 1,
|
// EN_ROUGHNESS = 2,
|
// EN_MINORLOSS = 3,
|
// EN_INITSTATUS = 4,
|
// EN_INITSETTING = 5,
|
// EN_KBULK = 6,
|
// EN_KWALL = 7,
|
// EN_FLOW = 8,
|
// EN_VELOCITY = 9,
|
// EN_HEADLOSS = 10,
|
// EN_STATUS = 11,
|
// EN_SETTING = 12,
|
// EN_ENERGY = 13,
|
//}
|
public enum NodeValueType
|
{
|
标高 = 0, // { Mode parameters }
|
基本需水量 = 1,
|
需水量模式 = 2,
|
扩散器系数 = 3,
|
初始物质浓度 = 4,
|
输入物质浓度 = 5,
|
浓度模式 = 6,
|
水源类型 = 7,
|
水池水位 = 8,
|
需水量 = 9,
|
绝对压力 = 10,
|
自由压力 = 11,
|
物质浓度 = 12,
|
物质扩散浓度 = 13,
|
初始容积 = 14,
|
多物质混合模型 = 15,
|
多物质混合容积 = 16,
|
}
|
public enum LinkValueType
|
{
|
管径 = 0, // { Link parameters }
|
管长 = 1,
|
海森威廉系数 = 2,
|
局部水头损失 = 3,
|
初始状态 = 4,
|
初始设置 = 5,
|
水体反应系数 = 6,
|
管壁反应系数 = 7,
|
流量 = 8,
|
流速 = 9,
|
水损 = 10,
|
状态 = 11,
|
设置 = 12,
|
功率 = 13,
|
}
|
public class HydraulicCore
|
{
|
public static class Const_class
|
{
|
public static class Const_Node
|
{
|
public const int EN_ELEVATION = 0; // { Mode parameters }
|
public const int EN_BASEDEMAND = 1;
|
public const int EN_PATTERN = 2;
|
public const int EN_EMITTER = 3;
|
public const int EN_INITQUAL = 4;
|
public const int EN_SOURCEQUAL = 5;
|
public const int EN_SOURCEPAT = 6;
|
public const int EN_SOURCETYPE = 7;
|
public const int EN_TANKLEVEL = 8;
|
public const int EN_DEMAND = 9;
|
public const int EN_HEAD = 10;
|
public const int EN_PRESSURE = 11;
|
public const int EN_QUALITY = 12;
|
public const int EN_SOURCEMASS = 13;
|
public const int EN_INITVOLUME = 14;
|
public const int EN_MIXMODEL = 15;
|
public const int EN_MIXZONEVOL = 16;
|
}
|
|
public static class Const_Tank
|
{
|
public const int EN_TANKDIAM = 17;
|
public const int EN_MINVOLUME = 18;
|
public const int EN_VOLCURVE = 19;
|
public const int EN_MINLEVEL = 20;
|
public const int EN_MAXLEVEL = 21;
|
public const int EN_MIXFRACTION = 22;
|
public const int EN_TANK_KBULK = 23;
|
}
|
|
public static class Const_Link
|
{
|
|
public const int EN_DIAMETER = 0; // { Link parameters }
|
public const int EN_LENGTH = 1;
|
public const int EN_ROUGHNESS = 2;
|
public const int EN_MINORLOSS = 3;
|
public const int EN_INITSTATUS = 4;
|
public const int EN_INITSETTING = 5;
|
public const int EN_KBULK = 6;
|
public const int EN_KWALL = 7;
|
public const int EN_FLOW = 8;
|
public const int EN_VELOCITY = 9;
|
public const int EN_HEADLOSS = 10;
|
public const int EN_STATUS = 11;
|
public const int EN_SETTING = 12;
|
public const int EN_ENERGY = 13;
|
}
|
|
public static class Const_Time
|
{
|
public const int EN_DURATION = 0; // { Time parameters }
|
public const int EN_HYDSTEP = 1;
|
public const int EN_QUALSTEP = 2;
|
public const int EN_PATTERNSTEP = 3;
|
public const int EN_PATTERNSTART = 4;
|
public const int EN_REPORTSTEP = 5;
|
public const int EN_REPORTSTART = 6;
|
public const int EN_RULESTEP = 7;
|
public const int EN_STATISTIC = 8;
|
public const int EN_PERIODS = 9;
|
}
|
|
public static class Const_Component
|
{
|
public const int EN_NODECOUNT = 0; //{ Component counts }
|
public const int EN_TANKCOUNT = 1;
|
public const int EN_LINKCOUNT = 2;
|
public const int EN_PATCOUNT = 3;
|
public const int EN_CURVECOUNT = 4;
|
public const int EN_CONTROLCOUNT = 5;
|
}
|
|
public static class Const_Node_Type
|
{
|
public const int EN_JUNCTION = 0; // { Node types }
|
public const int EN_RESERVOIR = 1;
|
public const int EN_TANK = 2;
|
}
|
|
public static class Const_Link_types
|
{
|
public const int EN_CVPIPE = 0; // { Link types }
|
public const int EN_PIPE = 1;
|
public const int EN_PUMP = 2;
|
public const int EN_PRV = 3;
|
public const int EN_PSV = 4;
|
public const int EN_PBV = 5;
|
public const int EN_FCV = 6;
|
public const int EN_TCV = 7;
|
public const int EN_GPV = 8;
|
}
|
|
public static class Const_Quality_analysis_types
|
{
|
public const int EN_NONE = 0; // { Quality analysis types }
|
public const int EN_CHEM = 1;
|
public const int EN_AGE = 2;
|
public const int EN_TRACE = 3;
|
}
|
|
public static class Const_Source_quality_types
|
{
|
public const int EN_CONCEN = 0; // { Source quality types }
|
public const int EN_MASS = 1;
|
public const int EN_SETPOINT = 2;
|
public const int EN_FLOWPACED = 3;
|
}
|
|
public static class Const_Flow_units_types
|
{
|
public const int EN_CFS = 0; // { Flow units types }
|
public const int EN_GPM = 1;
|
public const int EN_MGD = 2;
|
public const int EN_IMGD = 3;
|
public const int EN_AFD = 4;
|
public const int EN_LPS = 5;
|
public const int EN_LPM = 6;
|
public const int EN_MLD = 7;
|
public const int EN_CMH = 8;
|
public const int EN_CMD = 9;
|
}
|
|
public static class Const_Option_types
|
{
|
public const int EN_TRIALS = 0; // { Option types }
|
public const int EN_ACCURACY = 1;
|
public const int EN_TOLERANCE = 2;
|
public const int EN_EMITEXPON = 3;
|
public const int EN_DEMANDMULT = 4;
|
}
|
|
public static class Const_Control_types
|
{
|
public const int EN_LOWLEVEL = 0; //{ Control types }
|
public const int EN_HILEVEL = 1;
|
public const int EN_TIMER = 2;
|
public const int EN_TIMEOFDAY = 3;
|
}
|
|
public static class Const_Time_statistic_types
|
{
|
public const int EN_AVERAGE = 1; // { Time statistic types }
|
public const int EN_MINIMUM = 2;
|
public const int EN_MAXIMUM = 3;
|
public const int EN_RANGE = 4;
|
}
|
|
public static class Const_Tank_mixing_models
|
{
|
public const int EN_MIX1 = 0; // { Tank mixing models }
|
public const int EN_MIX2 = 1;
|
public const int EN_FIFO = 2;
|
public const int EN_LIFO = 3;
|
}
|
|
public static class Const_Save_results_Mode
|
{
|
public const int EN_NOSAVE = 0; // { Save-results-to-file flag }
|
public const int EN_SAVE = 1;
|
public const int EN_INITFLOW = 10; // { Re-initialize flow flag }
|
}
|
public static class Const_statuslevel
|
{
|
public const int EN_NONE = 0;
|
public const int EN_NORMAL = 0;
|
public const int EN_FULL = 0;
|
}
|
|
}
|
|
static int ProjectCount=0;
|
|
public void Dispose()
|
{
|
HydraulicCore.ProjectCount--;
|
}
|
|
int projectID;
|
|
public int GetProjectID()
|
{
|
return projectID;
|
}
|
public HydraulicCore()
|
{
|
|
this.projectID = ProjectCount;
|
HydraulicCore.ProjectCount++;
|
}
|
// 获取节点参数值
|
|
public int getnodevalue(int index, int paramcode, ref float value)
|
{
|
return HydraulicCoreBase.ENgetnodevalue22(projectID, index, paramcode, ref value);
|
}
|
// 获取节点类型
|
|
public float getvalue(string ID,int paramcode)
|
{
|
int err = 0;
|
int index = 0;
|
err=getnodeindex(ID,ref index);
|
float value = 0;
|
if (index>0)
|
{
|
err = getnodevalue(index,paramcode,ref value);
|
}
|
else
|
{
|
err = getlinkindex(ID, ref index);
|
err = getlinkvalue(index, paramcode, ref value);
|
}
|
return value;
|
|
}
|
public float getvalue(string ID, int paramcode,bool isNode)
|
{
|
int err = 0;
|
int index = 0;
|
float value = 0;
|
if (isNode)
|
{
|
err = getnodeindex(ID, ref index);
|
|
if (index > 0)
|
err = getnodevalue(index, paramcode, ref value);
|
}
|
|
else
|
{
|
err = getlinkindex(ID, ref index);
|
if (index > 0)
|
err = getlinkvalue(index, paramcode, ref value);
|
}
|
return value;
|
|
}
|
public int setvalue(string ID, int paramcode,double value, bool isNode)
|
{
|
int err = 0;
|
int index = 0;
|
|
if (isNode)
|
{
|
err = getnodeindex(ID, ref index);
|
|
if (index > 0)
|
err = setnodevalue(index, paramcode,(float) value);
|
}
|
|
else
|
{
|
err = getlinkindex(ID, ref index);
|
if (index > 0)
|
err = setlinkvalue(index, paramcode, (float)value);
|
}
|
|
return err;
|
|
}
|
public int getnodetype(int index, ref int typecode)
|
{
|
return HydraulicCoreBase.ENgetnodetype22(projectID, index, ref typecode);
|
}
|
// 获取节点编号
|
|
public int getnodeindex(string nodeid, ref int nodeindex)
|
{
|
return HydraulicCoreBase.ENgetnodeindex22(projectID, nodeid, ref nodeindex);
|
}
|
|
// 获取节点 id
|
|
public int getnodeid(int index, StringBuilder id)
|
{
|
return HydraulicCoreBase.ENgetnodeid22(projectID, index, id);
|
}
|
public int getnodecomment(int index, StringBuilder id)
|
{
|
return HydraulicCoreBase.ENgetnodecomment22(projectID, index, id);
|
}
|
public int addnode(string id, int nodeType, ref int index)
|
{
|
return HydraulicCoreBase.ENaddnode22(projectID, id, nodeType, ref index);
|
}
|
|
|
public int getcoord(int index, ref double x, ref double y)
|
{
|
return HydraulicCoreBase.ENgetcoord22(projectID, index, ref x, ref y);
|
}
|
|
public int setcoord(int index, double x, double y)
|
{
|
return HydraulicCoreBase.ENsetcoord22(projectID, index, x, y);
|
}
|
|
// 设置节点参数
|
|
public int setnodevalue(int index, int paramcode, float value)
|
{
|
return HydraulicCoreBase.ENsetnodevalue22(projectID, index, paramcode, value);
|
}
|
|
|
|
#region 管段
|
|
// 设置管段参数
|
|
public int setlinkvalue(int index, int paramcode, float value)
|
{
|
return HydraulicCoreBase.ENsetlinkvalue22(projectID, index, paramcode, value);
|
}
|
|
// 获取管段 id
|
|
|
public int getlinkid(int index, StringBuilder id)
|
{
|
return HydraulicCoreBase.ENgetlinkid22(projectID, index, id);
|
}
|
public int getlinkcomment(int index, StringBuilder id)
|
{
|
return HydraulicCoreBase.ENgetlinkcomment22(projectID, index, id);
|
}
|
// 获取管段 id
|
|
|
public int getlinkindex(string id, ref int index)
|
{
|
return HydraulicCoreBase.ENgetlinkindex22(projectID, id, ref index);
|
}
|
// 获取管段节点
|
|
public int getlinknodes(int index, ref int fromnode, ref int tonode)
|
{
|
return HydraulicCoreBase.ENgetlinknodes22(projectID, index, ref fromnode, ref tonode);
|
}
|
|
|
// 获得管段参数
|
|
public int getlinkvalue(int index, int paramcode, ref float value)
|
{
|
return HydraulicCoreBase.ENgetlinkvalue22(projectID, index, paramcode, ref value);
|
}
|
|
// 设置管段类型
|
|
public int getlinktype(int index, ref int typecode)
|
{
|
return HydraulicCoreBase.ENgetlinktype22(projectID, index, ref typecode);
|
}
|
// 增加管线
|
|
public int addlink(string id, int linkType, string fromNode, string toNode, ref int index)
|
{
|
return HydraulicCoreBase.ENaddlink22(projectID, id, linkType, fromNode, toNode, ref index);
|
}
|
|
|
#endregion
|
|
#region 模式
|
// 获取模式id
|
|
public int getpatternindex(string patternID, ref int patternindex)
|
{
|
return HydraulicCoreBase.ENgetpatternindex22(projectID, patternID, ref patternindex);
|
}
|
|
|
// 增加新的时间模式
|
|
public int addpattern(string patternID)
|
{
|
return HydraulicCoreBase.ENaddpattern22(projectID, patternID);
|
}
|
// 设置时间模式的值
|
|
public int setpatternvalue(int index, int period, float value)
|
{
|
return HydraulicCoreBase.ENsetpatternvalue22(projectID, index, period, value);
|
}
|
|
|
|
public int setpatternvalue_ex(string patternID, int period, float value)
|
{
|
return HydraulicCoreBase.ENsetpatternvalue_ex(projectID, patternID, period, value);
|
}
|
|
|
|
|
|
public int setpattern(int index, float[] values, int n)
|
{
|
return HydraulicCoreBase.ENsetpattern22(projectID, index, values, n);
|
}
|
|
/// <summary>
|
/// 加强版添加模式,如果模式名称不存在,则自动新增模式;新增完后,自定绑定节点
|
/// </summary>
|
/// <param name="projectID"></param>
|
/// <param name="nodeID"></param>
|
/// <param name="patternID"></param>
|
/// <param name="values"></param>
|
/// <returns></returns>
|
public int setpatternvalue_ex(string nodeID, string patternID, double[] values)
|
{
|
return HydraulicCoreBase.ENsetpatternvalue_ex(projectID, nodeID, patternID, values);
|
}
|
|
|
|
|
public int setcurve(int index, float[] Xvalues, float[] Yvalues, int n)
|
{
|
return HydraulicCoreBase.ENsetcurve22(projectID, index, Xvalues, Yvalues, n);
|
}
|
|
|
|
|
|
#endregion
|
|
#region 计算控制
|
|
//epanet 完全模拟函数
|
|
public int epanet(string f1, string f2, string f3, IntPtr vfunc)
|
{
|
return HydraulicCoreBase.ENepanet22(projectID, f1, f2, f3, vfunc);
|
}
|
// 关闭管网文件
|
|
public int close()
|
{
|
ProjectCount--;
|
return HydraulicCoreBase.ENclose22(projectID);
|
|
}
|
// 关闭水力模拟系统,释放内存
|
|
public int closeH()
|
{
|
return HydraulicCoreBase.ENcloseH22(projectID);
|
}
|
// 关闭水质模拟系统,释放内存
|
|
public int closeQ()
|
{
|
return HydraulicCoreBase.ENcloseQ22(projectID);
|
}
|
// 调用打开管网文件
|
|
public int open(string f1, string f2, string f3)
|
{
|
return HydraulicCoreBase.ENopen22(projectID, f1, f2, f3);
|
}
|
// 调用打开水力分析系统
|
|
public int openH()
|
{
|
return HydraulicCoreBase.ENopenH22(projectID);
|
}
|
// 调用打开水力分析系统
|
|
public int openQ()
|
{
|
return HydraulicCoreBase.ENopenQ22(projectID);
|
}
|
|
/// <summary>
|
/// 调用初始化水力计算系统
|
/// </summary>
|
/// <param name="saveflag">0-1标志,说明分析结果是否以均匀报告时段保存到EPANETH二进制输出文件。</param>
|
/// <returns>返回错误编号,0表示无错误</returns>
|
|
public int initH(int saveflag)
|
{
|
return HydraulicCoreBase.ENinitH22(projectID, saveflag);
|
}
|
|
// 调用运行水力计算
|
|
public int runH(ref int t1)
|
{
|
return HydraulicCoreBase.ENrunH22(projectID, ref t1);
|
}
|
// 水力计算步长
|
|
public int nextH(ref int tstep1)
|
{
|
return HydraulicCoreBase.ENnextH22(projectID, ref tstep1);
|
}
|
// 调用初始化水质计算系统
|
|
public int initQ(int saveflag)
|
{
|
return HydraulicCoreBase.ENinitQ22(projectID, saveflag);
|
}
|
// 调用运行水力计算
|
|
public int runQ(ref int t1)
|
{
|
return HydraulicCoreBase.ENrunQ22(projectID, ref t1);
|
}
|
// 水力计算步长
|
|
public int nextQ(ref int tstep1)
|
{
|
return HydraulicCoreBase.ENnextQ22(projectID, ref tstep1);
|
}
|
|
|
|
// 全部水力模拟
|
|
public int solveH()
|
{
|
return HydraulicCoreBase.ENsolveH22(projectID);
|
}
|
// 全部水质模拟
|
|
public int solveQ()
|
{
|
return HydraulicCoreBase.ENsolveQ22(projectID);
|
}
|
|
// 生成报告
|
|
public int saveH()
|
{
|
return HydraulicCoreBase.ENsaveH22(projectID);
|
}
|
#endregion
|
|
#region 报告
|
// 生成报告
|
|
public int report()
|
{
|
return HydraulicCoreBase.ENreport22(projectID);
|
}
|
// 重置报告
|
|
public int resetreport()
|
{
|
return HydraulicCoreBase.ENresetreport22(projectID);
|
}
|
|
// 重置报告
|
|
public int setreport(string x)
|
{
|
return HydraulicCoreBase.ENsetreport22(projectID, x);
|
}
|
#endregion
|
|
#region 其他
|
|
|
// 获取管网元件数
|
|
public int getcount(int countcode, ref int count)
|
{
|
return HydraulicCoreBase.ENgetcount22(projectID, countcode, ref count);
|
}
|
|
// 获取错误信息
|
|
public int geterror(int errcode, StringBuilder errmsg, int nchar)
|
{
|
return HydraulicCoreBase.ENgeterror22(projectID, errcode, errmsg, nchar);
|
}
|
|
// 输出文件信息
|
|
public int saveinpfile(string filename)
|
{
|
return HydraulicCoreBase.ENsaveinpfile22(projectID, filename);
|
}
|
|
|
|
// 获取简单控制状态的参数
|
|
public int getcontrol(int cindex, ref int ctype, ref int index, ref
|
float setting, ref int nindex, ref float level)
|
{
|
return HydraulicCoreBase.ENgetcontrol22(projectID, cindex, ref ctype, ref index, ref
|
setting, ref nindex, ref level);
|
}
|
|
|
|
// 设置选项
|
|
public int setoption(int code, float v)
|
{
|
return HydraulicCoreBase.ENsetoption22(projectID, code, v);
|
}
|
public int setstatusreport(int code)
|
{
|
|
return HydraulicCoreBase.ENsetstatusreport22(projectID, code);
|
}
|
public float getoption(int code )
|
{
|
float v = 0;
|
HydraulicCoreBase.ENgetoption22(projectID, code,ref v);
|
return v;
|
}
|
|
// 设置选项
|
|
public int gettimeparam(int code, ref int v)
|
{
|
return HydraulicCoreBase.ENgettimeparam22(projectID, code, ref v);
|
}
|
// 设置水质类型
|
|
public int setqualtype(int qualcode, string chemname,
|
string chemunits, string tracenode)
|
{
|
return HydraulicCoreBase.ENsetqualtype22(projectID, qualcode, chemname, chemunits, tracenode);
|
}
|
|
|
|
|
#endregion
|
|
//补充
|
|
public int setinistatus(string id, string value)
|
{
|
return HydraulicCoreBase.ENsetinistatus22(projectID, id, value);
|
}
|
|
//补充
|
|
public int setprojectreport(int value)
|
{
|
return HydraulicCoreBase.ENsetprojectreport22(projectID, value);
|
}
|
|
|
|
public int getbasedemand( int nodeIndex, int demandIndex, out List<double> baseDemand)
|
{
|
return HydraulicCoreBase.ENgetbasedemand22(projectID, nodeIndex,demandIndex, out baseDemand);
|
}
|
//补充
|
|
public int getdemandpattern(int nodeIndex, int demandIndex,
|
out List<int> patIndex)
|
{
|
return HydraulicCoreBase.ENgetdemandpattern22(projectID, nodeIndex, demandIndex, out patIndex);
|
}
|
|
public int getTotalDemand(int p, out double value)
|
{
|
return HydraulicCoreBase.ENgetTotalDemand22(projectID, p, out value);
|
}
|
|
|
|
}
|
}
|