EPANET
Macros | Functions
epanet2.h File Reference
#include "epanet2_enums.h"

Go to the source code of this file.

Macros

#define EN_API_FLOAT_TYPE   float
 
#define DLLEXPORT
 

Functions

int DLLEXPORT ENepanet (const char *inpFile, const char *rptFile, const char *binOutFile, void(*callback)(char *))
 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. More...
 
int DLLEXPORT ENinit (const char *rptFile, const char *binOutFile, int UnitsType, int HeadlossFormula)
 Initializes an EPANET session. More...
 
int DLLEXPORT ENopen (const char *inpFile, const char *rptFile, const char *binOutFile)
 Opens EPANET input file & reads in network data. More...
 
int DLLEXPORT ENsaveinpfile (const char *filename)
 Saves current data to "INP" formatted text file. More...
 
int DLLEXPORT ENclose ()
 Frees all memory and files used by EPANET. More...
 
int DLLEXPORT ENsolveH ()
 Solves the network hydraulics for all time periods. More...
 
int DLLEXPORT ENsaveH ()
 Saves hydraulic results to binary file. More...
 
int DLLEXPORT ENopenH ()
 Sets up data structures for hydraulic analysis. More...
 
int DLLEXPORT ENinitH (int initFlag)
 Initializes hydraulic analysis. More...
 
int DLLEXPORT ENrunH (long *currentTime)
 Run a hydraulic solution period. More...
 
int DLLEXPORT ENnextH (long *tStep)
 Determine time (in seconds) until next hydraulic event. More...
 
int DLLEXPORT ENcloseH ()
 Frees data allocated by hydraulics solver. More...
 
int DLLEXPORT ENsavehydfile (char *filename)
 Copies binary hydraulics file to disk. More...
 
int DLLEXPORT ENusehydfile (char *filename)
 Opens previously saved binary hydraulics file. More...
 
int DLLEXPORT ENsolveQ ()
 Solves for network water quality in all time periods. More...
 
int DLLEXPORT ENopenQ ()
 Sets up data structures for WQ analysis. More...
 
int DLLEXPORT ENinitQ (int saveFlag)
 Initializes water quality analysis. More...
 
int DLLEXPORT ENrunQ (long *currentTime)
 Retrieves hydraulic & WQ results at time t. More...
 
int DLLEXPORT ENnextQ (long *tStep)
 Advances WQ simulation to next hydraulic event. More...
 
int DLLEXPORT ENstepQ (long *timeLeft)
 Advances WQ simulation by a single WQ time step. More...
 
int DLLEXPORT ENcloseQ ()
 Frees data allocated by water quality solver. More...
 
int DLLEXPORT ENwriteline (char *line)
 Writes line of text to the report file. More...
 
int DLLEXPORT ENreport ()
 Writes simulation report to the report file. More...
 
int DLLEXPORT ENresetreport ()
 Resets report options to default values. More...
 
int DLLEXPORT ENsetreport (char *reportFormat)
 Processes a reporting format command. More...
 
int DLLEXPORT ENsetstatusreport (int code)
 Set the level of hydraulic status reporting. More...
 
int DLLEXPORT ENgetversion (int *version)
 Get the API version number. More...
 
int DLLEXPORT ENgetcount (int code, int *count)
 Retrieves the number of components of a given type in the network. More...
 
int DLLEXPORT ENgeterror (int errcode, char *errmsg, int maxLen)
 Get the text of an error code. More...
 
int DLLEXPORT ENgetstatistic (int code, EN_API_FLOAT_TYPE *value)
 Get hydraulic simulation statistic. More...
 
int DLLEXPORT ENgetoption (int code, EN_API_FLOAT_TYPE *value)
 Gets value for an analysis option. More...
 
int DLLEXPORT ENsetoption (int code, EN_API_FLOAT_TYPE v)
 Set a value for an anlysis option. More...
 
int DLLEXPORT ENgetflowunits (int *code)
 Retrieves the flow units code. More...
 
int DLLEXPORT ENsetflowunits (int code)
 Sets the flow units. More...
 
int DLLEXPORT ENgettimeparam (int code, long *value)
 Retrieves value of specific time parameter. More...
 
int DLLEXPORT ENsettimeparam (int code, long value)
 Set the value for a time parameter. More...
 
int DLLEXPORT ENgetqualinfo (int *qualcode, char *chemname, char *chemunits, int *tracenode)
 Get information about the type of water quality analysis requested. More...
 
