From 322a3cb46382bfe7172e2574003c6c277fcd2a43 Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Wed, 23 Sep 2015 15:31:29 +0300 Subject: [PATCH 01/11] Added pump's type constants to header files --- include/epanet2.bas | 4 ++++ include/epanet2.h | 3 +++ src/epanet.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/epanet2.bas b/include/epanet2.bas index 86e8c38..9ceeb2b 100644 --- a/include/epanet2.bas +++ b/include/epanet2.bas @@ -140,6 +140,10 @@ Global Const EN_SAVE = 1 Global Const EN_INITFLOW = 10 ' Re-initialize flow flag +Global Const EN_CONST_HP = 0 ' constant horsepower +Global Const EN_POWER_FUNC = 1 ' power function +Global Const EN_CUSTOM = 2 ' user-defined custom curve + 'These are the external functions that comprise the DLL Declare Function ENepanet Lib "epanet2.dll" (ByVal F1 As String, ByVal F2 As String, ByVal F3 As String, ByVal F4 As Any) As Long diff --git a/include/epanet2.h b/include/epanet2.h index 606bf1b..7bab95e 100755 --- a/include/epanet2.h +++ b/include/epanet2.h @@ -188,6 +188,9 @@ #define EN_INITFLOW 10 /* Re-initialize flows flag */ +#define EN_CONST_HP 0 /* constant horsepower */ +#define EN_POWER_FUNC 1 /* power function */ +#define EN_CUSTOM 2 /* user-defined custom curve */ // --- Declare the EPANET toolkit functions #if defined(__cplusplus) diff --git a/src/epanet.c b/src/epanet.c index c350434..571bdc5 100755 --- a/src/epanet.c +++ b/src/epanet.c @@ -2785,7 +2785,7 @@ int DLLEXPORT ENgetheadcurve(int index, char *id) int DLLEXPORT ENgetpumptype(int index, int *type) /*---------------------------------------------------------------- ** Input: index = index of pump in list of links -** Output: type = PumpType +** Output: type = Pump type ** Returns: error code ** Purpose: retrieves type of a pump for specific link index ** From 8be1fcffd68a8d0ca3bbe294eacd1474e936bc0a Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Thu, 24 Sep 2015 12:55:29 +0300 Subject: [PATCH 02/11] Fix header file --- include/epanet2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/epanet2.h b/include/epanet2.h index 7bab95e..0c944b0 100755 --- a/include/epanet2.h +++ b/include/epanet2.h @@ -257,8 +257,8 @@ extern "C" { int DLLEXPORT ENgetlinkvalue(int index, int code, EN_API_FLOAT_TYPE *value); int DLLEXPORT ENgetcurve(int curveIndex, char* id, int *nValues, EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues); - int DLLEXPORT ENgetheadcurve(int, char *); - int DLLEXPORT ENgetpumptype(int, int *); + int DLLEXPORT ENgetheadcurve(int index, char *id); + int DLLEXPORT ENgetpumptype(int index, int *type); int DLLEXPORT ENgetversion(int *version); From 942a3f2860e9316d543ee394cd9267679d67b0f3 Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Tue, 29 Sep 2015 23:23:14 +0300 Subject: [PATCH 03/11] Fix typo on vb.net header file --- include/epanet2.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/epanet2.vb b/include/epanet2.vb index ed0e116..1e86417 100644 --- a/include/epanet2.vb +++ b/include/epanet2.vb @@ -55,7 +55,7 @@ Public Const EN_STATUS = 11 Public Const EN_SETTING = 12 Public Const EN_ENERGY = 13 Public Const EN_LINKQUAL = 14 'ES -Public Const EN_LINKPATTERN 15 +Public Const EN_LINKPATTERN = 15 Public Const EN_DURATION = 0 ' Time parameters Public Const EN_HYDSTEP = 1 From cca1cda37ae6d531518f675799fc472ab2d336ad Mon Sep 17 00:00:00 2001 From: mauriziocingi Date: Wed, 4 Nov 2015 13:55:01 +0100 Subject: [PATCH 04/11] added Warnflag in exported symbols --- build/MinGW/Makefile | 78 ++++++++++++++++++++++++++++++++++++++++++++ include/epanet2.h | 6 ++++ 2 files changed, 84 insertions(+) create mode 100644 build/MinGW/Makefile diff --git a/build/MinGW/Makefile b/build/MinGW/Makefile new file mode 100644 index 0000000..a5c3178 --- /dev/null +++ b/build/MinGW/Makefile @@ -0,0 +1,78 @@ +# MINGW32 Makefile for EPANET + +# This will build EPANET as DLL +# (epanet2.dll) under MINGW32 GCC, and a standalone +# executable (epanet2d.exe). + +# The following targets are defined: +# make +# -Builds epanet2.dll, epanet2d.exe +# make install +# -Copy epanet2.dll, epanet2d.exe, epanet2.def to $(prefix) +# make clean +# -Removes object and library files, returning the build directory +# to its pristine state. + +# You may wish to change the install path 'prefix', +# or the compiler flags, but these defaults should be fine. + + +# Target filenames +epanetrootname := epanet2 +libname := $(epanetrootname).dll +exename := $(epanetrootname)d.exe + +# Location of EPANET toolkit includes +epanetincludedir = ../../include +# Search path for sources +epanetsrcdir = ../../src +# Search path for sources +epanetmainsrcdir = ../../run +VPATH = $(epanetsrcdir):$(epanetincludedir):$(epanetmainsrcdir) + +# Install directories +prefix = C:\discoD\EPA\EPAnet_util +execdir = $(prefix) +libdir = $(prefix) + + +# Compiler and flags +CC = gcc +CFLAGS = -g -O3 -std=c99 -Wno-implicit-function-declaration -D DLL +CPPFLAGS = -I $(epanetincludedir) -I $(epanetsrcdir) +LDFLAGS = -L . -Wl,--kill-at,--enable-stdcall-fixup,-rpath,$(libdir) -lm + + +# Files for the shared object library +epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \ + input3.o mempool.o output.o quality.o report.o \ + rules.o smatrix.o epanet.o +# Epanet header files +epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h types.h vars.h epanet2.h +# Epanet main program +epanet_main=main +# Epanet main program header files +epanet_main_heads=epanet2.h text.h + +.PHONY: all +all: $(libname) $(exename) + +$(libname): $(epanet_objs) + $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -Wl,--output-def,$(epanetrootname).def + +$(exename): $(epanet_main_heads) $(libname) $(epanet_main).o + $(CC) $(CFLAGS) -o $@ $(epanet_main).o -l$(epanetrootname) $(LDFLAGS) + +$(epanet_objs): $(epanet_heads) + + +.PHONY: clean +clean: + del $(epanet_main).o $(epanet_objs) $(exename) $(libname) $(epanetrootname).def + +.PHONY: install +install: + copy $(exename) $(execdir) + copy $(libname) $(libdir) + copy $(epanetrootname).def $(libdir) + diff --git a/include/epanet2.h b/include/epanet2.h index 0c944b0..75488c1 100755 --- a/include/epanet2.h +++ b/include/epanet2.h @@ -36,6 +36,7 @@ // --- define DLLEXPORT #ifndef DLLEXPORT #ifdef WINDOWS + #define DLLDATA __declspec(dllexport) #ifdef __cplusplus #define DLLEXPORT extern "C" __declspec(dllexport) #else @@ -53,6 +54,10 @@ #define DLLEXPORT #endif #endif +#ifndef DLLDATA + #define DLLDATA +#endif + // --- Define the EPANET toolkit constants @@ -282,6 +287,7 @@ extern "C" { int DLLEXPORT ENsetcurvevalue(int index, int pnt, EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y); int DLLEXPORT ENsetcurve(int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y, int len); int DLLEXPORT ENaddcurve(char *id); + char DLLDATA Warnflag; #if defined(__cplusplus) } From ea08fb9da12e7a2dbb1726472ad98fc6f59942b2 Mon Sep 17 00:00:00 2001 From: mauriziocingi Date: Fri, 20 Nov 2015 13:35:40 +0100 Subject: [PATCH 05/11] undone Warnflag declaration due to cl.exe incompatibilities , now Warnflag is retuned with errorcode --- build/MinGW/Makefile | 2 +- include/epanet2.h | 5 --- run/main.c | 75 +++++++++++++++++++++++++++++++++----------- src/epanet.c | 10 +++--- 4 files changed, 62 insertions(+), 30 deletions(-) diff --git a/build/MinGW/Makefile b/build/MinGW/Makefile index a5c3178..eae49e2 100644 --- a/build/MinGW/Makefile +++ b/build/MinGW/Makefile @@ -52,7 +52,7 @@ epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h types.h vars.h epanet2.h # Epanet main program epanet_main=main # Epanet main program header files -epanet_main_heads=epanet2.h text.h +epanet_main_heads=epanet2.h .PHONY: all all: $(libname) $(exename) diff --git a/include/epanet2.h b/include/epanet2.h index 75488c1..5908ec9 100755 --- a/include/epanet2.h +++ b/include/epanet2.h @@ -36,7 +36,6 @@ // --- define DLLEXPORT #ifndef DLLEXPORT #ifdef WINDOWS - #define DLLDATA __declspec(dllexport) #ifdef __cplusplus #define DLLEXPORT extern "C" __declspec(dllexport) #else @@ -54,9 +53,6 @@ #define DLLEXPORT #endif #endif -#ifndef DLLDATA - #define DLLDATA -#endif // --- Define the EPANET toolkit constants @@ -287,7 +283,6 @@ extern "C" { int DLLEXPORT ENsetcurvevalue(int index, int pnt, EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y); int DLLEXPORT ENsetcurve(int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y, int len); int DLLEXPORT ENaddcurve(char *id); - char DLLDATA Warnflag; #if defined(__cplusplus) } diff --git a/run/main.c b/run/main.c index 83949a7..d36ad6f 100644 --- a/run/main.c +++ b/run/main.c @@ -1,10 +1,17 @@ #include +#include #include "epanet2.h" -#include "text.h" + +/* text copied here, no more need of include "text.h" */ +#define FMT01 "\n... EPANET Version %d.%d.%d\n" +#define FMT03 "\n Correct syntax is:\n epanet \n" +#define FMT09 "\n... EPANET completed.\n" +#define FMT10 "\n... EPANET completed. There are warnings." +#define FMT11 "\n... EPANET completed. There are errors." + void writeConsole(char *s); -extern char Warnflag; /* ---------------------------------------------------------------- @@ -23,40 +30,70 @@ int main(int argc, char *argv[]) ** Command line for stand-alone operation is: ** progname f1 f2 f3 ** where progname = name of executable this code was compiled to, - ** f1 = name of input file, f2 = name of report file, and - ** f3 = name of binary output file (optional). + ** f1 = name of input file, + ** f2 = name of report file (optional, stdout if left blank) + ** f3 = name of binary output file (optional, nullfile if left blank). **-------------------------------------------------------------- */ { char *f1,*f2,*f3; char blank[] = ""; + char errmsg[40]; int errcode; + int version; + char s[25]; + /* Check for proper number of command line arguments */ - if (argc < 3) { + if (argc < 2) { writeConsole(FMT03); } else { /* Call the main control function */ f1 = argv[1]; - f2 = argv[2]; + if (argc > 2) { + f2 = argv[2]; + } + else { + f2 = blank; + } if (argc > 3) { f3 = argv[3]; } else { f3 = blank; } - writeConsole(FMT01); - errcode = ENepanet(f1,f2,f3,NULL); - if (errcode > 0) { - writeConsole(FMT11); - } - else if (Warnflag > 0) { - writeConsole(FMT10); - } - else { - writeConsole(FMT09); - } + } + + /* get version from DLL and trasform in Major.Minor.Patch format + instead of hardcoded version */ + ENgetversion(&version); + int major= version/10000; + int minor= (version%10000)/100; + int patch= version%100; + sprintf(s,FMT01, major , minor, patch); + writeConsole(s); + + if (strlen(f2)> 0) { + /* use stdout for progress messages */ + errcode = ENepanet(f1,f2,f3,writeConsole); + } + else { + /* use stdout for reporting, no progress messages */ + errcode = ENepanet(f1,f2,f3,NULL); + } + + /* Error/Warning check */ + if (errcode == 0) writeConsole(FMT09); + else { + if (errcode > 100) { + writeConsole(FMT11); + } + else { + writeConsole(FMT10); + } + ENgeterror(errcode, errmsg, 40); + writeConsole(errmsg); } return(0); } /* End of main */ @@ -70,6 +107,8 @@ void writeConsole(char *s) **---------------------------------------------------------------- */ { - fprintf(stdout,"%s",s); + fprintf(stdout,"%s\n",s); fflush(stdout); } + + diff --git a/src/epanet.c b/src/epanet.c index 571bdc5..18ef1c6 100755 --- a/src/epanet.c +++ b/src/epanet.c @@ -180,7 +180,7 @@ int DLLEXPORT ENepanet(char *f1, char *f2, char *f3, void (*pviewprog) (char *)) ERRCODE(ENsolveQ()); ERRCODE(ENreport()); ENclose(); - return(errcode); + return(MAX(errcode, Warnflag) ); } @@ -290,7 +290,7 @@ int DLLEXPORT ENclose() } //(2.00.12 - LR) if (InFile != NULL) { fclose(InFile); InFile=NULL; } - if (RptFile != NULL) { fclose(RptFile); RptFile=NULL; } + if (RptFile != NULL && RptFile != stdout) { fclose(RptFile); RptFile=NULL; } if (HydFile != NULL) { fclose(HydFile); HydFile=NULL; } if (OutFile != NULL) { fclose(OutFile); OutFile=NULL; } @@ -3499,8 +3499,8 @@ void writecon(char *s) */ { //(2.00.11 - LR) - fprintf(stdout,s); - fflush(stdout); + //fprintf(stdout,s); + //fflush(stdout); } @@ -3514,14 +3514,12 @@ void writewin(char *s) **---------------------------------------------------------------- */ { -#ifdef DLL char progmsg[MAXMSG+1]; if (viewprog != NULL) { strncpy(progmsg,s,MAXMSG); viewprog(progmsg); } -#endif } From 08937fc838a27504c10cf793554d33e6d00e1441 Mon Sep 17 00:00:00 2001 From: mauriziocingi Date: Mon, 23 Nov 2015 11:16:11 +0100 Subject: [PATCH 06/11] resolved no_args bug --- run/main.c | 85 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 33 deletions(-) diff --git a/run/main.c b/run/main.c index d36ad6f..a96c979 100644 --- a/run/main.c +++ b/run/main.c @@ -2,12 +2,14 @@ #include #include "epanet2.h" +#define MAXMSG 79 /* Max. # characters in message text */ +#define MAXWARNCODE 99 /* text copied here, no more need of include "text.h" */ -#define FMT01 "\n... EPANET Version %d.%d.%d\n" +#define FMT01 "\nEPANET Version %d.%d.%d\n" #define FMT03 "\n Correct syntax is:\n epanet \n" -#define FMT09 "\n... EPANET completed.\n" -#define FMT10 "\n... EPANET completed. There are warnings." -#define FMT11 "\n... EPANET completed. There are errors." +#define FMT09 "\nEPANET completed.\n" +#define FMT10 "\nEPANET completed. There are warnings." +#define FMT11 "\nEPANET completed. There are errors." void writeConsole(char *s); @@ -38,42 +40,50 @@ int main(int argc, char *argv[]) { char *f1,*f2,*f3; char blank[] = ""; - char errmsg[40]; + char errmsg[MAXMSG+1]=""; int errcode; int version; char s[25]; + int major; + int minor; + int patch; + + /* get version from DLL and trasform in Major.Minor.Patch format + instead of hardcoded version */ + ENgetversion(&version); + major= version/10000; + minor= (version%10000)/100; + patch= version%100; + sprintf(s,FMT01, major , minor, patch); + writeConsole(s); /* Check for proper number of command line arguments */ if (argc < 2) { writeConsole(FMT03); + return(1); + } + + /* set inputfile name */ + f1 = argv[1]; + if (argc > 2) { + /* set rptfile name */ + f2 = argv[2]; } else { - /* Call the main control function */ - f1 = argv[1]; - if (argc > 2) { - f2 = argv[2]; - } - else { - f2 = blank; - } - if (argc > 3) { - f3 = argv[3]; - } - else { - f3 = blank; - } + /* use stdout for rptfile */ + f2 = blank; + } + if (argc > 3) { + /* set binary output file name */ + f3 = argv[3]; + } + else { + /* NO binary output*/ + f3 = blank; } - /* get version from DLL and trasform in Major.Minor.Patch format - instead of hardcoded version */ - ENgetversion(&version); - int major= version/10000; - int minor= (version%10000)/100; - int patch= version%100; - sprintf(s,FMT01, major , minor, patch); - writeConsole(s); - + /* Call the main control function */ if (strlen(f2)> 0) { /* use stdout for progress messages */ errcode = ENepanet(f1,f2,f3,writeConsole); @@ -84,18 +94,27 @@ int main(int argc, char *argv[]) } /* Error/Warning check */ - if (errcode == 0) writeConsole(FMT09); + if (errcode == 0) { + /* no errors */ + writeConsole(FMT09); + return(0); + } else { - if (errcode > 100) { + ENgeterror(errcode, errmsg, MAXMSG); + writeConsole(errmsg); + if (errcode > MAXWARNCODE) { + /* error */ writeConsole(FMT11); + return(errcode); } else { + /* warning */ writeConsole(FMT10); + return(0); } - ENgeterror(errcode, errmsg, 40); - writeConsole(errmsg); } - return(0); + + } /* End of main */ From f89515febdcfe06ea7e806dc9b7365e93539879d Mon Sep 17 00:00:00 2001 From: Maurizio Cingi Date: Tue, 24 Nov 2015 19:49:13 +0100 Subject: [PATCH 07/11] added TmpOutFile=NULL; after closing TmpOutFile In case of [TIMES] Statistic not equal NONE (see page 174 of Epanet2 users manual) ENclose() function tries to close TmpOutFile again giving a "double free or corruption" error --- src/output.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/output.c b/src/output.c index 0e18bb8..ced8c73 100755 --- a/src/output.c +++ b/src/output.c @@ -503,6 +503,7 @@ int savefinaloutput() ERRCODE(savetimestat(x,LINKHDR)); if (!errcode) Nperiods = 1; fclose(TmpOutFile); + TmpOutFile=NULL; free(x); } From 1905c1011c55155916f0224d97423bc0e3e49946 Mon Sep 17 00:00:00 2001 From: Maurizio Cingi Date: Wed, 25 Nov 2015 12:01:51 +0100 Subject: [PATCH 08/11] adapted Linux/Makefile and created runepanet.sh.template --- build/Linux/runepanet.sh.template | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 build/Linux/runepanet.sh.template diff --git a/build/Linux/runepanet.sh.template b/build/Linux/runepanet.sh.template new file mode 100644 index 0000000..253dbc8 --- /dev/null +++ b/build/Linux/runepanet.sh.template @@ -0,0 +1,3 @@ +#!/bin/sh +export LD_LIBRARY_PATH=libdir:$LD_LIBRARY_PATH +exec exename $* From 60dc2870f5eda8850f5130988a652d5c05d174be Mon Sep 17 00:00:00 2001 From: Maurizio Cingi Date: Wed, 25 Nov 2015 12:03:51 +0100 Subject: [PATCH 09/11] adapted Linux/Makefile and created runepanet.sh.template --- build/Linux/Makefile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/build/Linux/Makefile b/build/Linux/Makefile index 01e80cf..584c1ad 100755 --- a/build/Linux/Makefile +++ b/build/Linux/Makefile @@ -41,10 +41,13 @@ runcmdname = runepanet2.sh epanetincludedir = ../../include # Search path for sources epanetsrcdir = ../../src -VPATH = $(epanetsrcdir):$(epanetincludedir) +epanetrundir = ../../run +VPATH = $(epanetsrcdir):$(epanetincludedir):$(epanetrundir) # Install directories -prefix = ~ +#prefix = /usr/local # GNU standard -- requires superuser rights +prefix =~ +# exec_prefix = $(prefix) libdir = $(exec_prefix)/lib bindir = $(exec_prefix)/bin @@ -66,11 +69,11 @@ INSTALL_DATA = $(INSTALL) -m 644 # Files for the shared object library epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \ input3.o mempool.o output.o quality.o report.o \ - rules.o smatrix.o + rules.o smatrix.o epanet.o # Epanet header files -epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h toolkit.h types.h vars.h +epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h types.h vars.h # Epanet main program -epanet_main=epanet +epanet_main=main # Epanet main program header files epanet_main_heads=epanet2.h @@ -78,11 +81,9 @@ epanet_main_heads=epanet2.h all: $(libname) $(exename) $(libname): $(epanet_objs) - $(CC) $(CFLAGS) $(CPPFLAGS) -D SOL -c $(epanetsrcdir)/$(epanet_main).c - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^ + $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -$(exename): $(libname) $(epanet_main_heads) - $(CC) $(CFLAGS) $(CPPFLAGS) -D CLE -c $(epanetsrcdir)/$(epanet_main).c +$(exename): $(epanet_main).o $(epanet_main_heads) $(CC) $(CFLAGS) -o $@ $(epanet_main).o -l$(epanetrootname) $(LDFLAGS) $(epanet_objs): $(epanet_heads) @@ -95,7 +96,7 @@ install: $(INSTALL_PROGRAM) -D $(exename) $(bindir)/$(exename) $(INSTALL_PROGRAM) -D $(libname) $(libdir)/$(libname) $(INSTALL_DATA) -D $(epanetincludedir)/epanet2.h $(includedir)/epanet2.h - $(INSTALL_PROGRAM) -D $(runcmdname) $(bindir)/$(runcmdname) + $(INSTALL_PROGRAM) -D $(runcmdname) ~/$(runcmdname) .PHONY: uninstall uninstall: From d191ec73d6660e8532016cfbda01e596afb22066 Mon Sep 17 00:00:00 2001 From: Sam Hatchett Date: Wed, 25 Nov 2015 19:41:38 -0500 Subject: [PATCH 10/11] xcode build file update to use correct input files --- build/Xcode/epanet.xcodeproj/project.pbxproj | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/build/Xcode/epanet.xcodeproj/project.pbxproj b/build/Xcode/epanet.xcodeproj/project.pbxproj index 02864fd..9e99d8e 100755 --- a/build/Xcode/epanet.xcodeproj/project.pbxproj +++ b/build/Xcode/epanet.xcodeproj/project.pbxproj @@ -59,6 +59,8 @@ 2255754917551234009946B1 /* report.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7E1068369500641384 /* report.c */; }; 2255754A17551234009946B1 /* rules.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7F1068369500641384 /* rules.c */; }; 2255754B17551234009946B1 /* smatrix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F801068369500641384 /* smatrix.c */; }; + 225762C51C068A3900484EC7 /* Net1.inp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 225762C31C068A2A00484EC7 /* Net1.inp */; }; + 225762C61C068A3B00484EC7 /* Net2.inp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 225762C41C068A2A00484EC7 /* Net2.inp */; }; 226537E0179EDEEB00258C60 /* epanet2.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322FA9106836B000641384 /* epanet2.h */; }; 22CD9A5E1B27898E00B65E83 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 22CD9A5D1B27898E00B65E83 /* main.c */; }; 22CD9A611B278BB900B65E83 /* libepanet-static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2255753B17551217009946B1 /* libepanet-static.a */; }; @@ -89,6 +91,8 @@ dstSubfolderSpec = 6; files = ( 223109E61BA865930030AAE8 /* Net3.inp in CopyFiles */, + 225762C51C068A3900484EC7 /* Net1.inp in CopyFiles */, + 225762C61C068A3B00484EC7 /* Net2.inp in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -106,8 +110,6 @@ /* Begin PBXFileReference section */ 223109E31BA8658A0030AAE8 /* Net3.inp */ = {isa = PBXFileReference; lastKnownFileType = text; name = Net3.inp; path = "../../example-networks/Net3.inp"; sourceTree = ""; }; - 223109E41BA8658A0030AAE8 /* sampletown.inp */ = {isa = PBXFileReference; lastKnownFileType = text; name = sampletown.inp; path = "../../example-networks/sampletown.inp"; sourceTree = ""; }; - 223109E51BA8658A0030AAE8 /* simplenet.inp */ = {isa = PBXFileReference; lastKnownFileType = text; name = simplenet.inp; path = "../../example-networks/simplenet.inp"; sourceTree = ""; }; 223109F31BA869DA0030AAE8 /* runepanet copy */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "runepanet copy"; sourceTree = BUILT_PRODUCTS_DIR; }; 22310A091BA869F30030AAE8 /* libepanet-static copy.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libepanet-static copy.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 22322F66106833BB00641384 /* runepanet */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = runepanet; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -133,6 +135,8 @@ 22322F841068369500641384 /* vars.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = vars.h; path = ../../src/vars.h; sourceTree = SOURCE_ROOT; }; 22322FA9106836B000641384 /* epanet2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 2; name = epanet2.h; path = ../../include/epanet2.h; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 2255753B17551217009946B1 /* libepanet-static.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libepanet-static.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 225762C31C068A2A00484EC7 /* Net1.inp */ = {isa = PBXFileReference; lastKnownFileType = text; name = Net1.inp; path = "../../example-networks/Net1.inp"; sourceTree = ""; }; + 225762C41C068A2A00484EC7 /* Net2.inp */ = {isa = PBXFileReference; lastKnownFileType = text; name = Net2.inp; path = "../../example-networks/Net2.inp"; sourceTree = ""; }; 22CD9A5D1B27898E00B65E83 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = main.c; path = ../../run/main.c; sourceTree = ""; }; D2AAC0630554660B00DB518D /* libepanet.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libepanet.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -233,8 +237,8 @@ isa = PBXGroup; children = ( 223109E31BA8658A0030AAE8 /* Net3.inp */, - 223109E41BA8658A0030AAE8 /* sampletown.inp */, - 223109E51BA8658A0030AAE8 /* simplenet.inp */, + 225762C31C068A2A00484EC7 /* Net1.inp */, + 225762C41C068A2A00484EC7 /* Net2.inp */, ); name = "sample networks"; sourceTree = ""; From 096167af8b0d07664caf223795592b3c161cee8f Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Sat, 28 Nov 2015 00:21:36 +0200 Subject: [PATCH 11/11] Change ENgetheadcurve to ENgetheadcurveindex Closes #31 --- build/WinSDK/epanet2.def | 2 +- include/epanet2.bas | 2 +- include/epanet2.h | 2 +- include/epanet2.vb | 2 +- src/epanet.c | 10 ++++------ 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/build/WinSDK/epanet2.def b/build/WinSDK/epanet2.def index 1e2bd35..8d1087b 100644 --- a/build/WinSDK/epanet2.def +++ b/build/WinSDK/epanet2.def @@ -66,7 +66,7 @@ EXPORTS ENgetqualinfo = _ENgetqualinfo@16 ENsetbasedemand = _ENsetbasedemand@12 ENgetaveragepatternvalue = _ENgetaveragepatternvalue@8 - ENgetheadcurve = _ENgetheadcurve@8 + ENgetheadcurveindex = _ENgetheadcurveindex@8 ENgetpumptype = _ENgetpumptype@8 ENgetcurveindex = _ENgetcurveindex@8 ENgetcurveid = _ENgetcurveid@8 diff --git a/include/epanet2.bas b/include/epanet2.bas index 9ceeb2b..1c1435c 100644 --- a/include/epanet2.bas +++ b/include/epanet2.bas @@ -206,7 +206,7 @@ Global Const EN_CUSTOM = 2 ' user-defined custom curve Declare Function ENgetlinkvalue Lib "epanet2.dll" (ByVal Index As Long, ByVal Code As Long, Value As Single) As Long Declare Function ENgetcurve Lib "epanet2.dll" (ByVal CurveIndex As Long, ByVal CurveID As String, nValues As Long, xValues As Any, yValues As Any) As Long - Declare Function ENgetheadcurve Lib "epanet2.dll" (ByVal Index As Long, ByVal ID As String) As Long + Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal PumpIndex As Long, ByVal CurveIndex As Long) As Long Declare Function ENgetpumptype Lib "epanet2.dll" (ByVal Index As Long, PumpType As Long) As Long Declare Function ENgetversion Lib "epanet2.dll" (Value As Long) As Long diff --git a/include/epanet2.h b/include/epanet2.h index 5908ec9..515af28 100755 --- a/include/epanet2.h +++ b/include/epanet2.h @@ -258,7 +258,7 @@ extern "C" { int DLLEXPORT ENgetlinkvalue(int index, int code, EN_API_FLOAT_TYPE *value); int DLLEXPORT ENgetcurve(int curveIndex, char* id, int *nValues, EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues); - int DLLEXPORT ENgetheadcurve(int index, char *id); + int DLLEXPORT ENgetheadcurveindex(int index, int *curveindex); int DLLEXPORT ENgetpumptype(int index, int *type); int DLLEXPORT ENgetversion(int *version); diff --git a/include/epanet2.vb b/include/epanet2.vb index 1e86417..9cd3e2c 100644 --- a/include/epanet2.vb +++ b/include/epanet2.vb @@ -200,7 +200,7 @@ Public Const EN_CUSTOM = 2 ' user-defined custom curve Declare Function ENgetlinkvalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByRef Value As Single) As Int32 Declare Function ENgetcurve Lib "epanet2.dll" (ByVal CurveIndex As Int32, ByRef nValues As Int32, ByRef xValues As Single, ByRef yValues As Single) As Int32 'ES - Declare Function ENgetheadcurve Lib "epanet2.dll" (ByVal Index As Int32, ByVal ID As StringBuilder) As Int32 'ES + Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal Index As Int32, ByVal CurveIndex As int32) As Int32 'ES Declare Function ENgetpumptype Lib "epanet2.dll" (ByVal Index As Int32, ByRef PumpType As Int32) As Int32 'ES Declare Function ENgetversion Lib "epanet2.dll" (ByRef Value As Int32) As Int32 diff --git a/src/epanet.c b/src/epanet.c index 18ef1c6..b088447 100755 --- a/src/epanet.c +++ b/src/epanet.c @@ -2764,21 +2764,19 @@ int DLLEXPORT ENsetqualtype(int qualcode, char *chemname, return(0); } -int DLLEXPORT ENgetheadcurve(int index, char *id) +int DLLEXPORT ENgetheadcurveindex(int index, int *curveindex) /*---------------------------------------------------------------- ** Input: index = index of pump in list of links -** Output: id = head curve ID +** Output: curveindex = head curve index ** Returns: error code -** Purpose: retrieves ID of a head curve for specific link index +** Purpose: retrieves index of a head curve for specific link index ** -** NOTE: 'id' must be able to hold MAXID characters **---------------------------------------------------------------- */ { - strcpy(id,""); if (!Openflag) return(102); if (index < 1 || index > Nlinks || PUMP != Link[index].Type) return(204); - strcpy(id,Curve[Pump[PUMPINDEX(index)].Hcurve].ID); + *curveindex = Pump[PUMPINDEX(index)].Hcurve; return(0); }