lixiaojun
2024-11-21 3e59a097e89632a53554f369eb55ece5fdda3eda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
/** @file epanet2_2.h
 @see http://github.com/openwateranalytics/epanet
 */
 
/*
 ******************************************************************************
 Project:      OWA HYDRAULIC
 Version:      2.2
 Module:       epanet2.h
 Description:  API function declarations
 Authors:      see AUTHORS
 Copyright:    see AUTHORS
 License:      see LICENSE
 Last Updated: 10/29/2019
 ******************************************************************************
 */
 
#ifndef EPANET2_2_H
#define EPANET2_2_H
 
#ifdef epanet_py_EXPORTS
  #define DLLEXPORT
#else
  #ifndef DLLEXPORT
    #ifdef _WIN32
      #ifdef epanet2_EXPORTS
        #define DLLEXPORT __declspec(dllexport) __stdcall
      #else
        #define DLLEXPORT __declspec(dllimport) __stdcall
      #endif
    #elif defined(__CYGWIN__)
      #define DLLEXPORT __stdcall
    #else
      #define DLLEXPORT
    #endif
  #endif
#endif
 
#include "epanet2_enums.h"
 
// --- Declare the HYDRAULIC toolkit functions
#if defined(__cplusplus)
extern "C" {
#endif
 
/**
 @brief The HYDRAULIC Project wrapper object
*/
typedef struct Project *EN_Project;
 
    
 
/********************************************************************
 
    Project Functions
 
********************************************************************/
 
  /**
  @brief Creates an HYDRAULIC project.
  @param[out] ph an HYDRAULIC project handle that is passed into all other API functions.
  @return an error code.
 
  EN_createproject must be called before any other API functions are used.
  */
  int DLLEXPORT EN_createproject(EN_Project *ph);
 
  /**
  @brief Deletes a currently opened HYDRAULIC project.
  @param[in,out] ph an HYDRAULIC project handle which is returned as NULL.
  @return an error code.
 
  EN_deleteproject should be called after all network analysis has been completed.
  */
  int DLLEXPORT EN_deleteproject(EN_Project ph);
 
  /**
  @brief Runs a complete HYDRAULIC simulation.
  @param ph an HYDRAULIC project handle.
  @param inpFile the name of an existing HYDRAULIC-formatted input file.
  @param rptFile the name of a report file to be created (or "" if not needed)
  @param outFile the name of a binary output file to be created (or "" if not needed)
  @param pviewprog a callback function that takes a character string (char *) as its only parameter.
  @return an error code
 
  The callback function should reside in and be used by the calling code to display
  the progress messages that HYDRAULIC generates as it carries out its computations. Here is
  an example of a such a function that displays progress messages to stdout:
  \code {.c}
  void  writeConsole(char *s)
  {
      fprintf(stdout, "\n%s", s);
  }
 \endcode
  It would be passed into EN_runproject as `&writeConsole`. If this feature is not needed then
  the pviewprog argument should be `NULL`.
  */
  int DLLEXPORT EN_runproject(EN_Project ph, const char *inpFile, const char *rptFile,
                const char *outFile, void (*pviewprog)(char *));
 
 
 
 
 
 
  /**
  @brief Initializes an HYDRAULIC project.
  @param ph an HYDRAULIC project handle.
  @param rptFile the name of a report file to be created (or "" if not needed).
  @param outFile the name of a binary output file to be created (or "" if not needed).
  @param unitsType the choice of flow units (see @ref EN_FlowUnits).
  @param headLossType the choice of head loss formula (see @ref EN_HeadLossType).
  @return an error code.
 
  This function should be called immediately after ::EN_createproject if an HYDRAULIC-formatted input
  file will not be used to supply network data. If the project receives it's network data
  from an input file then there is no need to call this function.
  */
  int DLLEXPORT EN_init(EN_Project ph, const char *rptFile, const char *outFile,
                int unitsType, int headLossType);
 
  /**
  @brief Opens an HYDRAULIC input file & reads in network data.
  @param ph an HYDRAULIC project handle.
  @param inpFile the name of an existing HYDRAULIC-formatted input file.
  @param rptFile the name of a report file to be created (or "" if not needed).
  @param outFile the name of a binary output file to be created (or "" if not needed).
  @return an error code.
 
  This function should be called immediately after ::EN_createproject if an HYDRAULIC-formatted
  input file will be used to supply network data.
  */
  int DLLEXPORT EN_open(EN_Project ph, const char *inpFile, const char *rptFile,
                const char *outFile);
 
  /**
  @brief Retrieves the title lines of the project
  @param ph an HYDRAULIC project handle.
  @param[out] out_line1 first title line
  @param[out] out_line2 second title line
  @param[out] out_line3 third title line
  @return an error code
  */
  int  DLLEXPORT EN_gettitle(EN_Project ph, char *out_line1, char *out_line2, char *out_line3);
 
  /**
  @brief Sets the title lines of the project
  @param ph an HYDRAULIC project handle.
  @param line1 first title line
  @param line2 second title line
  @param line3 third title line
  @return an error code
  */
  int  DLLEXPORT EN_settitle(EN_Project ph, char *line1, char *line2, char *line3);
 
 /**
 @brief Sets the project report Or Not     [CloudflightÐÞ¶©-ÐÂÔö] 2023Äê3ÔÂ13ÈÕ 21:41:44
 @param ph an HYDRAULIC project handle.
 @param line1 first title line
 @param line2 second title line
 @param line3 third title line
 @return an error code
 */
  int DLLEXPORT  EN_setprojectreport(EN_Project p, int report);
 
 
  /**
  @brief Retrieves a descriptive comment assigned to a Node, Link, Pattern or Curve.
  @param ph an HYDRAULIC project handle.
  @param object a type of object (either EN_NODE, EN_LINK, EN_TIMEPAT or EN_CURVE)
  @param index the object's index starting from 1
  @param[out] out_comment the comment string assigned to the object
  @return an error code
  */
  int  DLLEXPORT EN_getcomment(EN_Project ph, int object, int index, char *out_comment);
 
  /**
  @brief Assigns a descriptive comment to a Node, Link, Pattern or Curve.
  @param ph an HYDRAULIC project handle.
  @param object a type of object (either EN_NODE, EN_LINK, EN_TIMEPAT or EN_CURVE)
  @param index the object's index starting from 1
  @param[out] comment the comment string assigned to the object
  @return an error code
  */
  int  DLLEXPORT EN_setcomment(EN_Project ph, int object, int index, char *comment);
 
  /**
  @brief Retrieves the number of objects of a given type in a project.
  @param ph an HYDRAULIC project handle.
  @param object a type of object to count (see @ref EN_CountType)
  @param[out] count number of objects of the specified type
  @return an error code
  */
  int  DLLEXPORT EN_getcount(EN_Project ph, int object, int *count);
 
  /**
  @brief Saves a project's data to an HYDRAULIC-formatted text file.
  @param ph an HYDRAULIC project handle.
  @param filename the name of the file to create.
  @return Error code
  */
  int DLLEXPORT EN_saveinpfile(EN_Project ph, const char *filename);
 
  /**
  @brief Closes a project and frees all of its memory.
  @param ph an HYDRAULIC project handle.
  @return Error code
 
  This function clears all existing data from a project but does not delete the
  project, so it can be re-used with another set of network data. Use ::EN_deleteproject
  to actually delete a project from memory.
  */
  int DLLEXPORT EN_close(EN_Project ph);
 
  /********************************************************************
 
  Hydraulic Analysis Functions
 
  ********************************************************************/
 
  /**
  @brief Runs a complete hydraulic simulation with results for all time periods
  written to a temporary hydraulics file.
  @param ph an HYDRAULIC project handle.
  @return an error code.
 
  Use ::EN_solveH to generate a complete hydraulic solution which can stand alone
  or be used as input to a water quality analysis. This function will not allow one to
  examine intermediate hydraulic results as they are generated. It can also be followed by calls
  to ::EN_saveH and ::EN_report to write hydraulic results to the report file.
 
  The sequence ::EN_openH - ::EN_initH - ::EN_runH - ::EN_nextH - ::EN_closeH
  can be used instead to gain access to results at intermediate time periods and
  directly adjust link status and control settings as a simulation proceeds.
 
 <b>Example:</b>
  \code {.c}
  EN_Project ph;
  EN_createproject(&ph);
  EN_open(ph, "net1.inp", "net1.rpt", "");
  EN_solveH(ph);
  EN_solveQ(ph);
  EN_report(ph);
  EN_deleteproject(ph);
  \endcode
  */
  int DLLEXPORT EN_solveH(EN_Project ph);
 
  /**
  @brief Uses a previously saved binary hydraulics file to supply a project's hydraulics.
  @param ph an HYDRAULIC project handle.
  @param filename the name of the binary file containing hydraulic results.
  @return an error code.
 
  Call this function to re-use a set of hydraulic analysis results saved previously. This
  can save computational time if water quality analyses are being made under the same set
  of hydraulic conditions.
 
  Do not call this function while the hydraulics solver is open.
  */
  int DLLEXPORT EN_usehydfile(EN_Project ph, const char *filename);
 
  /**
  @brief Opens a project's hydraulic solver.
  @param ph an HYDRAULIC project handle.
  @return an error code.
 
  Call ::EN_openH prior to running the first hydraulic analysis using the
  ::EN_initH - ::EN_runH - ::EN_nextH sequence. Multiple analyses can be made before
  calling ::EN_closeH to close the hydraulic solver.
 
  Do not call this function if ::EN_solveH is being used to run a complete hydraulic
  analysis or if hydraulics are being supplied by a previously saved hydraulics file
  using ::EN_usehydfile.
  */
  int DLLEXPORT EN_openH(EN_Project ph);
 
  /**
  @brief Initializes a network prior to running a hydraulic analysis.
  @param ph an HYDRAULIC project handle.
  @param initFlag a 2-digit initialization flag (see @ref EN_InitHydOption).
  @return an error code.
 
  This function initializes storage tank levels, link status and settings, and
  the simulation time clock prior to running a hydraulic analysis.
 
  The initialization flag is a two digit number where the 1st (left) digit
  indicates if link flows should be re-initialized (1) or not (0), and the
  2nd digit indicates if hydraulic results should be saved to a temporary
  binary hydraulics file (1) or not (0).
 
  Be sure to call ::EN_initH prior to running a hydraulic analysis using a
  ::EN_runH - ::EN_nextH loop.
 
  Choose to save hydraulics results if you will be:
  - making a subsequent water quality run,
  - using ::EN_report to generate a report
  - using ::EN_savehydfile to save the binary hydraulics file.
 
  There is no need to save hydraulics if you will be writing custom code to
  process hydraulic results as they are generated using the functions ::EN_getnodevalue
  and ::EN_getlinkvalue.
  */
  int DLLEXPORT EN_initH(EN_Project ph, int initFlag);
 
  /**
  @brief Computes a hydraulic solution for the current point in time.
  @param ph an HYDRAULIC project handle.
  @param[out] currentTime the current simulation time in seconds.
  @return an error or warning code.
 
  This function is used in a loop with ::EN_nextH to run an extended period hydraulic
  simulation. This process automatically updates the simulation clock time so \b currentTime
  should be treated as a read-only variable.
 
  ::EN_initH must have been called prior to running the ::EN_runH - ::EN_nextH loop.
 
  See ::EN_nextH for an example of using this function.
  */
  int DLLEXPORT EN_runH(EN_Project ph, long *currentTime);
 
  /**
  @brief Determines the length of time until the next hydraulic event occurs in an
  extended period simulation.
  @param ph an HYDRAULIC project handle.
  @param[out] tStep the time (in seconds) until the next hydraulic event or 0 if at
  the end of the full simulation duration.
  @return an error code.
 
  This function is used in a loop with ::EN_runH to run an extended period hydraulic
  simulation.
 
  The value of \b tstep should be treated as a read-only variable. It is automatically
  computed as the smaller of:
    - the time interval until the next hydraulic time step begins
    - the time interval until the next reporting time step begins
    - the time interval until the next change in demands occurs
    - the time interval until a tank becomes full or empty
    - the time interval until a control or rule fires.
 
 <B>Example:</B>
  \code {.c}
  long t, tstep;
  EN_openH(ph);
  EN_initH(ph, EN_NOSAVE);
  do {
    EN_runH(ph, &t);
    // Retrieve hydraulic results for time t
    EN_nextH(ph, &tstep);
  } while (tstep > 0);
  EN_closeH(ph);
  \endcode
  */
  int DLLEXPORT EN_nextH(EN_Project ph, long *tStep);
 
  /**
  @brief 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.
  @param ph an HYDRAULIC project handle.
  @return an error code.
 
  ::EN_saveH is used when only a hydraulic analysis is run and results at uniform reporting
  intervals need to be transferred to a project's binary output file. Such would be the case
  when results are to be written in formatted fashion to the project's report file using ::EN_report.
  */
  int DLLEXPORT EN_saveH(EN_Project ph);
 
  /**
  @brief Saves a project's temporary hydraulics file to disk.
  @param ph an HYDRAULIC project handle.
  @param filename the name of the file to be created.
  @return an error code.
 
  Use this function to save the current set of hydraulics results to a file, either for
  post-processing or to be used at a later time by calling the ::EN_usehydfile function.
 
  The hydraulics file contains nodal demands and heads and link flows, status, and settings
  for all hydraulic time steps, even intermediate ones.
 
  Before calling this function hydraulic results must have been generated and saved by having
  called ::EN_solveH or the ::EN_initH - ::EN_runH - ::EN_nextH sequence with the initflag
  argument of ::EN_initH set to \b EN_SAVE or \b EN_SAVE_AND_INIT.
  */
  int DLLEXPORT EN_savehydfile(EN_Project ph, const char *filename);
 
  /**
  @brief Closes the hydraulic solver freeing all of its allocated memory.
  @return an error code.
 
  Call ::EN_closeH after all hydraulics analyses have been made using
  ::EN_initH - ::EN_runH - ::EN_nextH. Do not call this function if ::EN_solveH is being used.
  */
  int DLLEXPORT EN_closeH(EN_Project ph);
 
  /********************************************************************
 
  Water Quality Analysis Functions
 
  ********************************************************************/
 
  /**
  @brief Runs a complete water quality simulation with results at uniform
  reporting intervals written to the project's binary output file.
  @param ph an HYDRAULIC project handle.
  @return an error code.
 
  A hydraulic analysis must have been run and saved to a hydraulics file before
  calling ::EN_solveQ. This function will not allow one to examine intermediate water
  quality results as they are generated. It can be followed by a call to ::EN_report
  to write all hydraulic and water quality results to a formatted report file.
 
  One can instead use the ::EN_openQ - ::EN_initQ - ::EN_runQ - ::EN_nextQ - ::EN_closeQ
  sequence to gain access to gain access to water quality results at intermediate time
  periods.
 
   <b>Example:</b> see ::EN_solveH.
  */
  int DLLEXPORT EN_solveQ(EN_Project ph);
 
  /**
  @brief Opens a project's water quality solver.
  @param ph n HYDRAULIC project handle.
  @return an error code.
 
  Call ::EN_openQ prior to running the first water quality analysis using an
  ::EN_initQ - ::EN_runQ - ::EN_nextQ (or ::EN_stepQ) sequence. Multiple water
  quality analyses can be made before calling ::EN_closeQ to close the water
  quality solver.
 
  Do not call this function if a complete water quality analysis will be made
  using ::EN_solveQ.
  */
  int DLLEXPORT EN_openQ(EN_Project ph);
 
  /**
  @brief Initializes a network prior to running a water quality analysis.
  @param ph an HYDRAULIC project handle.
  @param saveFlag set to \b EN_SAVE (1) if results are to be saved to the project's
  binary output file, or to \b EN_NOSAVE (0) if not.
  @return an error code.
 
  Call ::EN_initQ prior to running a water quality analysis using ::EN_runQ in
  conjunction with either ::EN_nextQ or ::EN_stepQ.
 
  ::EN_openQ must have been called prior to calling ::EN_initQ.
 
  Do not call ::EN_initQ if a complete water quality analysis will be made using ::EN_solveQ.
  */
  int DLLEXPORT EN_initQ(EN_Project ph, int saveFlag);
 
  /**
  @brief Makes hydraulic and water quality results at the start of the current time
  period available to a project's water quality solver.
  @param ph an HYDRAULIC project handle.
  @param[out] currentTime current simulation time in seconds.
  @return an error code.
 
  Use ::EN_runQ along with ::EN_nextQ in a loop to access water quality results at the
  start of each hydraulic period in an extended period simulation. Or use it in a loop
  with ::EN_stepQ to access results at the start of each water quality time step. See
  each of these functions for examples of how to code such loops.
 
  ::EN_initQ must have been called prior to running an ::EN_runQ - ::EN_nextQ
  (or ::EN_stepQ) loop.
 
  The current time of the simulation is determined from information saved with the
  hydraulic analysis that preceded the water quality analysis. Treat it as a read-only
  variable.
  */
  int DLLEXPORT EN_runQ(EN_Project ph, long *currentTime);
 
  /**
  @brief Advances a water quality simulation over the time until the next hydraulic event.
  @param ph an HYDRAULIC project handle.
  @param[out] tStep time (in seconds) until the next hydraulic event or 0 if at the end
  of the full simulation duration.
  @return an error code.
 
  This function is used in a loop with ::EN_runQ to perform an extended period water
  quality analysis. It reacts and routes a project's water quality constituent over a
  time step determined by when the next hydraulic event occurs. Use ::EN_stepQ instead
  if you wish to generate results over each water quality time step.
 
  The value of \b tStep is determined from information produced by the hydraulic analysis
  that preceded the water quality analysis. Treat it as a read-only variable.
 
 <b>Example:</b>
  \code {.c}
  long t, tStep;
  EN_solveH(ph);  // Generate & save hydraulics
  EN_openQ(ph);
  EN_initQ(ph, EN_NOSAVE);
  do {
    EN_runQ(ph, &t);
    // Monitor results at time t, which
    // begins a new hydraulic time period
    EN_nextQ(ph, &tStep);
  } while (tStep > 0);
  EN_closeQ(ph);
  \endcode
  */
  int DLLEXPORT EN_nextQ(EN_Project ph, long *tStep);
 
  /**
  @brief Advances a water quality simulation by a single water quality time step.
  @param ph an HYDRAULIC project handle.
  @param[out] timeLeft time left (in seconds) to the overall simulation duration.
  @return an error code.
 
  This function is used in a loop with ::EN_runQ to perform an extended period water
  quality simulation. It allows one to generate water quality results at each water
  quality time step of the simulation, rather than over each hydraulic event period
  as with ::EN_nextQ.
 
  Use the argument \b timeLeft to determine when no more calls to ::EN_runQ are needed
  because the end of the simulation period has been reached (i.e., when \b timeLeft = 0).
  */
  int DLLEXPORT EN_stepQ(EN_Project ph, long *timeLeft);
 
  /**
  @brief Closes the water quality solver, freeing all of its allocated memory.
  @param ph an HYDRAULIC project handle.
  @return an error code.
 
  Call ::EN_closeQ after all water quality analyses have been made using the
  ::EN_initQ - ::EN_runQ - ::EN_nextQ (or ::EN_stepQ) sequence of function calls.
 
  Do not call this function if ::EN_solveQ is being used.
  */
  int DLLEXPORT EN_closeQ(EN_Project ph);
 
  /********************************************************************
 
  Reporting Functions
 
  ********************************************************************/
 
  /**
  @brief Writes a line of text to a project's report file.
  @param ph an HYDRAULIC project handle.
  @param line a text string to write.
  @return an error code.
  */
  int  DLLEXPORT EN_writeline(EN_Project ph, char *line);
 
  /**
  @brief Writes simulation results in a tabular format to a project's report file.
  @param ph an HYDRAULIC project handle.
  @return an error code
 
  Either a full hydraulic analysis or full hydraulic and water quality analysis must
  have been run, with results saved to file, before ::EN_report is called. In the
  former case, ::EN_saveH must also be called first to transfer results from the
  project's intermediate hydraulics file to its output file.
 
  The format of the report is controlled by commands issued with ::EN_setreport.
  */
  int  DLLEXPORT EN_report(EN_Project ph);
 
  /**
  @brief Copies the current contents of a project's report file to another file.
  @param ph an HYDRAULIC project handle.
  @param filename the full path name of the destination file.
  @return an error code.
 
  This function allows toolkit clients to retrieve the contents of a project's
  report file while the project is still open.
  */
  int  DLLEXPORT EN_copyreport(EN_Project ph, char *filename);
 
  /**
  @brief Clears the contents of a project's report file.
  @param ph an HYDRAULIC project handle.
  @return an error code.
  */
  int DLLEXPORT EN_clearreport(EN_Project ph);
 
  /**
  @brief Resets a project's report options to their default values.
  @param ph an HYDRAULIC project handle.
  @return an error code
 
  After calling this function the default reporting options are in effect. These are:
  - no status report
  - no energy report
  - no nodes reported on
  - no links reported on
  - node variables reported to 2 decimal places
  - link variables reported to 2 decimal places (3 for friction factor)
  - node variables reported are elevation, head, pressure, and quality
  - link variables reported are flow, velocity, and head loss.
  */
  int  DLLEXPORT EN_resetreport(EN_Project ph);
 
  /**
  @brief Processes a reporting format command.
  @param ph an HYDRAULIC project handle.
  @param format a report formatting command.
  @return an error code
 
  Acceptable report formatting commands are described in the @ref ReportPage section of
  the @ref InpFile topic.
 
  Formatted results of a simulation can be written to a project's report file
  using the ::EN_report function.
  */
  int  DLLEXPORT EN_setreport(EN_Project ph, char *format);
 
  /**
  @brief Sets the level of hydraulic status reporting.
  @param ph an HYDRAULIC project handle.
  @param level a status reporting level code (see @ref EN_StatusReport).
  @return an error code.
 
  Status reporting writes changes in the hydraulics status of network elements to a
  project's  report file as a hydraulic simulation unfolds. There are three levels
  of reporting: \b EN_NO_REPORT (no status reporting), \b EN_NORMAL_REPORT (normal
  reporting) \b EN_FULL_REPORT (full status reporting).
 
  The full status report contains information at each trial of the solution to the
  system hydraulic equations at each time step of a simulation. It is useful mainly
  for debugging purposes.
 
  If many hydraulic analyses will be run in the application it is recommended that
  status reporting be turned off (<b>level = EN_NO_REPORT</b>).
  */
  int  DLLEXPORT EN_setstatusreport(EN_Project ph, int level);
 
  /**
  @brief Retrieves the toolkit API version number.
  @param[out] version the version of the OWA-HYDRAULIC toolkit.
  @return an error code.
 
  The version number is to be interpreted with implied decimals, i.e.,
  "20100" == "2(.)01(.)00"
  */
  int  DLLEXPORT EN_getversion(int *version);
 
  /**
  @brief Returns the text of an error message generated by an error code.
  @param errcode an error code.
  @param[out] out_errmsg the error message generated by the error code
  @param maxLen maximum number of characters that errmsg can hold
  @return an error code
 
  Error message strings should be at least @ref EN_SizeLimits "EN_MAXMSG" characters in length.
  */
  int  DLLEXPORT EN_geterror(int errcode, char *out_errmsg, int maxLen);
 
  /**
  @brief Returns the text of an error message generated by an error code.
  @param errcode an error code.
  @param[out] out_errmsg the error message generated by the error code
  @param maxLen maximum number of characters that errmsg can hold
  @return an error code
 
  Error message strings should be at least @ref EN_SizeLimits "EN_MAXMSG" characters in length.
  */
  int DLLEXPORT EN_geterrormsg(EN_Project pr, char* errmsg, int maxLen);
 
  /**
  @brief Retrieves a particular simulation statistic.
  @param ph an HYDRAULIC project handle.
  @param type the type of statistic to retrieve (see @ref EN_AnalysisStatistic).
  @param[out] value the value of the statistic.
  @return an error code
  */
  int  DLLEXPORT EN_getstatistic(EN_Project ph, int type, double* value);
 
  /**
  @brief Retrieves the order in which a node or link appears in an @ref OutFile "output file".
  @param ph an HYDRAULIC project handle.
  @param type a type of element (either @ref EN_NODE or @ref EN_LINK).
  @param index the element's current index (starting from 1).
  @param[out] value the order in which the element's results were written to file.
  @return an error code.
 
  If the element does not appear in the file then its result index is 0.
 
  This function can be used to correctly retrieve results from an HYDRAULIC binary output file
  after the order of nodes or links in a network's database has been changed due to editing
  operations.
  */
  int  DLLEXPORT EN_getresultindex(EN_Project ph, int type, int index, int *value);
 
  /********************************************************************
 
  Analysis Options Functions
 
  ********************************************************************/
 
  /**
  @brief Retrieves the value of an analysis option.
  @param ph an HYDRAULIC project handle.
  @param option a type of analysis option (see @ref EN_Option).
  @param[out] value the current value of the option.
  @return an error code
  */
  int  DLLEXPORT EN_getoption(EN_Project ph, int option, double *value);
 
  /**
  @brief Sets the value for an anlysis option.
  @param ph an HYDRAULIC project handle.
  @param option a type of analysis option (see @ref EN_Option).
  @param value the new value assigned to the option.
  @return an error code.
  @see EN_Option
  */
  int  DLLEXPORT EN_setoption(EN_Project ph, int option, double value);
 
  /**
  @brief Retrieves a project's flow units.
  @param ph an HYDRAULIC project handle.
  @param[out] units a flow units code (see @ref EN_FlowUnits)
  @return an error code.
 
  Flow units in liters or cubic meters implies that SI metric units are used for all
  other quantities in addition to flow. Otherwise US Customary units are employed.
  */
  int  DLLEXPORT EN_getflowunits(EN_Project ph, int *units);
 
  /**
  @brief Sets a project's flow units.
  @param ph an HYDRAULIC project handle.
  @param units a flow units code (see @ref EN_FlowUnits)
  @return an error code.
 
  Flow units in liters or cubic meters implies that SI metric units are used for all
  other quantities in addition to flow. Otherwise US Customary units are employed.
  */
  int  DLLEXPORT EN_setflowunits(EN_Project ph, int units);
 
  /**
  @brief Retrieves the value of a time parameter.
  @param ph an HYDRAULIC project handle.
  @param param a time parameter code (see @ref EN_TimeParameter).
  @param[out] value the current value of the time parameter (in seconds).
  @return an error code.
  */
  int  DLLEXPORT EN_gettimeparam(EN_Project ph, int param, long *value);
 
  /**
  @brief Sets the value of a time parameter.
  @param ph an HYDRAULIC project handle.
  @param param a time parameter code (see @ref EN_TimeParameter).
  @param value the new value of the time parameter (in seconds)
  @return an error code.
  */
  int  DLLEXPORT EN_settimeparam(EN_Project ph, int param, long value);
 
  /**
  @brief Gets information about the type of water quality analysis requested.
  @param ph an HYDRAULIC project handle.
  @param[out] qualType type of analysis to run (see @ref EN_QualityType).
  @param[out] out_chemName name of chemical constituent.
  @param[out] out_chemUnits concentration units of the constituent.
  @param[out] traceNode index of the node being traced (if applicable).
  @return an error code.
  */
  int  DLLEXPORT EN_getqualinfo(EN_Project ph, int *qualType, char *out_chemName,
                 char *out_chemUnits, int *traceNode);
 
  /**
  @brief Retrieves the type of water quality analysis to be run.
  @param ph an HYDRAULIC project handle.
  @param[out] qualType the type of analysis to run (see @ref EN_QualityType).
  @param[out] traceNode the index of node being traced, if <b>qualType = EN_TRACE</b>.
  @return an error code.
  */
  int  DLLEXPORT EN_getqualtype(EN_Project ph, int *qualType, int *traceNode);
 
  /**
  @brief Sets the type of water quality analysis to run.
  @param ph an HYDRAULIC project handle.
  @param qualType the type of analysis to run (see @ref EN_QualityType).
  @param chemName the name of the quality constituent.
  @param chemUnits the concentration units of the constituent.
  @param traceNode the ID name of the node being traced if <b>qualType = EN_TRACE</b>.
  @return an error code.
 
  Chemical name and units can be an empty string if the analysis is not for a chemical.
  The same holds for the trace node if the analysis is not for source tracing.
 
  Note that the trace node is specified by ID name and not by index.
  */
  int  DLLEXPORT EN_setqualtype(EN_Project ph, int qualType, char *chemName,
                 char *chemUnits, char *traceNode);
 
  /********************************************************************
 
  Node Functions
 
  ********************************************************************/
 
  /**
  @brief Adds a new node to a project.
  @param ph an HYDRAULIC project handle.
  @param id the ID name of the node to be added.
  @param nodeType the type of node being added (see @ref EN_NodeType)
  @param[out] index the index of the newly added node
  @return an error code.
 
  When a new node is created all of its properties (see @ref EN_NodeProperty) are set to 0.
  */
  int DLLEXPORT EN_addnode(EN_Project ph, char *id, int nodeType, int *index);
 
  /**
  @brief Deletes a node from a project.
  @param ph an HYDRAULIC project handle.
  @param index the index of the node to be deleted.
  @param actionCode the action taken if any control contains the node and its links.
  @return an error code.
 
  If \b actionCode is \b EN_UNCONDITIONAL then the node, its incident links and all
  simple and rule-based controls that contain them are deleted. If set to
  \b EN_CONDITIONAL then the node is not deleted if it or its incident links appear
  in any controls and error code 261 is returned.
 
  */
  int DLLEXPORT EN_deletenode(EN_Project ph, int index, int actionCode);
 
  /**
  @brief Gets the index of a node given its ID name.
  @param ph an HYDRAULIC project handle.
  @param id a node ID name.
  @param[out] index the node's index (starting from 1).
  @return an error code
  */
  int  DLLEXPORT EN_getnodeindex(EN_Project ph, char *id, int *index);
 
  /**
  @brief Gets the ID name of a node given its index.
  @param ph an HYDRAULIC project handle.
  @param index a node's index (starting from 1).
  @param[out] out_id the node's ID name.
  @return an error code
 
  The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
  */
  int  DLLEXPORT EN_getnodeid(EN_Project ph, int index, char *out_id);
  /**
  @brief Gets the ID name of a node given its index.
  @param ph an HYDRAULIC project handle.
  @param index a node's index (starting from 1).
  @param[out] out_id the node's ID name.
  @return an error code
 
  The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
  */
  int  DLLEXPORT EN_getnodecomment(EN_Project ph, int index, char *out_id);
 
  /**
  @brief Changes the ID name of a node.
  @param ph an HYDRAULIC project handle.
  @param index a node's index (starting from 1).
  @param newid the new ID name for the node.
  @return an error code.
 
  The ID name must not be longer than @ref EN_SizeLimits "EN_MAXID" characters.
  */
  int DLLEXPORT EN_setnodeid(EN_Project ph, int index, char *newid);
 
  /**
  @brief Retrieves a node's type given its index.
  @param ph an HYDRAULIC project handle.
  @param index a node's index (starting from 1).
  @param[out] nodeType the node's type (see @ref EN_NodeType).
  @return an error code.
  */
  int  DLLEXPORT EN_getnodetype(EN_Project ph, int index, int *nodeType);
 
  /**
  @brief Retrieves a property value for a node.
  @param ph an HYDRAULIC project handle.
  @param index a node's index.
  @param property the property to retrieve (see @ref EN_NodeProperty).
  @param[out] value the current value of the property.
  @return an error code.
 
  Values are returned in units that depend on the units used for flow rate
  (see @ref Units).
  */
  int  DLLEXPORT EN_getnodevalue(EN_Project ph, int index, int property, double *value);
 
  /**
  @brief Sets a property value for a node.
  @param ph an HYDRAULIC project handle.
  @param index a node's index (starting from 1).
  @param property the property to set (see @ref EN_NodeProperty).
  @param value the new value for the property.
  @return an error code.
 
  Values are in units that depend on the units used for flow rate (see @ref Units).
  */
  int  DLLEXPORT EN_setnodevalue(EN_Project ph, int index, int property, double value);
 
  /**
  @brief Sets a group of properties for a junction node.
  @param ph an HYDRAULIC project handle.
  @param index a junction node's index (starting from 1).
  @param elev the value of the junction's elevation.
  @param dmnd the value of the junction's primary base demand.
  @param dmndpat the ID name of the demand's time pattern ("" for no pattern)
  @return an error code.
 
  These properties have units that depend on the units used for flow rate (see @ref Units).
  */
  int  DLLEXPORT EN_setjuncdata(EN_Project ph, int index, double elev, double dmnd,
      char *dmndpat);
 
  /**
  @brief Sets a group of properties for a tank node.
  @param ph an HYDRAULIC project handle.
  @param index a tank node's index (starting from 1).
  @param elev the tank's bottom elevation.
  @param initlvl the initial water level in the tank.
  @param minlvl the minimum water level for the tank.
  @param maxlvl the maximum water level for the tank.
  @param diam the tank's diameter (0 if a volume curve is supplied).
  @param minvol the volume of the tank at its minimum water level.
  @param volcurve the name of the tank's volume curve ("" for no curve)
  @return an error code.
 
  These properties have units that depend on the units used for flow rate (see @ref Units).
  */
  int  DLLEXPORT EN_settankdata(EN_Project ph, int index, double elev, double initlvl,
                 double minlvl, double maxlvl, double diam, double minvol, char *volcurve);
 
  /**
  @brief Gets the (x,y) coordinates of a node.
  @param ph an HYDRAULIC project handle.
  @param index a node index (starting from 1).
  @param[out] x the node's X-coordinate value.
  @param[out] y the node's Y-coordinate value.
  @return an error code.
  */
  int  DLLEXPORT EN_getcoord(EN_Project ph, int index, double *x, double *y);
 
  /**
  @brief Sets the (x,y) coordinates of a node.
  @param ph an HYDRAULIC project handle.
  @param index a node index (starting from 1).
  @param x the node's X-coordinate value.
  @param y the node's Y-coordinate value.
  @return an error code.
  */
  int  DLLEXPORT EN_setcoord(EN_Project ph, int index, double x, double y);
 
  /********************************************************************
 
  Nodal Demand Functions
 
  ********************************************************************/
 
  /**
  @brief Retrieves the type of demand model in use and its parameters.
  @param ph an HYDRAULIC project handle.
  @param[out] type  Type of demand model (see @ref EN_DemandModel).
  @param[out] pmin  Pressure below which there is no demand.
  @param[out] preq  Pressure required to deliver full demand.
  @param[out] pexp  Pressure exponent in demand function.
  @return an error code.
 
  Parameters <b>pmin, preq,</b> and \b pexp are only used when the demand model is \b EN_PDA.
  */
  int DLLEXPORT EN_getdemandmodel(EN_Project ph, int *type, double *pmin,
                double *preq, double *pexp);
 
  /**
  @brief Sets the type of demand model to use and its parameters.
  @param ph an HYDRAULIC project handle.
  @param type  Type of demand model (see @ref EN_DemandModel).
  @param pmin  Pressure below which there is no demand.
  @param preq  Pressure required to deliver full demand.
  @param pexp  Pressure exponent in demand function.
  @return an error code.
 
  Set \b type to \b EN_DDA for a traditional demand driven analysis (in which case the
  remaining three parameter values are ignored) or to \b EN_PDA for a pressure driven
  analysis. In the latter case a node's demand is computed as:
  >  `Dfull * [ (P - pmin) / (preq - pmin) ] ^ pexp`
  where `Dfull` is the full demand and `P` is the current pressure.
 
  Setting \b preq equal to \b pmin will result in a solution with the smallest amount of
  demand reductions needed to insure that no node delivers positive demand at a pressure
  below \b pmin.
  */
  int DLLEXPORT EN_setdemandmodel(EN_Project ph, int type, double pmin,
                double preq, double pexp);
 
 
  /**
  @brief appends a new demand to a junction node demands list.
  @param ph an HYDRAULIC project handle.
  @param nodeIndex the index of a node (starting from 1).
  @param baseDemand the demand's base value.
  @param demandPattern the name of a time pattern used by the demand
  @param demandName the name of the demand's category
  @return an error code.
 
  A NULL or blank string can be used for `demandPattern` and for `demandName` to indicate
  that no time pattern or category name is associated with the demand.
  */
  int DLLEXPORT EN_adddemand(EN_Project ph, int nodeIndex, double baseDemand,
                char *demandPattern, char *demandName);
 
  /**
  @brief deletes a demand from a junction node.
  @param ph an HYDRAULIC project handle.
  @param nodeIndex the index of a node (starting from 1).
  @param demandIndex the position of the demand in the node's demands list (starting from 1).
  @return an error code.
  */
  int DLLEXPORT EN_deletedemand(EN_Project ph, int nodeIndex, int demandIndex);
 
  /**
  @brief Retrieves the index of a node's named demand category
  @param ph an HYDRAULIC project handle.
  @param nodeIndex the index of a node (starting from 1)
  @param demandName the name of a demand category for the node
  @param[out] demandIndex the index of the demand being sought
  @return an error code
  */
  int DLLEXPORT EN_getdemandindex(EN_Project ph, int nodeIndex, char *demandName,
                int *demandIndex);
 
  /**
  @brief Retrieves the number of demand categories for a junction node.
  @param ph an HYDRAULIC project handle.
  @param nodeIndex the index of a node (starting from 1).
  @param[out] numDemands the number of demand categories assigned to the node.
  @return an error code.
  */
  int  DLLEXPORT EN_getnumdemands(EN_Project ph, int nodeIndex, int *numDemands);
 
 
  int DLLEXPORT EN_getTotalDemand(EN_Project ph, int p, double* value);
 
 
  /**
  @brief Gets the base demand for one of a node's demand categories.
  @param ph an HYDRAULIC project handle.
  @param nodeIndex a node's index (starting from 1).
  @param demandIndex the index of a demand category for the node (starting from 1).
  @param[out] baseDemand the category's base demand.
  @return an error code.
  */
  int  DLLEXPORT EN_getbasedemand(EN_Project ph, int nodeIndex, int demandIndex,
                 double *baseDemand);
 
  /**
  @brief Sets the base demand for one of a node's demand categories.
  @param ph an HYDRAULIC project handle.
  @param nodeIndex a node's index (starting from 1).
  @param demandIndex the index of a demand category for the node (starting from 1).
  @param baseDemand the new base demand for the category.
  @return an error code.
  */
  int  DLLEXPORT EN_setbasedemand(EN_Project ph, int nodeIndex, int demandIndex,
                 double baseDemand);
 
  /**
  @brief Retrieves the index of a time pattern assigned to one of a node's demand categories.
  @param ph an HYDRAULIC project handle.
  @param nodeIndex the node's index (starting from 1).
  @param demandIndex the index of a demand category for the node (starting from 1).
  @param[out] patIndex the index of the category's time pattern.
  @return an error code.
 
  A returned pattern index of 0 indicates that no time pattern has been assigned to the
  demand category.
  */
  int  DLLEXPORT EN_getdemandpattern(EN_Project ph, int nodeIndex, int demandIndex,
       int *patIndex);
 
  /**
  @brief Sets the index of a time pattern used for one of a node's demand categories.
  @param ph an HYDRAULIC project handle.
  @param nodeIndex a node's index (starting from 1).
  @param demandIndex the index of one of the node's demand categories (starting from 1).
  @param patIndex the index of the time pattern assigned to the category.
  @return an error code.
 
  Specifying a pattern index of 0 indicates that no time pattern is assigned to the
  demand category.
  */
  int  DLLEXPORT EN_setdemandpattern(EN_Project ph, int nodeIndex, int demandIndex, int patIndex);
 
  /**
  @brief Retrieves the name of a node's demand category.
  @param ph an HYDRAULIC project handle.
  @param nodeIndex a node's index (starting from 1).
  @param demandIndex the index of one of the node's demand categories (starting from 1).
  @param[out] out_demandName The name of the selected category.
  @return an error code.
 
  \b demandName must be sized to contain at least @ref EN_SizeLimits "EN_MAXID" characters.
  */
  int DLLEXPORT EN_getdemandname(EN_Project ph, int nodeIndex, int demandIndex, char *out_demandName);
 
  /**
  @brief Assigns a name to a node's demand category.
  @param ph an HYDRAULIC project handle.
  @param nodeIndex a node's index (starting from 1).
  @param demandIdx the index of one of the node's demand categories (starting from 1).
  @param demandName the new name assigned to the category.
  @return Error code.
 
  The category name must contain no more than @ref EN_SizeLimits "EN_MAXID" characters.
  */
  int DLLEXPORT EN_setdemandname(EN_Project ph, int nodeIndex, int demandIdx, char *demandName);
 
  /********************************************************************
 
  Link Functions
 
  ********************************************************************/
 
  /**
  @brief Adds a new link to a project.
  @param ph an HYDRAULIC project handle.
  @param id the ID name of the link to be added.
  @param linkType The type of link being added (see @ref EN_LinkType)
  @param fromNode The ID name of the link's starting node.
  @param toNode The ID name of the link's ending node.
  @param[out] index the index of the newly added link.
  @return 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 @ref 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 \b 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 @ref EN_LinkProperty.
  */
  int DLLEXPORT EN_addlink(EN_Project ph, char *id, int linkType, char *fromNode,
                          char *toNode, int *index);
 
  /**
  @brief Deletes a link from the project.
  @param ph an HYDRAULIC project handle.
  @param index the index of the link to be deleted.
  @param actionCode The action taken if any control contains the link.
  @return an error code.
 
  If \b actionCode is \b EN_UNCONDITIONAL then the link and all simple and rule-based
  controls that contain it are deleted. If set to \b EN_CONDITIONAL then the link
  is not deleted if it appears in any control and error 261 is returned.
  */
  int DLLEXPORT EN_deletelink(EN_Project ph, int index, int actionCode);
 
  /**
  @brief Gets the index of a link given its ID name.
  @param ph an HYDRAULIC project handle.
  @param id a link's ID name.
  @param[out] index the link's index (starting from 1).
  @return an error code.
  */
  int  DLLEXPORT EN_getlinkindex(EN_Project ph, char *id, int *index);
 
  /**
  @brief Gets the ID name of a link given its index.
  @param ph an HYDRAULIC project handle.
  @param index a link's index (starting from 1).
  @param[out] out_id The link's ID name.
  @return an error code.
 
  The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
  */
  int  DLLEXPORT EN_getlinkid(EN_Project ph, int index, char *out_id);
 
 
  /**
@brief Gets the ID name of a link given its index.
@param ph an HYDRAULIC project handle.
@param index a link's index (starting from 1).
@param[out] out_id The link's ID name.
@return an error code.
 
The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
*/
  int  DLLEXPORT EN_getlinkcomment(EN_Project ph, int index, char* out_id);
 
  /**
  @brief Changes the ID name of a link.
  @param ph an HYDRAULIC project handle.
  @param index a link's index (starting from 1).
  @param newid the new ID name for the link.
  @return Error code.
 
  The ID name must not be longer than @ref EN_SizeLimits "EN_MAXID" characters.
  */
  int DLLEXPORT EN_setlinkid(EN_Project ph, int index, char *newid);
 
  /**
  @brief Retrieves a link's type.
  @param ph an HYDRAULIC project handle.
  @param index a link's index (starting from 1).
  @param[out] linkType the link's type (see @ref EN_LinkType).
  @return an error code.
  */
  int  DLLEXPORT EN_getlinktype(EN_Project ph, int index, int *linkType);
 
  /**
  @brief Changes a link's type.
  @param ph an HYDRAULIC project handle.
  @param[in,out] inout_index the link's index before [in] and after [out] the type change.
  @param linkType the new type to change the link to (see @ref EN_LinkType).
  @param actionCode the action taken if any controls contain the link.
  @return an error code.
 
  If \b actionCode is \b 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
  \b EN_CONDITIONAL then the type change is cancelled if the link appears in any
  control and error 261 is returned.
  */
  int  DLLEXPORT EN_setlinktype(EN_Project ph, int *inout_index, int linkType, int actionCode);
 
  /**
  @brief Gets the indexes of a link's start- and end-nodes.
  @param ph an HYDRAULIC project handle.
  @param index a link's index (starting from 1).
  @param[out] node1 the index of the link's start node (starting from 1).
  @param[out] node2 the index of the link's end node (starting from 1).
  @return an error code.
  */
  int  DLLEXPORT EN_getlinknodes(EN_Project ph, int index, int *node1, int *node2);
 
  /**
  @brief Sets the indexes of a link's start- and end-nodes.
  @param ph an HYDRAULIC project handle.
  @param index a link's index (starting from 1).
  @param node1 The index of the link's start node (starting from 1).
  @param node2 The index of the link's end node (starting from 1).
  @return an error code.
  */
  int  DLLEXPORT EN_setlinknodes(EN_Project ph, int index, int node1, int node2);
 
  /**
  @brief Retrieves a property value for a link.
  @param ph an HYDRAULIC project handle.
  @param index a link's index (starting from 1).
  @param property the property to retrieve (see @ref EN_LinkProperty).
  @param[out] value the current value of the property.
  @return an error code.
 
  Values are returned in units that depend on the units used for flow rate (see @ref Units).
  */
  int  DLLEXPORT EN_getlinkvalue(EN_Project ph, int index, int property, double *value);
 
  /**
  @brief Sets a property value for a link.
  @param ph an HYDRAULIC project handle.
  @param index a link's index.
  @param property the property to set (see @ref EN_LinkProperty).
  @param value the new value for the property.
  @return an error code.
 
  Values are in units that depend on the units used for flow rate (see @ref Units).
  */
  int  DLLEXPORT EN_setlinkvalue(EN_Project ph, int index, int property, double value);
 
  /**
  @brief Sets a group of properties for a pipe link.
  @param ph an HYDRAULIC project handle.
  @param index the index of a pipe link (starting from 1).
  @param length the pipe's length.
  @param diam the pipe's diameter.
  @param rough the pipe's roughness coefficient.
  @param mloss the pipe's minor loss coefficient.
  @return an error code.
 
  These properties have units that depend on the units used for flow rate (see @ref Units).
  */
  int DLLEXPORT EN_setpipedata(EN_Project ph, int index, double length, double diam,
                double rough,  double mloss);
 
  /**
  @brief Retrieves the number of internal vertex points assigned to a link.
  @param ph an HYDRAULIC project handle.
  @param index a link's index (starting from 1).
  @param[out] count the number of vertex points that describe the link's shape.
  @return an error code.
  */
  int DLLEXPORT EN_getvertexcount(EN_Project ph, int index, int *count);
 
  /**
  @brief Retrieves the coordinate's of a vertex point assigned to a link.
  @param ph an HYDRAULIC project handle.
  @param index a link's index (starting from 1).
  @param vertex a vertex point index (starting from 1).
  @param[out] x the vertex's X-coordinate value.
  @param[out] y the vertex's Y-coordinate value.
  @return an error code.
  */
  int DLLEXPORT EN_getvertex(EN_Project ph, int index, int vertex, double *x, double *y);
 
  /**
  @brief Assigns a set of internal vertex points to a link.
  @param ph an HYDRAULIC project handle.
  @param index a link's index (starting from 1).
  @param x an array of X-coordinates for the vertex points.
  @param y an array of Y-coordinates for the vertex points.
  @param count the number of vertex points being assigned.
  @return an error code.
 
  Replaces any existing vertices previously assigned to the link.
  */
  int DLLEXPORT EN_setvertices(EN_Project ph, int index, double *x, double *y, int count);
 
  /********************************************************************
 
  Pump Functions
 
  ********************************************************************/
 
  /**
  @brief Retrieves the type of head curve used by a pump.
  @param ph an HYDRAULIC project handle.
  @param linkIndex the index of a pump link (starting from 1).
  @param[out] pumpType the type of head curve used by the pump (see @ref EN_PumpType).
  @return an error code.
  */
  int  DLLEXPORT EN_getpumptype(EN_Project ph, int linkIndex, int *pumpType);
 
  /**
  @brief Retrieves the curve assigned to a pump's head curve.
  @param ph an HYDRAULIC project handle.
  @param linkIndex the index of a pump link (starting from 1).
  @param[out] curveIndex the index of the curve assigned to the pump's head curve.
  @return an error code.
  */
  int  DLLEXPORT EN_getheadcurveindex(EN_Project ph, int linkIndex, int *curveIndex);
 
  /**
  @brief Assigns a curve to a pump's head curve.
  @param ph an HYDRAULIC project handle.
  @param linkIndex the index of a pump link (starting from 1).
  @param curveIndex the index of a curve to be assigned as the pump's head curve.
  @return an error code.
  */
  int  DLLEXPORT EN_setheadcurveindex(EN_Project ph, int linkIndex, int curveIndex);
 
  /********************************************************************
 
  Time Pattern Functions
 
  ********************************************************************/
 
  /**
  @brief Adds a new time pattern to a project.
  @param ph an HYDRAULIC project handle.
  @param id the ID name of the pattern to add.
  @return an error code.
 
  The new pattern contains a single time period whose factor is 1.0.
  */
  int  DLLEXPORT EN_addpattern(EN_Project ph, char *id);
 
  /**
  @brief Deletes a time pattern from a project.
  @param ph an HYDRAULIC project handle.
  @param index the time pattern's index (starting from 1).
  @return an error code.
  */
  int  DLLEXPORT EN_deletepattern(EN_Project ph, int index);
 
  /**
  @brief Retrieves the index of a time pattern given its ID name.
  @param ph an HYDRAULIC project handle.
  @param id the ID name of a time pattern.
  @param[out] index the time pattern's index (starting from 1).
  @return an error code.
  */
  int  DLLEXPORT EN_getpatternindex(EN_Project ph, char *id, int *index);
 
  /**
  @brief Retrieves the ID name of a time pattern given its index.
  @param ph an HYDRAULIC project handle.
  @param index a time pattern index (starting from 1).
  @param[out] out_id the time pattern's ID name.
  @return an error code.
 
  The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
  */
  int  DLLEXPORT EN_getpatternid(EN_Project ph, int index, char *out_id);
 
  /**
  @brief Changes the ID name of a time pattern given its index.
  @param ph an HYDRAULIC project handle.
  @param index a time pattern index (starting from 1).
  @param id the time pattern's new ID name.
  @return an error code.
 
  The new ID name must not exceed @ref EN_SizeLimits "EN_MAXID" characters.
  */
  int  DLLEXPORT EN_setpatternid(EN_Project ph, int index, char *id);
 
  /**
  @brief Retrieves the number of time periods in a time pattern.
  @param ph an HYDRAULIC project handle.
  @param index a time pattern index (starting from 1).
  @param[out] len the number of time periods in the pattern.
  @return an error code.
  */
  int  DLLEXPORT EN_getpatternlen(EN_Project ph, int index, int *len);
 
  /**
  @brief Retrieves a time pattern's factor for a given time period.
  @param ph an HYDRAULIC project handle.
  @param index a time pattern index (starting from 1).
  @param period a time period in the pattern (starting from 1).
  @param[out] value the pattern factor for the given time period.
  @return an error code.
  */
  int  DLLEXPORT EN_getpatternvalue(EN_Project ph, int index, int period, double *value);
 
  /**
  @brief Sets a time pattern's factor for a given time period.
  @param ph an HYDRAULIC project handle.
  @param index a time pattern index (starting from 1).
  @param period a time period in the pattern (starting from 1).
  @param value the new value of the pattern factor for the given time period.
  @return an error code.
  */
  int  DLLEXPORT EN_setpatternvalue(EN_Project ph, int index, int period, double value);
 
  /**
  @brief Retrieves the average of all pattern factors in a time pattern.
  @param ph an HYDRAULIC project handle.
  @param index a time pattern index (starting from 1).
  @param[out] value The average of all of the time pattern's factors.
  @return an error code.
  */
  int  DLLEXPORT EN_getaveragepatternvalue(EN_Project ph, int index, double *value);
 
  /**
  @brief Sets the pattern factors for a given time pattern.
  @param ph an HYDRAULIC project handle.
  @param index a time pattern index (starting from 1).
  @param values an array of new pattern factor values.
  @param len the number of factor values supplied.
  @return an error code.
 
  \b values is a zero-based array that contains \b len elements.
 
  Use this function to redefine (and resize) a time pattern all at once;
  use @ref EN_setpatternvalue to revise pattern factors one at a time.
  */
  int  DLLEXPORT EN_setpattern(EN_Project ph, int index, double *values, int len);
 
  /********************************************************************
 
  Data Curve Functions
 
  ********************************************************************/
 
  /**
  @brief Adds a new data curve to a project.
  @param ph an HYDRAULIC project handle.
  @param id The ID name of the curve to be added.
  @return an error code.
 
  The new curve contains a single data point (1.0, 1.0).
  */
  int  DLLEXPORT EN_addcurve(EN_Project ph, char *id);
 
  /**
  @brief Deletes a data curve from a project.
  @param ph an HYDRAULIC project handle.
  @param index the data curve's index (starting from 1).
  @return an error code.
  */
  int  DLLEXPORT EN_deletecurve(EN_Project ph, int index);
 
  /**
  @brief Retrieves the index of a curve given its ID name.
  @param ph an HYDRAULIC project handle.
  @param id the ID name of a curve.
  @param[out] index The curve's index (starting from 1).
  @return an error code.
  */
  int  DLLEXPORT EN_getcurveindex(EN_Project ph, char *id, int *index);
 
  /**
  @brief Retrieves the ID name of a curve given its index.
  @param ph an HYDRAULIC project handle.
  @param index a curve's index (starting from 1).
  @param[out] out_id the curve's ID name.
  @return an error code.
 
  The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
  */
  int  DLLEXPORT EN_getcurveid(EN_Project ph, int index, char *out_id);
 
  /**
  @brief Changes the ID name of a data curve given its index.
  @param ph an HYDRAULIC project handle.
  @param index a data curve index (starting from 1).
  @param id the data curve's new ID name.
  @return an error code.
 
  The new ID name must not exceed @ref EN_SizeLimits "EN_MAXID" characters.
  */
  int  DLLEXPORT EN_setcurveid(EN_Project ph, int index, char *id);
 
  /**
  @brief Retrieves the number of points in a curve.
  @param ph an HYDRAULIC project handle.
  @param index a curve's index (starting from 1).
  @param[out] len The number of data points assigned to the curve.
  @return an error code.
  */
  int  DLLEXPORT EN_getcurvelen(EN_Project ph, int index, int *len);
 
  /**
  @brief Retrieves a curve's type.
  @param ph an HYDRAULIC project handle.
  @param index a curve's index (starting from 1).
  @param[out] type the curve's type (see @ref EN_CurveType).
  @return an error code.
  */
  int  DLLEXPORT EN_getcurvetype(EN_Project ph, int index, int *type);
 
  /**
  @brief Retrieves the value of a single data point for a curve.
  @param ph an HYDRAULIC project handle.
  @param curveIndex a curve's index (starting from 1).
  @param pointIndex the index of a point on the curve (starting from 1).
  @param[out] x the point's x-value.
  @param[out] y the point's y-value.
  @return an error code.
  */
  int  DLLEXPORT EN_getcurvevalue(EN_Project ph, int curveIndex, int pointIndex,
                 double *x, double *y);
 
  /**
  @brief Sets the value of a single data point for a curve.
  @param ph an HYDRAULIC project handle.
  @param curveIndex a curve's index (starting from 1).
  @param pointIndex the index of a point on the curve (starting from 1).
  @param x the point's new x-value.
  @param y the point's new y-value.
  @return an error code.
  */
  int  DLLEXPORT EN_setcurvevalue(EN_Project ph, int curveIndex, int pointIndex,
                 double x, double y);
 
  /**
  @brief Retrieves all of a curve's data.
  @param ph an HYDRAULIC project handle.
  @param index a curve's index (starting from 1).
  @param[out] out_id the curve's ID name.
  @param[out] nPoints the number of data points on the curve.
  @param[out] xValues the curve's x-values.
  @param[out] yValues the curve's y-values.
  @return 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
  @ref EN_SizeLimits "EN_MAXID" characters.
  */
  int  DLLEXPORT EN_getcurve(EN_Project ph, int index, char *out_id, int *nPoints,
                 double *xValues, double *yValues);
 
  /**
  @brief assigns a set of data points to a curve.
  @param ph an HYDRAULIC project handle.
  @param index a curve's index (starting from 1).
  @param xValues an array of new x-values for the curve.
  @param yValues an array of new y-values for the curve.
  @param nPoints the new number of data points for the curve.
  @return an error code.
 
  \b xValues and \b yValues are zero-based arrays that contains \b nPoints elements.
 
  Use this function to redefine (and resize) a curve all at once;
  use @ref EN_setcurvevalue to revise a curve's data points one at a time.
  */
  int  DLLEXPORT EN_setcurve(EN_Project ph, int index, double *xValues,
                 double *yValues, int nPoints);
 
  /********************************************************************
 
  Simple Controls Functions
 
  ********************************************************************/
 
  /**
  @brief Adds a new simple control to a project.
  @param ph an HYDRAULIC project handle.
  @param type the type of control to add (see @ref EN_ControlType).
  @param linkIndex the index of a link to control (starting from 1).
  @param setting control setting applied to the link.
  @param nodeIndex index of the node used to control the link
  (0 for \b EN_TIMER and \b EN_TIMEOFDAY controls).
  @param level action level (tank level, junction pressure, or time in seconds)
  that triggers the control.
  @param[out] index index of the new control.
  @return an error code.
  */
  int  DLLEXPORT EN_addcontrol(EN_Project ph, int type, int linkIndex,
                 double setting, int nodeIndex, double level, int *index);
 
  /**
  @brief Deletes an existing simple control.
  @param ph an HYDRAULIC project handle.
  @param index the index of the control to delete (starting from 1).
  @return an error code.
  */
  int  DLLEXPORT EN_deletecontrol(EN_Project ph, int index);
 
  /**
  @brief Retrieves the properties of a simple control.
  @param ph an HYDRAULIC project handle.
  @param index the control's index (starting from 1).
  @param[out] type the type of control (see @ref EN_ControlType).
  @param[out] linkIndex the index of the link being controlled.
  @param[out] setting the control setting applied to the link.
  @param[out] nodeIndex the index of the node used to trigger the control
  (0 for \b EN_TIMER and  \b EN_TIMEOFDAY controls).
  @param[out] level the action level (tank level, junction pressure, or time in seconds)
  that triggers the control.
  @return an error code.
  */
  int  DLLEXPORT EN_getcontrol(EN_Project ph, int index, int *type, int *linkIndex,
                 double *setting, int *nodeIndex, double *level);
 
  /**
  @brief Sets the properties of an existing simple control.
  @param ph an HYDRAULIC project handle.
  @param index the control's index (starting from 1).
  @param type the type of control (see @ref EN_ControlType).
  @param linkIndex the index of the link being controlled.
  @param setting the control setting applied to the link.
  @param nodeIndex the index of the node used to trigger the control
  (0 for \b EN_TIMER and \b EN_TIMEOFDAY controls).
  @param level the action level (tank level, junction pressure, or time in seconds)
  that triggers the control.
  @return an error code.
  */
  int  DLLEXPORT EN_setcontrol(EN_Project ph, int index, int type, int linkIndex,
                 double setting, int nodeIndex, double level);
 
 
  /********************************************************************
 
  Rule-Based Controls Functions
 
  ********************************************************************/
 
  /**
  @brief Adds a new rule-based control to a project.
  @param ph an HYDRAULIC project handle.
  @param rule text of the rule following the format used in an HYDRAULIC input file.
  @return an error code.
 
  Consult the @ref RulesPage section of the @ref InpFile topic to learn about a
  rule's format. Each clause of the rule must end with a newline character <b>`\n`</b>.
  */
  int DLLEXPORT EN_addrule(EN_Project ph, char *rule);
 
  /**
  @brief Deletes an existing rule-based control.
  @param ph an HYDRAULIC project handle.
  @param index the index of the rule to be deleted (starting from 1).
  @return an error code.
  */
  int  DLLEXPORT EN_deleterule(EN_Project ph, int index);
 
  /**
  @brief Retrieves summary information about a rule-based control.
  @param ph an HYDRAULIC project handle.
  @param index the rule's index (starting from 1).
  @param[out] nPremises number of premises in the rule's IF section.
  @param[out] nThenActions number of actions in the rule's THEN section.
  @param[out] nElseActions number of actions in the rule's ELSE section.
  @param[out] priority the rule's priority value.
  @return an error code.
  */
  int  DLLEXPORT EN_getrule(EN_Project ph, int index, int *nPremises,
                 int *nThenActions, int *nElseActions, double *priority);
 
  /**
  @brief Gets the ID name of a rule-based control given its index.
  @param ph an HYDRAULIC project handle.
  @param index the rule's index (starting from 1).
  @param[out] out_id the rule's ID name.
  @return Error code.
 
  The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
  */
  int  DLLEXPORT EN_getruleID(EN_Project ph, int index, char *out_id);
 
  /**
  @brief Gets the properties of a premise in a rule-based control.
  @param ph an HYDRAULIC project handle.
  @param ruleIndex the rule's index (starting from 1).
  @param premiseIndex the position of the premise in the rule's list of premises
  (starting from 1).
  @param[out] logop the premise's logical operator ( \b IF = 1, \b AND = 2, \b OR = 3 ).
  @param[out] object the type of object the premise refers to (see @ref EN_RuleObject).
  @param[out] objIndex the index of the object (e.g. the index of a tank).
  @param[out] variable the object's variable being compared (see @ref EN_RuleVariable).
  @param[out] relop the premise's comparison operator (see @ref EN_RuleOperator).
  @param[out] status the status that the object's status is compared to
  (see @ref EN_RuleStatus).
  @param[out] value the value that the object's variable is compared to.
  @return an error code.
  */
  int  DLLEXPORT EN_getpremise(EN_Project ph, int ruleIndex, int premiseIndex,
                 int *logop,  int *object, int *objIndex, int *variable,
                 int *relop, int *status, double *value);
 
  /**
  @brief Sets the properties of a premise in a rule-based control.
  @param ph an HYDRAULIC project handle.
  @param ruleIndex the rule's index (starting from 1).
  @param premiseIndex the position of the premise in the rule's list of premises.
  @param logop the premise's logical operator ( \b IF = 1, \b AND = 2, \b OR = 3 ).
  @param object the type of object the premise refers to (see @ref EN_RuleObject).
  @param objIndex the index of the object (e.g. the index of a tank).
  @param variable the object's variable being compared (see @ref EN_RuleVariable).
  @param relop the premise's comparison operator (see @ref EN_RuleOperator).
  @param status the status that the object's status is compared to
  (see @ref EN_RuleStatus).
  @param value the value that the object's variable is compared to.
  @return an error code.
  */
  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);
 
  /**
  @brief Sets the index of an object in a premise of a rule-based control.
  @param ph an HYDRAULIC project handle.
  @param ruleIndex the rule's index (starting from 1).
  @param premiseIndex the premise's index (starting from 1).
  @param objIndex the index of the premise's object (e.g. the index of a tank).
  @return an error code.
  */
  int  DLLEXPORT EN_setpremiseindex(EN_Project ph, int ruleIndex, int premiseIndex,
                 int objIndex);
 
  /**
  @brief Sets the status being compared to in a premise of a rule-based control.
  @param ph an HYDRAULIC project handle.
  @param ruleIndex the rule's index (starting from 1).
  @param premiseIndex the premise's index (starting from 1).
  @param status the status that the premise's object status is compared to
  (see @ref EN_RuleStatus).
  @return an error code.
  */
  int  DLLEXPORT EN_setpremisestatus(EN_Project ph, int ruleIndex, int premiseIndex,
                 int status);
 
  /**
  @brief Sets the value in a premise of a rule-based control.
  @param ph an HYDRAULIC project handle.
  @param ruleIndex the rule's index (staring from 1).
  @param premiseIndex the premise's index (starting from 1).
  @param value The value that the premise's variable is compared to.
  @return an error code.
  */
  int  DLLEXPORT EN_setpremisevalue(EN_Project ph, int ruleIndex, int premiseIndex,
                 double value);
 
  /**
  @brief Gets the properties of a THEN action in a rule-based control.
  @param ph an HYDRAULIC project handle.
  @param ruleIndex the rule's index (starting from 1).
  @param actionIndex the index of the THEN action to retrieve (starting from 1).
  @param[out] linkIndex the index of the link in the action (starting from 1).
  @param[out] status the status assigned to the link (see @ref EN_RuleStatus)
  @param[out] setting the value assigned to the link's setting.
  @return an error code.
  */
  int  DLLEXPORT EN_getthenaction(EN_Project ph, int ruleIndex, int actionIndex,
                 int *linkIndex, int *status, double *setting);
 
  /**
  @brief Sets the properties of a THEN action in a rule-based control.
  @param ph an HYDRAULIC project handle.
  @param ruleIndex the rule's index (starting from 1).
  @param actionIndex the index of the THEN action to modify (starting from 1).
  @param linkIndex the index of the link in the action.
  @param status the new status assigned to the link (see @ref EN_RuleStatus).
  @param setting the new value assigned to the link's setting.
  @return an error code.
  */
  int  DLLEXPORT EN_setthenaction(EN_Project ph, int ruleIndex, int actionIndex,
                 int linkIndex, int status, double setting);
 
  /**
  @brief Gets the properties of an ELSE action in a rule-based control.
  @param ph an HYDRAULIC project handle.
  @param ruleIndex the rule's index (starting from 1).
  @param actionIndex the index of the ELSE action to retrieve (starting from 1).
  @param[out] linkIndex the index of the link in the action.
  @param[out] status the status assigned to the link (see @ref EN_RuleStatus).
  @param[out] setting the value assigned to the link's setting.
  @return an error code.
  */
  int  DLLEXPORT EN_getelseaction(EN_Project ph, int ruleIndex, int actionIndex,
                 int *linkIndex, int *status, double *setting);
 
  /**
  @brief Sets the properties of an ELSE action in a rule-based control.
  @param ph an HYDRAULIC project handle.
  @param ruleIndex the rule's index (starting from 1).
  @param actionIndex the index of the ELSE action being modified (starting from 1).
  @param linkIndex the index of the link in the action (starting from 1).
  @param status the new status assigned to the link (see @ref EN_RuleStatus)
  @param setting the new value assigned to the link's setting.
  @return an error code.
  */
  int  DLLEXPORT EN_setelseaction(EN_Project ph, int ruleIndex, int actionIndex,
                 int linkIndex, int status, double setting);
 
  /**
  @brief Sets the priority of a rule-based control.
  @param ph an HYDRAULIC project handle.
  @param index the rule's index (starting from 1).
  @param priority the priority value assigned to the rule.
  @return an error code.
  */
  int  DLLEXPORT EN_setrulepriority(EN_Project ph, int index, double priority);
 
 
 
  int DLLEXPORT EN_setinistatus(EN_Project ph, char*, char*);
 
 
  int DLLEXPORT EN_test(struct Sdemand d);
 
#if defined(__cplusplus)
}
#endif
 
#endif //EPANET2_2_H