Merge pull request #547 from OpenWaterAnalytics/lrossman-ENgetresultindex
Adds EN_getresultindex function to the API
This commit is contained in:
@@ -5,7 +5,7 @@ Attribute VB_Name = "Module1"
|
|||||||
'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
|
'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
|
||||||
'(EPANET2.DLL)
|
'(EPANET2.DLL)
|
||||||
|
|
||||||
'Last updated on 07/18/2019
|
'Last updated on 10/26/2019
|
||||||
|
|
||||||
' These are codes used by the DLL functions
|
' These are codes used by the DLL functions
|
||||||
Public Const EN_ELEVATION = 0 ' Node parameters
|
Public Const EN_ELEVATION = 0 ' Node parameters
|
||||||
@@ -282,6 +282,7 @@ Public Const EN_R_IS_ACTIVE = 3
|
|||||||
Declare Function ENgetcount Lib "epanet2.dll" (ByVal object As Long, count 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 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 ENgetstatistic Lib "epanet2.dll" (ByVal type_ As Long, ByRef value As Single) As Long
|
||||||
|
Declare Function ENgetresultindex Lib "epanet2.dll" (ByVal type_ As Long, ByVal index As Long, ByRef value As Long) As Long
|
||||||
|
|
||||||
'Analysis Options Functions
|
'Analysis Options Functions
|
||||||
Declare Function ENgetoption Lib "epanet2.dll" (ByVal option_ As Long, value As Single) As Long
|
Declare Function ENgetoption Lib "epanet2.dll" (ByVal option_ As Long, value As Single) As Long
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ EXPORTS
|
|||||||
ENgetpremise = _ENgetpremise@36
|
ENgetpremise = _ENgetpremise@36
|
||||||
ENgetpumptype = _ENgetpumptype@8
|
ENgetpumptype = _ENgetpumptype@8
|
||||||
ENgetqualinfo = _ENgetqualinfo@16
|
ENgetqualinfo = _ENgetqualinfo@16
|
||||||
ENgetqualtype = _ENgetqualtype@8
|
ENgetqualtype = _ENgetqualtype@8
|
||||||
|
ENgetresultindex = _ENgetresultindex@12
|
||||||
ENgetrule = _ENgetrule@20
|
ENgetrule = _ENgetrule@20
|
||||||
ENgetruleID = _ENgetruleID@8
|
ENgetruleID = _ENgetruleID@8
|
||||||
ENgetstatistic = _ENgetstatistic@8
|
ENgetstatistic = _ENgetstatistic@8
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 03/17/2019
|
Last Updated: 10/26/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -157,6 +157,7 @@ extern "C" {
|
|||||||
|
|
||||||
int DLLEXPORT ENgetstatistic(int type, EN_API_FLOAT_TYPE* value);
|
int DLLEXPORT ENgetstatistic(int type, EN_API_FLOAT_TYPE* value);
|
||||||
|
|
||||||
|
int DLLEXPORT ENgetresultindex(int type, int index, int *value);
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ unit epanet2;
|
|||||||
{ Declarations of imported procedures from the EPANET PROGRAMMERs TOOLKIT }
|
{ Declarations of imported procedures from the EPANET PROGRAMMERs TOOLKIT }
|
||||||
{ (EPANET2.DLL) }
|
{ (EPANET2.DLL) }
|
||||||
|
|
||||||
{Last updated on 7/18/19}
|
{Last updated on 10/26/19}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
@@ -297,7 +297,8 @@ const
|
|||||||
function ENsetstatusreport(Code: Integer): Integer; stdcall; external EpanetLib;
|
function ENsetstatusreport(Code: Integer): Integer; stdcall; external EpanetLib;
|
||||||
function ENgetversion(var Version: Integer): Integer; stdcall; external EpanetLib;
|
function ENgetversion(var Version: Integer): Integer; stdcall; external EpanetLib;
|
||||||
function ENgeterror(Errcode: Integer; Errmsg: PAnsiChar; MaxLen: Integer): Integer; stdcall; external EpanetLib;
|
function ENgeterror(Errcode: Integer; Errmsg: PAnsiChar; MaxLen: Integer): Integer; stdcall; external EpanetLib;
|
||||||
function ENgetstatistic(StatType: Integer; var Value: Single): Integer; stdcall; external EpanetLib;
|
function ENgetstatistic(StatType: Integer; var Value: Single): Integer; stdcall; external EpanetLib;
|
||||||
|
function ENgetresultindex(Code: Integer; Index: Integer; var Value: Integer): Integer; stdcall; external EpanetLib;
|
||||||
|
|
||||||
{Analysis Options Functions}
|
{Analysis Options Functions}
|
||||||
function ENgetoption(Code: Integer; var Value: Single): Integer; stdcall; external EpanetLib;
|
function ENgetoption(Code: Integer; var Value: Single): Integer; stdcall; external EpanetLib;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
|
'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
|
||||||
'(EPANET2.DLL) for use with VB.Net.
|
'(EPANET2.DLL) for use with VB.Net.
|
||||||
|
|
||||||
'Last updated on 07/18/2019
|
'Last updated on 10/26/2019
|
||||||
|
|
||||||
Imports System.Runtime.InteropServices
|
Imports System.Runtime.InteropServices
|
||||||
Imports System.Text
|
Imports System.Text
|
||||||
@@ -287,6 +287,7 @@ Public Const EN_R_IS_ACTIVE = 3
|
|||||||
Declare Function ENgetcount Lib "epanet2.dll" (ByVal object As Int32, count 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 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 ENgetstatistic Lib "epanet2.dll" (ByVal type_ As Int32, ByRef value As Single) As Int32
|
||||||
|
Declare Function ENgetresultindex Lib "epanet2.dll" (ByVal type_ As Int32, ByVal index As Int32, ByRef value As Int32) As Int32
|
||||||
|
|
||||||
'Analysis Options Functions
|
'Analysis Options Functions
|
||||||
Declare Function ENgetoption Lib "epanet2.dll" (ByVal option As Int32, value As Single) As Int32
|
Declare Function ENgetoption Lib "epanet2.dll" (ByVal option As Int32, value As Single) As Int32
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 07/20/2019
|
Last Updated: 10/26/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -638,6 +638,8 @@ typedef struct Project *EN_Project;
|
|||||||
*/
|
*/
|
||||||
int DLLEXPORT EN_getstatistic(EN_Project ph, int type, double* value);
|
int DLLEXPORT EN_getstatistic(EN_Project ph, int type, double* value);
|
||||||
|
|
||||||
|
int DLLEXPORT EN_getresultindex(EN_Project ph, int type, int index, int *value);
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
|
|
||||||
Analysis Options Functions
|
Analysis Options Functions
|
||||||
|
|||||||
31
src/epanet.c
31
src/epanet.c
@@ -7,7 +7,7 @@
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 07/18/2019
|
Last Updated: 10/26/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -1066,6 +1066,33 @@ int DLLEXPORT EN_getstatistic(EN_Project p, int type, double *value)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DLLEXPORT EN_getresultindex(EN_Project p, int type, int index, int *value)
|
||||||
|
/*----------------------------------------------------------------
|
||||||
|
** Input: type = type of object (either EN_NODE or EN_LINK)
|
||||||
|
** index = the object's index
|
||||||
|
** Output: value = the order in which the object's results were saved
|
||||||
|
** Returns: error code
|
||||||
|
** Purpose: retrieves the order in which a node's or link's results
|
||||||
|
** were saved to an output file.
|
||||||
|
**----------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
*value = 0;
|
||||||
|
if (!p->Openflag) return 102;
|
||||||
|
if (type == EN_NODE)
|
||||||
|
{
|
||||||
|
if (index <= 0 || index > p->network.Nnodes) return 203;
|
||||||
|
*value = p->network.Node[index].ResultIndex;
|
||||||
|
}
|
||||||
|
else if (type == EN_LINK)
|
||||||
|
{
|
||||||
|
if (index <= 0 || index > p->network.Nlinks) return 204;
|
||||||
|
*value = p->network.Link[index].ResultIndex;
|
||||||
|
}
|
||||||
|
else return 251;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
|
|
||||||
Analysis Options Functions
|
Analysis Options Functions
|
||||||
@@ -1827,6 +1854,7 @@ int DLLEXPORT EN_addnode(EN_Project p, char *id, int nodeType, int *index)
|
|||||||
node->C0 = 0;
|
node->C0 = 0;
|
||||||
node->Ke = 0;
|
node->Ke = 0;
|
||||||
node->Rpt = 0;
|
node->Rpt = 0;
|
||||||
|
node->ResultIndex = 0;
|
||||||
node->X = MISSING;
|
node->X = MISSING;
|
||||||
node->Y = MISSING;
|
node->Y = MISSING;
|
||||||
node->Comment = NULL;
|
node->Comment = NULL;
|
||||||
@@ -3210,6 +3238,7 @@ int DLLEXPORT EN_addlink(EN_Project p, char *id, int linkType,
|
|||||||
link->R = 0;
|
link->R = 0;
|
||||||
link->Rc = 0;
|
link->Rc = 0;
|
||||||
link->Rpt = 0;
|
link->Rpt = 0;
|
||||||
|
link->ResultIndex = 0;
|
||||||
link->Comment = NULL;
|
link->Comment = NULL;
|
||||||
|
|
||||||
hashtable_insert(net->LinkHashTable, link->ID, n);
|
hashtable_insert(net->LinkHashTable, link->ID, n);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 05/15/2019
|
Last Updated: 10/26/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -227,6 +227,12 @@ int DLLEXPORT ENgetstatistic(int type, EN_API_FLOAT_TYPE *value)
|
|||||||
return errcode;
|
return errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DLLEXPORT ENgetresultindex(int type, int index, int *value)
|
||||||
|
{
|
||||||
|
return EN_getresultindex(_defaultProject, type, index, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
|
|
||||||
Analysis Options Functions
|
Analysis Options Functions
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 05/15/2019
|
Last Updated: 10/26/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -115,8 +115,9 @@ void inithyd(Project *pr, int initflag)
|
|||||||
|
|
||||||
// Initialize emitter flows
|
// Initialize emitter flows
|
||||||
memset(hyd->EmitterFlow,0,(net->Nnodes+1)*sizeof(double));
|
memset(hyd->EmitterFlow,0,(net->Nnodes+1)*sizeof(double));
|
||||||
for (i = 1; i <= net->Njuncs; i++)
|
for (i = 1; i <= net->Nnodes; i++)
|
||||||
{
|
{
|
||||||
|
net->Node[i].ResultIndex = i;
|
||||||
if (net->Node[i].Ke > 0.0) hyd->EmitterFlow[i] = 1.0;
|
if (net->Node[i].Ke > 0.0) hyd->EmitterFlow[i] = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,6 +125,7 @@ void inithyd(Project *pr, int initflag)
|
|||||||
for (i = 1; i <= net->Nlinks; i++)
|
for (i = 1; i <= net->Nlinks; i++)
|
||||||
{
|
{
|
||||||
link = &net->Link[i];
|
link = &net->Link[i];
|
||||||
|
link->ResultIndex = i;
|
||||||
|
|
||||||
// Initialize status and setting
|
// Initialize status and setting
|
||||||
hyd->LinkStatus[i] = link->Status;
|
hyd->LinkStatus[i] = link->Status;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Description: parses network data from a line of an EPANET input file
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 06/19/2019
|
Last Updated: 10/26/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -109,6 +109,7 @@ int juncdata(Project *pr)
|
|||||||
node->S = NULL;
|
node->S = NULL;
|
||||||
node->Ke = 0.0;
|
node->Ke = 0.0;
|
||||||
node->Rpt = 0;
|
node->Rpt = 0;
|
||||||
|
node->ResultIndex = 0;
|
||||||
node->Type = JUNCTION;
|
node->Type = JUNCTION;
|
||||||
node->Comment = xstrcpy(&node->Comment, parser->Comment, MAXMSG);
|
node->Comment = xstrcpy(&node->Comment, parser->Comment, MAXMSG);
|
||||||
|
|
||||||
@@ -222,6 +223,7 @@ int tankdata(Project *pr)
|
|||||||
node->X = MISSING;
|
node->X = MISSING;
|
||||||
node->Y = MISSING;
|
node->Y = MISSING;
|
||||||
node->Rpt = 0;
|
node->Rpt = 0;
|
||||||
|
node->ResultIndex = 0;
|
||||||
node->El = el;
|
node->El = el;
|
||||||
node->C0 = 0.0;
|
node->C0 = 0.0;
|
||||||
node->S = NULL;
|
node->S = NULL;
|
||||||
@@ -335,6 +337,7 @@ int pipedata(Project *pr)
|
|||||||
link->Type = type;
|
link->Type = type;
|
||||||
link->Status = status;
|
link->Status = status;
|
||||||
link->Rpt = 0;
|
link->Rpt = 0;
|
||||||
|
link->ResultIndex = 0;
|
||||||
link->Comment = xstrcpy(&link->Comment, parser->Comment, MAXMSG);
|
link->Comment = xstrcpy(&link->Comment, parser->Comment, MAXMSG);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -400,6 +403,7 @@ int pumpdata(Project *pr)
|
|||||||
link->Type = PUMP;
|
link->Type = PUMP;
|
||||||
link->Status = OPEN;
|
link->Status = OPEN;
|
||||||
link->Rpt = 0;
|
link->Rpt = 0;
|
||||||
|
link->ResultIndex = 0;
|
||||||
link->Comment = xstrcpy(&link->Comment, parser->Comment, MAXMSG);
|
link->Comment = xstrcpy(&link->Comment, parser->Comment, MAXMSG);
|
||||||
pump->Link = net->Nlinks;
|
pump->Link = net->Nlinks;
|
||||||
pump->Ptype = NOCURVE; // NOCURVE is a placeholder
|
pump->Ptype = NOCURVE; // NOCURVE is a placeholder
|
||||||
@@ -556,6 +560,7 @@ int valvedata(Project *pr)
|
|||||||
link->Type = type;
|
link->Type = type;
|
||||||
link->Status = status;
|
link->Status = status;
|
||||||
link->Rpt = 0;
|
link->Rpt = 0;
|
||||||
|
link->ResultIndex = 0;
|
||||||
link->Comment = xstrcpy(&link->Comment, parser->Comment, MAXMSG);
|
link->Comment = xstrcpy(&link->Comment, parser->Comment, MAXMSG);
|
||||||
net->Valve[net->Nvalves].Link = net->Nlinks;
|
net->Valve[net->Nvalves].Link = net->Nlinks;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 05/24/2019
|
Last Updated: 10/26/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -174,10 +174,9 @@ int openoutfile(Project *pr)
|
|||||||
// Close output file if already opened
|
// Close output file if already opened
|
||||||
closeoutfile(pr);
|
closeoutfile(pr);
|
||||||
|
|
||||||
// If output file name was supplied, then attempt to
|
// Try to open binary output file
|
||||||
// open it. Otherwise open a temporary output file.
|
|
||||||
pr->outfile.OutFile = fopen(pr->outfile.OutFname, "w+b");
|
pr->outfile.OutFile = fopen(pr->outfile.OutFname, "w+b");
|
||||||
if (pr->outfile.OutFile == NULL) errcode = 304;
|
if (pr->outfile.OutFile == NULL) return 304;
|
||||||
|
|
||||||
// Save basic network data & energy usage results
|
// Save basic network data & energy usage results
|
||||||
ERRCODE(savenetdata(pr));
|
ERRCODE(savenetdata(pr));
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 07/08/2019
|
Last Updated: 10/26/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -377,6 +377,7 @@ typedef struct // Node Object
|
|||||||
double C0; // initial quality
|
double C0; // initial quality
|
||||||
double Ke; // emitter coeff.
|
double Ke; // emitter coeff.
|
||||||
int Rpt; // reporting flag
|
int Rpt; // reporting flag
|
||||||
|
int ResultIndex; // saved result index
|
||||||
NodeType Type; // node type
|
NodeType Type; // node type
|
||||||
char *Comment; // node comment
|
char *Comment; // node comment
|
||||||
} Snode;
|
} Snode;
|
||||||
@@ -397,6 +398,7 @@ typedef struct // Link Object
|
|||||||
LinkType Type; // link type
|
LinkType Type; // link type
|
||||||
StatusType Status; // initial status
|
StatusType Status; // initial status
|
||||||
int Rpt; // reporting flag
|
int Rpt; // reporting flag
|
||||||
|
int ResultIndex; // saved result index
|
||||||
char *Comment; // link comment
|
char *Comment; // link comment
|
||||||
} Slink;
|
} Slink;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user