int DLLEXPORT ENgetqualtype (int *qualcode, int *tracenode)
 Retrieve the type of quality analytis to be run. More...
 
int DLLEXPORT ENsetqualtype (int qualcode, char *chemname, char *chemunits, char *tracenode)
 Set the type of quality analysis called for. More...
 
int DLLEXPORT ENaddnode (char *id, EN_NodeType nodeType)
 Add a new node to the project. More...
 
int DLLEXPORT ENdeletenode (int index, int actionCode)
 Delete a node from the project. More...
 
int DLLEXPORT ENgetnodeindex (char *id, int *index)
 Get index of node with specified ID. More...
 
int DLLEXPORT ENgetnodeid (int index, char *id)
 Get the string ID of the specified node. More...
 
int DLLEXPORT ENsetnodeid (int index, char *newid)
 Change the ID name for a node. More...
 
int DLLEXPORT ENgetnodetype (int index, int *code)
 Get the type of node with specified index. More...
 
int DLLEXPORT ENgetnodevalue (int index, int code, EN_API_FLOAT_TYPE *value)
 Get a property value for specified node. More...
 
int DLLEXPORT ENsetnodevalue (int index, int code, EN_API_FLOAT_TYPE v)
 Set a property value for a node. More...
 
int DLLEXPORT ENgetcoord (int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y)
 Get coordinates (x,y) for a node. More...
 
int DLLEXPORT ENsetcoord (int index, EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y)
 Set coordinates (x,y) for a node. More...
 
int DLLEXPORT ENgetdemandmodel (int *type, EN_API_FLOAT_TYPE *pmin, EN_API_FLOAT_TYPE *preq, EN_API_FLOAT_TYPE *pexp)
 Retrieves the type of demand model in use and its parameters. More...
 
int DLLEXPORT ENsetdemandmodel (int type, EN_API_FLOAT_TYPE pmin, EN_API_FLOAT_TYPE preq, EN_API_FLOAT_TYPE pexp)
 Sets the type of demand model to use and its parameters. More...
 
int DLLEXPORT ENgetnumdemands (int nodeIndex, int *numDemands)
 Get the number of demand categories for a node. More...
 
int DLLEXPORT ENgetbasedemand (int nodeIndex, int demandIndex, EN_API_FLOAT_TYPE *baseDemand)
 Get a node's base demand for a specified category. More...
 
int DLLEXPORT ENsetbasedemand (int nodeIndex, int demandIndex, EN_API_FLOAT_TYPE baseDemand)
 Set a node's base demand for a demand category. More...
 
int DLLEXPORT ENgetdemandpattern (int nodeIndex, int demandIndex, int *pattIndex)
 Get the index of the demand pattern assigned to a node for a category index. More...
 
int DLLEXPORT ENsetdemandpattern (int nodeIndex, int demandIndex, int patIndex)
 Set the time pattern assigned to a node's demand category. More...
 
int DLLEXPORT ENgetdemandname (int nodeIndex, int demandIdx, char *demandName)
 Retrieve the name of a node's demand category. More...
 
int DLLEXPORT ENsetdemandname (int nodeIndex, int demandIdx, char *demandName)
 Set the name of a node's demand category. More...
 
int DLLEXPORT ENaddlink (char *id, EN_LinkType linkType, char *fromNode, char *toNode)
 Add a new link to the project. More...
 
int DLLEXPORT ENdeletelink (int index, int actionCode)
 Delete a link from the project. More...
 
int DLLEXPORT ENgetlinkindex (char *id, int *index)
 Get the index of a Link with specified ID. More...
 
int DLLEXPORT ENgetlinkid (int index, char *id)
 Get the string ID of a link with specified index. More...
 
int DLLEXPORT ENsetlinkid (int index, char *newid)
 Change the ID name for a link. More...
 
int DLLEXPORT ENgetlinktype (int index, EN_LinkType *code)
 Get the link type code for a specified link. More...
 
int DLLEXPORT ENsetlinktype (int *index, EN_LinkType Code, int actionCode)
 Set the link type code for a specified link. More...
 
int DLLEXPORT ENgetlinknodes (int index, int *node1, int *node2)
 Get the indexes of a link's start- and end-nodes. More...
 
int DLLEXPORT ENsetlinknodes (int index, int node1, int node2)
 Set the indexes of a link's start- and end-nodes. More...
 
