OWA-EPANET Toolkit  2.2
epanet2_2.h File Reference

Go to the source code of this file.

Typedefs

typedef struct Project * EN_Project
 The EPANET Project wrapper object.
 

Functions

int EN_createproject (EN_Project *ph)
 Creates an EPANET project. More...
 
int EN_deleteproject (EN_Project ph)
 Deletes a currently opened EPANET project. More...
 
int EN_runproject (EN_Project ph, const char *inpFile, const char *rptFile, const char *outFile, void(*pviewprog)(char *))
 Runs a complete EPANET simulation. More...
 
int EN_init (EN_Project ph, const char *rptFile, const char *outFile, int unitsType, int headLossType)
 Initializes an EPANET project. More...
 
int EN_open (EN_Project ph, const char *inpFile, const char *rptFile, const char *outFile)
 Opens an EPANET input file & reads in network data. More...
 
int EN_gettitle (EN_Project ph, char *out_line1, char *out_line2, char *out_line3)
 Retrieves the title lines of the project. More...
 
int EN_settitle (EN_Project ph, char *line1, char *line2, char *line3)
 Sets the title lines of the project. More...
 
int EN_getcomment (EN_Project ph, int object, int index, char *out_comment)
 Retrieves a descriptive comment assigned to a Node, Link, Pattern or Curve. More...
 
int EN_setcomment (EN_Project ph, int object, int index, char *comment)
 Assigns a descriptive comment to a Node, Link, Pattern or Curve. More...
 
int EN_getcount (EN_Project ph, int object, int *out_count)
 Retrieves the number of objects of a given type in a project. More...
 
int EN_saveinpfile (EN_Project ph, const char *filename)
 Saves a project's data to an EPANET-formatted text file. More...
 
int EN_close (EN_Project ph)
 Closes a project and frees all of its memory. More...
 
int EN_solveH (EN_Project ph)
 Runs a complete hydraulic simulation with results for all time periods written to a temporary hydraulics file. More...
 
int EN_usehydfile (EN_Project ph, const char *filename)
 Uses a previously saved binary hydraulics file to supply a project's hydraulics. More...
 
int EN_openH (EN_Project ph)
 Opens a project's hydraulic solver. More...
 
int EN_initH (EN_Project ph, int initFlag)
 Initializes a network prior to running a hydraulic analysis. More...
 
int EN_runH (EN_Project ph, long *out_currentTime)
 Computes a hydraulic solution for the current point in time. More...
 
int EN_nextH (EN_Project ph, long *out_tStep)
 Determines the length of time until the next hydraulic event occurs in an extended period simulation. More...
 
int EN_saveH (EN_Project ph)
 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. More...
 
int EN_savehydfile (EN_Project ph, const char *filename)
 Saves a project's temporary hydraulics file to disk. More...
 
int EN_closeH (EN_Project ph)
 Closes the hydraulic solver freeing all of its allocated memory. More...
 
int EN_solveQ (EN_Project ph)
 Runs a complete water quality simulation with results at uniform reporting intervals written to the project's binary output file. More...
 
int EN_openQ (EN_Project ph)
 Opens a project's water quality solver. More...
 
int EN_initQ (EN_Project ph, int saveFlag)
 Initializes a network prior to running a water quality analysis. More...
 
int EN_runQ (EN_Project ph, long *out_currentTime)
 Makes hydraulic and water quality results at the start of the current time period available to a project's water quality solver. More...
 
int EN_nextQ (EN_Project ph, long *out_tStep)
 Advances a water quality simulation over the time until the next hydraulic event. More...
 
int EN_stepQ (EN_Project ph, long *out_timeLeft)
 Advances a water quality simulation by a single water quality time step. More...
 
int EN_closeQ (EN_Project ph)
 Closes the water quality solver, freeing all of its allocated memory. More...
 
int EN_writeline (EN_Project ph, char *line)
 Writes a line of text to a project's report file. More...
 
int EN_report (EN_Project ph)
 Writes simulation results in a tabular format to a project's report file. More...
 
