diff --git a/src/enumstxt.h b/src/enumstxt.h index 65962a6..222f8d3 100755 --- a/src/enumstxt.h +++ b/src/enumstxt.h @@ -1,13 +1,13 @@ /* ***************************************************************************** Project: OWA EPANET - Version: 2.2 + Version: 2.3 Module: enumstxt.h Description: text strings for enumerated data types Authors: see AUTHORS Copyright: see AUTHORS License: see LICENSE - Last Updated: 06/24/2024 + Last Updated: 03/10/2025 ****************************************************************************** */ @@ -117,6 +117,14 @@ char *RptFlagTxt[] = {w_NO, char *BackflowTxt[] = {w_NO, w_YES, NULL}; + +char *CurveTypeTxt[] = {c_VOLUME, + c_PUMP, + c_EFFIC, + c_HEADLOSS, + c_GENERIC, + c_VALVE, + NULL}; char *SectTxt[] = {s_TITLE, s_JUNCTIONS, s_RESERVOIRS, s_TANKS, s_PIPES, s_PUMPS, diff --git a/src/inpfile.c b/src/inpfile.c index da69fd0..84ff42e 100644 --- a/src/inpfile.c +++ b/src/inpfile.c @@ -7,7 +7,7 @@ Description: saves network data to an EPANET formatted text file Authors: see AUTHORS Copyright: see AUTHORS License: see LICENSE -Last Updated: 02/14/2025 +Last Updated: 03/11/2025 ****************************************************************************** */ @@ -34,6 +34,7 @@ extern char *TstatTxt[]; extern char *RptFlagTxt[]; extern char *SectTxt[]; extern char *BackflowTxt[]; +extern char *CurveTypeTxt[]; void saveauxdata(Project *pr, FILE *f) /* @@ -434,15 +435,20 @@ int saveinpfile(Project *pr, const char *fname) // Write [CURVES] section fprintf(f, "\n\n"); fprintf(f, s_CURVES); - fprintf(f, "\n;;%-31s\t%-12s\t%-12s", - "ID", "X-Value", "Y-Value"); + fprintf(f, "\n;;%-31s\t%-12s\t%-12s", "ID", "X-Value", "Y-Value"); for (i = 1; i <= net->Ncurves; i++) { - if (net->Curve[i].Comment) fprintf(f, "\n;%s", net->Curve[i].Comment); - for (j = 0; j < net->Curve[i].Npts; j++) + curve = &net->Curve[i]; + if (curve->Comment) fprintf(f, "\n;%s", curve->Comment); + if (curve->Npts > 0) { - curve = &net->Curve[i]; - fprintf(f, "\n %-31s\t%-12.4f\t%-12.4f", curve->ID, curve->X[j], curve->Y[j]); + fprintf(f, "\n %-31s\t%-12.4f\t%-12.4f\t%s", curve->ID, + curve->X[0], curve->Y[0], CurveTypeTxt[curve->Type]); + for (j = 1; j < curve->Npts; j++) + { + fprintf(f, "\n %-31s\t%-12.4f\t%-12.4f", curve->ID, + curve->X[j], curve->Y[j]); + } } } diff --git a/src/input3.c b/src/input3.c index 281c09b..8568379 100644 --- a/src/input3.c +++ b/src/input3.c @@ -7,7 +7,7 @@ Description: parses network data from a line of an EPANET input file Authors: see AUTHORS Copyright: see AUTHORS License: see LICENSE -Last Updated: 02/14/2025 +Last Updated: 03/10/2025 ****************************************************************************** */ @@ -26,6 +26,7 @@ extern char *MixTxt[]; extern char *Fldname[]; extern char *DemandModelTxt[]; extern char *BackflowTxt[]; +extern char *CurveTypeTxt[]; // Imported Functions extern int addnodeID(Network *, int, char *); @@ -740,7 +741,7 @@ int curvedata(Project *pr) Network *net = &pr->network; Parser *parser = &pr->parser; - int i; + int i, ctype; double x, y; Scurve *curve; @@ -748,6 +749,11 @@ int curvedata(Project *pr) if (parser->Ntokens < 3) return 201; if (!getfloat(parser->Tok[1], &x)) return setError(parser, 1, 202); if (!getfloat(parser->Tok[2], &y)) return setError(parser, 2, 202); + ctype = -1; + if (parser->Ntokens > 3) + { + ctype = findmatch(parser->Tok[3], CurveTypeTxt); + } // Check if previous input line was for the same curve if (parser->PrevCurve && strcmp(parser->Tok[0], parser->PrevCurve->ID) == 0) @@ -777,6 +783,7 @@ int curvedata(Project *pr) curve->X[curve->Npts] = x; curve->Y[curve->Npts] = y; curve->Npts++; + if (ctype >= 0) curve->Type = (CurveType)ctype; // Save a reference to this curve for processing additional curve data parser->PrevCurve = curve; diff --git a/src/text.h b/src/text.h index 087977e..57f461e 100755 --- a/src/text.h +++ b/src/text.h @@ -7,7 +7,7 @@ Authors: see AUTHORS Copyright: see AUTHORS License: see LICENSE - Last Updated: 02/11/2025 + Last Updated: 03/10/2025 ****************************************************************************** */ @@ -270,6 +270,8 @@ #define c_PUMP "PUMP" #define c_EFFIC "EFFIC" #define c_VOLUME "VOLUME" +#define c_VALVE "VALVE" +#define c_GENERIC "GENERIC" //------- Text Phrases ------------------------------------