int DLLEXPORT ENgetlinkvalue (int index, int code, EN_API_FLOAT_TYPE *value)
 Get a property value for specified link. More...
 
int DLLEXPORT ENsetlinkvalue (int index, int code, EN_API_FLOAT_TYPE v)
 Set a property value for a link. More...
 
int DLLEXPORT ENgetpumptype (int linkIndex, int *outType)
 Get the type of pump. More...
 
int DLLEXPORT ENgetheadcurveindex (int pumpIndex, int *curveIndex)
 Retrieves the curve index for a specified pump index. More...
 
int DLLEXPORT ENsetheadcurveindex (int pumpIndex, int curveIndex)
 Sets the curve id for a specified pump index. More...
 
int DLLEXPORT ENaddpattern (char *id)
 Add a new time pattern. More...
 
int DLLEXPORT ENgetpatternindex (char *id, int *index)
 Retrieves the index of the time pattern with specified ID. More...
 
int DLLEXPORT ENgetpatternid (int index, char *id)
 Retrieves ID of a time pattern with specific index. More...
 
int DLLEXPORT ENgetpatternlen (int index, int *len)
 Retrieves the number of multipliers in a time pattern. More...
 
int DLLEXPORT ENgetpatternvalue (int index, int period, EN_API_FLOAT_TYPE *value)
 Retrive a multiplier from a pattern for a specific time period. More...
 
int DLLEXPORT ENsetpatternvalue (int index, int period, EN_API_FLOAT_TYPE value)
 Set the multiplier for a specific pattern at a specific period. More...
 
int DLLEXPORT ENgetaveragepatternvalue (int index, EN_API_FLOAT_TYPE *value)
 Retrieve the average multiplier value in a time pattern. More...
 
int DLLEXPORT ENsetpattern (int index, EN_API_FLOAT_TYPE *f, int len)
 Set multipliers for a specific pattern. More...
 
int DLLEXPORT ENaddcurve (char *id)
 Add a new curve to the project. More...
 
int DLLEXPORT ENgetcurveindex (char *id, int *index)
 Retrieve the index of a curve given its name. More...
 
int DLLEXPORT ENgetcurveid (int index, char *id)
 Retrieve the ID name of a curve given its index. More...
 
int DLLEXPORT ENgetcurvelen (int index, int *len)
 Retrieve the number of points in a curve. More...
 
int DLLEXPORT ENgetcurvetype (int curveIndex, int *outType)
 Get the type of a curve. More...
 
int DLLEXPORT ENgetcurvevalue (int curveIndex, int pointIndex, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y)
 Retrieve an x,y data point for a curve. More...
 
int DLLEXPORT ENsetcurvevalue (int curveIndex, int pointIndex, EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y)
 Set the x and y values for a curve's data point. More...
 
int DLLEXPORT ENgetcurve (int curveIndex, char *id, int *nValues, EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues)
 Get a curve's properties. More...
 
int DLLEXPORT ENsetcurve (int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y, int len)
 Set the x,y values for all points on a curve. More...
 
int DLLEXPORT ENaddcontrol (int *index, int ctype, int lindex, EN_API_FLOAT_TYPE setting, int nindex, EN_API_FLOAT_TYPE level)
 Add a new simple control to the project. More...
 
int DLLEXPORT ENdeletecontrol (int index)
 Delete an existing simple control. More...
 
int DLLEXPORT ENgetcontrol (int index, int *ctype, int *lindex, EN_API_FLOAT_TYPE *setting, int *nindex, EN_API_FLOAT_TYPE *level)
 Retrieves properties that define a simple control. More...
 
int DLLEXPORT ENsetcontrol (int cindex, int ctype, int lindex, EN_API_FLOAT_TYPE setting, int nindex, EN_API_FLOAT_TYPE level)
 Set the properties of an existing simple control. More...
 
int DLLEXPORT ENaddrule (char *rule)
 Add a new control rule to the project. More...
 
int DLLEXPORT ENdeleterule (int index)
 Delete a rule-based control. More...
 
int DLLEXPORT ENgetrule (int index, int *nPremises, int *nTrueActions, int *nFalseActions, EN_API_FLOAT_TYPE *priority)
 Get summary information for a rule-based control. More...
 
int DLLEXPORT ENgetruleID (int index, char *id)
 Get the ID name of a rule-based control. More...
 
