diff --git a/include/epanet2.bas b/include/epanet2.bas
index cab5ee6..2955f9b 100644
--- a/include/epanet2.bas
+++ b/include/epanet2.bas
@@ -5,7 +5,7 @@ Attribute VB_Name = "Module1"
'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
'(EPANET2.DLL)
-'Last updated on 01/01/2019
+'Last updated on 01/08/2019
' These are codes used by the DLL functions
Public Const EN_ELEVATION = 0 ' Node parameters
@@ -185,36 +185,36 @@ Public Const EN_NO_REPORT = 0 ' No status report
Public Const EN_NORMAL_REPORT = 1 ' Normal status report
Public Const EN_FULL_REPORT = 2 ' Full status report
-Public Const EN_R_NODE = 6 ' Rule objects
-Public Const EN_R_LINK = 7
+Public Const EN_R_NODE = 6 ' Rule objects
+Public Const EN_R_LINK = 7
Public Const EN_R_SYSTEM = 8
-Public Const EN_R_DEMAND = 0 ' Rule variables
-Public Const EN_R_HEAD = 1
-Public Const EN_R_GRADE = 2
-Public Const EN_R_LEVEL = 3
-Public Const EN_R_PRESSURE = 4
-Public Const EN_R_FLOW = 5
-Public Const EN_R_STATUS = 6
-Public Const EN_R_SETTING = 7
-Public Const EN_R_POWER = 8
-Public Const EN_R_TIME = 9
+Public Const EN_R_DEMAND = 0 ' Rule variables
+Public Const EN_R_HEAD = 1
+Public Const EN_R_GRADE = 2
+Public Const EN_R_LEVEL = 3
+Public Const EN_R_PRESSURE = 4
+Public Const EN_R_FLOW = 5
+Public Const EN_R_STATUS = 6
+Public Const EN_R_SETTING = 7
+Public Const EN_R_POWER = 8
+Public Const EN_R_TIME = 9
Public Const EN_R_CLOCKTIME = 10
-Public Const EN_R_FILLTIME = 11
+Public Const EN_R_FILLTIME = 11
Public Const EN_R_DRAINTIME = 12
-Public Const EN_R_EQ = 0 ' Rule operators
-Public Const EN_R_NE = 1
-Public Const EN_R_LE = 2
-Public Const EN_R_GE = 3
-Public Const EN_R_LT = 4
-Public Const EN_R_GT = 5
-Public Const EN_R_IS = 6
-Public Const EN_R_NOT = 7
+Public Const EN_R_EQ = 0 ' Rule operators
+Public Const EN_R_NE = 1
+Public Const EN_R_LE = 2
+Public Const EN_R_GE = 3
+Public Const EN_R_LT = 4
+Public Const EN_R_GT = 5
+Public Const EN_R_IS = 6
+Public Const EN_R_NOT = 7
Public Const EN_R_BELOW = 8
Public Const EN_R_ABOVE = 9
-Public Const EN_R_IS_OPEN = 1 ' Rule status types
+Public Const EN_R_IS_OPEN = 1 ' Rule status types
Public Const EN_R_IS_CLOSED = 2
Public Const EN_R_IS_ACTIVE = 3
@@ -222,136 +222,136 @@ Public Const EN_R_IS_ACTIVE = 3
'System Functions
Declare Function ENgetversion Lib "epanet2.dll" (value As Long) As Long
- Declare Function ENepanet Lib "epanet2.dll" (ByVal F1 As String, ByVal F2 As String, ByVal F3 As String, ByVal F4 As Any) As Long
- Declare Function ENinit Lib "epanet2.dll" (ByVal rptFile As String, ByVal binOutFile As String, ByVal UnitsType As Long, ByVal HeadlossFormula As Long) As Long
- Declare Function ENopen Lib "epanet2.dll" (ByVal F1 As String, ByVal F2 As String, ByVal F3 As String) As Long
- Declare Function ENsaveinpfile Lib "epanet2.dll" (ByVal F As String) As Long
+ Declare Function ENepanet Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String, ByVal pviewprog As Any) As Long
+ Declare Function ENinit Lib "epanet2.dll" (ByVal rptFile As String, ByVal outFile As String, ByVal unitsType As Long, ByVal headlossType As Long) As Long
+ Declare Function ENopen Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String) As Long
+ Declare Function ENsaveinpfile Lib "epanet2.dll" (ByVal filename As String) As Long
Declare Function ENclose Lib "epanet2.dll" () As Long
'Hydraulic Analysis Functions
Declare Function ENsolveH Lib "epanet2.dll" () As Long
Declare Function ENsaveH Lib "epanet2.dll" () As Long
Declare Function ENopenH Lib "epanet2.dll" () As Long
- Declare Function ENinitH Lib "epanet2.dll" (ByVal SaveFlag As Long) As Long
- Declare Function ENrunH Lib "epanet2.dll" (T As Long) As Long
- Declare Function ENnextH Lib "epanet2.dll" (Tstep As Long) As Long
+ Declare Function ENinitH Lib "epanet2.dll" (ByVal initFlag As Long) As Long
+ Declare Function ENrunH Lib "epanet2.dll" (currentTime As Long) As Long
+ Declare Function ENnextH Lib "epanet2.dll" (tStep As Long) As Long
Declare Function ENcloseH Lib "epanet2.dll" () As Long
- Declare Function ENsavehydfile Lib "epanet2.dll" (ByVal F As String) As Long
- Declare Function ENusehydfile Lib "epanet2.dll" (ByVal F As String) As Long
+ Declare Function ENsavehydfile Lib "epanet2.dll" (ByVal filename As String) As Long
+ Declare Function ENusehydfile Lib "epanet2.dll" (ByVal filename As String) As Long
'Water Quality Analysis Functions
Declare Function ENsolveQ Lib "epanet2.dll" () As Long
Declare Function ENopenQ Lib "epanet2.dll" () As Long
- Declare Function ENinitQ Lib "epanet2.dll" (ByVal SaveFlag As Long) As Long
- Declare Function ENrunQ Lib "epanet2.dll" (T As Long) As Long
- Declare Function ENnextQ Lib "epanet2.dll" (Tstep As Long) As Long
- Declare Function ENstepQ Lib "epanet2.dll" (Tleft As Long) As Long
+ Declare Function ENinitQ Lib "epanet2.dll" (ByVal saveFlag As Long) As Long
+ Declare Function ENrunQ Lib "epanet2.dll" (currentTime As Long) As Long
+ Declare Function ENnextQ Lib "epanet2.dll" (tStep As Long) As Long
+ Declare Function ENstepQ Lib "epanet2.dll" (timeLeft As Long) As Long
Declare Function ENcloseQ Lib "epanet2.dll" () As Long
'Reporting Functions
- Declare Function ENwriteline Lib "epanet2.dll" (ByVal S As String) As Long
+ Declare Function ENwriteline Lib "epanet2.dll" (ByVal line As String) As Long
Declare Function ENreport Lib "epanet2.dll" () As Long
Declare Function ENresetreport Lib "epanet2.dll" () As Long
- Declare Function ENsetreport Lib "epanet2.dll" (ByVal S As String) As Long
- Declare Function ENsetstatusreport Lib "epanet2.dll" (ByVal code As Long) As Long
- Declare Function ENgetcount Lib "epanet2.dll" (ByVal code As Long, value As Long) As Long
- Declare Function ENgeterror Lib "epanet2.dll" (ByVal ErrCode As Long, ByVal ErrMsg As String, ByVal N As Long) As Long
- Declare Function ENgetstatistic Lib "epanet2.dll" (ByVal code As Long, ByRef value As Single) As Long
+ Declare Function ENsetreport Lib "epanet2.dll" (ByVal format As String) As Long
+ Declare Function ENsetstatusreport Lib "epanet2.dll" (ByVal level As Long) As Long
+ Declare Function ENgetcount Lib "epanet2.dll" (ByVal object As Long, count As Long) As Long
+ Declare Function ENgeterror Lib "epanet2.dll" (ByVal errcode As Long, ByVal errmsg As String, ByVal maxLen As Long) As Long
+ Declare Function ENgetstatistic Lib "epanet2.dll" (ByVal type_ As Long, ByRef value As Single) As Long
'Analysis Options Functions
- Declare Function ENgetoption Lib "epanet2.dll" (ByVal code As Long, value As Single) As Long
- Declare Function ENsetoption Lib "epanet2.dll" (ByVal code As Long, ByVal value As Single) As Long
- Declare Function ENgetflowunits Lib "epanet2.dll" (code As Long) As Long
- Declare Function ENsetflowunits Lib "epanet2.dll" (ByVal code As Long) As Long
- Declare Function ENgettimeparam Lib "epanet2.dll" (ByVal code As Long, value As Long) As Long
- Declare Function ENsettimeparam Lib "epanet2.dll" (ByVal code As Long, ByVal value As Long) As Long
- Declare Function ENgetqualtype Lib "epanet2.dll" (QualCode As Long, TraceNode As Long) As Long
- Declare Function ENgetqualinfo Lib "epanet2.dll" (QualCode As Long, ByVal ChemName As String, ByVal ChemUnits As String, TraceNode As Long) As Long
- Declare Function ENsetqualtype Lib "epanet2.dll" (ByVal QualCode As Long, ByVal ChemName As String, ByVal ChemUnits As String, ByVal TraceNode As String) As Long
+ Declare Function ENgetoption Lib "epanet2.dll" (ByVal option_ As Long, value As Single) As Long
+ Declare Function ENsetoption Lib "epanet2.dll" (ByVal option_ As Long, ByVal value As Single) As Long
+ Declare Function ENgetflowunits Lib "epanet2.dll" (units As Long) As Long
+ Declare Function ENsetflowunits Lib "epanet2.dll" (ByVal units As Long) As Long
+ Declare Function ENgettimeparam Lib "epanet2.dll" (ByVal param As Long, value As Long) As Long
+ Declare Function ENsettimeparam Lib "epanet2.dll" (ByVal param As Long, ByVal value As Long) As Long
+ Declare Function ENgetqualinfo Lib "epanet2.dll" (qualType As Long, ByVal chemName As String, ByVal chemUnits As String, traceNode As Long) As Long
+ Declare Function ENgetqualtype Lib "epanet2.dll" (qualType As Long, traceNode As Long) As Long
+ Declare Function ENsetqualtype Lib "epanet2.dll" (ByVal qualType As Long, ByVal chemName As String, ByVal chemUnits As String, ByVal traceNode As String) As Long
-'Basic Node Functions
+'Node Functions
Declare Function ENaddnode Lib "epanet2.dll" (ByVal id As String, ByVal nodeType As Long) As Long
- Declare Function ENdeletenode Lib "epanet2.dll" (ByVal linkIndex As Long, ByVal actionCode As Long) As Long
+ Declare Function ENdeletenode Lib "epanet2.dll" (ByVal index As Long, ByVal actionCode As Long) As Long
Declare Function ENgetnodeindex Lib "epanet2.dll" (ByVal id As String, index As Long) As Long
Declare Function ENgetnodeid Lib "epanet2.dll" (ByVal index As Long, ByVal id As String) As Long
Declare Function ENsetnodeid Lib "epanet2.dll" (ByVal index As Long, ByVal newid As String) As Long
- Declare Function ENgetnodetype Lib "epanet2.dll" (ByVal index As Long, code As Long) As Long
- Declare Function ENgetnodevalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, value As Single) As Long
- Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, ByVal value As Single) As Long
+ Declare Function ENgetnodetype Lib "epanet2.dll" (ByVal index As Long, nodeType As Long) As Long
+ Declare Function ENgetnodevalue Lib "epanet2.dll" (ByVal index As Long, ByVal property As Long, value As Single) As Long
+ Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal index As Long, ByVal property As Long, ByVal value As Single) As Long
Declare Function ENsetjuncdata Lib "epanet2.dll" (ByVal index As Long, ByVal elev As Single, ByVal dmnd As Single, ByVal dmndpat As String) As Long
Declare Function ENsettankdata Lib "epanet2.dll" (ByVal index As Long, ByVal elev As Single, ByVal initlvl As Single, ByVal minlvl As Single, ByVal maxlvl As Single, ByVal diam As Single, ByVal minvol As Single, ByVal volcurve As String) As Long
- Declare Function ENgetcoord Lib "epanet2.dll" (ByVal index As Long, X As Single, Y As Single) As Long
- Declare Function ENsetcoord Lib "epanet2.dll" (ByVal index As Long, ByVal X As Single, ByVal Y As Single) As Long
+ Declare Function ENgetcoord Lib "epanet2.dll" (ByVal index As Long, x As Single, y As Single) As Long
+ Declare Function ENsetcoord Lib "epanet2.dll" (ByVal index As Long, ByVal x As Single, ByVal y As Single) As Long
'Nodal Demand Functions
- Declare Function ENgetdemandmodel Lib "epanet2.dll" (mtype As Long, pmin As Single, preq As Single, pexp As Single) As Long
- Declare Function ENsetdemandmodel Lib "epanet2.dll" (ByVal mtype As Long, ByVal pmin As Single, ByVal preq As Single, ByVal pexp As Single) As Long
- Declare Function ENgetnumdemands Lib "epanet2.dll" (ByVal index As Long, numDemands As Long) As Long
- Declare Function ENgetbasedemand Lib "epanet2.dll" (ByVal index As Long, ByVal DemandIndex As Long, value As Single) As Long
- Declare Function ENsetbasedemand Lib "epanet2.dll" (ByVal index As Long, ByVal DemandIndex As Long, ByVal BaseDemand As Single) As Long
- Declare Function ENgetdemandpattern Lib "epanet2.dll" (ByVal index As Long, ByVal DemandIndex As Long, PatIndex As Long) As Long
- Declare Function ENsetdemandpattern Lib "epanet2.dll" (ByVal index As Long, ByVal DemandIndex As Long, ByVal PatIndex As Long) As Long
- Declare Function ENgetdemandname Lib "epanet2.dll" (ByVal index As Long, ByVal DemandIndex As Long, ByVal demandName As String) As Long
- Declare Function ENsetdemandname Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal DemandIndex As Long, ByVal demandName As String) As Long
+ Declare Function ENgetdemandmodel Lib "epanet2.dll" (type_ As Long, pmin As Single, preq As Single, pexp As Single) As Long
+ Declare Function ENsetdemandmodel Lib "epanet2.dll" (ByVal type_ As Long, ByVal pmin As Single, ByVal preq As Single, ByVal pexp As Single) As Long
+ Declare Function ENgetnumdemands Lib "epanet2.dll" (ByVal nodeIndex As Long, numDemands As Long) As Long
+ Declare Function ENgetbasedemand Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal demandIndex As Long, value As Single) As Long
+ Declare Function ENsetbasedemand Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal demandIndex As Long, ByVal BaseDemand As Single) As Long
+ Declare Function ENgetdemandpattern Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal demandIndex As Long, patIndex As Long) As Long
+ Declare Function ENsetdemandpattern Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal demandIndex As Long, ByVal patIndex As Long) As Long
+ Declare Function ENgetdemandname Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal demandIndex As Long, ByVal demandName As String) As Long
+ Declare Function ENsetdemandname Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal demandIndex As Long, ByVal demandName As String) As Long
-'Basic Link Functions
+'Link Functions
Declare Function ENaddlink Lib "epanet2.dll" (ByVal id As String, ByVal linkType As Long, ByVal fromNode As String, ByVal toNode As String) As Long
- Declare Function ENdeletelink Lib "epanet2.dll" (ByVal linkIndex As Long, ByVal actionCode As Long) As Long
+ Declare Function ENdeletelink Lib "epanet2.dll" (ByVal index As Long, ByVal actionCode As Long) As Long
Declare Function ENgetlinkindex Lib "epanet2.dll" (ByVal id As String, index As Long) As Long
Declare Function ENgetlinkid Lib "epanet2.dll" (ByVal index As Long, ByVal id As String) As Long
Declare Function ENsetlinkid Lib "epanet2.dll" (ByVal index As Long, ByVal newid As String) As Long
- Declare Function ENgetlinktype Lib "epanet2.dll" (ByVal index As Long, code As Long) As Long
- Declare Function ENsetlinktype Lib "epanet2.dll" (index As Long, ByVal code As Long) As Long
+ Declare Function ENgetlinktype Lib "epanet2.dll" (ByVal index As Long, linkType As Long) As Long
+ Declare Function ENsetlinktype Lib "epanet2.dll" (index As Long, ByVal linkType As Long, ByVal actionCode As Long) As Long
Declare Function ENgetlinknodes Lib "epanet2.dll" (ByVal index As Long, node1 As Long, node2 As Long) As Long
Declare Function ENsetlinknodes Lib "epanet2.dll" (ByVal index As Long, ByVal node1 As Long, ByVal node2 As Long) As Long
- Declare Function ENgetlinkvalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, value As Single) As Long
- Declare Function ENsetlinkvalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, ByVal value As Single) As Long
+ Declare Function ENgetlinkvalue Lib "epanet2.dll" (ByVal index As Long, ByVal property As Long, value As Single) As Long
+ Declare Function ENsetlinkvalue Lib "epanet2.dll" (ByVal index As Long, ByVal property As Long, ByVal value As Single) As Long
Declare Function ENsetpipedata Lib "epanet2.dll" (ByVal index As Long, ByVal length As Single, ByVal diam As Single, ByVal rough As Single, ByVal mloss As Single) As Long
'Pump Functions
- Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal pumpIndex As Long, curveIndex As Long) As Long
- Declare Function ENsetheadcurveindex Lib "epanet2.dll" (ByVal pumpIndex As Long, ByVal curveIndex As Long) As Long
- Declare Function ENgetpumptype Lib "epanet2.dll" (ByVal index As Long, PumpType As Long) As Long
+ Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal linkIndex As Long, curveIndex As Long) As Long
+ Declare Function ENsetheadcurveindex Lib "epanet2.dll" (ByVal linkIndex As Long, ByVal curveIndex As Long) As Long
+ Declare Function ENgetpumptype Lib "epanet2.dll" (ByVal linkIndex As Long, pumpType As Long) As Long
'Time Pattern Functions
Declare Function ENaddpattern Lib "epanet2.dll" (ByVal id As String) As Long
Declare Function ENgetpatternindex Lib "epanet2.dll" (ByVal id As String, index As Long) As Long
Declare Function ENgetpatternid Lib "epanet2.dll" (ByVal index As Long, ByVal id As String) As Long
- Declare Function ENgetpatternlen Lib "epanet2.dll" (ByVal index As Long, L As Long) As Long
- Declare Function ENgetpatternvalue Lib "epanet2.dll" (ByVal index As Long, ByVal Period As Long, value As Single) As Long
- Declare Function ENsetpatternvalue Lib "epanet2.dll" (ByVal index As Long, ByVal Period As Long, ByVal value As Single) As Long
+ Declare Function ENgetpatternlen Lib "epanet2.dll" (ByVal index As Long, len_ As Long) As Long
+ Declare Function ENgetpatternvalue Lib "epanet2.dll" (ByVal index As Long, ByVal period As Long, value As Single) As Long
+ Declare Function ENsetpatternvalue Lib "epanet2.dll" (ByVal index As Long, ByVal period As Long, ByVal value As Single) As Long
Declare Function ENgetaveragepatternvalue Lib "epanet2.dll" (ByVal index As Long, value As Single) As Long
- Declare Function ENsetpattern Lib "epanet2.dll" (ByVal index As Long, F As Any, ByVal N As Long) As Long
+ Declare Function ENsetpattern Lib "epanet2.dll" (ByVal index As Long, values As Any, ByVal len_ As Long) As Long
'Data Curve Functions
Declare Function ENaddcurve Lib "epanet2.dll" (ByVal id As String) As Long
Declare Function ENgetcurveindex Lib "epanet2.dll" (ByVal id As String, index As Long) As Long
Declare Function ENgetcurveid Lib "epanet2.dll" (ByVal index As Long, ByVal id As String) As Long
- Declare Function ENgetcurvelen Lib "epanet2.dll" (ByVal index As Long, L As Long) As Long
- Declare Function ENgetcurvetype Lib "epanet2.dll" (ByVal curveIndex As Long, CurveType As Long) As Long
- Declare Function ENgetcurvevalue Lib "epanet2.dll" (ByVal index As Long, ByVal Ptn As Long, X As Single, Y As Single) As Long
- Declare Function ENsetcurvevalue Lib "epanet2.dll" (ByVal index As Long, ByVal Ptn As Long, ByVal X As Single, ByVal Y As Single) As Long
- Declare Function ENgetcurve Lib "epanet2.dll" (ByVal curveIndex As Long, ByVal CurveID As String, nValues As Long, xValues As Any, yValues As Any) As Long
- Declare Function ENsetcurve Lib "epanet2.dll" (ByVal index As Long, X As Any, Y As Any, ByVal N As Long) As Long
+ Declare Function ENgetcurvelen Lib "epanet2.dll" (ByVal index As Long, len_ As Long) As Long
+ Declare Function ENgetcurvetype Lib "epanet2.dll" (ByVal index As Long, type_ As Long) As Long
+ Declare Function ENgetcurvevalue Lib "epanet2.dll" (ByVal curveIndex As Long, ByVal pointIndex As Long, x As Single, y As Single) As Long
+ Declare Function ENsetcurvevalue Lib "epanet2.dll" (ByVal curveIndex As Long, ByVal pointIndex As Long, ByVal x As Single, ByVal y As Single) As Long
+ Declare Function ENgetcurve Lib "epanet2.dll" (ByVal index As Long, ByVal id As String, nPoints As Long, xValues As Any, yValues As Any) As Long
+ Declare Function ENsetcurve Lib "epanet2.dll" (ByVal index As Long, xValues As Any, yValues As Any, ByVal nPoints As Long) As Long
'Simple Control Functions
- Declare Function ENaddcontrol Lib "epanet2.dll" (Cindex As Long, ByVal Ctype As Long, ByVal Lindex As Long, ByVal setting As Single, ByVal Nindex As Long, ByVal Level As Single) As Long
- Declare Function ENdeletecontrol Lib "epanet2.dll" (ByVal Cindex As Long) As Long
- Declare Function ENgetcontrol Lib "epanet2.dll" (ByVal Cindex As Long, Ctype As Long, Lindex As Long, setting As Single, Nindex As Long, Level As Single) As Long
- Declare Function ENsetcontrol Lib "epanet2.dll" (ByVal Cindex As Long, ByVal Ctype As Long, ByVal Lindex As Long, ByVal setting As Single, ByVal Nindex As Long, ByVal Level As Single) As Long
+ Declare Function ENaddcontrol Lib "epanet2.dll" (ByVal type_ As Long, ByVal linkIndex As Long, ByVal setting As Single, ByVal nodeIndex As Long, ByVal level As Single, index As Long) As Long
+ Declare Function ENdeletecontrol Lib "epanet2.dll" (ByVal index As Long) As Long
+ Declare Function ENgetcontrol Lib "epanet2.dll" (ByVal index As Long, type_ As Long, linkIndex As Long, setting As Single, nodeIndex As Long, level As Single) As Long
+ Declare Function ENsetcontrol Lib "epanet2.dll" (ByVal index As Long, ByVal type_ As Long, ByVal linkIndex As Long, ByVal setting As Single, ByVal nodeIndex As Long, ByVal level As Single) As Long
-'Rue-Based Control Functions
+'Rule-Based Control Functions
Declare Function ENaddrule Lib "epanet2.dll" (ByVal rule As String) As Long
Declare Function ENdeleterule Lib "epanet2.dll" (ByVal index As Long) As Long
- Declare Function ENgetrule Lib "epanet2.dll" (ByVal index As Long, nPremises As Long, nTrueActions As Long, nFalseActions As Long, priority As Single) As Long
- Declare Function ENgetruleID Lib "epanet2.dll" (ByVal indexRule As Long, ByVal id As String) As Long
+ Declare Function ENgetrule Lib "epanet2.dll" (ByVal index As Long, nPremises As Long, nThenActions As Long, nElseActions As Long, priority As Single) As Long
+ Declare Function ENgetruleID Lib "epanet2.dll" (ByVal index As Long, ByVal id As String) As Long
Declare Function ENsetrulepriority Lib "epanet2.dll" (ByVal index As Long, ByVal priority As Single) As Long
- Declare Function ENgetpremise Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexPremise As Long, logop As Long, object As Long, indexObj As Long, variable As Long, relop As Long, status As Long, value As Single) As Long
- Declare Function ENsetpremise Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexPremise As Long, ByVal logop As Long, ByVal object As Long, ByVal indexObj As Long, ByVal variable As Long, ByVal relop As Long, ByVal status As Long, ByVal value As Single) As Long
- Declare Function ENsetpremiseindex Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexPremise As Long, ByVal indexObj As Long) As Long
- Declare Function ENsetpremisestatus Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexPremise As Long, ByVal status As Long) As Long
- Declare Function ENsetpremisevalue Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexPremise As Long, ByVal value As Single) As Long
- Declare Function ENgetthenaction Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexAction As Long, indexLink As Long, status As Long, setting As Single) As Long
- Declare Function ENsetthenaction Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexAction As Long, ByVal indexLink As Long, ByVal status As Long, ByVal setting As Single) As Long
- Declare Function ENgetelseaction Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexAction As Long, indexLink As Long, status As Long, setting As Single) As Long
- Declare Function ENsetelseaction Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexAction As Long, ByVal indexLink As Long, ByVal status As Long, ByVal setting As Single) As Long
+ Declare Function ENgetpremise Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal premiseIndex As Long, logop As Long, object As Long, objIndex As Long, variable As Long, relop As Long, status As Long, value As Single) As Long
+ Declare Function ENsetpremise Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal premiseIndex As Long, ByVal logop As Long, ByVal object As Long, ByVal objIndex As Long, ByVal variable As Long, ByVal relop As Long, ByVal status As Long, ByVal value As Single) As Long
+ Declare Function ENsetpremiseindex Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal premiseIndex As Long, ByVal objIndex As Long) As Long
+ Declare Function ENsetpremisestatus Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal premiseIndex As Long, ByVal status As Long) As Long
+ Declare Function ENsetpremisevalue Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal premiseIndex As Long, ByVal value As Single) As Long
+ Declare Function ENgetthenaction Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal actionIndex As Long, linkIndex As Long, status As Long, setting As Single) As Long
+ Declare Function ENsetthenaction Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal actionIndex As Long, ByVal linkIndex As Long, ByVal status As Long, ByVal setting As Single) As Long
+ Declare Function ENgetelseaction Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal actionIndex As Long, linkIndex As Long, status As Long, setting As Single) As Long
+ Declare Function ENsetelseaction Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal actionIndex As Long, ByVal linkIndex As Long, ByVal status As Long, ByVal setting As Single) As Long
diff --git a/include/epanet2.h b/include/epanet2.h
index 44c767b..8509641 100644
--- a/include/epanet2.h
+++ b/include/epanet2.h
@@ -3,21 +3,35 @@
Project: OWA EPANET
Version: 2.2
Module: epanet2.h
- Description: declarations for the legacy EPANET 2 API functions
+ Description: declarations of the legacy style EPANET 2 API functions
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
- Last Updated: 12/31/2018
+ Last Updated: 01/08/2019
******************************************************************************
*/
+/*
+This module contains declarations of the legacy style EPANET API functions, with
+version 2.2 updates, that apply only to single threaded applications. A second
+set of thread safe API functions that allows one to run concurrent analyses on
+multiple EPANET projects can be found in the epanet2_2.h header file. The two
+APIs share the same function names and arguments with the difference being that
+the thread safe functions use the prefix "EN_" and include an extra argument that
+represents the EPANET project being analyzed. To avoid unneccesary repetition,
+only the thread safe API functions have been documented. To see a description of
+a legacy style API function declared here please refer to its complementary named
+function in epanet2_2.h.
+*/
#ifndef EPANET2_H
#define EPANET2_H
-
-// the toolkit can be compiled with support for double-precision as well.
-// just make sure that you use the correct #define in your client code.
+// The legacy style EPANET API can be compiled with support for either single
+// precision or double precision floating point arguments, with the default
+// being single precision. To compile for double precision one must #define
+// EN_API_FLOAT_TYPE as double both here and in any client code that uses the
+// API.
#ifndef EN_API_FLOAT_TYPE
#define EN_API_FLOAT_TYPE float
#endif
@@ -52,7 +66,6 @@
#include "epanet2_enums.h"
-
// --- Declare the EPANET toolkit functions
#if defined(__cplusplus)
extern "C" {
@@ -65,54 +78,17 @@ extern "C" {
********************************************************************/
- /**
- brief runs a complete EPANET simulation
- param inpFile pointer to name of input file (must exist)
- param rptFile pointer to name of report file (to be created)
- param binOutFile pointer to name of binary output file (to be created)
- param callback a callback function that takes a character string (char *) as its only parameter.
- return error code
-
- The callback function should reside in and be used by the calling
- code to display the progress messages that EPANET generates
- as it carries out its computations. If this feature is not
- needed then the argument should be NULL.
- */
int DLLEXPORT ENepanet(const char *inpFile, const char *rptFile,
- const char *binOutFile, void (*callback) (char *));
+ const char *outFile, void (*pviewprog) (char *));
- /**
- @brief Initializes an EPANET session
- @param rptFile pointer to name of report file (to be created)
- @param binOutFile pointer to name of binary output file (to be created)
- @param UnitsType flow units flag
- @param HeadlossFormula headloss formula flag
- @return error code
- */
- int DLLEXPORT ENinit(const char *rptFile, const char *binOutFile,
- int UnitsType, int HeadlossFormula);
+ int DLLEXPORT ENinit(const char *rptFile, const char *outFile,
+ int unitsType, int headlossType);
- /**
- @brief Opens EPANET input file & reads in network data
- @param inpFile pointer to name of input file (must exist)
- @param rptFile pointer to name of report file (to be created)
- @param binOutFile pointer to name of binary output file (to be created)
- @return error code
- */
int DLLEXPORT ENopen(const char *inpFile, const char *rptFile,
- const char *binOutFile);
+ const char *outFile);
- /**
- @brief Saves current data to "INP" formatted text file.
- @param filename The file path to create
- @return Error code
- */
int DLLEXPORT ENsaveinpfile(const char *filename);
- /**
- @brief Frees all memory and files used by EPANET
- @return Error code
- */
int DLLEXPORT ENclose();
/********************************************************************
@@ -121,79 +97,22 @@ extern "C" {
********************************************************************/
- /**
- @brief Solves the network hydraulics for all time periods
- @return Error code
- */
int DLLEXPORT ENsolveH();
- /**
- @brief Saves hydraulic results to binary file
- @return Error code
-
- Must be called before ENreport() if no WQ simulation has been made.
- Should not be called if ENsolveQ() will be used.
- */
int DLLEXPORT ENsaveH();
- /**
- @brief Sets up data structures for hydraulic analysis
- @return Error code
- */
int DLLEXPORT ENopenH();
- /**
- @brief Initializes hydraulic analysis
- @param initFlag 2-digit initialization flag
- @return Error code
-
- The initialization flag is a two digit number where the 1st (left) digit
- indicates if link flows should be re-initialized (1) or not (0), and the
- 2nd digit indicates if hydraulic results should be saved to file (1) or not (0).
- */
int DLLEXPORT ENinitH(int initFlag);
- /**
- @brief Run a hydraulic solution period
- @param[out] currentTime The current simulation time in seconds
- @return Error or warning code
- @see ENsolveH
-
- This function is used in a loop with ENnextH() to run
- an extended period hydraulic simulation.
- See ENsolveH() for an example.
- */
int DLLEXPORT ENrunH(long *currentTime);
- /**
- @brief Determine time (in seconds) until next hydraulic event
- @param[out] tStep Time (seconds) until next hydraulic event. 0 marks end of simulation period.
- @return Error code
-
- This function is used in a loop with ENrunH() to run an extended period hydraulic simulation.
- See ENsolveH() for an example.
- */
int DLLEXPORT ENnextH(long *tStep);
-
- /**
- @brief Frees data allocated by hydraulics solver
- @return Error code
- */
int DLLEXPORT ENcloseH();
- /**
- @brief Copies binary hydraulics file to disk
- @param filename Name of file to be created
- @return Error code
- */
int DLLEXPORT ENsavehydfile(char *filename);
- /**
- @brief Opens previously saved binary hydraulics file
- @param filename Name of file to be used
- @return Error code
- */
int DLLEXPORT ENusehydfile(char *filename);
/********************************************************************
@@ -202,61 +121,18 @@ extern "C" {
********************************************************************/
- /**
- @brief Solves for network water quality in all time periods
- @return Error code
- */
int DLLEXPORT ENsolveQ();
- /**
- @brief Sets up data structures for WQ analysis
- @return Error code
- */
int DLLEXPORT ENopenQ();
- /**
- @brief Initializes water quality analysis
- @param saveFlag EN_SAVE (1) if results saved to file, EN_NOSAVE (0) if not
- @return Error code
- */
int DLLEXPORT ENinitQ(int saveFlag);
- /**
- @brief Retrieves hydraulic & WQ results at time t.
- @param[out] currentTime Current simulation time, in seconds.
- @return Error code
-
- This function is used in a loop with ENnextQ() to run
- an extended period WQ simulation. See ENsolveQ() for
- an example.
- */
int DLLEXPORT ENrunQ(long *currentTime);
- /**
- @brief Advances WQ simulation to next hydraulic event.
- @param[out] tStep Time in seconds until next hydraulic event. 0 marks end of simulation period.
- @return Error code
-
- This function is used in a loop with ENrunQ() to run
- an extended period WQ simulation. See ENsolveQ() for
- an example.
- */
int DLLEXPORT ENnextQ(long *tStep);
- /**
- @brief Advances WQ simulation by a single WQ time step
- @param[out] timeLeft Time left in overall simulation (in seconds)
- @return Error code
-
- This function is used in a loop with ENrunQ() to run
- an extended period WQ simulation.
- */
int DLLEXPORT ENstepQ(long *timeLeft);
- /**
- @brief Frees data allocated by water quality solver.
- @return Error code.
- */
int DLLEXPORT ENcloseQ();
/********************************************************************
@@ -265,72 +141,23 @@ extern "C" {
********************************************************************/
- /**
- @brief Writes line of text to the report file.
- @param line Text string to write
- @return Error code.
- */
int DLLEXPORT ENwriteline(char *line);
- /**
- @brief Writes simulation report to the report file
- @return Error code
- */
int DLLEXPORT ENreport();
- /**
- @brief Resets report options to default values
- @return Error code
- */
int DLLEXPORT ENresetreport();
- /**
- @brief Processes a reporting format command
- @return Error code
- */
- int DLLEXPORT ENsetreport(char *reportFormat);
+ int DLLEXPORT ENsetreport(char *format);
- /**
- @brief Set the level of hydraulic status reporting.
- @param code Status reporting code (see EN_StatusReport).
- @return Error code.
- */
- int DLLEXPORT ENsetstatusreport(int code);
+ int DLLEXPORT ENsetstatusreport(int level);
- /**
- @brief Get the API version number.
- @param[out] version The version of EPANET
- @return Error code.
-
- The version number is to be interpreted with implied decimals, i.e.,
- "20100" == "2(.)01(.)00"
- */
int DLLEXPORT ENgetversion(int *version);
- /**
- @brief Retrieves the number of components of a given type in the network.
- @param code Component code (see EPANET2.H)
- @param[out] count Number of components in network
- @return Error code
- */
- int DLLEXPORT ENgetcount(int code, int *count);
+ int DLLEXPORT ENgetcount(int object, int *count);
- /**
- @brief Get the text of an error code.
- @param errcode The error code
- @param[out] errmsg The error string represented by the code
- @param maxLen The maximum number of characters to copy into the char pointer errmsg
- @return Error code
- */
int DLLEXPORT ENgeterror(int errcode, char *errmsg, int maxLen);
- /**
- @brief Get hydraulic simulation statistic
- @param code The type of statistic to get
- @param[out] value The value of the statistic
- @return Error code
- */
- int DLLEXPORT ENgetstatistic(int code, EN_API_FLOAT_TYPE* value);
+ int DLLEXPORT ENgetstatistic(int type, EN_API_FLOAT_TYPE* value);
/********************************************************************
@@ -338,87 +165,25 @@ extern "C" {
********************************************************************/
- /**
- @brief Gets value for an analysis option
- @param code Option code (see EPANET2.H)
- @param[out] value Option value
- @return Error code
- */
- int DLLEXPORT ENgetoption(int code, EN_API_FLOAT_TYPE *value);
+ int DLLEXPORT ENgetoption(int option, EN_API_FLOAT_TYPE *value);
- /**
- @brief Set a value for an anlysis option.
- @param code The code for the desired option.
- @param v The desired value for the option specified.
- @return Error code.
- @see EN_Option
- */
- int DLLEXPORT ENsetoption(int code, EN_API_FLOAT_TYPE v);
+ int DLLEXPORT ENsetoption(int option, EN_API_FLOAT_TYPE value);
- /**
- @brief Retrieves the flow units code
- @param[out] code Code of flow units in use
- @return Error code
- */
- int DLLEXPORT ENgetflowunits(int *code);
+ int DLLEXPORT ENgetflowunits(int *units);
- /**
- @brief Sets the flow units
- @param code Code of flow units to use
- @return Error code
- */
- int DLLEXPORT ENsetflowunits(int code);
+ int DLLEXPORT ENsetflowunits(int units);
- /**
- @brief Retrieves value of specific time parameter.
- @param code Time parameter code
- @param[out] value Value of time parameter.
- @return Error code
- */
- int DLLEXPORT ENgettimeparam(int code, long *value);
+ int DLLEXPORT ENgettimeparam(int param, long *value);
- /**
- @brief Set the value for a time parameter.
- @param code The code for the parameter to set.
- @param value The desired value of the parameter.
- @return Error code.
- @see EN_TimeProperty
- */
- int DLLEXPORT ENsettimeparam(int code, long value);
+ int DLLEXPORT ENsettimeparam(int param, long value);
- /**
- @brief Get information about the type of water quality analysis requested.
- @param[out] qualcode Type of analysis to be made (see EN_QualityType).
- @param[out] chemname Name of the quality constituent.
- @param[out] chemunits Concentration units of the constituent.
- @param[out] tracenode ID of node being traced (if applicable).
- @return Error code.
- */
- int DLLEXPORT ENgetqualinfo(int *qualcode, char *chemname, char *chemunits,
- int *tracenode);
+ int DLLEXPORT ENgetqualinfo(int *qualType, char *chemName, char *chemUnits,
+ int *traceNode);
- /**
- @brief Retrieve the type of quality analytis to be run.
- @param[out] qualcode The quality analysis code number.
- @param[out] tracenode The index of node being traced, if qualcode == trace
- @return Error code
- @see ENsetqualtype
- */
- int DLLEXPORT ENgetqualtype(int *qualcode, int *tracenode);
+ int DLLEXPORT ENgetqualtype(int *qualType, int *traceNode);
- /**
- @brief Set the type of quality analysis called for.
- @param qualcode Type of analysis to be made (see EN_QualityType).
- @param chemname Name of the quality constituent.
- @param chemunits Concentration units of the constituent.
- @param tracenode ID of node being traced (if applicable).
- @return Error code.
-
- Note: "chemname" and "chemunits" only apply when "qualcode" is EN_CHEM.
- "tracenode" only applies when 'qualcode" is EN_TRACE.
- */
- int DLLEXPORT ENsetqualtype(int qualcode, char *chemname, char *chemunits,
- char *tracenode);
+ int DLLEXPORT ENsetqualtype(int qualType, char *chemName, char *chemUnits,
+ char *traceNode);
/********************************************************************
@@ -426,130 +191,32 @@ extern "C" {
********************************************************************/
- /**
- @brief Add a new node to the project.
- @param id The name of the node to be added.
- @param nodeType The type of node being added (see EN_NodeType)
- @return Error code.
- */
- int DLLEXPORT ENaddnode(char *id, EN_NodeType nodeType);
+ int DLLEXPORT ENaddnode(char *id, int nodeType);
- /**
- @brief Delete a node from the project.
- @param index The index of the node to be deleted.
- @param actionCode The action taken if any control contains the node and its links.
- @return Error code.
+ int DLLEXPORT ENdeletenode(int index, int actionCode);
- If 'actionCode' is EN_UNCONDITIONAL then the node, its incident links and all
- simple and rule-based controls that contain them are deleted. If set to
- EN_CONDITIONAL then the node is not deleted if it or its incident links appear
- in any controls and an error code is returned.
+ int DLLEXPORT ENgetnodeindex(char *id, int *index);
- */
- int DLLEXPORT ENdeletenode(int index, int actionCode);
+ int DLLEXPORT ENgetnodeid(int index, char *id);
- /**
- @brief Get index of node with specified ID
- @param id The string ID of the node
- @param[out] index The node's index (first node is index 1)
- @return Error code
- @see ENgetnodeid
- */
- int DLLEXPORT ENgetnodeindex(char *id, int *index);
+ int DLLEXPORT ENsetnodeid(int index, char *newid);
- /**
- @brief Get the string ID of the specified node.
- @param index The index of the node (first node is index 1)
- @param[out] id The string ID of the specified node.
- @return Error code
- @see ENgetnodeindex
+ int DLLEXPORT ENgetnodetype(int index, int *nodeType);
- The ID string must be sized to hold at least MAXID characters.
- */
- int DLLEXPORT ENgetnodeid(int index, char *id);
+ int DLLEXPORT ENgetnodevalue(int index, int property, EN_API_FLOAT_TYPE *value);
- /**
- @brief Change the ID name for a node.
- @param index The index of a node. First node is index 1.
- @param newid A string containing the node's new ID name.
- @return Error code.
- */
- int DLLEXPORT ENsetnodeid(int index, char *newid);
+ int DLLEXPORT ENsetnodevalue(int index, int property, EN_API_FLOAT_TYPE value);
- /**
- @brief Get the type of node with specified index.
- @param index The index of a node (first node is index 1)
- @param[out] code The type code for the node (see the EN_NodeType enumeration)
- @return Error code
- */
- int DLLEXPORT ENgetnodetype(int index, int *code);
-
- /**
- @brief Get a property value for specified node
- @param index The index of a node (first node is index 1).
- @param code The property type code
- @param[out] value The value of the node's property.
- @return Error code
- @see EN_NodeProperty
- */
- int DLLEXPORT ENgetnodevalue(int index, int code, EN_API_FLOAT_TYPE *value);
-
- /**
- @brief Set a property value for a node.
- @param index The index of a node. First node is index 1.
- @param code The code for the proprty to set.
- @param v The value to set for this node and property.
- @return Error code.
- @see EN_NodeProperty
- */
- int DLLEXPORT ENsetnodevalue(int index, int code, EN_API_FLOAT_TYPE v);
-
- /**
- @brief Set a group of properties for a junction node.
- @param index The index of a junction node.
- @param elev The junction's elevation.
- @param dmnd The junction's primary base demand.
- @param dmndpat The name of the demand's time pattern ("" for no pattern)
- @return Error code.
- */
- int DLLEXPORT ENsetjuncdata(int index, EN_API_FLOAT_TYPE elev,
+ int DLLEXPORT ENsetjuncdata(int index, EN_API_FLOAT_TYPE elev,
EN_API_FLOAT_TYPE dmnd, char *dmndpat);
- /**
- @brief Set a group of properties for a tank node.
- @param index The index of a tank node.
- @param elev The tank's bottom elevation.
- @param initlvl The initial water level in the tank.
- @param minlvl The minimum water level for the tank.
- @param maxlvl The maximum water level for the tank.
- @param diam The tank's diameter (0 if volume curve used).
- @param minvol The volume of the tank at its minimum water level.
- @param volcurve The name of the tank's volume curve ("" for no curve)
- @return Error code.
- */
int DLLEXPORT ENsettankdata(int index, EN_API_FLOAT_TYPE elev,
EN_API_FLOAT_TYPE initlvl, EN_API_FLOAT_TYPE minlvl,
EN_API_FLOAT_TYPE maxlvl, EN_API_FLOAT_TYPE diam,
EN_API_FLOAT_TYPE minvol, char *volcurve);
- /**
- @brief Get coordinates (x,y) for a node.
- @param index The index of a node (first node is index 1).
- @param[out] x X-value of node's coordinate
- @param[out] y Y-value of node's coordinate
- @return Error code
- @see ENsetcoord
- */
int DLLEXPORT ENgetcoord(int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y);
- /**
- @brief Set coordinates (x,y) for a node.
- @param index The index of a node (first node is index 1)
- @param x X-value of node's coordinate
- @param y Y-value of node's coordinate
- @return Error code
- @see ENgetcoord
- */
int DLLEXPORT ENsetcoord(int index, EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y);
/********************************************************************
@@ -558,91 +225,27 @@ extern "C" {
********************************************************************/
- /**
- @brief Retrieves the type of demand model in use and its parameters
- @param[out] type Type of demand model (EN_DDA or EN_PDA)
- @param[out] pmin Pressure below which there is no demand
- @param[out] preq Pressure required to deliver full demand
- @param[out] pexp Pressure exponent in demand function
- @return Error code
- */
- int DLLEXPORT ENgetdemandmodel(int *type, EN_API_FLOAT_TYPE *pmin,
- EN_API_FLOAT_TYPE *preq, EN_API_FLOAT_TYPE *pexp);
+ int DLLEXPORT ENgetdemandmodel(int *model, EN_API_FLOAT_TYPE *pmin,
+ EN_API_FLOAT_TYPE *preq, EN_API_FLOAT_TYPE *pexp);
- /**
- @brief Sets the type of demand model to use and its parameters
- @param type Type of demand model (EN_DDA or EN_PDA)
- @param pmin Pressure below which there is no demand
- @param preq Pressure required to deliver full demand
- @param pexp Pressure exponent in demand function
- @return Error code
- */
- int DLLEXPORT ENsetdemandmodel(int type, EN_API_FLOAT_TYPE pmin,
- EN_API_FLOAT_TYPE preq, EN_API_FLOAT_TYPE pexp);
+ int DLLEXPORT ENsetdemandmodel(int model, EN_API_FLOAT_TYPE pmin,
+ EN_API_FLOAT_TYPE preq, EN_API_FLOAT_TYPE pexp);
- /**
- @brief Get the number of demand categories for a node.
- @param nodeIndex The index of a node (first node is index 1)
- @param[out] numDemands The number of demand categories
- @return Error code
- */
- int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands);
+ int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands);
- /**
- @brief Get a node's base demand for a specified category.
- @param nodeIndex The index of a node (first node is index 1)
- @param demandIndex The index of the demand category (starting at 1)
- @return Error code
- */
- int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIndex,
- EN_API_FLOAT_TYPE *baseDemand);
+ int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIndex,
+ EN_API_FLOAT_TYPE *baseDemand);
- /**
- @brief Set a node's base demand for a demand category.
- @param nodeIndex The node's index.
- @param demandIndex The index of one of the node's demand categories.
- @param baseDemand The base demand for the selected category.
- @return Error code.
- @see ENgetbasedemand
- */
- int DLLEXPORT ENsetbasedemand(int nodeIndex, int demandIndex,
- EN_API_FLOAT_TYPE baseDemand);
+ int DLLEXPORT ENsetbasedemand(int nodeIndex, int demandIndex,
+ EN_API_FLOAT_TYPE baseDemand);
- /**
- @brief Get the index of the demand pattern assigned to a node for a category index.
- @param nodeIndex The index of a node (first node is index 1).
- @param demandIndex The index of a category (first category is index 1).
- @param[out] pattIndex The index of the pattern for this node and category.
- @return Error code
- */
- int DLLEXPORT ENgetdemandpattern(int nodeIndex, int demandIndex, int *pattIndex);
+ int DLLEXPORT ENgetdemandpattern(int nodeIndex, int demandIndex, int *patIndex);
- /**
- @brief Set the time pattern assigned to a node's demand category.
- @param nodeIndex The node's index.
- @param demandIndex The index of one of the node's demand categories.
- @param pattIndex The index of a time pattern applied to this demand category.
- @return Error code
- */
- int DLLEXPORT ENsetdemandpattern(int nodeIndex, int demandIndex, int patIndex);
+ int DLLEXPORT ENsetdemandpattern(int nodeIndex, int demandIndex, int patIndex);
- /**
- @brief Retrieve the name of a node's demand category.
- @param nodeIndex The node's index.
- @param demandIdx Index of the node's demand.
- @param demandName[out] Name of the category the demand belongs to.
- @return Error code.
- */
- int DLLEXPORT ENgetdemandname(int nodeIndex, int demandIdx, char *demandName);
+ int DLLEXPORT ENgetdemandname(int nodeIndex, int demandIndex, char *demandName);
- /**
- @brief Set the name of a node's demand category.
- @param nodeIndex The node's index.
- @param demandIdx Index of the node's demand.
- @param demandName Name for the category the demand belongs to.
- @return Error code.
- */
- int DLLEXPORT ENsetdemandname(int nodeIndex, int demandIdx, char *demandName);
+ int DLLEXPORT ENsetdemandname(int nodeIndex, int demandIndex, char *demandName);
/********************************************************************
@@ -650,165 +253,43 @@ extern "C" {
********************************************************************/
- /**
- @brief Add a new link to the project.
- @param id The name of the link to be added.
- @param linkType The type of link being added (see EN_LinkType)
- @param fromNode The id of the link's starting node
- @param toNode The id of the link's ending node
- @return Error code.
- */
- int DLLEXPORT ENaddlink(char *id, EN_LinkType linkType, char *fromNode, char *toNode);
+ int DLLEXPORT ENaddlink(char *id, int linkType, char *fromNode, char *toNode);
- /**
- @brief Delete a link from the project.
- @param index The index of the link to be deleted.
- @param ctrlsCode The action taken if any control contains the link.
- @return Error code.
-
- If 'actionCode' is EN_UNCONDITIONAL then the link an all simple and rule-based
- controls that contain it are deleted. If set to EN_CONDITIONAL then the link
- is not deleted if it appears in any control and an error code is returned.
-
- */
int DLLEXPORT ENdeletelink(int index, int actionCode);
- /**
- @brief Get the index of a Link with specified ID.
- @param id The string ID of a link.
- @param[out] index The index of the named link (first link is index 1)
- @return Error code
- @see ENgetlinkid
- */
- int DLLEXPORT ENgetlinkindex(char *id, int *index);
+ int DLLEXPORT ENgetlinkindex(char *id, int *index);
- /**
- @brief Get the string ID of a link with specified index
- @param index The index of a link (first link is index 1)
- @param[out] id The ID of the link.
- @return Error code
- @see ENgetlinkindex
+ int DLLEXPORT ENgetlinkid(int index, char *id);
- The ID string must be sized to hold at least MAXID characters.
- */
- int DLLEXPORT ENgetlinkid(int index, char *id);
-
- /**
- @brief Change the ID name for a link.
- @param index The index of a link. First link is index 1.
- @param newid A string containing the link's new ID name.
- @return Error code.
- */
int DLLEXPORT ENsetlinkid(int index, char *newid);
- /**
- @brief Get the link type code for a specified link
- @param index The index of a link (first link is index 1)
- @param[out] code The type code of the link (see the EN_LinkType enumeration)
- @return Error code
- @see EN_LinkType
- */
- int DLLEXPORT ENgetlinktype(int index, EN_LinkType *code);
+ int DLLEXPORT ENgetlinktype(int index, int *linkType);
- /**
- @brief Set the link type code for a specified link
- @param[in,out] index The index of a link before [in] and after [out] the type change
- @param code The new type code of the link (see EN_LinkType).
- @param actionCode Action taken if any controls contain the link.
- @return Error code
- @see the EN_LinkType enumeration
+ int DLLEXPORT ENsetlinktype(int *index, int linkType, int actionCode);
- If 'actionCode' is EN_UNCONDITIONAL then all simple and rule-based controls that
- contain the link are deleted when the link's type is changed. If set to
- EN_CONDITIONAL then the type change is cancelled if the link appears in any
- control and an error code is returned.
- */
- int DLLEXPORT ENsetlinktype(int *index, EN_LinkType Code, int actionCode);
+ int DLLEXPORT ENgetlinknodes(int index, int *node1, int *node2);
- /**
- @brief Get the indexes of a link's start- and end-nodes.
- @param index The index of a link (first link is index 1)
- @param[out] node1 The index of the link's start node (first node is index 1).
- @param[out] node2 The index of the link's end node (first node is index 1).
- @return Error code
- @see ENgetnodeid, ENgetlinkid
- */
- int DLLEXPORT ENgetlinknodes(int index, int *node1, int *node2);
+ int DLLEXPORT ENsetlinknodes(int index, int node1, int node2);
- /**
- @brief Set the indexes of a link's start- and end-nodes.
- @param index The index of a link (first link is index 1)
- @param node1 The index of the link's start node (first node is index 1).
- @param node2 The index of the link's end node (first node is index 1).
- @return Error code
- @see ENsetnodeid, ENsetlinkid
- */
- int DLLEXPORT ENsetlinknodes(int index, int node1, int node2);
+ int DLLEXPORT ENgetlinkvalue(int index, int property, EN_API_FLOAT_TYPE *value);
- /**
- @brief Get a property value for specified link.
- @param index The index of a node (first node is index 1).
- @param code The parameter desired.
- @param[out] value The value of the link's specified property.
- @return Error code
- @see ENgetnodevalue, EN_LinkProperty
- */
- int DLLEXPORT ENgetlinkvalue(int index, int code, EN_API_FLOAT_TYPE *value);
+ int DLLEXPORT ENsetlinkvalue(int index, int property, EN_API_FLOAT_TYPE value);
- /**
- @brief Set a property value for a link.
- @param index The index of a link. First link is index 1.
- @param code The code for the property to set.
- @param v The value to set for this link and property.
- @return Error code.
- @see EN_LinkProperty
- */
- int DLLEXPORT ENsetlinkvalue(int index, int code, EN_API_FLOAT_TYPE v);
-
- /**
- @brief Set a collection of property values for a pipe link.
- @param index The index of a pipe link.
- @param length The pipe's length.
- @param diam The pipe's diameter.
- @param rough The pipe's roughness coefficient.
- @param mloss The pipe's minor loss coefficient.
- @return Error code.
- */
int DLLEXPORT ENsetpipedata(int index, EN_API_FLOAT_TYPE length,
EN_API_FLOAT_TYPE diam, EN_API_FLOAT_TYPE rough,
EN_API_FLOAT_TYPE mloss);
-
/********************************************************************
Pump Functions
********************************************************************/
- /**
- @brief Get the type of pump
- @param linkIndex The index of the pump element
- @param[out] outType The integer-typed pump curve type signifier (output parameter)
- @return Error code
- @see EN_PumpType
- */
- int DLLEXPORT ENgetpumptype(int linkIndex, int *outType);
+ int DLLEXPORT ENgetpumptype(int linkIndex, int *pumpType);
- /**
- @brief Retrieves the curve index for a specified pump index.
- @param pumpIndex The index of a pump
- @param[out] curveIndex The index of the curve used by the pump.
- @return Error code.
- */
- int DLLEXPORT ENgetheadcurveindex(int pumpIndex, int *curveIndex);
+ int DLLEXPORT ENgetheadcurveindex(int linkIndex, int *curveIndex);
- /**
- @brief Sets the curve id for a specified pump index.
- @param pumpIndex The index of the pump
- @param curveIndex The index of the curve used by the pump
- @return Error code.
- */
- int DLLEXPORT ENsetheadcurveindex(int pumpIndex, int curveIndex);
+ int DLLEXPORT ENsetheadcurveindex(int linkIndex, int curveIndex);
/********************************************************************
@@ -816,75 +297,21 @@ extern "C" {
********************************************************************/
- /**
- @brief Add a new time pattern.
- @param id The string ID of the pattern to add.
- @return Error code.
- @see ENgetpatternindex
- */
- int DLLEXPORT ENaddpattern(char *id);
+ int DLLEXPORT ENaddpattern(char *id);
- /**
- @brief Retrieves the index of the time pattern with specified ID
- @param id String ID of the time pattern
- @param[out] index Index of the specified time pattern
- @return Error code
- @see ENgetpatternid
- */
- int DLLEXPORT ENgetpatternindex(char *id, int *index);
+ int DLLEXPORT ENgetpatternindex(char *id, int *index);
- /**
- @brief Retrieves ID of a time pattern with specific index.
- @param index The index of a time pattern.
- @param[out] id The string ID of the time pattern.
- @return Error code
- @see ENgetpatternindex
- */
- int DLLEXPORT ENgetpatternid(int index, char *id);
+ int DLLEXPORT ENgetpatternid(int index, char *id);
- /**
- @brief Retrieves the number of multipliers in a time pattern.
- @param index The index of a time pattern.
- @param[out] len The length of the time pattern.
- @return Error code
- */
- int DLLEXPORT ENgetpatternlen(int index, int *len);
+ int DLLEXPORT ENgetpatternlen(int index, int *len);
- /**
- @brief Retrive a multiplier from a pattern for a specific time period.
- @param index The index of a time pattern
- @param period The pattern time period. First time period is 1.
- @param[out] value Pattern multiplier
- @return Error code
- */
- int DLLEXPORT ENgetpatternvalue(int index, int period, EN_API_FLOAT_TYPE *value);
+ int DLLEXPORT ENgetpatternvalue(int index, int period, EN_API_FLOAT_TYPE *value);
- /**
- @brief Set the multiplier for a specific pattern at a specific period.
- @param index The index of a pattern. First pattern is index 1.
- @param period The period of the pattern to set.
- @param value The value of the multiplier to set.
- @return Error code.
- */
- int DLLEXPORT ENsetpatternvalue(int index, int period, EN_API_FLOAT_TYPE value);
+ int DLLEXPORT ENsetpatternvalue(int index, int period, EN_API_FLOAT_TYPE value);
- /**
- @brief Retrieve the average multiplier value in a time pattern
- @param index The index of a time pattern
- @param[out] value The average of all of this time pattern's values
- @return Error code
- */
- int DLLEXPORT ENgetaveragepatternvalue(int index, EN_API_FLOAT_TYPE *value);
+ int DLLEXPORT ENgetaveragepatternvalue(int index, EN_API_FLOAT_TYPE *value);
- /**
- @brief Set multipliers for a specific pattern
- @param index The index of a pattern. First pattern is index 1.
- @param f An array of multipliers
- @param len The length of array f.
- @return Error code.
- @see ENgetpatternindex
- */
- int DLLEXPORT ENsetpattern(int index, EN_API_FLOAT_TYPE *f, int len);
+ int DLLEXPORT ENsetpattern(int index, EN_API_FLOAT_TYPE *values, int len);
/********************************************************************
@@ -892,100 +319,27 @@ extern "C" {
********************************************************************/
- /**
- @brief Add a new curve to the project.
- @param id The name of the curve to be added.
- @return Error code.
- @see ENgetcurveindex ENsetcurve
- */
- int DLLEXPORT ENaddcurve(char *id);
+ int DLLEXPORT ENaddcurve(char *id);
- /**
- @brief Retrieve the index of a curve given its name.
- @param id The ID name of a curve.
- @param[out] index The index of the named curve.
- @return Error code.
- @see ENgetcurveid
- */
- int DLLEXPORT ENgetcurveindex(char *id, int *index);
+ int DLLEXPORT ENgetcurveindex(char *id, int *index);
- /**
- @brief Retrieve the ID name of a curve given its index.
- @param index The index of a curve.
- @param[out] id The ID of the specified curve.
- @return Error code.
- @see ENsetcurveindex
+ int DLLEXPORT ENgetcurveid(int index, char *id);
- NOTE: 'id' must be sized to hold MAXID characters.
- */
- int DLLEXPORT ENgetcurveid(int index, char *id);
+ int DLLEXPORT ENgetcurvelen(int index, int *len);
- /**
- @brief Retrieve the number of points in a curve.
- @param index The index of a curve.
- @param[out] len The number of data points assigned to the curve.
- @return Error code.
- @see ENgetcurvevalue
- */
- int DLLEXPORT ENgetcurvelen(int index, int *len);
+ int DLLEXPORT ENgetcurvetype(int index, int *type);
- /**
- @brief Get the type of a curve
- @param curveIndex The index of the curve element
- @param[out] outType The integer-typed curve curve type signifier (output parameter)
- @return Error code
- @see EN_CurveType
- */
- int DLLEXPORT ENgetcurvetype(int curveIndex, int *outType);
+ int DLLEXPORT ENgetcurvevalue(int curveIndex, int pointIndex,
+ EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y);
- /**
- @brief Retrieve an x,y data point for a curve.
- @param curveIndex The index of a curve.
- @param pointIndex The index of a point in the curve.
- @param[out] x The x-value of the specified point.
- @param[out] y The y-value of the specified point.
- @return Error code.
- @see ENgetcurvelen ENsetcurvevalue
- */
- int DLLEXPORT ENgetcurvevalue(int curveIndex, int pointIndex,
- EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y);
+ int DLLEXPORT ENsetcurvevalue(int curveIndex, int pointIndex,
+ EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y);
- /**
- @brief Set the x and y values for a curve's data point.
- @param curveIndex The index of a curve.
- @param pointIndex The index of a point in the curve.
- @param x The x-value of the point.
- @param y The y-value of the point.
- @return Error code.
- */
- int DLLEXPORT ENsetcurvevalue(int curveIndex, int pointIndex,
- EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y);
+ int DLLEXPORT ENgetcurve(int index, char* id, int *nPoints,
+ EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues);
- /**
- @brief Get a curve's properties.
- @param curveIndex The index of a curve (first curve is index 1).
- @param[out] id The curve's string ID. Client code must preallocate at least MAXID characters.
- @param[out] nValues The number of values in the curve's (x,y) list.
- @param[out] xValues The curve's x-values. Pointer must be freed by client.
- @param[out] yValues The curve's y-values. Pointer must be freed by client.
- @return Error code.
-
- The calling program is responsible for making xValues and yValues large enough
- to hold nValues number of data points.
- */
- int DLLEXPORT ENgetcurve(int curveIndex, char* id, int *nValues,
- EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues);
-
- /**
- @brief Set the x,y values for all points on a curve.
- @param index The index of a curve.
- @param x An array of x-values for the curve.
- @param y An array of y-values for the curve.
- @param len The length of the arrays for x and y.
- @return Error code.
- */
- int DLLEXPORT ENsetcurve(int index, EN_API_FLOAT_TYPE *x,
- EN_API_FLOAT_TYPE *y, int len);
+ int DLLEXPORT ENsetcurve(int index, EN_API_FLOAT_TYPE *xValues,
+ EN_API_FLOAT_TYPE *yValues, int nPoints);
/********************************************************************
@@ -993,51 +347,16 @@ extern "C" {
********************************************************************/
- /**
- @brief Add a new simple control to the project.
- @param[out] index The index of the new control. First control is index 1.
- @param ctype The type of control to add (see EN_ControlType).
- @param lindex The index of a link to control.
- @param setting The control setting applied to the link.
- @param nindex The index of a node used to control the link, or 0 for TIMER / TIMEOFDAY control.
- @param level control point (tank level, junction pressure, or time in seconds).
- @return Error code.
- */
- int DLLEXPORT ENaddcontrol(int *index, int ctype, int lindex, EN_API_FLOAT_TYPE setting,
- int nindex, EN_API_FLOAT_TYPE level);
+ int DLLEXPORT ENaddcontrol(int type, int linkIndex, EN_API_FLOAT_TYPE setting,
+ int nodeIndex, EN_API_FLOAT_TYPE level, int *index);
- /**
- @brief Delete an existing simple control
- @param index The index of the control. First control is index 1.
- @return Error code.
- */
- int DLLEXPORT ENdeletecontrol(int index);
+ int DLLEXPORT ENdeletecontrol(int index);
- /**
- @brief Retrieves properties that define a simple control
- @param index Position of control in list of controls added to the project
- @param[out] ctype Control type code (see EN_ControlType enumeration)
- @param[out] lindex Index of controlled link
- @param[out] setting Control setting on link
- @param[out] nindex Index of controlling node (0 for TIMER or TIMEOFDAY control)
- @param[out] level Control level (tank level, junction pressure, or time (seconds))
- @return Error code
- */
- int DLLEXPORT ENgetcontrol(int index, int *ctype, int *lindex, EN_API_FLOAT_TYPE *setting,
- int *nindex, EN_API_FLOAT_TYPE *level);
+ int DLLEXPORT ENgetcontrol(int index, int *type, int *linkIndex,
+ EN_API_FLOAT_TYPE *setting, int *nodeIndex, EN_API_FLOAT_TYPE *level);
- /**
- @brief Set the properties of an existing simple control.
- @param cindex The index of the control. First control is index 1.
- @param ctype The type of control to use (see EN_ControlType).
- @param lindex The index of a link to control.
- @param setting The control setting applied to the link.
- @param nindex The index of a node used to control the link, or 0 for TIMER / TIMEOFDAY control.
- @param level control point (tank level, junction pressure, or time in seconds).
- @return Error code.
- */
- int DLLEXPORT ENsetcontrol(int cindex, int ctype, int lindex,
- EN_API_FLOAT_TYPE setting, int nindex, EN_API_FLOAT_TYPE level);
+ int DLLEXPORT ENsetcontrol(int index, int type, int linkIndex,
+ EN_API_FLOAT_TYPE setting, int nodeIndex, EN_API_FLOAT_TYPE level);
/********************************************************************
@@ -1046,157 +365,43 @@ extern "C" {
********************************************************************/
- /**
- @brief Add a new control rule to the project.
- @param rule Text of the rule following the format used in an EPANET input file.
- @return Error code.
- */
int DLLEXPORT ENaddrule(char *rule);
- /**
- @brief Delete a rule-based control.
- @param index The rule's index.
- @return Error code.
- */
- int DLLEXPORT ENdeleterule(int index);
+ int DLLEXPORT ENdeleterule(int index);
- /**
- @brief Get summary information for a rule-based control.
- @param index The rule's index.
- @param[out] nPremises Number of premises in the rule's IF section.
- @param[out] nThenActions Number of actions in the rule's THEN section.
- @param nElseActions[out] Number of actions in the rule's ELSE section.
- @param priority[out] Rule's priority.
- @return Error code.
- */
- int DLLEXPORT ENgetrule(int index, int *nPremises, int *nTrueActions,
- int *nFalseActions, EN_API_FLOAT_TYPE *priority);
+ int DLLEXPORT ENgetrule(int index, int *nPremises, int *nThenActions,
+ int *nElseActions, EN_API_FLOAT_TYPE *priority);
- /**
- @brief Get the ID name of a rule-based control.
- @param index The rule's index.
- @param id[out] The rule's ID name.
- @return Error code.
- */
- int DLLEXPORT ENgetruleID(int index, char* id);
+ int DLLEXPORT ENgetruleID(int index, char* id);
- /**
- @brief Get the properties of a premise in a rule-based control.
- @param ruleIndex The rule's index.
- @param premiseIndex The premise's index.
- @param logop[out] Logical operator (IF = 1, AND = 2, OR = 3) of the premise.
- @param object[out] Type of object the premise is looking at (see EN_RuleObject).
- @param objIndex[out] Index of the object (e.g. the index of the tank).
- @param variable[out] Index of the variable to be checked (see EN_RuleVariable).
- @param relop[out] Relationship operator in the premise (see EN_RuleOperator).
- @param status[out] Status of the object being checked (see EN_RuleStatus).
- @param value[out] Setting of the variable being checked (e.g. 5.5)
- @return Error code.
- */
- int DLLEXPORT ENgetpremise(int ruleIndex, int premiseIndex, int *logop,
- int *object, int *objIndex, int *variable,
- int *relop, int *status, EN_API_FLOAT_TYPE *value);
+ int DLLEXPORT ENgetpremise(int ruleIndex, int premiseIndex, int *logop,
+ int *object, int *objIndex, int *variable,
+ int *relop, int *status, EN_API_FLOAT_TYPE *value);
- /**
- @brief Set the properties of a premise in a rule-based control.
- @param ruleIndex The rule's index.
- @param premiseIndex The premise's index.
- @param logop Logical operator (IF = 1, AND = 2, OR = 3) of the premise.
- @param object Type of object the premise is looking at (see EN_RuleObject).
- @param objIndex Index of the object (e.g. the index of the tank).
- @param variable Index of the variable to be checked (see EN_RuleVariable).
- @param relop Relationship operator in the premise (see EN_RuleOperator).
- @param status Status of the object being checked (see EN_RuleStatus).
- @param value Setting of the variable being checked (e.g. 5.5)
- @return Error code.
- */
- int DLLEXPORT ENsetpremise(int ruleIndex, int premiseIndex, int logop,
- int object, int objIndex, int variable, int relop,
- int status, EN_API_FLOAT_TYPE value);
+ int DLLEXPORT ENsetpremise(int ruleIndex, int premiseIndex, int logop,
+ int object, int objIndex, int variable, int relop,
+ int status, EN_API_FLOAT_TYPE value);
- /**
- @brief Set the index of an object in a premise of a rule-based control.
- @param ruleIndex The rule's index.
- @param premiseIndex The premise's index.
- @param objIndex The index of the premise's object (e.g. the index of the tank).
- @return Error code.
- */
- int DLLEXPORT ENsetpremiseindex(int ruleIndex, int premiseIndex, int objIndex);
+ int DLLEXPORT ENsetpremiseindex(int ruleIndex, int premiseIndex, int objIndex);
- /**
- @brief Set the status in a premise of a rule-based control.
- @param ruleIndex The rule's index.
- @param premiseIndex The premise's index.
- @param status The status of the object being checked (see EN_RuleStatus)
- @return Error code.
- */
- int DLLEXPORT ENsetpremisestatus(int ruleIndex, int premiseIndex, int status);
+ int DLLEXPORT ENsetpremisestatus(int ruleIndex, int premiseIndex, int status);
- /**
- @brief Set the value in a premise of a rule-based control.
- @param ruleIndex The rule's index.
- @param premiseIndex The premise's index.
- @param value The value of the premise's variable being checked (e.g. 5.5)
- @return Error code.
- */
- int DLLEXPORT ENsetpremisevalue(int ruleIndex, int premiseIndex,
- EN_API_FLOAT_TYPE value);
+ int DLLEXPORT ENsetpremisevalue(int ruleIndex, int premiseIndex,
+ EN_API_FLOAT_TYPE value);
- /**
- @brief Get the properties of a THEN action in a rule-based control.
- @param ruleIndex The rule's index.
- @param actionIndex Index of the THEN action to retrieve.
- @param linkIndex[out] Index of the link in the action (e.g. index of Pump 1)
- @param status[out] Status of the link (see EN_RuleStatus)
- @param setting[out] Value of the link's setting (e.g. pump speed 0.9)
- @return Error code.
- */
- int DLLEXPORT ENgetthenaction(int ruleIndex, int actionIndex, int *linkIndex,
- int *status, EN_API_FLOAT_TYPE *setting);
+ int DLLEXPORT ENgetthenaction(int ruleIndex, int actionIndex, int *linkIndex,
+ int *status, EN_API_FLOAT_TYPE *setting);
- /**
- @brief Set the properties of a THEN action in a rule-based control.
- @param ruleIndex The rule's index.
- @param actionIndex Index of the THEN action to modify.
- @param linkIndex Index of the link in the action (e.g. index of Pump 1)
- @param status Status assigned to the link (e.g. CLOSED)
- @param setting Setting value assigned to the link (e.g. pump speed 0.9)
- @return Error code.
- */
- int DLLEXPORT ENsetthenaction(int ruleIndex, int actionIndex, int linkIndex,
- int status, EN_API_FLOAT_TYPE setting);
+ int DLLEXPORT ENsetthenaction(int ruleIndex, int actionIndex, int linkIndex,
+ int status, EN_API_FLOAT_TYPE setting);
- /**
- @brief Get the properties of an ELSE action in a rule-based control.
- @param ruleIndex The rule's index.
- @param actionIndex Index of the ELSE action to retrieve.
- @param linkIndex[out] Index of the link in the action (e.g. index of Pump 1).
- @param status[out] Status of the link (see EN_RuleStatus).
- @param setting[out] Value of the link's setting (e.g. pump speed 0.9)
- @return Error code.
- */
- int DLLEXPORT ENgetelseaction(int ruleIndex, int actionIndex, int *linkIndex,
- int *status, EN_API_FLOAT_TYPE *setting);
+ int DLLEXPORT ENgetelseaction(int ruleIndex, int actionIndex, int *linkIndex,
+ int *status, EN_API_FLOAT_TYPE *setting);
- /**
- @brief Set the properties of an ELSE action in a rule-based control.
- @param ruleIndex The rule's index.
- @param actionIndex Index of the ELSE action being modified.
- @param linkIndex Index of the link in the action (e.g. index of Pump 1)
- @param status Status assigned to the link (see EN_RuleStatus)
- @param setting Setting value assigned to the link (e.g. pump speed 0.9)
- @return Error code.
- */
- int DLLEXPORT ENsetelseaction(int ruleIndex, int actionIndex, int linkIndex,
- int status, EN_API_FLOAT_TYPE setting);
+ int DLLEXPORT ENsetelseaction(int ruleIndex, int actionIndex, int linkIndex,
+ int status, EN_API_FLOAT_TYPE setting);
- /**
- @brief Set the priority of a rule-based control.
- @param index The rule's index.
- @param priority The priority assigned to the rule.
- @return Error code.
- */
- int DLLEXPORT ENsetrulepriority(int index, EN_API_FLOAT_TYPE priority);
+ int DLLEXPORT ENsetrulepriority(int index, EN_API_FLOAT_TYPE priority);
#if defined(__cplusplus)
diff --git a/include/epanet2.vb b/include/epanet2.vb
index a1d8ccc..d6a31c6 100644
--- a/include/epanet2.vb
+++ b/include/epanet2.vb
@@ -4,7 +4,7 @@
'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
'(EPANET2.DLL) for use with VB.Net.
-'Last updated on 01/01/2019
+'Last updated on 01/08/2019
Imports System.Runtime.InteropServices
Imports System.Text
@@ -226,139 +226,139 @@ Public Const EN_R_IS_ACTIVE = 3
'These are the external functions that comprise the DLL
'System Functions
- Declare Function ENgetversion Lib "epanet2.dll" (ByRef Value As Int32) As Int32
- Declare Function ENepanet Lib "epanet2.dll" (ByVal F1 As String, ByVal F2 As String, ByVal F3 As String, ByVal F4 As String) As Int32
- Declare Function ENinit Lib "epanet2.dll" (ByVal rptFile As String, ByVal binOutFile As String, ByVal UnitsType As Int32, ByVal HeadlossFormula As Int32) As Int32
- Declare Function ENopen Lib "epanet2.dll" (ByVal F1 As String, ByVal F2 As String, ByVal F3 As String) As Int32
- Declare Function ENsaveinpfile Lib "epanet2.dll" (ByVal F As String) As Int32
+ Declare Function ENgetversion Lib "epanet2.dll" (value As Int32) As Int32
+ Declare Function ENepanet Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String, ByVal pviewprog As Any) As Int32
+ Declare Function ENinit Lib "epanet2.dll" (ByVal rptFile As String, ByVal outFile As String, ByVal unitsType As Int32, ByVal headlossType As Int32) As Int32
+ Declare Function ENopen Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String) As Int32
+ Declare Function ENsaveinpfile Lib "epanet2.dll" (ByVal filename As String) As Int32
Declare Function ENclose Lib "epanet2.dll" () As Int32
-'Hydraulic Analysis Functions
+'Hydraulic Analysis Functions
Declare Function ENsolveH Lib "epanet2.dll" () As Int32
Declare Function ENsaveH Lib "epanet2.dll" () As Int32
Declare Function ENopenH Lib "epanet2.dll" () As Int32
- Declare Function ENinitH Lib "epanet2.dll" (ByVal SaveFlag As Int32) As Int32
- Declare Function ENrunH Lib "epanet2.dll" (ByRef T As Int32) As Int32
- Declare Function ENnextH Lib "epanet2.dll" (ByRef Tstep As Int32) As Int32
+ Declare Function ENinitH Lib "epanet2.dll" (ByVal initFlag As Int32) As Int32
+ Declare Function ENrunH Lib "epanet2.dll" (currentTime As Int32) As Int32
+ Declare Function ENnextH Lib "epanet2.dll" (tStep As Int32) As Int32
Declare Function ENcloseH Lib "epanet2.dll" () As Int32
- Declare Function ENsavehydfile Lib "epanet2.dll" (ByVal F As String) As Int32
- Declare Function ENusehydfile Lib "epanet2.dll" (ByVal F As String) As Int32
+ Declare Function ENsavehydfile Lib "epanet2.dll" (ByVal filename As String) As Int32
+ Declare Function ENusehydfile Lib "epanet2.dll" (ByVal filename As String) As Int32
'Water Quality Analysis Functions
Declare Function ENsolveQ Lib "epanet2.dll" () As Int32
Declare Function ENopenQ Lib "epanet2.dll" () As Int32
- Declare Function ENinitQ Lib "epanet2.dll" (ByVal SaveFlag As Int32) As Int32
- Declare Function ENrunQ Lib "epanet2.dll" (ByRef T As Int32) As Int32
- Declare Function ENnextQ Lib "epanet2.dll" (ByRef Tstep As Int32) As Int32
- Declare Function ENstepQ Lib "epanet2.dll" (ByRef Tleft As Int32) As Int32
+ Declare Function ENinitQ Lib "epanet2.dll" (ByVal saveFlag As Int32) As Int32
+ Declare Function ENrunQ Lib "epanet2.dll" (currentTime As Int32) As Int32
+ Declare Function ENnextQ Lib "epanet2.dll" (tStep As Int32) As Int32
+ Declare Function ENstepQ Lib "epanet2.dll" (timeLeft As Int32) As Int32
Declare Function ENcloseQ Lib "epanet2.dll" () As Int32
-'Reporting Functions
- Declare Function ENwriteline Lib "epanet2.dll" (ByVal S As String) As Int32
+'Reporting Functions
+ Declare Function ENwriteline Lib "epanet2.dll" (ByVal line As String) As Int32
Declare Function ENreport Lib "epanet2.dll" () As Int32
Declare Function ENresetreport Lib "epanet2.dll" () As Int32
- Declare Function ENsetreport Lib "epanet2.dll" (ByVal S As String) As Int32
- Declare Function ENsetstatusreport Lib "epanet2.dll" (ByVal Code As Int32) As Int32
- Declare Function ENgetcount Lib "epanet2.dll" (ByVal Code As Int32, ByRef Value As Int32) As Int32
- Declare Function ENgeterror Lib "epanet2.dll" (ByVal ErrCode As Int32, ByVal ErrMsg As StringBuilder, ByVal N As Int32) As Int32
- Declare Function ENgetstatistic Lib "epanet2.dll" (ByVal code As Int32, ByRef value As Single) As Int32
+ Declare Function ENsetreport Lib "epanet2.dll" (ByVal format As String) As Int32
+ Declare Function ENsetstatusreport Lib "epanet2.dll" (ByVal level As Int32) As Int32
+ Declare Function ENgetcount Lib "epanet2.dll" (ByVal object As Int32, count As Int32) As Int32
+ Declare Function ENgeterror Lib "epanet2.dll" (ByVal errcode As Int32, ByVal errmsg As String, ByVal maxLen As Int32) As Int32
+ Declare Function ENgetstatistic Lib "epanet2.dll" (ByVal type As Int32, ByRef value As Single) As Int32
'Analysis Options Functions
- Declare Function ENgetoption Lib "epanet2.dll" (ByVal Code As Int32, ByRef Value As Single) As Int32
- Declare Function ENsetoption Lib "epanet2.dll" (ByVal Code As Int32, ByVal Value As Single) As Int32
- Declare Function ENgetflowunits Lib "epanet2.dll" (ByRef Code As Int32) As Int32
- Declare Function ENsetflowunits Lib "epanet2.dll" (ByVal code As Int32) As Int32
- Declare Function ENgettimeparam Lib "epanet2.dll" (ByVal Code As Int32, ByRef Value As Int32) As Int32
- Declare Function ENsettimeparam Lib "epanet2.dll" (ByVal Code As Int32, ByVal Value As Int32) As Int32
- Declare Function ENgetqualtype Lib "epanet2.dll" (ByRef QualCode As Int32, ByRef TraceNode As Int32) As Int32
- Declare Function ENgetqualinfo Lib "epanet2.dll" (ByRef QualCode As Int32, ByVal ChemName As String, ByVal ChemUnits As String, ByRef TraceNode As Int32) As Int32
- Declare Function ENsetqualtype Lib "epanet2.dll" (ByVal QualCode As Int32, ByVal ChemName As String, ByVal ChemUnits As String, ByVal TraceNode As String) As Int32
+ Declare Function ENgetoption Lib "epanet2.dll" (ByVal option As Int32, value As Single) As Int32
+ Declare Function ENsetoption Lib "epanet2.dll" (ByVal option As Int32, ByVal value As Single) As Int32
+ Declare Function ENgetflowunits Lib "epanet2.dll" (units As Int32) As Int32
+ Declare Function ENsetflowunits Lib "epanet2.dll" (ByVal units As Int32) As Int32
+ Declare Function ENgettimeparam Lib "epanet2.dll" (ByVal param As Int32, value As Int32) As Int32
+ Declare Function ENsettimeparam Lib "epanet2.dll" (ByVal param As Int32, ByVal value As Int32) As Int32
+ Declare Function ENgetqualinfo Lib "epanet2.dll" (qualType As Int32, ByVal chemName As String, ByVal chemUnits As String, traceNode As Int32) As Int32
+ Declare Function ENgetqualtype Lib "epanet2.dll" (qualType As Int32, traceNode As Int32) As Int32
+ Declare Function ENsetqualtype Lib "epanet2.dll" (ByVal qualType As Int32, ByVal chemName As String, ByVal chemUnits As String, ByVal traceNode As String) As Int32
-'Basic Node Functions
+'Node Functions
Declare Function ENaddnode Lib "epanet2.dll" (ByVal id As String, ByVal nodeType As Int32) As Int32
- Declare Function ENdeletenode Lib "epanet2.dll" (ByVal linkIndex As Long) As Long
- Declare Function ENgetnodeindex Lib "epanet2.dll" (ByVal ID As String, ByRef Index As Int32) As Int32
- Declare Function ENgetnodeid Lib "epanet2.dll" (ByVal Index As Int32, ByVal ID As StringBuilder) As Int32
+ Declare Function ENdeletenode Lib "epanet2.dll" (ByVal index As Int32, ByVal actionCode As Int32) As Int32
+ Declare Function ENgetnodeindex Lib "epanet2.dll" (ByVal id As String, index As Int32) As Int32
+ Declare Function ENgetnodeid Lib "epanet2.dll" (ByVal index As Int32, ByVal id As String) As Int32
Declare Function ENsetnodeid Lib "epanet2.dll" (ByVal index As Int32, ByVal newid As String) As Int32
- Declare Function ENgetnodetype Lib "epanet2.dll" (ByVal Index As Int32, ByRef Code As Int32) As Int32
- Declare Function ENgetnodevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByRef Value As Single) As Int32
- Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByVal Value As Single) As Int32
+ Declare Function ENgetnodetype Lib "epanet2.dll" (ByVal index As Int32, nodeType As Int32) As Int32
+ Declare Function ENgetnodevalue Lib "epanet2.dll" (ByVal index As Int32, ByVal property As Int32, value As Single) As Int32
+ Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal index As Int32, ByVal property As Int32, ByVal value As Single) As Int32
Declare Function ENsetjuncdata Lib "epanet2.dll" (ByVal index As Int32, ByVal elev As Single, ByVal dmnd As Single, ByVal dmndpat As String) As Int32
Declare Function ENsettankdata Lib "epanet2.dll" (ByVal index As Int32, ByVal elev As Single, ByVal initlvl As Single, ByVal minlvl As Single, ByVal maxlvl As Single, ByVal diam As Single, ByVal minvol As Single, ByVal volcurve As String) As Int32
- Declare Function ENgetcoord Lib "epanet2.dll" (ByVal Index As Int32, ByRef X As Single, ByRef Y As Single) As Int32
- Declare Function ENsetcoord Lib "epanet2.dll" (ByVal Index As Int32, ByVal X As Single, ByVal Y As Single) As Int32
-
+ Declare Function ENgetcoord Lib "epanet2.dll" (ByVal index As Int32, x As Single, y As Single) As Int32
+ Declare Function ENsetcoord Lib "epanet2.dll" (ByVal index As Int32, ByVal x As Single, ByVal y As Single) As Int32
+
'Nodal Demand Functions
- Declare Function ENgetdemandmodel Lib "epanet2.dll" (ByRef mtype As Int32, ByRef pmin As Single, ByRef preq As Single, ByRef pexp As Single) As Int32
- Declare Function ENsetdemandmodel Lib "epanet2.dll" (ByVal mtype As Int32, ByVal pmin As Single, ByVal preq As Single, ByVal pexp As Single) As Int32
- Declare Function ENgetnumdemands Lib "epanet2.dll" (ByVal Index As Int32, ByRef numDemands As Int32) As Int32 'ES
- Declare Function ENgetbasedemand Lib "epanet2.dll" (ByVal Index As Int32, ByVal DemandIndex As Int32, ByRef BaseDemand As Single) As Int32 'ES
- Declare Function ENsetbasedemand Lib "epanet2.dll" (ByVal Index As Int32, ByVal DemandIndex As Int32, ByVal BaseDemand As Single) As Int32 'ES
- Declare Function ENgetdemandpattern Lib "epanet2.dll" (ByVal Index As Int32, ByVal DemandIndex As Int32, ByRef PatIndex As Int32) As Int32 'ES
- Declare Function ENsetdemandpattern Lib "epanet2.dll" (ByVal index As Int32, ByVal DemandIndex As Int32, ByVal PatIndex As Int32) As Int32
- Declare Function ENgetdemandname Lib "epanet2.dll" (ByVal index As Int32, ByVal DemandIndex As Int32, ByVal demandName As String) As Int32
- Declare Function ENsetdemandname Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal DemandIndex As Int32, ByVal demandName As String) As Int32
+ Declare Function ENgetdemandmodel Lib "epanet2.dll" (type As Int32, pmin As Single, preq As Single, pexp As Single) As Int32
+ Declare Function ENsetdemandmodel Lib "epanet2.dll" (ByVal type As Int32, ByVal pmin As Single, ByVal preq As Single, ByVal pexp As Single) As Int32
+ Declare Function ENgetnumdemands Lib "epanet2.dll" (ByVal nodeIndex As Int32, numDemands As Int32) As Int32
+ Declare Function ENgetbasedemand Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32, value As Single) As Int32
+ Declare Function ENsetbasedemand Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32, ByVal BaseDemand As Single) As Int32
+ Declare Function ENgetdemandpattern Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32, patIndex As Int32) As Int32
+ Declare Function ENsetdemandpattern Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32, ByVal patIndex As Int32) As Int32
+ Declare Function ENgetdemandname Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32, ByVal demandName As String) As Int32
+ Declare Function ENsetdemandname Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32, ByVal demandName As String) As Int32
-'Basic Link Functions
+'Link Functions
Declare Function ENaddlink Lib "epanet2.dll" (ByVal id As String, ByVal linkType As Int32, ByVal fromNode As String, ByVal toNode As String) As Int32
- Declare Function ENdeletelink Lib "epanet2.dll" (ByVal nodeIndex As Long) As Long
- Declare Function ENgetlinkindex Lib "epanet2.dll" (ByVal ID As String, ByRef Index As Int32) As Int32
- Declare Function ENgetlinkid Lib "epanet2.dll" (ByVal Index As Int32, ByVal ID As StringBuilder) As Int32
+ Declare Function ENdeletelink Lib "epanet2.dll" (ByVal index As Int32, ByVal actionCode As Int32) As Int32
+ Declare Function ENgetlinkindex Lib "epanet2.dll" (ByVal id As String, index As Int32) As Int32
+ Declare Function ENgetlinkid Lib "epanet2.dll" (ByVal index As Int32, ByVal id As String) As Int32
Declare Function ENsetlinkid Lib "epanet2.dll" (ByVal index As Int32, ByVal newid As String) As Int32
- Declare Function ENgetlinktype Lib "epanet2.dll" (ByVal Index As Int32, ByRef Code As Int32) As Int32
- Declare Function ENsetlinktype Lib "epanet2.dll" (ByRef index As Int32, ByVal code As Int32) As Int32
- Declare Function ENgetlinknodes Lib "epanet2.dll" (ByVal Index As Int32, ByRef Node1 As Int32, ByRef Node2 As Int32) As Int32
+ Declare Function ENgetlinktype Lib "epanet2.dll" (ByVal index As Int32, linkType As Int32) As Int32
+ Declare Function ENsetlinktype Lib "epanet2.dll" (index As Int32, ByVal linkType As Int32, ByVal actionCode As Int32) As Int32
+ Declare Function ENgetlinknodes Lib "epanet2.dll" (ByVal index As Int32, node1 As Int32, node2 As Int32) As Int32
Declare Function ENsetlinknodes Lib "epanet2.dll" (ByVal index As Int32, ByVal node1 As Int32, ByVal node2 As Int32) As Int32
- Declare Function ENgetlinkvalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByRef Value As Single) As Int32
- Declare Function ENsetlinkvalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByVal Value As Single) As Int32
+ Declare Function ENgetlinkvalue Lib "epanet2.dll" (ByVal index As Int32, ByVal property As Int32, value As Single) As Int32
+ Declare Function ENsetlinkvalue Lib "epanet2.dll" (ByVal index As Int32, ByVal property As Int32, ByVal value As Single) As Int32
Declare Function ENsetpipedata Lib "epanet2.dll" (ByVal index As Int32, ByVal length As Single, ByVal diam As Single, ByVal rough As Single, ByVal mloss As Single) As Int32
-
+
'Pump Functions
- Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal Index As Int32, ByVal CurveIndex As int32) As Int32 'ES
- Declare Function ENsetheadcurveindex Lib "epanet2.dll" (ByVal pumpIndex As Int32, ByVal curveIndex As Int32) As Int32
- Declare Function ENgetpumptype Lib "epanet2.dll" (ByVal Index As Int32, ByRef PumpType As Int32) As Int32 'ES
-
-'Time Pattern Functions
- Declare Function ENaddpattern Lib "epanet2.dll" (ByVal ID As String) As Int32
- Declare Function ENgetpatternindex Lib "epanet2.dll" (ByVal ID As String, ByRef Index As Int32) As Int32
- Declare Function ENgetpatternid Lib "epanet2.dll" (ByVal Index As Int32, ByVal ID As StringBuilder) As Int32
- Declare Function ENgetpatternlen Lib "epanet2.dll" (ByVal Index As Int32, ByRef L As Int32) As Int32
- Declare Function ENgetpatternvalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Period As Int32, ByRef Value As Single) As Int32
- Declare Function ENsetpatternvalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Period As Int32, ByVal Value As Single) As Int32
- Declare Function ENgetaveragepatternvalue Lib "epanet2.dll" (ByVal index As Int32, ByRef value As Single) As Int32
- Declare Function ENsetpattern Lib "epanet2.dll" (ByVal Index as Int32, ByRef F as Single, ByVal N as Int32) as Int32
-
+ Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal linkIndex As Int32, curveIndex As Int32) As Int32
+ Declare Function ENsetheadcurveindex Lib "epanet2.dll" (ByVal linkIndex As Int32, ByVal curveIndex As Int32) As Int32
+ Declare Function ENgetpumptype Lib "epanet2.dll" (ByVal linkIndex As Int32, pumpType As Int32) As Int32
+
+'Time Pattern Functions
+ Declare Function ENaddpattern Lib "epanet2.dll" (ByVal id As String) As Int32
+ Declare Function ENgetpatternindex Lib "epanet2.dll" (ByVal id As String, index As Int32) As Int32
+ Declare Function ENgetpatternid Lib "epanet2.dll" (ByVal index As Int32, ByVal id As String) As Int32
+ Declare Function ENgetpatternlen Lib "epanet2.dll" (ByVal index As Int32, len As Int32) As Int32
+ Declare Function ENgetpatternvalue Lib "epanet2.dll" (ByVal index As Int32, ByVal period As Int32, value As Single) As Int32
+ Declare Function ENsetpatternvalue Lib "epanet2.dll" (ByVal index As Int32, ByVal period As Int32, ByVal value As Single) As Int32
+ Declare Function ENgetaveragepatternvalue Lib "epanet2.dll" (ByVal index As Int32, value As Single) As Int32
+ Declare Function ENsetpattern Lib "epanet2.dll" (ByVal index As Int32, values As Any, ByVal len As Int32) As Int32
+
'Data Curve Functions
- Declare Function ENaddcurve Lib "epanet2.dll" (ByVal ID As String) As Int32
- Declare Function ENgetcurveindex Lib "epanet2.dll" (ByVal ID As String, ByRef Index As Int32) As Int32
- Declare Function ENgetcurveid Lib "epanet2.dll" (ByVal Index As Int32, ByVal ID As StringBuilder) As Int32
- Declare Function ENgetcurvelen Lib "epanet2.dll" (ByVal Index As Int32, ByRef L As Int32) As Int32
- Declare Function ENgetcurvetype Lib "epanet2.dll" (ByVal curveIndex As Int32, ByRef CurveType As Int32) As Int32
- Declare Function ENgetcurvevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Pnt As Int32, ByRef X As Single, ByRef Y As Single) As Int32
- Declare Function ENsetcurvevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Pnt As Int32, ByVal X As Single, ByVal Y As Single) As Int32
- Declare Function ENgetcurve Lib "epanet2.dll" (ByVal CurveIndex As Int32, ByRef nValues As Int32, ByRef xValues As Single, ByRef yValues As Single) As Int32 'ES
- Declare Function ENsetcurve Lib "epanet2.dll" (ByVal Index as Int32, ByRef X as Single, ByRef Y as Single, ByVal N as Int32) as Int32
+ Declare Function ENaddcurve Lib "epanet2.dll" (ByVal id As String) As Int32
+ Declare Function ENgetcurveindex Lib "epanet2.dll" (ByVal id As String, index As Int32) As Int32
+ Declare Function ENgetcurveid Lib "epanet2.dll" (ByVal index As Int32, ByVal id As String) As Int32
+ Declare Function ENgetcurvelen Lib "epanet2.dll" (ByVal index As Int32, len As Int32) As Int32
+ Declare Function ENgetcurvetype Lib "epanet2.dll" (ByVal index As Int32, type As Int32) As Int32
+ Declare Function ENgetcurvevalue Lib "epanet2.dll" (ByVal curveIndex As Int32, ByVal pointIndex As Int32, x As Single, y As Single) As Int32
+ Declare Function ENsetcurvevalue Lib "epanet2.dll" (ByVal curveIndex As Int32, ByVal pointIndex As Int32, ByVal x As Single, ByVal y As Single) As Int32
+ Declare Function ENgetcurve Lib "epanet2.dll" (ByVal index As Int32, ByVal id As String, nPoints As Int32, xValues As Any, yValues As Any) As Int32
+ Declare Function ENsetcurve Lib "epanet2.dll" (ByVal index As Int32, xValues As Any, yValues As Any, ByVal nPoints As Int32) As Int32
'Simple Control Functions
- Declare Function ENaddcontrol Lib "epanet2.dll" (ByRef Cindex As Int32, ByVal Ctype As Int32, ByVal Lindex As Int32, ByVal setting As Single, ByVal Nindex As Int32, ByVal Level As Single) As Int32
- Declare Function ENdeletecontrol Lib "epanet2.dll" (ByVal Cindex as Int32) As Int32
- Declare Function ENgetcontrol Lib "epanet2.dll" (ByVal Cindex As Int32, ByRef CtlType As Int32, ByRef Lindex As Int32, ByRef Setting As Single, ByRef Nindex As Int32, ByRef Level As Single) As Int32
- Declare Function ENsetcontrol Lib "epanet2.dll" (ByVal Cindex As Int32, ByVal CtlType As Int32, ByVal Lindex As Int32, ByVal Setting As Single, ByVal Nindex As Int32, ByVal Level As Single) As Int32
+ Declare Function ENaddcontrol Lib "epanet2.dll" (ByVal type As Int32, ByVal linkIndex As Int32, ByVal setting As Single, ByVal nodeIndex As Int32, ByVal level As Single, index As Int32) As Int32
+ Declare Function ENdeletecontrol Lib "epanet2.dll" (ByVal index As Int32) As Int32
+ Declare Function ENgetcontrol Lib "epanet2.dll" (ByVal index As Int32, type As Int32, linkIndex As Int32, setting As Single, nodeIndex As Int32, level As Single) As Int32
+ Declare Function ENsetcontrol Lib "epanet2.dll" (ByVal index As Int32, ByVal type As Int32, ByVal linkIndex As Int32, ByVal setting As Single, ByVal nodeIndex As Int32, ByVal level As Single) As Int32
-'Rule-Based Control Functions
- Declare Function ENaddrule Lib "epanet2.dll" (ByVal rule As String) as Int32
+'Rule-Based Control Functions
+ Declare Function ENaddrule Lib "epanet2.dll" (ByVal rule As String) As Int32
Declare Function ENdeleterule Lib "epanet2.dll" (ByVal index As Int32) As Int32
- Declare Function ENgetrule Lib "epanet2.dll" (ByVal index As Int32, ByRef nPremises As Int32, ByRef nTrueActions As Int32, ByRef nFalseActions As Int32, ByRef priority As Single) As Int32
- Declare Function ENgetruleID Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal id As StringBuilder) As Int32
+ Declare Function ENgetrule Lib "epanet2.dll" (ByVal index As Int32, nPremises As Int32, nThenActions As Int32, nElseActions As Int32, priority As Single) As Int32
+ Declare Function ENgetruleID Lib "epanet2.dll" (ByVal index As Int32, ByVal id As String) As Int32
Declare Function ENsetrulepriority Lib "epanet2.dll" (ByVal index As Int32, ByVal priority As Single) As Int32
- Declare Function ENgetpremise Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexPremise As Int32, ByRef logop As Int32, ByRef object As Int32, ByRef indexObj As Int32, ByRef variable As Int32, ByRef relop As Int32, ByRef status As Int32, ByRef value As Single) As Int32
- Declare Function ENsetpremise Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexPremise As Int32, ByVal logop As Int32, ByVal object As Int32, ByVal indexObj As Int32, ByVal variable As Int32, ByVal relop As Int32, ByVal status As Int32, ByVal value As Single) As Int32
- Declare Function ENsetpremiseindex Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexPremise As Int32, ByVal indexObj As Int32) As Int32
- Declare Function ENsetpremisestatus Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexPremise As Int32, ByVal status As Int32) As Int32
- Declare Function ENsetpremisevalue Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexPremise As Int32, ByVal value As Single) As Int32
- Declare Function ENgetthenaction Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexAction As Int32, ByRef indexLink As Int32, ByRef status As Int32, ByRef setting As Single) As Int32
- Declare Function ENsetthenaction Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexAction As Int32, ByVal indexLink As Int32, ByVal status As Int32, ByVal setting As Single) As Int32
- Declare Function ENgetelseaction Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexAction As Int32, ByRef indexLink As Int32, ByRef status As Int32, ByRef setting As Single) As Int32
- Declare Function ENsetelseaction Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexAction As Int32, ByVal indexLink As Int32, ByVal status As Int32, ByVal setting As Single) As Int32
+ Declare Function ENgetpremise Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal premiseIndex As Int32, logop As Int32, object As Int32, objIndex As Int32, variable As Int32, relop As Int32, status As Int32, value As Single) As Int32
+ Declare Function ENsetpremise Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal premiseIndex As Int32, ByVal logop As Int32, ByVal object As Int32, ByVal objIndex As Int32, ByVal variable As Int32, ByVal relop As Int32, ByVal status As Int32, ByVal value As Single) As Int32
+ Declare Function ENsetpremiseindex Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal premiseIndex As Int32, ByVal objIndex As Int32) As Int32
+ Declare Function ENsetpremisestatus Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal premiseIndex As Int32, ByVal status As Int32) As Int32
+ Declare Function ENsetpremisevalue Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal premiseIndex As Int32, ByVal value As Single) As Int32
+ Declare Function ENgetthenaction Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal actionIndex As Int32, linkIndex As Int32, status As Int32, setting As Single) As Int32
+ Declare Function ENsetthenaction Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal actionIndex As Int32, ByVal linkIndex As Int32, ByVal status As Int32, ByVal setting As Single) As Int32
+ Declare Function ENgetelseaction Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal actionIndex As Int32, linkIndex As Int32, status As Int32, setting As Single) As Int32
+ Declare Function ENsetelseaction Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal actionIndex As Int32, ByVal linkIndex As Int32, ByVal status As Int32, ByVal setting As Single) As Int32
End Module
diff --git a/include/epanet2_2.h b/include/epanet2_2.h
index 54c0e72..ed2213b 100644
--- a/include/epanet2_2.h
+++ b/include/epanet2_2.h
@@ -1,4 +1,4 @@
-/** @file epanet2.h
+/** @file epanet2_2.h
@see http://github.com/openwateranalytics/epanet
*/
@@ -6,24 +6,18 @@
******************************************************************************
Project: OWA EPANET
Version: 2.2
- Module: epanet2.h
- Description: symbolic constants and function declarations for the EPANET API
+ Module: epanet2_2.h
+ Description: declarations of the new thread-safe EPANET 2 API functions
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
- Last Updated: 12/31/2018
+ Last Updated: 01/09/2019
******************************************************************************
*/
#ifndef EPANET2_2_H
#define EPANET2_2_H
-// the toolkit can be compiled with support for double-precision as well.
-// just make sure that you use the correct #define in your client code.
-#ifndef EN_API_FLOAT_TYPE
- #define EN_API_FLOAT_TYPE float
-#endif
-
#ifdef WITH_GENX
#include "epanet2_export.h"
#else
@@ -66,179 +60,1372 @@ typedef struct Project *EN_Project;
/********************************************************************
- Threadsafe versions of all EPANET functions
+ System Functions
********************************************************************/
+/**
+ @brief Creates an EPANET project.
+ @param[out] ph an EPANET project handle that is passed into all other API functions.
+ @return an error code.
+ */
int DLLEXPORT EN_createproject(EN_Project *ph);
+
+
+ /**
+ @brief Deletes a currently opened EPANET project.
+ @param[in,out] ph an EPANET project handle which is returned as NULL.
+ @return an error code.
+
+ EN_deleteproject should be called after all network analysis has been completed.
+ */
int DLLEXPORT EN_deleteproject(EN_Project *ph);
- int DLLEXPORT EN_runproject(EN_Project ph, const char *f1, const char *f2, const char *f3,
- void (*pviewprog)(char *));
+
+ /**
+ @brief Runs a complete EPANET simulation.
+ @param ph an EPANET project handle.
+ @param inpFile the name of an existing EPANET-formatted input file.
+ @param rptFile the name of a report file to be created (or "" if not needed)
+ @param outFile the name of a binary output file to be created (or "" if not needed)
+ @param pviewprog a callback function that takes a character string (char *) as its only parameter.
+ @return an error code
+
+ The callback function should reside in and be used by the calling code to display
+ the progress messages that EPANET generates as it carries out its computations. Here is
+ an example of a such a function that displays progress messages to stdout:
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ void writeConsole(char *s)
+ {
+ fprintf(stdout, "\n%s", s);
+ }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ It would be passed into EN_runproject as &writeConsole. If this feature is not needed then
+ the pviewprog argument should be NULL.
+ */
+ int DLLEXPORT EN_runproject(EN_Project ph, const char *inpFile, const char *rptFile,
+ const char *outFile, void (*pviewprog)(char *));
+
+ /**
+ @brief Initializes an EPANET project.
+ @param ph an EPANET project handle.
+ @param rptFile the name of a report file to be created (or "" if not needed).
+ @param outFile the name of a binary output file to be created (or "" if not needed).
+ @param unitsType the choice of flow units (see ::EN_FlowUnits).
+ @param headLossType the choice of head loss formula (see ::EN_HeadLossType).
+ @return an error code.
+
+ This function should be called immediately after EN_open if an EPANET-formatted input
+ file will not be used to supply network data. If the project receives it's network data
+ from an input file then there is no need to call this function.
+ */
int DLLEXPORT EN_init(EN_Project ph, const char *rptFile, const char *outFile,
- EN_FlowUnits unitsType, EN_HeadLossType headLossType);
- int DLLEXPORT EN_open(EN_Project ph, const char *inpFile,
- const char *rptFile, const char *binOutFile);
+ int unitsType, int headLossType);
+
+ /**
+ @brief Opens an EPANET input file & reads in network data.
+ @param ph an EPANET project handle.
+ @param inpFile the name of an existing EPANET-formatted input file.
+ @param rptFile the name of a report file to be created (or "" if not needed).
+ @param outFile the name of a binary output file to be created (or "" if not needed).
+ @return an error code.
+ */
+ int DLLEXPORT EN_open(EN_Project ph, const char *inpFile, const char *rptFile,
+ const char *outFile);
+
+
+ /**
+ @brief Saves a project's data to an EPANET-formatted text file.
+ @param ph an EPANET project handle.
+ @param filename the name of the file to create.
+ @return Error code
+ */
int DLLEXPORT EN_saveinpfile(EN_Project ph, const char *filename);
+
+
+ /**
+ @brief Closes a project and frees all of its memory.
+ @param ph an EPANET project handle.
+ @return Error code
+
+ This function clears all existing data from a project but does not delete the
+ project, so it can be re-used with another set of network data. Use \ref EN_deleteProject
+ to actually delete a project from memory.
+ */
int DLLEXPORT EN_close(EN_Project ph);
+ /********************************************************************
+
+ Hydraulic Analysis Functions
+
+ ********************************************************************/
+
+ /**
+ @brief Runs a complete hydraulic simulation with results for all time periods
+ written to a temporary hydraulics file.
+ @param ph an EPANET project handle.
+ @return an error code.
+
+ Use EN_solveH to generate a complete hydraulic solution which can stand alone
+ or be used as input to a water quality analysis. This function will not allow one to
+ examine intermediate hydraulic results as they are generated. It can also be followed by calls
+ to ::EN_saveH and ::EN_report to write hydraulic results to the report file.
+
+ The sequence ::EN_openH - ::EN_initH - ::EN_runH - ::EN_nextH - ::EN_closeH
+ can be used instead to gain access to results at intermediate time periods and
+ directly adjust link status and control settings as a simulation proceeds.
+ */
int DLLEXPORT EN_solveH(EN_Project ph);
- int DLLEXPORT EN_saveH(EN_Project ph);
- int DLLEXPORT EN_openH(EN_Project ph);
- int DLLEXPORT EN_initH(EN_Project ph, int saveFlag);
- int DLLEXPORT EN_runH(EN_Project ph, long *currentTime);
- int DLLEXPORT EN_nextH(EN_Project ph, long *tStep);
- int DLLEXPORT EN_closeH(EN_Project ph);
- int DLLEXPORT EN_savehydfile(EN_Project ph, char *filename);
+
+
+ /**
+ @brief Uses a previously saved binary hydraulics file to supply a project's hydraulics.
+ @param ph an EPANET project handle.
+ @param filename the name of the binary file containing hydraulic results.
+ @return an error code.
+
+ Call this function to re-use a set of hydraulic analysis results saved previously. This
+ can save computational time if water quality analyses are being made under the same set
+ of hydraulic conditions.
+
+ Do not call this function while the hydraulics solver is open.
+ */
int DLLEXPORT EN_usehydfile(EN_Project ph, char *filename);
+
+ /**
+ @brief Opens a project's hydraulic solver.
+ @param ph an EPANET project handle.
+ @return an error code.
+
+ Call EN_openH prior to running the first hydraulic analysis using the EN_initH - EN_runH - EN_nextH
+ sequence. Multiple analyses can be made before calling ::EN_closeH to close the hydraulic solver.
+
+ Do not call this function if ::EN_solveH is being used to run a complete hydraulic analysis or if
+ hydraulics are being supplied by a previously saved hydraulics file using ::EN_usehydfile.
+ */
+ int DLLEXPORT EN_openH(EN_Project ph);
+
+
+ /**
+ @brief Initializes a network prior to running a hydraulic analysis.
+ @param ph an EPANET project handle.
+ @param initFlag a 2-digit initialization flag (see ::EN_SaveOption).
+ @return an error code.
+
+ The initialization flag is a two digit number where the 1st (left) digit
+ indicates if link flows should be re-initialized (1) or not (0), and the
+ 2nd digit indicates if hydraulic results should be saved to a temporary
+ binary hydraulics file (1) or not (0).
+
+ Be sure to call EN_initH prior to running a hydraulic analysis using a ::EN_runH - ::EN_nextH loop.
+
+ Choose to save hydraulics results if you will be:
+ - making a subsequent water quality run,
+ - using ::EN_report to generate a report
+ - or using ::EN_savehydfile to save the binary hydraulics file.
+ There is no need to save hydraulics if you will be writing custom code to process hydraulic
+ results as they are generated, using functions like ::EN_getnodevalue and ::EN_getlinkvalue.
+ */
+ int DLLEXPORT EN_initH(EN_Project ph, int initFlag);
+
+
+ /**
+ @brief Computes a hydraulic solution for the current point in time.
+ @param ph an EPANET project handle.
+ @param[out] currentTime the current simulation time in seconds.
+ @return an error or warning code.
+
+ This function is used in a loop with ::EN_nextH() to run an extended period hydraulic simulation.
+ This process automatically updates the simulation clock time so currentTime should be treated as a
+ read-only variable.
+
+ ::EN_initH must have been called prior to running the EN_runH - EN_nextH loop.
+ */
+ int DLLEXPORT EN_runH(EN_Project ph, long *currentTime);
+
+
+ /**
+ @brief Determines the length of time until the next hydraulic event occurs in an extended period
+ simulation.
+ @param ph an EPANET project handle.
+ @param[out] tStep the time (in seconds) until the next hydraulic event or 0 if at the end of the
+ full simulation duration.
+ @return an error code.
+
+ This function is used in a loop with ::EN_runH() to run an extended period hydraulic simulation.
+
+ The value of tstep should be treated as a read-only variable. It is automatically computed as
+ the smaller of:
+ - the time interval until the next hydraulic time step begins
+ - the time interval until the next reporting time step begins
+ - the time interval until the next change in demands occurs
+ - the time interval until a tank becomes full or empty
+ - the time interval until a control or rule fires.
+ */
+ int DLLEXPORT EN_nextH(EN_Project ph, long *tStep);
+
+ /**
+ @brief Transfers a project's hydraulics results from its temporary hydraulics file to its
+ binary output file, where results are only reported at uniform reporting intervals.
+ @param ph an EPANET project handle.
+ @return an error code.
+
+ EN_saveH is used when only a hydraulic analysis is run and results at uniform reporting intervals
+ need to be transferred to EPANET's binary output file. Such would be the case when an output
+ report to EPANET's report file will be written using ::EN_report.
+ */
+ int DLLEXPORT EN_saveH(EN_Project ph);
+
+
+ /**
+ @brief Saves a project's temporary hydraulics file to disk.
+ @param ph an EPANET project handle.
+ @param filename the name of the file to be created.
+ @return an error code.
+
+ Use this function to save the current set of hydraulics results to a file, either for
+ post-processing or to be used at a later time by calling the ::EN_usehydfile function.
+
+ The hydraulics file contains nodal demands and heads and link flows, status, and settings
+ for all hydraulic time steps, even intermediate ones.
+ */
+ int DLLEXPORT EN_savehydfile(EN_Project ph, char *filename);
+
+
+ /**
+ @brief Closes the hydraulic solver freeing all of its allocated memory.
+ @return an error code.
+ */
+ int DLLEXPORT EN_closeH(EN_Project ph);
+
+ /********************************************************************
+
+ Water Quality Analysis Functions
+
+ ********************************************************************/
+
+ /**
+ @brief Runs a complete water quality simulation with results at uniform
+ reporting intervals written to the project's binary output file.
+ @param ph an EPANET project handle.
+ @return an error code.
+
+ A hydraulic analysis must have been run and saved to a hydraulics file before
+ calling EN_solveQ. This function will not allow one to examine intermediate water
+ quality results as they are generated. It can be followed by a call to ::EN_report
+ to write all hydraulic and water quality results to a formatted report file.
+
+ One can instead use the ::EN_openQ - ::EN_initQ - ::EN_runQ - ::EN_nextQ - ::EN_closeQ
+ sequence to gain access to gain access to water quality results at intermediate time
+ periods.
+ */
int DLLEXPORT EN_solveQ(EN_Project ph);
+
+
+ /**
+ @brief Opens a project's water quality solver.
+ @param ph n EPANET project handle.
+ @return an error code.
+
+ Call EN_openQ prior to running the first water quality analysis using an
+ ::EN_initQ - ::EN_runQ - ::EN_nextQ (or ::EN_stepQ) sequence. Multiple water
+ quality analyses can be made before calling ::EN_closeQ to close the water
+ quality solver.
+
+ Do not call this function if a complete water quality analysis will be made
+ using ::EN_solveQ.
+ */
int DLLEXPORT EN_openQ(EN_Project ph);
+
+
+ /**
+ @brief Initializes a network prior to running a water quality analysis.
+ @param ph n EPANET project handle.
+ @param saveFlag set to EN_SAVE (1) if results are to be saved to the project's
+ binary output file, or to EN_NOSAVE (0) if not.
+ @return an error code.
+
+ Call EN_initQ prior to running a water quality analysis using ::EN_runQ in conjunction with
+ either ::EN_nextQ or ::EN_stepQ.
+
+ ::EN_openQ must have been called prior to calling EN_initQ.
+
+ Do not call EN_initQ if a complete water quality analysis will be made using ::EN_solveQ.
+ */
int DLLEXPORT EN_initQ(EN_Project ph, int saveFlag);
+
+
+ /**
+ @brief Makes hydraulic and water quality results at the start of the current time
+ period available to a project's water quality solver.
+ @param ph an EPANET project handle.
+ @param[out] currentTime current simulation time in seconds.
+ @return an error code.
+
+ Use EN_runQ along with ::EN_nextQ in a loop to access water quality results at the start
+ of each hydraulic period in an extended period simulation. Or use it in a loop with ::EN_stepQ
+ to access results at the start of each water quality time step. See each of these functions
+ for examples of how to code such loops.
+
+ ::EN_initQ must have been called prior to running an EN_runQ - EN_nextQ (or EN_stepQ) loop.
+
+ The current time of the simulation is determined from information saved with the hydraulic
+ analysis that preceded the water quality analysis. Treat it as a read-only variable.
+ */
int DLLEXPORT EN_runQ(EN_Project ph, long *currentTime);
+
+
+ /**
+ @brief Advances a water quality simulation over the time until the next hydraulic event.
+ @param ph an EPANET project handle.
+ @param[out] tStep time (in seconds) until the next hydraulic event or 0 if at the end of the
+ full simulation duration.
+ @return an error code.
+
+ This function is used in a loop with ::EN_runQ to perform an extended period water quality analysis.
+ It reacts and routes a project's water quality constituent over a time step determined by when
+ the next hydraulic event occurs. Use ::EN_stepQ instead if you wish to generate results over each
+ water quality time step.
+
+ The value of tstep is determined from information produced by the hydraulic analysis that
+ preceded the water quality analysis. Treat it as a read-only variable.
+ */
int DLLEXPORT EN_nextQ(EN_Project ph, long *tStep);
+
+
+ /**
+ @brief Advances a water quality simulation by a single water quality time step.
+ @param ph an EPANET project handle.
+ @param[out] timeLeft time left (in seconds) to the overall simulation duration.
+ @return an error code.
+
+ This function is used in a loop with ::EN_runQ to perform an extended period water quality
+ simulation. It allows one to generate water quality results at each water quality time step
+ of the simulation, rather than over each hydraulic event period as with ::EN_nextQ.
+
+ Use the argument timeLeft to determine when no more calls to EN_runQ are needed because
+ the end of the simulation period has been reached (i.e., when tleft = 0).
+ */
int DLLEXPORT EN_stepQ(EN_Project ph, long *timeLeft);
+
+
+ /**
+ @brief Closes the water quality solver, freeing all of its allocated memory.
+ @param ph an EPANET project handle.
+ @return an error code.
+ */
int DLLEXPORT EN_closeQ(EN_Project ph);
- int DLLEXPORT EN_writeline(EN_Project ph, char *line);
- int DLLEXPORT EN_report(EN_Project ph);
- int DLLEXPORT EN_resetreport(EN_Project ph);
- int DLLEXPORT EN_setreport(EN_Project ph, char *reportCommand);
- int DLLEXPORT EN_setstatusreport(EN_Project ph, int code);
- int DLLEXPORT EN_getversion(int *version);
- int DLLEXPORT EN_getcount(EN_Project ph, EN_CountType code, int *count);
- int DLLEXPORT EN_geterror(int errcode, char *errmsg, int maxLen);
- int DLLEXPORT EN_getstatistic(EN_Project ph, int code, EN_API_FLOAT_TYPE* value);
+ /********************************************************************
- int DLLEXPORT EN_getoption(EN_Project ph, EN_Option opt, EN_API_FLOAT_TYPE *value);
- int DLLEXPORT EN_setoption(EN_Project ph, int code, EN_API_FLOAT_TYPE v);
- int DLLEXPORT EN_getflowunits(EN_Project ph, int *code);
- int DLLEXPORT EN_setflowunits(EN_Project ph, int code);
- int DLLEXPORT EN_gettimeparam(EN_Project ph, int code, long *value);
- int DLLEXPORT EN_settimeparam(EN_Project ph, int code, long value);
- int DLLEXPORT EN_getqualinfo(EN_Project ph, int *qualcode, char *chemname,
- char *chemunits, int *tracenode);
- int DLLEXPORT EN_getqualtype(EN_Project ph, int *qualcode, int *tracenode);
- int DLLEXPORT EN_setqualtype(EN_Project ph, int qualcode, char *chemname,
- char *chemunits, char *tracenode);
+ Reporting Functions
- int DLLEXPORT EN_addnode(EN_Project ph, char *id, EN_NodeType nodeType);
+ ********************************************************************/
+
+ /**
+ @brief Writes a line of text to a project's report file.
+ @param ph an EPANET project handle.
+ @param line a text string to write.
+ @return an error code.
+ */
+ int DLLEXPORT EN_writeline(EN_Project ph, char *line);
+
+ /**
+ @brief Writes simulation results in a tabular format to a project's report file.
+ @param ph an EPANET project handle.
+ @return an error code
+ */
+ int DLLEXPORT EN_report(EN_Project ph);
+
+ /**
+ @brief Resets a project's report options to their default values.
+ @param ph an EPANET project handle.
+ @return an error code
+ */
+ int DLLEXPORT EN_resetreport(EN_Project ph);
+
+ /**
+ @brief Processes a reporting format command.
+ @param ph an EPANET project handle.
+ @param format a report formatting command.
+ @return an error code
+
+ Acceptable report formatting commands are described in Appendix C of the
+ EPANET 2 Users Manual.
+ */
+ int DLLEXPORT EN_setreport(EN_Project ph, char *format);
+
+ /**
+ @brief Sets the level of hydraulic status reporting.
+ @param ph an EPANET project handle.
+ @param level a status reporting level code (see ::EN_StatusReport).
+ @return an error code.
+ */
+ int DLLEXPORT EN_setstatusreport(EN_Project ph, int level);
+
+ /**
+ @brief Retrieves the toolkit API version number.
+ @param[out] version the version of the OWA-EPANET toolkit
+ @return an error code.
+
+ The version number is to be interpreted with implied decimals, i.e.,
+ "20100" == "2(.)01(.)00"
+ */
+ int DLLEXPORT EN_getversion(int *version);
+
+ /**
+ @brief Retrieves the number of objects of a given type in the network.
+ @param ph an EPANET project handle.
+ @param object a type of object to count (see ::EN_CountType)
+ @param[out] count number of objects of the specified type
+ @return an error code
+ */
+ int DLLEXPORT EN_getcount(EN_Project ph, int object, int *count);
+
+ /**
+ @brief Returns the text of an error message generated by an error code.
+ @param errcode an error code.
+ @param[out] errmsg the error message generated by the error code
+ @param maxLen maximum number of characters that errmsg can hold
+ @return an error code
+ */
+ int DLLEXPORT EN_geterror(int errcode, char *errmsg, int maxLen);
+
+ /**
+ @brief Retrieves a particular simulation statistic
+ @param ph an EPANET project handle.
+ @param type the type of statistic to retrieve (see ::EN_AnalysisStatistic).
+ @param[out] value the value of the statistic.
+ @return an error code
+ */
+ int DLLEXPORT EN_getstatistic(EN_Project ph, int type, double* value);
+
+ /********************************************************************
+
+ Analysis Options Functions
+
+ ********************************************************************/
+
+ /**
+ @brief Retrieves the value of an analysis option.
+ @param ph an EPANET project handle.
+ @param option a type of analysis option (see ::EN_Option).
+ @param[out] value the current value of the option.
+ @return an error code
+ */
+ int DLLEXPORT EN_getoption(EN_Project ph, int option, double *value);
+
+ /**
+ @brief Sets the value for an anlysis option.
+ @param ph an EPANET project handle.
+ @param option a type of analysis option (see ::EN_Option).
+ @param value the new value assigned to the option.
+ @return an error code.
+ @see EN_Option
+ */
+ int DLLEXPORT EN_setoption(EN_Project ph, int option, double value);
+
+ /**
+ @brief Retrieves a project's flow units.
+ @param ph an EPANET project handle.
+ @param[out] units a flow units code (see ::EN_FlowUnits)
+ @return an error code.
+ */
+ int DLLEXPORT EN_getflowunits(EN_Project ph, int *units);
+
+ /**
+ @brief Sets a project's flow units.
+ @param ph an EPANET project handle.
+ @param units a flow units code (see ::EN_FlowUnits)
+ @return an error code.
+ */
+ int DLLEXPORT EN_setflowunits(EN_Project ph, int units);
+
+ /**
+ @brief Retrieves the value of a time parameter.
+ @param ph an EPANET project handle.
+ @param param a time parameter code (see ::EN_TimeProperty).
+ @param[out] value the current value of the time parameter (in seconds).
+ @return an error code.
+ */
+ int DLLEXPORT EN_gettimeparam(EN_Project ph, int param, long *value);
+
+ /**
+ @brief Sets the value of a time parameter.
+ @param ph an EPANET project handle.
+ @param param a time parameter code (see ::EN_TimeProperty).
+ @param value the new value of the time parameter (in seconds)
+ @return an error code.
+ */
+ int DLLEXPORT EN_settimeparam(EN_Project ph, int param, long value);
+
+ /**
+ @brief Gets information about the type of water quality analysis requested.
+ @param ph an EPANET project handle.
+ @param[out] qualType type of analysis to run (see ::EN_QualityType).
+ @param[out] chemName name of chemical constituent.
+ @param[out] chemUnits concentration units of the constituent.
+ @param[out] traceNode index of the node being traced (if applicable).
+ @return an error code.
+ */
+ int DLLEXPORT EN_getqualinfo(EN_Project ph, int *qualType, char *chemName,
+ char *chemUnits, int *traceNode);
+
+ /**
+ @brief Retrieves the type of water quality analysis to be run.
+ @param ph an EPANET project handle.
+ @param[out] qualType the type of analysis to run (see ::EN_QualityType).
+ @param[out] traceNode the index of node being traced, if qualType is EN_TRACE.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getqualtype(EN_Project ph, int *qualType, int *traceNode);
+
+ /**
+ @brief Sets the type of water quality analysis to run.
+ @param ph an EPANET project handle.
+ @param qualType the type of analysis to run (see ::EN_QualityType).
+ @param chemName the name of the quality constituent.
+ @param chemUnits the concentration units of the constituent.
+ @param traceNode the index of the node being traced if qualType is EN_TRACE.
+ @return an error code.
+
+ _chemName_ and _chemUnits_ only apply when _qualType_ is EN_CHEM.
+ _traceNode_ only applies when _qualType_ is EN_TRACE.
+ */
+ int DLLEXPORT EN_setqualtype(EN_Project ph, int qualType, char *chemName,
+ char *chemUnits, char *traceNode);
+
+ /********************************************************************
+
+ Node Functions
+
+ ********************************************************************/
+
+ /**
+ @brief Adds a new node to a project.
+ @param ph an EPANET project handle.
+ @param id the ID name of the node to be added.
+ @param nodeType the type of node being added (see ::EN_NodeType)
+ @return an error code.
+ */
+ int DLLEXPORT EN_addnode(EN_Project ph, char *id, int nodeType);
+
+ /**
+ @brief Deletes a node from a project.
+ @param ph an EPANET project handle.
+ @param index the index of the node to be deleted.
+ @param actionCode the action taken if any control contains the node and its links.
+ @return an error code.
+
+ If _actionCode_ is EN_UNCONDITIONAL then the node, its incident links and all
+ simple and rule-based controls that contain them are deleted. If set to
+ EN_CONDITIONAL then the node is not deleted if it or its incident links appear
+ in any controls and error code 261 is returned.
+
+ */
int DLLEXPORT EN_deletenode(EN_Project ph, int index, int actionCode);
- int DLLEXPORT EN_getnodeindex(EN_Project ph, char *id, int *index);
- int DLLEXPORT EN_getnodeid(EN_Project ph, int index, char *id);
+
+ /**
+ @brief Gets the index of node given its ID name.
+ @param ph an EPANET project handle.
+ @param id a node ID name.
+ @param[out] index the node's index.
+ @return an error code
+ */
+ int DLLEXPORT EN_getnodeindex(EN_Project ph, char *id, int *index);
+
+ /**
+ @brief Gets the ID name of a node given its index.
+ @param ph an EPANET project handle.
+ @param index a node's index.
+ @param[out] id the node's ID name.
+ @return an error code
+
+ The ID name must be sized to hold at least ::MAXID characters.
+ */
+ int DLLEXPORT EN_getnodeid(EN_Project ph, int index, char *id);
+
+ /**
+ @brief Changes the ID name of a node.
+ @param ph an EPANET project handle.
+ @param index a node's index.
+ @param newid the new ID name for the node.
+ @return an error code.
+ */
int DLLEXPORT EN_setnodeid(EN_Project ph, int index, char *newid);
- int DLLEXPORT EN_getnodetype(EN_Project ph, int index, int *code);
- int DLLEXPORT EN_getnodevalue(EN_Project ph, int index, int code, EN_API_FLOAT_TYPE *value);
- int DLLEXPORT EN_setnodevalue(EN_Project ph, int index, int code, EN_API_FLOAT_TYPE v);
- int DLLEXPORT EN_setjuncdata(EN_Project ph, int index, EN_API_FLOAT_TYPE elev,
- EN_API_FLOAT_TYPE dmnd, char *dmndpat);
- int DLLEXPORT EN_settankdata(EN_Project ph, int index, EN_API_FLOAT_TYPE elev,
- EN_API_FLOAT_TYPE initlvl, EN_API_FLOAT_TYPE minlvl,
- EN_API_FLOAT_TYPE maxlvl, EN_API_FLOAT_TYPE diam,
- EN_API_FLOAT_TYPE minvol, char *volcurve);
- int DLLEXPORT EN_getcoord(EN_Project ph, int index, EN_API_FLOAT_TYPE *x,
- EN_API_FLOAT_TYPE *y);
- int DLLEXPORT EN_setcoord(EN_Project ph, int index, EN_API_FLOAT_TYPE x,
- EN_API_FLOAT_TYPE y);
- int DLLEXPORT EN_getdemandmodel(EN_Project ph, int *type, EN_API_FLOAT_TYPE *pmin,
- EN_API_FLOAT_TYPE *preq, EN_API_FLOAT_TYPE *pexp);
- int DLLEXPORT EN_setdemandmodel(EN_Project ph, int type, EN_API_FLOAT_TYPE pmin,
- EN_API_FLOAT_TYPE preq, EN_API_FLOAT_TYPE pexp);
- int DLLEXPORT EN_getnumdemands(EN_Project ph, int nodeIndex, int *numDemands);
- int DLLEXPORT EN_getbasedemand(EN_Project ph, int nodeIndex,
- int demandIndex, EN_API_FLOAT_TYPE *baseDemand);
- int DLLEXPORT EN_setbasedemand(EN_Project ph, int nodeIndex,
- int demandIndex, EN_API_FLOAT_TYPE baseDemand);
- int DLLEXPORT EN_getdemandpattern(EN_Project ph, int nodeIndex, int demandIndex,
- int *pattIndex);
- int DLLEXPORT EN_setdemandpattern(EN_Project ph, int nodeIndex, int demandIndex,
- int patIndex);
- int DLLEXPORT EN_getdemandname(EN_Project ph, int nodeIndex, int demandIdx,
- char *demandName);
- int DLLEXPORT EN_setdemandname(EN_Project ph, int nodeIndex, int demandIdx,
- char *demandName);
+ /**
+ @brief Retrieves a node's type given its index.
+ @param ph an EPANET project handle.
+ @param index a node's index.
+ @param[out] nodeType the node's type (see ::EN_NodeType).
+ @return an error code.
+ */
+ int DLLEXPORT EN_getnodetype(EN_Project ph, int index, int *nodeType);
- int DLLEXPORT EN_addlink(EN_Project ph, char *id, EN_LinkType linkType,
- char *fromNode, char *toNode);
+ /**
+ @brief Retrieves a property value for a node.
+ @param ph an EPANET project handle.
+ @param index a node's index.
+ @param property the property to retrieve (see ::EN_NodeProperty).
+ @param[out] value the current value of the property.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getnodevalue(EN_Project ph, int index, int property, double *value);
+
+ /**
+ @brief Sets a property value for a node.
+ @param ph an EPANET project handle.
+ @param index a node's index.
+ @param property the property to set (see ::EN_NodeProperty).
+ @param value the new value for the property.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setnodevalue(EN_Project ph, int index, int property, double value);
+
+ /**
+ @brief Sets a group of properties for a junction node.
+ @param ph an EPANET project handle.
+ @param index a junction node's index.
+ @param elev the value of the junction's elevation.
+ @param dmnd the value of the junction's primary base demand.
+ @param dmndpat the name of the demand's time pattern ("" for no pattern)
+ @return an error code.
+ */
+ int DLLEXPORT EN_setjuncdata(EN_Project ph, int index, double elev, double dmnd,
+ char *dmndpat);
+
+ /**
+ @brief Sets a group of properties for a tank node.
+ @param ph an EPANET project handle.
+ @param index a tank node's index.
+ @param elev the tank's bottom elevation.
+ @param initlvl the initial water level in the tank.
+ @param minlvl the minimum water level for the tank.
+ @param maxlvl the maximum water level for the tank.
+ @param diam the tank's diameter (0 if a volume curve is supplied).
+ @param minvol the volume of the tank at its minimum water level.
+ @param volcurve the name of the tank's volume curve ("" for no curve)
+ @return an error code.
+ */
+ int DLLEXPORT EN_settankdata(EN_Project ph, int index, double elev, double initlvl,
+ double minlvl, double maxlvl, double diam, double minvol, char *volcurve);
+
+ /**
+ @brief Gets the (x,y) coordinates of a node.
+ @param ph an EPANET project handle.
+ @param index a node index.
+ @param[out] x the node's X-coordinate value.
+ @param[out] y the node's Y-coordinate value.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getcoord(EN_Project ph, int index, double *x, double *y);
+
+ /**
+ @brief Sets the (x,y) coordinates of a node.
+ @param ph an EPANET project handle.
+ @param index a node index.
+ @param x the node's X-coordinate value.
+ @param y the node's Y-coordinate value.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setcoord(EN_Project ph, int index, double x, double y);
+
+ /********************************************************************
+
+ Nodal Demand Functions
+
+ ********************************************************************/
+
+ /**
+ @brief Retrieves the type of demand model in use and its parameters.
+ @param ph an EPANET project handle.
+ @param[out] type Type of demand model (see ::EN_DemandModel).
+ @param[out] pmin Pressure below which there is no demand.
+ @param[out] preq Pressure required to deliver full demand.
+ @param[out] pexp Pressure exponent in demand function.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getdemandmodel(EN_Project ph, int *type, double *pmin,
+ double *preq, double *pexp);
+
+ /**
+ @brief Sets the type of demand model to use and its parameters.
+ @param ph an EPANET project handle.
+ @param type Type of demand model (see ::EN_DemandModel).
+ @param pmin Pressure below which there is no demand.
+ @param preq Pressure required to deliver full demand.
+ @param pexp Pressure exponent in demand function.
+ @return an error code.
+
+ Set _type_ to __EN_DDA__ for a traditional demand driven analysis (in which case the
+ remaining three parameter values are ignored) or to __EN_PDA__ for a pressure driven
+ analysis. In the latter case a node's demand is computed as:
+ > Dfull * [ (P - pmin) / (preq - pmin) ] ^ pexp
+ where Dfull is the full demand and P is the current pressure.
+
+ Setting _preq_ equal to _pmin_ will result in a solution with the smallest amount of demand reductions needed to insure that no node delivers positive demand at a pressure below _pmin_.
+ */
+ int DLLEXPORT EN_setdemandmodel(EN_Project ph, int type, double pmin,
+ double preq, double pexp);
+
+ /**
+ @brief Retrieves the number of demand categories for a node.
+ @param ph an EPANET project handle.
+ @param nodeIndex the index of a node.
+ @param[out] numDemands the number of demand categories assigned to the node.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getnumdemands(EN_Project ph, int nodeIndex, int *numDemands);
+
+ /**
+ @brief Gets the base demand for one of a node's demand categories.
+ @param ph an EPANET project handle.
+ @param nodeIndex a node's index.
+ @param demandIndex the index of a demand category for the node.
+ @param[out] baseDemand the category's base demand.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getbasedemand(EN_Project ph, int nodeIndex, int demandIndex,
+ double *baseDemand);
+
+ /**
+ @brief Sets the base demand for one of a node's demand categories.
+ @param ph an EPANET project handle.
+ @param nodeIndex a node's index.
+ @param demandIndex the index of a demand category for the node.
+ @param baseDemand the new base demand for the category.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setbasedemand(EN_Project ph, int nodeIndex, int demandIndex,
+ double baseDemand);
+
+ /**
+ @brief Retrieves the index of a time pattern assigned to one of a node's demand categories.
+ @param ph an EPANET project handle.
+ @param nodeIndex the node's index.
+ @param demandIndex the index of a demand category for the node.
+ @param[out] patIndex the index of the category's time pattern.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getdemandpattern(EN_Project ph, int nodeIndex, int demandIndex,
+ int *patIndex);
+
+ /**
+ @brief Sets the index of a time pattern used for one of a node's demand categories.
+ @param ph an EPANET project handle.
+ @param nodeIndex a node's index.
+ @param demandIndex the index of one of the node's demand categories.
+ @param patIndex the index of the time pattern assigned to the category.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setdemandpattern(EN_Project ph, int nodeIndex, int demandIndex, int patIndex);
+
+ /**
+ @brief Retrieves the name of a node's demand category.
+ @param ph an EPANET project handle.
+ @param nodeIndex a node's index.
+ @param demandIndex the index of one of the node's demand categories.
+ @param[out] demandName The name of the selected category.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getdemandname(EN_Project ph, int nodeIndex, int demandIndex, char *demandName);
+
+ /**
+ @brief Sets the name of a node's demand category.
+ @param ph an EPANET project handle.
+ @param nodeIndex a node's index.
+ @param demandIdx the index of one of the node's demand categories.
+ @param demandName the new name assigned to the category.
+ @return Error code.
+ */
+ int DLLEXPORT EN_setdemandname(EN_Project ph, int nodeIndex, int demandIdx, char *demandName);
+
+ /********************************************************************
+
+ Link Functions
+
+ ********************************************************************/
+
+ /**
+ @brief Adds a new link to a project.
+ @param ph an EPANET project handle.
+ @param id the ID name of the link to be added.
+ @param linkType The type of link being added (see ::EN_LinkType)
+ @param fromNode The ID name of the link's starting node.
+ @param toNode The ID name of the link's ending node.
+ @return an error code.
+ */
+ int DLLEXPORT EN_addlink(EN_Project ph, char *id, int linkType, char *fromNode, char *toNode);
+
+ /**
+ @brief Deletes a link from the project.
+ @param ph an EPANET project handle.
+ @param index the index of the link to be deleted.
+ @param actionCode The action taken if any control contains the link.
+ @return an error code.
+
+ If _actionCode_ is __EN_UNCONDITIONAL__ then the link and all simple and rule-based
+ controls that contain it are deleted. If set to __EN_CONDITIONAL__ then the link
+ is not deleted if it appears in any control and error 261 is returned.
+
+ */
int DLLEXPORT EN_deletelink(EN_Project ph, int index, int actionCode);
- int DLLEXPORT EN_getlinkindex(EN_Project ph, char *id, int *index);
- int DLLEXPORT EN_getlinkid(EN_Project ph, int index, char *id);
+
+ /**
+ @brief Gets the index of a link given its ID name.
+ @param ph an EPANET project handle.
+ @param id a link's ID name.
+ @param[out] index the link's index.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getlinkindex(EN_Project ph, char *id, int *index);
+
+ /**
+ @brief Gets the ID name of a link given its index.
+ @param ph an EPANET project handle.
+ @param index a link's index.
+ @param[out] id The link's ID name.
+ @return an error code.
+
+ The _id_ string must be sized to hold at least ::MAXID characters.
+ */
+ int DLLEXPORT EN_getlinkid(EN_Project ph, int index, char *id);
+
+ /**
+ @brief Changes the ID name of a link.
+ @param ph an EPANET project handle.
+ @param index a link's index.
+ @param newid the new ID name for the link.
+ @return Error code.
+ */
int DLLEXPORT EN_setlinkid(EN_Project ph, int index, char *newid);
- int DLLEXPORT EN_getlinktype(EN_Project ph, int index, EN_LinkType *code);
- int DLLEXPORT EN_setlinktype(EN_Project ph, int *index, EN_LinkType type, int actionCode);
- int DLLEXPORT EN_getlinknodes(EN_Project ph, int index, int *node1, int *node2);
- int DLLEXPORT EN_setlinknodes(EN_Project ph, int index, int node1, int node2);
- int DLLEXPORT EN_getlinkvalue(EN_Project ph, int index, EN_LinkProperty code,
- EN_API_FLOAT_TYPE *value);
- int DLLEXPORT EN_setlinkvalue(EN_Project ph, int index, int code, EN_API_FLOAT_TYPE v);
- int DLLEXPORT EN_setpipedata(EN_Project ph, int index, EN_API_FLOAT_TYPE length,
- EN_API_FLOAT_TYPE diam, EN_API_FLOAT_TYPE rough, EN_API_FLOAT_TYPE mloss);
+
+ /**
+ @brief Retrieves a link's type given its index.
+ @param ph an EPANET project handle.
+ @param index a link's index.
+ @param[out] linkType the link's type (see ::EN_LinkType).
+ @return an error code.
+ */
+ int DLLEXPORT EN_getlinktype(EN_Project ph, int index, int *linkType);
+
+ /**
+ @brief Changes a link's type.
+ @param ph an EPANET project handle.
+ @param[in,out] index the link's index before [in] and after [out] the type change.
+ @param linkType the new type to change the link to (see ::EN_LinkType).
+ @param actionCode the action taken if any controls contain the link.
+ @return an error code.
+
+ If _actionCode_ is __EN_UNCONDITIONAL__ then all simple and rule-based controls that
+ contain the link are deleted when the link's type is changed. If set to
+ __EN_CONDITIONAL__ then the type change is cancelled if the link appears in any
+ control and error 261 is returned.
+ */
+ int DLLEXPORT EN_setlinktype(EN_Project ph, int *index, int linkType, int actionCode);
+
+ /**
+ @brief Gets the indexes of a link's start- and end-nodes.
+ @param ph an EPANET project handle.
+ @param index a link's index.
+ @param[out] node1 the index of the link's start node.
+ @param[out] node2 the index of the link's end node.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getlinknodes(EN_Project ph, int index, int *node1, int *node2);
+
+ /**
+ @brief Sets the indexes of a link's start- and end-nodes.
+ @param ph an EPANET project handle.
+ @param index a link's index.
+ @param node1 The index of the link's start node.
+ @param node2 The index of the link's end node.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setlinknodes(EN_Project ph, int index, int node1, int node2);
+
+ /**
+ @brief Retrieves a property value for a link.
+ @param ph an EPANET project handle.
+ @param index a link's index.
+ @param property the property to retrieve (see ::EN_LinkProperty).
+ @param[out] value the current value of the property.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getlinkvalue(EN_Project ph, int index, int property, double *value);
+
+ /**
+ @brief Sets a property value for a link.
+ @param ph an EPANET project handle.
+ @param index a link's index.
+ @param property the property to set (see ::EN_LinkProperty).
+ @param value the new value for the property.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setlinkvalue(EN_Project ph, int index, int property, double value);
+
+ /**
+ @brief Sets a group of properties for a pipe link.
+ @param ph an EPANET project handle.
+ @param index the index of a pipe link.
+ @param length the pipe's length.
+ @param diam the pipe's diameter.
+ @param rough the pipe's roughness coefficient.
+ @param mloss the pipe's minor loss coefficient.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setpipedata(EN_Project ph, int index, double length, double diam,
+ double rough, double mloss);
- int DLLEXPORT EN_getpumptype(EN_Project ph, int linkIndex, int *outType);
- int DLLEXPORT EN_getheadcurveindex(EN_Project ph, int pumpIndex, int *curveIndex);
- int DLLEXPORT EN_setheadcurveindex(EN_Project ph, int pumpIndex, int curveIndex);
+ /********************************************************************
- int DLLEXPORT EN_addpattern(EN_Project ph, char *id);
- int DLLEXPORT EN_getpatternindex(EN_Project ph, char *id, int *index);
- int DLLEXPORT EN_getpatternid(EN_Project ph, int index, char *id);
- int DLLEXPORT EN_getpatternlen(EN_Project ph, int index, int *len);
- int DLLEXPORT EN_getpatternvalue(EN_Project ph, int index, int period, EN_API_FLOAT_TYPE *value);
- int DLLEXPORT EN_setpatternvalue(EN_Project ph, int index, int period, EN_API_FLOAT_TYPE value);
- int DLLEXPORT EN_getaveragepatternvalue(EN_Project ph, int index, EN_API_FLOAT_TYPE *value);
- int DLLEXPORT EN_setpattern(EN_Project ph, int index, EN_API_FLOAT_TYPE *f, int len);
+ Pump Functions
- int DLLEXPORT EN_addcurve(EN_Project ph, char *id);
- int DLLEXPORT EN_getcurveindex(EN_Project ph, char *id, int *index);
- int DLLEXPORT EN_getcurveid(EN_Project ph, int index, char *id);
- int DLLEXPORT EN_getcurvelen(EN_Project ph, int index, int *len);
- int DLLEXPORT EN_getcurvetype(EN_Project ph, int curveIndex, int *outType);
- int DLLEXPORT EN_getcurvevalue(EN_Project ph, int curveIndex, int pointIndex,
- EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y);
- int DLLEXPORT EN_setcurvevalue(EN_Project ph, int curveIndex, int pointIndex,
- EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y);
- int DLLEXPORT EN_getcurve(EN_Project ph, int curveIndex, char* id,
- int *nValues, EN_API_FLOAT_TYPE **xValues,
- EN_API_FLOAT_TYPE **yValues);
- int DLLEXPORT EN_setcurve(EN_Project ph, int index, EN_API_FLOAT_TYPE *x,
- EN_API_FLOAT_TYPE *y, int len);
+ ********************************************************************/
- int DLLEXPORT EN_addcontrol(EN_Project ph, int *cindex, int ctype, int lindex,
- EN_API_FLOAT_TYPE setting, int nindex, EN_API_FLOAT_TYPE level);
- int DLLEXPORT EN_deletecontrol(EN_Project ph, int index);
- int DLLEXPORT EN_getcontrol(EN_Project ph, int controlIndex,
- int *controlType, int *linkIndex, EN_API_FLOAT_TYPE *setting,
- int *nodeIndex, EN_API_FLOAT_TYPE *level);
- int DLLEXPORT EN_setcontrol(EN_Project ph, int cindex, int ctype, int lindex,
- EN_API_FLOAT_TYPE setting, int nindex, EN_API_FLOAT_TYPE level);
+ /**
+ @brief Retrieves the type of head curve used by a pump.
+ @param ph an EPANET project handle.
+ @param linkIndex the index of a pump link.
+ @param[out] pumpType the type of head curve used by the pump (see ::EN_PumpType).
+ @return an error code.
+ */
+ int DLLEXPORT EN_getpumptype(EN_Project ph, int linkIndex, int *pumpType);
+ /**
+ @brief Retrieves the curve assigned to a pump's head curve.
+ @param ph an EPANET project handle.
+ @param linkIndex the index of a pump link.
+ @param[out] curveIndex the index of the curve assigned to the pump's head curve.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getheadcurveindex(EN_Project ph, int linkIndex, int *curveIndex);
+
+ /**
+ @brief Assigns a curve to a pump's head curve.
+ @param ph an EPANET project handle.
+ @param linkIndex the index of a pump link.
+ @param curveIndex the index of a curve to be assigned as the pump's head curve.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setheadcurveindex(EN_Project ph, int linkIndex, int curveIndex);
+
+ /********************************************************************
+
+ Time Pattern Functions
+
+ ********************************************************************/
+
+ /**
+ @brief Adds a new time pattern to a project.
+ @param ph an EPANET project handle.
+ @param id the ID name of the pattern to add.
+ @return an error code.
+ */
+ int DLLEXPORT EN_addpattern(EN_Project ph, char *id);
+
+ /**
+ @brief Retrieves the index of a time pattern given its ID name.
+ @param ph an EPANET project handle.
+ @param id the ID name of a time pattern.
+ @param[out] index the time pattern's index.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getpatternindex(EN_Project ph, char *id, int *index);
+
+ /**
+ @brief Retrieves ID name of a time pattern given its index.
+ @param ph an EPANET project handle.
+ @param index a time pattern index.
+ @param[out] id the time pattern's ID name.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getpatternid(EN_Project ph, int index, char *id);
+
+ /**
+ @brief Retrieves the number time periods in a time pattern.
+ @param ph an EPANET project handle.
+ @param index a time pattern index.
+ @param[out] len the number of time periods in the pattern.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getpatternlen(EN_Project ph, int index, int *len);
+
+ /**
+ @brief Retrieves a time pattern's factor for a given time period.
+ @param ph an EPANET project handle.
+ @param index a time pattern index.
+ @param period a time period in the pattern.
+ @param[out] value the pattern factor for the given time period.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getpatternvalue(EN_Project ph, int index, int period, double *value);
+
+ /**
+ @brief Sets a time pattern's factor for a given time period.
+ @param ph an EPANET project handle.
+ @param index a time pattern index.
+ @param period a time period in the pattern.
+ @param value the new value of the pattern factor for the given time period.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setpatternvalue(EN_Project ph, int index, int period, double value);
+
+ /**
+ @brief Retrieves the average of all pattern factors in a time pattern.
+ @param ph an EPANET project handle.
+ @param index a time pattern index.
+ @param[out] value The average of all of the time pattern's factors.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getaveragepatternvalue(EN_Project ph, int index, double *value);
+
+ /**
+ @brief Sets the pattern factors for a given time pattern.
+ @param ph an EPANET project handle.
+ @param index a time pattern index.
+ @param f an array of new pattern factors.
+ @param len the number of time periods contained in the factor array f.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setpattern(EN_Project ph, int index, double *f, int len);
+
+ /********************************************************************
+
+ Data Curve Functions
+
+ ********************************************************************/
+
+ /**
+ @brief Adds a new data curve to a project.
+ @param ph an EPANET project handle.
+ @param id The ID name of the curve to be added.
+ @return an error code.
+ */
+ int DLLEXPORT EN_addcurve(EN_Project ph, char *id);
+
+ /**
+ @brief Retrieves the index of a curve given its ID name.
+ @param ph an EPANET project handle.
+ @param id the ID name of a curve.
+ @param[out] index The curve's index.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getcurveindex(EN_Project ph, char *id, int *index);
+
+ /**
+ @brief Retrieves the ID name of a curve given its index.
+ @param ph an EPANET project handle.
+ @param index a curve's index.
+ @param[out] id the curve's ID name.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getcurveid(EN_Project ph, int index, char *id);
+
+ /**
+ @brief Retrieves the number of points in a curve.
+ @param ph an EPANET project handle.
+ @param index a curve's index.
+ @param[out] len The number of data points assigned to the curve.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getcurvelen(EN_Project ph, int index, int *len);
+
+ /**
+ @brief Retrieves a curve's type.
+ @param ph an EPANET project handle.
+ @param index a curve's index.
+ @param[out] type the curve's type (see EN_CurveType).
+ @return an error code.
+ */
+ int DLLEXPORT EN_getcurvetype(EN_Project ph, int index, int *type);
+
+ /**
+ @brief Retrieves the value of a single data point for a curve.
+ @param ph an EPANET project handle.
+ @param curveIndex a curve's index.
+ @param pointIndex the index of a point on the curve.
+ @param[out] x the point's x-value.
+ @param[out] y the point's y-value.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getcurvevalue(EN_Project ph, int curveIndex, int pointIndex,
+ double *x, double *y);
+
+ /**
+ @brief Sets the value of a single data point for a curve.
+ @param ph an EPANET project handle.
+ @param curveIndex a curve's index.
+ @param pointIndex the index of a point on the curve.
+ @param x the point's x-value.
+ @param y the point's y-value.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setcurvevalue(EN_Project ph, int curveIndex, int pointIndex,
+ double x, double y);
+
+ /**
+ @brief Retrieves a curve's data.
+ @param ph an EPANET project handle.
+ @param curveIndex a curve's index.
+ @param[out] id the curve's ID name.
+ @param[out] nPoints the number of data points on the curve.
+ @param[out] xValues the curve's x-values.
+ @param[out] yValues the curve's y-values.
+ @return an error code.
+
+ The calling program is responsible for making _xValues_ and _yValues_ large enough
+ to hold nPoints number of data points and sizing _id_ to hold at least MAXID characters.
+ */
+ int DLLEXPORT EN_getcurve(EN_Project ph, int curveIndex, char* id, int *nPoints,
+ double **xValues, double **yValues);
+
+ /**
+ @brief Sets a curve's data points.
+ @param ph an EPANET project handle.
+ @param index a curve's index.
+ @param xValues an array of new x-values for the curve.
+ @param yValues an array of new y-values for the curve.
+ @param nPoints a new number of data points for the curve.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setcurve(EN_Project ph, int index, double *xValues,
+ double *yValues, int nPoints);
+
+ /********************************************************************
+
+ Simple Controls Functions
+
+ ********************************************************************/
+
+ /**
+ @brief Adds a new simple control to a project.
+ @param ph an EPANET project handle.
+ @param type the type of control to add (see EN_ControlType).
+ @param linkIndex the index of a link to control.
+ @param setting control setting applied to the link.
+ @param nodeIndex index of the node used to control the link, or 0 for TIMER / TIMEOFDAY control.
+ @param level action level (tank level, junction pressure, or time in seconds) that triggers the control.
+ @param[out] index index of the new control.
+ @return an error code.
+ */
+ int DLLEXPORT EN_addcontrol(EN_Project ph, int type, int linkIndex,
+ double setting, int nodeIndex, double level, int *index);
+
+ /**
+ @brief Deletes an existing simple control.
+ @param ph an EPANET project handle.
+ @param index the index of the control to delete.
+ @return an error code.
+ */
+ int DLLEXPORT EN_deletecontrol(EN_Project ph, int index);
+
+ /**
+ @brief Retrieves the properties of a simple control.
+ @param ph an EPANET project handle.
+ @param index the control's index.
+ @param[out] type the type of control (see EN_ControlType).
+ @param[out] linkIndex the index of the link being controlled.
+ @param[out] setting the control setting applied to the link.
+ @param[out] nodeIndex the index of the node used to trigger the control (0 for TIMER / TIMEOFDAY control).
+ @param[out] level the action level (tank level, junction pressure, or time in seconds) that triggers the control.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getcontrol(EN_Project ph, int index, int *type, int *linkIndex,
+ double *setting, int *nodeIndex, double *level);
+
+ /**
+ @brief Sets the properties of an existing simple control.
+ @param ph an EPANET project handle.
+ @param index the control's index.
+ @param type the type of control (see EN_ControlType).
+ @param linkIndex the index of the link being controlled.
+ @param setting the control setting applied to the link.
+ @param nodeIndex the index of the node used to trigger the control (0 for TIMER / TIMEOFDAY control).
+ @param level the action level (tank level, junction pressure, or time in seconds) that triggers the control.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setcontrol(EN_Project ph, int index, int type, int linkIndex,
+ double setting, int nodeIndex, double level);
+
+
+ /********************************************************************
+
+ Rule-Based Controls Functions
+
+ ********************************************************************/
+
+ /**
+ @brief Adds a new rule-based control to a project.
+ @param ph an EPANET project handle.
+ @param rule text of the rule following the format used in an EPANET input file.
+ @return an error code.
+
+ Consult Appendix C of the EPANET 2 Users Manual to learn about a rule's format.
+ */
int DLLEXPORT EN_addrule(EN_Project ph, char *rule);
- int DLLEXPORT EN_deleterule(EN_Project ph, int index);
- int DLLEXPORT EN_getrule(EN_Project ph, int index, int *nPremises,
- int *nThenActions, int *nElseActions, EN_API_FLOAT_TYPE *priority);
- int DLLEXPORT EN_getruleID(EN_Project ph, int index, char* id);
- int DLLEXPORT EN_getpremise(EN_Project ph, int ruleIndex, int premiseIndex,
- int *logop, int *object, int *objIndex, int *variable, int *relop,
- int *status, EN_API_FLOAT_TYPE *value);
- int DLLEXPORT EN_setpremise(EN_Project ph, int ruleIndex, int premiseIndex,
- int logop, int object, int objIndex, int variable, int relop,
- int status, EN_API_FLOAT_TYPE value);
- int DLLEXPORT EN_setpremiseindex(EN_Project ph, int ruleIndex,
- int premiseIndex, int objIndex);
- int DLLEXPORT EN_setpremisestatus(EN_Project ph, int ruleIndex,
- int premiseIndex, int status);
- int DLLEXPORT EN_setpremisevalue(EN_Project ph, int ruleIndex,
- int premiseIndex, EN_API_FLOAT_TYPE value);
- int DLLEXPORT EN_getthenaction(EN_Project ph, int ruleIndex, int actionIndex,
- int *linkIndex, int *status, EN_API_FLOAT_TYPE *setting);
- int DLLEXPORT EN_setthenaction(EN_Project ph, int ruleIndex, int actionIndex,
- int linkIndex, int status, EN_API_FLOAT_TYPE setting);
- int DLLEXPORT EN_getelseaction(EN_Project ph, int ruleIndex, int actionIndex,
- int *linkIndex, int *status, EN_API_FLOAT_TYPE *setting);
- int DLLEXPORT EN_setelseaction(EN_Project ph, int ruleIndex, int actionIndex,
- int linkIndex, int status, EN_API_FLOAT_TYPE setting);
- int DLLEXPORT EN_setrulepriority(EN_Project ph, int index, EN_API_FLOAT_TYPE priority);
+ /**
+ @brief Deletes an existing rule-based control.
+ @param ph an EPANET project handle.
+ @param index the index of the rule to be deleted.
+ @return an error code.
+ */
+ int DLLEXPORT EN_deleterule(EN_Project ph, int index);
+
+ /**
+ @brief Retrieves summary information about a rule-based control.
+ @param ph an EPANET project handle.
+ @param index the rule's index.
+ @param[out] nPremises number of premises in the rule's IF section.
+ @param[out] nThenActions number of actions in the rule's THEN section.
+ @param[out] nElseActions number of actions in the rule's ELSE section.
+ @param[out] priority the rule's priority.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getrule(EN_Project ph, int index, int *nPremises,
+ int *nThenActions, int *nElseActions, double *priority);
+
+ /**
+ @brief Gets the ID name of a rule-based control given its index.
+ @param ph an EPANET project handle.
+ @param index the rule's index.
+ @param[out] id the rule's ID name.
+ @return Error code.
+ */
+ int DLLEXPORT EN_getruleID(EN_Project ph, int index, char* id);
+
+ /**
+ @brief Gets the properties of a premise in a rule-based control.
+ @param ph an EPANET project handle.
+ @param ruleIndex the rule's index.
+ @param premiseIndex the position of the premise in the rule's list of premises.
+ @param[out] logop the premise's logical operator (IF = 1, AND = 2, OR = 3).
+ @param[out] object the type of object the premise refers to (see EN_RuleObject).
+ @param[out] objIndex the index of the object (e.g. the index of the tank).
+ @param[out] variable the object's variable being compared (see EN_RuleVariable).
+ @param[out] relop the premise's comparison operator (see EN_RuleOperator).
+ @param[out] status the status that the object's status is compared to (see EN_RuleStatus).
+ @param[out] value the value that the object's variable is compared to.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getpremise(EN_Project ph, int ruleIndex, int premiseIndex,
+ int *logop, int *object, int *objIndex, int *variable,
+ int *relop, int *status, double *value);
+
+ /**
+ @brief Sets the properties of a premise in a rule-based control.
+ @param ph an EPANET project handle.
+ @param ruleIndex the rule's index.
+ @param premiseIndex the position of the premise in the rule's list of premises.
+ @param logop the premise's logical operator (IF = 1, AND = 2, OR = 3).
+ @param object the type of object the premise refers to (see EN_RuleObject).
+ @param objIndex the index of the object (e.g. the index of the tank).
+ @param variable the object's variable being compared (see EN_RuleVariable).
+ @param relop the premise's comparison operator (see EN_RuleOperator).
+ @param status the status that the object's status is compared to (see ::EN_RuleStatus).
+ @param value the value that the object's variable is compared to.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setpremise(EN_Project ph, int ruleIndex, int premiseIndex,
+ int logop, int object, int objIndex, int variable, int relop,
+ int status, double value);
+
+ /**
+ @brief Sets the index of an object in a premise of a rule-based control.
+ @param ph an EPANET project handle.
+ @param ruleIndex the rule's index.
+ @param premiseIndex the premise's index.
+ @param objIndex the index of the premise's object (e.g. the index of the tank).
+ @return an error code.
+ */
+ int DLLEXPORT EN_setpremiseindex(EN_Project ph, int ruleIndex, int premiseIndex,
+ int objIndex);
+
+ /**
+ @brief Sets the status being compared to in a premise of a rule-based control.
+ @param ph an EPANET project handle.
+ @param ruleIndex the rule's index.
+ @param premiseIndex the premise's index.
+ @param status the status that the premise's object status is compared to (see ::EN_RuleStatus).
+ @return an error code.
+ */
+ int DLLEXPORT EN_setpremisestatus(EN_Project ph, int ruleIndex, int premiseIndex,
+ int status);
+
+ /**
+ @brief Sets the value in a premise of a rule-based control.
+ @param ph an EPANET project handle.
+ @param ruleIndex the rule's index.
+ @param premiseIndex the premise's index.
+ @param value The value that the premise's variable is compared to.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setpremisevalue(EN_Project ph, int ruleIndex, int premiseIndex,
+ double value);
+
+ /**
+ @brief Gets the properties of a THEN action in a rule-based control.
+ @param ph an EPANET project handle.
+ @param ruleIndex the rule's index.
+ @param actionIndex the index of the THEN action to retrieve.
+ @param[out] linkIndex the index of the link in the action.
+ @param[out] status the status assigned to the link (see ::EN_RuleStatus)
+ @param[out] setting the value assigned to the link's setting.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getthenaction(EN_Project ph, int ruleIndex, int actionIndex,
+ int *linkIndex, int *status, double *setting);
+
+ /**
+ @brief Sets the properties of a THEN action in a rule-based control.
+ @param ph an EPANET project handle.
+ @param ruleIndex the rule's index.
+ @param actionIndex the index of the THEN action to modify.
+ @param[out] linkIndex the index of the link in the action.
+ @param[out] status the new status assigned to the link (see ::EN_RuleStatus).
+ @param[out] setting the new value assigned to the link's setting.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setthenaction(EN_Project ph, int ruleIndex, int actionIndex,
+ int linkIndex, int status, double setting);
+
+ /**
+ @brief Gets the properties of an ELSE action in a rule-based control.
+ @param ph an EPANET project handle.
+ @param ruleIndex the rule's index.
+ @param actionIndex the index of the ELSE action to retrieve.
+ @param[out] linkIndex the index of the link in the action.
+ @param[out] status the status assigned to the link (see ::EN_RuleStatus).
+ @param[out] setting the value assigned to the link's setting.
+ @return an error code.
+ */
+ int DLLEXPORT EN_getelseaction(EN_Project ph, int ruleIndex, int actionIndex,
+ int *linkIndex, int *status, double *setting);
+
+ /**
+ @brief Sets the properties of an ELSE action in a rule-based control.
+ @param ph an EPANET project handle.
+ @param ruleIndex the rule's index.
+ @param actionIndex the index of the ELSE action being modified.
+ @param[out] linkIndex the index of the link in the action.
+ @param[out] status the new status assigned to the link (see ::EN_RuleStatus)
+ @param[out] setting the new value assigned to the link's setting.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setelseaction(EN_Project ph, int ruleIndex, int actionIndex,
+ int linkIndex, int status, double setting);
+
+ /**
+ @brief Sets the priority of a rule-based control.
+ @param ph an EPANET project handle.
+ @param index the rule's index.
+ @param priority the priority assigned to the rule.
+ @return an error code.
+ */
+ int DLLEXPORT EN_setrulepriority(EN_Project ph, int index, double priority);
#if defined(__cplusplus)
}
diff --git a/include/epanet2_enums.h b/include/epanet2_enums.h
index 769ca9e..cd63cac 100644
--- a/include/epanet2_enums.h
+++ b/include/epanet2_enums.h
@@ -1,13 +1,15 @@
+/** @file epanet2_enums.h
+ */
/*
******************************************************************************
Project: OWA EPANET
Version: 2.2
Module: epanet2_enums.h
- Description: enums shared between API versions
+ Description: enumerations of symbolic constants used by the API
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
- Last Updated: 01/01/2019
+ Last Updated: 01/08/2019
******************************************************************************
*/
@@ -31,12 +33,12 @@ typedef enum {
EN_SOURCEQUAL = 5, //!< Quality source strength
EN_SOURCEPAT = 6, //!< Quality source pattern
EN_SOURCETYPE = 7, //!< Qualiy source type
- EN_TANKLEVEL = 8, //!< Tank water level
- EN_DEMAND = 9, //!< Current simulated demand
- EN_HEAD = 10, //!< Current hydraulic head
- EN_PRESSURE = 11, //!< Current pressure
- EN_QUALITY = 12, //!< Current quality
- EN_SOURCEMASS = 13, //!< Current source mass inflow
+ EN_TANKLEVEL = 8, //!< Current computed tank water level
+ EN_DEMAND = 9, //!< Current computed demand
+ EN_HEAD = 10, //!< Current computed hydraulic head
+ EN_PRESSURE = 11, //!< Current computed pressure
+ EN_QUALITY = 12, //!< Current computed quality
+ EN_SOURCEMASS = 13, //!< Current computed quality source mass inflow
EN_INITVOLUME = 14, //!< Tank initial volume
EN_MIXMODEL = 15, //!< Tank mixing model
EN_MIXZONEVOL = 16, //!< Tank mixing zone volume
@@ -47,74 +49,74 @@ typedef enum {
EN_MAXLEVEL = 21, //!< Tank maximum level
EN_MIXFRACTION = 22, //!< Tank mixing fraction
EN_TANK_KBULK = 23, //!< Tank bulk decay coefficient
- EN_TANKVOLUME = 24, //!< Tank current volume
+ EN_TANKVOLUME = 24, //!< Current computed tank volume
EN_MAXVOLUME = 25 //!< Tank maximum volume
} EN_NodeProperty;
/// Link property codes
typedef enum {
EN_DIAMETER = 0, //!< Pipe/valve diameter
- EN_LENGTH = 1, //!> Pipe length
- EN_ROUGHNESS = 2, //!> Pipe roughness coefficient
- EN_MINORLOSS = 3, //!> Pipe/valve minor loss coefficient
- EN_INITSTATUS = 4, //!> Initial status (e.g., OPEN/CLOSED)
- EN_INITSETTING = 5, //!> Initial pump speed or valve setting
- EN_KBULK = 6, //!> Bulk chemical reaction coefficient
- EN_KWALL = 7, //!> Pipe wall chemical reaction coefficient
- EN_FLOW = 8, //!> Current link flow rate
- EN_VELOCITY = 9, //!> Current link flow velocity
- EN_HEADLOSS = 10, //!> Current head loss across link
- EN_STATUS = 11, //!> Current link status
- EN_SETTING = 12, //!> Current link setting
- EN_ENERGY = 13, //!> Current pump energy usage
- EN_LINKQUAL = 14, //!> Current link quality
- EN_LINKPATTERN = 15, //!> Pump speed time pattern
+ EN_LENGTH = 1, //!< Pipe length
+ EN_ROUGHNESS = 2, //!< Pipe roughness coefficient
+ EN_MINORLOSS = 3, //!< Pipe/valve minor loss coefficient
+ EN_INITSTATUS = 4, //!< Initial status (e.g., OPEN/CLOSED)
+ EN_INITSETTING = 5, //!< Initial pump speed or valve setting
+ EN_KBULK = 6, //!< Bulk chemical reaction coefficient
+ EN_KWALL = 7, //!< Pipe wall chemical reaction coefficient
+ EN_FLOW = 8, //!< Current computed flow rate
+ EN_VELOCITY = 9, //!< Current computed flow velocity
+ EN_HEADLOSS = 10, //!< Current computed head loss
+ EN_STATUS = 11, //!< Current link status
+ EN_SETTING = 12, //!< Current link setting
+ EN_ENERGY = 13, //!< Current computed pump energy usage
+ EN_LINKQUAL = 14, //!< Current computed link quality
+ EN_LINKPATTERN = 15, //!< Pump speed time pattern
- EN_PUMP_STATE = 16, //!> Current pump status
- EN_PUMP_EFFIC = 17, //!> Current pump efficiency
- EN_PUMP_POWER = 18, //!> Pump constant power rating
- EN_PUMP_HCURVE = 19, //!> Pump head v. flow curve
- EN_PUMP_ECURVE = 20, //!> Pump efficiency v. flow curve
- EN_PUMP_ECOST = 21, //!> Pump average energy price
- EN_PUMP_EPAT = 22 //!> Pump energy price time pattern
+ EN_PUMP_STATE = 16, //!< Current computed pump state
+ EN_PUMP_EFFIC = 17, //!< Current computed pump efficiency
+ EN_PUMP_POWER = 18, //!< Pump constant power rating
+ EN_PUMP_HCURVE = 19, //!< Pump head v. flow curve
+ EN_PUMP_ECURVE = 20, //!< Pump efficiency v. flow curve
+ EN_PUMP_ECOST = 21, //!< Pump average energy price
+ EN_PUMP_EPAT = 22 //!< Pump energy price time pattern
} EN_LinkProperty;
-/// Time parameter codes
+/// Time parameter codes (all in seconds)
typedef enum {
- EN_DURATION = 0, //!> Total simulation duration
- EN_HYDSTEP = 1, //!> Hydraulic time step
- EN_QUALSTEP = 2, //!> Water quality time step
- EN_PATTERNSTEP = 3, //!> Time pattern period
- EN_PATTERNSTART = 4, //!> Time when time patterns begin
- EN_REPORTSTEP = 5, //!> Reporting time step
- EN_REPORTSTART = 6, //!> Time when reporting starts
- EN_RULESTEP = 7, //!> Rule evaluation time step
- EN_STATISTIC = 8, //!> Reporting statistic code
- EN_PERIODS = 9, //!> Number of reporting time periods
- EN_STARTTIME = 10, //!> Simulation starting time of day
- EN_HTIME = 11, //!> Elapsed time of current hydraulic solution
- EN_QTIME = 12, //!> Elapsed time of current quality solution
- EN_HALTFLAG = 13, //!> Flag indicating if simulation halted
- EN_NEXTEVENT = 14, //!> Next time until a tank becomes empty or full
- EN_NEXTEVENTIDX = 15 //!> Index of next tank that becomes empty or full
+ EN_DURATION = 0, //!< Total simulation duration
+ EN_HYDSTEP = 1, //!< Hydraulic time step
+ EN_QUALSTEP = 2, //!< Water quality time step
+ EN_PATTERNSTEP = 3, //!< Time pattern period
+ EN_PATTERNSTART = 4, //!< Time when time patterns begin
+ EN_REPORTSTEP = 5, //!< Reporting time step
+ EN_REPORTSTART = 6, //!< Time when reporting starts
+ EN_RULESTEP = 7, //!< Rule evaluation time step
+ EN_STATISTIC = 8, //!< Reporting statistic code
+ EN_PERIODS = 9, //!< Number of reporting time periods
+ EN_STARTTIME = 10, //!< Simulation starting time of day
+ EN_HTIME = 11, //!< Elapsed time of current hydraulic solution
+ EN_QTIME = 12, //!< Elapsed time of current quality solution
+ EN_HALTFLAG = 13, //!< Flag indicating if the simulation was halted
+ EN_NEXTEVENT = 14, //!< Next time until a tank becomes empty or full
+ EN_NEXTEVENTIDX = 15 //!< Index of next tank that becomes empty or full
} EN_TimeProperty;
-/// Analysis statistic codes
+/// Statistics for the most current hydraulic/quality analysis made
typedef enum {
- EN_ITERATIONS = 0, //!< Number of hydraulic iterations
- EN_RELATIVEERROR = 1, //!< Sum of all flow changes / total flow
+ EN_ITERATIONS = 0, //!< Number of hydraulic iterations taken
+ EN_RELATIVEERROR = 1, //!< Sum of link flow changes / sum of link flows
EN_MAXHEADERROR = 2, //!< Largest head loss error for links
EN_MAXFLOWCHANGE = 3, //!< Largest flow change in links
- EN_MASSBALANCE = 4 //!< Water quality mass balance ratio
+ EN_MASSBALANCE = 4 //!< Cumulative water quality mass balance ratio
} EN_AnalysisStatistic;
/// Object count codes
typedef enum {
- EN_NODECOUNT = 0, //!< Number of nodes (Juntions + Tanks + Reservoirs)
- EN_TANKCOUNT = 1, //!< Number of tanks and Reservoirs
- EN_LINKCOUNT = 2, //!< Number of links (Pipes + Pumps + Valves)
+ EN_NODECOUNT = 0, //!< Number of nodes (junctions + tanks + reservoirs)
+ EN_TANKCOUNT = 1, //!< Number of tanks and reservoirs
+ EN_LINKCOUNT = 2, //!< Number of links (pipes + pumps + valves)
EN_PATCOUNT = 3, //!< Number of time patterns
- EN_CURVECOUNT = 4, //!< Number of curves
+ EN_CURVECOUNT = 4, //!< Number of data curves
EN_CONTROLCOUNT = 5, //!< Number of simple controls
EN_RULECOUNT = 6 //!< Number of rule-based controls
} EN_CountType;
@@ -164,16 +166,16 @@ typedef enum {
/// Flow units types
typedef enum {
- EN_CFS = 0,
- EN_GPM = 1,
- EN_MGD = 2,
- EN_IMGD = 3,
- EN_AFD = 4,
- EN_LPS = 5,
- EN_LPM = 6,
- EN_MLD = 7,
- EN_CMH = 8,
- EN_CMD = 9
+ EN_CFS = 0, //!< Cubic feet per second
+ EN_GPM = 1, //!< Gallons per minute
+ EN_MGD = 2, //!< Million gallons per day
+ EN_IMGD = 3, //!< Imperial million gallons per day
+ EN_AFD = 4, //!< Acre-feet per day
+ EN_LPS = 5, //!< Liters per second
+ EN_LPM = 6, //!< Liters per minute
+ EN_MLD = 7, //!< Million liters per day
+ EN_CMH = 8, //!< Cubic meters per hour
+ EN_CMD = 9 //!< Cubic meters per day
} EN_FlowUnits;
/// Demand model types
@@ -184,35 +186,35 @@ typedef enum {
/// Simulation option codes
typedef enum {
- EN_TRIALS = 0, //!> Maximum hydraulic trials allowed
- EN_ACCURACY = 1, //!> Hydraulic convergence accuracy
- EN_TOLERANCE = 2, //!> Water quality tolerance
- EN_EMITEXPON = 3, //!> Exponent for emitter head loss formula
- EN_DEMANDMULT = 4, //!> Global demand multiplier
- EN_HEADERROR = 5, //!> Maximum allowable head loss error
- EN_FLOWCHANGE = 6, //!> Maximum allowable flow change
- EN_DEFDEMANDPAT = 7, //!> Default demand time pattern
- EN_HEADLOSSFORM = 8, //!> Head loss formula code
- EN_GLOBALEFFIC = 9, //!> Global pump efficiency
- EN_GLOBALPRICE = 10, //!> Global energy price per KWH
- EN_GLOBALPATTERN = 11, //!> Global energy price pattern
- EN_DEMANDCHARGE = 12 //!> Energy charge per max. KW usage
+ EN_TRIALS = 0, //!< Maximum hydraulic trials allowed
+ EN_ACCURACY = 1, //!< Hydraulic convergence accuracy
+ EN_TOLERANCE = 2, //!< Water quality tolerance
+ EN_EMITEXPON = 3, //!< Exponent for emitter head loss formula
+ EN_DEMANDMULT = 4, //!< Global demand multiplier
+ EN_HEADERROR = 5, //!< Maximum allowable head loss error
+ EN_FLOWCHANGE = 6, //!< Maximum allowable flow change
+ EN_DEFDEMANDPAT = 7, //!< Default demand time pattern
+ EN_HEADLOSSFORM = 8, //!< Head loss formula
+ EN_GLOBALEFFIC = 9, //!< Global pump efficiency
+ EN_GLOBALPRICE = 10, //!< Global energy price per KWH
+ EN_GLOBALPATTERN = 11, //!< Global energy price pattern
+ EN_DEMANDCHARGE = 12 //!< Energy charge per max. KW usage
} EN_Option;
/// Simple control types
typedef enum {
- EN_LOWLEVEL = 0,
- EN_HILEVEL = 1,
- EN_TIMER = 2,
- EN_TIMEOFDAY = 3
+ EN_LOWLEVEL = 0, //!< Act when level drops below a setpoint
+ EN_HILEVEL = 1, //!< Act when level rises above a setpoint
+ EN_TIMER = 2, //!< Act at a prescribed elapsed amount of time
+ EN_TIMEOFDAY = 3 //!< Act at a particular time of day
} EN_ControlType;
/// Reporting statistic types
typedef enum {
- EN_AVERAGE = 1, //!> Report average value over simulation period
- EN_MINIMUM = 2, //!> Report minimum value over simulation period
- EN_MAXIMUM = 3, //!> Report maximum value over simulation period
- EN_RANGE = 4 //!> Report maximum - minimum over simulation period
+ EN_AVERAGE = 1, //!< Report average value over simulation period
+ EN_MINIMUM = 2, //!< Report minimum value over simulation period
+ EN_MAXIMUM = 3, //!< Report maximum value over simulation period
+ EN_RANGE = 4 //!< Report maximum - minimum over simulation period
} EN_StatisticType;
/// Tank mixing models
@@ -225,10 +227,10 @@ typedef enum {
/// Hydraulic initialization options
typedef enum {
- EN_NOSAVE = 0, //!> Don't save hydraulics; don't re-initialize flows
- EN_SAVE = 1, //!> Save hydraulics to file, don't re-initialize flows
- EN_INITFLOW = 10, //!> Don't save hydraulics; re-initialize flows
- EN_SAVE_AND_INIT = 11 //!> Save hydraulics; re-initialize flows
+ EN_NOSAVE = 0, //!< Don't save hydraulics; don't re-initialize flows
+ EN_SAVE = 1, //!< Save hydraulics to file, don't re-initialize flows
+ EN_INITFLOW = 10, //!< Don't save hydraulics; re-initialize flows
+ EN_SAVE_AND_INIT = 11 //!< Save hydraulics; re-initialize flows
} EN_SaveOption;
/// Pump curve types
@@ -250,60 +252,60 @@ typedef enum {
/// Deletion action codes
typedef enum {
- EN_UNCONDITIONAL = 0, //!> Delete all controls that contain object
- EN_CONDITIONAL = 1 //!> Cancel object deletion if contained in controls
+ EN_UNCONDITIONAL = 0, //!< Delete all controls that contain object
+ EN_CONDITIONAL = 1 //!< Cancel object deletion if contained in controls
} EN_ActionCodeType;
-/// Status report options
+/// Options for reporting on the status of the hydraulic solver at each time period
typedef enum {
- EN_NO_REPORT = 0,
- EN_NORMAL_REPORT = 1,
- EN_FULL_REPORT = 2
+ EN_NO_REPORT = 0, //!< No status reporting
+ EN_NORMAL_REPORT = 1, //!< Normal level of status reporting
+ EN_FULL_REPORT = 2 //!< Full level of status reporting
} EN_StatusReport;
-/// Rule object codes
+/// Codes for objects referred to in the clauses of rule-based controls
typedef enum {
- EN_R_NODE = 6,
- EN_R_LINK = 7,
- EN_R_SYSTEM = 8
+ EN_R_NODE = 6, //!< Clause refers to a node
+ EN_R_LINK = 7, //!< Clause refers to a link
+ EN_R_SYSTEM = 8 //!< Clause refers to a system parameter (e.g., time)
} EN_RuleObject;
-/// Rule variable codes
+/// Codes for variables used in the clauses of rule-based controls
typedef enum {
- EN_R_DEMAND = 0,
- EN_R_HEAD = 1,
- EN_R_GRADE = 2,
- EN_R_LEVEL = 3,
- EN_R_PRESSURE = 4,
- EN_R_FLOW = 5,
- EN_R_STATUS = 6,
- EN_R_SETTING = 7,
- EN_R_POWER = 8,
- EN_R_TIME = 9,
- EN_R_CLOCKTIME = 10,
- EN_R_FILLTIME = 11,
- EN_R_DRAINTIME = 12
+ EN_R_DEMAND = 0, //!< Nodal demand
+ EN_R_HEAD = 1, //!< Nodal hydraulic head
+ EN_R_GRADE = 2, //!< Nodal hydraulic grade
+ EN_R_LEVEL = 3, //!< Tank water level
+ EN_R_PRESSURE = 4, //!< Nodal pressure
+ EN_R_FLOW = 5, //!< Link flow rate
+ EN_R_STATUS = 6, //!< Link status
+ EN_R_SETTING = 7, //!< Link setting
+ EN_R_POWER = 8, //!< Pump power output
+ EN_R_TIME = 9, //!< Elapsed simulation time
+ EN_R_CLOCKTIME = 10, //!< Time of day
+ EN_R_FILLTIME = 11, //!< Time to fill a tank
+ EN_R_DRAINTIME = 12 //!< Time to drain a tank
} EN_RuleVariable;
-/// Rule operator types
+/// Comparison operators used in the premises of rule-based controls
typedef enum {
- EN_R_EQ = 0,
- EN_R_NE = 1,
- EN_R_LE = 2,
- EN_R_GE = 3,
- EN_R_LT = 4,
- EN_R_GT = 5,
- EN_R_IS = 6,
- EN_R_NOT = 7,
- EN_R_BELOW = 8,
- EN_R_ABOVE = 9
+ EN_R_EQ = 0, //!< Equal to
+ EN_R_NE = 1, //!< Not equal
+ EN_R_LE = 2, //!< Less than or equal to
+ EN_R_GE = 3, //!< Greater than or equal to
+ EN_R_LT = 4, //!< Less than
+ EN_R_GT = 5, //!< Greater than
+ EN_R_IS = 6, //!< Is equal to
+ EN_R_NOT = 7, //!< Is not equal to
+ EN_R_BELOW = 8, //!< Is below
+ EN_R_ABOVE = 9 //!< Is above
} EN_RuleOperator;
-/// Rule status types
+/// Status codes used in the clauses of rule-based controls
typedef enum {
- EN_R_IS_OPEN = 1,
- EN_R_IS_CLOSED = 2,
- EN_R_IS_ACTIVE = 3
+ EN_R_IS_OPEN = 1, //!< Link is open
+ EN_R_IS_CLOSED = 2, //!< Link is closed
+ EN_R_IS_ACTIVE = 3 //!< Control valve is active
} EN_RuleStatus;
diff --git a/src/epanet.c b/src/epanet.c
index 9399295..e5e0135 100644
--- a/src/epanet.c
+++ b/src/epanet.c
@@ -3,11 +3,11 @@
Project: OWA EPANET
Version: 2.2
Module: epanet.c
- Description: implementation of the EPANET API functions
+ Description: implementation of EPANET's API functions
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
- Last Updated: 01/01/2019
+ Last Updated: 01/11/2019
******************************************************************************
*/
@@ -73,12 +73,13 @@ int DLLEXPORT EN_deleteproject(EN_Project *p)
return 0;
}
-int DLLEXPORT EN_runproject(EN_Project p, const char *f1, const char *f2,
- const char *f3, void (*pviewprog)(char *))
+int DLLEXPORT EN_runproject(EN_Project p, const char *inpFile,
+ const char *rptFile, const char *outFile,
+ void (*pviewprog)(char *))
/*------------------------------------------------------------------------
-** Input: f1 = name of EPANET formatted input file
-** f2 = name of report file
-** f3 = name of binary output file
+** Input: inpFile = name of EPANET formatted input file
+** rptFile = name of report file
+** outFile = name of binary output file
** pviewprog = see note below
** Output: none
** Returns: error code
@@ -96,7 +97,7 @@ int DLLEXPORT EN_runproject(EN_Project p, const char *f1, const char *f2,
int errcode = 0;
// Read in project data from an input file
- ERRCODE(EN_open(p, f1, f2, f3));
+ ERRCODE(EN_open(p, inpFile, rptFile, outFile));
p->viewprog = pviewprog;
// Solve for system hydraulics
@@ -117,11 +118,11 @@ int DLLEXPORT EN_runproject(EN_Project p, const char *f1, const char *f2,
return errcode;
}
-int DLLEXPORT EN_init(EN_Project p, const char *f2, const char *f3,
- EN_FlowUnits unitsType, EN_HeadLossType headLossType)
+int DLLEXPORT EN_init(EN_Project p, const char *rptFile, const char *outFile,
+ int unitsType, int headLossType)
/*----------------------------------------------------------------
- ** Input: f2 = name of report file
- ** f3 = name of binary output file
+ ** Input: rptFile = name of report file
+ ** outFile = name of binary output file
** unitsType = type of flow units (see EN_FlowUnits)
** headLossType = type of head loss formula (see EN_HeadLossType)
** Output: none
@@ -148,7 +149,7 @@ int DLLEXPORT EN_init(EN_Project p, const char *f2, const char *f3,
if (headLossType < 0 || headLossType > CM) return 251;
// Open files
- errcode = openfiles(p, "", f2, f3);
+ errcode = openfiles(p, "", rptFile, outFile);
// Initialize memory used for project's data objects
initpointers(p);
@@ -175,11 +176,12 @@ int DLLEXPORT EN_init(EN_Project p, const char *f2, const char *f3,
return errcode;
}
-int DLLEXPORT EN_open(EN_Project p, const char *f1, const char *f2, const char *f3)
+int DLLEXPORT EN_open(EN_Project p, const char *inpFile, const char *rptFile,
+ const char *outFile)
/*----------------------------------------------------------------
- ** Input: f1 = name of input file
- ** f2 = name of report file
- ** f3 = name of binary output file
+ ** Input: inpFile = name of input file
+ ** rptFile = name of report file
+ ** outFile = name of binary output file
** Output: none
** Returns: error code
** Purpose: opens an EPANET input file & reads in network data
@@ -202,7 +204,7 @@ int DLLEXPORT EN_open(EN_Project p, const char *f1, const char *f2, const char *
initpointers(p);
// Open input & report files
- ERRCODE(openfiles(p, f1, f2, f3));
+ ERRCODE(openfiles(p, inpFile, rptFile, outFile));
if (errcode > 0)
{
errmsg(p, errcode);
@@ -411,12 +413,12 @@ int DLLEXPORT EN_openH(EN_Project p)
return errcode;
}
-int DLLEXPORT EN_initH(EN_Project p, int flag)
+int DLLEXPORT EN_initH(EN_Project p, int initFlag)
/*----------------------------------------------------------------
- ** Input: flag = 2-digit flag where 1st (left) digit indicates
- ** if link flows should be re-initialized (1) or
- ** not (0) and 2nd digit indicates if hydraulic
- ** results should be saved to file (1) or not (0)
+ ** Input: initFlag = 2-digit flag where 1st (left) digit indicates
+ ** if link flows should be re-initialized (1) or
+ ** not (0) and 2nd digit indicates if hydraulic
+ ** results should be saved to file (1) or not (0)
** Output: none
** Returns: error code
** Purpose: initializes EPANET's hydraulic solver
@@ -431,8 +433,8 @@ int DLLEXPORT EN_initH(EN_Project p, int flag)
p->Warnflag = FALSE;
// Get values of save-to-file flag and reinitialize-flows flag
- fflag = flag / EN_INITFLOW;
- sflag = flag - fflag * EN_INITFLOW;
+ fflag = initFlag / EN_INITFLOW;
+ sflag = initFlag - fflag * EN_INITFLOW;
// Check that hydraulics solver was opened
if (!p->hydraul.OpenHflag) return 103;
@@ -456,10 +458,10 @@ int DLLEXPORT EN_initH(EN_Project p, int flag)
return errcode;
}
-int DLLEXPORT EN_runH(EN_Project p, long *t)
+int DLLEXPORT EN_runH(EN_Project p, long *currentTime)
/*----------------------------------------------------------------
** Input: none
-** Output: t = elapsed time (sec)
+** Output: currentTime = current elapsed time (sec)
** Returns: error code
** Purpose: solves network hydraulics at current time point
**----------------------------------------------------------------
@@ -467,17 +469,17 @@ int DLLEXPORT EN_runH(EN_Project p, long *t)
{
int errcode;
- *t = 0;
+ *currentTime = 0;
if (!p->hydraul.OpenHflag) return 103;
- errcode = runhyd(p, t);
+ errcode = runhyd(p, currentTime);
if (errcode) errmsg(p, errcode);
return errcode;
}
-int DLLEXPORT EN_nextH(EN_Project p, long *tstep)
+int DLLEXPORT EN_nextH(EN_Project p, long *tStep)
/*----------------------------------------------------------------
** Input: none
-** Output: tstep = next hydraulic time step to take (sec)
+** Output: tStep = next hydraulic time step to take (sec)
** Returns: error code
** Purpose: determines the time step until the next hydraulic event
**----------------------------------------------------------------
@@ -485,11 +487,11 @@ int DLLEXPORT EN_nextH(EN_Project p, long *tstep)
{
int errcode;
- *tstep = 0;
+ *tStep = 0;
if (!p->hydraul.OpenHflag) return 103;
- errcode = nexthyd(p, tstep);
+ errcode = nexthyd(p, tStep);
if (errcode) errmsg(p, errcode);
- else if (p->outfile.Saveflag && *tstep == 0) p->outfile.SaveHflag = TRUE;
+ else if (p->outfile.Saveflag && *tStep == 0) p->outfile.SaveHflag = TRUE;
return errcode;
}
@@ -643,9 +645,9 @@ int DLLEXPORT EN_openQ(EN_Project p)
return errcode;
}
-int DLLEXPORT EN_initQ(EN_Project p, int saveflag)
+int DLLEXPORT EN_initQ(EN_Project p, int saveFlag)
/*----------------------------------------------------------------
-** Input: saveflag = flag indicating if results should be saved
+** Input: saveFlag = flag indicating if results should be saved
** to the binary output file or not
** Output: none
** Returns: error code
@@ -659,7 +661,7 @@ int DLLEXPORT EN_initQ(EN_Project p, int saveflag)
initqual(p);
p->outfile.SaveQflag = FALSE;
p->outfile.Saveflag = FALSE;
- if (saveflag)
+ if (saveFlag)
{
errcode = openoutfile(p);
if (!errcode) p->outfile.Saveflag = TRUE;
@@ -667,29 +669,29 @@ int DLLEXPORT EN_initQ(EN_Project p, int saveflag)
return errcode;
}
-int DLLEXPORT EN_runQ(EN_Project p, long *t)
+int DLLEXPORT EN_runQ(EN_Project p, long *currentTime)
/*----------------------------------------------------------------
** Input: none
-** Output: t = current simulation time (sec)
+** Output: currentTime = current simulation time (sec)
** Returns: error code
-** Purpose: retrieves current hydraulic results (at time t)
-** and saves current results to file.
+** Purpose: retrieves current hydraulic results and saves current
+** results to file.
**----------------------------------------------------------------
*/
{
int errcode;
- *t = 0;
+ *currentTime = 0;
if (!p->quality.OpenQflag) return 105;
- errcode = runqual(p, t);
+ errcode = runqual(p, currentTime);
if (errcode) errmsg(p, errcode);
return errcode;
}
-int DLLEXPORT EN_nextQ(EN_Project p, long *tstep)
+int DLLEXPORT EN_nextQ(EN_Project p, long *tStep)
/*----------------------------------------------------------------
** Input: none
-** Output: tstep = time step over which water quality is updated (sec)
+** Output: tStep = time step over which water quality is updated (sec)
** Returns: error code
** Purpose: updates water quality throughout the network until
** next hydraulic event occurs.
@@ -698,10 +700,10 @@ int DLLEXPORT EN_nextQ(EN_Project p, long *tstep)
{
int errcode;
- *tstep = 0;
+ *tStep = 0;
if (!p->quality.OpenQflag) return 105;
- errcode = nextqual(p, tstep);
- if (!errcode && p->outfile.Saveflag && *tstep == 0)
+ errcode = nextqual(p, tStep);
+ if (!errcode && p->outfile.Saveflag && *tStep == 0)
{
p->outfile.SaveQflag = TRUE;
}
@@ -709,10 +711,10 @@ int DLLEXPORT EN_nextQ(EN_Project p, long *tstep)
return errcode;
}
-int DLLEXPORT EN_stepQ(EN_Project p, long *tleft)
+int DLLEXPORT EN_stepQ(EN_Project p, long *timeLeft)
/*----------------------------------------------------------------
** Input: none
-** Output: tleft = amount of simulation time remaining (sec)
+** Output: timeLeft = amount of simulation time remaining (sec)
** Returns: error code
** Purpose: updates water quality throughout the network over
** fixed time step.
@@ -721,10 +723,10 @@ int DLLEXPORT EN_stepQ(EN_Project p, long *tleft)
{
int errcode;
- *tleft = 0;
+ *timeLeft = 0;
if (!p->quality.OpenQflag) return 105;
- errcode = stepqual(p, tleft);
- if (!errcode && p->outfile.Saveflag && *tleft == 0)
+ errcode = stepqual(p, timeLeft);
+ if (!errcode && p->outfile.Saveflag && *timeLeft == 0)
{
p->outfile.SaveQflag = TRUE;
}
@@ -813,9 +815,9 @@ int DLLEXPORT EN_resetreport(EN_Project p)
return 0;
}
-int DLLEXPORT EN_setreport(EN_Project p, char *s)
+int DLLEXPORT EN_setreport(EN_Project p, char *format)
/*----------------------------------------------------------------
-** Input: s = a report formatting command
+** Input: format = a report formatting command
** Output: none
** Returns: error code
** Purpose: sets a specific set of reporting options
@@ -825,16 +827,16 @@ int DLLEXPORT EN_setreport(EN_Project p, char *s)
char s1[MAXLINE + 1];
if (!p->Openflag) return 102;
- if (strlen(s) >= MAXLINE) return 250;
- strcpy(s1, s);
+ if (strlen(format) >= MAXLINE) return 250;
+ strcpy(s1, format);
strcat(s1, "\n");
if (setreport(p, s1) > 0) return 250;
else return 0;
}
-int DLLEXPORT EN_setstatusreport(EN_Project p, int code)
+int DLLEXPORT EN_setstatusreport(EN_Project p, int level)
/*----------------------------------------------------------------
-** Input: code = level of reporting to use (see EN_StatusReport)
+** Input: level = level of reporting to use (see EN_StatusReport)
** Output: none
** Returns: error code
** Purpose: sets the level of hydraulic status reporting
@@ -843,18 +845,18 @@ int DLLEXPORT EN_setstatusreport(EN_Project p, int code)
{
int errcode = 0;
- if (code >= EN_NO_REPORT && code <= EN_FULL_REPORT)
+ if (level >= EN_NO_REPORT && level <= EN_FULL_REPORT)
{
- p->report.Statflag = (char)code;
+ p->report.Statflag = (char)level;
}
else errcode = 251;
return errcode;
}
-int DLLEXPORT EN_getversion(int *v)
+int DLLEXPORT EN_getversion(int *version)
/*----------------------------------------------------------------
** Input: none
-** Output: v = version number of the source code
+** Output: version = version number of the source code
** Returns: error code (should always be 0)
** Purpose: retrieves a number assigned to the most recent
** update of the source code. This number, set by the
@@ -864,16 +866,16 @@ int DLLEXPORT EN_getversion(int *v)
**----------------------------------------------------------------
*/
{
- *v = CODEVERSION;
+ *version = CODEVERSION;
return 0;
}
-int DLLEXPORT EN_getcount(EN_Project p, EN_CountType code, int *count)
+int DLLEXPORT EN_getcount(EN_Project p, int object, int *count)
/*----------------------------------------------------------------
-** Input: code = type of component to count (see EN_CountType)
-** Output: count = number of components of specified type
+** Input: object = type of object to count (see EN_CountType)
+** Output: count = number of objects of the specified type
** Returns: error code
-** Purpose: Retrieves number of network components of a given type
+** Purpose: Retrieves number of network objects of a given type.
**----------------------------------------------------------------
*/
{
@@ -881,7 +883,7 @@ int DLLEXPORT EN_getcount(EN_Project p, EN_CountType code, int *count)
*count = 0;
if (!p->Openflag) return 102;
- switch (code)
+ switch (object)
{
case EN_NODECOUNT:
*count = net->Nnodes;
@@ -910,10 +912,10 @@ int DLLEXPORT EN_getcount(EN_Project p, EN_CountType code, int *count)
return 0;
}
-int DLLEXPORT EN_geterror(int errcode, char *errmsg, int n)
+int DLLEXPORT EN_geterror(int errcode, char *errmsg, int maxLen)
/*----------------------------------------------------------------
** Input: errcode = an error or warnng code
-** n = maximum characters that errmsg can hold
+** maxLen = maximum characters that errmsg can hold
** Output: errmsg = text of error/warning message
** Returns: error code
** Purpose: retrieves the text of the message associated with
@@ -927,28 +929,28 @@ int DLLEXPORT EN_geterror(int errcode, char *errmsg, int n)
switch (errcode)
{
case 1:
- strncpy(errmsg, WARN1, n);
+ strncpy(errmsg, WARN1, maxLen);
break;
case 2:
- strncpy(errmsg, WARN2, n);
+ strncpy(errmsg, WARN2, maxLen);
break;
case 3:
- strncpy(errmsg, WARN3, n);
+ strncpy(errmsg, WARN3, maxLen);
break;
case 4:
- strncpy(errmsg, WARN4, n);
+ strncpy(errmsg, WARN4, maxLen);
break;
case 5:
- strncpy(errmsg, WARN5, n);
+ strncpy(errmsg, WARN5, maxLen);
break;
case 6:
- strncpy(errmsg, WARN6, n);
+ strncpy(errmsg, WARN6, maxLen);
break;
default:
sprintf(msg1, "Error %d: ", errcode);
if ((errcode >= 202 && errcode <= 222) ||
(errcode >= 240 && errcode <= 261)) strcat(msg1, "function call contains ");
- snprintf(errmsg, n, "%s%s", msg1, geterrmsg(errcode, msg2));
+ snprintf(errmsg, maxLen, "%s%s", msg1, geterrmsg(errcode, msg2));
}
if (strlen(errmsg) == 0)
return 251;
@@ -956,31 +958,31 @@ int DLLEXPORT EN_geterror(int errcode, char *errmsg, int n)
return 0;
}
-int DLLEXPORT EN_getstatistic(EN_Project p, int code, EN_API_FLOAT_TYPE *value)
+int DLLEXPORT EN_getstatistic(EN_Project p, int type, double *value)
/*----------------------------------------------------------------
-** Input: code = simulation statistic (see EN_AnalysisStatistic)
+** Input: type = type of simulation statistic (see EN_AnalysisStatistic)
** Output: value = simulation analysis statistic value
** Returns: error code
** Purpose: retrieves the value of a simulation analysis statistic
**----------------------------------------------------------------
*/
{
- switch (code)
+ switch (type)
{
case EN_ITERATIONS:
- *value = (EN_API_FLOAT_TYPE)p->hydraul.Iterations;
+ *value = (double)p->hydraul.Iterations;
break;
case EN_RELATIVEERROR:
- *value = (EN_API_FLOAT_TYPE)p->hydraul.RelativeError;
+ *value = (double)p->hydraul.RelativeError;
break;
case EN_MAXHEADERROR:
- *value = (EN_API_FLOAT_TYPE)(p->hydraul.MaxHeadError * p->Ucf[HEAD]);
+ *value = (double)(p->hydraul.MaxHeadError * p->Ucf[HEAD]);
break;
case EN_MAXFLOWCHANGE:
- *value = (EN_API_FLOAT_TYPE)(p->hydraul.MaxFlowChange * p->Ucf[FLOW]);
+ *value = (double)(p->hydraul.MaxFlowChange * p->Ucf[FLOW]);
break;
case EN_MASSBALANCE:
- *value = (EN_API_FLOAT_TYPE)(p->quality.MassBalance.ratio);
+ *value = (double)(p->quality.MassBalance.ratio);
break;
default:
*value = 0.0;
@@ -995,10 +997,9 @@ int DLLEXPORT EN_getstatistic(EN_Project p, int code, EN_API_FLOAT_TYPE *value)
********************************************************************/
-int DLLEXPORT EN_getoption(EN_Project p, EN_Option code,
- EN_API_FLOAT_TYPE *value)
+int DLLEXPORT EN_getoption(EN_Project p, int option, double *value)
/*----------------------------------------------------------------
-** Input: code = an analysis option code (see EN_Option)
+** Input: option = an analysis option code (see EN_Option)
** Output: value = analysis option value
** Returns: error code
** Purpose: retrieves the value of an analysis option
@@ -1013,7 +1014,7 @@ int DLLEXPORT EN_getoption(EN_Project p, EN_Option code,
*value = 0.0;
if (!p->Openflag) return 102;
- switch (code)
+ switch (option)
{
case EN_TRIALS:
v = (double)hyd->MaxIter;
@@ -1059,14 +1060,14 @@ int DLLEXPORT EN_getoption(EN_Project p, EN_Option code,
default:
return 251;
}
- *value = (EN_API_FLOAT_TYPE)v;
+ *value = (double)v;
return 0;
}
-int DLLEXPORT EN_setoption(EN_Project p, int code, EN_API_FLOAT_TYPE v)
+int DLLEXPORT EN_setoption(EN_Project p, int option, double value)
/*----------------------------------------------------------------
-** Input: code = analysis option code (see EN_Option)
-** v = analysis option value
+** Input: option = analysis option code (see EN_Option)
+** value = analysis option value
** Output: none
** Returns: error code
** Purpose: sets the value for an analysis option
@@ -1082,12 +1083,12 @@ int DLLEXPORT EN_setoption(EN_Project p, int code, EN_API_FLOAT_TYPE v)
const int Njuncs = net->Njuncs;
double *Ucf = p->Ucf;
int i, j;
- int tmpPat, error;
+ int tmpPat, pat, error;
char tmpId[MAXID + 1];
- double Ke, n, ucf, value = v;
+ double Ke, n, ucf;
if (!p->Openflag) return 102;
- switch (code)
+ switch (option)
{
case EN_TRIALS:
if (value < 1.0) return 213;
@@ -1110,8 +1111,7 @@ int DLLEXPORT EN_setoption(EN_Project p, int code, EN_API_FLOAT_TYPE v)
ucf = pow(Ucf[FLOW], n) / Ucf[PRESSURE];
for (i = 1; i <= Njuncs; i++)
{
- j = EN_getnodevalue(p, i, EN_EMITTER, &v);
- Ke = v;
+ j = EN_getnodevalue(p, i, EN_EMITTER, &Ke);
if (j == 0 && Ke > 0.0) net->Node[i].Ke = ucf / pow(Ke, n);
}
hyd->Qexp = n;
@@ -1134,16 +1134,17 @@ int DLLEXPORT EN_setoption(EN_Project p, int code, EN_API_FLOAT_TYPE v)
case EN_DEFDEMANDPAT:
//check that the pattern exists or is set to zero to delete the default pattern
- if (value < 0 || value > net->Npats) return 205;
+ pat = ROUND(value);
+ if (pat < 0 || pat > net->Npats) return 205;
tmpPat = hyd->DefPat;
//get the new pattern ID
- if (value == 0)
+ if (pat == 0)
{
strncpy(tmpId, p->parser.DefPatID, MAXID);
}
else
{
- error = EN_getpatternid(p, (int)value, tmpId);
+ error = EN_getpatternid(p, pat, tmpId);
if (error != 0) return error;
}
// replace node patterns with default pattern
@@ -1154,13 +1155,13 @@ int DLLEXPORT EN_setoption(EN_Project p, int code, EN_API_FLOAT_TYPE v)
{
if (demand->Pat == tmpPat)
{
- demand->Pat = (int)value;
+ demand->Pat = pat;
strcpy(demand->Name, "");
}
}
}
strncpy(p->parser.DefPatID, tmpId, MAXID);
- hyd->DefPat = (int)value;
+ hyd->DefPat = pat;
break;
case EN_GLOBALEFFIC:
@@ -1174,9 +1175,9 @@ int DLLEXPORT EN_setoption(EN_Project p, int code, EN_API_FLOAT_TYPE v)
break;
case EN_GLOBALPATTERN:
- tmpPat = (int)(value + 0.5);
- if (tmpPat < 0 || tmpPat > net->Npats) return 205;
- hyd->Epat = tmpPat;
+ pat = ROUND(value);
+ if (pat < 0 || pat > net->Npats) return 205;
+ hyd->Epat = pat;
break;
case EN_DEMANDCHARGE:
@@ -1190,24 +1191,24 @@ int DLLEXPORT EN_setoption(EN_Project p, int code, EN_API_FLOAT_TYPE v)
return 0;
}
-int DLLEXPORT EN_getflowunits(EN_Project p, int *code)
+int DLLEXPORT EN_getflowunits(EN_Project p, int *units)
/*----------------------------------------------------------------
** Input: none
-** Output: code = flow units code (see EN_FlowUnits)
+** Output: units = flow units code (see EN_FlowUnits)
** Returns: error code
** Purpose: retrieves the flow units used by a project
**----------------------------------------------------------------
*/
{
- *code = -1;
+ *units = -1;
if (!p->Openflag) return 102;
- *code = p->parser.Flowflag;
+ *units = p->parser.Flowflag;
return 0;
}
-int DLLEXPORT EN_setflowunits(EN_Project p, int code)
+int DLLEXPORT EN_setflowunits(EN_Project p, int units)
/*----------------------------------------------------------------
-** Input: code = flow units code (see EN_FlowUnits)
+** Input: units = flow units code (see EN_FlowUnits)
** Output: none
** Returns: error code
** Purpose: sets the flow units used by a project
@@ -1228,8 +1229,8 @@ int DLLEXPORT EN_setflowunits(EN_Project p, int code)
hfactor = Ucf[HEAD];
efactor = Ucf[ELEV];
- p->parser.Flowflag = code;
- switch (code)
+ p->parser.Flowflag = units;
+ switch (units)
{
case LPS:
case LPM:
@@ -1280,9 +1281,9 @@ int DLLEXPORT EN_setflowunits(EN_Project p, int code)
return 0;
}
-int DLLEXPORT EN_gettimeparam(EN_Project p, int code, long *value)
+int DLLEXPORT EN_gettimeparam(EN_Project p, int param, long *value)
/*----------------------------------------------------------------
-** Input: code = time parameter code (see EN_TimeProperty)
+** Input: param = time parameter code (see EN_TimeProperty)
** Output: value = time parameter value
** Returns: error code
** Purpose: retrieves the value of a time parameter
@@ -1296,8 +1297,8 @@ int DLLEXPORT EN_gettimeparam(EN_Project p, int code, long *value)
*value = 0;
if (!p->Openflag) return 102;
- if (code < EN_DURATION || code > EN_NEXTEVENTIDX) return 251;
- switch (code)
+ if (param < EN_DURATION || param > EN_NEXTEVENTIDX) return 251;
+ switch (param)
{
case EN_DURATION:
*value = time->Dur;
@@ -1349,9 +1350,9 @@ int DLLEXPORT EN_gettimeparam(EN_Project p, int code, long *value)
return 0;
}
-int DLLEXPORT EN_settimeparam(EN_Project p, int code, long value)
+int DLLEXPORT EN_settimeparam(EN_Project p, int param, long value)
/*----------------------------------------------------------------
-** Input: code = time parameter code (see EN_TimeProperty)
+** Input: param = time parameter code (see EN_TimeProperty)
** value = time parameter value
** Output: none
** Returns: error code
@@ -1364,7 +1365,7 @@ int DLLEXPORT EN_settimeparam(EN_Project p, int code, long value)
if (!p->Openflag) return 102;
if (value < 0) return 213;
- switch (code)
+ switch (param)
{
case EN_DURATION:
time->Dur = value;
@@ -1431,68 +1432,68 @@ int DLLEXPORT EN_settimeparam(EN_Project p, int code, long value)
return 0;
}
-int DLLEXPORT EN_getqualinfo(EN_Project p, int *qualcode, char *chemname,
- char *chemunits, int *tracenode)
+int DLLEXPORT EN_getqualinfo(EN_Project p, int *qualType, char *chemName,
+ char *chemUnits, int *traceNode)
/*----------------------------------------------------------------
** Input: none
-** Output: qualcode = quality analysis code (see EN_QualityType)
-** chemname = name of chemical species
-** chemunits = concentration units
-** tracenode = index of node being traced
+** Output: qualType = type of quality analysis to run (see EN_QualityType)
+** chemName = name of chemical constituent
+** chemUnits = concentration units of constituent
+** traceNode = index of node being traced (if applicable)
** Returns: error code
** Purpose: retrieves water quality analysis options
**----------------------------------------------------------------
*/
{
- EN_getqualtype(p, qualcode, tracenode);
+ EN_getqualtype(p, qualType, traceNode);
if (p->quality.Qualflag == CHEM)
{
- strncpy(chemname, p->quality.ChemName, MAXID);
- strncpy(chemunits, p->quality.ChemUnits, MAXID);
+ strncpy(chemName, p->quality.ChemName, MAXID);
+ strncpy(chemUnits, p->quality.ChemUnits, MAXID);
}
else if (p->quality.Qualflag == TRACE)
{
- strncpy(chemname, w_TRACE, MAXID);
- strncpy(chemunits, u_PERCENT, MAXID);
+ strncpy(chemName, w_TRACE, MAXID);
+ strncpy(chemUnits, u_PERCENT, MAXID);
}
else if (p->quality.Qualflag == AGE)
{
- strncpy(chemname, w_AGE, MAXID);
- strncpy(chemunits, u_HOURS, MAXID);
+ strncpy(chemName, w_AGE, MAXID);
+ strncpy(chemUnits, u_HOURS, MAXID);
}
else
{
- strncpy(chemname, "", MAXID);
- strncpy(chemunits, "", MAXID);
+ strncpy(chemName, "", MAXID);
+ strncpy(chemUnits, "", MAXID);
}
return 0;
}
-int DLLEXPORT EN_getqualtype(EN_Project p, int *qualcode, int *tracenode)
+int DLLEXPORT EN_getqualtype(EN_Project p, int *qualType, int *traceNode)
/*----------------------------------------------------------------
** Input: none
-** Output: qualcode = quality analysis code (see EN_QualityType)
-** tracenode = index of node being traced
+** Output: qualType = type of quality analysis to run (see EN_QualityType)
+** traceNode = index of node being traced (for qualType = EN_TRACE)
** Output: none
** Returns: error code
** Purpose: retrieves type of quality analysis being made
**----------------------------------------------------------------
*/
{
- *tracenode = 0;
+ *traceNode = 0;
if (!p->Openflag) return 102;
- *qualcode = p->quality.Qualflag;
- if (p->quality.Qualflag == TRACE) *tracenode = p->quality.TraceNode;
+ *qualType = p->quality.Qualflag;
+ if (p->quality.Qualflag == TRACE) *traceNode = p->quality.TraceNode;
return 0;
}
-int DLLEXPORT EN_setqualtype(EN_Project p, int qualcode, char *chemname,
- char *chemunits, char *tracenode)
+int DLLEXPORT EN_setqualtype(EN_Project p, int qualType, char *chemName,
+ char *chemUnits, char *traceNode)
/*----------------------------------------------------------------
-** Input: qualcode = quality analysis code (see EN_QualityType)
-** chemname = name of chemical species
-** chemunits = concentration units
-** tracenode = index of node being traced
+** Input: qualType = type of quality analysis to run (see EN_QualityType)
+** chemname = name of chemical constituent
+** chemunits = concentration units of constituent
+** tracenode = index of node being traced (if applicable)
** Output: none
** Returns: error code
** Purpose: sets water quality analysis options
@@ -1508,13 +1509,13 @@ int DLLEXPORT EN_setqualtype(EN_Project p, int qualcode, char *chemname,
double ccf = 1.0;
if (!p->Openflag) return 102;
- if (qualcode < EN_NONE || qualcode > EN_TRACE) return 251;
- qual->Qualflag = (char)qualcode;
+ if (qualType < EN_NONE || qualType > EN_TRACE) return 251;
+ qual->Qualflag = (char)qualType;
qual->Ctol *= Ucf[QUALITY];
if (qual->Qualflag == CHEM) // Chemical analysis
{
- strncpy(qual->ChemName, chemname, MAXID);
- strncpy(qual->ChemUnits, chemunits, MAXID);
+ strncpy(qual->ChemName, chemName, MAXID);
+ strncpy(qual->ChemUnits, chemUnits, MAXID);
strncpy(rpt->Field[QUALITY].Units, qual->ChemUnits, MAXID);
strncpy(rpt->Field[REACTRATE].Units, qual->ChemUnits, MAXID);
strcat(rpt->Field[REACTRATE].Units, t_PERDAY);
@@ -1522,7 +1523,7 @@ int DLLEXPORT EN_setqualtype(EN_Project p, int qualcode, char *chemname,
}
if (qual->Qualflag == TRACE) // Source trace analysis
{
- qual->TraceNode = findnode(net, tracenode);
+ qual->TraceNode = findnode(net, traceNode);
if (qual->TraceNode == 0) return 212;
strncpy(qual->ChemName, w_TRACE, MAXID);
strncpy(qual->ChemUnits, u_PERCENT, MAXID);
@@ -1558,7 +1559,7 @@ int DLLEXPORT EN_setqualtype(EN_Project p, int qualcode, char *chemname,
********************************************************************/
-int DLLEXPORT EN_addnode(EN_Project p, char *id, EN_NodeType nodeType)
+int DLLEXPORT EN_addnode(EN_Project p, char *id, int nodeType)
/*----------------------------------------------------------------
** Input: id = node ID name
** nodeType = type of node (see EN_NodeType)
@@ -1878,31 +1879,34 @@ int DLLEXPORT EN_setnodeid(EN_Project p, int index, char *newid)
return 0;
}
-int DLLEXPORT EN_getnodetype(EN_Project p, int index, int *code)
+int DLLEXPORT EN_getnodetype(EN_Project p, int index, int *nodeType)
/*----------------------------------------------------------------
** Input: index = node index
-** Output: code = node type (see EN_NodeType)
+** Output: nodeType = node type (see EN_NodeType)
** Returns: error code
** Purpose: retrieves the type of a node
**----------------------------------------------------------------
*/
{
- *code = -1;
+ *nodeType = -1;
if (!p->Openflag) return 102;
if (index < 1 || index > p->network.Nnodes) return 203;
- if (index <= p->network.Njuncs) *code = EN_JUNCTION;
+ if (index <= p->network.Njuncs) *nodeType = EN_JUNCTION;
else
{
- if (p->network.Tank[index - p->network.Njuncs].A == 0.0) *code = EN_RESERVOIR;
- else *code = EN_TANK;
+ if (p->network.Tank[index - p->network.Njuncs].A == 0.0)
+ {
+ *nodeType = EN_RESERVOIR;
+ }
+ else *nodeType = EN_TANK;
}
return 0;
}
-int DLLEXPORT EN_getnodevalue(EN_Project p, int index, int code, EN_API_FLOAT_TYPE *value)
+int DLLEXPORT EN_getnodevalue(EN_Project p, int index, int property, double *value)
/*----------------------------------------------------------------
** Input: index = node index
-** code = node property code (see EN_NodeProperty)
+** property = node property code (see EN_NodeProperty)
** Output: value = node property value
** Returns: error code
** Purpose: retrieves a property value for a node
@@ -1933,7 +1937,7 @@ int DLLEXPORT EN_getnodevalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
if (index <= 0 || index > net->Nnodes) return 203;
// Retrieve requested property
- switch (code)
+ switch (property)
{
case EN_ELEVATION:
v = Node[index].El * Ucf[ELEV];
@@ -1983,9 +1987,9 @@ int DLLEXPORT EN_getnodevalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
case EN_SOURCEPAT:
source = Node[index].S;
if (source == NULL) return 240;
- if (code == EN_SOURCEQUAL) v = source->C0;
- else if (code == EN_SOURCEMASS) v = source->Smass * 60.0;
- else if (code == EN_SOURCEPAT) v = source->Pat;
+ if (property == EN_SOURCEQUAL) v = source->C0;
+ else if (property == EN_SOURCEMASS) v = source->Smass * 60.0;
+ else if (property == EN_SOURCEPAT) v = source->Pat;
else v = source->Type;
break;
@@ -2085,14 +2089,14 @@ int DLLEXPORT EN_getnodevalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
default:
return 251;
}
- *value = (EN_API_FLOAT_TYPE)v;
+ *value = v;
return 0;
}
-int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int code, EN_API_FLOAT_TYPE v)
+int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int property, double value)
/*----------------------------------------------------------------
** Input: index = node index
-** code = node property code (see EN_NodeProperty)
+** property = node property code (see EN_NodeProperty)
** value = node property value
** Output: none
** Returns: error code
@@ -2118,11 +2122,10 @@ int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
Pdemand demand;
Psource source;
double hTmp;
- double value = v;
if (!p->Openflag) return 102;
if (index <= 0 || index > nNodes) return 203;
- switch (code)
+ switch (property)
{
case EN_ELEVATION:
if (index <= nJuncs) Node[index].El = value / Ucf[ELEV];
@@ -2190,14 +2193,14 @@ int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
source->Pat = 0;
Node[index].S = source;
}
- if (code == EN_SOURCEQUAL) source->C0 = value;
- else if (code == EN_SOURCEPAT)
+ if (property == EN_SOURCEQUAL) source->C0 = value;
+ else if (property == EN_SOURCEPAT)
{
j = ROUND(value);
if (j < 0 || j > nPats) return 205;
source->Pat = j;
}
- else // code == EN_SOURCETYPE
+ else // property == EN_SOURCETYPE
{
j = ROUND(value);
if (j < CONCEN || j > FLOWPACED) return 251;
@@ -2338,13 +2341,13 @@ int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
return 0;
}
-int DLLEXPORT EN_setjuncdata(EN_Project p, int index, EN_API_FLOAT_TYPE elev,
- EN_API_FLOAT_TYPE dmnd, char *patID)
+int DLLEXPORT EN_setjuncdata(EN_Project p, int index, double elev,
+ double dmnd, char *dmndpat)
/*----------------------------------------------------------------
** Input: index = junction node index
** elev = junction elevation
** dmnd = junction primary base demand
-** patID = name of primary demand time pattern
+** dmndpat = name of primary demand time pattern
** Output: none
** Returns: error code
** Purpose: sets several properties for a junction node.
@@ -2362,11 +2365,11 @@ int DLLEXPORT EN_setjuncdata(EN_Project p, int index, EN_API_FLOAT_TYPE elev,
if (index <= 0 || index > net->Njuncs) return 203;
// Check that demand pattern exists
- if (strlen(patID) > 0)
+ if (strlen(dmndpat) > 0)
{
for (i = 1; i <= net->Npats; i++)
{
- if (strcmp(patID, net->Pattern[i].ID) == 0)
+ if (strcmp(dmndpat, net->Pattern[i].ID) == 0)
{
patIndex = i;
break;
@@ -2388,10 +2391,10 @@ int DLLEXPORT EN_setjuncdata(EN_Project p, int index, EN_API_FLOAT_TYPE elev,
return 0;
}
-int DLLEXPORT EN_settankdata(EN_Project p, int index, EN_API_FLOAT_TYPE elev,
- EN_API_FLOAT_TYPE initlvl, EN_API_FLOAT_TYPE minlvl,
- EN_API_FLOAT_TYPE maxlvl, EN_API_FLOAT_TYPE diam,
- EN_API_FLOAT_TYPE minvol, char *volcurve)
+int DLLEXPORT EN_settankdata(EN_Project p, int index, double elev,
+ double initlvl, double minlvl,
+ double maxlvl, double diam,
+ double minvol, char *volcurve)
/*----------------------------------------------------------------
** Input: index = tank node index
** elev = tank bottom elevation
@@ -2462,8 +2465,7 @@ int DLLEXPORT EN_settankdata(EN_Project p, int index, EN_API_FLOAT_TYPE elev,
}
-int DLLEXPORT EN_getcoord(EN_Project p, int index, EN_API_FLOAT_TYPE *x,
- EN_API_FLOAT_TYPE *y)
+int DLLEXPORT EN_getcoord(EN_Project p, int index, double *x, double *y)
/*----------------------------------------------------------------
** Input: index = node index
** Output: x = node x-coordinate
@@ -2484,13 +2486,12 @@ int DLLEXPORT EN_getcoord(EN_Project p, int index, EN_API_FLOAT_TYPE *x,
if (node->X == MISSING ||
node->Y == MISSING) return 254;
- *x = (EN_API_FLOAT_TYPE)(node->X);
- *y = (EN_API_FLOAT_TYPE)(node->Y);
+ *x = (double)(node->X);
+ *y = (double)(node->Y);
return 0;
}
-int DLLEXPORT EN_setcoord(EN_Project p, int index, EN_API_FLOAT_TYPE x,
- EN_API_FLOAT_TYPE y)
+int DLLEXPORT EN_setcoord(EN_Project p, int index, double x, double y)
/*----------------------------------------------------------------
** Input: index = node index
** x = node x-coordinate
@@ -2518,11 +2519,11 @@ int DLLEXPORT EN_setcoord(EN_Project p, int index, EN_API_FLOAT_TYPE x,
********************************************************************/
-int DLLEXPORT EN_getdemandmodel(EN_Project p, int *type, EN_API_FLOAT_TYPE *pmin,
- EN_API_FLOAT_TYPE *preq, EN_API_FLOAT_TYPE *pexp)
+int DLLEXPORT EN_getdemandmodel(EN_Project p, int *model, double *pmin,
+ double *preq, double *pexp)
/*----------------------------------------------------------------
** Input: none
-** Output: type = type of demand model (see EN_DemandModel)
+** Output: model = type of demand model (see EN_DemandModel)
** pmin = minimum pressure for any demand
** preq = required pressure for full demand
** pexp = exponent in pressure dependent demand formula
@@ -2531,17 +2532,17 @@ int DLLEXPORT EN_getdemandmodel(EN_Project p, int *type, EN_API_FLOAT_TYPE *pmin
**----------------------------------------------------------------
*/
{
- *type = p->hydraul.DemandModel;
- *pmin = (EN_API_FLOAT_TYPE)(p->hydraul.Pmin * p->Ucf[PRESSURE]);
- *preq = (EN_API_FLOAT_TYPE)(p->hydraul.Preq * p->Ucf[PRESSURE]);
- *pexp = (EN_API_FLOAT_TYPE)(p->hydraul.Pexp);
+ *model = p->hydraul.DemandModel;
+ *pmin = (double)(p->hydraul.Pmin * p->Ucf[PRESSURE]);
+ *preq = (double)(p->hydraul.Preq * p->Ucf[PRESSURE]);
+ *pexp = (double)(p->hydraul.Pexp);
return 0;
}
-int DLLEXPORT EN_setdemandmodel(EN_Project p, int type, EN_API_FLOAT_TYPE pmin,
- EN_API_FLOAT_TYPE preq, EN_API_FLOAT_TYPE pexp)
+int DLLEXPORT EN_setdemandmodel(EN_Project p, int model, double pmin,
+ double preq, double pexp)
/*----------------------------------------------------------------
-** Input: type = type of demand model (see EN_DemandModel)
+** Input: model = type of demand model (see EN_DemandModel)
** pmin = minimum pressure for any demand
** preq = required pressure for full demand
** pexp = exponent in pressure dependent demand formula
@@ -2551,9 +2552,9 @@ int DLLEXPORT EN_setdemandmodel(EN_Project p, int type, EN_API_FLOAT_TYPE pmin,
**----------------------------------------------------------------
*/
{
- if (type < 0 || type > EN_PDA) return 251;
+ if (model < 0 || model > EN_PDA) return 251;
if (pmin > preq || pexp <= 0.0) return 209;
- p->hydraul.DemandModel = type;
+ p->hydraul.DemandModel = model;
p->hydraul.Pmin = pmin / p->Ucf[PRESSURE];
p->hydraul.Preq = preq / p->Ucf[PRESSURE];
p->hydraul.Pexp = pexp;
@@ -2582,11 +2583,11 @@ int DLLEXPORT EN_getnumdemands(EN_Project p, int nodeIndex, int *numDemands)
return 0;
}
-int DLLEXPORT EN_getbasedemand(EN_Project p, int nodeIndex, int demandIdx,
- EN_API_FLOAT_TYPE *baseDemand)
+int DLLEXPORT EN_getbasedemand(EN_Project p, int nodeIndex, int demandIndex,
+ double *baseDemand)
/*----------------------------------------------------------------
** Input: nodeIndex = node index
-** demandIdx = demand category index
+** demandIndex = demand category index
** Output: baseDemand = baseline demand value
** Returns: error code
** Purpose: retrieves the baseline value for a node's demand category
@@ -2603,20 +2604,20 @@ int DLLEXPORT EN_getbasedemand(EN_Project p, int nodeIndex, int demandIdx,
// Retrieve demand for specified category
if (nodeIndex <= p->network.Njuncs)
{
- for (d = p->network.Node[nodeIndex].D; n < demandIdx && d->next != NULL;
+ for (d = p->network.Node[nodeIndex].D; n < demandIndex && d->next != NULL;
d = d->next) n++;
- if (n != demandIdx) return 253;
- *baseDemand = (EN_API_FLOAT_TYPE)(d->Base * p->Ucf[FLOW]);
+ if (n != demandIndex) return 253;
+ *baseDemand = (double)(d->Base * p->Ucf[FLOW]);
}
- else *baseDemand = (EN_API_FLOAT_TYPE)(0.0);
+ else *baseDemand = (double)(0.0);
return 0;
}
-int DLLEXPORT EN_setbasedemand(EN_Project p, int nodeIndex, int demandIdx,
- EN_API_FLOAT_TYPE baseDemand)
+int DLLEXPORT EN_setbasedemand(EN_Project p, int nodeIndex, int demandIndex,
+ double baseDemand)
/*----------------------------------------------------------------
** Input: nodeIndex = node index
-** demandIdx = demand category index
+** demandIndex = demand category index
** baseDemand = baseline demand value
** Output: none
** Returns: error code
@@ -2634,18 +2635,19 @@ int DLLEXPORT EN_setbasedemand(EN_Project p, int nodeIndex, int demandIdx,
// Set baseline demand for specified category
if (nodeIndex <= p->network.Njuncs)
{
- for (d = p->network.Node[nodeIndex].D; n < demandIdx && d->next != NULL;
+ for (d = p->network.Node[nodeIndex].D; n < demandIndex && d->next != NULL;
d = d->next) n++;
- if (n != demandIdx) return 253;
+ if (n != demandIndex) return 253;
d->Base = baseDemand / p->Ucf[FLOW];
}
return 0;
}
-int DLLEXPORT EN_getdemandname(EN_Project p, int nodeIndex, int demandIdx, char *demandName)
+int DLLEXPORT EN_getdemandname(EN_Project p, int nodeIndex, int demandIndex,
+ char *demandName)
/*----------------------------------------------------------------
** Input: nodeIndex = node index
-** demandIdx = demand category index
+** demandIndex = demand category index
** Output: demandname = demand category name
** Returns: error code
** Purpose: retrieves the name assigned to a node's demand category
@@ -2663,16 +2665,17 @@ int DLLEXPORT EN_getdemandname(EN_Project p, int nodeIndex, int demandIdx, char
// Locate demand category record and retrieve its name
for (d = p->network.Node[nodeIndex].D;
- n < demandIdx && d->next != NULL; d = d->next) n++;
- if (n != demandIdx) return 253;
+ n < demandIndex && d->next != NULL; d = d->next) n++;
+ if (n != demandIndex) return 253;
strcpy(demandName, d->Name);
return 0;
}
-int DLLEXPORT EN_setdemandname(EN_Project p, int nodeIndex, int demandIdx, char *demandName)
+int DLLEXPORT EN_setdemandname(EN_Project p, int nodeIndex, int demandIndex,
+ char *demandName)
/*----------------------------------------------------------------
** Input: nodeIndex = node index
-** demandIdx = demand category index
+** demandIndex = demand category index
** demandName = name of demand category
** Output: none
** Returns: error code
@@ -2689,17 +2692,18 @@ int DLLEXPORT EN_setdemandname(EN_Project p, int nodeIndex, int demandIdx, char
// Locate demand category record and assign demandName to it
for (d = p->network.Node[nodeIndex].D;
- n < demandIdx && d->next != NULL; d = d->next) n++;
- if (n != demandIdx) return 253;
+ n < demandIndex && d->next != NULL; d = d->next) n++;
+ if (n != demandIndex) return 253;
strncpy(d->Name, demandName, MAXMSG);
return 0;
}
-int DLLEXPORT EN_getdemandpattern(EN_Project p, int nodeIndex, int demandIdx, int *patIdx)
+int DLLEXPORT EN_getdemandpattern(EN_Project p, int nodeIndex, int demandIndex,
+ int *patIndex)
/*----------------------------------------------------------------
** Input: nodeIndex = node index
-** demandIdx = demand category index
-** Output: patIdx = time pattern index
+** demandIndex = demand category index
+** Output: patIndex = time pattern index
** Returns: error code
** Purpose: retrieves the time pattern assigned to a node's
** demand category
@@ -2713,17 +2717,18 @@ int DLLEXPORT EN_getdemandpattern(EN_Project p, int nodeIndex, int demandIdx, in
if (!p->Openflag) return 102;
if (nodeIndex <= 0 || nodeIndex > p->network.Nnodes) return 203;
for (d = p->network.Node[nodeIndex].D;
- n < demandIdx && d->next != NULL; d = d->next) n++;
- if (n != demandIdx) return 253;
- *patIdx = d->Pat;
+ n < demandIndex && d->next != NULL; d = d->next) n++;
+ if (n != demandIndex) return 253;
+ *patIndex = d->Pat;
return 0;
}
-int DLLEXPORT EN_setdemandpattern(EN_Project p, int nodeIndex, int demandIdx, int patIdx)
+int DLLEXPORT EN_setdemandpattern(EN_Project p, int nodeIndex, int demandIndex,
+ int patIndex)
/*----------------------------------------------------------------
** Input: nodeIndex = node index
-** demandIdx = demand category index
-** patIdx = time pattern index
+** demandIndex = demand category index
+** patIndex = time pattern index
** Output: none
** Returns: error code
** Purpose: assigns a time pattern to a node's demand category
@@ -2738,15 +2743,15 @@ int DLLEXPORT EN_setdemandpattern(EN_Project p, int nodeIndex, int demandIdx, i
// Check for valid arguments
if (!p->Openflag) return 102;
if (nodeIndex <= 0 || nodeIndex > net->Nnodes) return 203;
- if (patIdx <= 0 || patIdx > net->Npats) return 205;
+ if (patIndex <= 0 || patIndex > net->Npats) return 205;
// Locate demand category record and assign time pattern to it
if (nodeIndex <= net->Njuncs)
{
for (d = net->Node[nodeIndex].D;
- n < demandIdx && d->next != NULL; d = d->next) n++;
- if (n != demandIdx) return 253;
- d->Pat = patIdx;
+ n < demandIndex && d->next != NULL; d = d->next) n++;
+ if (n != demandIndex) return 253;
+ d->Pat = patIndex;
}
return 0;
}
@@ -2757,7 +2762,7 @@ int DLLEXPORT EN_setdemandpattern(EN_Project p, int nodeIndex, int demandIdx, i
********************************************************************/
-int DLLEXPORT EN_addlink(EN_Project p, char *id, EN_LinkType linkType,
+int DLLEXPORT EN_addlink(EN_Project p, char *id, int linkType,
char *fromNode, char *toNode)
/*----------------------------------------------------------------
** Input: id = link ID name
@@ -2905,7 +2910,7 @@ int DLLEXPORT EN_deletelink(EN_Project p, int index, int actionCode)
int i;
int pumpindex;
int valveindex;
- EN_LinkType linkType;
+ int linkType;
Slink *link;
// Cannot modify network structure while solvers are active
@@ -3051,33 +3056,33 @@ int DLLEXPORT EN_setlinkid(EN_Project p, int index, char *newid)
return 0;
}
-int DLLEXPORT EN_getlinktype(EN_Project p, int index, EN_LinkType *code)
+int DLLEXPORT EN_getlinktype(EN_Project p, int index, int *linkType)
/*----------------------------------------------------------------
** Input: index = link index
-** Output: code = link type (see EN_LinkType)
+** Output: linkType = link type (see EN_LinkType)
** Returns: error code
** Purpose: retrieves the type code of a link
**----------------------------------------------------------------
*/
{
- *code = -1;
+ *linkType = -1;
if (!p->Openflag) return 102;
if (index < 1 || index > p->network.Nlinks) return 204;
- *code = p->network.Link[index].Type;
+ *linkType = p->network.Link[index].Type;
return 0;
}
-int DLLEXPORT EN_setlinktype(EN_Project p, int *index, EN_LinkType type, int actionCode)
+int DLLEXPORT EN_setlinktype(EN_Project p, int *index, int linkType, int actionCode)
/*----------------------------------------------------------------
** Input: index = link index
-** type = link type (see EN_LinkType)
+** linkType = new link type (see EN_LinkType)
** actionCode = how to treat controls that contain the link:
** EN_UNCONDITIONAL deletes all such controls,
** EN_CONDITIONAL cancels the type change if the link appears
** in a control and returns an error code
** Output: none
** Returns: error code
-** Purpose: retrieves the ID name of an indexed link
+** Purpose: changes the type of a particular link (e.g. pipe to pump)
**----------------------------------------------------------------
*/
{
@@ -3088,14 +3093,14 @@ int DLLEXPORT EN_setlinktype(EN_Project p, int *index, EN_LinkType type, int act
char id1[MAXID + 1];
char id2[MAXID + 1];
int errcode;
- EN_LinkType oldtype;
+ int oldType;
// Cannot modify network structure while solvers are active
if (!p->Openflag) return 102;
if (p->hydraul.OpenHflag || p->quality.OpenQflag) return 262;
// Check for valid input parameters
- if (type < 0 || type > GPV || actionCode < EN_UNCONDITIONAL ||
+ if (linkType < 0 || linkType > GPV || actionCode < EN_UNCONDITIONAL ||
actionCode > EN_CONDITIONAL)
{
return 251;
@@ -3105,8 +3110,8 @@ int DLLEXPORT EN_setlinktype(EN_Project p, int *index, EN_LinkType type, int act
if (i <= 0 || i > net->Nlinks) return 204;
// Check if current link type equals new type
- EN_getlinktype(p, i, &oldtype);
- if (oldtype == type) return 0;
+ EN_getlinktype(p, i, &oldType);
+ if (oldType == linkType) return 0;
// Type change will be cancelled if link appears in any controls
if (actionCode == EN_CONDITIONAL)
@@ -3116,10 +3121,10 @@ int DLLEXPORT EN_setlinktype(EN_Project p, int *index, EN_LinkType type, int act
}
// Pipe changing from or to having a check valve
- if (oldtype <= PIPE && type <= PIPE)
+ if (oldType <= PIPE && linkType <= PIPE)
{
- net->Link[i].Type = type;
- if (type == CVPIPE) net->Link[i].Status = OPEN;
+ net->Link[i].Type = linkType;
+ if (linkType == CVPIPE) net->Link[i].Status = OPEN;
return 0;
}
@@ -3130,14 +3135,14 @@ int DLLEXPORT EN_setlinktype(EN_Project p, int *index, EN_LinkType type, int act
EN_getnodeid(p, n2, id2);
// Check for illegal valve connections
- errcode = valvecheck(p, type, n1, n2);
+ errcode = valvecheck(p, linkType, n1, n2);
if (errcode) return errcode;
// Delete the original link (and any controls containing it)
EN_deletelink(p, i, actionCode);
// Create a new link of new type and old id
- errcode = EN_addlink(p, id, type, id1, id2);
+ errcode = EN_addlink(p, id, linkType, id1, id2);
// Find the index of this new link
EN_getlinkindex(p, id, index);
@@ -3200,11 +3205,10 @@ int DLLEXPORT EN_setlinknodes(EN_Project p, int index, int node1, int node2)
return 0;
}
-int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, EN_LinkProperty code,
- EN_API_FLOAT_TYPE *value)
+int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, int property, double *value)
/*----------------------------------------------------------------
** Input: index = link index
-** code = link property code (see EN_LinkProperty)
+** property = link property code (see EN_LinkProperty)
** Output: value = link property value
** Returns: error code
** Purpose: retrieves a property value for a link
@@ -3228,7 +3232,7 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, EN_LinkProperty code,
if (index <= 0 || index > net->Nlinks) return 204;
// Retrieve called-for property
- switch (code)
+ switch (property)
{
case EN_DIAMETER:
if (Link[index].Type == EN_PUMP) v = 0.0;
@@ -3321,32 +3325,6 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, EN_LinkProperty code,
else v = 1.0;
break;
- case EN_PUMP_STATE:
- v = hyd->LinkStatus[index];
-
- if (Link[index].Type == EN_PUMP)
- {
- pmp = findpump(net, index);
- if (hyd->LinkStatus[index] >= OPEN)
- {
- if (hyd->LinkFlow[index] > hyd->LinkSetting[index] * Pump[pmp].Qmax)
- {
- v = XFLOW;
- }
- if (hyd->LinkFlow[index] < 0.0) v = XHEAD;
- }
- }
- break;
-
- case EN_PUMP_POWER:
- v = 0;
- if (Link[index].Type == EN_PUMP)
- {
- pmp = findpump(net, index);
- if (Pump[pmp].Ptype == CONST_HP) v = Link[index].Km; // Power in HP or KW
- }
- break;
-
case EN_SETTING:
if (Link[index].Type == EN_PIPE || Link[index].Type == EN_CVPIPE)
{
@@ -3383,14 +3361,33 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, EN_LinkProperty code,
}
break;
+ case EN_PUMP_STATE:
+ v = hyd->LinkStatus[index];
+
+ if (Link[index].Type == EN_PUMP)
+ {
+ pmp = findpump(net, index);
+ if (hyd->LinkStatus[index] >= OPEN)
+ {
+ if (hyd->LinkFlow[index] > hyd->LinkSetting[index] * Pump[pmp].Qmax)
+ {
+ v = XFLOW;
+ }
+ if (hyd->LinkFlow[index] < 0.0) v = XHEAD;
+ }
+ }
+ break;
+
case EN_PUMP_EFFIC:
getenergy(p, index, &a, &v);
break;
- case EN_PUMP_EPAT:
+ case EN_PUMP_POWER:
+ v = 0;
if (Link[index].Type == EN_PUMP)
{
- v = (double)Pump[findpump(&p->network, index)].Epat;
+ pmp = findpump(net, index);
+ if (Pump[pmp].Ptype == CONST_HP) v = Link[index].Km; // Power in HP or KW
}
break;
@@ -3407,19 +3404,33 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, EN_LinkProperty code,
v = (double)Pump[findpump(&p->network, index)].Ecurve;
}
break;
+
+ case EN_PUMP_ECOST:
+ if (Link[index].Type == EN_PUMP)
+ {
+ v = (double)Pump[findpump(&p->network, index)].Ecost;
+ }
+ break;
+
+ case EN_PUMP_EPAT:
+ if (Link[index].Type == EN_PUMP)
+ {
+ v = (double)Pump[findpump(&p->network, index)].Epat;
+ }
+ break;
default:
return 251;
}
- *value = (EN_API_FLOAT_TYPE)v;
+ *value = (double)v;
return 0;
}
-int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int code, EN_API_FLOAT_TYPE v)
+int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double value)
/*----------------------------------------------------------------
** Input: index = link index
-** code = link property code (see EN_LinkProperty)
-** v = property value
+** property = link property code (see EN_LinkProperty)
+** value = property value
** Output: none
** Returns: error code
** Purpose: sets a property value for a link
@@ -3434,12 +3445,12 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
double *Ucf = p->Ucf;
double *LinkSetting = hyd->LinkSetting;
char s;
- double r, value = v;
+ double r;
int pumpIndex, patIndex, curveIndex;
if (!p->Openflag) return 102;
if (index <= 0 || index > net->Nlinks) return 204;
- switch (code)
+ switch (property)
{
case EN_DIAMETER:
if (Link[index].Type != EN_PUMP)
@@ -3487,7 +3498,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
if (Link[index].Type == EN_CVPIPE) return 207;
s = (char)ROUND(value);
if (s < 0 || s > 1) return 211;
- if (code == EN_INITSTATUS)
+ if (property == EN_INITSTATUS)
{
setlinkstatus(p, index, s, &Link[index].Status, &Link[index].Kc);
}
@@ -3502,7 +3513,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
if (value < 0.0) return 211;
if (Link[index].Type == EN_PIPE || Link[index].Type == EN_CVPIPE)
{
- return EN_setlinkvalue(p, index, EN_ROUGHNESS, v);
+ return EN_setlinkvalue(p, index, EN_ROUGHNESS, value);
}
else
{
@@ -3525,7 +3536,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
default:
return 0;
}
- if (code == EN_INITSETTING)
+ if (property == EN_INITSETTING)
{
setlinksetting(p, index, value, &Link[index].Status, &Link[index].Kc);
}
@@ -3556,13 +3567,46 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
case EN_LINKPATTERN:
if (Link[index].Type == EN_PUMP)
{
- patIndex = (int) (value + 0.5);
+ patIndex = ROUND(value);
if (patIndex <= 0 || patIndex > net->Npats) return 205;
pumpIndex = findpump(&p->network, index);
net->Pump[pumpIndex].Upat = patIndex;
}
break;
+ case EN_PUMP_POWER:
+ if (Link[index].Type == EN_PUMP)
+ {
+ if (value <= 0.0) return 211;
+ pumpIndex = findpump(&p->network, index);
+ net->Pump[pumpIndex].Ptype = CONST_HP;
+ net->Pump[pumpIndex].Hcurve = 0;
+ net->Link[index].Km = value;
+ updatepumpparams(p, pumpIndex);
+ net->Pump[pumpIndex].R /= Ucf[POWER];
+ net->Pump[pumpIndex].Q0 /= Ucf[FLOW];
+ net->Pump[pumpIndex].Qmax /= Ucf[FLOW];
+ net->Pump[pumpIndex].Hmax /= Ucf[HEAD];
+ }
+ break;
+
+ case EN_PUMP_HCURVE:
+ if (Link[index].Type == EN_PUMP)
+ {
+ return EN_setheadcurveindex(p, index, ROUND(value));
+ }
+ break;
+
+ case EN_PUMP_ECURVE:
+ if (Link[index].Type == EN_PUMP)
+ {
+ curveIndex = ROUND(value);
+ if (curveIndex <= 0 || curveIndex > net->Ncurves) return 205;
+ pumpIndex = findpump(&p->network, index);
+ net->Pump[pumpIndex].Ecurve = curveIndex;
+ }
+ break;
+
case EN_PUMP_ECOST:
if (Link[index].Type == EN_PUMP)
{
@@ -3575,54 +3619,21 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
case EN_PUMP_EPAT:
if (Link[index].Type == EN_PUMP)
{
- patIndex = (int)(value + 0.5);
+ patIndex = ROUND(value);
if (patIndex <= 0 || patIndex > net->Npats) return 205;
pumpIndex = findpump(&p->network, index);
net->Pump[pumpIndex].Epat = patIndex;
}
break;
- case EN_PUMP_HCURVE:
- if (Link[index].Type == EN_PUMP)
- {
- return EN_setheadcurveindex(p, index, (int)(value + 0.5));
- }
- break;
-
- case EN_PUMP_POWER:
- if (Link[index].Type == EN_PUMP)
- {
- if (value <= 0.0) return 211;
- pumpIndex = findpump(&p->network, index);
- net->Pump[pumpIndex].Ptype = CONST_HP;
- net->Pump[pumpIndex].Hcurve = 0;
- net->Link[index].Km = v;
- updatepumpparams(p, pumpIndex);
- net->Pump[pumpIndex].R /= Ucf[POWER];
- net->Pump[pumpIndex].Q0 /= Ucf[FLOW];
- net->Pump[pumpIndex].Qmax /= Ucf[FLOW];
- net->Pump[pumpIndex].Hmax /= Ucf[HEAD];
- }
- break;
-
- case EN_PUMP_ECURVE:
- if (Link[index].Type == EN_PUMP)
- {
- curveIndex = (int)(v + 0.5);
- if (curveIndex <= 0 || curveIndex > net->Ncurves) return 205;
- pumpIndex = findpump(&p->network, index);
- net->Pump[pumpIndex].Ecurve = curveIndex;
- }
- break;
-
default:
return 251;
}
return 0;
}
-int DLLEXPORT EN_setpipedata(EN_Project p, int index, EN_API_FLOAT_TYPE length,
- EN_API_FLOAT_TYPE diam, EN_API_FLOAT_TYPE rough, EN_API_FLOAT_TYPE mloss)
+int DLLEXPORT EN_setpipedata(EN_Project p, int index, double length,
+ double diam, double rough, double mloss)
/*----------------------------------------------------------------
** Input: index = pipe link index
** length = pipe length
@@ -3669,12 +3680,12 @@ int DLLEXPORT EN_setpipedata(EN_Project p, int index, EN_API_FLOAT_TYPE length,
********************************************************************/
-int DLLEXPORT EN_getpumptype(EN_Project p, int index, int *type) //2.1
+int DLLEXPORT EN_getpumptype(EN_Project p, int linkIndex, int *pumpType)
/*----------------------------------------------------------------
-** Input: index = index of a pump link
-** Output: type = type of pump characteristic curve (see EN_PumpType)
+** Input: linkIndex = index of a pump link
+** Output: pumpType = type of pump head curve (see EN_PumpType)
** Returns: error code
-** Purpose: retrieves the type of characteristic curve used by a pump
+** Purpose: retrieves the type of head curve used by a pump
**----------------------------------------------------------------
*/
{
@@ -3684,20 +3695,20 @@ int DLLEXPORT EN_getpumptype(EN_Project p, int index, int *type) //2.1
Spump *Pump = net->Pump;
const int Nlinks = net->Nlinks;
- *type = -1;
+ *pumpType = -1;
if (!p->Openflag) return 102;
- if (index < 1 || index > Nlinks) return 204;
- if (EN_PUMP != Link[index].Type) return 216;
- *type = Pump[findpump(&p->network, index)].Ptype;
+ if (linkIndex < 1 || linkIndex > Nlinks) return 204;
+ if (EN_PUMP != Link[linkIndex].Type) return 216;
+ *pumpType = Pump[findpump(&p->network, linkIndex)].Ptype;
return 0;
}
-int DLLEXPORT EN_getheadcurveindex(EN_Project p, int index, int *curveindex) //2.1
+int DLLEXPORT EN_getheadcurveindex(EN_Project p, int linkIndex, int *curveIndex)
/*----------------------------------------------------------------
-** Input: index = index of a pump link
-** Output: curveindex = index of a pump's characteristic curve
+** Input: linkIndex = index of a pump link
+** Output: curveIndex = index of a pump's head curve
** Returns: error code
-** Purpose: retrieves the index of a pump's characteristic curve
+** Purpose: retrieves the index of a pump's head curve
**----------------------------------------------------------------
*/
{
@@ -3707,21 +3718,21 @@ int DLLEXPORT EN_getheadcurveindex(EN_Project p, int index, int *curveindex) //
Spump *Pump = net->Pump;
const int Nlinks = net->Nlinks;
- *curveindex = 0;
+ *curveIndex = 0;
if (!p->Openflag) return 102;
- if (index < 1 || index > Nlinks) return 204;
- if (EN_PUMP != Link[index].Type) return 216;
- *curveindex = Pump[findpump(net, index)].Hcurve;
+ if (linkIndex < 1 || linkIndex > Nlinks) return 204;
+ if (EN_PUMP != Link[linkIndex].Type) return 216;
+ *curveIndex = Pump[findpump(net, linkIndex)].Hcurve;
return 0;
}
-int DLLEXPORT EN_setheadcurveindex(EN_Project p, int index, int curveindex)
+int DLLEXPORT EN_setheadcurveindex(EN_Project p, int linkIndex, int curveIndex)
/*----------------------------------------------------------------
-** Input: index = index of a pump link
-** curveindex = index of a pump's characteristic curve
+** Input: linkIndex = index of a pump link
+** curveIndex = index of a curve
** Output: none
** Returns: error code
-** Purpose: assigns a new characteristic curve to a pump
+** Purpose: assigns a new head curve to a pump
**----------------------------------------------------------------
*/
{
@@ -3731,23 +3742,23 @@ int DLLEXPORT EN_setheadcurveindex(EN_Project p, int index, int curveindex)
const int Nlinks = net->Nlinks;
const int Ncurves = net->Ncurves;
double *Ucf = p->Ucf;
- int pIdx;
+ int pumpIndex;
Spump *pump;
// Check for valid parameters
if (!p->Openflag) return 102;
- if (index < 1 || index > net->Nlinks) return 204;
- if (EN_PUMP != net->Link[index].Type) return 0;
- if (curveindex <= 0 || curveindex > net->Ncurves) return 206;
+ if (linkIndex < 1 || linkIndex > net->Nlinks) return 204;
+ if (EN_PUMP != net->Link[linkIndex].Type) return 0;
+ if (curveIndex <= 0 || curveIndex > net->Ncurves) return 206;
// Assign the new curve to the pump
- pIdx = findpump(net, index);
- pump = &p->network.Pump[pIdx];
+ pumpIndex = findpump(net, linkIndex);
+ pump = &p->network.Pump[pumpIndex];
pump->Ptype = NOCURVE;
- pump->Hcurve = curveindex;
+ pump->Hcurve = curveIndex;
// Update the pump curve's parameters and convert their units
- updatepumpparams(p, pIdx);
+ updatepumpparams(p, pumpIndex);
if (pump->Ptype == POWER_FUNC)
{
pump->H0 /= Ucf[HEAD];
@@ -3758,7 +3769,7 @@ int DLLEXPORT EN_setheadcurveindex(EN_Project p, int index, int curveindex)
pump->Hmax /= Ucf[HEAD];
// Designate the newly assigned curve as being a Pump Curve
- p->network.Curve[curveindex].Type = PUMP_CURVE;
+ p->network.Curve[curveIndex].Type = PUMP_CURVE;
return 0;
}
@@ -3875,13 +3886,13 @@ int DLLEXPORT EN_getpatternlen(EN_Project p, int index, int *len)
return 0;
}
-int DLLEXPORT EN_getpatternvalue(EN_Project p, int index, int period, EN_API_FLOAT_TYPE *value)
+int DLLEXPORT EN_getpatternvalue(EN_Project p, int index, int period, double *value)
/*----------------------------------------------------------------
** Input: index = time pattern index
** period = time pattern period
-** Output: value = multiplier for a particular time period
+** Output: value = pattern factor for a particular time period
** Returns: error code
-** Purpose: retrieves the multiplier for a specific time period
+** Purpose: retrieves the pattern factor for a specific time period
** in a time pattern
**----------------------------------------------------------------
*/
@@ -3890,18 +3901,18 @@ int DLLEXPORT EN_getpatternvalue(EN_Project p, int index, int period, EN_API_FLO
if (!p->Openflag) return 102;
if (index < 1 || index > p->network.Npats) return 205;
if (period < 1 || period > p->network.Pattern[index].Length) return 251;
- *value = (EN_API_FLOAT_TYPE)p->network.Pattern[index].F[period - 1];
+ *value = (double)p->network.Pattern[index].F[period - 1];
return 0;
}
-int DLLEXPORT EN_setpatternvalue(EN_Project p, int index, int period, EN_API_FLOAT_TYPE value)
+int DLLEXPORT EN_setpatternvalue(EN_Project p, int index, int period, double value)
/*----------------------------------------------------------------
** Input: index = time pattern index
** period = time pattern period
-** value = multiplier for a particular time period
+** value = pattern factor for a particular time period
** Output: none
** Returns: error code
-** Purpose: sets the multiplier for a specific time period
+** Purpose: sets the pattern factor for a specific time period
** in a time pattern
**----------------------------------------------------------------
*/
@@ -3916,12 +3927,12 @@ int DLLEXPORT EN_setpatternvalue(EN_Project p, int index, int period, EN_API_FLO
return 0;
}
-int DLLEXPORT EN_getaveragepatternvalue(EN_Project p, int index, EN_API_FLOAT_TYPE *value)
+int DLLEXPORT EN_getaveragepatternvalue(EN_Project p, int index, double *value)
/*----------------------------------------------------------------
** Input: index = time pattern index
-** Output: value = average of a time pattern's multipliers
+** Output: value = average of a time pattern's factors
** Returns: error code
-** Purpose: retrieves the average multiplier value for a time pattern
+** Purpose: retrieves the average of all pattern factors for a time pattern
**----------------------------------------------------------------
*/
{
@@ -3935,20 +3946,20 @@ int DLLEXPORT EN_getaveragepatternvalue(EN_Project p, int index, EN_API_FLOAT_TY
if (index < 1 || index > net->Npats) return 205;
for (i = 0; i < Pattern[index].Length; i++)
{
- *value += (EN_API_FLOAT_TYPE)Pattern[index].F[i];
+ *value += (double)Pattern[index].F[i];
}
- *value /= (EN_API_FLOAT_TYPE)Pattern[index].Length;
+ *value /= (double)Pattern[index].Length;
return 0;
}
-int DLLEXPORT EN_setpattern(EN_Project p, int index, EN_API_FLOAT_TYPE *f, int n)
+int DLLEXPORT EN_setpattern(EN_Project p, int index, double *values, int len)
/*----------------------------------------------------------------
** Input: index = time pattern index
-** f = an array of multiplier values
-** n = number of values in f
+** values = an array of pattern factor values
+** len = number of time periods contained in f
** Output: none
** Returns: error code
-** Purpose: replaces the multipliers in a time pattern
+** Purpose: replaces the pattern factors in a time pattern
**----------------------------------------------------------------
*/
{
@@ -3960,15 +3971,15 @@ int DLLEXPORT EN_setpattern(EN_Project p, int index, EN_API_FLOAT_TYPE *f, int n
// Check for valid arguments
if (!p->Openflag) return 102;
if (index <= 0 || index > net->Npats) return 205;
- if (n <= 0) return 251;
+ if (len <= 0) return 251;
// Re-set number of time periods & reallocate memory for multipliers
- Pattern[index].Length = n;
- Pattern[index].F = (double *)realloc(Pattern[index].F, n * sizeof(double));
+ Pattern[index].Length = len;
+ Pattern[index].F = (double *)realloc(Pattern[index].F, len * sizeof(double));
if (Pattern[index].F == NULL) return 101;
// Load multipliers into pattern
- for (j = 0; j < n; j++) Pattern[index].F[j] = f[j];
+ for (j = 0; j < len; j++) Pattern[index].F[j] = values[j];
return 0;
}
@@ -4088,7 +4099,7 @@ int DLLEXPORT EN_getcurvelen(EN_Project p, int index, int *len)
return 0;
}
-int DLLEXPORT EN_getcurvetype(EN_Project p, int curveindex, int *type)
+int DLLEXPORT EN_getcurvetype(EN_Project p, int index, int *type)
/*----------------------------------------------------------------
** Input: index = data curve index
** Output: type = type of data curve (see EN_CurveType)
@@ -4099,18 +4110,18 @@ int DLLEXPORT EN_getcurvetype(EN_Project p, int curveindex, int *type)
{
Network *net = &p->network;
if (!p->Openflag) return 102;
- if (curveindex < 1 || curveindex > net->Ncurves) return 206;
- *type = net->Curve[curveindex].Type;
+ if (index < 1 || index > net->Ncurves) return 206;
+ *type = net->Curve[index].Type;
return 0;
}
-int DLLEXPORT EN_getcurvevalue(EN_Project p, int index, int pnt,
- EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y)
+int DLLEXPORT EN_getcurvevalue(EN_Project p, int curveIndex, int pointIndex,
+ double *x, double *y)
/*----------------------------------------------------------------
-** Input: index = data curve index
-** pnt = index of data curve point
-** Output: x = x-value of a point on the curve
-** y = y-value of a point on the curve
+** Input: curveIndex = data curve index
+** pointIndex = index of a data point on the curve
+** Output: x = x-value of the point on the curve
+** y = y-value of the point on the curve
** Returns: error code
** Purpose: retrieves the value of a specific point on a data curve
**----------------------------------------------------------------
@@ -4119,20 +4130,20 @@ int DLLEXPORT EN_getcurvevalue(EN_Project p, int index, int pnt,
*x = 0.0;
*y = 0.0;
if (!p->Openflag) return 102;
- if (index < 1 || index > p->network.Ncurves) return 206;
- if (pnt < 1 || pnt > p->network.Curve[index].Npts) return 251;
- *x = (EN_API_FLOAT_TYPE)p->network.Curve[index].X[pnt - 1];
- *y = (EN_API_FLOAT_TYPE)p->network.Curve[index].Y[pnt - 1];
+ if (curveIndex < 1 || curveIndex > p->network.Ncurves) return 206;
+ if (pointIndex < 1 || pointIndex > p->network.Curve[curveIndex].Npts) return 251;
+ *x = (double)p->network.Curve[curveIndex].X[pointIndex - 1];
+ *y = (double)p->network.Curve[curveIndex].Y[pointIndex - 1];
return 0;
}
-int DLLEXPORT EN_setcurvevalue(EN_Project p, int index, int pnt,
- EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y)
+int DLLEXPORT EN_setcurvevalue(EN_Project p, int curveIndex, int pointIndex,
+ double x, double y)
/*----------------------------------------------------------------
-** Input: index = time pattern index
-** pnt = index of data curve point
-** x = new x-value for point on the curve
-** y = new y-value for point on the curve
+** Input: curveIndex = data curve index
+** pointIndex = index of a data point on the curve
+** x = new x-value for the point on the curve
+** y = new y-value for the point on the curve
** Output: none
** Returns: error code
** Purpose: sets the value of a specific point on a data curve
@@ -4143,27 +4154,27 @@ int DLLEXPORT EN_setcurvevalue(EN_Project p, int index, int pnt,
Scurve *curve;
if (!p->Openflag) return 102;
- if (index <= 0 || index > net->Ncurves) return 206;
- curve = &net->Curve[index];
- if (pnt <= 0 || pnt > curve->Npts) return 251;
- curve->X[pnt - 1] = x;
- curve->Y[pnt - 1] = y;
+ if (curveIndex <= 0 || curveIndex > net->Ncurves) return 206;
+ curve = &net->Curve[curveIndex];
+ if (pointIndex <= 0 || pointIndex > curve->Npts) return 251;
+ curve->X[pointIndex - 1] = x;
+ curve->Y[pointIndex - 1] = y;
return 0;
}
-int DLLEXPORT EN_getcurve(EN_Project p, int index, char *id, int *nValues,
- EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues)
+int DLLEXPORT EN_getcurve(EN_Project p, int index, char *id, int *nPoints,
+ double **xValues, double **yValues)
/*----------------------------------------------------------------
** Input: index = data curve index
** Output: id = ID name of data curve
-** nValues = number of data points on the curve
+** nPoints = number of data points on the curve
** xValues = array of x-values for each data point
** yValues = array of y-values for each data point
** Returns: error code
** Purpose: retrieves the data associated with a data curve
**
** The calling program is responsible for making xValues and
-** yValues large enough to hold nValues data points.
+** yValues large enough to hold nPoints data points.
**----------------------------------------------------------------
*/
{
@@ -4174,22 +4185,22 @@ int DLLEXPORT EN_getcurve(EN_Project p, int index, char *id, int *nValues,
if (index <= 0 || index > p->network.Ncurves) return 206;
curve = &p->network.Curve[index];
strncpy(id, curve->ID, MAXID);
- *nValues = curve->Npts;
+ *nPoints = curve->Npts;
for (i = 0; i < curve->Npts; i++)
{
- *xValues[i] = (EN_API_FLOAT_TYPE)curve->X[i];
- *yValues[i] = (EN_API_FLOAT_TYPE)curve->Y[i];
+ *xValues[i] = curve->X[i];
+ *yValues[i] = curve->Y[i];
}
return 0;
}
-int DLLEXPORT EN_setcurve(EN_Project p, int index, EN_API_FLOAT_TYPE *x,
- EN_API_FLOAT_TYPE *y, int n)
+int DLLEXPORT EN_setcurve(EN_Project p, int index, double *xValues,
+ double *yValues, int nPoints)
/*----------------------------------------------------------------
** Input: index = data curve index
-** x = array of x-values
-** y = array of y-values
-** n = number of data points in the x and y arrays
+** xValues = array of x-values
+** yValues = array of y-values
+** nPoints = number of data points in the x and y arrays
** Returns: error code
** Purpose: replaces a curve's set of data points
**----------------------------------------------------------------
@@ -4202,24 +4213,24 @@ int DLLEXPORT EN_setcurve(EN_Project p, int index, EN_API_FLOAT_TYPE *x,
// Check for valid arguments
if (!p->Openflag) return 102;
if (index <= 0 || index > net->Ncurves) return 206;
- if (n <= 0) return 202;
+ if (nPoints <= 0) return 202;
// Check that x values are increasing
- for (j = 1; j < n; j++) if (x[j-1] >= x[j]) return 230;
+ for (j = 1; j < nPoints; j++) if (xValues[j-1] >= xValues[j]) return 230;
// Re-set number of points & reallocate memory for values
curve = &net->Curve[index];
- curve->Npts = n;
- curve->X = (double *)realloc(curve->X, n * sizeof(double));
- curve->Y = (double *)realloc(curve->Y, n * sizeof(double));
+ curve->Npts = nPoints;
+ curve->X = (double *)realloc(curve->X, nPoints * sizeof(double));
+ curve->Y = (double *)realloc(curve->Y, nPoints * sizeof(double));
if (curve->X == NULL) return 101;
if (curve->Y == NULL) return 101;
// Load values into curve
- for (j = 0; j < n; j++)
+ for (j = 0; j < nPoints; j++)
{
- curve->X[j] = x[j];
- curve->Y[j] = y[j];
+ curve->X[j] = xValues[j];
+ curve->Y[j] = yValues[j];
}
return 0;
}
@@ -4230,13 +4241,13 @@ int DLLEXPORT EN_setcurve(EN_Project p, int index, EN_API_FLOAT_TYPE *x,
********************************************************************/
-int DLLEXPORT EN_addcontrol(EN_Project p, int *index, int ctype, int lindex,
- EN_API_FLOAT_TYPE setting, int nindex, EN_API_FLOAT_TYPE level)
+int DLLEXPORT EN_addcontrol(EN_Project p, int type, int linkIndex, double setting,
+ int nodeIndex, double level, int *index)
/*----------------------------------------------------------------
-** Input: ctype = type of control (see EN_ControlType)
-** lindex = index of link being controlled
+** Input: type = type of control (see EN_ControlType)
+** linkIndex = index of link being controlled
** setting = link control setting (e.g., pump speed)
-** nindex = index of node controlling a link (for level controls)
+** nodeIndex = index of node controlling a link (for level controls)
** level = control activation level (pressure for junction nodes,
** water level for tank nodes or time value for time-based
** control)
@@ -4261,22 +4272,22 @@ int DLLEXPORT EN_addcontrol(EN_Project p, int *index, int ctype, int lindex,
if (!p->Openflag) return 102;
// Check that controlled link exists
- if (lindex <= 0 || lindex > net->Nlinks) return 204;
+ if (linkIndex <= 0 || linkIndex > net->Nlinks) return 204;
// Cannot control check valve
- if (net->Link[lindex].Type == EN_CVPIPE) return 207;
+ if (net->Link[linkIndex].Type == EN_CVPIPE) return 207;
// Check for valid parameters
- if (ctype < 0 || ctype > EN_TIMEOFDAY) return 251;
- if (ctype == EN_LOWLEVEL || ctype == EN_HILEVEL)
+ if (type < 0 || type > EN_TIMEOFDAY) return 251;
+ if (type == EN_LOWLEVEL || type == EN_HILEVEL)
{
- if (nindex < 1 || nindex > net->Nnodes) return 203;
+ if (nodeIndex < 1 || nodeIndex > net->Nnodes) return 203;
}
- else nindex = 0;
+ else nodeIndex = 0;
if (s < 0.0 || lvl < 0.0) return 202;
// Adjust units of control parameters
- switch (net->Link[lindex].Type)
+ switch (net->Link[linkIndex].Type)
{
case EN_PRV:
case EN_PSV:
@@ -4290,7 +4301,7 @@ int DLLEXPORT EN_addcontrol(EN_Project p, int *index, int ctype, int lindex,
if (s == 0.0) status = CLOSED;
else if (s == 1.0) status = OPEN;
else return 202;
- s = net->Link[lindex].Kc;
+ s = net->Link[linkIndex].Kc;
break;
case EN_PIPE:
case EN_PUMP:
@@ -4300,13 +4311,13 @@ int DLLEXPORT EN_addcontrol(EN_Project p, int *index, int ctype, int lindex,
break;
}
- if (ctype == LOWLEVEL || ctype == HILEVEL)
+ if (type == LOWLEVEL || type == HILEVEL)
{
- if (nindex > net->Njuncs) lvl = net->Node[nindex].El + level / Ucf[ELEV];
- else lvl = net->Node[nindex].El + level / Ucf[PRESSURE];
+ if (nodeIndex > net->Njuncs) lvl = net->Node[nodeIndex].El + level / Ucf[ELEV];
+ else lvl = net->Node[nodeIndex].El + level / Ucf[PRESSURE];
}
- if (ctype == TIMER) t = (long)ROUND(lvl);
- if (ctype == TIMEOFDAY) t = (long)ROUND(lvl) % SECperDAY;
+ if (type == TIMER) t = (long)ROUND(lvl);
+ if (type == TIMEOFDAY) t = (long)ROUND(lvl) % SECperDAY;
// Expand project's array of controls
n = net->Ncontrols + 1;
@@ -4314,9 +4325,9 @@ int DLLEXPORT EN_addcontrol(EN_Project p, int *index, int ctype, int lindex,
// Set properties of the new control
control = &net->Control[n];
- control->Type = (char)ctype;
- control->Link = lindex;
- control->Node = nindex;
+ control->Type = (char)type;
+ control->Link = linkIndex;
+ control->Node = nodeIndex;
control->Status = status;
control->Setting = s;
control->Grade = lvl;
@@ -4326,7 +4337,7 @@ int DLLEXPORT EN_addcontrol(EN_Project p, int *index, int ctype, int lindex,
net->Ncontrols = n;
parser->MaxControls = n;
- // Return the new control index
+ // Replace the control's index
*index = n;
return 0;
}
@@ -4352,18 +4363,16 @@ int DLLEXPORT EN_deletecontrol(EN_Project p, int index)
return 0;
}
-int DLLEXPORT EN_getcontrol(EN_Project p, int index, int *ctype, int *lindex,
- EN_API_FLOAT_TYPE *setting, int *nindex,
- EN_API_FLOAT_TYPE *level)
+int DLLEXPORT EN_getcontrol(EN_Project p, int index, int *type, int *linkIndex,
+ double *setting, int *nodeIndex, double *level)
/*----------------------------------------------------------------
** Input: index = index of the control
-** Output: ctype = type of control (see EN_ControlType)
-** lindex = index of link being controlled
+** Output: type = type of control (see EN_ControlType)
+** linkIndex = index of link being controlled
** setting = link control setting (e.g., pump speed)
-** nindex = index of node controlling a link (for level controls)
-** level = control activation level (pressure for junction nodes,
-** water level for tank nodes or time value for time-based
-** control)
+** nodeIndex = index of node that triggers a level control
+** level = trigger level that activates the control (pressure for junction nodes,
+** water level for tank nodes or time value for time-based control)
** Returns: error code
** Purpose: Retrieves the properties of a simple control
**----------------------------------------------------------------
@@ -4379,9 +4388,9 @@ int DLLEXPORT EN_getcontrol(EN_Project p, int index, int *ctype, int *lindex,
// Set default return values
s = 0.0;
lvl = 0.0;
- *ctype = 0;
- *lindex = 0;
- *nindex = 0;
+ *type = 0;
+ *linkIndex = 0;
+ *nodeIndex = 0;
// Check for valid arguments
if (!p->Openflag) return 102;
@@ -4389,14 +4398,14 @@ int DLLEXPORT EN_getcontrol(EN_Project p, int index, int *ctype, int *lindex,
// Retrieve control's type and link index
control = &net->Control[index];
- *ctype = control->Type;
- *lindex = control->Link;
+ *type = control->Type;
+ *linkIndex = control->Link;
// Retrieve control's setting
s = control->Setting;
if (control->Setting != MISSING)
{
- switch (net->Link[*lindex].Type)
+ switch (net->Link[*linkIndex].Type)
{
case EN_PRV:
case EN_PSV:
@@ -4413,11 +4422,11 @@ int DLLEXPORT EN_getcontrol(EN_Project p, int index, int *ctype, int *lindex,
else s = 0.0;
// Retrieve level value for a node level control
- *nindex = control->Node;
- if (*nindex > 0)
+ *nodeIndex = control->Node;
+ if (*nodeIndex > 0)
{
- node = &net->Node[*nindex];
- if (*nindex > net->Njuncs) // Node is a tank
+ node = &net->Node[*nodeIndex];
+ if (*nodeIndex > net->Njuncs) // Node is a tank
{
lvl = (control->Grade - node->El) * Ucf[ELEV];
}
@@ -4430,25 +4439,23 @@ int DLLEXPORT EN_getcontrol(EN_Project p, int index, int *ctype, int *lindex,
// Retrieve level value for a time-based control
else
{
- lvl = (EN_API_FLOAT_TYPE)control->Time;
+ lvl = (double)control->Time;
}
- *setting = (EN_API_FLOAT_TYPE)s;
- *level = (EN_API_FLOAT_TYPE)lvl;
+ *setting = (double)s;
+ *level = (double)lvl;
return 0;
}
-int DLLEXPORT EN_setcontrol(EN_Project p, int index, int ctype, int lindex,
- EN_API_FLOAT_TYPE setting, int nindex,
- EN_API_FLOAT_TYPE level)
+int DLLEXPORT EN_setcontrol(EN_Project p, int index, int type, int linkIndex,
+ double setting, int nodeIndex, double level)
/*----------------------------------------------------------------
** Input: index = index of the control
-** ctype = type of control (see EN_ControlType)
-** lindex = index of link being controlled
+** type = type of control (see EN_ControlType)
+** linkIndex = index of link being controlled
** setting = link control setting (e.g., pump speed)
-** nindex = index of node controlling a link (for level controls)
-** level = control activation level (pressure for junction nodes,
-** water level for tank nodes or time value for time-based
-** control)
+** nodeIndex = index of node that triggers the control (for level controls)
+** level = trigger level that activates the control (pressure for junction nodes,
+** water level for tank nodes or time value for time-based control)
** Output: none
** Returns: error code
** Purpose: Sets the properties of a simple control
@@ -4471,28 +4478,28 @@ int DLLEXPORT EN_setcontrol(EN_Project p, int index, int ctype, int lindex,
if (index <= 0 || index > net->Ncontrols) return 241;
control = &net->Control[index];
- // Check that controlled link exists
- if (lindex == 0)
+ // Check that controlled link exists (0 index de-activates the control)
+ if (linkIndex == 0)
{
control->Link = 0;
return 0;
}
- if (lindex < 0 || lindex > net->Nlinks) return 204;
+ if (linkIndex < 0 || linkIndex > net->Nlinks) return 204;
// Cannot control check valve
- if (net->Link[lindex].Type == EN_CVPIPE) return 207;
+ if (net->Link[linkIndex].Type == EN_CVPIPE) return 207;
// Check for valid control properties
- if (ctype < 0 || ctype > EN_TIMEOFDAY) return 251;
- if (ctype == EN_LOWLEVEL || ctype == EN_HILEVEL)
+ if (type < 0 || type > EN_TIMEOFDAY) return 251;
+ if (type == EN_LOWLEVEL || type == EN_HILEVEL)
{
- if (nindex < 1 || nindex > net->Nnodes) return 203;
+ if (nodeIndex < 1 || nodeIndex > net->Nnodes) return 203;
}
- else nindex = 0;
+ else nodeIndex = 0;
if (s < 0.0 || lvl < 0.0) return 202;
// Adjust units of control's properties
- link = &net->Link[lindex];
+ link = &net->Link[linkIndex];
switch (link->Type)
{
case EN_PRV:
@@ -4516,18 +4523,18 @@ int DLLEXPORT EN_setcontrol(EN_Project p, int index, int ctype, int lindex,
default:
break;
}
- if (ctype == LOWLEVEL || ctype == HILEVEL)
+ if (type == LOWLEVEL || type == HILEVEL)
{
- if (nindex > net->Njuncs) lvl = net->Node[nindex].El + level / Ucf[ELEV];
- else lvl = net->Node[nindex].El + level / Ucf[PRESSURE];
+ if (nodeIndex > net->Njuncs) lvl = net->Node[nodeIndex].El + level / Ucf[ELEV];
+ else lvl = net->Node[nodeIndex].El + level / Ucf[PRESSURE];
}
- if (ctype == TIMER) t = (long)ROUND(lvl);
- if (ctype == TIMEOFDAY) t = (long)ROUND(lvl) % SECperDAY;
+ if (type == TIMER) t = (long)ROUND(lvl);
+ if (type == TIMEOFDAY) t = (long)ROUND(lvl) % SECperDAY;
/* Reset control's parameters */
- control->Type = (char)ctype;
- control->Link = lindex;
- control->Node = nindex;
+ control->Type = (char)type;
+ control->Link = linkIndex;
+ control->Node = nodeIndex;
control->Status = status;
control->Setting = s;
control->Grade = lvl;
@@ -4613,7 +4620,7 @@ int DLLEXPORT EN_deleterule(EN_Project p, int index)
int DLLEXPORT EN_getrule(EN_Project p, int index, int *nPremises,
int *nThenActions, int *nElseActions,
- EN_API_FLOAT_TYPE *priority)
+ double *priority)
/*----------------------------------------------------------------
** Input: index = rule index
** Output: nPremises = number of premises conditions (IF AND OR)
@@ -4632,7 +4639,7 @@ int DLLEXPORT EN_getrule(EN_Project p, int index, int *nPremises,
Saction *action;
if (index < 1 || index > net->Nrules) return 257;
- *priority = (EN_API_FLOAT_TYPE)p->network.Rule[index].priority;
+ *priority = (double)p->network.Rule[index].priority;
count = 1;
premise = net->Rule[index].Premises;
@@ -4685,7 +4692,7 @@ int DLLEXPORT EN_getruleID(EN_Project p, int index, char *id)
int DLLEXPORT EN_getpremise(EN_Project p, int ruleIndex, int premiseIndex,
int *logop, int *object, int *objIndex, int *variable,
- int *relop, int *status, EN_API_FLOAT_TYPE *value)
+ int *relop, int *status, double *value)
/*----------------------------------------------------------------
** Input: ruleIndex = rule index
** premiseIndex = premise index
@@ -4716,14 +4723,14 @@ int DLLEXPORT EN_getpremise(EN_Project p, int ruleIndex, int premiseIndex,
*variable = premise->variable;
*relop = premise->relop;
*status = premise->status;
- *value = (EN_API_FLOAT_TYPE)premise->value;
+ *value = (double)premise->value;
return 0;
}
int DLLEXPORT EN_setpremise(EN_Project p, int ruleIndex, int premiseIndex,
int logop, int object, int objIndex, int variable,
- int relop, int status, EN_API_FLOAT_TYPE value)
+ int relop, int status, double value)
/*----------------------------------------------------------------
** Input: ruleIndex = rule index
** premiseIndex = premise index
@@ -4810,7 +4817,7 @@ int DLLEXPORT EN_setpremisestatus(EN_Project p, int ruleIndex, int premiseIndex,
return 0;
}
-int DLLEXPORT EN_setpremisevalue(EN_Project p, int ruleIndex, int premiseIndex, EN_API_FLOAT_TYPE value)
+int DLLEXPORT EN_setpremisevalue(EN_Project p, int ruleIndex, int premiseIndex, double value)
/*----------------------------------------------------------------
** Input: ruleIndex = rule index
** premiseIndex = premise index
@@ -4836,7 +4843,7 @@ int DLLEXPORT EN_setpremisevalue(EN_Project p, int ruleIndex, int premiseIndex,
}
int DLLEXPORT EN_getthenaction(EN_Project p, int ruleIndex, int actionIndex,
- int *linkIndex, int *status, EN_API_FLOAT_TYPE *setting)
+ int *linkIndex, int *status, double *setting)
/*----------------------------------------------------------------
** Input: ruleIndex = rule index
** actionIndex = index of a rule's THEN actions
@@ -4859,12 +4866,12 @@ int DLLEXPORT EN_getthenaction(EN_Project p, int ruleIndex, int actionIndex,
*linkIndex = action->link;
*status = action->status;
- *setting = (EN_API_FLOAT_TYPE)action->setting;
+ *setting = (double)action->setting;
return 0;
}
int DLLEXPORT EN_setthenaction(EN_Project p, int ruleIndex, int actionIndex,
- int linkIndex, int status, EN_API_FLOAT_TYPE setting)
+ int linkIndex, int status, double setting)
/*----------------------------------------------------------------
** Input: ruleIndex = rule index
** actionIndex = index of a rule's THEN actions
@@ -4892,7 +4899,7 @@ int DLLEXPORT EN_setthenaction(EN_Project p, int ruleIndex, int actionIndex,
}
int DLLEXPORT EN_getelseaction(EN_Project p, int ruleIndex, int actionIndex,
- int *linkIndex, int *status, EN_API_FLOAT_TYPE *setting)
+ int *linkIndex, int *status, double *setting)
/*----------------------------------------------------------------
** Input: ruleIndex = rule index
** actionIndex = index of a rule's ELSE actions
@@ -4916,12 +4923,12 @@ int DLLEXPORT EN_getelseaction(EN_Project p, int ruleIndex, int actionIndex,
*linkIndex = action->link;
*status = action->status;
- *setting = (EN_API_FLOAT_TYPE)action->setting;
+ *setting = (double)action->setting;
return 0;
}
int DLLEXPORT EN_setelseaction(EN_Project p, int ruleIndex, int actionIndex,
- int linkIndex, int status, EN_API_FLOAT_TYPE setting)
+ int linkIndex, int status, double setting)
/*----------------------------------------------------------------
** Input: ruleIndex = rule index
** actionIndex = index of a rule's ELSE actions
@@ -4948,7 +4955,7 @@ int DLLEXPORT EN_setelseaction(EN_Project p, int ruleIndex, int actionIndex,
return 0;
}
-int DLLEXPORT EN_setrulepriority(EN_Project p, int index, EN_API_FLOAT_TYPE priority)
+int DLLEXPORT EN_setrulepriority(EN_Project p, int index, double priority)
/*-----------------------------------------------------------------------------
** Input: index = rule index
** priority = rule priority level
diff --git a/src/epanet2.c b/src/epanet2.c
index a7a431c..8c02b3a 100644
--- a/src/epanet2.c
+++ b/src/epanet2.c
@@ -7,10 +7,15 @@
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
- Last Updated: 11/29/2018
+ Last Updated: 01/09/2019
******************************************************************************
*/
-
+#ifndef __APPLE__
+#include
+#else
+#include
+#endif
+#include
#include "types.h"
#include "funcs.h"
@@ -46,13 +51,13 @@ void removetmpfiles()
********************************************************************/
-int DLLEXPORT ENepanet(const char *f1, const char *f2, const char *f3,
- void (*pviewprog)(char *))
+int DLLEXPORT ENepanet(const char *inpFile, const char *rptFile,
+ const char *outFile, void (*pviewprog)(char *))
{
/*------------------------------------------------------------------------
- ** Input: f1 = name of EPANET formatted input file
- ** f2 = name of report file
- ** f3 = name of binary output file
+ ** Input: inpFile = name of EPANET formatted input file
+ ** rptFile = name of report file
+ ** outFile = name of binary output file
** pviewprog = see note below
** Output: none
** Returns: error code
@@ -71,7 +76,7 @@ int DLLEXPORT ENepanet(const char *f1, const char *f2, const char *f3,
// Run the project and record any warning
createtmpfiles();
- errcode = EN_runproject(_defaultProject, f1, f2, f3, pviewprog);
+ errcode = EN_runproject(_defaultProject, inpFile, rptFile, outFile, pviewprog);
if (errcode < 100) warncode = errcode;
removetmpfiles();
@@ -80,20 +85,20 @@ int DLLEXPORT ENepanet(const char *f1, const char *f2, const char *f3,
return errcode;
}
-int DLLEXPORT ENinit(const char *f2, const char *f3, int UnitsType,
- int HeadlossFormula)
+int DLLEXPORT ENinit(const char *rptFile, const char *outFile, int unitsType,
+ int headlossType)
{
int errcode = 0;
createtmpfiles();
- errcode = EN_init(_defaultProject, f2, f3, UnitsType, HeadlossFormula);
+ errcode = EN_init(_defaultProject, rptFile, outFile, unitsType, headlossType);
return errcode;
}
-int DLLEXPORT ENopen(const char *f1, const char *f2, const char *f3)
+int DLLEXPORT ENopen(const char *inpFile, const char *rptFile, const char *outFile)
{
int errcode = 0;
createtmpfiles();
- errcode = EN_open(_defaultProject, f1, f2, f3);
+ errcode = EN_open(_defaultProject, inpFile, rptFile, outFile);
return errcode;
}
@@ -121,11 +126,11 @@ int DLLEXPORT ENsaveH() { return EN_saveH(_defaultProject); }
int DLLEXPORT ENopenH() { return EN_openH(_defaultProject); }
-int DLLEXPORT ENinitH(int flag) { return EN_initH(_defaultProject, flag); }
+int DLLEXPORT ENinitH(int initFlag) { return EN_initH(_defaultProject, initFlag); }
-int DLLEXPORT ENrunH(long *t) { return EN_runH(_defaultProject, t); }
+int DLLEXPORT ENrunH(long *currentTime) { return EN_runH(_defaultProject, currentTime); }
-int DLLEXPORT ENnextH(long *tstep) { return EN_nextH(_defaultProject, tstep); }
+int DLLEXPORT ENnextH(long *tStep) { return EN_nextH(_defaultProject, tStep); }
int DLLEXPORT ENcloseH() { return EN_closeH(_defaultProject); }
@@ -149,13 +154,13 @@ int DLLEXPORT ENsolveQ() { return EN_solveQ(_defaultProject); }
int DLLEXPORT ENopenQ() { return EN_openQ(_defaultProject); }
-int DLLEXPORT ENinitQ(int saveflag) { return EN_initQ(_defaultProject, saveflag); }
+int DLLEXPORT ENinitQ(int saveFlag) { return EN_initQ(_defaultProject, saveFlag); }
-int DLLEXPORT ENrunQ(long *t) { return EN_runQ(_defaultProject, t); }
+int DLLEXPORT ENrunQ(long *currentTime) { return EN_runQ(_defaultProject, currentTime); }
-int DLLEXPORT ENnextQ(long *tstep) { return EN_nextQ(_defaultProject, tstep); }
+int DLLEXPORT ENnextQ(long *tStep) { return EN_nextQ(_defaultProject, tStep); }
-int DLLEXPORT ENstepQ(long *tleft) { return EN_stepQ(_defaultProject, tleft); }
+int DLLEXPORT ENstepQ(long *timeLeft) { return EN_stepQ(_defaultProject, timeLeft); }
int DLLEXPORT ENcloseQ() { return EN_closeQ(_defaultProject); }
@@ -171,28 +176,31 @@ int DLLEXPORT ENreport() { return EN_report(_defaultProject); }
int DLLEXPORT ENresetreport() { return EN_resetreport(_defaultProject); }
-int DLLEXPORT ENsetreport(char *s) { return EN_setreport(_defaultProject, s); }
+int DLLEXPORT ENsetreport(char *format) { return EN_setreport(_defaultProject, format); }
-int DLLEXPORT ENsetstatusreport(int code)
+int DLLEXPORT ENsetstatusreport(int level)
{
- return EN_setstatusreport(_defaultProject, code);
+ return EN_setstatusreport(_defaultProject, level);
}
-int DLLEXPORT ENgetversion(int *v) { return EN_getversion(v); }
+int DLLEXPORT ENgetversion(int *version) { return EN_getversion(version); }
-int DLLEXPORT ENgetcount(int code, int *count)
+int DLLEXPORT ENgetcount(int object, int *count)
{
- return EN_getcount(_defaultProject, (EN_CountType)code, count);
+ return EN_getcount(_defaultProject, object, count);
}
-int DLLEXPORT ENgeterror(int errcode, char *errmsg, int n)
+int DLLEXPORT ENgeterror(int errcode, char *errmsg, int maxLen)
{
- return EN_geterror(errcode, errmsg, n);
+ return EN_geterror(errcode, errmsg, maxLen);
}
-int DLLEXPORT ENgetstatistic(int code, EN_API_FLOAT_TYPE *value)
+int DLLEXPORT ENgetstatistic(int type, EN_API_FLOAT_TYPE *value)
{
- return EN_getstatistic(_defaultProject, code, value);
+ double v = 0.0;
+ int errcode = EN_getstatistic(_defaultProject, type, &v);
+ *value = (EN_API_FLOAT_TYPE)v;
+ return errcode;
}
/********************************************************************
@@ -201,45 +209,54 @@ int DLLEXPORT ENgetstatistic(int code, EN_API_FLOAT_TYPE *value)
********************************************************************/
-int DLLEXPORT ENgetoption(int code, EN_API_FLOAT_TYPE *value)
+int DLLEXPORT ENgetoption(int option, EN_API_FLOAT_TYPE *value)
{
- return EN_getoption(_defaultProject, (EN_Option)code, value);
+ double v = 0.0;
+ int errcode = EN_getoption(_defaultProject, option, &v);
+ *value = (EN_API_FLOAT_TYPE)v;
+ return errcode;
}
-int DLLEXPORT ENsetoption(int code, EN_API_FLOAT_TYPE v)
+int DLLEXPORT ENsetoption(int option, EN_API_FLOAT_TYPE value)
{
- return EN_setoption(_defaultProject, code, v);
+ return EN_setoption(_defaultProject, option, value);
}
-int DLLEXPORT ENgetflowunits(int *code) { return EN_getflowunits(_defaultProject, code); }
-
-int DLLEXPORT ENsetflowunits(int code) { return EN_setflowunits(_defaultProject, code); }
-
-int DLLEXPORT ENgettimeparam(int code, long *value)
+int DLLEXPORT ENgetflowunits(int *units)
{
- return EN_gettimeparam(_defaultProject, code, value);
+ return EN_getflowunits(_defaultProject, units);
}
-int DLLEXPORT ENsettimeparam(int code, long value)
+int DLLEXPORT ENsetflowunits(int units)
{
- return EN_settimeparam(_defaultProject, code, value);
+ return EN_setflowunits(_defaultProject, units);
}
-int DLLEXPORT ENgetqualinfo(int *qualcode, char *chemname, char *chemunits,
- int *tracenode)
+int DLLEXPORT ENgettimeparam(int param, long *value)
{
- return EN_getqualinfo(_defaultProject, qualcode, chemname, chemunits, tracenode);
+ return EN_gettimeparam(_defaultProject, param, value);
}
-int DLLEXPORT ENgetqualtype(int *qualcode, int *tracenode)
+int DLLEXPORT ENsettimeparam(int param, long value)
{
- return EN_getqualtype(_defaultProject, qualcode, tracenode);
+ return EN_settimeparam(_defaultProject, param, value);
}
-int DLLEXPORT ENsetqualtype(int qualcode, char *chemname, char *chemunits,
- char *tracenode)
+int DLLEXPORT ENgetqualinfo(int *qualType, char *chemName, char *chemUnits,
+ int *traceNode)
{
- return EN_setqualtype(_defaultProject, qualcode, chemname, chemunits, tracenode);
+ return EN_getqualinfo(_defaultProject, qualType, chemName, chemUnits, traceNode);
+}
+
+int DLLEXPORT ENgetqualtype(int *qualType, int *traceNode)
+{
+ return EN_getqualtype(_defaultProject, qualType, traceNode);
+}
+
+int DLLEXPORT ENsetqualtype(int qualType, char *chemName, char *chemUnits,
+ char *traceNode)
+{
+ return EN_setqualtype(_defaultProject, qualType, chemName, chemUnits, traceNode);
}
/********************************************************************
@@ -248,7 +265,7 @@ int DLLEXPORT ENsetqualtype(int qualcode, char *chemname, char *chemunits,
********************************************************************/
-int DLLEXPORT ENaddnode(char *id, EN_NodeType nodeType)
+int DLLEXPORT ENaddnode(char *id, int nodeType)
{
return EN_addnode(_defaultProject, id, nodeType);
}
@@ -273,19 +290,22 @@ int DLLEXPORT ENsetnodeid(int index, char *newid)
return EN_setnodeid(_defaultProject, index, newid);
}
-int DLLEXPORT ENgetnodetype(int index, int *code)
+int DLLEXPORT ENgetnodetype(int index, int *nodeType)
{
- return EN_getnodetype(_defaultProject, index, code);
+ return EN_getnodetype(_defaultProject, index, nodeType);
}
-int DLLEXPORT ENgetnodevalue(int index, int code, EN_API_FLOAT_TYPE *value)
+int DLLEXPORT ENgetnodevalue(int index, int property, EN_API_FLOAT_TYPE *value)
{
- return EN_getnodevalue(_defaultProject, index, code, value);
+ double v = 0.0;
+ int errcode = EN_getnodevalue(_defaultProject, index, property, &v);
+ *value = (EN_API_FLOAT_TYPE)v;
+ return errcode;
}
-int DLLEXPORT ENsetnodevalue(int index, int code, EN_API_FLOAT_TYPE v)
+int DLLEXPORT ENsetnodevalue(int index, int property, EN_API_FLOAT_TYPE value)
{
- return EN_setnodevalue(_defaultProject, index, code, v);
+ return EN_setnodevalue(_defaultProject, index, property, value);
}
int DLLEXPORT ENsetjuncdata(int index, EN_API_FLOAT_TYPE elev, EN_API_FLOAT_TYPE dmnd,
@@ -294,8 +314,9 @@ int DLLEXPORT ENsetjuncdata(int index, EN_API_FLOAT_TYPE elev, EN_API_FLOAT_TYPE
return EN_setjuncdata(_defaultProject, index, elev, dmnd, dmndpat);
}
-int DLLEXPORT ENsettankdata(int index, EN_API_FLOAT_TYPE elev, EN_API_FLOAT_TYPE initlvl,
- EN_API_FLOAT_TYPE minlvl, EN_API_FLOAT_TYPE maxlvl, EN_API_FLOAT_TYPE diam,
+int DLLEXPORT ENsettankdata(int index, EN_API_FLOAT_TYPE elev,
+ EN_API_FLOAT_TYPE initlvl, EN_API_FLOAT_TYPE minlvl,
+ EN_API_FLOAT_TYPE maxlvl, EN_API_FLOAT_TYPE diam,
EN_API_FLOAT_TYPE minvol, char *volcurve)
{
return EN_settankdata(_defaultProject, index, elev, initlvl, minlvl, maxlvl,
@@ -304,7 +325,11 @@ int DLLEXPORT ENsettankdata(int index, EN_API_FLOAT_TYPE elev, EN_API_FLOAT_TYP
int DLLEXPORT ENgetcoord(int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y)
{
- return EN_getcoord(_defaultProject, index, x, y);
+ double xx = 0.0, yy = 0.0;
+ int errcode = EN_getcoord(_defaultProject, index, &xx, &yy);
+ *x = (EN_API_FLOAT_TYPE)xx;
+ *y = (EN_API_FLOAT_TYPE)yy;
+ return errcode;
}
int DLLEXPORT ENsetcoord(int index, EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y)
@@ -318,16 +343,21 @@ int DLLEXPORT ENsetcoord(int index, EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y)
********************************************************************/
-int DLLEXPORT ENgetdemandmodel(int *type, EN_API_FLOAT_TYPE *pmin,
- EN_API_FLOAT_TYPE *preq, EN_API_FLOAT_TYPE *pexp)
+int DLLEXPORT ENgetdemandmodel(int *model, EN_API_FLOAT_TYPE *pmin,
+ EN_API_FLOAT_TYPE *preq, EN_API_FLOAT_TYPE *pexp)
{
- return EN_getdemandmodel(_defaultProject, type, pmin, preq, pexp);
+ double pmin2 = 0.0, preq2 = 0.0, pexp2 = 0.0;
+ int errcode = EN_getdemandmodel(_defaultProject, model, &pmin2, &preq2, &pexp2);
+ *pmin = (EN_API_FLOAT_TYPE)pmin2;
+ *preq = (EN_API_FLOAT_TYPE)preq2;
+ *pexp = (EN_API_FLOAT_TYPE)pexp2;
+ return errcode;
}
-int DLLEXPORT ENsetdemandmodel(int type, EN_API_FLOAT_TYPE pmin,
- EN_API_FLOAT_TYPE preq, EN_API_FLOAT_TYPE pexp)
+int DLLEXPORT ENsetdemandmodel(int model, EN_API_FLOAT_TYPE pmin,
+ EN_API_FLOAT_TYPE preq, EN_API_FLOAT_TYPE pexp)
{
- return EN_setdemandmodel(_defaultProject, type, pmin, preq, pexp);
+ return EN_setdemandmodel(_defaultProject, model, pmin, preq, pexp);
}
int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands)
@@ -335,34 +365,39 @@ int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands)
return EN_getnumdemands(_defaultProject, nodeIndex, numDemands);
}
-int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIdx, EN_API_FLOAT_TYPE *baseDemand)
+int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIndex,
+ EN_API_FLOAT_TYPE *baseDemand)
{
- return EN_getbasedemand(_defaultProject, nodeIndex, demandIdx, baseDemand);
+ double bd2 = 0.0;
+ int errcode = EN_getbasedemand(_defaultProject, nodeIndex, demandIndex, &bd2);
+ *baseDemand = (EN_API_FLOAT_TYPE)bd2;
+ return errcode;
}
-int DLLEXPORT ENsetbasedemand(int nodeIndex, int demandIdx, EN_API_FLOAT_TYPE baseDemand)
+int DLLEXPORT ENsetbasedemand(int nodeIndex, int demandIndex,
+ EN_API_FLOAT_TYPE baseDemand)
{
- return EN_setbasedemand(_defaultProject, nodeIndex, demandIdx, baseDemand);
+ return EN_setbasedemand(_defaultProject, nodeIndex, demandIndex, baseDemand);
}
-int DLLEXPORT ENsetdemandpattern(int nodeIndex, int demandIdx, int patIndex)
+int DLLEXPORT ENsetdemandpattern(int nodeIndex, int demandIndex, int patIndex)
{
- return EN_setdemandpattern(_defaultProject, nodeIndex, demandIdx, patIndex);
+ return EN_setdemandpattern(_defaultProject, nodeIndex, demandIndex, patIndex);
}
-int DLLEXPORT ENgetdemandpattern(int nodeIndex, int demandIdx, int *pattIdx)
+int DLLEXPORT ENgetdemandpattern(int nodeIndex, int demandIndex, int *pattIdx)
{
- return EN_getdemandpattern(_defaultProject, nodeIndex, demandIdx, pattIdx);
+ return EN_getdemandpattern(_defaultProject, nodeIndex, demandIndex, pattIdx);
}
-int DLLEXPORT ENgetdemandname(int nodeIndex, int demandIdx, char *demandName)
+int DLLEXPORT ENgetdemandname(int nodeIndex, int demandIndex, char *demandName)
{
- return EN_getdemandname(_defaultProject, nodeIndex, demandIdx, demandName);
+ return EN_getdemandname(_defaultProject, nodeIndex, demandIndex, demandName);
}
-int DLLEXPORT ENsetdemandname(int nodeIndex, int demandIdx, char *demandName)
+int DLLEXPORT ENsetdemandname(int nodeIndex, int demandIndex, char *demandName)
{
- return EN_setdemandname(_defaultProject, nodeIndex, demandIdx, demandName);
+ return EN_setdemandname(_defaultProject, nodeIndex, demandIndex, demandName);
}
/********************************************************************
@@ -371,7 +406,7 @@ int DLLEXPORT ENsetdemandname(int nodeIndex, int demandIdx, char *demandName)
********************************************************************/
-int DLLEXPORT ENaddlink(char *id, EN_LinkType linkType, char *fromNode, char *toNode)
+int DLLEXPORT ENaddlink(char *id, int linkType, char *fromNode, char *toNode)
{
return EN_addlink(_defaultProject, id, linkType, fromNode, toNode);
}
@@ -396,14 +431,14 @@ int DLLEXPORT ENsetlinkid(int index, char *newid)
return EN_setlinkid(_defaultProject, index, newid);
}
-int DLLEXPORT ENgetlinktype(int index, EN_LinkType *code)
+int DLLEXPORT ENgetlinktype(int index, int *linkType)
{
- return EN_getlinktype(_defaultProject, index, code);
+ return EN_getlinktype(_defaultProject, index, linkType);
}
-int DLLEXPORT ENsetlinktype(int *index, EN_LinkType type, int actionCode)
+int DLLEXPORT ENsetlinktype(int *index, int linkType, int actionCode)
{
- return EN_setlinktype(_defaultProject, index, type, actionCode);
+ return EN_setlinktype(_defaultProject, index, linkType, actionCode);
}
int DLLEXPORT ENgetlinknodes(int index, int *node1, int *node2)
@@ -416,18 +451,21 @@ int DLLEXPORT ENsetlinknodes(int index, int node1, int node2)
return EN_setlinknodes(_defaultProject, index, node1, node2);
}
-int DLLEXPORT ENgetlinkvalue(int index, int code, EN_API_FLOAT_TYPE *value)
+int DLLEXPORT ENgetlinkvalue(int index, int property, EN_API_FLOAT_TYPE *value)
{
- return EN_getlinkvalue(_defaultProject, index, (EN_LinkProperty)code, value);
+ double v = 0.0;
+ int errcode = EN_getlinkvalue(_defaultProject, index, property, &v);
+ *value = (EN_API_FLOAT_TYPE)v;
+ return errcode;
}
-int DLLEXPORT ENsetlinkvalue(int index, int code, EN_API_FLOAT_TYPE v)
+int DLLEXPORT ENsetlinkvalue(int index, int property, EN_API_FLOAT_TYPE value)
{
- return EN_setlinkvalue(_defaultProject, index, code, v);
+ return EN_setlinkvalue(_defaultProject, index, property, value);
}
-int DLLEXPORT ENsetpipedata(int index, EN_API_FLOAT_TYPE length, EN_API_FLOAT_TYPE diam,
- EN_API_FLOAT_TYPE rough, EN_API_FLOAT_TYPE mloss)
+int DLLEXPORT ENsetpipedata(int index, EN_API_FLOAT_TYPE length,
+ EN_API_FLOAT_TYPE diam, EN_API_FLOAT_TYPE rough, EN_API_FLOAT_TYPE mloss)
{
return EN_setpipedata(_defaultProject, index, length, diam, rough, mloss);
}
@@ -439,19 +477,19 @@ int DLLEXPORT ENsetpipedata(int index, EN_API_FLOAT_TYPE length, EN_API_FLOAT_TY
********************************************************************/
-int DLLEXPORT ENgetpumptype(int index, int *type)
+int DLLEXPORT ENgetpumptype(int linkIndex, int *pumpType)
{
- return EN_getpumptype(_defaultProject, index, type);
+ return EN_getpumptype(_defaultProject, linkIndex, pumpType);
}
-int DLLEXPORT ENgetheadcurveindex(int index, int *curveindex)
+int DLLEXPORT ENgetheadcurveindex(int linkIndex, int *curveIndex)
{
- return EN_getheadcurveindex(_defaultProject, index, curveindex);
+ return EN_getheadcurveindex(_defaultProject, linkIndex, curveIndex);
}
-int DLLEXPORT ENsetheadcurveindex(int index, int curveindex)
+int DLLEXPORT ENsetheadcurveindex(int linkIndex, int curveIndex)
{
- return EN_setheadcurveindex(_defaultProject, index, curveindex);
+ return EN_setheadcurveindex(_defaultProject, linkIndex, curveIndex);
}
/********************************************************************
@@ -482,7 +520,10 @@ int DLLEXPORT ENgetpatternlen(int index, int *len)
int DLLEXPORT ENgetpatternvalue(int index, int period, EN_API_FLOAT_TYPE *value)
{
- return EN_getpatternvalue(_defaultProject, index, period, value);
+ double v = 0.0;
+ int errcode = EN_getpatternvalue(_defaultProject, index, period, &v);
+ *value = (EN_API_FLOAT_TYPE)v;
+ return errcode;
}
int DLLEXPORT ENsetpatternvalue(int index, int period, EN_API_FLOAT_TYPE value)
@@ -492,12 +533,25 @@ int DLLEXPORT ENsetpatternvalue(int index, int period, EN_API_FLOAT_TYPE value)
int DLLEXPORT ENgetaveragepatternvalue(int index, EN_API_FLOAT_TYPE *value)
{
- return EN_getaveragepatternvalue(_defaultProject, index, value);
+ double v;
+ int errcode = EN_getaveragepatternvalue(_defaultProject, index, &v);
+ *value = (EN_API_FLOAT_TYPE)v;
+ return errcode;
}
-int DLLEXPORT ENsetpattern(int index, EN_API_FLOAT_TYPE *f, int n)
+int DLLEXPORT ENsetpattern(int index, EN_API_FLOAT_TYPE *values, int len)
{
- return EN_setpattern(_defaultProject, index, f, n);
+ double *v = NULL;
+ int i, errcode;
+ v = (double *)calloc(len, sizeof(double));
+ if (v)
+ {
+ for (i = 0; i < len; i++) v[i] = values[i];
+ errcode = EN_setpattern(_defaultProject, index, v, len);
+ }
+ else errcode = 101;
+ free(v);
+ return errcode;
}
/********************************************************************
@@ -526,32 +580,67 @@ int DLLEXPORT ENgetcurvelen(int index, int *len)
return EN_getcurvelen(_defaultProject, index, len);
}
-int DLLEXPORT ENgetcurvetype(int curveindex, int *type)
+int DLLEXPORT ENgetcurvetype(int index, int *type)
{
- return EN_getcurvetype(_defaultProject, curveindex, type);
+ return EN_getcurvetype(_defaultProject, index, type);
}
-int DLLEXPORT ENgetcurvevalue(int index, int pnt, EN_API_FLOAT_TYPE *x,
- EN_API_FLOAT_TYPE *y)
+int DLLEXPORT ENgetcurvevalue(int curveIndex, int pointIndex, EN_API_FLOAT_TYPE *x,
+ EN_API_FLOAT_TYPE *y)
{
- return EN_getcurvevalue(_defaultProject, index, pnt, x, y);
+ double xx = 0.0, yy = 0.0;
+ int errcode = EN_getcurvevalue(_defaultProject, curveIndex, pointIndex, &xx, &yy);
+ *x = (EN_API_FLOAT_TYPE)xx;
+ *y = (EN_API_FLOAT_TYPE)yy;
+ return errcode;
}
-int DLLEXPORT ENsetcurvevalue(int index, int pnt, EN_API_FLOAT_TYPE x,
- EN_API_FLOAT_TYPE y)
+int DLLEXPORT ENsetcurvevalue(int curveIndex, int pointIndex, EN_API_FLOAT_TYPE x,
+ EN_API_FLOAT_TYPE y)
{
- return EN_setcurvevalue(_defaultProject, index, pnt, x, y);
+ return EN_setcurvevalue(_defaultProject, curveIndex, pointIndex, x, y);
}
-int DLLEXPORT ENgetcurve(int curveIndex, char *id, int *nValues,
- EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues)
+int DLLEXPORT ENgetcurve(int index, char *id, int *nPoints,
+ EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues)
{
- return EN_getcurve(_defaultProject, curveIndex, id, nValues, xValues, yValues);
+ int i;
+ Network *net = &_defaultProject->network;
+ Scurve *curve;
+
+ if (index <= 0 || index > net->Ncurves) return 206;
+ curve = &net->Curve[index];
+ strncpy(id, curve->ID, MAXID);
+ *nPoints = curve->Npts;
+ for (i = 0; i < curve->Npts; i++)
+ {
+ *xValues[i] = (EN_API_FLOAT_TYPE)curve->X[i];
+ *yValues[i] = (EN_API_FLOAT_TYPE)curve->Y[i];
+ }
+ return 0;
}
-int DLLEXPORT ENsetcurve(int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y, int n)
+int DLLEXPORT ENsetcurve(int index, EN_API_FLOAT_TYPE *xValues,
+ EN_API_FLOAT_TYPE *yValues, int nPoints)
{
- return EN_setcurve(_defaultProject, index, x, y, n);
+ double *xx = NULL;
+ double *yy = NULL;
+ int i, errcode;
+ xx = (double *)calloc(nPoints, sizeof(double));
+ yy = (double *)calloc(nPoints, sizeof(double));
+ if (xx && yy)
+ {
+ for (i = 0; i < nPoints; i++)
+ {
+ xx[i] = xValues[i];
+ yy[i] = yValues[i];
+ }
+ errcode = EN_setcurve(_defaultProject, index, xx, yy, nPoints);
+ }
+ else errcode = 101;
+ free(xx);
+ free(yy);
+ return errcode;
}
/********************************************************************
@@ -560,27 +649,34 @@ int DLLEXPORT ENsetcurve(int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y,
********************************************************************/
-int DLLEXPORT ENaddcontrol(int *cindex, int ctype, int lindex, EN_API_FLOAT_TYPE setting,
- int nindex, EN_API_FLOAT_TYPE level)
+int DLLEXPORT ENaddcontrol(int type, int linkIndex, EN_API_FLOAT_TYPE setting,
+ int nodeIndex, EN_API_FLOAT_TYPE level, int *index)
{
- return EN_addcontrol(_defaultProject, cindex, ctype, lindex, setting, nindex, level);
+ return EN_addcontrol(_defaultProject, type, linkIndex, setting, nodeIndex,
+ level, index);
}
-int DLLEXPORT ENdeletecontrol(int cindex)
+int DLLEXPORT ENdeletecontrol(int index)
{
- return EN_deletecontrol(_defaultProject, cindex);
+ return EN_deletecontrol(_defaultProject, index);
}
-int DLLEXPORT ENgetcontrol(int cindex, int *ctype, int *lindex, EN_API_FLOAT_TYPE *setting,
- int *nindex, EN_API_FLOAT_TYPE *level)
+int DLLEXPORT ENgetcontrol(int index, int *type, int *linkIndex,
+ EN_API_FLOAT_TYPE *setting, int *nodeIndex, EN_API_FLOAT_TYPE *level)
{
- return EN_getcontrol(_defaultProject, cindex, ctype, lindex, setting, nindex, level);
+ double setting2 = 0.0, level2 = 0.0;
+ int errcode = EN_getcontrol(_defaultProject, index, type, linkIndex, &setting2,
+ nodeIndex, &level2);
+ *setting = (EN_API_FLOAT_TYPE)setting2;
+ *level = (EN_API_FLOAT_TYPE)level2;
+ return errcode;
}
-int DLLEXPORT ENsetcontrol(int cindex, int ctype, int lindex, EN_API_FLOAT_TYPE setting,
- int nindex, EN_API_FLOAT_TYPE level)
+int DLLEXPORT ENsetcontrol(int index, int type, int linkIndex,
+ EN_API_FLOAT_TYPE setting, int nodeIndex, EN_API_FLOAT_TYPE level)
{
- return EN_setcontrol(_defaultProject, cindex, ctype, lindex, setting, nindex, level);
+ return EN_setcontrol(_defaultProject, index, type, linkIndex, setting,
+ nodeIndex, level);
}
/********************************************************************
@@ -599,10 +695,14 @@ int DLLEXPORT ENdeleterule(int index)
return EN_deleterule(_defaultProject, index);
}
-int DLLEXPORT ENgetrule(int index, int *nPremises, int *nThenActions, int *nElseActions,
- EN_API_FLOAT_TYPE *priority)
+int DLLEXPORT ENgetrule(int index, int *nPremises, int *nThenActions,
+ int *nElseActions, EN_API_FLOAT_TYPE *priority)
{
- return EN_getrule(_defaultProject, index, nPremises, nThenActions, nElseActions, priority);
+ double priority2 = 0.0;
+ int errcode = EN_getrule(_defaultProject, index, nPremises, nThenActions,
+ nElseActions, &priority2);
+ *priority = (EN_API_FLOAT_TYPE)priority2;
+ return errcode;
}
int DLLEXPORT ENgetruleID(int index, char* id)
@@ -610,17 +710,19 @@ int DLLEXPORT ENgetruleID(int index, char* id)
return EN_getruleID(_defaultProject, index, id);
}
-int DLLEXPORT ENgetpremise(int ruleIndex, int premiseIndex, int *logop,
- int *object, int *objIndex, int *variable,
- int *relop, int *status, EN_API_FLOAT_TYPE *value)
+int DLLEXPORT ENgetpremise(int ruleIndex, int premiseIndex, int *logop, int *object,
+ int *objIndex, int *variable, int *relop, int *status,
+ EN_API_FLOAT_TYPE *value)
{
- return EN_getpremise(_defaultProject, ruleIndex, premiseIndex, logop, object,
- objIndex, variable, relop, status, value);
+ double v = 0.0;
+ int errcode = EN_getpremise(_defaultProject, ruleIndex, premiseIndex, logop,
+ object, objIndex, variable, relop, status, &v);
+ *value = (EN_API_FLOAT_TYPE)v;
+ return errcode;
}
-int DLLEXPORT ENsetpremise(int ruleIndex, int premiseIndex, int logop,
- int object, int objIndex, int variable, int relop,
- int status, EN_API_FLOAT_TYPE value)
+int DLLEXPORT ENsetpremise(int ruleIndex, int premiseIndex, int logop, int object,
+ int objIndex, int variable, int relop, int status, EN_API_FLOAT_TYPE value)
{
return EN_setpremise(_defaultProject, ruleIndex, premiseIndex, logop, object,
objIndex, variable, relop, status, value);
@@ -642,28 +744,34 @@ int DLLEXPORT ENsetpremisevalue(int ruleIndex, int premiseIndex, EN_API_FLOAT_TY
}
int DLLEXPORT ENgetthenaction(int ruleIndex, int actionIndex, int *linkIndex,
- int *status, EN_API_FLOAT_TYPE *setting)
+ int *status, EN_API_FLOAT_TYPE *setting)
{
- return EN_getthenaction(_defaultProject, ruleIndex, actionIndex, linkIndex,
- status, setting);
+ double setting2 = 0.0;
+ int errcode = EN_getthenaction(_defaultProject, ruleIndex, actionIndex, linkIndex,
+ status, &setting2);
+ *setting = (EN_API_FLOAT_TYPE)setting2;
+ return errcode;
}
int DLLEXPORT ENsetthenaction(int ruleIndex, int actionIndex, int linkIndex,
- int status, EN_API_FLOAT_TYPE setting)
+ int status, EN_API_FLOAT_TYPE setting)
{
return EN_setthenaction(_defaultProject, ruleIndex, actionIndex, linkIndex,
status, setting);
}
int DLLEXPORT ENgetelseaction(int ruleIndex, int actionIndex, int *linkIndex,
- int *status, EN_API_FLOAT_TYPE *setting)
+ int *status, EN_API_FLOAT_TYPE *setting)
{
- return EN_getelseaction(_defaultProject, ruleIndex, actionIndex, linkIndex,
- status, setting);
+ double setting2 = 0.0;
+ int errcode = EN_getelseaction(_defaultProject, ruleIndex, actionIndex, linkIndex,
+ status, &setting2);
+ *setting = (EN_API_FLOAT_TYPE)setting2;
+ return errcode;
}
int DLLEXPORT ENsetelseaction(int ruleIndex, int actionIndex, int linkIndex,
- int status, EN_API_FLOAT_TYPE setting)
+ int status, EN_API_FLOAT_TYPE setting)
{
return EN_setelseaction(_defaultProject, ruleIndex, actionIndex, linkIndex,
status, setting);
diff --git a/src/errors.dat b/src/errors.dat
index 842f59b..52922c7 100644
--- a/src/errors.dat
+++ b/src/errors.dat
@@ -8,7 +8,6 @@ DAT(105,"water quality solver not opened")
DAT(106,"no results saved to report on")
DAT(107,"hydraulics supplied from external file")
DAT(108,"cannot use external file while hydraulics solver is active")
-DAT(109,"cannot change time parameter when solver is active")
DAT(110,"cannot solve network hydraulic equations")
DAT(120,"cannot solve water quality transport equations")
@@ -23,9 +22,7 @@ DAT(204,"undefined link")
DAT(205,"undefined time pattern")
DAT(206,"undefined curve")
DAT(207,"attempt to control CV/GPV link")
-DAT(208,"reference to undefined node")
DAT(209,"illegal node property value")
-DAT(210,"reference to undefined link")
DAT(211,"illegal link property value")
DAT(212,"undefined trace node")
DAT(213,"invalid option value")
diff --git a/src/inpfile.c b/src/inpfile.c
index d13c012..18f4a1c 100644
--- a/src/inpfile.c
+++ b/src/inpfile.c
@@ -116,7 +116,7 @@ int saveinpfile(Project *pr, const char *fname)
Scurve *curve;
// Open the new text file
- if ((f = fopen(fname, "wt")) == NULL) return (308);
+ if ((f = fopen(fname, "wt")) == NULL) return 302;
// Write [TITLE] section
fprintf(f, s_TITLE);
diff --git a/src/input3.c b/src/input3.c
index 4abd0fc..0acc72e 100644
--- a/src/input3.c
+++ b/src/input3.c
@@ -1479,10 +1479,10 @@ int reportdata(Project *pr)
else if (match(parser->Tok[n], w_ALL)) rpt->Nodeflag = 1; // All nodes
else
{
- if (net->Nnodes == 0) return setError(parser, 1, 208);
+ if (net->Nnodes == 0) return setError(parser, 1, 203);
for (i = 1; i <= n; i++)
{
- if ((j = findnode(net, parser->Tok[i])) == 0) return setError(parser, i, 208);
+ if ((j = findnode(net, parser->Tok[i])) == 0) return setError(parser, i, 203);
net->Node[j].Rpt = 1;
}
rpt->Nodeflag = 2;
@@ -1497,10 +1497,10 @@ int reportdata(Project *pr)
else if (match(parser->Tok[n], w_ALL)) rpt->Linkflag = 1;
else
{
- if (net->Nlinks == 0) return setError(parser, 1, 210);
+ if (net->Nlinks == 0) return setError(parser, 1, 204);
for (i = 1; i <= n; i++)
{
- if ((j = findlink(net, parser->Tok[i])) == 0) return setError(parser, i, 210);
+ if ((j = findlink(net, parser->Tok[i])) == 0) return setError(parser, i, 204);
net->Link[j].Rpt = 1;
}
rpt->Linkflag = 2;
diff --git a/tests/test_addrule.cpp b/tests/test_addrule.cpp
index 6fc67d7..9d9666d 100644
--- a/tests/test_addrule.cpp
+++ b/tests/test_addrule.cpp
@@ -43,7 +43,7 @@ int main(int argc, char *argv[])
int error = 0;
int ruleCount, nP, nTA, nEA;
int link113, node23, link22, pump9_before, pump9_after;
- float priority;
+ double priority;
EN_Project ph = NULL;
EN_createproject(&ph);
diff --git a/tests/test_net_builder.cpp b/tests/test_net_builder.cpp
index f54fa8d..b0067e9 100644
--- a/tests/test_net_builder.cpp
+++ b/tests/test_net_builder.cpp
@@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
int flag = 00;
long t, tstep;
int i, ind, Lindex, Nindex, Cindex;
- float h_orig, h_build, h_build_loaded;
+ double h_orig, h_build, h_build_loaded;
// first we load Net1.inp, run it and record the head in Tank 2 at the end of the simulation (h_orig)
EN_Project ph = NULL;
@@ -80,13 +80,13 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
// ------------------------------------------------------------------------
// now we build Net1 from scratch...
char juncs[9][10] = { "10", "11", "12", "13", "21", "22", "23", "31", "32" };
- float e[9] = {710, 710, 700, 695, 700, 695, 690, 700, 710};
- float d[9] = {0, 150, 150, 100, 150, 200, 150, 100, 100 };
- float X[9] = {20, 30, 50, 70, 30, 50, 70, 30, 50};
- float Y[9] = {70, 70, 70, 70, 40, 40, 40, 10, 10 };
- float L[12] = {10530, 5280, 5280, 5280, 5280, 5280, 200, 5280, 5280, 5280, 5280, 5280};
- float dia[12] = { 18, 14, 10, 10, 12, 6, 18, 10, 12, 8, 8, 6 };
- float P[12] = { 1.0f, 1.2f, 1.4f, 1.6f, 1.4f, 1.2f, 1.0f, 0.8f, 0.6f, 0.4f, 0.6f, 0.8f };
+ double e[9] = {710, 710, 700, 695, 700, 695, 690, 700, 710};
+ double d[9] = {0, 150, 150, 100, 150, 200, 150, 100, 100 };
+ double X[9] = {20, 30, 50, 70, 30, 50, 70, 30, 50};
+ double Y[9] = {70, 70, 70, 70, 40, 40, 40, 10, 10 };
+ double L[12] = {10530, 5280, 5280, 5280, 5280, 5280, 200, 5280, 5280, 5280, 5280, 5280};
+ double dia[12] = { 18, 14, 10, 10, 12, 6, 18, 10, 12, 8, 8, 6 };
+ double P[12] = { 1.0f, 1.2f, 1.4f, 1.6f, 1.4f, 1.2f, 1.0f, 0.8f, 0.6f, 0.4f, 0.6f, 0.8f };
error = EN_createproject(&ph);
error = EN_init(ph, "net.rpt", "net.out", EN_GPM, EN_HW);
@@ -187,9 +187,9 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
BOOST_REQUIRE(error == 0);
// Add controls
- error = EN_addcontrol(ph, &Cindex, EN_LOWLEVEL, Lindex, 1, Nindex, 110);
+ error = EN_addcontrol(ph, EN_LOWLEVEL, Lindex, 1, Nindex, 110, &Cindex);
BOOST_REQUIRE(error == 0);
- error = EN_addcontrol(ph, &Cindex, EN_HILEVEL, Lindex, 0, Nindex, 140);
+ error = EN_addcontrol(ph, EN_HILEVEL, Lindex, 0, Nindex, 140, &Cindex);
BOOST_REQUIRE(error == 0);
error = EN_openH(ph);
@@ -250,10 +250,10 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
// if we got this far we can compare results
// compare the original to the build & saved network
- BOOST_REQUIRE(h_orig == h_build_loaded);
+ BOOST_REQUIRE(abs(h_orig - h_build_loaded) < 0.0001);
// compare the original to the build without saving
- BOOST_REQUIRE(h_orig == h_build); // this seems to fail :(
+ BOOST_REQUIRE(abs(h_orig - h_build) < 0.0001);
}
diff --git a/tests/test_net_builder_2.cpp b/tests/test_net_builder_2.cpp
index 8fe4f92..8002b4a 100644
--- a/tests/test_net_builder_2.cpp
+++ b/tests/test_net_builder_2.cpp
@@ -36,8 +36,8 @@ int main(int argc, char *argv[])
int index;
char id[EN_MAXID+1];
- float p1_1, p2_1, p1_2, p2_2;
- float q1_1, q2_1, q1_2, q2_2;
+ double p1_1, p2_1, p1_2, p2_2;
+ double q1_1, q2_1, q1_2, q2_2;
// Create & initialize a project
EN_Project ph = NULL;
@@ -100,10 +100,10 @@ int main(int argc, char *argv[])
cout << "\n Link L2 Flow: " << q2_1 << " " << q2_2;
// Compare old & new results
- BOOST_REQUIRE(p1_1 == p1_2);
- BOOST_REQUIRE(p2_1 == p2_2);
- BOOST_REQUIRE(q1_1 == q1_2);
- BOOST_REQUIRE(q2_1 == q2_2);
+ BOOST_REQUIRE(abs(p1_1 - p1_2) < 1.e-5);
+ BOOST_REQUIRE(abs(p2_1 - p2_2) < 1.e-5);
+ BOOST_REQUIRE(abs(q1_1 - q1_2) < 1.e-5);
+ BOOST_REQUIRE(abs(q2_1 - q2_2) < 1.e-5);
// Close project
EN_close(ph);
diff --git a/tests/test_setlinktype.cpp b/tests/test_setlinktype.cpp
index 32c3987..575af67 100644
--- a/tests/test_setlinktype.cpp
+++ b/tests/test_setlinktype.cpp
@@ -27,7 +27,7 @@ BOOST_AUTO_TEST_CASE(test_setlinktype)
{
int error = 0;
int p113, n31, p121, n113_1, n113_2;
- float q113 = 0.0f, p31 = 0.0f, diam;
+ double q113 = 0.0, p31 = 0.0, diam;
EN_Project ph = NULL;
EN_createproject(&ph);
diff --git a/tests/test_toolkit.cpp b/tests/test_toolkit.cpp
index 1bcd613..943a400 100644
--- a/tests/test_toolkit.cpp
+++ b/tests/test_toolkit.cpp
@@ -301,7 +301,7 @@ BOOST_FIXTURE_TEST_CASE(test_add_control, Fixture)
{
int flag = 00;
long t, tstep;
- float h1, h2;
+ double h1, h2;
int Cindex;
// run with original controls
@@ -328,10 +328,10 @@ BOOST_FIXTURE_TEST_CASE(test_add_control, Fixture)
BOOST_REQUIRE(error == 0);
// add new controls
- error = EN_addcontrol(ph, &Cindex, 0, 13, 1, 11, 110);
+ error = EN_addcontrol(ph, 0, 13, 1, 11, 110, &Cindex);
BOOST_REQUIRE(error == 0);
BOOST_CHECK(Cindex == 3);
- error = EN_addcontrol(ph, &Cindex, 1, 13, 0, 11, 140);
+ error = EN_addcontrol(ph, 1, 13, 0, 11, 140, &Cindex);
BOOST_REQUIRE(error == 0);
BOOST_CHECK(Cindex == 4);
@@ -352,7 +352,7 @@ BOOST_FIXTURE_TEST_CASE(test_add_control, Fixture)
error = EN_closeH(ph);
BOOST_REQUIRE(error == 0);
- BOOST_CHECK(h1 == h2); // end head should be the same with new controls
+ BOOST_CHECK(abs(h1 - h2) < 1.e-5); // end head should be the same with new controls
}
BOOST_AUTO_TEST_SUITE_END()