From 36b78f28d30f854b5ad07b8f906d19d12c73d936 Mon Sep 17 00:00:00 2001 From: Lew Rossman Date: Fri, 8 Feb 2019 12:07:56 -0500 Subject: [PATCH] New function `clearreport` added (see issue #383) The newly added `gettitle` and `settitle` functions were moved from the Reporting Functions section to the Project (formerly System) Functions section of epanet2.c and epanet.c. --- include/epanet2.bas | 9 +- include/epanet2.def | 7 +- include/epanet2.h | 17 ++-- include/epanet2.vb | 9 +- include/epanet2_2.h | 65 +++++++------- include/epanet_py.h | 5 +- src/epanet.c | 163 +++++++++++++++++++---------------- src/epanet2.c | 36 ++++---- src/epanet_py.c | 20 ++++- src/funcs.h | 3 +- src/report.c | 15 ++++ win_build/WinSDK/epanet2.def | 3 + 12 files changed, 211 insertions(+), 141 deletions(-) diff --git a/include/epanet2.bas b/include/epanet2.bas index 09e9e4c..3f4dcb9 100644 --- a/include/epanet2.bas +++ b/include/epanet2.bas @@ -5,7 +5,7 @@ Attribute VB_Name = "Module1" 'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT '(EPANET2.DLL) -'Last updated on 01/08/2019 +'Last updated on 02/08/2019 ' These are codes used by the DLL functions Public Const EN_ELEVATION = 0 ' Node parameters @@ -220,11 +220,13 @@ Public Const EN_R_IS_ACTIVE = 3 'These are the external functions that comprise the DLL -'System Functions +'Project Functions Declare Function ENgetversion Lib "epanet2.dll" (value As Long) As Long Declare Function ENepanet Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String, ByVal pviewprog As Any) As Long Declare Function ENinit Lib "epanet2.dll" (ByVal rptFile As String, ByVal outFile As String, ByVal unitsType As Long, ByVal headlossType As Long) As Long Declare Function ENopen Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String) As Long + Declare Function ENgettitle Lib "epanet2.dll" (ByVal line1 As String, ByVal line2 As String, ByVal line3 As String) As Long + Declare Function ENsettitle Lib "epanet2.dll" (ByVal titleline1 As String, ByVal titleline2 As String, ByVal titleline3 As String) As Long Declare Function ENsaveinpfile Lib "epanet2.dll" (ByVal filename As String) As Long Declare Function ENclose Lib "epanet2.dll" () As Long @@ -251,14 +253,13 @@ Public Const EN_R_IS_ACTIVE = 3 'Reporting Functions Declare Function ENwriteline Lib "epanet2.dll" (ByVal line As String) As Long Declare Function ENreport Lib "epanet2.dll" () As Long + Declare Function ENclearreport Lib "epanet2.dll" () As Long Declare Function ENresetreport Lib "epanet2.dll" () As Long Declare Function ENsetreport Lib "epanet2.dll" (ByVal format As String) As Long Declare Function ENsetstatusreport Lib "epanet2.dll" (ByVal level As Long) As Long Declare Function ENgetcount Lib "epanet2.dll" (ByVal object As Long, count As Long) As Long 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 ENgettitle Lib "epanet2.dll" (ByVal titleline1 As String, ByVal titleline2 As String, ByVal titleline3 As String) As Long - Declare Function ENsettitle Lib "epanet2.dll" (ByVal titleline1 As String, ByVal titleline2 As String, ByVal titleline3 As String) 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 19b76e5..878ca99 100644 --- a/include/epanet2.def +++ b/include/epanet2.def @@ -7,6 +7,7 @@ EXPORTS ENaddnode = _ENaddnode@8 ENaddpattern = _ENaddpattern@4 ENaddrule = _ENaddrule@4 + ENclearreport = _ENclearreport@0 ENclose = _ENclose@0 ENcloseH = _ENcloseH@0 ENcloseQ = _ENcloseQ@0 @@ -57,7 +58,8 @@ EXPORTS ENgetruleID = _ENgetruleID@8 ENgetstatistic = _ENgetstatistic@8 ENgetthenaction = _ENgetthenaction@20 - ENgettimeparam = _ENgettimeparam@8 + ENgettimeparam = _ENgettimeparam@8 + ENgettitle = _ENgettitle@12 ENgetversion = _ENgetversion@4 ENinit = _ENinit@16 ENinitH = _ENinitH@4 @@ -106,7 +108,8 @@ EXPORTS ENsetstatusreport = _ENsetstatusreport@4 ENsettankdata = _ENsettankdata@32 ENsetthenaction = _ENsetthenaction@20 - ENsettimeparam = _ENsettimeparam@8 + ENsettimeparam = _ENsettimeparam@8 + ENsettitle = _ENsettitle@12 ENsolveH = _ENsolveH@0 ENsolveQ = _ENsolveQ@0 ENstepQ = _ENstepQ@4 diff --git a/include/epanet2.h b/include/epanet2.h index 55bde59..96285d4 100644 --- a/include/epanet2.h +++ b/include/epanet2.h @@ -7,7 +7,7 @@ Authors: see AUTHORS Copyright: see AUTHORS License: see LICENSE - Last Updated: 01/08/2019 + Last Updated: 02/08/2019 ****************************************************************************** */ @@ -60,7 +60,7 @@ extern "C" { /******************************************************************** - System Functions + Project Functions ********************************************************************/ @@ -72,6 +72,12 @@ extern "C" { int DLLEXPORT ENopen(const char *inpFile, const char *rptFile, const char *outFile); + + int DLLEXPORT ENgettitle(char *line1, char *line2, char *line3); + + int DLLEXPORT ENsettitle(char *line1, char *line2, char *line3); + + int DLLEXPORT ENgetcount(int object, int *count); int DLLEXPORT ENsaveinpfile(const char *filename); @@ -131,6 +137,8 @@ extern "C" { int DLLEXPORT ENreport(); + int DLLEXPORT ENclearreport(); + int DLLEXPORT ENresetreport(); int DLLEXPORT ENsetreport(char *format); @@ -139,15 +147,10 @@ extern "C" { int DLLEXPORT ENgetversion(int *version); - int DLLEXPORT ENgetcount(int object, int *count); - int DLLEXPORT ENgeterror(int errcode, char *errmsg, int maxLen); int DLLEXPORT ENgetstatistic(int type, EN_API_FLOAT_TYPE* value); - int DLLEXPORT ENgettitle(char *titleline1, char *titleline2, char *titleline3); - - int DLLEXPORT ENsettitle(char *titleline1, char *titleline2, char *titleline3); /******************************************************************** diff --git a/include/epanet2.vb b/include/epanet2.vb index 6fee91b..b882562 100644 --- a/include/epanet2.vb +++ b/include/epanet2.vb @@ -4,7 +4,7 @@ 'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT '(EPANET2.DLL) for use with VB.Net. -'Last updated on 01/08/2019 +'Last updated on 02/08/2019 Imports System.Runtime.InteropServices Imports System.Text @@ -225,11 +225,13 @@ Public Const EN_R_IS_ACTIVE = 3 'These are the external functions that comprise the DLL -'System Functions +'Project Functions Declare Function ENgetversion Lib "epanet2.dll" (value As Int32) As Int32 Declare Function ENepanet Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String, ByVal pviewprog As Any) As Int32 Declare Function ENinit Lib "epanet2.dll" (ByVal rptFile As String, ByVal outFile As String, ByVal unitsType As Int32, ByVal headlossType As Int32) As Int32 Declare Function ENopen Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String) As Int32 + Declare Function ENgettitle Lib "epanet2.dll" (ByVal titleline1 As String, ByVal titleline2 As String, ByVal titleline3 As String) As Int32 + Declare Function ENsettitle Lib "epanet2.dll" (ByVal titleline1 As String, ByVal titleline2 As String, ByVal titleline3 As String) As Int32 Declare Function ENsaveinpfile Lib "epanet2.dll" (ByVal filename As String) As Int32 Declare Function ENclose Lib "epanet2.dll" () As Int32 @@ -256,14 +258,13 @@ Public Const EN_R_IS_ACTIVE = 3 'Reporting Functions Declare Function ENwriteline Lib "epanet2.dll" (ByVal line As String) As Int32 Declare Function ENreport Lib "epanet2.dll" () As Int32 + Declare Function ENclearreport Lib "epanet2.dll" () As Int32 Declare Function ENresetreport Lib "epanet2.dll" () As Int32 Declare Function ENsetreport Lib "epanet2.dll" (ByVal format As String) As Int32 Declare Function ENsetstatusreport Lib "epanet2.dll" (ByVal level As Int32) As Int32 Declare Function ENgetcount Lib "epanet2.dll" (ByVal object As Int32, count As Int32) As Int32 Declare Function ENgeterror Lib "epanet2.dll" (ByVal errcode As Int32, ByVal errmsg As String, ByVal maxLen As Int32) As Int32 Declare Function ENgetstatistic Lib "epanet2.dll" (ByVal type_ As Int32, ByRef value As Single) As Int32 - Declare Function ENgettitle Lib "epanet2.dll" (ByVal titleline1 As String, ByVal titleline2 As String, ByVal titleline3 As String) As Int32 - Declare Function ENsettitle Lib "epanet2.dll" (ByVal titleline1 As String, ByVal titleline2 As String, ByVal titleline3 As String) As Int32 'Analysis Options Functions Declare Function ENgetoption Lib "epanet2.dll" (ByVal option As Int32, value As Single) As Int32 diff --git a/include/epanet2_2.h b/include/epanet2_2.h index fbf9c15..2f32d70 100644 --- a/include/epanet2_2.h +++ b/include/epanet2_2.h @@ -11,7 +11,7 @@ Authors: see AUTHORS Copyright: see AUTHORS License: see LICENSE - Last Updated: 01/08/2019 + Last Updated: 02/08/2019 ****************************************************************************** */ @@ -50,7 +50,7 @@ typedef struct Project *EN_Project; /******************************************************************** - System Functions + Project Functions ********************************************************************/ @@ -126,6 +126,33 @@ typedef struct Project *EN_Project; int DLLEXPORT EN_open(EN_Project ph, const char *inpFile, const char *rptFile, const char *outFile); + /** + @brief Retrieves the title lines of the project + @param[out] line1 first title line + @param[out] line2 second title line + @param[out] line3 third title line + @return an error code + */ + int DLLEXPORT EN_gettitle(EN_Project ph, char *line1, char *line2, char *line3); + + /** + @brief Sets the title lines of the project + @param line1 first title line + @param line2 second title line + @param line3 third title line + @return an error code + */ + int DLLEXPORT EN_settitle(EN_Project ph, char *line1, char *line2, char *line3); + + /** + @brief Retrieves the number of objects of a given type in a project. + @param ph an EPANET project handle. + @param object a type of object to count (see @ref EN_CountType) + @param[out] count number of objects of the specified type + @return an error code + */ + int DLLEXPORT EN_getcount(EN_Project ph, int object, int *count); + /** @brief Saves a project's data to an EPANET-formatted text file. @param ph an EPANET project handle. @@ -490,6 +517,13 @@ typedef struct Project *EN_Project; */ int DLLEXPORT EN_report(EN_Project ph); + /** + @brief Clears the contents of a project's report file. + @param ph an EPANET project handle. + @return and error code. + */ + int DLLEXPORT EN_clearreport(EN_Project ph); + /** @brief Resets a project's report options to their default values. @param ph an EPANET project handle. @@ -551,15 +585,6 @@ typedef struct Project *EN_Project; */ int DLLEXPORT EN_getversion(int *version); - /** - @brief Retrieves the number of objects of a given type in a project. - @param ph an EPANET project handle. - @param object a type of object to count (see @ref EN_CountType) - @param[out] count number of objects of the specified type - @return an error code - */ - int DLLEXPORT EN_getcount(EN_Project ph, int object, int *count); - /** @brief Returns the text of an error message generated by an error code. @param errcode an error code. @@ -579,24 +604,6 @@ typedef struct Project *EN_Project; @return an error code */ int DLLEXPORT EN_getstatistic(EN_Project ph, int type, double* value); - - /** - @brief Retrieves the title lines of the project - @param[out] titleline1 first title line - @param[out] titleline2 second title line - @param[out] titleline3 third title line - @return an error code - */ - int DLLEXPORT EN_gettitle(EN_Project ph, char *titleline1, char *titleline2, char *titleline3); - - /** - @brief Sets the title lines of the project - @param titleline1 first title line - @param titleline2 second title line - @param titleline3 third title line - @return an error code - */ - int DLLEXPORT EN_settitle(EN_Project ph, char *titleline1, char *titleline2, char *titleline3); /******************************************************************** diff --git a/include/epanet_py.h b/include/epanet_py.h index 9af6951..a7e3b84 100644 --- a/include/epanet_py.h +++ b/include/epanet_py.h @@ -7,7 +7,7 @@ Authors: see AUTHORS Copyright: see AUTHORS License: see LICENSE - Last Updated: 12/10/2018 + Last Updated: 02/08/2019 ****************************************************************************** */ @@ -34,6 +34,8 @@ int EXPORT_PY_API proj_delete(Handle *ph_inout); int EXPORT_PY_API proj_run(Handle ph, const char *input_path, const char *report_path, const char *output_path); int EXPORT_PY_API proj_init(Handle ph, const char *rptFile, const char *outFile, EN_FlowUnits unitsType, EN_HeadLossType headLossType); int EXPORT_PY_API proj_open(Handle ph, const char *inpFile, const char *rptFile, const char *binOutFile); +int EXPORT_PY_API proj_gettitle(Handle ph, char *line1, char *line2, char *line3); +int EXPORT_PY_API proj_settitle(Handle ph, const char *line1, const char *line2, const char *line3); int EXPORT_PY_API proj_savefile(Handle ph, const char *inpfilename); int EXPORT_PY_API proj_close(Handle ph); @@ -60,6 +62,7 @@ int EXPORT_PY_API qual_close(Handle ph); int EXPORT_PY_API rprt_writeline(Handle ph, char *line); int EXPORT_PY_API rprt_writeresults(Handle ph); +int EXPORT_PY_API rprt_clear(Handle ph); int EXPORT_PY_API rprt_reset(Handle ph); int EXPORT_PY_API rprt_set(Handle ph, char *reportCommand); int EXPORT_PY_API rprt_setlevel(Handle ph, EN_StatusReport code); diff --git a/src/epanet.c b/src/epanet.c index a8b424c..eda2523 100644 --- a/src/epanet.c +++ b/src/epanet.c @@ -7,7 +7,7 @@ Authors: see AUTHORS Copyright: see AUTHORS License: see LICENSE - Last Updated: 01/11/2019 + Last Updated: 02/08/2019 ****************************************************************************** */ @@ -32,7 +32,7 @@ /******************************************************************** - System Functions + Project Functions ********************************************************************/ @@ -237,6 +237,79 @@ int DLLEXPORT EN_open(EN_Project p, const char *inpFile, const char *rptFile, return errcode; } +int DLLEXPORT EN_gettitle(EN_Project p, char *line1, char *line2, char *line3) +/*---------------------------------------------------------------- +** Input: None +** Output: line1, line2, line3 = project's title lines +** Returns: error code +** Purpose: retrieves the title lines of the project +**---------------------------------------------------------------- +*/ +{ + if (!p->Openflag) return 102; + strcpy(line1, p->Title[0]); + strcpy(line2, p->Title[1]); + strcpy(line3, p->Title[2]); + return 0; +} + +int DLLEXPORT EN_settitle(EN_Project p, char *line1, char *line2, char *line3) +/*---------------------------------------------------------------- +** Input: line1, line2, line3 = project's title lines +** Returns: error code +** Purpose: sets the title lines of the project +**---------------------------------------------------------------- +*/ +{ + if (!p->Openflag) return 102; + strncpy(p->Title[0], line1, TITLELEN); + strncpy(p->Title[1], line2, TITLELEN); + strncpy(p->Title[2], line3, TITLELEN); + return 123; +} + +int DLLEXPORT EN_getcount(EN_Project p, int object, int *count) +/*---------------------------------------------------------------- +** Input: object = type of object to count (see EN_CountType) +** Output: count = number of objects of the specified type +** Returns: error code +** Purpose: Retrieves number of network objects of a given type +**---------------------------------------------------------------- +*/ +{ + Network *net = &p->network; + + *count = 0; + if (!p->Openflag) return 102; + switch (object) + { + case EN_NODECOUNT: + *count = net->Nnodes; + break; + case EN_TANKCOUNT: + *count = net->Ntanks; + break; + case EN_LINKCOUNT: + *count = net->Nlinks; + break; + case EN_PATCOUNT: + *count = net->Npats; + break; + case EN_CURVECOUNT: + *count = net->Ncurves; + break; + case EN_CONTROLCOUNT: + *count = net->Ncontrols; + break; + case EN_RULECOUNT: + *count = net->Nrules; + break; + default: + return 251; + } + return 0; +} + int DLLEXPORT EN_saveinpfile(EN_Project p, const char *filename) /*---------------------------------------------------------------- ** Input: filename = name of file to which project is saved @@ -791,6 +864,19 @@ int DLLEXPORT EN_report(EN_Project p) return errcode; } +int DLLEXPORT EN_clearreport(EN_Project p) +/*---------------------------------------------------------------- +** Input: none +** Output: none +** Returns: error code +** Purpose: clears the contents of a project's report file +**---------------------------------------------------------------- +*/ +{ + if (!p->Openflag) return 102; + return clearreport(p); +} + int DLLEXPORT EN_resetreport(EN_Project p) /*---------------------------------------------------------------- ** Input: none @@ -870,48 +956,6 @@ int DLLEXPORT EN_getversion(int *version) return 0; } -int DLLEXPORT EN_getcount(EN_Project p, int object, int *count) -/*---------------------------------------------------------------- -** Input: object = type of object to count (see EN_CountType) -** Output: count = number of objects of the specified type -** Returns: error code -** Purpose: Retrieves number of network objects of a given type -**---------------------------------------------------------------- -*/ -{ - Network *net = &p->network; - - *count = 0; - if (!p->Openflag) return 102; - switch (object) - { - case EN_NODECOUNT: - *count = net->Nnodes; - break; - case EN_TANKCOUNT: - *count = net->Ntanks; - break; - case EN_LINKCOUNT: - *count = net->Nlinks; - break; - case EN_PATCOUNT: - *count = net->Npats; - break; - case EN_CURVECOUNT: - *count = net->Ncurves; - break; - case EN_CONTROLCOUNT: - *count = net->Ncontrols; - break; - case EN_RULECOUNT: - *count = net->Nrules; - break; - default: - return 251; - } - return 0; -} - int DLLEXPORT EN_geterror(int errcode, char *errmsg, int maxLen) /*---------------------------------------------------------------- ** Input: errcode = an error or warnng code @@ -991,37 +1035,6 @@ int DLLEXPORT EN_getstatistic(EN_Project p, int type, double *value) return 0; } -int DLLEXPORT EN_gettitle(EN_Project p, char *titleline1, char *titleline2, char *titleline3) -/*---------------------------------------------------------------- -** Input: None -** Output: titleline1-3 = project's title lines -** Returns: error code -** Purpose: retrieves the title lines of the project -**---------------------------------------------------------------- -*/ -{ - if (!p->Openflag) return 102; - strcpy(titleline1, p->Title[0]); - strcpy(titleline2, p->Title[1]); - strcpy(titleline3, p->Title[2]); - return 0; -} - -int DLLEXPORT EN_settitle(EN_Project p, char *titleline1, char *titleline2, char *titleline3) -/*---------------------------------------------------------------- -** Input: titleline1-3 = project's title lines -** Returns: error code -** Purpose: sets the title lines of the project -**---------------------------------------------------------------- -*/ -{ - if (!p->Openflag) return 102; - strncpy(p->Title[0], titleline1, TITLELEN); - strncpy(p->Title[1], titleline2, TITLELEN); - strncpy(p->Title[2], titleline3, TITLELEN); - return 123; -} - /******************************************************************** Analysis Options Functions diff --git a/src/epanet2.c b/src/epanet2.c index faa1718..33d30cf 100644 --- a/src/epanet2.c +++ b/src/epanet2.c @@ -7,7 +7,7 @@ Authors: see AUTHORS Copyright: see AUTHORS License: see LICENSE - Last Updated: 01/09/2019 + Last Updated: 02/08/2019 ****************************************************************************** */ #ifndef __APPLE__ @@ -47,7 +47,7 @@ void removetmpfiles() /******************************************************************** - System Functions + Project Functions ********************************************************************/ @@ -102,6 +102,21 @@ int DLLEXPORT ENopen(const char *inpFile, const char *rptFile, const char *outFi return errcode; } +int DLLEXPORT ENgettitle(char *line1, char *line2, char *line3) +{ + return EN_gettitle(_defaultProject, line1, line2, line3) ; +} + +int DLLEXPORT ENsettitle(char *line1, char *line2, char *line3) +{ + return EN_settitle(_defaultProject, line1, line2, line3) ; +} + +int DLLEXPORT ENgetcount(int object, int *count) +{ + return EN_getcount(_defaultProject, object, count); +} + int DLLEXPORT ENsaveinpfile(const char *filename) { return EN_saveinpfile(_defaultProject, filename); @@ -174,6 +189,8 @@ int DLLEXPORT ENwriteline(char *line) { return EN_writeline(_defaultProject, lin int DLLEXPORT ENreport() { return EN_report(_defaultProject); } +int DLLEXPORT ENclearreport() { return EN_clearreport(_defaultProject); } + int DLLEXPORT ENresetreport() { return EN_resetreport(_defaultProject); } int DLLEXPORT ENsetreport(char *format) { return EN_setreport(_defaultProject, format); } @@ -185,11 +202,6 @@ int DLLEXPORT ENsetstatusreport(int level) int DLLEXPORT ENgetversion(int *version) { return EN_getversion(version); } -int DLLEXPORT ENgetcount(int object, int *count) -{ - return EN_getcount(_defaultProject, object, count); -} - int DLLEXPORT ENgeterror(int errcode, char *errmsg, int maxLen) { return EN_geterror(errcode, errmsg, maxLen); @@ -203,16 +215,6 @@ int DLLEXPORT ENgetstatistic(int type, EN_API_FLOAT_TYPE *value) return errcode; } -int DLLEXPORT ENgettitle(char *titleline1, char *titleline2, char *titleline3) -{ - return EN_gettitle(_defaultProject, titleline1, titleline2, titleline3) ; -} - -int DLLEXPORT ENsettitle(char *titleline1, char *titleline2, char *titleline3) -{ - return EN_settitle(_defaultProject, titleline1, titleline2, titleline3) ; -} - /******************************************************************** Analysis Options Functions diff --git a/src/epanet_py.c b/src/epanet_py.c index ec76631..72d69d9 100644 --- a/src/epanet_py.c +++ b/src/epanet_py.c @@ -7,7 +7,7 @@ Authors: see AUTHORS Copyright: see AUTHORS License: see LICENSE - Last Updated: 12/10/2018 + Last Updated: 02/08/2019 ****************************************************************************** */ @@ -84,6 +84,18 @@ int EXPORT_PY_API proj_open(Handle ph, const char *inpFile, const char *rptFile, return error_set(pr->error, EN_open(pr->project, inpFile, rptFile, binOutFile)); } +int EXPORT_PY_API proj_gettitle(Handle ph, char *line1, char *line2, char *line3) +{ + handle_t *pr = (handle_t *)ph; + return error_set(pr->error, EN_gettitle(pr->project, line1, line2, line3)); +} + +int EXPORT_PY_API proj_settitle(Handle ph, const char *line1, const char *line2, const char *line3) +{ + handle_t *pr = (handle_t *)ph; + return error_set(pr->error, EN_settitle(pr->project, line1, line2, line3)); +} + int EXPORT_PY_API proj_savefile(Handle ph, const char *filename) { handle_t *pr = (handle_t *)ph; @@ -213,6 +225,12 @@ int EXPORT_PY_API rprt_writeresults(Handle ph) return error_set(pr->error, EN_report(pr->project)); } +int EXPORT_PY_API rprt_clear(Handle ph) +{ + handle_t *pr = (handle_t *)ph; + return error_set(pr->error, EN_clearreport(pr->project)); +} + int EXPORT_PY_API rprt_reset(Handle ph) { handle_t *pr = (handle_t *)ph; diff --git a/src/funcs.h b/src/funcs.h index 28fd298..5594f22 100755 --- a/src/funcs.h +++ b/src/funcs.h @@ -7,7 +7,7 @@ Authors: see AUTHORS Copyright: see AUTHORS License: see LICENSE - Last Updated: 11/27/2018 + Last Updated: 02/08/2019 ****************************************************************************** */ #ifndef FUNCS_H @@ -108,6 +108,7 @@ int checkrules(Project *, long); // ------- REPORT.C ----------------- +int clearreport(Project *); int writereport(Project *); void writelogo(Project *); void writesummary(Project *); diff --git a/src/report.c b/src/report.c index 885e0b2..4e749e8 100644 --- a/src/report.c +++ b/src/report.c @@ -57,6 +57,21 @@ static int checklimits(Report *, double *, int, int); static char *fillstr(char *, char, int); static int getnodetype(Network *, int); +int clearreport(Project *pr) +/* +**------------------------------------------------------ +** Input: none +** Output: returns error code +** Purpose: clears contents of a project's report file +**------------------------------------------------------ +*/ +{ + Report *rpt = &pr->report; + if (rpt->RptFile == NULL) return 0; + if (freopen(rpt->Rpt1Fname, "w", rpt->RptFile) == NULL) return 303; + writelogo(pr); + return 0; +} int writereport(Project *pr) /* diff --git a/win_build/WinSDK/epanet2.def b/win_build/WinSDK/epanet2.def index 29c71eb..0f7d7bc 100644 --- a/win_build/WinSDK/epanet2.def +++ b/win_build/WinSDK/epanet2.def @@ -7,6 +7,7 @@ EXPORTS ENaddnode = _ENaddnode@8 ENaddpattern = _ENaddpattern@4 ENaddrule = _ENaddrule@4 + ENclearreport = _ENclearreport@0 ENclose = _ENclose@0 ENcloseH = _ENcloseH@0 ENcloseQ = _ENcloseQ@0 @@ -58,6 +59,7 @@ EXPORTS ENgetstatistic = _ENgetstatistic@8 ENgetthenaction = _ENgetthenaction@20 ENgettimeparam = _ENgettimeparam@8 + ENgettitle = _ENgettitle@12 ENgetversion = _ENgetversion@4 ENinit = _ENinit@16 ENinitH = _ENinitH@4 @@ -107,6 +109,7 @@ EXPORTS ENsettankdata = _ENsettankdata@32 ENsetthenaction = _ENsetthenaction@20 ENsettimeparam = _ENsettimeparam@8 + ENsettitle = _ENsettitle@12 ENsolveH = _ENsolveH@0 ENsolveQ = _ENsolveQ@0 ENstepQ = _ENstepQ@4