int EN_copyreport (EN_Project ph, char *filename)
 Copies the current contents of a project's report file to another file. More...
 
int EN_clearreport (EN_Project ph)
 Clears the contents of a project's report file. More...
 
int EN_resetreport (EN_Project ph)
 Resets a project's report options to their default values. More...
 
int EN_setreport (EN_Project ph, char *format)
 Processes a reporting format command. More...
 
int EN_setstatusreport (EN_Project ph, int level)
 Sets the level of hydraulic status reporting. More...
 
int EN_getversion (int *out_version)
 Retrieves the toolkit API version number. More...
 
int EN_geterror (int errcode, char *out_errmsg, int maxLen)
 Returns the text of an error message generated by an error code. More...
 
int EN_getstatistic (EN_Project ph, int type, double *out_value)
 Retrieves a particular simulation statistic. More...
 
int EN_getresultindex (EN_Project ph, int type, int index, int *out_value)
 Retrieves the order in which a node or link appears in an output file. More...
 
int EN_getoption (EN_Project ph, int option, double *out_value)
 Retrieves the value of an analysis option. More...
 
int EN_setoption (EN_Project ph, int option, double value)
 Sets the value for an anlysis option. More...
 
int EN_getflowunits (EN_Project ph, int *out_units)
 Retrieves a project's flow units. More...
 
int EN_setflowunits (EN_Project ph, int units)
 Sets a project's flow units. More...
 
int EN_gettimeparam (EN_Project ph, int param, long *out_value)
 Retrieves the value of a time parameter. More...
 
int EN_settimeparam (EN_Project ph, int param, long value)
 Sets the value of a time parameter. More...
 
int EN_getqualinfo (EN_Project ph, int *out_qualType, char *out_chemName, char *out_chemUnits, int *out_traceNode)
 Gets information about the type of water quality analysis requested. More...
 
int EN_getqualtype (EN_Project ph, int *out_qualType, int *out_traceNode)
 Retrieves the type of water quality analysis to be run. More...
 
int EN_setqualtype (EN_Project ph, int qualType, char *chemName, char *chemUnits, char *traceNode)
 Sets the type of water quality analysis to run. More...
 
int EN_addnode (EN_Project ph, char *id, int nodeType, int *out_index)
 Adds a new node to a project. More...
 
int EN_deletenode (EN_Project ph, int index, int actionCode)
 Deletes a node from a project. More...
 
int EN_getnodeindex (EN_Project ph, char *id, int *out_index)
 Gets the index of a node given its ID name. More...
 
int EN_getnodeid (EN_Project ph, int index, char *out_id)
 Gets the ID name of a node given its index. More...
 
int EN_setnodeid (EN_Project ph, int index, char *newid)
 Changes the ID name of a node. More...
 
int EN_getnodetype (EN_Project ph, int index, int *out_nodeType)
 Retrieves a node's type given its index. More...
 
int EN_getnodevalue (EN_Project ph, int index, int property, double *out_value)
 Retrieves a property value for a node. More...
 
int EN_setnodevalue (EN_Project ph, int index, int property, double value)
 Sets a property value for a node. More...
 
int EN_setjuncdata (EN_Project ph, int index, double elev, double dmnd, char *dmndpat)
 Sets a group of properties for a junction node. More...
 
int EN_settankdata (EN_Project ph, int index, double elev, double initlvl, double minlvl, double maxlvl, double diam, double minvol, char *volcurve)
 Sets a group of properties for a tank node. More...
 
int EN_getcoord (EN_Project ph, int index, double *out_x, double *out_y)
 Gets the (x,y) coordinates of a node. More...
 
int EN_setcoord (EN_Project ph, int index, double x, double y)
 Sets the (x,y) coordinates of a node. More...
 
int EN_getdemandmodel (EN_Project ph, int *out_type, double *out_pmin, double *out_preq, double *out_pexp)
 Retrieves the type of demand model in use and its parameters. More...
 
