From d94e1643bf0ac7c4ee09c074065eaa1d18afbfbd Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Mon, 13 Aug 2018 09:19:05 +0300 Subject: [PATCH] Update Windows build script and VB header file Also save HeadErrorLimit and FlowChangeLimit only if they are used. --- include/epanet2.bas | 8 ++++++++ src/inpfile.c | 8 ++++++-- win_build/WinSDK/Makefile.bat | 8 ++++---- win_build/WinSDK/epanet2.def | 4 +++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/include/epanet2.bas b/include/epanet2.bas index 0826a3b..8a2c79b 100644 --- a/include/epanet2.bas +++ b/include/epanet2.bas @@ -75,6 +75,8 @@ Public Const EN_NEXTEVENT = 14 Public Const EN_ITERATIONS = 0 Public Const EN_RELATIVEERROR = 1 +Public Const EN_MAXHEADERROR = 2 +Public Const EN_MAXFLOWCHANGE = 3 Public Const EN_NODECOUNT = 0 'Component counts Public Const EN_TANKCOUNT = 1 @@ -123,6 +125,9 @@ Public Const EN_MLD = 7 Public Const EN_CMH = 8 Public Const EN_CMD = 9 +Public Const EN_DDA = 0 ' Demand driven analysis +Public Const EN_PDA = 1 ' Pressure driven analysis + Public Const EN_TRIALS = 0 ' Misc. options Public Const EN_ACCURACY = 1 Public Const EN_TOLERANCE = 2 @@ -222,6 +227,9 @@ Public Const EN_CUSTOM = 2 ' user-defined custom curve Declare Function ENgetversion Lib "epanet2.dll" (value As Long) As Long + Declare Function ENgetdemandmodel Lib "epanet2.dll" (type as long, pmin as Single, preq as Single, pexp as Single) As Long + Declare Function ENsetdemandmodel Lib "epanet2.dll" (ByVal type as long, ByVal pmin as Single, ByVal preq as Single, ByVal pexp as Single) As Long + Declare Function ENsetflowunits Lib "epanet2.dll" (ByVal code As Long) As Long Declare Function ENsetcontrol Lib "epanet2.dll" (ByVal Cindex As Long, ByVal Ctype As Long, ByVal Lindex As Long, ByVal setting As Single, ByVal Nindex As Long, ByVal Level As Single) As Long Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, ByVal value As Single) As Long diff --git a/src/inpfile.c b/src/inpfile.c index f5ef6b8..9d5d0a4 100644 --- a/src/inpfile.c +++ b/src/inpfile.c @@ -618,8 +618,12 @@ int saveinpfile(EN_Project *pr, char *fname) fprintf(f, "\n CHECKFREQ %-d", hyd->CheckFreq); fprintf(f, "\n MAXCHECK %-d", hyd->MaxCheck); fprintf(f, "\n DAMPLIMIT %-.8f", hyd->DampLimit); - fprintf(f, "\n HEADERROR %-.8f", hyd->HeadErrorLimit * pr->Ucf[HEAD]); - fprintf(f, "\n FLOWCHANGE %-.8f", hyd->FlowChangeLimit * pr->Ucf[FLOW]); + if (hyd->HeadErrorLimit > 0.0) { + fprintf(f, "\n HEADERROR %-.8f", hyd->HeadErrorLimit * pr->Ucf[HEAD]); + } + if (hyd->FlowChangeLimit > 0.0) { + fprintf(f, "\n FLOWCHANGE %-.8f", hyd->FlowChangeLimit * pr->Ucf[FLOW]); + } if (hyd->DemandModel == PDA) { diff --git a/win_build/WinSDK/Makefile.bat b/win_build/WinSDK/Makefile.bat index d0a00c3..ee5b030 100644 --- a/win_build/WinSDK/Makefile.bat +++ b/win_build/WinSDK/Makefile.bat @@ -21,9 +21,9 @@ Find /i "x86" < checkOS.tmp > StringCheck.tmp If %ERRORLEVEL% == 1 ( CALL "%SDK_PATH%bin\"SetEnv.cmd /x64 /release rem : create EPANET2.DLL - cl -o epanet2.dll epanet.c hash.c hydraul.c hydcoeffs.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c /I ..\include /I ..\run /link /DLL + cl -o epanet2.dll epanet.c hash.c hydraul.c hydcoeffs.c hydsolver.c hydstatus.c genmmd.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c /I ..\include /I ..\run /link /DLL rem : create EPANET2.EXE - cl -o epanet2.exe epanet.c ..\run\main.c hash.c hydraul.c hydcoeffs.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c /I ..\include /I ..\run /I ..\src /link + cl -o epanet2.exe epanet.c ..\run\main.c hash.c hydraul.c hydcoeffs.c hydsolver.c hydstatus.c genmmd.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c /I ..\include /I ..\run /I ..\src /link md "%Build_PATH%"\64bit move /y "%SRC_PATH%"\*.dll "%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 echo "32 bit with epanet2.def mapping" rem : create EPANET2.DLL -cl -o epanet2.dll epanet.c hash.c hydraul.c hydcoeffs.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c /I ..\include /I ..\run /link /DLL /def:..\win_build\WinSDK\epanet2.def /MAP +cl -o epanet2.dll epanet.c hash.c hydraul.c hydcoeffs.c hydsolver.c hydstatus.c genmmd.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c /I ..\include /I ..\run /link /DLL /def:..\win_build\WinSDK\epanet2.def /MAP rem : create EPANET2.EXE -cl -o epanet2.exe epanet.c ..\run\main.c hash.c hydraul.c hydcoeffs.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c /I ..\include /I ..\run /I ..\src /link +cl -o epanet2.exe epanet.c ..\run\main.c hash.c hydraul.c hydcoeffs.c hydstatus.c genmmd.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c /I ..\include /I ..\run /I ..\src /link md "%Build_PATH%"\32bit move /y "%SRC_PATH%"\*.dll "%Build_PATH%"\32bit move /y "%SRC_PATH%"\*.exe "%Build_PATH%"\32bit diff --git a/win_build/WinSDK/epanet2.def b/win_build/WinSDK/epanet2.def index 09acdb7..6fc90f8 100644 --- a/win_build/WinSDK/epanet2.def +++ b/win_build/WinSDK/epanet2.def @@ -92,4 +92,6 @@ EXPORTS ENaddlink = _ENaddlink@16 ENdeletelink = _ENdeletelink@4 ENdeletenode = _ENdeletenode@4 - ENsetlinktype = _ENsetlinktype@8 \ No newline at end of file + ENsetlinktype = _ENsetlinktype@8 + ENgetdemandmodel = _ENgetdemandmodel@16 + ENsetdemandmodel = _ENsetdemandmodel@16 \ No newline at end of file