EPANET
epanet2_2.h
Go to the documentation of this file.
1 
5 /*
6  ******************************************************************************
7  Project: OWA EPANET
8  Version: 2.3
9  Module: epanet2.h
10  Description: API function declarations
11  Authors: see AUTHORS
12  Copyright: see AUTHORS
13  License: see LICENSE
14  Last Updated: 04/25/2025
15  ******************************************************************************
16  */
17 
18 #ifndef EPANET2_2_H
19 #define EPANET2_2_H
20 
21 #ifdef epanet_py_EXPORTS
22  #define DLLEXPORT
23 #else
24  #ifndef DLLEXPORT
25  #ifdef _WIN32
26  #ifdef epanet2_EXPORTS
27  #define DLLEXPORT __declspec(dllexport) __stdcall
28  #else
29  #define DLLEXPORT __declspec(dllimport) __stdcall
30  #endif
31  #elif defined(__CYGWIN__)
32  #define DLLEXPORT __stdcall
33  #else
34  #define DLLEXPORT
35  #endif
36  #endif
37 #endif
38 
39 #include "epanet2_enums.h"
40 
41 // --- Declare the EPANET toolkit functions
42 #if defined(__cplusplus)
43 extern "C" {
44 #endif
45 
49 typedef struct Project *EN_Project;
50 
51 /*===================================================================
52 
53  Project Functions
54 
55 ===================================================================*/
56 
64  int DLLEXPORT EN_createproject(EN_Project *ph);
65 
73  int DLLEXPORT EN_deleteproject(EN_Project ph);
74 
96  int DLLEXPORT EN_runproject(EN_Project ph, const char *inpFile, const char *rptFile,
97  const char *outFile, void (*pviewprog)(char *));
98 
112  int DLLEXPORT EN_init(EN_Project ph, const char *rptFile, const char *outFile,
113  int unitsType, int headLossType);
114 
127  int DLLEXPORT EN_open(EN_Project ph, const char *inpFile, const char *rptFile,
128  const char *outFile);
129 
142  int DLLEXPORT EN_openX(EN_Project ph, const char *inpFile, const char *rptFile,
143  const char *outFile);
144 
153  int DLLEXPORT EN_gettitle(EN_Project ph, char *out_line1, char *out_line2, char *out_line3);
154 
163  int DLLEXPORT EN_settitle(EN_Project ph, const char *line1, const char *line2,
164  const char *line3);
165 
174  int DLLEXPORT EN_getcomment(EN_Project ph, int object, int index, char *out_comment);
175 
184  int DLLEXPORT EN_setcomment(EN_Project ph, int object, int index,
185  const char *comment);
186 
195  int DLLEXPORT EN_gettag(EN_Project ph, int object, int index, char *out_tag);
196 
205  int DLLEXPORT EN_settag(EN_Project ph, int object, int index,
206  const char *tag);
207 
215  int DLLEXPORT EN_getcount(EN_Project ph, int object, int *out_count);
216 
223  int DLLEXPORT EN_saveinpfile(EN_Project ph, const char *filename);
224 
234  int DLLEXPORT EN_close(EN_Project ph);
235 
236 /*===================================================================
237 
238  Hydraulic Analysis Functions
239 
240 ===================================================================*/
241 
268  int DLLEXPORT EN_solveH(EN_Project ph);
269 
282  int DLLEXPORT EN_usehydfile(EN_Project ph, const char *filename);
283 
297  int DLLEXPORT EN_openH(EN_Project ph);
298 
325  int DLLEXPORT EN_initH(EN_Project ph, int initFlag);
326 
341  int DLLEXPORT EN_runH(EN_Project ph, long *out_currentTime);
342 
375  int DLLEXPORT EN_nextH(EN_Project ph, long *out_tStep);
376 
387  int DLLEXPORT EN_saveH(EN_Project ph);
388 
405  int DLLEXPORT EN_savehydfile(EN_Project ph, const char *filename);
406 
414  int DLLEXPORT EN_closeH(EN_Project ph);
415 
416 /*===================================================================
417 
418  Water Quality Analysis Functions
419 
420 ===================================================================*/
421 
439  int DLLEXPORT EN_solveQ(EN_Project ph);
440 
454  int DLLEXPORT EN_openQ(EN_Project ph);
455 
470  int DLLEXPORT EN_initQ(EN_Project ph, int saveFlag);
471 
491  int DLLEXPORT EN_runQ(EN_Project ph, long *out_currentTime);
492 
523  int DLLEXPORT EN_nextQ(EN_Project ph, long *out_tStep);
524 
539  int DLLEXPORT EN_stepQ(EN_Project ph, long *out_timeLeft);
540 
551  int DLLEXPORT EN_closeQ(EN_Project ph);
552 
553 /*===================================================================
554 
555  Reporting Functions
556 
557 ===================================================================*/
558 
577  int DLLEXPORT EN_setreportcallback(EN_Project ph, void(*callback)(void *userData, void *EN_projectHandle, const char*));
578 
589  int DLLEXPORT EN_setreportcallbackuserdata(EN_Project ph, void *userData);
590 
600  int DLLEXPORT EN_writeline(EN_Project ph, const char *line);
601 
614  int DLLEXPORT EN_report(EN_Project ph);
615 
625  int DLLEXPORT EN_copyreport(EN_Project ph, const char *filename);
626 
632  int DLLEXPORT EN_clearreport(EN_Project ph);
633 
649  int DLLEXPORT EN_resetreport(EN_Project ph);
650 
663  int DLLEXPORT EN_setreport(EN_Project ph, const char *format);
664 
683  int DLLEXPORT EN_setstatusreport(EN_Project ph, int level);
684 
693  int DLLEXPORT EN_getversion(int *out_version);
694 
704  int DLLEXPORT EN_geterror(int errcode, char *out_errmsg, int maxLen);
705 
713  int DLLEXPORT EN_getstatistic(EN_Project ph, int type, double* out_value);
714 
715 
723  int DLLEXPORT EN_timetonextevent(EN_Project ph, int *eventType, long *duration, int *elementIndex);
724 
739  int DLLEXPORT EN_getresultindex(EN_Project ph, int type, int index, int *out_value);
740 
741 /*===================================================================
742 
743  Analysis Options Functions
744 
745 ===================================================================*/
746 
754  int DLLEXPORT EN_getoption(EN_Project ph, int option, double *out_value);
755 
764  int DLLEXPORT EN_setoption(EN_Project ph, int option, double value);
765 
775  int DLLEXPORT EN_getflowunits(EN_Project ph, int *out_units);
776 
786  int DLLEXPORT EN_setflowunits(EN_Project ph, int units);
787 
795  int DLLEXPORT EN_gettimeparam(EN_Project ph, int param, long *out_value);
796 
804  int DLLEXPORT EN_settimeparam(EN_Project ph, int param, long value);
805 
815  int DLLEXPORT EN_getqualinfo(EN_Project ph, int *out_qualType, char *out_chemName,
816  char *out_chemUnits, int *out_traceNode);
817 
825  int DLLEXPORT EN_getqualtype(EN_Project ph, int *out_qualType, int *out_traceNode);
826 
841  int DLLEXPORT EN_setqualtype(EN_Project ph, int qualType, const char *chemName,
842  const char *chemUnits, const char *traceNode);
843 
844 /*===================================================================
845 
846  Node Functions
847 
848 ===================================================================*/
849 
860  int DLLEXPORT EN_addnode(EN_Project ph, const char *id, int nodeType, int *out_index);
861 
875  int DLLEXPORT EN_deletenode(EN_Project ph, int index, int actionCode);
876 
884  int DLLEXPORT EN_getnodeindex(EN_Project ph, const char *id, int *out_index);
885 
895  int DLLEXPORT EN_getnodeid(EN_Project ph, int index, char *out_id);
896 
906  int DLLEXPORT EN_setnodeid(EN_Project ph, int index, const char *newid);
907 
915  int DLLEXPORT EN_getnodetype(EN_Project ph, int index, int *out_nodeType);
916 
929  int DLLEXPORT EN_getnodevalue(EN_Project ph, int index, int property, double *out_value);
930 
942  int DLLEXPORT EN_getnodevalues(EN_Project ph, int property, double *out_values);
943 
954  int DLLEXPORT EN_setnodevalue(EN_Project ph, int index, int property, double value);
955 
967  int DLLEXPORT EN_setjuncdata(EN_Project ph, int index, double elev, double dmnd,
968  const char *dmndpat);
969 
985  int DLLEXPORT EN_settankdata(EN_Project ph, int index, double elev, double initlvl,
986  double minlvl, double maxlvl, double diam, double minvol, const char *volcurve);
987 
996  int DLLEXPORT EN_getcoord(EN_Project ph, int index, double *out_x, double *out_y);
997 
1006  int DLLEXPORT EN_setcoord(EN_Project ph, int index, double x, double y);
1007 
1008 /*===================================================================
1009 
1010  Nodal Demand Functions
1011 
1012 ===================================================================*/
1013 
1025  int DLLEXPORT EN_getdemandmodel(EN_Project ph, int *out_type, double *out_pmin,
1026  double *out_preq, double *out_pexp);
1027 
1045  int DLLEXPORT EN_setdemandmodel(EN_Project ph, int type, double pmin,
1046  double preq, double pexp);
1047 
1048 
1061  int DLLEXPORT EN_adddemand(EN_Project ph, int nodeIndex, double baseDemand,
1062  const char *demandPattern, const char *demandName);
1063 
1071  int DLLEXPORT EN_deletedemand(EN_Project ph, int nodeIndex, int demandIndex);
1072 
1081  int DLLEXPORT EN_getdemandindex(EN_Project ph, int nodeIndex, const char *demandName,
1082  int *out_demandIndex);
1083 
1091  int DLLEXPORT EN_getnumdemands(EN_Project ph, int nodeIndex, int *out_numDemands);
1092 
1101  int DLLEXPORT EN_getbasedemand(EN_Project ph, int nodeIndex, int demandIndex,
1102  double *out_baseDemand);
1103 
1112  int DLLEXPORT EN_setbasedemand(EN_Project ph, int nodeIndex, int demandIndex,
1113  double baseDemand);
1114 
1126  int DLLEXPORT EN_getdemandpattern(EN_Project ph, int nodeIndex, int demandIndex,
1127  int *out_patIndex);
1128 
1140  int DLLEXPORT EN_setdemandpattern(EN_Project ph, int nodeIndex, int demandIndex, int patIndex);
1141 
1152  int DLLEXPORT EN_getdemandname(EN_Project ph, int nodeIndex, int demandIndex, char *out_demandName);
1153 
1164  int DLLEXPORT EN_setdemandname(EN_Project ph, int nodeIndex, int demandIdx,
1165  const char *demandName);
1166 
1167 /*===================================================================
1168 
1169  Link Functions
1170 
1171 ===================================================================*/
1172 
1198  int DLLEXPORT EN_addlink(EN_Project ph, const char *id, int linkType, const char *fromNode,
1199  const char *toNode, int *out_index);
1200 
1212  int DLLEXPORT EN_deletelink(EN_Project ph, int index, int actionCode);
1213 
1221  int DLLEXPORT EN_getlinkindex(EN_Project ph, const char *id, int *out_index);
1222 
1232  int DLLEXPORT EN_getlinkid(EN_Project ph, int index, char *out_id);
1233 
1243  int DLLEXPORT EN_setlinkid(EN_Project ph, int index, const char *newid);
1244 
1252  int DLLEXPORT EN_getlinktype(EN_Project ph, int index, int *out_linkType);
1253 
1269  int DLLEXPORT EN_setlinktype(EN_Project ph, int *inout_index, int linkType, int actionCode);
1270 
1279  int DLLEXPORT EN_getlinknodes(EN_Project ph, int index, int *out_node1, int *out_node2);
1280 
1289  int DLLEXPORT EN_setlinknodes(EN_Project ph, int index, int node1, int node2);
1290 
1301  int DLLEXPORT EN_getlinkvalue(EN_Project ph, int index, int property, double *out_value);
1302 
1312  int DLLEXPORT EN_getlinkvalues(EN_Project ph, int property, double *out_values);
1313 
1324  int DLLEXPORT EN_setlinkvalue(EN_Project ph, int index, int property, double value);
1325 
1338  int DLLEXPORT EN_setpipedata(EN_Project ph, int index, double length, double diam,
1339  double rough, double mloss);
1340 
1348  int DLLEXPORT EN_getvertexcount(EN_Project ph, int index, int *out_count);
1349 
1359  int DLLEXPORT EN_getvertex(EN_Project ph, int index, int vertex, double *out_x, double *out_y);
1360 
1370  int DLLEXPORT EN_setvertex(EN_Project ph, int index, int vertex, double x, double y);
1371 
1383  int DLLEXPORT EN_setvertices(EN_Project ph, int index, double *x, double *y, int count);
1384 
1385 /*===================================================================
1386 
1387  Pump Functions
1388 
1389 ===================================================================*/
1390 
1398  int DLLEXPORT EN_getpumptype(EN_Project ph, int linkIndex, int *out_pumpType);
1399 
1407  int DLLEXPORT EN_getheadcurveindex(EN_Project ph, int linkIndex, int *out_curveIndex);
1408 
1416  int DLLEXPORT EN_setheadcurveindex(EN_Project ph, int linkIndex, int curveIndex);
1417 
1418 /*===================================================================
1419 
1420  Time Pattern Functions
1421 
1422 ===================================================================*/
1423 
1432  int DLLEXPORT EN_addpattern(EN_Project ph, const char *id);
1433 
1440  int DLLEXPORT EN_deletepattern(EN_Project ph, int index);
1441 
1449  int DLLEXPORT EN_getpatternindex(EN_Project ph, const char *id, int *out_index);
1450 
1460  int DLLEXPORT EN_getpatternid(EN_Project ph, int index, char *out_id);
1461 
1471  int DLLEXPORT EN_setpatternid(EN_Project ph, int index, const char *id);
1472 
1480  int DLLEXPORT EN_getpatternlen(EN_Project ph, int index, int *out_len);
1481 
1490  int DLLEXPORT EN_getpatternvalue(EN_Project ph, int index, int period, double *out_value);
1491 
1500  int DLLEXPORT EN_setpatternvalue(EN_Project ph, int index, int period, double value);
1501 
1509  int DLLEXPORT EN_getaveragepatternvalue(EN_Project ph, int index, double *out_value);
1510 
1524  int DLLEXPORT EN_setpattern(EN_Project ph, int index, double *values, int len);
1525 
1533  int DLLEXPORT EN_loadpatternfile(EN_Project ph, const char *filename, const char *id);
1534 
1535 /*===================================================================
1536 
1537  Data Curve Functions
1538 
1539 ===================================================================*/
1540 
1549  int DLLEXPORT EN_addcurve(EN_Project ph, const char *id);
1550 
1557  int DLLEXPORT EN_deletecurve(EN_Project ph, int index);
1558 
1566  int DLLEXPORT EN_getcurveindex(EN_Project ph, const char *id, int *out_index);
1567 
1577  int DLLEXPORT EN_getcurveid(EN_Project ph, int index, char *out_id);
1578 
1588  int DLLEXPORT EN_setcurveid(EN_Project ph, int index, const char *id);
1589 
1597  int DLLEXPORT EN_getcurvelen(EN_Project ph, int index, int *out_len);
1598 
1606  int DLLEXPORT EN_getcurvetype(EN_Project ph, int index, int *out_type);
1607 
1615  int DLLEXPORT EN_setcurvetype(EN_Project ph, int index, int type);
1616 
1626  int DLLEXPORT EN_getcurvevalue(EN_Project ph, int curveIndex, int pointIndex,
1627  double *out_x, double *out_y);
1628 
1638  int DLLEXPORT EN_setcurvevalue(EN_Project ph, int curveIndex, int pointIndex,
1639  double x, double y);
1640 
1655  int DLLEXPORT EN_getcurve(EN_Project ph, int index, char *out_id, int *out_nPoints,
1656  double *out_xValues, double *out_yValues);
1657 
1672  int DLLEXPORT EN_setcurve(EN_Project ph, int index, double *xValues,
1673  double *yValues, int nPoints);
1674 
1675 /*===================================================================
1676 
1677  Simple Controls Functions
1678 
1679 ===================================================================*/
1680 
1694  int DLLEXPORT EN_addcontrol(EN_Project ph, int type, int linkIndex,
1695  double setting, int nodeIndex, double level, int *out_index);
1696 
1703  int DLLEXPORT EN_deletecontrol(EN_Project ph, int index);
1704 
1718  int DLLEXPORT EN_getcontrol(EN_Project ph, int index, int *out_type, int *out_linkIndex,
1719  double *out_setting, int *out_nodeIndex, double *out_level);
1720 
1734  int DLLEXPORT EN_setcontrol(EN_Project ph, int index, int type, int linkIndex,
1735  double setting, int nodeIndex, double level);
1736 
1744  int DLLEXPORT EN_getcontrolenabled(EN_Project ph, int index, int *out_enabled);
1745 
1753  int DLLEXPORT EN_setcontrolenabled(EN_Project ph, int index, int enabled);
1754 
1755 /*===================================================================
1756 
1757  Rule-Based Controls Functions
1758 
1759 ===================================================================*/
1760 
1770  int DLLEXPORT EN_addrule(EN_Project ph, char *rule);
1771 
1778  int DLLEXPORT EN_deleterule(EN_Project ph, int index);
1779 
1790  int DLLEXPORT EN_getrule(EN_Project ph, int index, int *out_nPremises,
1791  int *out_nThenActions, int *out_nElseActions, double *out_priority);
1792 
1802  int DLLEXPORT EN_getruleID(EN_Project ph, int index, char *out_id);
1803 
1820  int DLLEXPORT EN_getpremise(EN_Project ph, int ruleIndex, int premiseIndex,
1821  int *out_logop, int *out_object, int *out_objIndex, int *out_variable,
1822  int *out_relop, int *out_status, double *out_value);
1823 
1839  int DLLEXPORT EN_setpremise(EN_Project ph, int ruleIndex, int premiseIndex,
1840  int logop, int object, int objIndex, int variable, int relop,
1841  int status, double value);
1842 
1851  int DLLEXPORT EN_setpremiseindex(EN_Project ph, int ruleIndex, int premiseIndex,
1852  int objIndex);
1853 
1863  int DLLEXPORT EN_setpremisestatus(EN_Project ph, int ruleIndex, int premiseIndex,
1864  int status);
1865 
1874  int DLLEXPORT EN_setpremisevalue(EN_Project ph, int ruleIndex, int premiseIndex,
1875  double value);
1876 
1887  int DLLEXPORT EN_getthenaction(EN_Project ph, int ruleIndex, int actionIndex,
1888  int *out_linkIndex, int *out_status, double *out_setting);
1889 
1900  int DLLEXPORT EN_setthenaction(EN_Project ph, int ruleIndex, int actionIndex,
1901  int linkIndex, int status, double setting);
1902 
1913  int DLLEXPORT EN_getelseaction(EN_Project ph, int ruleIndex, int actionIndex,
1914  int *out_linkIndex, int *out_status, double *out_setting);
1915 
1926  int DLLEXPORT EN_setelseaction(EN_Project ph, int ruleIndex, int actionIndex,
1927  int linkIndex, int status, double setting);
1928 
1936  int DLLEXPORT EN_setrulepriority(EN_Project ph, int index, double priority);
1937 
1945  int DLLEXPORT EN_getruleenabled(EN_Project ph, int index, int *out_enabled);
1946 
1954  int DLLEXPORT EN_setruleenabled(EN_Project ph, int index, int enabled);
1955 
1956 #if defined(__cplusplus)
1957 }
1958 #endif
1959 
1960 #endif //EPANET2_2_H
int DLLEXPORT EN_getcount(EN_Project ph, int object, int *out_count)
Retrieves the number of objects of a given type in a project.
Definition: epanet.c:291
int DLLEXPORT EN_closeQ(EN_Project ph)
Closes the water quality solver, freeing all of its allocated memory.
Definition: epanet.c:829
int DLLEXPORT EN_clearreport(EN_Project ph)
Clears the contents of a project's report file.
Definition: epanet.c:929
int DLLEXPORT EN_getdemandname(EN_Project ph, int nodeIndex, int demandIndex, char *out_demandName)
Retrieves the name of a node's demand category.
Definition: epanet.c:3197
int DLLEXPORT EN_getaveragepatternvalue(EN_Project ph, int index, double *out_value)
Retrieves the average of all pattern factors in a time pattern.
Definition: epanet.c:4840
int DLLEXPORT EN_setoption(EN_Project ph, int option, double value)
Sets the value for an analysis option.
Definition: epanet.c:1248
int DLLEXPORT 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.
Definition: epanet.c:5859
int DLLEXPORT EN_setnodeid(EN_Project ph, int index, const char *newid)
Changes the ID name of a node.
Definition: epanet.c:2182
int DLLEXPORT EN_setqualtype(EN_Project ph, int qualType, const char *chemName, const char *chemUnits, const char *traceNode)
Sets the type of water quality analysis to run.
Definition: epanet.c:1817
int DLLEXPORT EN_getcomment(EN_Project ph, int object, int index, char *out_comment)
Retrieves a descriptive comment assigned to a Node, Link, Pattern or Curve.
Definition: epanet.c:238
int DLLEXPORT EN_addcurve(EN_Project ph, const char *id)
Adds a new data curve to a project.
Definition: epanet.c:4903
int DLLEXPORT EN_setcontrolenabled(EN_Project ph, int index, int enabled)
Sets the enabled status of a simple control.
Definition: epanet.c:5461
int DLLEXPORT EN_gettitle(EN_Project ph, char *out_line1, char *out_line2, char *out_line3)
Retrieves the title lines of the project.
Definition: epanet.c:206
int DLLEXPORT EN_nextQ(EN_Project ph, long *out_tStep)
Advances a water quality simulation over the time until the next hydraulic event. ...
Definition: epanet.c:783
int DLLEXPORT EN_report(EN_Project ph)
Writes simulation results in a tabular format to a project's report file.
Definition: epanet.c:894
int DLLEXPORT EN_setcurvevalue(EN_Project ph, int curveIndex, int pointIndex, double x, double y)
Sets the value of a single data point for a curve.
Definition: epanet.c:5122
int DLLEXPORT EN_usehydfile(EN_Project ph, const char *filename)
Uses a previously saved binary hydraulics file to supply a project's hydraulics.
Definition: epanet.c:633
int DLLEXPORT EN_open(EN_Project ph, const char *inpFile, const char *rptFile, const char *outFile)
Reads an EPANET input file with no errors allowed.
Definition: epanet.c:174
int DLLEXPORT EN_setcurve(EN_Project ph, int index, double *xValues, double *yValues, int nPoints)
assigns a set of data points to a curve.
Definition: epanet.c:5205
int DLLEXPORT EN_adddemand(EN_Project ph, int nodeIndex, double baseDemand, const char *demandPattern, const char *demandName)
appends a new demand to a junction node demands list.
Definition: epanet.c:2989
int DLLEXPORT EN_setrulepriority(EN_Project ph, int index, double priority)
Sets the priority of a rule-based control.
Definition: epanet.c:5887
int DLLEXPORT EN_setjuncdata(EN_Project ph, int index, double elev, double dmnd, const char *dmndpat)
Sets a group of properties for a junction node.
Definition: epanet.c:2768
int DLLEXPORT EN_setpatternid(EN_Project ph, int index, const char *id)
Changes the ID name of a time pattern given its index.
Definition: epanet.c:4759
int DLLEXPORT EN_writeline(EN_Project ph, const char *line)
Writes a line of text to a project's report file.
Definition: epanet.c:880
int DLLEXPORT EN_getqualtype(EN_Project ph, int *out_qualType, int *out_traceNode)
Retrieves the type of water quality analysis to be run.
Definition: epanet.c:1799
int DLLEXPORT EN_setnodevalue(EN_Project ph, int index, int property, double value)
Sets a property value for a node.
Definition: epanet.c:2469
int DLLEXPORT EN_getnodevalues(EN_Project ph, int property, double *out_values)
Retrieves an array of property values for all nodes.
Definition: epanet.c:2450
int DLLEXPORT EN_setruleenabled(EN_Project ph, int index, int enabled)
Sets the enabled status of a rule-based control.
Definition: epanet.c:5920
int DLLEXPORT EN_getnumdemands(EN_Project ph, int nodeIndex, int *out_numDemands)
Retrieves the number of demand categories for a junction node.
Definition: epanet.c:3121
struct Project * EN_Project
The EPANET Project wrapper object.
Definition: epanet2_2.h:49
int DLLEXPORT EN_getpatternvalue(EN_Project ph, int index, int period, double *out_value)
Retrieves a time pattern's factor for a given time period.
Definition: epanet.c:4799
int DLLEXPORT EN_getnodevalue(EN_Project ph, int index, int property, double *out_value)
Retrieves a property value for a node.
Definition: epanet.c:2232
int DLLEXPORT EN_stepQ(EN_Project ph, long *out_timeLeft)
Advances a water quality simulation by a single water quality time step.
Definition: epanet.c:806
int DLLEXPORT EN_getcurveindex(EN_Project ph, const char *id, int *out_index)
Retrieves the index of a curve given its ID name.
Definition: epanet.c:4995
int DLLEXPORT EN_savehydfile(EN_Project ph, const char *filename)
Saves a project's temporary hydraulics file to disk.
Definition: epanet.c:605
int DLLEXPORT EN_settimeparam(EN_Project ph, int param, long value)
Sets the value of a time parameter.
Definition: epanet.c:1627
int DLLEXPORT EN_deletepattern(EN_Project ph, int index)
Deletes a time pattern from a project.
Definition: epanet.c:4674
int DLLEXPORT EN_setflowunits(EN_Project ph, int units)
Sets a project's flow units.
Definition: epanet.c:1462
int DLLEXPORT EN_settag(EN_Project ph, int object, int index, const char *tag)
Assigns a tag string to a Node or Link.
Definition: epanet.c:278
int DLLEXPORT EN_getbasedemand(EN_Project ph, int nodeIndex, int demandIndex, double *out_baseDemand)
Gets the base demand for one of a node's demand categories.
Definition: epanet.c:3143
int DLLEXPORT EN_getruleID(EN_Project ph, int index, char *out_id)
Gets the ID name of a rule-based control given its index.
Definition: epanet.c:5607
int DLLEXPORT EN_timetonextevent(EN_Project ph, int *eventType, long *duration, int *elementIndex)
Gets information about when the next hydraulic time step occurs.
Definition: epanet.c:1716
int DLLEXPORT EN_getnodeid(EN_Project ph, int index, char *out_id)
Gets the ID name of a node given its index.
Definition: epanet.c:2166
int DLLEXPORT EN_setcomment(EN_Project ph, int object, int index, const char *comment)
Assigns a descriptive comment to a Node, Link, Pattern or Curve.
Definition: epanet.c:251
int DLLEXPORT EN_saveH(EN_Project ph)
Transfers a project's hydraulics results from its temporary hydraulics file to its binary output file...
Definition: epanet.c:438
int DLLEXPORT EN_gettag(EN_Project ph, int object, int index, char *out_tag)
Retrieves a tag string assigned to a Node or Link.
Definition: epanet.c:265
int DLLEXPORT EN_getdemandindex(EN_Project ph, int nodeIndex, const char *demandName, int *out_demandIndex)
Retrieves the index of a node's named demand category.
Definition: epanet.c:3077
int DLLEXPORT EN_settankdata(EN_Project ph, int index, double elev, double initlvl, double minlvl, double maxlvl, double diam, double minvol, const char *volcurve)
Sets a group of properties for a tank node.
Definition: epanet.c:2811
int DLLEXPORT EN_setpatternvalue(EN_Project ph, int index, int period, double value)
Sets a time pattern's factor for a given time period.
Definition: epanet.c:4818
int DLLEXPORT EN_getnodeindex(EN_Project ph, const char *id, int *out_index)
Gets the index of a node given its ID name.
Definition: epanet.c:2150
int DLLEXPORT 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.
Definition: epanet.c:5555
int DLLEXPORT EN_addrule(EN_Project ph, char *rule)
Adds a new rule-based control to a project.
Definition: epanet.c:5485
int DLLEXPORT EN_getpatternindex(EN_Project ph, const char *id, int *out_index)
Retrieves the index of a time pattern given its ID name.
Definition: epanet.c:4718
int DLLEXPORT EN_loadpatternfile(EN_Project ph, const char *filename, const char *id)
Loads time patterns from a file into a project under a specific pattern ID.
Definition: epanet.c:4610
int DLLEXPORT EN_getflowunits(EN_Project ph, int *out_units)
Retrieves a project's flow units.
Definition: epanet.c:1447
int DLLEXPORT EN_setreportcallbackuserdata(EN_Project ph, void *userData)
Sets a pointer to a client-side data object.
Definition: epanet.c:866
int DLLEXPORT EN_runproject(EN_Project ph, const char *inpFile, const char *rptFile, const char *outFile, void(*pviewprog)(char *))
Runs a complete EPANET simulation.
Definition: epanet.c:74
int DLLEXPORT EN_deletecurve(EN_Project ph, int index)
Deletes a data curve from a project.
Definition: epanet.c:4959
int DLLEXPORT EN_resetreport(EN_Project ph)
Resets a project's report options to their default values.
Definition: epanet.c:941
int DLLEXPORT EN_openX(EN_Project ph, const char *inpFile, const char *rptFile, const char *outFile)
Reads an EPANET input file with errors allowed.
Definition: epanet.c:190
int DLLEXPORT EN_settitle(EN_Project ph, const char *line1, const char *line2, const char *line3)
Sets the title lines of the project.
Definition: epanet.c:222
int DLLEXPORT EN_getcurvetype(EN_Project ph, int index, int *out_type)
Retrieves a curve's type.
Definition: epanet.c:5067
int DLLEXPORT 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.
Definition: epanet.c:5775
int DLLEXPORT EN_openH(EN_Project ph)
Opens a project's hydraulic solver.
Definition: epanet.c:470
int DLLEXPORT EN_deleteproject(EN_Project ph)
Deletes a currently opened EPANET project.
Definition: epanet.c:54
int DLLEXPORT 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.
Definition: epanet.c:5699
Definition: types.h:899
int DLLEXPORT EN_deleterule(EN_Project ph, int index)
Deletes an existing rule-based control.
Definition: epanet.c:5541
int DLLEXPORT EN_getcurvelen(EN_Project ph, int index, int *out_len)
Retrieves the number of points in a curve.
Definition: epanet.c:5052
int DLLEXPORT EN_closeH(EN_Project ph)
Closes the hydraulic solver freeing all of its allocated memory.
Definition: epanet.c:586
int DLLEXPORT EN_getoption(EN_Project ph, int option, double *out_value)
Retrieves the value of an analysis option.
Definition: epanet.c:1141
int DLLEXPORT EN_initH(EN_Project ph, int initFlag)
Initializes a network prior to running a hydraulic analysis.
Definition: epanet.c:500
int DLLEXPORT EN_createproject(EN_Project *ph)
Creates an EPANET project.
Definition: epanet.c:36
int DLLEXPORT EN_geterror(int errcode, char *out_errmsg, int maxLen)
Returns the text of an error message generated by an error code.
Definition: epanet.c:1020
int DLLEXPORT EN_close(EN_Project ph)
Closes a project and frees all of its memory.
Definition: epanet.c:346
int DLLEXPORT EN_setreportcallback(EN_Project ph, void(*callback)(void *userData, void *EN_projectHandle, const char *))
Sets a user-supplied callback function for reporting.
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)
Sets the properties of a premise in a rule-based control.
Definition: epanet.c:5661
int DLLEXPORT 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.
Definition: epanet.c:5831
int DLLEXPORT 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.
Definition: epanet.c:1762
int DLLEXPORT EN_getruleenabled(EN_Project ph, int index, int *out_enabled)
Gets the enabled status of a rule-based control.
Definition: epanet.c:5903
int DLLEXPORT EN_deletecontrol(EN_Project ph, int index)
Deletes an existing simple control.
Definition: epanet.c:5297
int DLLEXPORT EN_deletenode(EN_Project ph, int index, int actionCode)
Deletes a node from a project.
Definition: epanet.c:2034
int DLLEXPORT EN_gettimeparam(EN_Project ph, int param, long *out_value)
Retrieves the value of a time parameter.
Definition: epanet.c:1552
int DLLEXPORT EN_getstatistic(EN_Project ph, int type, double *out_value)
Retrieves a particular simulation statistic.
Definition: epanet.c:1066
int DLLEXPORT EN_setdemandmodel(EN_Project ph, int type, double pmin, double preq, double pexp)
Sets the type of demand model to use and its parameters.
Definition: epanet.c:2962
int DLLEXPORT 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.
Definition: epanet.c:5100
int DLLEXPORT EN_solveH(EN_Project ph)
Runs a complete hydraulic simulation with results for all time periods written to a temporary hydraul...
Definition: epanet.c:397
int DLLEXPORT EN_saveinpfile(EN_Project ph, const char *filename)
Saves a project's data to an EPANET-formatted text file.
Definition: epanet.c:333
int DLLEXPORT EN_addnode(EN_Project ph, const char *id, int nodeType, int *out_index)
Adds a new node to a project.
Definition: epanet.c:1896
int DLLEXPORT EN_nextH(EN_Project ph, long *out_tStep)
Determines the length of time until the next hydraulic event occurs in an extended period simulation...
Definition: epanet.c:567
int DLLEXPORT EN_setpattern(EN_Project ph, int index, double *values, int len)
Sets the pattern factors for a given time pattern.
Definition: epanet.c:4865
int DLLEXPORT EN_setstatusreport(EN_Project ph, int level)
Sets the level of hydraulic status reporting.
Definition: epanet.c:984
int DLLEXPORT EN_getpatternlen(EN_Project ph, int index, int *out_len)
Retrieves the number of time periods in a time pattern.
Definition: epanet.c:4784
int DLLEXPORT 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.
Definition: epanet.c:5250
int DLLEXPORT EN_addlink(EN_Project ph, const char *id, int linkType, const char *fromNode, const char *toNode, int *out_index)
Adds a new link to a project.
Definition: epanet.c:3316
int DLLEXPORT EN_getpatternid(EN_Project ph, int index, char *out_id)
Retrieves the ID name of a time pattern given its index.
Definition: epanet.c:4743
int DLLEXPORT 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.
Definition: epanet.c:5401
int DLLEXPORT 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.
Definition: epanet.c:2942
int DLLEXPORT 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.
Definition: epanet.c:3252
int DLLEXPORT 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.
Definition: epanet.c:5623
int DLLEXPORT EN_deletedemand(EN_Project ph, int nodeIndex, int demandIndex)
deletes a demand from a junction node.
Definition: epanet.c:3021
int DLLEXPORT EN_getversion(int *out_version)
Retrieves the toolkit API version number.
Definition: epanet.c:1003
int DLLEXPORT EN_copyreport(EN_Project ph, const char *filename)
Copies the current contents of a project's report file to another file.
Definition: epanet.c:916
int DLLEXPORT EN_solveQ(EN_Project ph)
Runs a complete water quality simulation with results at uniform reporting intervals written to the p...
Definition: epanet.c:671
int DLLEXPORT EN_setbasedemand(EN_Project ph, int nodeIndex, int demandIndex, double baseDemand)
Sets the base demand for one of a node's demand categories.
Definition: epanet.c:3170
int DLLEXPORT 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.
Definition: epanet.c:1108
int DLLEXPORT 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.
Definition: epanet.c:5172
int DLLEXPORT EN_getcoord(EN_Project ph, int index, double *out_x, double *out_y)
Gets the (x,y) coordinates of a node.
Definition: epanet.c:2888
int DLLEXPORT EN_openQ(EN_Project ph)
Opens a project's water quality solver.
Definition: epanet.c:716
int DLLEXPORT EN_getcurveid(EN_Project ph, int index, char *out_id)
Retrieves the ID name of a curve given its index.
Definition: epanet.c:5011
int DLLEXPORT EN_getcontrolenabled(EN_Project ph, int index, int *out_enabled)
Gets the enabled status of a simple control.
Definition: epanet.c:5444
int DLLEXPORT EN_runH(EN_Project ph, long *out_currentTime)
Computes a hydraulic solution for the current point in time.
Definition: epanet.c:549
int DLLEXPORT EN_setcurveid(EN_Project ph, int index, const char *id)
Changes the ID name of a data curve given its index.
Definition: epanet.c:5027
int DLLEXPORT EN_initQ(EN_Project ph, int saveFlag)
Initializes a network prior to running a water quality analysis.
Definition: epanet.c:740
int DLLEXPORT EN_addpattern(EN_Project ph, const char *id)
Adds a new time pattern to a project.
Definition: epanet.c:4562
int DLLEXPORT EN_setdemandname(EN_Project ph, int nodeIndex, int demandIdx, const char *demandName)
Assigns a name to a node's demand category.
Definition: epanet.c:3225
int DLLEXPORT 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.
Definition: epanet.c:5724
int DLLEXPORT 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 proj...
Definition: epanet.c:764
int DLLEXPORT EN_setpremisevalue(EN_Project ph, int ruleIndex, int premiseIndex, double value)
Sets the value in a premise of a rule-based control.
Definition: epanet.c:5750
int DLLEXPORT EN_setreport(EN_Project ph, const char *format)
Processes a reporting format command.
Definition: epanet.c:965
int DLLEXPORT EN_getnodetype(EN_Project ph, int index, int *out_nodeType)
Retrieves a node's type given its index.
Definition: epanet.c:2208
int DLLEXPORT 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.
Definition: epanet.c:3280
int DLLEXPORT EN_setcoord(EN_Project ph, int index, double x, double y)
Sets the (x,y) coordinates of a node.
Definition: epanet.c:2914
int DLLEXPORT 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.
Definition: epanet.c:5318
int DLLEXPORT 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.
Definition: epanet.c:5803
int DLLEXPORT EN_setcurvetype(EN_Project ph, int index, int type)
Sets a curve's type.
Definition: epanet.c:5083
int DLLEXPORT EN_init(EN_Project ph, const char *rptFile, const char *outFile, int unitsType, int headLossType)
Initializes an EPANET project.
Definition: epanet.c:119