int EN_setdemandmodel (EN_Project ph, int type, double pmin, double preq, double pexp)
 Sets the type of demand model to use and its parameters. More...
 
int EN_adddemand (EN_Project ph, int nodeIndex, double baseDemand, char *demandPattern, char *demandName)
 appends a new demand to a junction node demands list. More...
 
int EN_deletedemand (EN_Project ph, int nodeIndex, int demandIndex)
 deletes a demand from a junction node. More...
 
int EN_getdemandindex (EN_Project ph, int nodeIndex, char *demandName, int *out_demandIndex)
 Retrieves the index of a node's named demand category. More...
 
int EN_getnumdemands (EN_Project ph, int nodeIndex, int *out_numDemands)
 Retrieves the number of demand categories for a junction node. More...
 
int EN_getbasedemand (EN_Project ph, int nodeIndex, int demandIndex, double *out_baseDemand)
 Gets the base demand for one of a node's demand categories. More...
 
int EN_setbasedemand (EN_Project ph, int nodeIndex, int demandIndex, double baseDemand)
 Sets the base demand for one of a node's demand categories. More...
 
int EN_getdemandpattern (EN_Project ph, int nodeIndex, int demandIndex, int *out_patIndex)
 Retrieves the index of a time pattern assigned to one of a node's demand categories. More...
 
int EN_setdemandpattern (EN_Project ph, int nodeIndex, int demandIndex, int patIndex)
 Sets the index of a time pattern used for one of a node's demand categories. More...
 
int EN_getdemandname (EN_Project ph, int nodeIndex, int demandIndex, char *out_demandName)
 Retrieves the name of a node's demand category. More...
 
int EN_setdemandname (EN_Project ph, int nodeIndex, int demandIdx, char *demandName)
 Assigns a name to a node's demand category. More...
 
int EN_addlink (EN_Project ph, char *id, int linkType, char *fromNode, char *toNode, int *out_index)
 Adds a new link to a project. More...
 
int EN_deletelink (EN_Project ph, int index, int actionCode)
 Deletes a link from the project. More...
 
int EN_getlinkindex (EN_Project ph, char *id, int *out_index)
 Gets the index of a link given its ID name. More...
 
int EN_getlinkid (EN_Project ph, int index, char *out_id)
 Gets the ID name of a link given its index. More...
 
int EN_setlinkid (EN_Project ph, int index, char *newid)
 Changes the ID name of a link. More...
 
int EN_getlinktype (EN_Project ph, int index, int *out_linkType)
 Retrieves a link's type. More...
 
int EN_setlinktype (EN_Project ph, int *inout_index, int linkType, int actionCode)
 Changes a link's type. More...
 
int EN_getlinknodes (EN_Project ph, int index, int *out_node1, int *out_node2)
 Gets the indexes of a link's start- and end-nodes. More...
 
int EN_setlinknodes (EN_Project ph, int index, int node1, int node2)
 Sets the indexes of a link's start- and end-nodes. More...
 
int EN_getlinkvalue (EN_Project ph, int index, int property, double *out_value)
 Retrieves a property value for a link. More...
 
int EN_setlinkvalue (EN_Project ph, int index, int property, double value)
 Sets a property value for a link. More...
 
int EN_setpipedata (EN_Project ph, int index, double length, double diam, double rough, double mloss)
 Sets a group of properties for a pipe link. More...
 
int EN_getvertexcount (EN_Project ph, int index, int *out_count)
 Retrieves the number of internal vertex points assigned to a link. More...
 
int EN_getvertex (EN_Project ph, int index, int vertex, double *out_x, double *out_y)
 Retrieves the coordinates of a vertex point assigned to a link. More...
 
int EN_setvertex (EN_Project ph, int index, int vertex, double x, double y)
 Sets the coordinates of a vertex point assigned to a link. More...
 
int EN_setvertices (EN_Project ph, int index, double *x, double *y, int count)
 Assigns a set of internal vertex points to a link. More...
 
