Merge branch 'dev' into pr86
This commit is contained in:
@@ -75,12 +75,11 @@ source_group("Library" FILES ${EPANET_LIB_ALL})
|
|||||||
|
|
||||||
|
|
||||||
# the shared library
|
# the shared library
|
||||||
add_library(epanet SHARED ${EPANET_SOURCES}) #${EPANET_API_HEADER})
|
add_library(epanet SHARED ${EPANET_SOURCES})
|
||||||
target_include_directories(epanet PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
target_include_directories(epanet PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
|
|
||||||
# create export lib so we can link against dll using Visual Studio
|
# create export lib so we can link against dll using Visual Studio
|
||||||
add_definitions(-D WITH_GENX)
|
|
||||||
include(GenerateExportHeader)
|
include(GenerateExportHeader)
|
||||||
GENERATE_EXPORT_HEADER(epanet
|
GENERATE_EXPORT_HEADER(epanet
|
||||||
BASE_NAME epanet
|
BASE_NAME epanet
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ EPANET {#epanet-readme}
|
|||||||
======
|
======
|
||||||
|
|
||||||
## Build Status
|
## Build Status
|
||||||
[](https://ci.appveyor.com/project/OpenWaterAnalytics/epanet)
|
[](https://ci.appveyor.com/project/OpenWaterAnalytics/epanet/branch/dev)
|
||||||
[](https://travis-ci.org/OpenWaterAnalytics/EPANET)
|
[](https://travis-ci.org/OpenWaterAnalytics/EPANET)
|
||||||
|
|
||||||
## For EPANET-related questions and discussion
|
## For EPANET-related questions and discussion
|
||||||
|
|||||||
@@ -30,9 +30,7 @@
|
|||||||
#define EN_API_FLOAT_TYPE float
|
#define EN_API_FLOAT_TYPE float
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WITH_GENX
|
#ifdef NO_GENX
|
||||||
#include "epanet_export.h"
|
|
||||||
#else
|
|
||||||
// --- define WINDOWS
|
// --- define WINDOWS
|
||||||
#undef WINDOWS
|
#undef WINDOWS
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -62,6 +60,8 @@
|
|||||||
#define DLLEXPORT
|
#define DLLEXPORT
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
#include "epanet_export.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ source_group("CLI" FILES ${EPANET_CLI_SOURCES})
|
|||||||
|
|
||||||
|
|
||||||
# Creates the EPANET command line executable
|
# Creates the EPANET command line executable
|
||||||
add_definitions(-D WITH_GENX)
|
|
||||||
add_executable(runepanet ${EPANET_CLI_SOURCES})
|
add_executable(runepanet ${EPANET_CLI_SOURCES})
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
target_link_libraries(runepanet LINK_PUBLIC epanet m)
|
target_link_libraries(runepanet LINK_PUBLIC epanet m)
|
||||||
|
|||||||
37
src/epanet.c
37
src/epanet.c
@@ -132,7 +132,7 @@ execute function x and set the error code equal to its return value.
|
|||||||
|
|
||||||
// This single global variable is used only when the library is called
|
// This single global variable is used only when the library is called
|
||||||
// in "legacy mode" with the 2.1-style API.
|
// in "legacy mode" with the 2.1-style API.
|
||||||
EN_Project *_defaultModel;
|
void *_defaultModel;
|
||||||
|
|
||||||
|
|
||||||
// Local functions
|
// Local functions
|
||||||
@@ -164,12 +164,15 @@ void errorLookup(int errcode, char *errmsg, int len);
|
|||||||
int DLLEXPORT ENepanet(const char *f1, const char *f2, const char *f3, void (*pviewprog)(char *))
|
int DLLEXPORT ENepanet(const char *f1, const char *f2, const char *f3, void (*pviewprog)(char *))
|
||||||
{
|
{
|
||||||
int errcode = 0;
|
int errcode = 0;
|
||||||
|
EN_Project *p = NULL;
|
||||||
|
|
||||||
ERRCODE(EN_createproject(&_defaultModel));
|
ERRCODE(EN_createproject(&_defaultModel));
|
||||||
ERRCODE(EN_open(_defaultModel, f1, f2, f3));
|
ERRCODE(EN_open(_defaultModel, f1, f2, f3));
|
||||||
_defaultModel->viewprog = pviewprog;
|
|
||||||
|
|
||||||
if (_defaultModel->out_files.Hydflag != USE) {
|
p = (EN_Project*)(_defaultModel);
|
||||||
|
p->viewprog = pviewprog;
|
||||||
|
|
||||||
|
if (p->out_files.Hydflag != USE) {
|
||||||
ERRCODE(EN_solveH(_defaultModel));
|
ERRCODE(EN_solveH(_defaultModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,6 +185,14 @@ int DLLEXPORT ENepanet(const char *f1, const char *f2, const char *f3, void (*pv
|
|||||||
return (errcode);
|
return (errcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DLLEXPORT ENinit(char *f2, char *f3, int UnitsType,
|
||||||
|
int HeadlossFormula) {
|
||||||
|
int errcode = 0;
|
||||||
|
ERRCODE(EN_createproject(&_defaultModel));
|
||||||
|
ERRCODE(EN_init(_defaultModel, f2, f3, UnitsType, HeadlossFormula));
|
||||||
|
return (errcode);
|
||||||
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENopen(char *f1, char *f2, char *f3) {
|
int DLLEXPORT ENopen(char *f1, char *f2, char *f3) {
|
||||||
int errcode = 0;
|
int errcode = 0;
|
||||||
ERRCODE(EN_createproject(&_defaultModel));
|
ERRCODE(EN_createproject(&_defaultModel));
|
||||||
@@ -603,7 +614,7 @@ int DLLEXPORT EN_deleteproject(EN_ProjectHandle *ph)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int DLLEXPORT EN_init(EN_ProjectHandle *ph, char *f2, char *f3,
|
int DLLEXPORT EN_init(EN_ProjectHandle ph, char *f2, char *f3,
|
||||||
EN_FlowUnits UnitsType, EN_FormType HeadlossFormula)
|
EN_FlowUnits UnitsType, EN_FormType HeadlossFormula)
|
||||||
/*----------------------------------------------------------------
|
/*----------------------------------------------------------------
|
||||||
** Input:
|
** Input:
|
||||||
@@ -624,7 +635,7 @@ int DLLEXPORT EN_init(EN_ProjectHandle *ph, char *f2, char *f3,
|
|||||||
_fpreset();
|
_fpreset();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EN_Project *pr = (EN_Project*)*ph;
|
EN_Project *pr = (EN_Project*)ph;
|
||||||
|
|
||||||
/* Set system flags */
|
/* Set system flags */
|
||||||
pr->Openflag = TRUE;
|
pr->Openflag = TRUE;
|
||||||
@@ -3104,7 +3115,7 @@ int DLLEXPORT EN_addpattern(EN_ProjectHandle ph, char *id) {
|
|||||||
|
|
||||||
if (!p->Openflag)
|
if (!p->Openflag)
|
||||||
return set_error(p->error_handle, 102);
|
return set_error(p->error_handle, 102);
|
||||||
if (ENgetpatternindex(id, &i) == 0)
|
if (EN_getpatternindex(ph, id, &i) == 0)
|
||||||
return set_error(p->error_handle, 215);
|
return set_error(p->error_handle, 215);
|
||||||
|
|
||||||
/* Check that id name is not too long */
|
/* Check that id name is not too long */
|
||||||
@@ -3157,7 +3168,7 @@ int DLLEXPORT EN_addpattern(EN_ProjectHandle ph, char *id) {
|
|||||||
for (i = 0; i <= Npats; i++)
|
for (i = 0; i <= Npats; i++)
|
||||||
free(Pattern[i].F);
|
free(Pattern[i].F);
|
||||||
free(Pattern);
|
free(Pattern);
|
||||||
Pattern = tmpPat;
|
net->Pattern = tmpPat;
|
||||||
net->Npats = n;
|
net->Npats = n;
|
||||||
par->MaxPats = n;
|
par->MaxPats = n;
|
||||||
return set_error(p->error_handle, 0);
|
return set_error(p->error_handle, 0);
|
||||||
@@ -4829,6 +4840,7 @@ int DLLEXPORT EN_addlink(EN_ProjectHandle ph, char *id, EN_LinkType linkType, ch
|
|||||||
link->Type = linkType;
|
link->Type = linkType;
|
||||||
link->N1 = N1;
|
link->N1 = N1;
|
||||||
link->N2 = N2;
|
link->N2 = N2;
|
||||||
|
link->Stat = OPEN;
|
||||||
|
|
||||||
if (linkType == EN_PUMP) {
|
if (linkType == EN_PUMP) {
|
||||||
link->Kc = 1.0; // Speed factor
|
link->Kc = 1.0; // Speed factor
|
||||||
@@ -4844,23 +4856,14 @@ int DLLEXPORT EN_addlink(EN_ProjectHandle ph, char *id, EN_LinkType linkType, ch
|
|||||||
link->Kc = 0.0; // Valve setting.
|
link->Kc = 0.0; // Valve setting.
|
||||||
link->Km = 0.0; // Loss coeff
|
link->Km = 0.0; // Loss coeff
|
||||||
link->Len = 0.0;
|
link->Len = 0.0;
|
||||||
|
link->Stat = ACTIVE;
|
||||||
}
|
}
|
||||||
// link->Len = 0.0;
|
|
||||||
// link->Kc = 0.01;
|
|
||||||
// link->Km = 0;
|
|
||||||
link->Kb = 0;
|
link->Kb = 0;
|
||||||
link->Kw = 0;
|
link->Kw = 0;
|
||||||
link->R = 0;
|
link->R = 0;
|
||||||
link->Rc = 0;
|
link->Rc = 0;
|
||||||
link->Rpt = 0;
|
link->Rpt = 0;
|
||||||
|
|
||||||
if (linkType == EN_CVPIPE) {
|
|
||||||
link->Stat = OPEN;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
link->Stat = CLOSED;
|
|
||||||
}
|
|
||||||
|
|
||||||
ENHashTableInsert(net->LinkHashTable, link->ID, n);
|
ENHashTableInsert(net->LinkHashTable, link->ID, n);
|
||||||
return set_error(p->error_handle, 0);
|
return set_error(p->error_handle, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,6 +236,28 @@ BOOST_FIXTURE_TEST_CASE(test_setdemandpattern, Fixture)
|
|||||||
BOOST_REQUIRE(pat_index == pat_index_2);
|
BOOST_REQUIRE(pat_index == pat_index_2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_FIXTURE_TEST_CASE(test_addpattern, Fixture)
|
||||||
|
{
|
||||||
|
int pat_index, n_patterns_1, n_patterns_2;
|
||||||
|
char newpat[] = "new_pattern";
|
||||||
|
|
||||||
|
// get the number of current patterns
|
||||||
|
error = EN_getcount(ph, EN_PATCOUNT, &n_patterns_1);
|
||||||
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
|
// add a new pattern
|
||||||
|
error = EN_addpattern(ph, newpat);
|
||||||
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
|
// get the new patterns count, shoul dbe the old one + 1
|
||||||
|
error = EN_getcount(ph, EN_PATCOUNT, &n_patterns_2);
|
||||||
|
BOOST_REQUIRE(error == 0);
|
||||||
|
BOOST_REQUIRE(n_patterns_1 + 1 == n_patterns_2);
|
||||||
|
|
||||||
|
// gwt the new patterns index, should be as the number of patterns
|
||||||
|
error = EN_getpatternindex(ph, newpat, &pat_index);
|
||||||
|
BOOST_REQUIRE(pat_index == n_patterns_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ Find /i "x86" < checkOS.tmp > StringCheck.tmp
|
|||||||
If %ERRORLEVEL% == 1 (
|
If %ERRORLEVEL% == 1 (
|
||||||
CALL "%SDK_PATH%bin\"SetEnv.cmd /x64 /release
|
CALL "%SDK_PATH%bin\"SetEnv.cmd /x64 /release
|
||||||
rem : create EPANET2.DLL
|
rem : create EPANET2.DLL
|
||||||
cl -o epanet2.dll epanet.c util\errormanager.c hash.c hydraul.c hydcoeffs.c hydstatus.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c genmmd.c /I ..\include /I ..\run /link /DLL
|
cl -o epanet2.dll /D NO_GENX epanet.c util\errormanager.c hash.c hydraul.c hydcoeffs.c hydstatus.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c genmmd.c /I ..\include /I ..\run /link /DLL
|
||||||
rem : create EPANET2.EXE
|
rem : create EPANET2.EXE
|
||||||
cl -o epanet2.exe epanet.c util\errormanager.c ..\run\main.c hash.c hydraul.c hydcoeffs.c hydstatus.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c genmmd.c /I ..\include /I ..\run /I ..\src /link
|
cl -o epanet2.exe /D NO_GENX epanet.c util\errormanager.c ..\run\main.c hash.c hydraul.c hydcoeffs.c hydstatus.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c genmmd.c /I ..\include /I ..\run /I ..\src /link
|
||||||
md "%Build_PATH%"\64bit
|
md "%Build_PATH%"\64bit
|
||||||
move /y "%SRC_PATH%"\*.dll "%Build_PATH%"\64bit
|
move /y "%SRC_PATH%"\*.dll "%Build_PATH%"\64bit
|
||||||
move /y "%SRC_PATH%"\*.exe "%Build_PATH%"\64bit
|
move /y "%SRC_PATH%"\*.exe "%Build_PATH%"\64bit
|
||||||
@@ -35,9 +35,9 @@ rem : 32 bit with DEF
|
|||||||
CALL "%SDK_PATH%bin\"SetEnv.cmd /x86 /release
|
CALL "%SDK_PATH%bin\"SetEnv.cmd /x86 /release
|
||||||
echo "32 bit with epanet2.def mapping"
|
echo "32 bit with epanet2.def mapping"
|
||||||
rem : create EPANET2.DLL
|
rem : create EPANET2.DLL
|
||||||
cl -o epanet2.dll epanet.c util\errormanager.c hash.c hydraul.c hydcoeffs.c hydstatus.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c genmmd.c /I ..\include /I ..\run /link /DLL /def:..\win_build\WinSDK\epanet2.def /MAP
|
cl -o epanet2.dll /D NO_GENX epanet.c util\errormanager.c hash.c hydraul.c hydcoeffs.c hydstatus.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c genmmd.c /I ..\include /I ..\run /link /DLL /def:..\win_build\WinSDK\epanet2.def /MAP
|
||||||
rem : create EPANET2.EXE
|
rem : create EPANET2.EXE
|
||||||
cl -o epanet2.exe epanet.c util\errormanager.c ..\run\main.c hash.c hydraul.c hydcoeffs.c hydstatus.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c genmmd.c /I ..\include /I ..\run /I ..\src /link
|
cl -o epanet2.exe /D NO_GENX epanet.c util\errormanager.c ..\run\main.c hash.c hydraul.c hydcoeffs.c hydstatus.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c genmmd.c /I ..\include /I ..\run /I ..\src /link
|
||||||
md "%Build_PATH%"\32bit
|
md "%Build_PATH%"\32bit
|
||||||
move /y "%SRC_PATH%"\*.dll "%Build_PATH%"\32bit
|
move /y "%SRC_PATH%"\*.dll "%Build_PATH%"\32bit
|
||||||
move /y "%SRC_PATH%"\*.exe "%Build_PATH%"\32bit
|
move /y "%SRC_PATH%"\*.exe "%Build_PATH%"\32bit
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ EXPORTS
|
|||||||
ENsetdemandpattern = _ENsetdemandpattern@12
|
ENsetdemandpattern = _ENsetdemandpattern@12
|
||||||
ENgetaveragepatternvalue = _ENgetaveragepatternvalue@8
|
ENgetaveragepatternvalue = _ENgetaveragepatternvalue@8
|
||||||
ENgetheadcurveindex = _ENgetheadcurveindex@8
|
ENgetheadcurveindex = _ENgetheadcurveindex@8
|
||||||
|
ENsetheadcurveindex = _ENsetheadcurveindex@8
|
||||||
ENgetpumptype = _ENgetpumptype@8
|
ENgetpumptype = _ENgetpumptype@8
|
||||||
ENgetcurveindex = _ENgetcurveindex@8
|
ENgetcurveindex = _ENgetcurveindex@8
|
||||||
ENgetcurveid = _ENgetcurveid@8
|
ENgetcurveid = _ENgetcurveid@8
|
||||||
@@ -97,4 +98,4 @@ EXPORTS
|
|||||||
ENgetdemandmodel = _ENgetdemandmodel@16
|
ENgetdemandmodel = _ENgetdemandmodel@16
|
||||||
ENsetdemandmodel = _ENsetdemandmodel@16
|
ENsetdemandmodel = _ENsetdemandmodel@16
|
||||||
ENgetcurvetype = _ENgetcurvetype@8
|
ENgetcurvetype = _ENgetcurvetype@8
|
||||||
|
ENinit = _ENinit@16
|
||||||
Reference in New Issue
Block a user