int DLLEXPORT ENgetpremise (int ruleIndex, int premiseIndex, int *logop, int *object, int *objIndex, int *variable, int *relop, int *status, EN_API_FLOAT_TYPE *value)
 Get the properties of a premise in a rule-based control. More...
 
int DLLEXPORT ENsetpremise (int ruleIndex, int premiseIndex, int logop, int object, int objIndex, int variable, int relop, int status, EN_API_FLOAT_TYPE value)
 Set the properties of a premise in a rule-based control. More...
 
int DLLEXPORT ENsetpremiseindex (int ruleIndex, int premiseIndex, int objIndex)
 Set the index of an object in a premise of a rule-based control. More...
 
int DLLEXPORT ENsetpremisestatus (int ruleIndex, int premiseIndex, int status)
 Set the status in a premise of a rule-based control. More...
 
int DLLEXPORT ENsetpremisevalue (int ruleIndex, int premiseIndex, EN_API_FLOAT_TYPE value)
 Set the value in a premise of a rule-based control. More...
 
int DLLEXPORT ENgetthenaction (int ruleIndex, int actionIndex, int *linkIndex, int *status, EN_API_FLOAT_TYPE *setting)
 Get the properties of a THEN action in a rule-based control. More...
 
int DLLEXPORT ENsetthenaction (int ruleIndex, int actionIndex, int linkIndex, int status, EN_API_FLOAT_TYPE setting)
 Set the properties of a THEN action in a rule-based control. More...
 
int DLLEXPORT ENgetelseaction (int ruleIndex, int actionIndex, int *linkIndex, int *status, EN_API_FLOAT_TYPE *setting)
 Get the properties of an ELSE action in a rule-based control. More...
 
int DLLEXPORT ENsetelseaction (int ruleIndex, int actionIndex, int linkIndex, int status, EN_API_FLOAT_TYPE setting)
 Set the properties of an ELSE action in a rule-based control. More...
 
int DLLEXPORT ENsetrulepriority (int index, EN_API_FLOAT_TYPE priority)
 Set the priority of a rule-based control. More...
 

Detailed Description

See also
http://github.com/openwateranalytics/epanet

Function Documentation

§ ENaddcontrol()

int DLLEXPORT ENaddcontrol ( int *  index,
int  ctype,
int  lindex,
EN_API_FLOAT_TYPE  setting,
int  nindex,
EN_API_FLOAT_TYPE  level 
)

Add a new simple control to the project.

Parameters
[out]indexThe index of the new control. First control is index 1.
ctypeThe type of control to add (see EN_ControlType).
lindexThe index of a link to control.
settingThe control setting applied to the link.
nindexThe index of a node used to control the link, or 0 for TIMER / TIMEOFDAY control.
levelcontrol point (tank level, junction pressure, or time in seconds).
Returns
Error code.

§ ENaddlink()

int DLLEXPORT ENaddlink ( char *  id,
EN_LinkType  linkType,
char *  fromNode,
char *  toNode 
)

Add a new link to the project.

Parameters
idThe name of the link to be added.
linkTypeThe type of link being added (see EN_LinkType)
fromNodeThe id of the link's starting node
toNodeThe id of the link's ending node
Returns
Error code.

§ ENaddnode()

int DLLEXPORT ENaddnode ( char *  id,
EN_NodeType  nodeType 
)

Add a new node to the project.

Parameters
idThe name of the node to be added.
nodeTypeThe type of node being added (see EN_NodeType)
Returns
Error code.

§ ENaddrule()

int DLLEXPORT ENaddrule ( char *  rule)

Add a new control rule to the project.

Parameters
ruleText of the rule following the format used in an EPANET input file.
Returns
Error code.

§ ENdeletecontrol()

int DLLEXPORT ENdeletecontrol ( int  index)

Delete an existing simple control.

Parameters
indexThe index of the control. First control is index 1.
Returns
Error code.

§ ENdeletelink()

int DLLEXPORT ENdeletelink ( int  index,
int  actionCode 
)

Delete a link from the project.

Parameters
indexThe index of the link to be deleted.
ctrlsCodeThe action taken if any control contains the link.
Returns
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.

§ ENdeletenode()

int DLLEXPORT ENdeletenode ( int  index,
int  actionCode 
)

Delete a node from the project.

Parameters
indexThe index of the node to be deleted.
actionCodeThe action taken if any control contains the node and its links.
Returns
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 an error code is returned.

§ ENdeleterule()

int DLLEXPORT ENdeleterule ( int  index)

