@@ -3,7 +3,7 @@ unit epanet2;
|
||||
{ Declarations of imported procedures from the EPANET PROGRAMMERs TOOLKIT }
|
||||
{ (EPANET2.DLL) }
|
||||
|
||||
{Last updated on 11/04/19}
|
||||
{Last updated on 11/09/19}
|
||||
|
||||
interface
|
||||
|
||||
@@ -313,7 +313,7 @@ const
|
||||
function ENsetqualtype(QualCode: Integer; ChemName: PAnsiChar; ChemUnits: PAnsiChar; TraceNodeID: PAnsiChar): Integer; stdcall; external EpanetLib;
|
||||
|
||||
{Node Functions}
|
||||
function ENaddnode(ID: PAnsiChar; NodeType: Integer): Integer; stdcall; external EpanetLib;
|
||||
function ENaddnode(ID: PAnsiChar; NodeType: Integer; var Index: Integer): Integer; stdcall; external EpanetLib;
|
||||
function ENdeletenode(Index: Integer; ActionCode: Integer): Integer; stdcall; external EpanetLib;
|
||||
function ENgetnodeindex(ID: PAnsiChar; var Index: Integer): Integer; stdcall; external EpanetLib;
|
||||
function ENgetnodeid(Index: Integer; ID: PAnsiChar): Integer; stdcall; external EpanetLib;
|
||||
@@ -341,7 +341,7 @@ const
|
||||
function ENsetdemandname(NodeIndex: Integer; DemandIndex: Integer; DemandName: PAnsiChar): Integer; stdcall; external EpanetLib;
|
||||
|
||||
{Link Functions}
|
||||
function ENaddlink(ID: PAnsiChar; LinkType: Integer; FromNode: PAnsiChar; ToNode: PAnsiChar): Integer; stdcall; external EpanetLib;
|
||||
function ENaddlink(ID: PAnsiChar; LinkType: Integer; FromNode: PAnsiChar; ToNode: PAnsiChar; var Index: Integer): Integer; stdcall; external EpanetLib;
|
||||
function ENdeletelink(Index: Integer; ActionCode: Integer): Integer; stdcall; external EpanetLib;
|
||||
function ENgetlinkindex(ID: PAnsiChar; var Index: Integer): Integer; stdcall; external EpanetLib;
|
||||
function ENgetlinkid(Index: Integer; ID: PAnsiChar): Integer; stdcall; external EpanetLib;
|
||||
|
||||
33
src/epanet.c
33
src/epanet.c
@@ -7,7 +7,7 @@
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 11/04/2019
|
||||
Last Updated: 11/09/2019
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
@@ -4183,6 +4183,9 @@ int DLLEXPORT EN_setheadcurveindex(EN_Project p, int linkIndex, int curveIndex)
|
||||
|
||||
double *Ucf = p->Ucf;
|
||||
int pumpIndex;
|
||||
int oldCurveIndex;
|
||||
int newCurveType;
|
||||
int err = 0;
|
||||
Spump *pump;
|
||||
|
||||
// Check for valid parameters
|
||||
@@ -4191,15 +4194,33 @@ int DLLEXPORT EN_setheadcurveindex(EN_Project p, int linkIndex, int curveIndex)
|
||||
if (PUMP != net->Link[linkIndex].Type) return 0;
|
||||
if (curveIndex < 0 || curveIndex > net->Ncurves) return 206;
|
||||
|
||||
// Assign the new curve to the pump
|
||||
// Save values that need to be restored in case new curve is invalid
|
||||
pumpIndex = findpump(net, linkIndex);
|
||||
pump = &p->network.Pump[pumpIndex];
|
||||
oldCurveIndex = pump->Hcurve;
|
||||
newCurveType = p->network.Curve[curveIndex].Type;
|
||||
|
||||
// Assign the new curve to the pump
|
||||
pump->Ptype = NOCURVE;
|
||||
pump->Hcurve = curveIndex;
|
||||
if (curveIndex == 0) return 0;
|
||||
|
||||
// Update the pump curve's parameters and convert their units
|
||||
updatepumpparams(p, pumpIndex);
|
||||
// Update the pump's head curve parameters (which also changes
|
||||
// the new curve's Type to PUMP_CURVE)
|
||||
err = updatepumpparams(p, pumpIndex);
|
||||
|
||||
// If the parameter updating failed (new curve was not a valid pump curve)
|
||||
// restore the pump's original curve and its parameters
|
||||
if (err > 0)
|
||||
{
|
||||
p->network.Curve[curveIndex].Type = newCurveType;
|
||||
pump->Ptype = NOCURVE;
|
||||
pump->Hcurve = oldCurveIndex;
|
||||
if (oldCurveIndex == 0) return err;
|
||||
updatepumpparams(p, pumpIndex);
|
||||
}
|
||||
|
||||
// Convert the units of the updated pump parameters to feet and cfs
|
||||
if (pump->Ptype == POWER_FUNC)
|
||||
{
|
||||
pump->H0 /= Ucf[HEAD];
|
||||
@@ -4209,9 +4230,7 @@ int DLLEXPORT EN_setheadcurveindex(EN_Project p, int linkIndex, int curveIndex)
|
||||
pump->Qmax /= Ucf[FLOW];
|
||||
pump->Hmax /= Ucf[HEAD];
|
||||
|
||||
// Designate the newly assigned curve as being a Pump Curve
|
||||
p->network.Curve[curveIndex].Type = PUMP_CURVE;
|
||||
return 0;
|
||||
return err;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Reference in New Issue
Block a user