int EN_getpumptype (EN_Project ph, int linkIndex, int *out_pumpType)
 Retrieves the type of head curve used by a pump. More...
 
int EN_getheadcurveindex (EN_Project ph, int linkIndex, int *out_curveIndex)
 Retrieves the curve assigned to a pump's head curve. More...
 
int EN_setheadcurveindex (EN_Project ph, int linkIndex, int curveIndex)
 Assigns a curve to a pump's head curve. More...
 
int EN_addpattern (EN_Project ph, char *id)
 Adds a new time pattern to a project. More...
 
int EN_deletepattern (EN_Project ph, int index)
 Deletes a time pattern from a project. More...
 
int EN_getpatternindex (EN_Project ph, char *id, int *out_index)
 Retrieves the index of a time pattern given its ID name. More...
 
int EN_getpatternid (EN_Project ph, int index, char *out_id)
 Retrieves the ID name of a time pattern given its index. More...
 
int EN_setpatternid (EN_Project ph, int index, char *id)
 Changes the ID name of a time pattern given its index. More...
 
int EN_getpatternlen (EN_Project ph, int index, int *out_len)
 Retrieves the number of time periods in a time pattern. More...
 
int EN_getpatternvalue (EN_Project ph, int index, int period, double *out_value)
 Retrieves a time pattern's factor for a given time period. More...
 
int EN_setpatternvalue (EN_Project ph, int index, int period, double value)
 Sets a time pattern's factor for a given time period. More...
 
int EN_getaveragepatternvalue (EN_Project ph, int index, double *out_value)
 Retrieves the average of all pattern factors in a time pattern. More...
 
int EN_setpattern (EN_Project ph, int index, double *values, int len)
 Sets the pattern factors for a given time pattern. More...
 
int EN_addcurve (EN_Project ph, char *id)
 Adds a new data curve to a project. More...
 
int EN_deletecurve (EN_Project ph, int index)
 Deletes a data curve from a project. More...
 
int EN_getcurveindex (EN_Project ph, char *id, int *out_index)
 Retrieves the index of a curve given its ID name. More...
 
int EN_getcurveid (EN_Project ph, int index, char *out_id)
 Retrieves the ID name of a curve given its index. More...
 
int EN_setcurveid (EN_Project ph, int index, char *id)
 Changes the ID name of a data curve given its index. More...
 
int EN_getcurvelen (EN_Project ph, int index, int *out_len)
 Retrieves the number of points in a curve. More...
 
int EN_getcurvetype (EN_Project ph, int index, int *out_type)
 Retrieves a curve's type. More...
 
int EN_setcurvetype (EN_Project ph, int index, int type)
 Sets a curve's type. More...
 
int EN_getcurvevalue (EN_Project ph, int curveIndex, int pointIndex, double *out_x, double *out_y)
 Retrieves the value of a single data point for a curve. More...
 
int EN_setcurvevalue (EN_Project ph, int curveIndex, int pointIndex, double x, double y)
 Sets the value of a single data point for a curve. More...
 
int EN_getcurve (EN_Project ph, int index, char *out_id, int *out_nPoints, double *out_xValues, double *out_yValues)
 Retrieves all of a curve's data. More...
 
int EN_setcurve (EN_Project ph, int index, double *xValues, double *yValues, int nPoints)
 assigns a set of data points to a curve. More...
 
int EN_addcontrol (EN_Project ph, int type, int linkIndex, double setting, int nodeIndex, double level, int *out_index)
 Adds a new simple control to a project. More...
 
int EN_deletecontrol (EN_Project ph, int index)
 Deletes an existing simple control. More...
 
int EN_getcontrol (EN_Project ph, int index, int *out_type, int *out_linkIndex, double *out_setting, int *out_nodeIndex, double *out_level)
 Retrieves the properties of a simple control. More...
 
int EN_setcontrol (EN_Project ph, int index, int type, int linkIndex, double setting, int nodeIndex, double level)
 Sets the properties of an existing simple control. More...
 
