Merge pull request #743 from OpenWaterAnalytics/dev-status_report

Allow API to get/set type of status report
This commit is contained in:
Lew Rossman
2023-07-27 10:37:40 -04:00
committed by GitHub
9 changed files with 31 additions and 14 deletions

View File

@@ -43,4 +43,5 @@ This document describes the changes and updates that have been made in version 2
- Errors in node and link vertex coordinates are now ignored when reading an EPANET input file. - Errors in node and link vertex coordinates are now ignored when reading an EPANET input file.
- Only non-zero demands are now included in the `[DEMANDS]` section of the input file produced by `EN_saveinpfile`. - Only non-zero demands are now included in the `[DEMANDS]` section of the input file produced by `EN_saveinpfile`.
- `EN_SET_CLOSED` and `EN_SET_OPEN` constants were added that can be used with `EN_setcontrol` to fix the status of pipes and valves to completely closed or completely open. - `EN_SET_CLOSED` and `EN_SET_OPEN` constants were added that can be used with `EN_setcontrol` to fix the status of pipes and valves to completely closed or completely open.
- `EN_EMITTERFLOW` can now be used with `EN_getnodevalue` to retrieve a node's emitter flow rate. - `EN_EMITTERFLOW` can now be used with `EN_getnodevalue` to retrieve a node's emitter flow rate.
- `EN_STATUS_REPORT` can now be used with `EN_getoption` and `EN_setoption` to get or set the type of status report that EPANET will generate (`EN_NO_REPORT`, `EN_NORMAL_REPORT` or `EN_FULL_REPORT`).

View File

@@ -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 05/13/2023 'Last updated on 07/18/2023
' 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
@@ -188,6 +188,7 @@ Public Const EN_CONCENLIMIT = 22
Public Const EN_DEMANDPATTERN = 23 Public Const EN_DEMANDPATTERN = 23
Public Const EN_EMITBACKFLOW = 24 Public Const EN_EMITBACKFLOW = 24
Public Const EN_PRESS_UNITS = 25 Public Const EN_PRESS_UNITS = 25
Public Const EN_STATUS_REPORT = 26
Public Const EN_LOWLEVEL = 0 ' Control types Public Const EN_LOWLEVEL = 0 ' Control types
Public Const EN_HILEVEL = 1 Public Const EN_HILEVEL = 1

View File

@@ -3,7 +3,7 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
//epanet2.cs[By Oscar Vegas] //epanet2.cs[By Oscar Vegas]
//Last updated on 05/13/2023 //Last updated on 07/18/2023
//Declarations of functions in the EPANET PROGRAMMERs TOOLKIT //Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
//(EPANET2.DLL) for use with C# //(EPANET2.DLL) for use with C#
@@ -192,6 +192,7 @@ namespace EpanetCSharpLibrary
public const int EN_DEMANDPATTERN = 23; public const int EN_DEMANDPATTERN = 23;
public const int EN_EMITBACKFLOW = 24; public const int EN_EMITBACKFLOW = 24;
public const int EN_PRESS_UNITS = 25; public const int EN_PRESS_UNITS = 25;
public const int EN_STATUS_REPORT = 26;
public const int EN_LOWLEVEL = 0; //Control types public const int EN_LOWLEVEL = 0; //Control types
public const int EN_HILEVEL = 1; public const int EN_HILEVEL = 1;

View File

@@ -191,6 +191,8 @@ const
EN_CONCENLIMIT = 22; EN_CONCENLIMIT = 22;
EN_DEMANDPATTERN = 23; EN_DEMANDPATTERN = 23;
EN_EMITBACKFLOW = 24; EN_EMITBACKFLOW = 24;
EN_PRESS_UNITS = 25;
EN_STATUS_REPORT = 26;
EN_LOWLEVEL = 0; { Control types } EN_LOWLEVEL = 0; { Control types }
EN_HILEVEL = 1; EN_HILEVEL = 1;

View File

@@ -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 05/13/2023 'Last updated on 07/18/2023
Imports System.Runtime.InteropServices Imports System.Runtime.InteropServices
Imports System.Text Imports System.Text
@@ -183,6 +183,7 @@ Public Const EN_CONCENLIMIT = 22
Public Const EN_DEMANDPATTERN = 23 Public Const EN_DEMANDPATTERN = 23
Public Const EN_EMITBACKFLOW = 24 Public Const EN_EMITBACKFLOW = 24
Public Const EN_PRESS_UNITS = 25 Public Const EN_PRESS_UNITS = 25
Public Const EN_STATUS_REPORT = 26
Public Const EN_LOWLEVEL = 0 ' Control types Public Const EN_LOWLEVEL = 0 ' Control types
Public Const EN_HILEVEL = 1 Public Const EN_HILEVEL = 1

View File

