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: 05/11/2026
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 
226  int DLLEXPORT EN_saveinpfile(EN_Project ph, const char *filename);
227 
237  int DLLEXPORT EN_close(EN_Project ph);
238 
239 /*===================================================================
240 
241  Hydraulic Analysis Functions
242 
243 ===================================================================*/
244 
271  int DLLEXPORT EN_solveH(EN_Project ph);
272 
285  int DLLEXPORT EN_usehydfile(EN_Project ph, const char *filename);
286 
300  int DLLEXPORT EN_openH(EN_Project ph);
301 
328  int DLLEXPORT EN_initH(EN_Project ph, int initFlag);
329 
344  int DLLEXPORT EN_runH(EN_Project ph, long *out_currentTime);
345 
378  int DLLEXPORT EN_nextH(EN_Project ph, long *out_tStep);
379 
390  int DLLEXPORT EN_saveH(EN_Project ph);
391 
408  int DLLEXPORT EN_savehydfile(EN_Project ph, const char *filename);
409 
417  int DLLEXPORT EN_closeH(EN_Project ph);
418 
419 /*===================================================================
420 
421  Water Quality Analysis Functions
422 
423 ===================================================================*/
424 
442  int DLLEXPORT EN_solveQ(EN_Project ph);
443 
457  int DLLEXPORT EN_openQ(EN_Project ph);
458 
473  int DLLEXPORT EN_initQ(EN_Project ph, int saveFlag);
474 
494  int DLLEXPORT EN_runQ(EN_Project ph, long *out_currentTime);
495 
526  int DLLEXPORT EN_nextQ(EN_Project ph, long *out_tStep);
527 
542  int DLLEXPORT EN_stepQ(EN_Project ph, long *out_timeLeft);
543 
554  int DLLEXPORT EN_closeQ(EN_Project ph);
555 
556 /*===================================================================
557 
558  Reporting Functions
559 
560 ===================================================================*/
561 
580  int DLLEXPORT EN_setreportcallback(EN_Project ph, void(*callback)(void *userData, void *EN_projectHandle, const char*));
581 
592  int DLLEXPORT EN_setreportcallbackuserdata(EN_Project ph, void *userData);
593 
603  int DLLEXPORT EN_writeline(EN_Project ph, const char *line);
604 
617  int DLLEXPORT EN_report(EN_Project ph);
618 
628  int DLLEXPORT EN_copyreport(EN_Project ph, const char *filename);
629 
635  int DLLEXPORT EN_clearreport(EN_Project ph);
636 
652  int DLLEXPORT EN_resetreport(EN_Project ph);
653 
666  int DLLEXPORT EN_setreport(EN_Project ph, const char *format);
667 
686  int DLLEXPORT EN_setstatusreport(EN_Project ph, int level);
687 
696  int DLLEXPORT EN_getversion(int *out_version);
697 
707  int DLLEXPORT EN_geterror(int errcode, char *out_errmsg, int maxLen);
708 
716  int DLLEXPORT EN_getstatistic(EN_Project ph, int type, double* out_value);
717 
718 
726  int DLLEXPORT EN_timetonextevent(EN_Project ph, int *eventType, long *duration, int *elementIndex);
727 
742  int DLLEXPORT EN_getresultindex(EN_Project ph, int type, int index, int *out_value);
743 
744 /*===================================================================
745 
746  Analysis Options Functions
747 
748 ===================================================================*/
749 
757  int DLLEXPORT EN_getoption(EN_Project ph, int option, double *out_value);
758 
767  int DLLEXPORT EN_setoption(EN_Project ph, int option, double value);
768 
778  int DLLEXPORT EN_getflowunits(EN_Project ph, int *out_units);
779 
789  int DLLEXPORT EN_setflowunits(EN_Project ph, int units);
790 
798  int DLLEXPORT EN_gettimeparam(EN_Project ph, int param, long *out_value);
799 
807  int DLLEXPORT EN_settimeparam(EN_Project ph, int param, long value);
808 
818  int DLLEXPORT EN_getqualinfo(EN_Project ph, int *out_qualType, char *out_chemName,
819  char *out_chemUnits, int *out_traceNode);
820 
828  int DLLEXPORT EN_getqualtype(EN_Project ph, int *out_qualType, int *out_traceNode);
829 
844  int DLLEXPORT EN_setqualtype(EN_Project ph, int qualType, const char *chemName,
845  const char *chemUnits, const char *traceNode);
846 
847 /*===================================================================
848 
849  Node Functions
850 
851 ===================================================================*/
852 
863  int DLLEXPORT EN_addnode(EN_Project ph, const char *id, int nodeType, int *out_index);
864 
878  int DLLEXPORT EN_deletenode(EN_Project ph, int index, int actionCode);
879 
887  int DLLEXPORT EN_getnodeindex(EN_Project ph, const char *id, int *out_index);
888 
898  int DLLEXPORT EN_getnodeid(EN_Project ph, int index, char *out_id);
899 
909  int DLLEXPORT EN_setnodeid(EN_Project ph, int index, const char *newid);
910 
918  int DLLEXPORT EN_getnodetype(EN_Project ph, int index, int *out_nodeType);
919 
932  int DLLEXPORT EN_getnodevalue(EN_Project ph, int index, int property, double *out_value);
933 
945  int DLLEXPORT EN_getnodevalues(EN_Project ph, int property, double *out_values);
946 
957  int DLLEXPORT EN_setnodevalue(EN_Project ph, int index, int property, double value);
958 
969  int DLLEXPORT EN_setnodevalues(EN_Project ph, int property, double *values, int *badIndex);
970 
982  int DLLEXPORT EN_setjuncdata(EN_Project ph, int index, double elev, double dmnd,
983  const char *dmndpat);
984 
1000  int DLLEXPORT EN_settankdata(EN_Project ph, int index, double elev, double initlvl,
1001  double minlvl, double maxlvl, double diam, double minvol, const char *volcurve);
1002 
1011  int DLLEXPORT EN_getcoord(EN_Project ph, int index, double *out_x, double *out_y);
1012 
1021  int DLLEXPORT EN_setcoord(EN_Project ph, int index, double x, double y);
1022 
1023 /*===================================================================
1024 
1025  Nodal Demand Functions
1026 
1027 ===================================================================*/
1028 
1040  int DLLEXPORT EN_getdemandmodel(EN_Project ph, int *out_type, double *out_pmin,
1041  double *out_preq, double *out_pexp);
1042 
1060  int DLLEXPORT EN_setdemandmodel(EN_Project ph, int type, double pmin,
1061  double preq, double pexp);
1062 
1063 
1076  int DLLEXPORT EN_adddemand(EN_Project ph, int nodeIndex, double baseDemand,
1077  const char *demandPattern, const char *demandName);
1078 
1086  int DLLEXPORT EN_deletedemand(EN_Project ph, int nodeIndex, int demandIndex);
1087 
1096  int DLLEXPORT EN_getdemandindex(EN_Project ph, int nodeIndex, const char *demandName,
1097  int *out_demandIndex);
1098 
1106  int DLLEXPORT EN_getnumdemands(EN_Project ph, int nodeIndex, int *out_numDemands);
1107 
1116  int DLLEXPORT EN_getbasedemand(EN_Project ph, int nodeIndex, int demandIndex,
1117  double *out_baseDemand);
1118 
1127  int DLLEXPORT EN_setbasedemand(EN_Project ph, int nodeIndex, int demandIndex,
1128  double baseDemand);
1129 
1141  int DLLEXPORT EN_getdemandpattern(EN_Project ph, int nodeIndex, int demandIndex,
1142  int *out_patIndex);
1143 
1155  int DLLEXPORT EN_setdemandpattern(EN_Project ph, int nodeIndex, int demandIndex, int patIndex);
1156 
1167  int DLLEXPORT EN_getdemandname(EN_Project ph, int nodeIndex, int demandIndex, char *out_demandName);
1168 
1179  int DLLEXPORT EN_setdemandname(EN_Project ph, int nodeIndex, int demandIdx,
1180  const char *demandName);
1181 
1182 /*===================================================================
1183 
1184  Link Functions
1185 
1186 ===================================================================*/
1187 
1213  int DLLEXPORT EN_addlink(EN_Project ph, const char *id, int linkType, const char *fromNode,
1214  const char *toNode, int *out_index);
1215 
1227  int DLLEXPORT EN_deletelink(EN_Project ph, int index, int actionCode);
1228 
1236  int DLLEXPORT EN_getlinkindex(EN_Project ph, const char *id, int *out_index);
1237 
1247  int DLLEXPORT EN_getlinkid(EN_Project ph, int index, char *out_id);
1248 
1258  int DLLEXPORT EN_setlinkid(EN_Project ph, int index, const char *newid);
1259 
1267  int DLLEXPORT EN_getlinktype(EN_Project ph, int index, int *out_linkType);
1268 
1284  int DLLEXPORT EN_setlinktype(EN_Project ph, int *inout_index, int linkType, int actionCode);
1285 
1294  int DLLEXPORT EN_getlinknodes(EN_Project ph, int index, int *out_node1, int *out_node2);
1295 
1304  int DLLEXPORT EN_setlinknodes(EN_Project ph, int index, int node1, int node2);
1305 
1316  int DLLEXPORT EN_getlinkvalue(EN_Project ph, int index, int property, double *out_value);
1317 
1327  int DLLEXPORT EN_getlinkvalues(EN_Project ph, int property, double *out_values);
1328 
1339  int DLLEXPORT EN_setlinkvalue(EN_Project ph, int index, int property, double value);
1340 
1351  int DLLEXPORT EN_setlinkvalues(EN_Project ph, int property, double *values, int *badIndex);
1352 
1365  int DLLEXPORT EN_setpipedata(EN_Project ph, int index, double length, double diam,
1366  double rough, double mloss);
1367 
1375  int DLLEXPORT EN_getvertexcount(EN_Project ph, int index, int *out_count);
1376 
1386  int DLLEXPORT EN_getvertex(EN_Project ph, int index, int vertex, double *out_x, double *out_y);
1387 
1397  int DLLEXPORT EN_setvertex(EN_Project ph, int index, int vertex, double x, double y);
1398 
1410  int DLLEXPORT EN_setvertices(EN_Project ph, int index, double *x, double *y, int count);
1411 
1412 /*===================================================================
1413 
1414  Pump Functions
1415 
1416 ===================================================================*/
1417 
1425  int DLLEXPORT EN_getpumptype(EN_Project ph, int linkIndex, int *out_pumpType);
1426 
1434  int DLLEXPORT EN_getheadcurveindex(EN_Project ph, int linkIndex, int *out_curveIndex);
1435 
1443  int DLLEXPORT EN_setheadcurveindex(EN_Project ph, int linkIndex, int curveIndex);
1444 
1445 /*===================================================================
1446 
1447  Time Pattern Functions
1448 
1449 ===================================================================*/
1450 
1459  int DLLEXPORT EN_addpattern(EN_Project ph, const char *id);
1460 
1467  int DLLEXPORT EN_deletepattern(EN_Project ph, int index);
1468 
1476  int DLLEXPORT EN_getpatternindex(EN_Project ph, const char *id, int *out_index);
1477 
1487  int DLLEXPORT EN_getpatternid(EN_Project ph, int index, char *out_id);
1488 
1498  int DLLEXPORT EN_setpatternid(EN_Project ph, int index, const char *id);
1499 
1507  int DLLEXPORT EN_getpatternlen(EN_Project ph, int index, int *out_len);
1508 
1517  int DLLEXPORT EN_getpatternvalue(EN_Project ph, int index, int period, double *out_value);
1518 
1527  int DLLEXPORT EN_setpatternvalue(EN_Project ph, int index, int period, double value);
1528 
1536  int DLLEXPORT EN_getaveragepatternvalue(EN_Project ph, int index, double *out_value);
1537 
1551  int DLLEXPORT EN_setpattern(EN_Project ph, int index, double *values, int len);
1552 
1560  int DLLEXPORT EN_loadpatternfile(EN_Project ph, const char *filename, const char *id);
1561 
1562 /*===================================================================
1563 
1564  Data Curve Functions
1565 
1566 ===================================================================*/
1567 
1576  int DLLEXPORT EN_addcurve(EN_Project ph, const char *id);
1577 
1584  int DLLEXPORT EN_deletecurve(EN_Project ph, int index);
1585 
1593  int DLLEXPORT EN_getcurveindex(EN_Project ph, const char *id, int *out_index);
1594 
1604  int DLLEXPORT EN_getcurveid(EN_Project ph, int index, char *out_id);
1605 
1615  int DLLEXPORT EN_setcurveid(EN_Project ph, int index, const char *id);
1616 
1624  int DLLEXPORT EN_getcurvelen(EN_Project ph, int index, int *out_len);
1625 
1633  int DLLEXPORT EN_getcurvetype(EN_Project ph, int index, int *out_type);
1634 
1642  int DLLEXPORT EN_setcurvetype(EN_Project ph, int index, int type);
1643 
1653  int DLLEXPORT EN_getcurvevalue(EN_Project ph, int curveIndex, int pointIndex,
1654  double *out_x, double *out_y);
1655 
1665  int DLLEXPORT EN_setcurvevalue(EN_Project ph, int curveIndex, int pointIndex,
1666  double x, double y);
1667 
1682  int DLLEXPORT EN_getcurve(EN_Project ph, int index, char *out_id, int *out_nPoints,
1683  double *out_xValues, double *out_yValues);
1684 
1699  int DLLEXPORT EN_setcurve(EN_Project ph, int index, double *xValues,
1700  double *yValues, int nPoints);
1701 
1702 /*===================================================================
1703 
1704  Simple Controls Functions
1705 
1706 ===================================================================*/
1707 
1721  int DLLEXPORT EN_addcontrol(EN_Project ph, int type, int linkIndex,
1722  double setting, int nodeIndex, double level, int *out_index);
1723 
1730  int DLLEXPORT EN_deletecontrol(EN_Project ph, int index);
1731 
1745  int DLLEXPORT EN_getcontrol(EN_Project ph, int index, int *out_type, int *out_linkIndex,
1746  double *out_setting, int *out_nodeIndex, double *out_level);
1747 
1761  int DLLEXPORT EN_setcontrol(EN_Project ph, int index, int type, int linkIndex,
1762  double setting, int nodeIndex, double level);
1763 
1771  int DLLEXPORT EN_getcontrolenabled(EN_Project ph, int index, int *out_enabled);
1772 
1780  int DLLEXPORT EN_setcontrolenabled(EN_Project ph, int index, int enabled);
1781 
1782 /*===================================================================
1783 
1784  Rule-Based Controls Functions
1785 
1786 ===================================================================*/
1787 
1797  int DLLEXPORT EN_addrule(EN_Project ph, char *rule);
1798 
1805  int DLLEXPORT EN_deleterule(EN_Project ph, int index);
1806 
1817  int DLLEXPORT EN_getrule(EN_Project ph, int index, int *out_nPremises,
1818  int *out_nThenActions, int *out_nElseActions, double *out_priority);
1819 
1829  int DLLEXPORT EN_getruleID(EN_Project ph, int index, char *out_id);
1830 
1847  int DLLEXPORT EN_getpremise(EN_Project ph, int ruleIndex, int premiseIndex,
1848  int *out_logop, int *out_object, int *out_objIndex, int *out_variable,
1849  int *out_relop, int *out_status, double *out_value);
1850 
1866  int DLLEXPORT EN_setpremise(EN_Project ph, int ruleIndex, int premiseIndex,
1867  int logop, int object, int objIndex, int variable, int relop,
1868  int status, double value);
1869 
1878  int DLLEXPORT EN_setpremiseindex(EN_Project ph, int ruleIndex, int premiseIndex,
1879  int objIndex);
1880 
1890  int DLLEXPORT EN_setpremisestatus(EN_Project ph, int ruleIndex, int premiseIndex,
1891  int status);
1892 
1901  int DLLEXPORT EN_setpremisevalue(EN_Project ph, int ruleIndex, int premiseIndex,
1902  double value);
1903 
1914  int DLLEXPORT EN_getthenaction(EN_Project ph, int ruleIndex, int actionIndex,
1915  int *out_linkIndex, int *out_status, double *out_setting);
1916 
1927  int DLLEXPORT EN_setthenaction(EN_Project ph, int ruleIndex, int actionIndex,
1928  int linkIndex, int status, double setting);
1929 
1940  int DLLEXPORT EN_getelseaction(EN_Project ph, int ruleIndex, int actionIndex,
1941  int *out_linkIndex, int *out_status, double *out_setting);
1942 
1953  int DLLEXPORT EN_setelseaction(EN_Project ph, int ruleIndex, int actionIndex,
1954  int linkIndex, int status, double setting);
1955 
1963  int DLLEXPORT EN_setrulepriority(EN_Project ph, int index, double priority);
1964 
1972  int DLLEXPORT EN_getruleenabled(EN_Project ph, int index, int *out_enabled);
1973 
1981  int DLLEXPORT EN_setruleenabled(EN_Project ph, int index, int enabled);
1982 
1983 #if defined(__cplusplus)
1984 }
1985 #endif
1986 
1987 #endif //EPANET2_2_H
int DLLEXPORT EN_setnodevalues(EN_Project ph, int property, double *values, int *badIndex)
Sets property values for all nodes.
Definition: epanet.c:2766
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:296
int DLLEXPORT EN_closeQ(EN_Project ph)
Closes the water quality solver, freeing all of its allocated memory.
Definition: epanet.c:834
int DLLEXPORT EN_clearreport(EN_Project ph)
Clears the contents of a project's report file.
Definition: epanet.c:934
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:3244
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:4940
int DLLEXPORT EN_setoption(EN_Project ph, int option, double value)
Sets the value for an analysis option.
Definition: epanet.c:1253
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:5959
int DLLEXPORT EN_setnodeid(EN_Project ph, int index, const char *newid)
Changes the ID name of a node.
Definition: epanet.c:2180
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:1815
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:243
int DLLEXPORT EN_addcurve(EN_Project ph, const char *id)
Adds a new data curve to a project.
Definition: epanet.c:5003
int DLLEXPORT EN_setcontrolenabled(EN_Project ph, int index, int enabled)
Sets the enabled status of a simple control.
Definition: epanet.c:5561
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:211
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:788
int DLLEXPORT EN_report(EN_Project ph)
Writes simulation results in a tabular format to a project's report file.
Definition: epanet.c:899
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:5222
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:638
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:179
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:5305
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:3036
int DLLEXPORT EN_setrulepriority(EN_Project ph, int index, double priority)
Sets the priority of a rule-based control.
Definition: epanet.c:5987
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:2815
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:4859
int DLLEXPORT EN_writeline(EN_Project ph, const char *line)
Writes a line of text to a project's report file.
Definition: epanet.c:885
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:1797
int DLLEXPORT EN_setnodevalue(EN_Project ph, int index, int property, double value)
Sets a property value for a node.
Definition: epanet.c:2467
int DLLEXPORT EN_getnodevalues(EN_Project ph, int property, double *out_values)
Retrieves an array of property values for all nodes.
Definition: epanet.c:2448
int DLLEXPORT EN_setruleenabled(EN_Project ph, int index, int enabled)
Sets the enabled status of a rule-based control.
Definition: epanet.c:6020
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:3168
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:4899
int DLLEXPORT EN_getnodevalue(EN_Project ph, int index, int property, double *out_value)
Retrieves a property value for a node.
Definition: epanet.c:2230
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:811
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:5095
int DLLEXPORT EN_savehydfile(EN_Project ph, const char *filename)
Saves a project's temporary hydraulics file to disk.
Definition: epanet.c:610
int DLLEXPORT EN_settimeparam(EN_Project ph, int param, long value)
Sets the value of a time parameter.
Definition: epanet.c:1625
int DLLEXPORT EN_deletepattern(EN_Project ph, int index)
Deletes a time pattern from a project.
Definition: epanet.c:4774
int DLLEXPORT EN_setflowunits(EN_Project ph, int units)
Sets a project's flow units.
Definition: epanet.c:1467
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:283
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:3190
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:5707
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:1714
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:2164
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:256
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:443
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:270
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:3124
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:2858
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:4918
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:2148
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:5655
int DLLEXPORT EN_addrule(EN_Project ph, char *rule)
Adds a new rule-based control to a project.
Definition: epanet.c:5585
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:4818
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:4710
int DLLEXPORT EN_getflowunits(EN_Project ph, int *out_units)
Retrieves a project's flow units.
Definition: epanet.c:1452
int DLLEXPORT EN_setreportcallbackuserdata(EN_Project ph, void *userData)
Sets a pointer to a client-side data object.
Definition: epanet.c:871
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:79
int DLLEXPORT EN_deletecurve(EN_Project ph, int index)
Deletes a data curve from a project.
Definition: epanet.c:5059
int DLLEXPORT EN_resetreport(EN_Project ph)
Resets a project's report options to their default values.
Definition: epanet.c:946
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:195
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:227
int DLLEXPORT EN_getcurvetype(EN_Project ph, int index, int *out_type)
Retrieves a curve's type.
Definition: epanet.c:5167
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:5875
int DLLEXPORT EN_openH(EN_Project ph)
Opens a project's hydraulic solver.
Definition: epanet.c:475
int DLLEXPORT EN_deleteproject(EN_Project ph)
Deletes a currently opened EPANET project.
Definition: epanet.c:59
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:5799
Definition: types.h:899
int DLLEXPORT EN_deleterule(EN_Project ph, int index)
Deletes an existing rule-based control.
Definition: epanet.c:5641
int DLLEXPORT EN_getcurvelen(EN_Project ph, int index, int *out_len)
Retrieves the number of points in a curve.
Definition: epanet.c:5152
int DLLEXPORT EN_closeH(EN_Project ph)
Closes the hydraulic solver freeing all of its allocated memory.
Definition: epanet.c:591
int DLLEXPORT EN_getoption(EN_Project ph, int option, double *out_value)
Retrieves the value of an analysis option.
Definition: epanet.c:1146
int DLLEXPORT EN_initH(EN_Project ph, int initFlag)
Initializes a network prior to running a hydraulic analysis.
Definition: epanet.c:505
int DLLEXPORT EN_createproject(EN_Project *ph)
Creates an EPANET project.
Definition: epanet.c:37
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:1025
int DLLEXPORT EN_close(EN_Project ph)
Closes a project and frees all of its memory.
Definition: epanet.c:351
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:5761
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:5931
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:1760
int DLLEXPORT EN_getruleenabled(EN_Project ph, int index, int *out_enabled)
Gets the enabled status of a rule-based control.
Definition: epanet.c:6003
int DLLEXPORT EN_deletecontrol(EN_Project ph, int index)
Deletes an existing simple control.
Definition: epanet.c:5397
int DLLEXPORT EN_deletenode(EN_Project ph, int index, int actionCode)
Deletes a node from a project.
Definition: epanet.c:2032
int DLLEXPORT EN_gettimeparam(EN_Project ph, int param, long *out_value)
Retrieves the value of a time parameter.
Definition: epanet.c:1550
int DLLEXPORT EN_getstatistic(EN_Project ph, int type, double *out_value)
Retrieves a particular simulation statistic.
Definition: epanet.c:1071
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:3009
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:5200
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:402
int DLLEXPORT EN_saveinpfile(EN_Project ph, const char *filename)
Saves a project's data to an EPANET-formatted text file.
Definition: epanet.c:338
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:1894
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:572
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:4965
int DLLEXPORT EN_setstatusreport(EN_Project ph, int level)
Sets the level of hydraulic status reporting.
Definition: epanet.c:989
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:4884
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:5350
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:3363
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:4843
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:5501
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:2989
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:3299
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:5723
int DLLEXPORT EN_deletedemand(EN_Project ph, int nodeIndex, int demandIndex)
deletes a demand from a junction node.
Definition: epanet.c:3068
int DLLEXPORT EN_getversion(int *out_version)
Retrieves the toolkit API version number.
Definition: epanet.c:1008
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:921
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:676
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:3217
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:1113
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:5272
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:2935
int DLLEXPORT EN_openQ(EN_Project ph)
Opens a project's water quality solver.
Definition: epanet.c:721
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:5111
int DLLEXPORT EN_getcontrolenabled(EN_Project ph, int index, int *out_enabled)
Gets the enabled status of a simple control.
Definition: epanet.c:5544
int DLLEXPORT EN_runH(EN_Project ph, long *out_currentTime)
Computes a hydraulic solution for the current point in time.
Definition: epanet.c:554
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:5127
int DLLEXPORT EN_initQ(EN_Project ph, int saveFlag)
Initializes a network prior to running a water quality analysis.
Definition: epanet.c:745
int DLLEXPORT EN_setlinkvalues(EN_Project ph, int property, double *values, int *badIndex)
Sets property values for all links.
Definition: epanet.c:4361
int DLLEXPORT EN_addpattern(EN_Project ph, const char *id)
Adds a new time pattern to a project.
Definition: epanet.c:4662
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:3272
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:5824
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:769
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:5850
int DLLEXPORT EN_setreport(EN_Project ph, const char *format)
Processes a reporting format command.
Definition: epanet.c:970
int DLLEXPORT EN_getnodetype(EN_Project ph, int index, int *out_nodeType)
Retrieves a node's type given its index.
Definition: epanet.c:2206
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:3327
int DLLEXPORT EN_setcoord(EN_Project ph, int index, double x, double y)
Sets the (x,y) coordinates of a node.
Definition: epanet.c:2961
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:5418
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:5903
int DLLEXPORT EN_setcurvetype(EN_Project ph, int index, int type)
Sets a curve's type.
Definition: epanet.c:5183
int DLLEXPORT EN_init(EN_Project ph, const char *rptFile, const char *outFile, int unitsType, int headLossType)
Initializes an EPANET project.
Definition: epanet.c:124