Delete a rule-based control.

Parameters
indexThe rule's index.
Returns
Error code.

§ ENepanet()

int DLLEXPORT ENepanet ( const char *  inpFile,
const char *  rptFile,
const char *  binOutFile,
void(*)(char *)  callback 
)

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.

§ ENgetbasedemand()

int DLLEXPORT ENgetbasedemand ( int  nodeIndex,
int  demandIndex,
EN_API_FLOAT_TYPE *  baseDemand 
)

Get a node's base demand for a specified category.

Parameters
nodeIndexThe index of a node (first node is index 1)
demandIndexThe index of the demand category (starting at 1)
Returns
Error code

§ ENgetcurvetype()

int DLLEXPORT ENgetcurvetype ( int  curveIndex,
int *  outType 
)

Get the type of a curve.

Parameters
curveIndexThe index of the curve element
[out]outTypeThe integer-typed curve curve type signifier (output parameter)
Returns
Error code
See also
EN_CurveType

§ ENgetdemandmodel()

int DLLEXPORT ENgetdemandmodel ( int *  type,
EN_API_FLOAT_TYPE *  pmin,
EN_API_FLOAT_TYPE *  preq,
EN_API_FLOAT_TYPE *  pexp 
)

Retrieves the type of demand model in use and its parameters.

Parameters
[out]typeType of demand model (EN_DDA or EN_PDA)
[out]pminPressure below which there is no demand
[out]preqPressure required to deliver full demand
[out]pexpPressure exponent in demand function
Returns
Error code

§ ENgetdemandname()

int DLLEXPORT ENgetdemandname ( int  nodeIndex,
int  demandIdx,
char *  demandName 
)

Retrieve the name of a node's demand category.

Parameters
nodeIndexThe node's index.
demandIdxIndex of the node's demand.
demandName[out]Name of the category the demand belongs to.
Returns
Error code.

§ ENgetelseaction()

int DLLEXPORT ENgetelseaction ( int  ruleIndex,
int  actionIndex,
int *  linkIndex,
int *  status,
EN_API_FLOAT_TYPE *  setting 
)

Get the properties of an ELSE action in a rule-based control.

Parameters
ruleIndexThe rule's index.
actionIndexIndex of the ELSE action to retrieve.
linkIndex[out]Index of the link in the action (e.g. index of Pump 1).
status[out]Status of the link (see EN_RuleStatus).
setting[out]Value of the link's setting (e.g. pump speed 0.9)
Returns
Error code.

§ ENgetlinkid()

int DLLEXPORT ENgetlinkid ( int  index,
char *  id 
)

Get the string ID of a link with specified index.

Parameters
indexThe index of a link (first link is index 1)
[out]idThe ID of the link.
Returns
Error code
See also
ENgetlinkindex

The ID string must be sized to hold at least MAXID characters.

§ ENgetlinkindex()

int DLLEXPORT ENgetlinkindex ( char *  id,
int *  index 
)

Get the index of a Link with specified ID.

Parameters
idThe string ID of a link.
[out]indexThe index of the named link (first link is index 1)
Returns
Error code
See also
ENgetlinkid

§ ENgetlinknodes()

int DLLEXPORT ENgetlinknodes ( int  index,
int *  node1,
int *  node2 
)

Get the indexes of a link's start- and end-nodes.

Parameters
indexThe index of a link (first link is index 1)
[out]node1The index of the link's start node (first node is index 1).
[out]node2The index of the link's end node (first node is index 1).
Returns
Error code
See also
ENgetnodeid, ENgetlinkid

§ ENgetlinktype()

int DLLEXPORT ENgetlinktype ( int  index,
EN_LinkType *  code 
)

Get the link type code for a specified link.

Parameters
indexThe index of a link (first link is index 1)
[out]codeThe type code of the link (see the EN_LinkType enumeration)
Returns
Error code
See also
EN_LinkType

§ ENgetlinkvalue()

int DLLEXPORT ENgetlinkvalue ( int  index,
int  code,
EN_API_FLOAT_TYPE *  value 
)

Get a property value for specified link.

Parameters
indexThe index of a node (first node is index 1).
codeThe parameter desired.
[out]valueThe value of the link's specified property.
Returns
Error code
See also
ENgetnodevalue, EN_LinkProperty

§ ENgetnumdemands()

int DLLEXPORT ENgetnumdemands ( int  nodeIndex,
int *  numDemands 
)

