Keeping legacy api in epanet2.h epanet2.c and moving new api to epanet2_2.h epanet.c
This commit is contained in:
@@ -16,7 +16,7 @@ node or link appearing in any simple or rule-based controls.
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "epanet2.h"
|
||||
#include "epanet2_2.h"
|
||||
|
||||
#define DATA_PATH_INP "./net1.inp"
|
||||
#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 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";
|
||||
|
||||
#ifndef NO_BOOST
|
||||
@@ -47,11 +47,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
EN_Project ph = NULL;
|
||||
EN_createproject(&ph);
|
||||
|
||||
|
||||
std::string path_inp = std::string(DATA_PATH_INP);
|
||||
std::string path_rpt = std::string(DATA_PATH_RPT);
|
||||
std::string path_out = std::string(DATA_PATH_OUT);
|
||||
|
||||
|
||||
error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), "");
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
@@ -66,7 +66,7 @@ int main(int argc, char *argv[])
|
||||
// Check that rules were added
|
||||
error = EN_getcount(ph, EN_RULECOUNT, &ruleCount);
|
||||
BOOST_REQUIRE(ruleCount == 3);
|
||||
|
||||
|
||||
// Check the number of clauses in rule 3
|
||||
error = EN_getrule(ph, 3, &nP, &nTA, &nEA, &priority);
|
||||
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 <string>
|
||||
#include "epanet2.h"
|
||||
#include "epanet2_2.h"
|
||||
|
||||
// NOTE: Project Home needs to be updated to run unit test
|
||||
#define DATA_PATH_INP "./net1.inp"
|
||||
@@ -41,12 +41,12 @@ BOOST_AUTO_TEST_CASE(test_demand_categories)
|
||||
char demand_category[] = "Demand category name";
|
||||
char demname[80];
|
||||
|
||||
|
||||
|
||||
int error = 0;
|
||||
int Nindex, ndem;
|
||||
|
||||
EN_Project ph = NULL;
|
||||
|
||||
|
||||
error = EN_createproject(&ph);
|
||||
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);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_CHECK(ndem == 1);
|
||||
|
||||
|
||||
error = EN_setdemandname(ph, Nindex, ndem, demand_category);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
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");
|
||||
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());
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
@@ -81,11 +81,11 @@ BOOST_AUTO_TEST_CASE(test_demand_categories)
|
||||
error = EN_getdemandname(ph, Nindex, ndem, demname);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_CHECK(check_string(demname, demand_category));
|
||||
|
||||
|
||||
error = EN_close(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_deleteproject(&ph);
|
||||
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 <string>
|
||||
#include "epanet2.h"
|
||||
#include "epanet2_2.h"
|
||||
|
||||
// NOTE: Project Home needs to be updated to run unit test
|
||||
#define DATA_PATH_INP "./net1.inp"
|
||||
@@ -35,11 +35,11 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
|
||||
long t, tstep;
|
||||
int i, ind, Lindex, Nindex, Cindex;
|
||||
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)
|
||||
EN_Project ph = NULL;
|
||||
EN_createproject(&ph);
|
||||
|
||||
|
||||
std::string path_inp = std::string(DATA_PATH_INP);
|
||||
std::string path_rpt = std::string(DATA_PATH_RPT);
|
||||
std::string path_out = std::string(DATA_PATH_OUT);
|
||||
@@ -59,19 +59,19 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
|
||||
do {
|
||||
error = EN_runH(ph, &t);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
|
||||
// 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);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
|
||||
error = EN_nextH(ph, &tstep);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
} while (tstep > 0);
|
||||
} while (tstep > 0);
|
||||
|
||||
error = EN_closeH(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
|
||||
error = EN_close(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
@@ -200,17 +200,17 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
|
||||
error = EN_runH(ph, &t);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
// 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);
|
||||
error = EN_nextH(ph, &tstep);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
} while (tstep > 0);
|
||||
error = EN_closeH(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
|
||||
error = EN_saveinpfile(ph, "net_builder.inp");
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
|
||||
error = EN_close(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_deleteproject(&ph);
|
||||
@@ -238,17 +238,17 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
} while (tstep > 0);
|
||||
|
||||
|
||||
error = EN_closeH(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
|
||||
error = EN_close(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
EN_deleteproject(&ph);
|
||||
EN_deleteproject(&ph);
|
||||
//---------------------------------------------------------------------
|
||||
// if we got this far we can compare results
|
||||
|
||||
|
||||
// compare the original to the build & saved network
|
||||
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 "epanet2.h"
|
||||
#include "epanet2_2.h"
|
||||
|
||||
#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 <string>
|
||||
#include "epanet2.h"
|
||||
#include "epanet2_2.h"
|
||||
|
||||
#define DATA_PATH_INP "./net1.inp"
|
||||
#define DATA_PATH_RPT "./test.rpt"
|
||||
@@ -37,13 +37,13 @@ int main(int argc, char *argv[])
|
||||
string path_rpt(DATA_PATH_RPT);
|
||||
string path_out(DATA_PATH_OUT);
|
||||
string inp_save("net1_setid.inp");
|
||||
|
||||
|
||||
int error = 0;
|
||||
int index;
|
||||
|
||||
EN_Project ph = NULL;
|
||||
EN_createproject(&ph);
|
||||
|
||||
|
||||
error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), "");
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
@@ -74,17 +74,17 @@ int main(int argc, char *argv[])
|
||||
error = EN_close(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
EN_deleteproject(&ph);
|
||||
|
||||
|
||||
// Re-open the saved project
|
||||
EN_createproject(&ph);
|
||||
error = EN_open(ph, inp_save.c_str(), path_rpt.c_str(), "");
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
|
||||
// Check that 3rd node has its new name
|
||||
error = EN_getnodeindex(ph, newid_2, &index);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_REQUIRE(index == 3);
|
||||
|
||||
|
||||
// Check that 3rd link has its new name
|
||||
error = EN_getlinkindex(ph, newid_4, &index);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
@@ -13,7 +13,7 @@ of the PRV 121 should be 100.
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include <string>
|
||||
#include "epanet2.h"
|
||||
#include "epanet2_2.h"
|
||||
|
||||
#define DATA_PATH_INP "./net1.inp"
|
||||
#define DATA_PATH_RPT "./test.rpt"
|
||||
@@ -31,11 +31,11 @@ BOOST_AUTO_TEST_CASE(test_setlinktype)
|
||||
|
||||
EN_Project ph = NULL;
|
||||
EN_createproject(&ph);
|
||||
|
||||
|
||||
std::string path_inp = std::string(DATA_PATH_INP);
|
||||
std::string path_rpt = std::string(DATA_PATH_RPT);
|
||||
std::string path_out = std::string(DATA_PATH_OUT);
|
||||
|
||||
|
||||
error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), "");
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include <string>
|
||||
#include "epanet2.h"
|
||||
#include "epanet2_2.h"
|
||||
|
||||
// NOTE: Project Home needs to be updated to run unit test
|
||||
#define DATA_PATH_INP "./net1.inp"
|
||||
|
||||
Reference in New Issue
Block a user