Network building enhancements

This commit is contained in:
Lew Rossman
2020-02-04 10:01:23 -05:00
parent 77243b1607
commit 80f9acfe4d
16 changed files with 188 additions and 93 deletions

View File

@@ -5,7 +5,7 @@ Attribute VB_Name = "Module1"
'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
'(EPANET2.DLL)
'Last updated on 11/04/2019
'Last updated on 02/01/2020
' These are codes used by the DLL functions
Public Const EN_ELEVATION = 0 ' Node parameters
@@ -62,6 +62,7 @@ Public Const EN_PUMP_HCURVE = 19
Public Const EN_PUMP_ECURVE = 20
Public Const EN_PUMP_ECOST = 21
Public Const EN_PUMP_EPAT = 22
Public Const EN_GPV_CURVE = 23
Public Const EN_DURATION = 0 ' Time parameters
Public Const EN_HYDSTEP = 1
@@ -340,6 +341,7 @@ Public Const EN_MISSING As Double = -1.0E10
Declare Function ENsetpipedata Lib "epanet2.dll" (ByVal index As Long, ByVal length As Single, ByVal diam As Single, ByVal rough As Single, ByVal mloss As Single) As Long
Declare Function ENgetvertexcount Lib "epanet2.dll" (ByVal index As Long, count As Long) As Long
Declare Function ENgetvertex Lib "epanet2.dll" (ByVal index As Long, ByVal vertex As Long, x As Double, y As Double) As Long
Declare Function ENsetvertex Lib "epanet2.dll" (ByVal index As Long, ByVal vertex As Long, ByVal x As Double, ByVal y As Double) As Long
Declare Function ENsetvertices Lib "epanet2.dll" (ByVal index As Long, xCoords As Any, yCoords As Any, ByVal count As Long) As Long
'Pump Functions
@@ -367,6 +369,7 @@ Public Const EN_MISSING As Double = -1.0E10
Declare Function ENsetcurveid Lib "epanet2.dll" (ByVal index As Long, ByVal newid As String) As Long
Declare Function ENgetcurvelen Lib "epanet2.dll" (ByVal index As Long, len_ As Long) As Long
Declare Function ENgetcurvetype Lib "epanet2.dll" (ByVal index As Long, type_ As Long) As Long
Declare Function ENsetcurvetype Lib "epanet2.dll" (ByVal index As Long, ByVal type_ As Long) As Long
Declare Function ENgetcurvevalue Lib "epanet2.dll" (ByVal curveIndex As Long, ByVal pointIndex As Long, x As Single, y As Single) As Long
Declare Function ENsetcurvevalue Lib "epanet2.dll" (ByVal curveIndex As Long, ByVal pointIndex As Long, ByVal x As Single, ByVal y As Single) As Long
Declare Function ENgetcurve Lib "epanet2.dll" (ByVal index As Long, ByVal id As String, nPoints As Long, xValues As Any, yValues As Any) As Long

View File

@@ -91,7 +91,8 @@ EXPORTS
ENsetcontrol = _ENsetcontrol@24
ENsetcoord = _ENsetcoord@20
ENsetcurve = _ENsetcurve@16
ENsetcurveid = _ENsetcurveid@8
ENsetcurveid = _ENsetcurveid@8
ENsetcurvetype = _ENsetcurvetype@8
ENsetcurvevalue = _ENsetcurvevalue@16
ENsetdemandmodel = _ENsetdemandmodel@16
ENsetdemandname = _ENsetdemandname@12
@@ -122,7 +123,8 @@ EXPORTS
ENsettankdata = _ENsettankdata@32
ENsetthenaction = _ENsetthenaction@20
ENsettimeparam = _ENsettimeparam@8
ENsettitle = _ENsettitle@12
ENsettitle = _ENsettitle@12
ENsetvertex = _ENsetvertex@24
ENsetvertices = _ENsetvertices@16
ENsolveH = _ENsolveH@0
ENsolveQ = _ENsolveQ@0