int EN_addrule (EN_Project ph, char *rule)
 Adds a new rule-based control to a project. More...
 
int EN_deleterule (EN_Project ph, int index)
 Deletes an existing rule-based control. More...
 
int EN_getrule (EN_Project ph, int index, int *out_nPremises, int *out_nThenActions, int *out_nElseActions, double *out_priority)
 Retrieves summary information about a rule-based control. More...
 
int EN_getruleID (EN_Project ph, int index, char *out_id)
 Gets the ID name of a rule-based control given its index. More...
 
int EN_getpremise (EN_Project ph, int ruleIndex, int premiseIndex, int *out_logop, int *out_object, int *out_objIndex, int *out_variable, int *out_relop, int *out_status, double *out_value)
 Gets the properties of a premise in a rule-based control. More...
 
int EN_setpremise (EN_Project ph, int ruleIndex, int premiseIndex, int logop, int object, int objIndex, int variable, int relop, int status, double value)
 Sets the properties of a premise in a rule-based control. More...
 
int EN_setpremiseindex (EN_Project ph, int ruleIndex, int premiseIndex, int objIndex)
 Sets the index of an object in a premise of a rule-based control. More...
 
int EN_setpremisestatus (EN_Project ph, int ruleIndex, int premiseIndex, int status)
 Sets the status being compared to in a premise of a rule-based control. More...
 
int EN_setpremisevalue (EN_Project ph, int ruleIndex, int premiseIndex, double value)
 Sets the value in a premise of a rule-based control. More...
 
int EN_getthenaction (EN_Project ph, int ruleIndex, int actionIndex, int *out_linkIndex, int *out_status, double *out_setting)
 Gets the properties of a THEN action in a rule-based control. More...
 
int EN_setthenaction (EN_Project ph, int ruleIndex, int actionIndex, int linkIndex, int status, double setting)
 Sets the properties of a THEN action in a rule-based control. More...
 
int EN_getelseaction (EN_Project ph, int ruleIndex, int actionIndex, int *out_linkIndex, int *out_status, double *out_setting)
 Gets the properties of an ELSE action in a rule-based control. More...
 
int EN_setelseaction (EN_Project ph, int ruleIndex, int actionIndex, int linkIndex, int status, double setting)
 Sets the properties of an ELSE action in a rule-based control. More...
 
int EN_setrulepriority (EN_Project ph, int index, double priority)
 Sets the priority of a rule-based control. More...
 

Detailed Description

Function Documentation

◆ EN_getcomment()

int EN_getcomment ( EN_Project  ph,
int  object,
int  index,
char *  out_comment 
)

Retrieves a descriptive comment assigned to a Node, Link, Pattern or Curve.

Parameters
phan EPANET project handle.
objecta type of object (either EN_NODE, EN_LINK, EN_TIMEPAT or EN_CURVE)
indexthe object's index starting from 1
[out]out_commentthe comment string assigned to the object
Returns
an error code

◆ EN_getcurve()

int EN_getcurve ( EN_Project  ph,
int  index,
char *  out_id,
int *  out_nPoints,
double *  out_xValues,
double *  out_yValues 
)

Retrieves all of a curve's data.

Parameters
phan EPANET project handle.
indexa curve's index (starting from 1).
[out]out_idthe curve's ID name.
[out]nPointsthe number of data points on the curve.
[out]xValuesthe curve's x-values.
[out]yValuesthe curve's y-values.
Returns
an error code.

The calling program is responsible for making xValues and yValues large enough to hold nPoints number of data points and for sizing id to hold at least EN_MAXID characters.

◆ EN_setcomment()

int EN_setcomment ( EN_Project  ph,
int  object,
int  index,
char *  comment 
)

Assigns a descriptive comment to a Node, Link, Pattern or Curve.

Parameters
phan EPANET project handle.
objecta type of object (either EN_NODE, EN_LINK, EN_TIMEPAT or EN_CURVE)
indexthe object's index starting from 1
commentthe comment string assigned to the object
Returns
an error code