Skip to content

Commit

Permalink
Merge pull request #801 from OpenWaterAnalytics/API_fixes
Browse files Browse the repository at this point in the history
Fix two legacy API functions
  • Loading branch information
LRossman committed Jun 18, 2024
2 parents 109a93f + 6ac4156 commit d055157
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions src/epanet2.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,16 @@ int DLLEXPORT ENgetnodevalue(int index, int property, EN_API_FLOAT_TYPE *value)

int DLLEXPORT ENgetnodevalues(int property, EN_API_FLOAT_TYPE *values)
{
return EN_getnodevalues(_defaultProject, property, values);
int i, errcode = 0;
EN_API_FLOAT_TYPE value;

for (i = 1; i <= _defaultProject->network.Nnodes; i++)
{
errcode = ENgetnodevalue(i, property, &value);
values[i-1] = value;
if (errcode != 0) return errcode;
}
return 0;
}

int DLLEXPORT ENsetnodevalue(int index, int property, EN_API_FLOAT_TYPE value)
Expand Down Expand Up @@ -530,7 +539,16 @@ int DLLEXPORT ENgetlinkvalue(int index, int property, EN_API_FLOAT_TYPE *value)
}
int DLLEXPORT ENgetlinkvalues(int property, EN_API_FLOAT_TYPE *values)
{
return EN_getlinkvalues(_defaultProject, property, values);
int i, errcode = 0;
EN_API_FLOAT_TYPE value;

for (i = 1; i <= _defaultProject->network.Nlinks; i++)
{
errcode = ENgetlinkvalue(i, property, &value);
values[i-1] = value;
if (errcode != 0) return errcode;
}
return 0;
}

int DLLEXPORT ENsetlinkvalue(int index, int property, EN_API_FLOAT_TYPE value)
Expand Down
2 changes: 1 addition & 1 deletion src/report.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ void writesummary(Project *pr)
if (qual->Qualflag == NONE || time->Dur == 0.0) sprintf(s, FMT29);
else if (qual->Qualflag == CHEM) sprintf(s, FMT30, qual->ChemName);
else if (qual->Qualflag == TRACE) sprintf(s, FMT31, net->Node[qual->TraceNode].ID);
else if (qual->Qualflag == AGE) printf(s, FMT32);
else if (qual->Qualflag == AGE) sprintf(s, FMT32);
writeline(pr, s);
if (qual->Qualflag != NONE && time->Dur > 0)
{
Expand Down

0 comments on commit d055157

Please sign in to comment.