Keeping legacy api in epanet2.h epanet2.c and moving new api to epanet2_2.h epanet.c
This commit is contained in:
1248
include/epanet2.h
1248
include/epanet2.h
File diff suppressed because it is too large
Load Diff
1170
include/epanet2_1.h
1170
include/epanet2_1.h
File diff suppressed because it is too large
Load Diff
246
include/epanet2_2.h
Normal file
246
include/epanet2_2.h
Normal file
@@ -0,0 +1,246 @@
|
|||||||
|
/** @file epanet2.h
|
||||||
|
@see http://github.com/openwateranalytics/epanet
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
******************************************************************************
|
||||||
|
Project: OWA EPANET
|
||||||
|
Version: 2.2
|
||||||
|
Module: epanet2.h
|
||||||
|
Description: symbolic constants and function declarations for the EPANET API
|
||||||
|
Authors: see AUTHORS
|
||||||
|
Copyright: see AUTHORS
|
||||||
|
License: see LICENSE
|
||||||
|
Last Updated: 11/29/2018
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EPANET2_2_H
|
||||||
|
#define EPANET2_2_H
|
||||||
|
|
||||||
|
// the toolkit can be compiled with support for double-precision as well.
|
||||||
|
// just make sure that you use the correct #define in your client code.
|
||||||
|
#ifndef EN_API_FLOAT_TYPE
|
||||||
|
#define EN_API_FLOAT_TYPE float
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_GENX
|
||||||
|
#include "epanet2_export.h"
|
||||||
|
#else
|
||||||
|
// --- define WINDOWS
|
||||||
|
#undef WINDOWS
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define WINDOWS
|
||||||
|
#endif
|
||||||
|
#ifdef __WIN32__
|
||||||
|
#define WINDOWS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// --- define DLLEXPORT
|
||||||
|
#ifndef DLLEXPORT
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define DLLEXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define DLLEXPORT __declspec(dllexport) __stdcall
|
||||||
|
#endif // __cplusplus
|
||||||
|
#elif defined(CYGWIN)
|
||||||
|
#define DLLEXPORT __stdcall
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define DLLEXPORT
|
||||||
|
#else
|
||||||
|
#define DLLEXPORT
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define DLLEXPORT
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "epanet2_enums.h"
|
||||||
|
|
||||||
|
|
||||||
|
// --- Declare the EPANET toolkit functions
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The EPANET Project wrapper object
|
||||||
|
*/
|
||||||
|
typedef struct Project *EN_Project;
|
||||||
|
|
||||||
|
/********************************************************************
|
||||||
|
|
||||||
|
Threadsafe versions of all EPANET functions
|
||||||
|
|
||||||
|
********************************************************************/
|
||||||
|
|
||||||
|
int DLLEXPORT EN_createproject(EN_Project *ph);
|
||||||
|
int DLLEXPORT EN_deleteproject(EN_Project *ph);
|
||||||
|
int DLLEXPORT EN_runproject(EN_Project ph, const char *f1, const char *f2, const char *f3,
|
||||||
|
void (*pviewprog)(char *));
|
||||||
|
int DLLEXPORT EN_init(EN_Project ph, const char *rptFile, const char *outFile,
|
||||||
|
EN_FlowUnits unitsType, EN_HeadLossType headLossType);
|
||||||
|
int DLLEXPORT EN_open(EN_Project ph, const char *inpFile,
|
||||||
|
const char *rptFile, const char *binOutFile);
|
||||||
|
int DLLEXPORT EN_saveinpfile(EN_Project ph, const char *filename);
|
||||||
|
int DLLEXPORT EN_close(EN_Project ph);
|
||||||
|
|
||||||
|
int DLLEXPORT EN_solveH(EN_Project ph);
|
||||||
|
int DLLEXPORT EN_saveH(EN_Project ph);
|
||||||
|
int DLLEXPORT EN_openH(EN_Project ph);
|
||||||
|
int DLLEXPORT EN_initH(EN_Project ph, int saveFlag);
|
||||||
|
int DLLEXPORT EN_runH(EN_Project ph, long *currentTime);
|
||||||
|
int DLLEXPORT EN_nextH(EN_Project ph, long *tStep);
|
||||||
|
int DLLEXPORT EN_closeH(EN_Project ph);
|
||||||
|
int DLLEXPORT EN_savehydfile(EN_Project ph, char *filename);
|
||||||
|
int DLLEXPORT EN_usehydfile(EN_Project ph, char *filename);
|
||||||
|
|
||||||
|
int DLLEXPORT EN_solveQ(EN_Project ph);
|
||||||
|
int DLLEXPORT EN_openQ(EN_Project ph);
|
||||||
|
int DLLEXPORT EN_initQ(EN_Project ph, int saveFlag);
|
||||||
|
int DLLEXPORT EN_runQ(EN_Project ph, long *currentTime);
|
||||||
|
int DLLEXPORT EN_nextQ(EN_Project ph, long *tStep);
|
||||||
|
int DLLEXPORT EN_stepQ(EN_Project ph, long *timeLeft);
|
||||||
|
int DLLEXPORT EN_closeQ(EN_Project ph);
|
||||||
|
|
||||||
|
int DLLEXPORT EN_writeline(EN_Project ph, char *line);
|
||||||
|
int DLLEXPORT EN_report(EN_Project ph);
|
||||||
|
int DLLEXPORT EN_resetreport(EN_Project ph);
|
||||||
|
int DLLEXPORT EN_setreport(EN_Project ph, char *reportCommand);
|
||||||
|
int DLLEXPORT EN_setstatusreport(EN_Project ph, int code);
|
||||||
|
int DLLEXPORT EN_getversion(int *version);
|
||||||
|
int DLLEXPORT EN_getcount(EN_Project ph, EN_CountType code, int *count);
|
||||||
|
int DLLEXPORT EN_geterror(int errcode, char *errmsg, int maxLen);
|
||||||
|
int DLLEXPORT EN_getstatistic(EN_Project ph, int code, EN_API_FLOAT_TYPE* value);
|
||||||
|
|
||||||
|
int DLLEXPORT EN_getoption(EN_Project ph, EN_Option opt, EN_API_FLOAT_TYPE *value);
|
||||||
|
int DLLEXPORT EN_setoption(EN_Project ph, int code, EN_API_FLOAT_TYPE v);
|
||||||
|
int DLLEXPORT EN_getflowunits(EN_Project ph, int *code);
|
||||||
|
int DLLEXPORT EN_setflowunits(EN_Project ph, int code);
|
||||||
|
int DLLEXPORT EN_gettimeparam(EN_Project ph, int code, long *value);
|
||||||
|
int DLLEXPORT EN_settimeparam(EN_Project ph, int code, long value);
|
||||||
|
int DLLEXPORT EN_getqualinfo(EN_Project ph, int *qualcode, char *chemname,
|
||||||
|
char *chemunits, int *tracenode);
|
||||||
|
int DLLEXPORT EN_getqualtype(EN_Project ph, int *qualcode, int *tracenode);
|
||||||
|
int DLLEXPORT EN_setqualtype(EN_Project ph, int qualcode, char *chemname,
|
||||||
|
char *chemunits, char *tracenode);
|
||||||
|
|
||||||
|
int DLLEXPORT EN_addnode(EN_Project ph, char *id, EN_NodeType nodeType);
|
||||||
|
int DLLEXPORT EN_deletenode(EN_Project ph, int index, int actionCode);
|
||||||
|
int DLLEXPORT EN_getnodeindex(EN_Project ph, char *id, int *index);
|
||||||
|
int DLLEXPORT EN_getnodeid(EN_Project ph, int index, char *id);
|
||||||
|
int DLLEXPORT EN_setnodeid(EN_Project ph, int index, char *newid);
|
||||||
|
int DLLEXPORT EN_getnodetype(EN_Project ph, int index, int *code);
|
||||||
|
int DLLEXPORT EN_getnodevalue(EN_Project ph, int index, int code, EN_API_FLOAT_TYPE *value);
|
||||||
|
int DLLEXPORT EN_setnodevalue(EN_Project ph, int index, int code, EN_API_FLOAT_TYPE v);
|
||||||
|
int DLLEXPORT EN_getcoord(EN_Project ph, int index, EN_API_FLOAT_TYPE *x,
|
||||||
|
EN_API_FLOAT_TYPE *y);
|
||||||
|
int DLLEXPORT EN_setcoord(EN_Project ph, int index, EN_API_FLOAT_TYPE x,
|
||||||
|
EN_API_FLOAT_TYPE y);
|
||||||
|
|
||||||
|
int DLLEXPORT EN_getdemandmodel(EN_Project ph, int *type, EN_API_FLOAT_TYPE *pmin,
|
||||||
|
EN_API_FLOAT_TYPE *preq, EN_API_FLOAT_TYPE *pexp);
|
||||||
|
int DLLEXPORT EN_setdemandmodel(EN_Project ph, int type, EN_API_FLOAT_TYPE pmin,
|
||||||
|
EN_API_FLOAT_TYPE preq, EN_API_FLOAT_TYPE pexp);
|
||||||
|
int DLLEXPORT EN_getnumdemands(EN_Project ph, int nodeIndex, int *numDemands);
|
||||||
|
int DLLEXPORT EN_getbasedemand(EN_Project ph, int nodeIndex,
|
||||||
|
int demandIndex, EN_API_FLOAT_TYPE *baseDemand);
|
||||||
|
int DLLEXPORT EN_setbasedemand(EN_Project ph, int nodeIndex,
|
||||||
|
int demandIndex, EN_API_FLOAT_TYPE baseDemand);
|
||||||
|
int DLLEXPORT EN_getdemandpattern(EN_Project ph, int nodeIndex, int demandIndex,
|
||||||
|
int *pattIndex);
|
||||||
|
int DLLEXPORT EN_setdemandpattern(EN_Project ph, int nodeIndex, int demandIndex,
|
||||||
|
int patIndex);
|
||||||
|
int DLLEXPORT EN_getdemandname(EN_Project ph, int nodeIndex, int demandIdx,
|
||||||
|
char *demandName);
|
||||||
|
int DLLEXPORT EN_setdemandname(EN_Project ph, int nodeIndex, int demandIdx,
|
||||||
|
char *demandName);
|
||||||
|
|
||||||
|
int DLLEXPORT EN_addlink(EN_Project ph, char *id, EN_LinkType linkType,
|
||||||
|
char *fromNode, char *toNode);
|
||||||
|
int DLLEXPORT EN_deletelink(EN_Project ph, int index, int actionCode);
|
||||||
|
int DLLEXPORT EN_getlinkindex(EN_Project ph, char *id, int *index);
|
||||||
|
int DLLEXPORT EN_getlinkid(EN_Project ph, int index, char *id);
|
||||||
|
int DLLEXPORT EN_setlinkid(EN_Project ph, int index, char *newid);
|
||||||
|
int DLLEXPORT EN_getlinktype(EN_Project ph, int index, EN_LinkType *code);
|
||||||
|
int DLLEXPORT EN_setlinktype(EN_Project ph, int *index, EN_LinkType type, int actionCode);
|
||||||
|
int DLLEXPORT EN_getlinknodes(EN_Project ph, int index, int *node1, int *node2);
|
||||||
|
int DLLEXPORT EN_setlinknodes(EN_Project ph, int index, int node1, int node2);
|
||||||
|
int DLLEXPORT EN_getlinkvalue(EN_Project ph, int index, EN_LinkProperty code,
|
||||||
|
EN_API_FLOAT_TYPE *value);
|
||||||
|
int DLLEXPORT EN_setlinkvalue(EN_Project ph, int index, int code, EN_API_FLOAT_TYPE v);
|
||||||
|
|
||||||
|
int DLLEXPORT EN_getpumptype(EN_Project ph, int linkIndex, int *outType);
|
||||||
|
int DLLEXPORT EN_getheadcurveindex(EN_Project ph, int pumpIndex, int *curveIndex);
|
||||||
|
int DLLEXPORT EN_setheadcurveindex(EN_Project ph, int pumpIndex, int curveIndex);
|
||||||
|
|
||||||
|
int DLLEXPORT EN_addpattern(EN_Project ph, char *id);
|
||||||
|
int DLLEXPORT EN_getpatternindex(EN_Project ph, char *id, int *index);
|
||||||
|
int DLLEXPORT EN_getpatternid(EN_Project ph, int index, char *id);
|
||||||
|
int DLLEXPORT EN_getpatternlen(EN_Project ph, int index, int *len);
|
||||||
|
int DLLEXPORT EN_getpatternvalue(EN_Project ph, int index, int period, EN_API_FLOAT_TYPE *value);
|
||||||
|
int DLLEXPORT EN_setpatternvalue(EN_Project ph, int index, int period, EN_API_FLOAT_TYPE value);
|
||||||
|
int DLLEXPORT EN_getaveragepatternvalue(EN_Project ph, int index, EN_API_FLOAT_TYPE *value);
|
||||||
|
int DLLEXPORT EN_setpattern(EN_Project ph, int index, EN_API_FLOAT_TYPE *f, int len);
|
||||||
|
|
||||||
|
int DLLEXPORT EN_addcurve(EN_Project ph, char *id);
|
||||||
|
int DLLEXPORT EN_getcurveindex(EN_Project ph, char *id, int *index);
|
||||||
|
int DLLEXPORT EN_getcurveid(EN_Project ph, int index, char *id);
|
||||||
|
int DLLEXPORT EN_getcurvelen(EN_Project ph, int index, int *len);
|
||||||
|
int DLLEXPORT EN_getcurvetype(EN_Project ph, int curveIndex, int *outType);
|
||||||
|
int DLLEXPORT EN_getcurvevalue(EN_Project ph, int curveIndex, int pointIndex,
|
||||||
|
EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y);
|
||||||
|
int DLLEXPORT EN_setcurvevalue(EN_Project ph, int curveIndex, int pointIndex,
|
||||||
|
EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y);
|
||||||
|
int DLLEXPORT EN_getcurve(EN_Project ph, int curveIndex, char* id,
|
||||||
|
int *nValues, EN_API_FLOAT_TYPE **xValues,
|
||||||
|
EN_API_FLOAT_TYPE **yValues);
|
||||||
|
int DLLEXPORT EN_setcurve(EN_Project ph, int index, EN_API_FLOAT_TYPE *x,
|
||||||
|
EN_API_FLOAT_TYPE *y, int len);
|
||||||
|
|
||||||
|
int DLLEXPORT EN_addcontrol(EN_Project ph, int *cindex, int ctype, int lindex,
|
||||||
|
EN_API_FLOAT_TYPE setting, int nindex, EN_API_FLOAT_TYPE level);
|
||||||
|
int DLLEXPORT EN_deletecontrol(EN_Project ph, int index);
|
||||||
|
int DLLEXPORT EN_getcontrol(EN_Project ph, int controlIndex,
|
||||||
|
int *controlType, int *linkIndex, EN_API_FLOAT_TYPE *setting,
|
||||||
|
int *nodeIndex, EN_API_FLOAT_TYPE *level);
|
||||||
|
int DLLEXPORT EN_setcontrol(EN_Project ph, int cindex, int ctype, int lindex,
|
||||||
|
EN_API_FLOAT_TYPE setting, int nindex, EN_API_FLOAT_TYPE level);
|
||||||
|
|
||||||
|
int DLLEXPORT EN_addrule(EN_Project ph, char *rule);
|
||||||
|
int DLLEXPORT EN_deleterule(EN_Project ph, int index);
|
||||||
|
int DLLEXPORT EN_getrule(EN_Project ph, int index, int *nPremises,
|
||||||
|
int *nThenActions, int *nElseActions, EN_API_FLOAT_TYPE *priority);
|
||||||
|
int DLLEXPORT EN_getruleID(EN_Project ph, int index, char* id);
|
||||||
|
int DLLEXPORT EN_getpremise(EN_Project ph, int ruleIndex, int premiseIndex,
|
||||||
|
int *logop, int *object, int *objIndex, int *variable, int *relop,
|
||||||
|
int *status, EN_API_FLOAT_TYPE *value);
|
||||||
|
int DLLEXPORT EN_setpremise(EN_Project ph, int ruleIndex, int premiseIndex,
|
||||||
|
int logop, int object, int objIndex, int variable, int relop,
|
||||||
|
int status, EN_API_FLOAT_TYPE value);
|
||||||
|
int DLLEXPORT EN_setpremiseindex(EN_Project ph, int ruleIndex,
|
||||||
|
int premiseIndex, int objIndex);
|
||||||
|
int DLLEXPORT EN_setpremisestatus(EN_Project ph, int ruleIndex,
|
||||||
|
int premiseIndex, int status);
|
||||||
|
int DLLEXPORT EN_setpremisevalue(EN_Project ph, int ruleIndex,
|
||||||
|
int premiseIndex, EN_API_FLOAT_TYPE value);
|
||||||
|
int DLLEXPORT EN_getthenaction(EN_Project ph, int ruleIndex, int actionIndex,
|
||||||
|
int *linkIndex, int *status, EN_API_FLOAT_TYPE *setting);
|
||||||
|
int DLLEXPORT EN_setthenaction(EN_Project ph, int ruleIndex, int actionIndex,
|
||||||
|
int linkIndex, int status, EN_API_FLOAT_TYPE setting);
|
||||||
|
int DLLEXPORT EN_getelseaction(EN_Project ph, int ruleIndex, int actionIndex,
|
||||||
|
int *linkIndex, int *status, EN_API_FLOAT_TYPE *setting);
|
||||||
|
int DLLEXPORT EN_setelseaction(EN_Project ph, int ruleIndex, int actionIndex,
|
||||||
|
int linkIndex, int status, EN_API_FLOAT_TYPE setting);
|
||||||
|
int DLLEXPORT EN_setrulepriority(EN_Project ph, int index, EN_API_FLOAT_TYPE priority);
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //EPANET2_2_H
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "epanet2_1.h"
|
#include "epanet2.h"
|
||||||
|
|
||||||
#define MAXMSG 255 /* Max. # characters in message text */
|
#define MAXMSG 255 /* Max. # characters in message text */
|
||||||
#define MAXWARNCODE 99
|
#define MAXWARNCODE 99
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "epanet2.h"
|
#include "epanet2_2.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "funcs.h"
|
#include "funcs.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
Project: OWA EPANET
|
Project: OWA EPANET
|
||||||
Version: 2.2
|
Version: 2.2
|
||||||
Module: epanet.c
|
Module: epanet.c
|
||||||
Description: implementation of the EPANET 2.1 API functions
|
Description: implementation of the legacy EPANET API functions
|
||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
@@ -15,8 +15,8 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "funcs.h"
|
#include "funcs.h"
|
||||||
|
|
||||||
#include "epanet2_1.h"
|
|
||||||
#include "epanet2.h"
|
#include "epanet2.h"
|
||||||
|
#include "epanet2_2.h"
|
||||||
|
|
||||||
|
|
||||||
// This single global variable is used only when the library is called
|
// This single global variable is used only when the library is called
|
||||||
@@ -16,7 +16,7 @@ node or link appearing in any simple or rule-based controls.
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "epanet2.h"
|
#include "epanet2_2.h"
|
||||||
|
|
||||||
#define DATA_PATH_INP "./net1.inp"
|
#define DATA_PATH_INP "./net1.inp"
|
||||||
#define DATA_PATH_RPT "./test.rpt"
|
#define DATA_PATH_RPT "./test.rpt"
|
||||||
@@ -30,7 +30,7 @@ using namespace std;
|
|||||||
|
|
||||||
char R1[] = "RULE 1 \n IF NODE 2 LEVEL < 100 \n THEN LINK 9 STATUS = OPEN";
|
char R1[] = "RULE 1 \n IF NODE 2 LEVEL < 100 \n THEN LINK 9 STATUS = OPEN";
|
||||||
char R2[] = "RULE 2\nIF SYSTEM TIME = 4\nTHEN LINK 9 STATUS = CLOSED\nAND LINK 31 STATUS = CLOSED";
|
char R2[] = "RULE 2\nIF SYSTEM TIME = 4\nTHEN LINK 9 STATUS = CLOSED\nAND LINK 31 STATUS = CLOSED";
|
||||||
char R3[] = "RULE 3\nIF NODE 23 PRESSURE ABOVE 140\nAND NODE 2 LEVEL > 120\n"
|
char R3[] = "RULE 3\nIF NODE 23 PRESSURE ABOVE 140\nAND NODE 2 LEVEL > 120\n"
|
||||||
"THEN LINK 113 STATUS = CLOSED\nELSE LINK 22 STATUS = CLOSED";
|
"THEN LINK 113 STATUS = CLOSED\nELSE LINK 22 STATUS = CLOSED";
|
||||||
|
|
||||||
#ifndef NO_BOOST
|
#ifndef NO_BOOST
|
||||||
@@ -47,11 +47,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
EN_Project ph = NULL;
|
EN_Project ph = NULL;
|
||||||
EN_createproject(&ph);
|
EN_createproject(&ph);
|
||||||
|
|
||||||
std::string path_inp = std::string(DATA_PATH_INP);
|
std::string path_inp = std::string(DATA_PATH_INP);
|
||||||
std::string path_rpt = std::string(DATA_PATH_RPT);
|
std::string path_rpt = std::string(DATA_PATH_RPT);
|
||||||
std::string path_out = std::string(DATA_PATH_OUT);
|
std::string path_out = std::string(DATA_PATH_OUT);
|
||||||
|
|
||||||
error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), "");
|
error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), "");
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ int main(int argc, char *argv[])
|
|||||||
// Check that rules were added
|
// Check that rules were added
|
||||||
error = EN_getcount(ph, EN_RULECOUNT, &ruleCount);
|
error = EN_getcount(ph, EN_RULECOUNT, &ruleCount);
|
||||||
BOOST_REQUIRE(ruleCount == 3);
|
BOOST_REQUIRE(ruleCount == 3);
|
||||||
|
|
||||||
// Check the number of clauses in rule 3
|
// Check the number of clauses in rule 3
|
||||||
error = EN_getrule(ph, 3, &nP, &nTA, &nEA, &priority);
|
error = EN_getrule(ph, 3, &nP, &nTA, &nEA, &priority);
|
||||||
BOOST_REQUIRE(nP == 2);
|
BOOST_REQUIRE(nP == 2);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ A demand category name is set, the network is saved, reopened and the new demand
|
|||||||
#include <boost/test/included/unit_test.hpp>
|
#include <boost/test/included/unit_test.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "epanet2.h"
|
#include "epanet2_2.h"
|
||||||
|
|
||||||
// NOTE: Project Home needs to be updated to run unit test
|
// NOTE: Project Home needs to be updated to run unit test
|
||||||
#define DATA_PATH_INP "./net1.inp"
|
#define DATA_PATH_INP "./net1.inp"
|
||||||
@@ -41,12 +41,12 @@ BOOST_AUTO_TEST_CASE(test_demand_categories)
|
|||||||
char demand_category[] = "Demand category name";
|
char demand_category[] = "Demand category name";
|
||||||
char demname[80];
|
char demname[80];
|
||||||
|
|
||||||
|
|
||||||
int error = 0;
|
int error = 0;
|
||||||
int Nindex, ndem;
|
int Nindex, ndem;
|
||||||
|
|
||||||
EN_Project ph = NULL;
|
EN_Project ph = NULL;
|
||||||
|
|
||||||
error = EN_createproject(&ph);
|
error = EN_createproject(&ph);
|
||||||
error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), path_out.c_str());
|
error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), path_out.c_str());
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(test_demand_categories)
|
|||||||
error = EN_getnumdemands(ph, Nindex, &ndem);
|
error = EN_getnumdemands(ph, Nindex, &ndem);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
BOOST_CHECK(ndem == 1);
|
BOOST_CHECK(ndem == 1);
|
||||||
|
|
||||||
error = EN_setdemandname(ph, Nindex, ndem, demand_category);
|
error = EN_setdemandname(ph, Nindex, ndem, demand_category);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
error = EN_saveinpfile(ph, inp_save.c_str());
|
error = EN_saveinpfile(ph, inp_save.c_str());
|
||||||
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(test_demand_categories)
|
|||||||
|
|
||||||
BOOST_TEST_CHECKPOINT("Reopening saved input file");
|
BOOST_TEST_CHECKPOINT("Reopening saved input file");
|
||||||
error = EN_createproject(&ph);
|
error = EN_createproject(&ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
error = EN_open(ph, inp_save.c_str(), path_rpt.c_str(), path_out.c_str());
|
error = EN_open(ph, inp_save.c_str(), path_rpt.c_str(), path_out.c_str());
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
@@ -81,11 +81,11 @@ BOOST_AUTO_TEST_CASE(test_demand_categories)
|
|||||||
error = EN_getdemandname(ph, Nindex, ndem, demname);
|
error = EN_getdemandname(ph, Nindex, ndem, demname);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
BOOST_CHECK(check_string(demname, demand_category));
|
BOOST_CHECK(check_string(demname, demand_category));
|
||||||
|
|
||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
error = EN_deleteproject(&ph);
|
error = EN_deleteproject(&ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ The test ends with a check that the three head values are equal.
|
|||||||
#include <boost/test/included/unit_test.hpp>
|
#include <boost/test/included/unit_test.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "epanet2.h"
|
#include "epanet2_2.h"
|
||||||
|
|
||||||
// NOTE: Project Home needs to be updated to run unit test
|
// NOTE: Project Home needs to be updated to run unit test
|
||||||
#define DATA_PATH_INP "./net1.inp"
|
#define DATA_PATH_INP "./net1.inp"
|
||||||
@@ -35,11 +35,11 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
|
|||||||
long t, tstep;
|
long t, tstep;
|
||||||
int i, ind, Lindex, Nindex, Cindex;
|
int i, ind, Lindex, Nindex, Cindex;
|
||||||
float h_orig, h_build, h_build_loaded;
|
float h_orig, h_build, h_build_loaded;
|
||||||
|
|
||||||
// first we load Net1.inp, run it and record the head in Tank 2 at the end of the simulation (h_orig)
|
// first we load Net1.inp, run it and record the head in Tank 2 at the end of the simulation (h_orig)
|
||||||
EN_Project ph = NULL;
|
EN_Project ph = NULL;
|
||||||
EN_createproject(&ph);
|
EN_createproject(&ph);
|
||||||
|
|
||||||
std::string path_inp = std::string(DATA_PATH_INP);
|
std::string path_inp = std::string(DATA_PATH_INP);
|
||||||
std::string path_rpt = std::string(DATA_PATH_RPT);
|
std::string path_rpt = std::string(DATA_PATH_RPT);
|
||||||
std::string path_out = std::string(DATA_PATH_OUT);
|
std::string path_out = std::string(DATA_PATH_OUT);
|
||||||
@@ -59,19 +59,19 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
|
|||||||
do {
|
do {
|
||||||
error = EN_runH(ph, &t);
|
error = EN_runH(ph, &t);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
// this is the head at the end of the simulation after loading the original Net1.inp
|
// this is the head at the end of the simulation after loading the original Net1.inp
|
||||||
error = EN_getnodevalue(ph, Nindex, EN_HEAD, &h_orig);
|
error = EN_getnodevalue(ph, Nindex, EN_HEAD, &h_orig);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
error = EN_nextH(ph, &tstep);
|
error = EN_nextH(ph, &tstep);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
} while (tstep > 0);
|
} while (tstep > 0);
|
||||||
|
|
||||||
error = EN_closeH(ph);
|
error = EN_closeH(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
@@ -200,17 +200,17 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
|
|||||||
error = EN_runH(ph, &t);
|
error = EN_runH(ph, &t);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
// this is the head at the end of the simulation after building the network *without* saving it to file
|
// this is the head at the end of the simulation after building the network *without* saving it to file
|
||||||
error = EN_getnodevalue(ph, Nindex, EN_HEAD, &h_build);
|
error = EN_getnodevalue(ph, Nindex, EN_HEAD, &h_build);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
error = EN_nextH(ph, &tstep);
|
error = EN_nextH(ph, &tstep);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
} while (tstep > 0);
|
} while (tstep > 0);
|
||||||
error = EN_closeH(ph);
|
error = EN_closeH(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
error = EN_saveinpfile(ph, "net_builder.inp");
|
error = EN_saveinpfile(ph, "net_builder.inp");
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
error = EN_deleteproject(&ph);
|
error = EN_deleteproject(&ph);
|
||||||
@@ -238,17 +238,17 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
|
|||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
} while (tstep > 0);
|
} while (tstep > 0);
|
||||||
|
|
||||||
error = EN_closeH(ph);
|
error = EN_closeH(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(&ph);
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// if we got this far we can compare results
|
// if we got this far we can compare results
|
||||||
|
|
||||||
// compare the original to the build & saved network
|
// compare the original to the build & saved network
|
||||||
BOOST_REQUIRE(h_orig == h_build_loaded);
|
BOOST_REQUIRE(h_orig == h_build_loaded);
|
||||||
|
|
||||||
@@ -257,4 +257,4 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
|
|
||||||
#include "epanet2.h"
|
#include "epanet2_2.h"
|
||||||
|
|
||||||
#define NUM_THREADS 2
|
#define NUM_THREADS 2
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ A node and link name are changed, the network is saved, reopened and the new nam
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "epanet2.h"
|
#include "epanet2_2.h"
|
||||||
|
|
||||||
#define DATA_PATH_INP "./net1.inp"
|
#define DATA_PATH_INP "./net1.inp"
|
||||||
#define DATA_PATH_RPT "./test.rpt"
|
#define DATA_PATH_RPT "./test.rpt"
|
||||||
@@ -37,13 +37,13 @@ int main(int argc, char *argv[])
|
|||||||
string path_rpt(DATA_PATH_RPT);
|
string path_rpt(DATA_PATH_RPT);
|
||||||
string path_out(DATA_PATH_OUT);
|
string path_out(DATA_PATH_OUT);
|
||||||
string inp_save("net1_setid.inp");
|
string inp_save("net1_setid.inp");
|
||||||
|
|
||||||
int error = 0;
|
int error = 0;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
EN_Project ph = NULL;
|
EN_Project ph = NULL;
|
||||||
EN_createproject(&ph);
|
EN_createproject(&ph);
|
||||||
|
|
||||||
error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), "");
|
error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), "");
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
@@ -74,17 +74,17 @@ int main(int argc, char *argv[])
|
|||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(&ph);
|
||||||
|
|
||||||
// Re-open the saved project
|
// Re-open the saved project
|
||||||
EN_createproject(&ph);
|
EN_createproject(&ph);
|
||||||
error = EN_open(ph, inp_save.c_str(), path_rpt.c_str(), "");
|
error = EN_open(ph, inp_save.c_str(), path_rpt.c_str(), "");
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
// Check that 3rd node has its new name
|
// Check that 3rd node has its new name
|
||||||
error = EN_getnodeindex(ph, newid_2, &index);
|
error = EN_getnodeindex(ph, newid_2, &index);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
BOOST_REQUIRE(index == 3);
|
BOOST_REQUIRE(index == 3);
|
||||||
|
|
||||||
// Check that 3rd link has its new name
|
// Check that 3rd link has its new name
|
||||||
error = EN_getlinkindex(ph, newid_4, &index);
|
error = EN_getlinkindex(ph, newid_4, &index);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ of the PRV 121 should be 100.
|
|||||||
#include <boost/test/included/unit_test.hpp>
|
#include <boost/test/included/unit_test.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "epanet2.h"
|
#include "epanet2_2.h"
|
||||||
|
|
||||||
#define DATA_PATH_INP "./net1.inp"
|
#define DATA_PATH_INP "./net1.inp"
|
||||||
#define DATA_PATH_RPT "./test.rpt"
|
#define DATA_PATH_RPT "./test.rpt"
|
||||||
@@ -31,11 +31,11 @@ BOOST_AUTO_TEST_CASE(test_setlinktype)
|
|||||||
|
|
||||||
EN_Project ph = NULL;
|
EN_Project ph = NULL;
|
||||||
EN_createproject(&ph);
|
EN_createproject(&ph);
|
||||||
|
|
||||||
std::string path_inp = std::string(DATA_PATH_INP);
|
std::string path_inp = std::string(DATA_PATH_INP);
|
||||||
std::string path_rpt = std::string(DATA_PATH_RPT);
|
std::string path_rpt = std::string(DATA_PATH_RPT);
|
||||||
std::string path_out = std::string(DATA_PATH_OUT);
|
std::string path_out = std::string(DATA_PATH_OUT);
|
||||||
|
|
||||||
error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), "");
|
error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), "");
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include <boost/test/included/unit_test.hpp>
|
#include <boost/test/included/unit_test.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "epanet2.h"
|
#include "epanet2_2.h"
|
||||||
|
|
||||||
// NOTE: Project Home needs to be updated to run unit test
|
// NOTE: Project Home needs to be updated to run unit test
|
||||||
#define DATA_PATH_INP "./net1.inp"
|
#define DATA_PATH_INP "./net1.inp"
|
||||||
|
|||||||
Reference in New Issue
Block a user