From e2df3e87ace62351446276a6d90e25c5edc5741c Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Thu, 19 Jan 2023 20:45:30 +0200 Subject: [PATCH] Adding support for VB Also supporting C89 compiler. --- include/epanet2.bas | 7 +++++++ include/epanet2.def | 1 + src/epanet.c | 7 ++++--- src/report.c | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/epanet2.bas b/include/epanet2.bas index bc2ce1e..2d41bb2 100644 --- a/include/epanet2.bas +++ b/include/epanet2.bas @@ -253,6 +253,12 @@ Public Const EN_R_IS_OPEN = 1 ' Rule status types Public Const EN_R_IS_CLOSED = 2 Public Const EN_R_IS_ACTIVE = 3 +Public Const EN_STEP_REPORT = 0 ' Types of events that can cause a timestep to end +Public Const EN_STEP_HYD = 1 +Public Const EN_STEP_WQ = 2 +Public Const EN_STEP_TANKEVENT = 3 +Public Const EN_STEP_CONTROLEVENT = 4 + Public Const EN_MISSING As Double = -1.0E10 'These are the external functions that comprise the DLL @@ -302,6 +308,7 @@ Public Const EN_MISSING As Double = -1.0E10 Declare Function ENgeterror Lib "epanet2.dll" (ByVal errcode As Long, ByVal errmsg As String, ByVal maxLen As Long) As Long Declare Function ENgetstatistic Lib "epanet2.dll" (ByVal type_ As Long, ByRef value As Single) As Long Declare Function ENgetresultindex Lib "epanet2.dll" (ByVal type_ As Long, ByVal index As Long, ByRef value As Long) As Long + Declare Function ENtimetonextevent Lib "epanet2.dll" (eventType As Long, duration As Long, elementIndex As Long) As Long 'Analysis Options Functions Declare Function ENgetoption Lib "epanet2.dll" (ByVal option_ As Long, value As Single) As Long diff --git a/include/epanet2.def b/include/epanet2.def index 66b87ed..d72da8e 100644 --- a/include/epanet2.def +++ b/include/epanet2.def @@ -131,3 +131,4 @@ EXPORTS ENstepQ = _ENstepQ@4 ENusehydfile = _ENusehydfile@4 ENwriteline = _ENwriteline@4 + ENtimetonextevent = _ENtimetonextevent@12 \ No newline at end of file diff --git a/src/epanet.c b/src/epanet.c index a5c83ac..6516f7a 100644 --- a/src/epanet.c +++ b/src/epanet.c @@ -1629,13 +1629,14 @@ int DLLEXPORT EN_timetonextevent(EN_Project p, int *eventType, long *duration, { Times *time = &p->times; long hydStep, tankStep, controlStep; - + int iTank, iControl; + hydStep = time->Hstep; tankStep = hydStep; controlStep = hydStep; - int iTank = tanktimestep(p, &tankStep); - int iControl = controltimestep(p, &controlStep); + iTank = tanktimestep(p, &tankStep); + iControl = controltimestep(p, &controlStep); // return the lesser of the three step lengths if (controlStep < tankStep) { diff --git a/src/report.c b/src/report.c index 2922332..ae675da 100644 --- a/src/report.c +++ b/src/report.c @@ -885,14 +885,14 @@ void writeline(Project *pr, char *s) **-------------------------------------------------------------- */ { + Report *rpt = &pr->report; + if (pr->report.reportCallback != NULL) { pr->report.reportCallback(pr->report.reportCallbackUserData, pr, s); return; } - Report *rpt = &pr->report; - if (rpt->RptFile == NULL) return; if (rpt->Rptflag) {