Add EN_openX function

EN_openX allows an EPANET input file to be opened even if it has errors. This required re-arranging code, mainly in input3.c, so that default values are assigned to an object before its input line is parsed.
This commit is contained in:
Lew Rossman
2023-10-04 09:53:05 -04:00
parent c84c6baee2
commit 10d5079d75
18 changed files with 994 additions and 724 deletions

View File

@@ -5,7 +5,7 @@ Attribute VB_Name = "Module1"
'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
'(EPANET2.DLL)
'Last updated on 07/18/2023
'Last updated on 09/28/2023
' These are codes used by the DLL functions
Public Const EN_ELEVATION = 0 ' Node parameters
@@ -280,6 +280,7 @@ Public Const EN_SET_OPEN As Double = 1.0E10
Declare Function ENepanet Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String, ByVal pviewprog As Any) As Long
Declare Function ENinit Lib "epanet2.dll" (ByVal rptFile As String, ByVal outFile As String, ByVal unitsType As Long, ByVal headlossType As Long) As Long
Declare Function ENopen Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String) As Long
Declare Function ENopenX Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String) As Long
Declare Function ENgettitle Lib "epanet2.dll" (ByVal line1 As String, ByVal line2 As String, ByVal line3 As String) As Long
Declare Function ENsettitle Lib "epanet2.dll" (ByVal titleline1 As String, ByVal titleline2 As String, ByVal titleline3 As String) As Long
Declare Function ENsaveinpfile Lib "epanet2.dll" (ByVal filename As String) As Long

View File

@@ -3,7 +3,7 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
//epanet2.cs[By Oscar Vegas]
//Last updated on 07/18/2023
//Last updated on 09/28/2023
//Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
//(EPANET2.DLL) for use with C#
@@ -286,6 +286,9 @@ namespace EpanetCSharpLibrary
[DllImport(EPANETDLL, EntryPoint = "ENopen")]
public static extern int ENopen(string inpFile, string rptFile, string outFile);
[DllImport(EPANETDLL, EntryPoint = "ENopenX")]
public static extern int ENopenX(string inpFile, string rptFile, string outFile);
[DllImport(EPANETDLL, EntryPoint = "ENgettitle")]
public static extern int ENgettitle(string titleline1, string titleline2, string titleline3);

View File

@@ -131,4 +131,5 @@ EXPORTS
ENstepQ = _ENstepQ@4
ENusehydfile = _ENusehydfile@4
ENwriteline = _ENwriteline@4
ENtimetonextevent = _ENtimetonextevent@12
ENtimetonextevent = _ENtimetonextevent@12
ENopenX = _ENopenX@12

View File

@@ -7,7 +7,7 @@
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
Last Updated: 02/01/2020
Last Updated: 09/28/2023
******************************************************************************
*/
@@ -73,6 +73,9 @@ extern "C" {
int DLLEXPORT ENopen(const char *inpFile, const char *rptFile,
const char *outFile);
int DLLEXPORT ENopenX(const char *inpFile, const char *rptFile,
const char *outFile);
int DLLEXPORT ENgettitle(char *line1, char *line2, char *line3);
int DLLEXPORT ENsettitle(const char *line1, const char *line2, const char *line3);

View File

@@ -3,7 +3,7 @@ unit epanet2;
{ Declarations of imported procedures from the EPANET PROGRAMMERs TOOLKIT }
{ (EPANET2.DLL) }
{Last updated on 09/11/2023}
{Last updated on 09/28/2023}
interface
@@ -281,6 +281,7 @@ const
function ENepanet(F1: PAnsiChar; F2: PAnsiChar; F3: PAnsiChar; F4: Pointer): Integer; stdcall; external EpanetLib;
function ENinit(F2: PAnsiChar; F3: PAnsiChar; UnitsType: Integer; HeadlossType: Integer): Integer; stdcall; external EpanetLib;
function ENopen(F1: PAnsiChar; F2: PAnsiChar; F3: PAnsiChar): Integer; stdcall; external EpanetLib;
function ENopenX(F1: PAnsiChar; F2: PAnsiChar; F3: PAnsiChar): Integer; stdcall; external EpanetLib;
function ENgetcount(Code: Integer; var Count: Integer): Integer; stdcall; external EpanetLib;
function ENgettitle(Line1: PAnsiChar; Line2: PAnsiChar; Line3: PAnsiChar): Integer; stdcall; external EpanetLib;
function ENsettitle(Line1: PAnsiChar; Line2: PAnsiChar; Line3: PAnsiChar): 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 07/18/2023
'Last updated on 09/28/2023
Imports System.Runtime.InteropServices
Imports System.Text
@@ -268,6 +268,7 @@ Public Const EN_SET_OPEN As Double = 1.0E10
Declare Function ENepanet Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String, ByVal pviewprog As Any) As Int32
Declare Function ENinit Lib "epanet2.dll" (ByVal rptFile As String, ByVal outFile As String, ByVal unitsType As Int32, ByVal headlossType As Int32) As Int32
Declare Function ENopen Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String) As Int32
Declare Function ENopenX Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String) As Int32
Declare Function ENgettitle Lib "epanet2.dll" (ByVal titleline1 As String, ByVal titleline2 As String, ByVal titleline3 As String) As Int32
Declare Function ENsettitle Lib "epanet2.dll" (ByVal titleline1 As String, ByVal titleline2 As String, ByVal titleline3 As String) As Int32
Declare Function ENsaveinpfile Lib "epanet2.dll" (ByVal filename As String) As Int32

View File

@@ -11,7 +11,7 @@
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
Last Updated: 02/01/2020
Last Updated: 09/28/2023
******************************************************************************
*/
@@ -113,7 +113,7 @@ typedef struct Project *EN_Project;
int unitsType, int headLossType);
/**
@brief Opens an EPANET input file & reads in network data.
@brief Reads an EPANET input file with no errors allowed.
@param ph an EPANET project handle.
@param inpFile the name of an existing EPANET-formatted input file.
@param rptFile the name of a report file to be created (or "" if not needed).
@@ -121,11 +121,27 @@ typedef struct Project *EN_Project;
@return an error code.
This function should be called immediately after ::EN_createproject if an EPANET-formatted
input file will be used to supply network data.
input file will be used to supply network data. If errors are detected then the project is
not opened and will not accept toolkit function calls.
*/
int DLLEXPORT EN_open(EN_Project ph, const char *inpFile, const char *rptFile,
const char *outFile);
/**
@brief Reads an EPANET input file with errors allowed.
@param ph an EPANET project handle.
@param inpFile the name of an existing EPANET-formatted input file.
@param rptFile the name of a report file to be created (or "" if not needed).
@param outFile the name of a binary output file to be created (or "" if not needed).
@return an error code.
This function should be called immediately after ::EN_createproject if an EPANET-formatted
input file will be used to supply network data. If formatting errors are detected (error
code = 200) then the project remains open and will accept toolkit function calls.
*/
int DLLEXPORT EN_openX(EN_Project ph, const char *inpFile, const char *rptFile,
const char *outFile);
/**
@brief Retrieves the title lines of the project
@param ph an EPANET project handle.