View File

@@ -7,7 +7,7 @@
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
Last Updated: 10/29/2019
Last Updated: 02/01/2020
******************************************************************************
*/
@@ -290,6 +290,8 @@ extern "C" {
int DLLEXPORT ENgetvertex(int index, int vertex, double *x, double *y);
int DLLEXPORT ENsetvertex(int index, int vertex, double x, double y);
int DLLEXPORT ENsetvertices(int index, double *x, double *y, int count);
/********************************************************************
@@ -349,6 +351,8 @@ extern "C" {
int DLLEXPORT ENgetcurvelen(int index, int *len);
int DLLEXPORT ENgetcurvetype(int index, int *type);
int DLLEXPORT ENsetcurvetype(int index, int type);
int DLLEXPORT ENgetcurvevalue(int curveIndex, int pointIndex,
EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y);

View File

@@ -3,7 +3,7 @@ unit epanet2;
{ Declarations of imported procedures from the EPANET PROGRAMMERs TOOLKIT }
{ (EPANET2.DLL) }
{Last updated on 11/12/19}
{Last updated on 02/01/2020}
interface
@@ -67,6 +67,7 @@ const
EN_PUMP_ECURVE = 20;
EN_PUMP_ECOST = 21;
EN_PUMP_EPAT = 22;
EN_GPV_CURVE = 23;
EN_DURATION = 0; { Time parameters }
EN_HYDSTEP = 1;
@@ -253,8 +254,12 @@ const
EN_R_IS_OPEN = 1; { Rule-based control link status }
EN_R_IS_CLOSED = 2;
EN_R_IS_ACTIVE = 3;
{$ifdef WINDOWS}
EpanetLib = 'epanet2.dll';
{$else}
EpanetLib = 'libepanet2.so';
{$endif}
{Project Functions}
function ENepanet(F1: PAnsiChar; F2: PAnsiChar; F3: PAnsiChar; F4: Pointer): Integer; stdcall; external EpanetLib;
@@ -273,8 +278,8 @@ const
function ENsaveH: Integer; stdcall; external EpanetLib;
function ENopenH: Integer; stdcall; external EpanetLib;
function ENinitH(SaveFlag: Integer): Integer; stdcall; external EpanetLib;
function ENrunH(var T: LongInt): Integer; stdcall; external EpanetLib;
function ENnextH(var Tstep: LongInt): Integer; stdcall; external EpanetLib;
function ENrunH(var T: Integer): Integer; stdcall; external EpanetLib;
function ENnextH(var Tstep: Integer): Integer; stdcall; external EpanetLib;
function ENcloseH: Integer; stdcall; external EpanetLib;
function ENsavehydfile(F: PAnsiChar): Integer; stdcall; external EpanetLib;
function ENusehydfile(F: PAnsiChar): Integer; stdcall; external EpanetLib;
@@ -283,9 +288,9 @@ const
function ENsolveQ: Integer; stdcall; external EpanetLib;
function ENopenQ: Integer; stdcall; external EpanetLib;
function ENinitQ(SaveFlag: Integer): Integer; stdcall; external EpanetLib;
function ENrunQ(var T: LongInt): Integer; stdcall; external EpanetLib;
function ENnextQ(var Tstep: LongInt): Integer; stdcall; external EpanetLib;
function ENstepQ(var Tleft: LongInt): Integer; stdcall; external EpanetLib;
function ENrunQ(var T: Integer): Integer; stdcall; external EpanetLib;
function ENnextQ(var Tstep: Integer): Integer; stdcall; external EpanetLib;
function ENstepQ(var Tleft: Integer): Integer; stdcall; external EpanetLib;
function ENcloseQ: Integer; stdcall; external EpanetLib;
{Reporting Functions}
@@ -306,8 +311,8 @@ const
function ENsetoption(Code: Integer; Value: Single): Integer; stdcall; external EpanetLib;
function ENgetflowunits(var Code: Integer): Integer; stdcall; external EpanetLib;
function ENsetflowunits(Code: Integer): Integer; stdcall; external EpanetLib;
function ENgettimeparam(Code: Integer; var Value: LongInt): Integer; stdcall; external EpanetLib;
function ENsettimeparam(Code: Integer; Value: LongInt): Integer; stdcall; external EpanetLib;
function ENgettimeparam(Code: Integer; var Value: Integer): Integer; stdcall; external EpanetLib;
function ENsettimeparam(Code: Integer; Value: Integer): Integer; stdcall; external EpanetLib;
function ENgetqualinfo(var QualType: Integer; ChemName: PAnsiChar; ChemUnits: PAnsiChar; var TraceNode: Integer): Integer; stdcall; external EpanetLib;
function ENgetqualtype(var QualCode: Integer; var TraceNode: Integer): Integer; stdcall; external EpanetLib;
function ENsetqualtype(QualCode: Integer; ChemName: PAnsiChar; ChemUnits: PAnsiChar; TraceNodeID: PAnsiChar): Integer; stdcall; external EpanetLib;
@@ -356,6 +361,7 @@ const
function ENgetvertexcount(Index: Integer; var Count: Integer): Integer; stdcall; external EpanetLib;
function ENgetvertex(Index: Integer; Vertex: Integer; var X: Double; var Y: Double): Integer; stdcall; external EpanetLib;
function ENsetvertex(Index: Integer; Vertex: Integer; X: Double; Y: Double): Integer; stdcall; external EpanetLib;
function ENsetvertices(Index: Integer; var X: Double; var Y: Double; Count: Integer): Integer; stdcall; external EpanetLib;
{Pump Functions}
@@ -383,6 +389,7 @@ const
function ENsetcurveid(Index: Integer; ID: PAnsiChar): Integer; stdcall; external EpanetLib;
function ENgetcurvelen(Index: Integer; var Len: Integer): Integer; stdcall; external EpanetLib;
function ENgetcurvetype(Index: Integer; var CurveType: Integer): Integer; stdcall; external EpanetLib;
function ENsetcurvetype(Index: Integer; CurveType: Integer): Integer; stdcall; external EpanetLib;
function ENgetcurvevalue(CurveIndex: Integer; PointIndex: Integer; var X: Single; var Y: Single): Integer; stdcall; external EpanetLib;
function ENsetcurvevalue(CurveIndex: Integer; PointIndex: Integer; X: Single; Y: Single): Integer; stdcall; external EpanetLib;
function ENgetcurve(Index: Integer; ID: PAnsiChar; var N: Integer; var X: Single; var Y: Single): Integer; stdcall; external EpanetLib;

View File

@@ -4,7 +4,7 @@
'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
'(EPANET2.DLL) for use with VB.Net.
'Last updated on 11/04/2019
'Last updated on 02/01/2020
Imports System.Runtime.InteropServices
Imports System.Text
@@ -67,6 +67,7 @@ Public Const EN_PUMP_HCURVE = 19
Public Const EN_PUMP_ECURVE = 20
Public Const EN_PUMP_ECOST = 21
Public Const EN_PUMP_EPAT = 22
Public Const EN_GPV_CURVE = 23
Public Const EN_DURATION = 0 ' Time parameters
Public Const EN_HYDSTEP = 1
@@ -345,6 +346,7 @@ Public Const EN_MISSING As Double = -1.0E10
Declare Function ENsetpipedata Lib "epanet2.dll" (ByVal index As Int32, ByVal length As Single, ByVal diam As Single, ByVal rough As Single, ByVal mloss As Single) As Int32
Declare Function ENgetvertexcount Lib "epanet2.dll" (ByVal index As Int32, count As Int32) As Int32
Declare Function ENgetvertex Lib "epanet2.dll" (ByVal index As Int32, ByVal vertex As Int32, x As Double, y As Double) As Int32
Declare Function ENsetvertex Lib "epanet2.dll" (ByVal index As Int32, ByVal vertex As Int32, ByVal x As Double, ByVal y As Double) As Int32
Declare Function ENsetvertices Lib "epanet2.dll" (ByVal index As Int32, xCoords As Any, yCoords As Any, ByVal count As Int32) As Int32
'Pump Functions
@@ -372,6 +374,7 @@ Public Const EN_MISSING As Double = -1.0E10
Declare Function ENsetcurveid Lib "epanet2.dll" (ByVal index As Int32, ByVal newid As String) As Int32
Declare Function ENgetcurvelen Lib "epanet2.dll" (ByVal index As Int32, len_ As Int32) As Int32
Declare Function ENgetcurvetype Lib "epanet2.dll" (ByVal index As Int32, type_ As Int32) As Int32
Declare Function ENsetcurvetype Lib "epanet2.dll" (ByVal index As Int32, ByVal type_ As Int32) As Int32
Declare Function ENgetcurvevalue Lib "epanet2.dll" (ByVal curveIndex As Int32, ByVal pointIndex As Int32, x As Single, y As Single) As Int32
Declare Function ENsetcurvevalue Lib "epanet2.dll" (ByVal curveIndex As Int32, ByVal pointIndex As Int32, ByVal x As Single, ByVal y As Single) As Int32
Declare Function ENgetcurve Lib "epanet2.dll" (ByVal index As Int32, ByVal id As String, nPoints As Int32, xValues As Any, yValues As Any) As Int32

View File

@@ -11,7 +11,7 @@
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
Last Updated: 10/29/2019
Last Updated: 02/01/2020
******************************************************************************
*/
@@ -1238,7 +1238,7 @@ typedef struct Project *EN_Project;
int DLLEXPORT EN_getvertexcount(EN_Project ph, int index, int *count);
/**
@brief Retrieves the coordinate's of a vertex point assigned to a link.
@brief Retrieves the coordinates of a vertex point assigned to a link.
@param ph an EPANET project handle.
@param index a link's index (starting from 1).
@param vertex a vertex point index (starting from 1).
@@ -1248,6 +1248,17 @@ typedef struct Project *EN_Project;
*/
int DLLEXPORT EN_getvertex(EN_Project ph, int index, int vertex, double *x, double *y);
/**
@brief Sets the coordinates of a vertex point assigned to a link.
@param ph an EPANET project handle.
@param index a link's index (starting from 1).
@param vertex a vertex point index (starting from 1).
@param x the vertex's X-coordinate value.
@param y the vertex's Y-coordinate value.
@return an error code.
*/
int DLLEXPORT EN_setvertex(EN_Project ph, int index, int vertex, double x, double y);
/**
@brief Assigns a set of internal vertex points to a link.
@param ph an EPANET project handle.
@@ -1475,6 +1486,15 @@ typedef struct Project *EN_Project;
*/
int DLLEXPORT EN_getcurvetype(EN_Project ph, int index, int *type);
/**
@brief Sets a curve's type.
@param ph an EPANET project handle.
@param index a curve's index (starting from 1).
@param type the curve's type (see @ref EN_CurveType).
@return an error code.
*/
int DLLEXPORT EN_setcurvetype(EN_Project ph, int index, int type);
/**
@brief Retrieves the value of a single data point for a curve.
@param ph an EPANET project handle.

View File

@@ -9,7 +9,7 @@
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
Last Updated: 11/06/2019
Last Updated: 02/01/2020
******************************************************************************
*/
@@ -94,7 +94,8 @@ typedef enum {
EN_PUMP_HCURVE = 19, //!< Pump head v. flow curve index
EN_PUMP_ECURVE = 20, //!< Pump efficiency v. flow curve index
EN_PUMP_ECOST = 21, //!< Pump average energy price
EN_PUMP_EPAT = 22 //!< Pump energy price time pattern index
EN_PUMP_EPAT = 22, //!< Pump energy price time pattern index
EN_GPV_CURVE = 23 //!< GPV head loss v. flow curve index
} EN_LinkProperty;
/// Time parameters