OWA-EPANET Toolkit  2.2
Network Link Functions

These functions are used for working with network links. More...

Functions

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_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_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...
 

Overview

These functions are used for working with network links.

Function Documentation

◆ EN_addlink()

int EN_addlink ( EN_Project  ph,
char *  id,
int  linkType,
char *  fromNode,
char *  toNode,
int *  out_index 
)

Adds a new link to a project.

Parameters
phan EPANET project handle.
idthe ID name of the link to be added.
linkTypeThe type of link being added (see EN_LinkType)
fromNodeThe ID name of the link's starting node.
toNodeThe ID name of the link's ending node.
[out]indexthe index of the newly added link.
Returns
an error code.

A new pipe is assigned a diameter of 10 inches (254 mm) and a length of 330 feet (~ 100 meters). Its roughness coefficient depends on the head loss formula in effect (see EN_HeadLossType) as follows:

  • Hazen-Williams formula: 130
  • Darcy-Weisbach formula: 0.5 millifeet (0.15 mm)
  • Chezy-Manning formula: 0.01

All other pipe properties are set to 0.

A new pump has a status of EN_OPEN, a speed setting of 1, and has no pump curve or power rating assigned to it.

A new valve has a diameter of 10 inches (254 mm) and all other properties set to 0.

See EN_LinkProperty.

◆ EN_deletelink()

int EN_deletelink ( EN_Project  ph,
int  index,
int  actionCode 
)

Deletes a link from the project.

Parameters
phan EPANET project handle.
indexthe index of the link to be deleted.
actionCodeThe action taken if any control contains the link.
Returns
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.

◆ EN_getheadcurveindex()

int EN_getheadcurveindex ( EN_Project  ph,
int  linkIndex,
int *  out_curveIndex 
)

Retrieves the curve assigned to a pump's head curve.

Parameters
phan EPANET project handle.
linkIndexthe index of a pump link (starting from 1).
[out]curveIndexthe index of the curve assigned to the pump's head curve.
Returns
an error code.

◆ EN_getlinkid()

int EN_getlinkid ( EN_Project  ph,
int  index,
char *  out_id 
)

Gets the ID name of a link given its index.

Parameters
phan EPANET project handle.
indexa link's index (starting from 1).
[out]out_idThe link's ID name.
Returns
an error code.

The ID name must be sized to hold at least EN_MAXID characters.

◆ EN_getlinkindex()

int EN_getlinkindex ( EN_Project  ph,
char *  id,
int *  out_index 
)

Gets the index of a link given its ID name.

Parameters
phan EPANET project handle.
ida link's ID name.
[out]indexthe link's index (starting from 1).
Returns
an error code.

◆ EN_getlinknodes()

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.

Parameters
phan EPANET project handle.
indexa link's index (starting from 1).
[out]node1the index of the link's start node (starting from 1).
[out]node2the index of the link's end node (starting from 1).
Returns
an error code.

◆ EN_getlinktype()

int EN_getlinktype ( EN_Project  ph,
int  index,
int *  out_linkType 
)

Retrieves a link's type.

Parameters
phan EPANET project handle.
indexa link's index (starting from 1).
[out]linkTypethe link's type (see EN_LinkType).
Returns
an error code.

◆ EN_getlinkvalue()

int EN_getlinkvalue ( EN_Project  ph,
int  index,
int  property,
double *  out_value 
)

Retrieves a property value for a link.

Parameters
phan EPANET project handle.
indexa link's index (starting from 1).
propertythe property to retrieve (see EN_LinkProperty).
[out]valuethe current value of the property.
Returns
an error code.

Values are returned in units that depend on the units used for flow rate (see Measurement Units).

◆ EN_getpumptype()

int EN_getpumptype ( EN_Project  ph,
int  linkIndex,
int *  out_pumpType 
)

Retrieves the type of head curve used by a pump.

Parameters
phan EPANET project handle.
linkIndexthe index of a pump link (starting from 1).
[out]pumpTypethe type of head curve used by the pump (see EN_PumpType).
Returns
an error code.

◆ EN_getvertex()

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.

Parameters
phan EPANET project handle.
indexa link's index (starting from 1).
vertexa vertex point index (starting from 1).
[out]xthe vertex's X-coordinate value.
[out]ythe vertex's Y-coordinate value.
Returns
an error code.

◆ EN_getvertexcount()

int EN_getvertexcount ( EN_Project  ph,
int  index,
int *  out_count 
)

Retrieves the number of internal vertex points assigned to a link.

Parameters
phan EPANET project handle.
indexa link's index (starting from 1).
[out]countthe number of vertex points that describe the link's shape.
Returns
an error code.

◆ EN_setheadcurveindex()

int EN_setheadcurveindex ( EN_Project  ph,
int  linkIndex,
int  curveIndex 
)

Assigns a curve to a pump's head curve.

Parameters
phan EPANET project handle.
linkIndexthe index of a pump link (starting from 1).
curveIndexthe index of a curve to be assigned as the pump's head curve.
Returns
an error code.

◆ EN_setlinkid()

int EN_setlinkid ( EN_Project  ph,
int  index,
char *  newid 
)

Changes the ID name of a link.

Parameters
phan EPANET project handle.
indexa link's index (starting from 1).
newidthe new ID name for the link.
Returns
Error code.

The ID name must not be longer than EN_MAXID characters.

◆ EN_setlinknodes()

int EN_setlinknodes ( EN_Project  ph,
int  index,
int  node1,
int  node2 
)

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

Parameters
phan EPANET project handle.
indexa link's index (starting from 1).
node1The index of the link's start node (starting from 1).
node2The index of the link's end node (starting from 1).
Returns
an error code.

◆ EN_setlinktype()

int EN_setlinktype ( EN_Project  ph,
int *  inout_index,
int  linkType,
int  actionCode 
)

Changes a link's type.

Parameters
phan EPANET project handle.
[in,out]inout_indexthe link's index before [in] and after [out] the type change.
linkTypethe new type to change the link to (see EN_LinkType).
actionCodethe action taken if any controls contain the link.
Returns
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.

◆ EN_setlinkvalue()

int EN_setlinkvalue ( EN_Project  ph,
int  index,
int  property,
double  value 
)

Sets a property value for a link.

Parameters
phan EPANET project handle.
indexa link's index.
propertythe property to set (see EN_LinkProperty).
valuethe new value for the property.
Returns
an error code.

Values are in units that depend on the units used for flow rate (see Measurement Units).

◆ EN_setpipedata()

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.

Parameters
phan EPANET project handle.
indexthe index of a pipe link (starting from 1).
lengththe pipe's length.
diamthe pipe's diameter.
roughthe pipe's roughness coefficient.
mlossthe pipe's minor loss coefficient.
Returns
an error code.

These properties have units that depend on the units used for flow rate (see Measurement Units).

◆ EN_setvertex()

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.

Parameters
phan EPANET project handle.
indexa link's index (starting from 1).
vertexa vertex point index (starting from 1).
xthe vertex's X-coordinate value.
ythe vertex's Y-coordinate value.
Returns
an error code.

◆ EN_setvertices()

int EN_setvertices ( EN_Project  ph,
int  index,
double *  x,
double *  y,
int  count 
)

Assigns a set of internal vertex points to a link.

Parameters
phan EPANET project handle.
indexa link's index (starting from 1).
xan array of X-coordinates for the vertex points.
yan array of Y-coordinates for the vertex points.
countthe number of vertex points being assigned.
Returns
an error code.

Replaces any existing vertices previously assigned to the link.