Get the number of demand categories for a node.

Parameters
nodeIndexThe index of a node (first node is index 1)
[out]numDemandsThe number of demand categories
Returns
Error code

§ ENgetpremise()

int DLLEXPORT ENgetpremise ( int  ruleIndex,
int  premiseIndex,
int *  logop,
int *  object,
int *  objIndex,
int *  variable,
int *  relop,
int *  status,
EN_API_FLOAT_TYPE *  value 
)

Get the properties of a premise in a rule-based control.

Parameters
ruleIndexThe rule's index.
premiseIndexThe premise's index.
logop[out]Logical operator (IF = 1, AND = 2, OR = 3) of the premise.
object[out]Type of object the premise is looking at (see EN_RuleObject).
objIndex[out]Index of the object (e.g. the index of the tank).
variable[out]Index of the variable to be checked (see EN_RuleVariable).
relop[out]Relationship operator in the premise (see EN_RuleOperator).
status[out]Status of the object being checked (see EN_RuleStatus).
value[out]Setting of the variable being checked (e.g. 5.5)
Returns
Error code.

§ ENgetqualinfo()

int DLLEXPORT ENgetqualinfo ( int *  qualcode,
char *  chemname,
char *  chemunits,
int *  tracenode 
)

Get information about the type of water quality analysis requested.

Parameters
[out]qualcodeType of analysis to be made (see EN_QualityType).
[out]chemnameName of the quality constituent.
[out]chemunitsConcentration units of the constituent.
[out]tracenodeID of node being traced (if applicable).
Returns
Error code.

§ ENgetrule()

int DLLEXPORT ENgetrule ( int  index,
int *  nPremises,
int *  nTrueActions,
int *  nFalseActions,
EN_API_FLOAT_TYPE *  priority 
)

Get summary information for a rule-based control.

Parameters
indexThe rule's index.
[out]nPremisesNumber of premises in the rule's IF section.
[out]nThenActionsNumber of actions in the rule's THEN section.
nElseActions[out]Number of actions in the rule's ELSE section.
priority[out]Rule's priority.
Returns
Error code.

§ ENgetruleID()

int DLLEXPORT ENgetruleID ( int  index,
char *  id 
)

Get the ID name of a rule-based control.

Parameters
indexThe rule's index.
id[out]The rule's ID name.
Returns
Error code.

§ ENgetthenaction()

int DLLEXPORT ENgetthenaction ( int  ruleIndex,
int  actionIndex,
int *  linkIndex,
int *  status,
EN_API_FLOAT_TYPE *  setting 
)

Get the properties of a THEN action in a rule-based control.

Parameters
ruleIndexThe rule's index.
actionIndexIndex of the THEN action to retrieve.
linkIndex[out]Index of the link in the action (e.g. index of Pump 1)
status[out]Status of the link (see EN_RuleStatus)
setting[out]Value of the link's setting (e.g. pump speed 0.9)
Returns
Error code.

§ ENgetversion()

int DLLEXPORT ENgetversion ( int *  version)

Get the API version number.

Parameters
[out]versionThe version of EPANET
Returns
Error code.

The version number is to be interpreted with implied decimals, i.e., "20100" == "2(.)01(.)00"

§ ENinit()

int DLLEXPORT ENinit ( const char *  rptFile,
const char *  binOutFile,
int  UnitsType,
int  HeadlossFormula 
)

Initializes an EPANET session.

Parameters
rptFilepointer to name of report file (to be created)
binOutFilepointer to name of binary output file (to be created)
UnitsTypeflow units flag
HeadlossFormulaheadloss formula flag
Returns
error code

§ ENopen()

int DLLEXPORT ENopen ( const char *  inpFile,
const char *  rptFile,
const char *  binOutFile 
)

Opens EPANET input file & reads in network data.

Parameters
inpFilepointer to name of input file (must exist)
rptFilepointer to name of report file (to be created)
binOutFilepointer to name of binary output file (to be created)
Returns
error code

§ ENsaveinpfile()

int DLLEXPORT ENsaveinpfile ( const char *  filename)

Saves current data to "INP" formatted text file.

Parameters
filenameThe file path to create
Returns
Error code

§ ENsetbasedemand()

int DLLEXPORT ENsetbasedemand ( int  nodeIndex,
int  demandIndex,
EN_API_FLOAT_TYPE  baseDemand 
)

Set a node's base demand for a demand category.