@@ -3,13 +3,13 @@
/* /*
****************************************************************************** ******************************************************************************
Project: OWA EPANET Project: OWA EPANET
Version: 2.2 Version: 2.3
Module: epanet2_enums.h Module: epanet2_enums.h
Description: enumerations of symbolic constants used by the API functions Description: enumerations of symbolic constants used by the API functions
Authors: see AUTHORS Authors: see AUTHORS
Copyright: see AUTHORS Copyright: see AUTHORS
License: see LICENSE License: see LICENSE
Last Updated: 04/28/2023 Last Updated: 07/17/2023
****************************************************************************** ******************************************************************************
*/ */
@@ -352,7 +352,8 @@ typedef enum {
EN_CONCENLIMIT = 22, //!< Limiting concentration for growth reactions EN_CONCENLIMIT = 22, //!< Limiting concentration for growth reactions
EN_DEMANDPATTERN = 23, //!< Name of default demand pattern EN_DEMANDPATTERN = 23, //!< Name of default demand pattern
EN_EMITBACKFLOW = 24, //!< 1 if emitters can backflow, 0 if not EN_EMITBACKFLOW = 24, //!< 1 if emitters can backflow, 0 if not
EN_PRESS_UNITS = 25 //!< Pressure units (see @ref EN_PressUnits) EN_PRESS_UNITS = 25, //!< Pressure units (see @ref EN_PressUnits)
EN_STATUS_REPORT = 26 //!< Type of status report to produce (see @ref EN_StatusReport)
} EN_Option; } EN_Option;
/// Simple control types /// Simple control types
@@ -446,7 +447,8 @@ typedef enum {
/// Status reporting levels /// Status reporting levels
/** /**
These choices specify the level of status reporting written to a project's report These choices specify the level of status reporting written to a project's report
file during a hydraulic analysis. The level is set using the @ref EN_setstatusreport function. file during a hydraulic analysis. The level is set using the @ref EN_setstatusreport
or the @ref EN_setoption functions.
*/ */
typedef enum { typedef enum {
EN_NO_REPORT = 0, //!< No status reporting EN_NO_REPORT = 0, //!< No status reporting

View File

@@ -1,13 +1,13 @@
/* /*
****************************************************************************** ******************************************************************************
Project: OWA EPANET Project: OWA EPANET
Version: 2.2 Version: 2.3
Module: epanet.c Module: epanet.c
Description: implementation of EPANET's API functions Description: implementation of EPANET's API functions
Authors: see AUTHORS Authors: see AUTHORS
Copyright: see AUTHORS Copyright: see AUTHORS
License: see LICENSE License: see LICENSE
Last Updated: 04/29/2023 Last Updated: 07/17/2023
****************************************************************************** ******************************************************************************
*/ */
@@ -1211,6 +1211,9 @@ int DLLEXPORT EN_getoption(EN_Project p, int option, double *value)
case EN_PRESS_UNITS: case EN_PRESS_UNITS:
v = (double)p->parser.Pressflag; v = (double)p->parser.Pressflag;
break; break;
case EN_STATUS_REPORT:
v = (double)( p->report.Statflag);
break;
default: default:
return 251; return 251;
} }
@@ -1401,6 +1404,12 @@ int DLLEXPORT EN_setoption(EN_Project p, int option, double value)
qcf = Ucf[FLOW] / qfactor; qcf = Ucf[FLOW] / qfactor;
updateruleunits(p, dcf, pcf, hcf, qcf); updateruleunits(p, dcf, pcf, hcf, qcf);
break; break;
case EN_STATUS_REPORT:
i = ROUND(value);
if (i < EN_NO_REPORT || i > EN_FULL_REPORT) return 213;
p->report.Statflag = i;
break;
default: default:
return 251; return 251;

View File

@@ -1,13 +1,13 @@
/* /*
****************************************************************************** ******************************************************************************
Project: OWA EPANET Project: OWA EPANET
Version: 2.2 Version: 2.3
Module: types.h Module: types.h
Description: symbolic constants and data types used throughout EPANET Description: symbolic constants and data types used throughout EPANET
Authors: see AUTHORS Authors: see AUTHORS
Copyright: see AUTHORS Copyright: see AUTHORS
License: see LICENSE License: see LICENSE
Last Updated: 04/29/2023 Last Updated: 07/17/2023
****************************************************************************** ******************************************************************************
*/ */
@@ -31,7 +31,7 @@ typedef int INT4;
Various constants Various constants
---------------------------------------------- ----------------------------------------------
*/ */
#define CODEVERSION 20200 #define CODEVERSION 20300
#define MAGICNUMBER 516114521 #define MAGICNUMBER 516114521
#define ENGINE_VERSION 201 // Used for binary hydraulics file #define ENGINE_VERSION 201 // Used for binary hydraulics file
#define EOFMARK 0x1A // Use 0x04 for UNIX systems #define EOFMARK 0x1A // Use 0x04 for UNIX systems

View File

@@ -44,7 +44,7 @@ BOOST_FIXTURE_TEST_CASE(test_anlys_getoption, FixtureOpenClose)
BOOST_CHECK_EQUAL_COLLECTIONS(ref.begin(), ref.end(), test.begin(), test.end()); BOOST_CHECK_EQUAL_COLLECTIONS(ref.begin(), ref.end(), test.begin(), test.end());
double temp; double temp;
error = EN_getoption(ph, 26, &temp); error = EN_getoption(ph, 27, &temp);
BOOST_CHECK(error == 251); BOOST_CHECK(error == 251);
} }