Parameters
nodeIndexThe node's index.
demandIndexThe index of one of the node's demand categories.
baseDemandThe base demand for the selected category.
Returns
Error code.
See also
ENgetbasedemand

§ ENsetdemandmodel()

int DLLEXPORT ENsetdemandmodel ( int  type,
EN_API_FLOAT_TYPE  pmin,
EN_API_FLOAT_TYPE  preq,
EN_API_FLOAT_TYPE  pexp 
)

Sets the type of demand model to use and its parameters.

Parameters
typeType of demand model (EN_DDA or EN_PDA)
pminPressure below which there is no demand
preqPressure required to deliver full demand
pexpPressure exponent in demand function
Returns
Error code

§ ENsetdemandname()

int DLLEXPORT ENsetdemandname ( int  nodeIndex,
int  demandIdx,
char *  demandName 
)

Set the name of a node's demand category.

Parameters
nodeIndexThe node's index.
demandIdxIndex of the node's demand.
demandNameName for the category the demand belongs to.
Returns
Error code.

§ ENsetdemandpattern()

int DLLEXPORT ENsetdemandpattern ( int  nodeIndex,
int  demandIndex,
int  patIndex 
)

Set the time pattern assigned to a node's demand category.

Parameters
nodeIndexThe node's index.
demandIndexThe index of one of the node's demand categories.
pattIndexThe index of a time pattern applied to this demand category.
Returns
Error code

§ ENsetelseaction()

int DLLEXPORT ENsetelseaction ( int  ruleIndex,
int  actionIndex,
int  linkIndex,
int  status,
EN_API_FLOAT_TYPE  setting 
)

Set the properties of an ELSE action in a rule-based control.

Parameters
ruleIndexThe rule's index.
actionIndexIndex of the ELSE action being modified.
linkIndexIndex of the link in the action (e.g. index of Pump 1)
statusStatus assigned to the link (see EN_RuleStatus)
settingSetting value assigned to the link (e.g. pump speed 0.9)
Returns
Error code.

§ ENsetflowunits()

int DLLEXPORT ENsetflowunits ( int  code)

Sets the flow units.

Parameters
codeCode of flow units to use
Returns
Error code

§ ENsetheadcurveindex()

int DLLEXPORT ENsetheadcurveindex ( int  pumpIndex,
int  curveIndex 
)

Sets the curve id for a specified pump index.

Parameters
pumpIndexThe index of the pump
curveIndexThe index of the curve used by the pump
Returns
Error code.

§ ENsetlinkid()

int DLLEXPORT ENsetlinkid ( int  index,
char *  newid 
)

Change the ID name for a link.

Parameters
indexThe index of a link. First link is index 1.
newidA string containing the link's new ID name.
Returns
Error code.

§ ENsetlinknodes()

int DLLEXPORT ENsetlinknodes ( int  index,
int  node1,
int  node2 
)

Set the indexes of a link's start- and end-nodes.

Parameters
indexThe index of a link (first link is index 1)
node1The index of the link's start node (first node is index 1).
node2The index of the link's end node (first node is index 1).
Returns
Error code
See also
ENsetnodeid, ENsetlinkid

§ ENsetlinktype()

int DLLEXPORT ENsetlinktype ( int *  index,
EN_LinkType  Code,
int  actionCode 
)

Set the link type code for a specified link.

Parameters
[in,out]indexThe index of a link before [in] and after [out] the type change
codeThe new type code of the link (see EN_LinkType).
actionCodeAction taken if any controls contain the link.
Returns
Error code
See also
the EN_LinkType enumeration

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.

§ ENsetlinkvalue()

int DLLEXPORT ENsetlinkvalue ( int  index,
int  code,
EN_API_FLOAT_TYPE  v 
)

Set a property value for a link.

Parameters
indexThe index of a link. First link is index 1.
codeThe code for the property to set.
vThe value to set for this link and property.
Returns
Error code.
See also
EN_LinkProperty

§ ENsetnodeid()

int DLLEXPORT ENsetnodeid ( int  index,
char *  newid 
)

Change the ID name for a node.

Parameters
indexThe index of a node. First node is index 1.
newidA string containing the node's new ID name.
Returns
Error code.

§ ENsetnodevalue()

int DLLEXPORT ENsetnodevalue ( int  index,
int  code,
EN_API_FLOAT_TYPE  v 
)

Set a property value for a node.

Parameters
indexThe index of a node. First node is index 1.
codeThe code for the proprty to set.
vThe value to set for this node and property.
Returns
Error code.
See also
EN_NodeProperty

§ ENsetoption()

int DLLEXPORT ENsetoption ( int  code,
EN_API_FLOAT_TYPE  v 
)

Set a value for an anlysis option.

Parameters
codeThe code for the desired option.
vThe desired value for the option specified.
Returns
Error code.
See also
EN_Option

§ ENsetpremise()

int DLLEXPORT ENsetpremise ( int  ruleIndex,
int  premiseIndex,
int  logop,
int  object,
int  objIndex,
int  variable,
int  relop,
int  status,
EN_API_FLOAT_TYPE  value 
)

Set the properties of a premise in a rule-based control.

Parameters
ruleIndexThe rule's index.
premiseIndexThe premise's index.
logopLogical operator (IF = 1, AND = 2, OR = 3) of the premise.
objectType of object the premise is looking at (see EN_RuleObject).
objIndexIndex of the object (e.g. the index of the tank).
variableIndex of the variable to be checked (see EN_RuleVariable).
relopRelationship operator in the premise (see EN_RuleOperator).
statusStatus of the object being checked (see EN_RuleStatus).
valueSetting of the variable being checked (e.g. 5.5)
Returns
Error code.

§ ENsetpremiseindex()

int DLLEXPORT ENsetpremiseindex ( int  ruleIndex,
int  premiseIndex,
int  objIndex 
)

Set the index of an object in a premise of a rule-based control.

Parameters
ruleIndexThe rule's index.
premiseIndexThe premise's index.
objIndexThe index of the premise's object (e.g. the index of the tank).
Returns
Error code.

§ ENsetpremisestatus()

int DLLEXPORT ENsetpremisestatus ( int  ruleIndex,
int  premiseIndex,
int  status 
)

Set the status in a premise of a rule-based control.

Parameters
ruleIndexThe rule's index.
premiseIndexThe premise's index.
statusThe status of the object being checked (see EN_RuleStatus)
Returns
Error code.

§ ENsetpremisevalue()

int DLLEXPORT ENsetpremisevalue ( int  ruleIndex,
int  premiseIndex,
EN_API_FLOAT_TYPE  value 
)

Set the value in a premise of a rule-based control.

Parameters
ruleIndexThe rule's index.
premiseIndexThe premise's index.
valueThe value of the premise's variable being checked (e.g. 5.5)
Returns
Error code.

§ ENsetqualtype()

int DLLEXPORT ENsetqualtype ( int  qualcode,
char *  chemname,
char *  chemunits,
char *  tracenode 
)

Set the type of quality analysis called for.

Parameters
qualcodeType of analysis to be made (see EN_QualityType).
chemnameName of the quality constituent.
chemunitsConcentration units of the constituent.
tracenodeID of node being traced (if applicable).
Returns
Error code.

Note: "chemname" and "chemunits" only apply when "qualcode" is EN_CHEM. "tracenode" only applies when 'qualcode" is EN_TRACE.

§ ENsetrulepriority()

int DLLEXPORT ENsetrulepriority ( int  index,
EN_API_FLOAT_TYPE  priority 
)

Set the priority of a rule-based control.

Parameters
indexThe rule's index.
priorityThe priority assigned to the rule.
Returns
Error code.

§ ENsetstatusreport()

int DLLEXPORT ENsetstatusreport ( int  code)

Set the level of hydraulic status reporting.

Parameters
codeStatus reporting code (see EN_StatusReport).
Returns
Error code.

§ ENsetthenaction()

int DLLEXPORT ENsetthenaction ( int  ruleIndex,
int  actionIndex,
int  linkIndex,
int  status,
EN_API_FLOAT_TYPE  setting 
)

Set the properties of a THEN action in a rule-based control.

Parameters
ruleIndexThe rule's index.
actionIndexIndex of the THEN action to modify.
linkIndexIndex of the link in the action (e.g. index of Pump 1)
statusStatus assigned to the link (e.g. CLOSED)
settingSetting value assigned to the link (e.g. pump speed 0.9)
Returns
Error code.

§ ENsettimeparam()

int DLLEXPORT ENsettimeparam ( int  code,
long  value 
)

Set the value for a time parameter.

Parameters
codeThe code for the parameter to set.
valueThe desired value of the parameter.
Returns
Error code.
See also
EN_TimeProperty