New updates to address compiler warnings (issue #370)

In addition to addressing compiler warnings, argument names in the API function prototypes were made more consistent and descriptive. Also additional Doxygen comments were added in preparation for producing a more thorough documentation of the API.
This commit is contained in:
Lew Rossman
2019-01-19 16:56:19 -05:00
parent 414db4d7e2
commit 0cfa45e52e
16 changed files with 1034 additions and 754 deletions

View File

@@ -261,7 +261,7 @@ Public Const EN_R_IS_ACTIVE = 3
Declare Function ENsetstatusreport Lib "epanet2.dll" (ByVal level 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 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
'Analysis Options Functions
Declare Function ENgetoption Lib "epanet2.dll" (ByVal option As Int32, value As Single) As Int32
@@ -289,8 +289,8 @@ Public Const EN_R_IS_ACTIVE = 3
Declare Function ENsetcoord Lib "epanet2.dll" (ByVal index As Int32, ByVal x As Single, ByVal y As Single) As Int32
'Nodal Demand Functions
Declare Function ENgetdemandmodel Lib "epanet2.dll" (type As Int32, pmin As Single, preq As Single, pexp As Single) As Int32
Declare Function ENsetdemandmodel Lib "epanet2.dll" (ByVal type As Int32, ByVal pmin As Single, ByVal preq As Single, ByVal pexp As Single) As Int32
Declare Function ENgetdemandmodel Lib "epanet2.dll" (type_ As Int32, pmin As Single, preq As Single, pexp As Single) As Int32
Declare Function ENsetdemandmodel Lib "epanet2.dll" (ByVal type_ As Int32, ByVal pmin As Single, ByVal preq As Single, ByVal pexp As Single) As Int32
Declare Function ENgetnumdemands Lib "epanet2.dll" (ByVal nodeIndex As Int32, numDemands As Int32) As Int32
Declare Function ENgetbasedemand Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32, value As Single) As Int32
Declare Function ENsetbasedemand Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32, ByVal BaseDemand As Single) As Int32
@@ -322,28 +322,28 @@ Public Const EN_R_IS_ACTIVE = 3
Declare Function ENaddpattern Lib "epanet2.dll" (ByVal id As String) As Int32
Declare Function ENgetpatternindex Lib "epanet2.dll" (ByVal id As String, index As Int32) As Int32
Declare Function ENgetpatternid Lib "epanet2.dll" (ByVal index As Int32, ByVal id As String) As Int32
Declare Function ENgetpatternlen Lib "epanet2.dll" (ByVal index As Int32, len As Int32) As Int32
Declare Function ENgetpatternlen Lib "epanet2.dll" (ByVal index As Int32, len_ As Int32) As Int32
Declare Function ENgetpatternvalue Lib "epanet2.dll" (ByVal index As Int32, ByVal period As Int32, value As Single) As Int32
Declare Function ENsetpatternvalue Lib "epanet2.dll" (ByVal index As Int32, ByVal period As Int32, ByVal value As Single) As Int32
Declare Function ENgetaveragepatternvalue Lib "epanet2.dll" (ByVal index As Int32, value As Single) As Int32
Declare Function ENsetpattern Lib "epanet2.dll" (ByVal index As Int32, values As Any, ByVal len As Int32) As Int32
Declare Function ENsetpattern Lib "epanet2.dll" (ByVal index As Int32, values As Any, ByVal len_ As Int32) As Int32
'Data Curve Functions
Declare Function ENaddcurve Lib "epanet2.dll" (ByVal id As String) As Int32
Declare Function ENgetcurveindex Lib "epanet2.dll" (ByVal id As String, index As Int32) As Int32
Declare Function ENgetcurveid Lib "epanet2.dll" (ByVal index As Int32, ByVal id 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 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 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
Declare Function ENsetcurve Lib "epanet2.dll" (ByVal index As Int32, xValues As Any, yValues As Any, ByVal nPoints As Int32) As Int32
'Simple Control Functions
Declare Function ENaddcontrol Lib "epanet2.dll" (ByVal type As Int32, ByVal linkIndex As Int32, ByVal setting As Single, ByVal nodeIndex As Int32, ByVal level As Single, index As Int32) As Int32
Declare Function ENaddcontrol Lib "epanet2.dll" (ByVal type_ As Int32, ByVal linkIndex As Int32, ByVal setting As Single, ByVal nodeIndex As Int32, ByVal level As Single, index As Int32) As Int32
Declare Function ENdeletecontrol Lib "epanet2.dll" (ByVal index As Int32) As Int32
Declare Function ENgetcontrol Lib "epanet2.dll" (ByVal index As Int32, type As Int32, linkIndex As Int32, setting As Single, nodeIndex As Int32, level As Single) As Int32
Declare Function ENsetcontrol Lib "epanet2.dll" (ByVal index As Int32, ByVal type As Int32, ByVal linkIndex As Int32, ByVal setting As Single, ByVal nodeIndex As Int32, ByVal level As Single) As Int32
Declare Function ENgetcontrol Lib "epanet2.dll" (ByVal index As Int32, type_ As Int32, linkIndex As Int32, setting As Single, nodeIndex As Int32, level As Single) As Int32
Declare Function ENsetcontrol Lib "epanet2.dll" (ByVal index As Int32, ByVal type_ As Int32, ByVal linkIndex As Int32, ByVal setting As Single, ByVal nodeIndex As Int32, ByVal level As Single) As Int32
'Rule-Based Control Functions
Declare Function ENaddrule Lib "epanet2.dll" (ByVal rule As String) As Int32

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,15 @@
/** @file epanet2_enums.h
*/
*/
/*
******************************************************************************
Project: OWA EPANET
Version: 2.2
Module: epanet2_enums.h
Description: enumerations of symbolic constants used by the API
Description: enumerations of symbolic constants used by the API functions
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
Last Updated: 01/08/2019
Last Updated: 01/14/2019
******************************************************************************
*/
@@ -23,65 +23,78 @@
#define EN_MAXID 31 //!< Max. # characters in ID name
#define EN_MAXMSG 255 //!< Max. # characters in message text
/// Node property codes
/// Node properties
/**
These node properties can be accessed with @ref EN_getnodevalue and
@ref EN_setnodevalue. Those marked as read only are computed values that can
only be retrieved.
*/
typedef enum {
EN_ELEVATION = 0, //!< Elevation
EN_BASEDEMAND = 1, //!< Junction baseline demand, from last demand category
EN_PATTERN = 2, //!< Junction baseline demand pattern
EN_EMITTER = 3, //!< Junction emitter coefficient
EN_BASEDEMAND = 1, //!< Primary demand baseline value
EN_PATTERN = 2, //!< Primary demand time pattern index
EN_EMITTER = 3, //!< Emitter flow coefficient
EN_INITQUAL = 4, //!< Initial quality
EN_SOURCEQUAL = 5, //!< Quality source strength
EN_SOURCEPAT = 6, //!< Quality source pattern
EN_SOURCETYPE = 7, //!< Qualiy source type
EN_TANKLEVEL = 8, //!< Current computed tank water level
EN_DEMAND = 9, //!< Current computed demand
EN_HEAD = 10, //!< Current computed hydraulic head
EN_PRESSURE = 11, //!< Current computed pressure
EN_QUALITY = 12, //!< Current computed quality
EN_SOURCEMASS = 13, //!< Current computed quality source mass inflow
EN_INITVOLUME = 14, //!< Tank initial volume
EN_MIXMODEL = 15, //!< Tank mixing model
EN_MIXZONEVOL = 16, //!< Tank mixing zone volume
EN_SOURCEPAT = 6, //!< Quality source pattern index
EN_SOURCETYPE = 7, //!< Quality source type (see @ref EN_SourceType)
EN_TANKLEVEL = 8, //!< Current computed tank water level (read only)
EN_DEMAND = 9, //!< Current computed demand (read only)
EN_HEAD = 10, //!< Current computed hydraulic head (read only)
EN_PRESSURE = 11, //!< Current computed pressure (read only)
EN_QUALITY = 12, //!< Current computed quality (read only)
EN_SOURCEMASS = 13, //!< Current computed quality source mass inflow (read only)
EN_INITVOLUME = 14, //!< Tank initial volume (read only)
EN_MIXMODEL = 15, //!< Tank mixing model (see @ref EN_MixingModel)
EN_MIXZONEVOL = 16, //!< Tank mixing zone volume (read only)
EN_TANKDIAM = 17, //!< Tank diameter
EN_MINVOLUME = 18, //!< Tank minimum volume
EN_VOLCURVE = 19, //!< Tank volume curve
EN_VOLCURVE = 19, //!< Tank volume curve index
EN_MINLEVEL = 20, //!< Tank minimum level
EN_MAXLEVEL = 21, //!< Tank maximum level
EN_MIXFRACTION = 22, //!< Tank mixing fraction
EN_TANK_KBULK = 23, //!< Tank bulk decay coefficient
EN_TANKVOLUME = 24, //!< Current computed tank volume
EN_MAXVOLUME = 25 //!< Tank maximum volume
EN_TANKVOLUME = 24, //!< Current computed tank volume (read only)
EN_MAXVOLUME = 25 //!< Tank maximum volume (read only)
} EN_NodeProperty;
/// Link property codes
/// Link properties
/**
These link properties can be accessed with @ref EN_getlinkvalue and @ref EN_setlinkvalue.
Those marked as read only are computed values that can only be retrieved.
*/
typedef enum {
EN_DIAMETER = 0, //!< Pipe/valve diameter
EN_LENGTH = 1, //!< Pipe length
EN_ROUGHNESS = 2, //!< Pipe roughness coefficient
EN_MINORLOSS = 3, //!< Pipe/valve minor loss coefficient
EN_INITSTATUS = 4, //!< Initial status (e.g., OPEN/CLOSED)
EN_INITSTATUS = 4, //!< Initial status (see @ref EN_LinkStatusType)
EN_INITSETTING = 5, //!< Initial pump speed or valve setting
EN_KBULK = 6, //!< Bulk chemical reaction coefficient
EN_KWALL = 7, //!< Pipe wall chemical reaction coefficient
EN_FLOW = 8, //!< Current computed flow rate
EN_VELOCITY = 9, //!< Current computed flow velocity
EN_HEADLOSS = 10, //!< Current computed head loss
EN_STATUS = 11, //!< Current link status
EN_FLOW = 8, //!< Current computed flow rate (read only)
EN_VELOCITY = 9, //!< Current computed flow velocity (read only)
EN_HEADLOSS = 10, //!< Current computed head loss (read only)
EN_STATUS = 11, //!< Current link status (see @ref EN_LinkStatusType)
EN_SETTING = 12, //!< Current link setting
EN_ENERGY = 13, //!< Current computed pump energy usage
EN_LINKQUAL = 14, //!< Current computed link quality
EN_LINKPATTERN = 15, //!< Pump speed time pattern
EN_PUMP_STATE = 16, //!< Current computed pump state
EN_PUMP_EFFIC = 17, //!< Current computed pump efficiency
EN_ENERGY = 13, //!< Current computed pump energy usage (read only)
EN_LINKQUAL = 14, //!< Current computed link quality (read only)
EN_LINKPATTERN = 15, //!< Pump speed time pattern index
EN_PUMP_STATE = 16, //!< Current computed pump state (read only) (see @ref EN_PumpStateType)
EN_PUMP_EFFIC = 17, //!< Current computed pump efficiency (read only)
EN_PUMP_POWER = 18, //!< Pump constant power rating
EN_PUMP_HCURVE = 19, //!< Pump head v. flow curve
EN_PUMP_ECURVE = 20, //!< Pump efficiency v. flow curve
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
EN_PUMP_EPAT = 22 //!< Pump energy price time pattern index
} EN_LinkProperty;
/// Time parameter codes (all in seconds)
/// Time parameters
/**
These time parameters are accessed using @ref EN_gettimeparam and@ref EN_settimeparam.
All times are expressed in seconds The parameters marked as read only are
computed values that can only be retrieved.
*/
typedef enum {
EN_DURATION = 0, //!< Total simulation duration
EN_HYDSTEP = 1, //!< Hydraulic time step
@@ -90,18 +103,23 @@ typedef enum {
EN_PATTERNSTART = 4, //!< Time when time patterns begin
EN_REPORTSTEP = 5, //!< Reporting time step
EN_REPORTSTART = 6, //!< Time when reporting starts
EN_RULESTEP = 7, //!< Rule evaluation time step
EN_STATISTIC = 8, //!< Reporting statistic code
EN_PERIODS = 9, //!< Number of reporting time periods
EN_RULESTEP = 7, //!< Rule-based control evaluation time step
EN_STATISTIC = 8, //!< Reporting statistic code (see @ref EN_StatisticType)
EN_PERIODS = 9, //!< Number of reporting time periods (read only)
EN_STARTTIME = 10, //!< Simulation starting time of day
EN_HTIME = 11, //!< Elapsed time of current hydraulic solution
EN_QTIME = 12, //!< Elapsed time of current quality solution
EN_HALTFLAG = 13, //!< Flag indicating if the simulation was halted
EN_NEXTEVENT = 14, //!< Next time until a tank becomes empty or full
EN_NEXTEVENTIDX = 15 //!< Index of next tank that becomes empty or full
} EN_TimeProperty;
EN_HTIME = 11, //!< Elapsed time of current hydraulic solution (read only)
EN_QTIME = 12, //!< Elapsed time of current quality solution (read only)
EN_HALTFLAG = 13, //!< Flag indicating if the simulation was halted (read only)
EN_NEXTEVENT = 14, //!< Shortest time until a tank becomes empty or full (read only)
EN_NEXTEVENTTANK = 15 //!< Index of tank with shortest time to become empty or full (read only)
} EN_TimeParameter;
/// Statistics for the most current hydraulic/quality analysis made
/// Analysis convergence statistics
/**
These statistics report the convergence criteria for the most current hydraulic analysis
and the cumulative water quality mass balance error at the current simulation time. They
can be retrieved with @ref EN_getstatistic.
*/
typedef enum {
EN_ITERATIONS = 0, //!< Number of hydraulic iterations taken
EN_RELATIVEERROR = 1, //!< Sum of link flow changes / sum of link flows
@@ -110,7 +128,10 @@ typedef enum {
EN_MASSBALANCE = 4 //!< Cumulative water quality mass balance ratio
} EN_AnalysisStatistic;
/// Object count codes
/// Types of objects to count
/**
These options tell @ref EN_getcount which type of object to count.
*/
typedef enum {
EN_NODECOUNT = 0, //!< Number of nodes (junctions + tanks + reservoirs)
EN_TANKCOUNT = 1, //!< Number of tanks and reservoirs
@@ -121,14 +142,20 @@ typedef enum {
EN_RULECOUNT = 6 //!< Number of rule-based controls
} EN_CountType;
/// Node type codes
/// Types of nodes
/**
These are the different types of nodes that can be returned by calling @ref EN_getnodetype.
*/
typedef enum {
EN_JUNCTION = 0, //!< Junction node
EN_RESERVOIR = 1, //!< Reservoir node
EN_TANK = 2 //!< Storage tank node
} EN_NodeType;
/// Link type codes
/// Types of links
/**
These are the different types of links that can be returned by calling @ref EN_getlinktype.
*/
typedef enum {
EN_CVPIPE = 0, //!< Pipe with check valve
EN_PIPE = 1, //!< Pipe
@@ -141,7 +168,36 @@ typedef enum {
EN_GPV = 8 //!< General purpose valve
} EN_LinkType;
/// Water quality analysis types
/// Link status
/**
One of these values is returned when @ref EN_getlinkvalue is used to retrieve a link's
initial status (EN_INITSTATUS) or its current status (EN_STATUS). These options are
also used with @ref EN_setlinkvalue to set values for these same properties.
*/
typedef enum {
EN_CLOSED = 0,
EN_OPEN = 1
} EN_LinkStatusType;
/// Pump states
/**
One of these codes is returned when @ref EN_getlinkvalue is used to retrieve a pump's
current operating state (EN_PUMP_STATE). EN_PUMP_XHEAD indicates that the pump has been
shut down because it is being asked to deliver more than its shutoff head. EN_PUMP_XFLOW
indicates that the pump is being asked to deliver more than its maximum flow.
*/
typedef enum {
EN_PUMP_XHEAD = 0, //!< Pump closed - cannot supply head
EN_PUMP_CLOSED = 2, //!< Pump closed
EN_PUMP_OPEN = 3, //!< Pump open
EN_PUMP_XFLOW = 5 //!< Pump open - cannot supply flow
} EN_PumpStateType;
/// Types of water quality analyses
/**
These are the different types of water quality analyses that EPANET can run. They
are used with @ref EN_getqualinfo, @ref EN_getqualtype, and @ref EN_setqualtype.
*/
typedef enum {
EN_NONE = 0, //!< No quality analysis
EN_CHEM = 1, //!< Chemical fate and transport
@@ -149,22 +205,40 @@ typedef enum {
EN_TRACE = 3 //!< Source tracing analysis
} EN_QualityType;
/// Water quality source types
/// Types of water quality sources
/**
These are the options for EN_SOURCETYPE, the type of external water quality
source assigned to a node. They are used in @ref EN_getnodevalue and @ref EN_setnodevalue.
The EN_SOURCEQUAL property is used in these functions to access a source's strength
and EN_SOURCEPATTERN to access a time pattern applied to the source.
*/
typedef enum {
EN_CONCEN = 0, //!< Concentration inflow source
EN_MASS = 1, //!< Mass inflow source
EN_SETPOINT = 2, //!< Concentration setpoint source
EN_FLOWPACED = 3 //!< Concentration flow paced source
EN_CONCEN = 0, //!< Concentration of any external inflow entering a node
EN_MASS = 1, //!< Injects a given mass/minute into a node
EN_SETPOINT = 2, //!< Sets the concentration leaving a node to a given value
EN_FLOWPACED = 3 //!< Adds a given value to the concentration leaving a node
} EN_SourceType;
/// Head loss formulas
/// Head loss formula choices
/**
These are the choices for the EN_HEADLOSSFORM option in @ref EN_getoption and
@ref EN_setoption. They are also used for the head loss type argument in @ref EN_init.
Each head loss formula uses a different type of roughness coefficient (EN_ROUGHNESS)
that can be set with @ref EN_setlinkvalue.
*/
typedef enum {
EN_HW = 0, //!< Hazen-Williams
EN_DW = 1, //!< Darcy-Weisbach
EN_CM = 2 //!< Chezy-Manning
} EN_HeadLossType;
/// Flow units types
/// Flow units choices
/**
These choices for flow units are used with @ref EN_getflowunits and @ref EN_setflowunits.
They are also used for the flow units type argument in @ref EN_init. If flow units are
expressed in US Customary units (EN_CFS through EN_AFD) then all other quantities are
in US Customary units. Otherwise they are in metric units.
*/
typedef enum {
EN_CFS = 0, //!< Cubic feet per second
EN_GPM = 1, //!< Gallons per minute
@@ -178,39 +252,65 @@ typedef enum {
EN_CMD = 9 //!< Cubic meters per day
} EN_FlowUnits;
/// Demand model types
/// Types of demand models
/**
These choices for representing consumer demands are used with @ref EN_getdemandmodel
and @ref EN_setdemandmodel.
A demand driven analysis requires that a junction's full demand be supplied
in each time period independent of how much pressure is available. A pressure
driven analysis makes demand be a power function of pressure, up to the point
where the full demand is met.
*/
typedef enum {
EN_DDA = 0, //!< Demand driven analysis
EN_PDA = 1 //!< Pressure driven analysis
} EN_DemandModel;
/// Simulation option codes
/// Simulation options
/**
These options specify hydraulic convergence criteria, choice of head loss formula, and
several other parameters applied on a network-wide basis. They are accessed using the
@ref EN_getoption and @ref EN_setoption functions.
*/
typedef enum {
EN_TRIALS = 0, //!< Maximum hydraulic trials allowed
EN_ACCURACY = 1, //!< Hydraulic convergence accuracy
EN_ACCURACY = 1, //!< Maximum total relative flow change for hydraulic convergence
EN_TOLERANCE = 2, //!< Water quality tolerance
EN_EMITEXPON = 3, //!< Exponent for emitter head loss formula
EN_EMITEXPON = 3, //!< Exponent in emitter discharge formula
EN_DEMANDMULT = 4, //!< Global demand multiplier
EN_HEADERROR = 5, //!< Maximum allowable head loss error
EN_FLOWCHANGE = 6, //!< Maximum allowable flow change
EN_DEFDEMANDPAT = 7, //!< Default demand time pattern
EN_HEADLOSSFORM = 8, //!< Head loss formula
EN_GLOBALEFFIC = 9, //!< Global pump efficiency
EN_HEADERROR = 5, //!< Maximum head loss error for hydraulic convergence
EN_FLOWCHANGE = 6, //!< Maximum flow change for hydraulic convergence
EN_DEFDEMANDPAT = 7, //!< Index of the default demand time pattern
EN_HEADLOSSFORM = 8, //!< Head loss formula (see @ref EN_HeadLossType)
EN_GLOBALEFFIC = 9, //!< Global pump efficiency (percent)
EN_GLOBALPRICE = 10, //!< Global energy price per KWH
EN_GLOBALPATTERN = 11, //!< Global energy price pattern
EN_GLOBALPATTERN = 11, //!< Index of a global energy price pattern
EN_DEMANDCHARGE = 12 //!< Energy charge per max. KW usage
} EN_Option;
/// Simple control types
/// Types of simple controls
/**
These are the different types of simple (single statement) controls that can be applied
to network links. They are used as an argument to @ref EN_addcontrol,@ref EN_getcontrol,
and @ref EN_setcontrol.
*/
typedef enum {
EN_LOWLEVEL = 0, //!< Act when level drops below a setpoint
EN_HILEVEL = 1, //!< Act when level rises above a setpoint
EN_LOWLEVEL = 0, //!< Act when pressure or tank level drops below a setpoint
EN_HILEVEL = 1, //!< Act when pressure or tank level rises above a setpoint
EN_TIMER = 2, //!< Act at a prescribed elapsed amount of time
EN_TIMEOFDAY = 3 //!< Act at a particular time of day
} EN_ControlType;
/// Reporting statistic types
/// Reporting statistic choices
/**
These options determine what kind of statistical post-processing should be done on
the time series of simulation results generated before they are reported using
@ref EN_report. An option can be chosen by using `STATISTIC option` as the argument
to @ref EN_setreport.
*/
typedef enum {
EN_SERIES = 0, //!< Report all time series points
EN_AVERAGE = 1, //!< Report average value over simulation period
EN_MINIMUM = 2, //!< Report minimum value over simulation period
EN_MAXIMUM = 3, //!< Report maximum value over simulation period
@@ -218,6 +318,11 @@ typedef enum {
} EN_StatisticType;
/// Tank mixing models
/**
These are the different types of models that describe water quality mixing in storage tanks.
The choice of model is accessed with the EN_MIXMODEL property of a Tank node using
@ref EN_getnodevalue and @ref EN_setnodevalue.
*/
typedef enum {
EN_MIX1 = 0, //!< Complete mix model
EN_MIX2 = 1, //!< 2-compartment model
@@ -226,14 +331,20 @@ typedef enum {
} EN_MixingModel;
/// Hydraulic initialization options
/**
These options are used to initialize a new hydraulic analysis when @ref EN_initH is called.
*/
typedef enum {
EN_NOSAVE = 0, //!< Don't save hydraulics; don't re-initialize flows
EN_SAVE = 1, //!< Save hydraulics to file, don't re-initialize flows
EN_INITFLOW = 10, //!< Don't save hydraulics; re-initialize flows
EN_SAVE_AND_INIT = 11 //!< Save hydraulics; re-initialize flows
} EN_SaveOption;
} EN_InitHydOption;
/// Pump curve types
/// Types of pump curves
/**
@ref EN_getpumptype returns one of these values when it is called.
*/
typedef enum {
EN_CONST_HP = 0, //!< Constant horsepower
EN_POWER_FUNC = 1, //!< Power function
@@ -241,36 +352,49 @@ typedef enum {
EN_NOCURVE = 3 //!< No curve
} EN_PumpType;
/// Data curve types
/// Types of data curves
/**
These are the different types of physical relationships that a data curve could
represent as returned by calling @ref EN_getcurvetype.
*/
typedef enum {
EN_VOLUME_CURVE = 0, //!< Tank volume curve
EN_PUMP_CURVE = 1, //!< Pump head curve
EN_EFFIC_CURVE = 2, //!< Pump efficiency curve
EN_HLOSS_CURVE = 3, //!< Valve head loss curve
EN_VOLUME_CURVE = 0, //!< Tank volume v. depth curve
EN_PUMP_CURVE = 1, //!< Pump head v. flow curve
EN_EFFIC_CURVE = 2, //!< Pump efficiency v. flow curve
EN_HLOSS_CURVE = 3, //!< Valve head loss v. flow curve
EN_GENERIC_CURVE = 4 //!< Generic curve
} EN_CurveType;
/// Deletion action codes
/**
These codes are used in @ref EN_deletenode and @ref EN_deletelink to indicate what action
should be taken if the node or link being deleted appears in any simple or rule-based
controls.
*/
typedef enum {
EN_UNCONDITIONAL = 0, //!< Delete all controls that contain object
EN_CONDITIONAL = 1 //!< Cancel object deletion if contained in controls
} EN_ActionCodeType;
/// Options for reporting on the status of the hydraulic solver at each time period
/// Status reporting levels
/**
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.
*/
typedef enum {
EN_NO_REPORT = 0, //!< No status reporting
EN_NORMAL_REPORT = 1, //!< Normal level of status reporting
EN_FULL_REPORT = 2 //!< Full level of status reporting
} EN_StatusReport;
/// Codes for objects referred to in the clauses of rule-based controls
/// Network objects used in rule-based controls
typedef enum {
EN_R_NODE = 6, //!< Clause refers to a node
EN_R_LINK = 7, //!< Clause refers to a link
EN_R_SYSTEM = 8 //!< Clause refers to a system parameter (e.g., time)
} EN_RuleObject;
/// Codes for variables used in the clauses of rule-based controls
/// Object variables used in rule-based controls
typedef enum {
EN_R_DEMAND = 0, //!< Nodal demand
EN_R_HEAD = 1, //!< Nodal hydraulic head
@@ -287,7 +411,7 @@ typedef enum {
EN_R_DRAINTIME = 12 //!< Time to drain a tank
} EN_RuleVariable;
/// Comparison operators used in the premises of rule-based controls
/// Comparison operators used in rule-based controls
typedef enum {
EN_R_EQ = 0, //!< Equal to
EN_R_NE = 1, //!< Not equal
@@ -301,7 +425,7 @@ typedef enum {
EN_R_ABOVE = 9 //!< Is above
} EN_RuleOperator;
/// Status codes used in the clauses of rule-based controls
/// Link status codes used in rule-based controls
typedef enum {
EN_R_IS_OPEN = 1, //!< Link is open
EN_R_IS_CLOSED = 2, //!< Link is closed

View File

@@ -123,8 +123,8 @@ int DLLEXPORT EN_init(EN_Project p, const char *rptFile, const char *outFile,
/*----------------------------------------------------------------
** Input: rptFile = name of report file
** outFile = name of binary output file
** unitsType = type of flow units (see EN_FlowUnits)
** headLossType = type of head loss formula (see EN_HeadLossType)
** unitsType = type of flow units (see FlowUnitsType)
** headLossType = type of head loss formula (see HeadLossType)
** Output: none
** Returns: error code
** Purpose: initializes an EPANET project that isn't opened with
@@ -255,7 +255,7 @@ int DLLEXPORT EN_close(EN_Project p)
** Input: none
** Output: none
** Returns: error code
** Purpose: frees all memory & files used by EPANET
** Purpose: frees all memory & files used by a project
**----------------------------------------------------------------
*/
{
@@ -367,7 +367,7 @@ int DLLEXPORT EN_saveH(EN_Project p)
**----------------------------------------------------------------
*/
{
char tmpflag;
int tmpflag;
int errcode;
// Check if hydraulic results exist
@@ -392,7 +392,7 @@ int DLLEXPORT EN_openH(EN_Project p)
** Input: none
** Output: none
** Returns: error code
** Purpose: opens EPANET's hydraulic solver
** Purpose: opens a project's hydraulic solver
**----------------------------------------------------------------
*/
{
@@ -421,7 +421,7 @@ int DLLEXPORT EN_initH(EN_Project p, int initFlag)
** results should be saved to file (1) or not (0)
** Output: none
** Returns: error code
** Purpose: initializes EPANET's hydraulic solver
** Purpose: initializes a project's hydraulic solver
**----------------------------------------------------------------
*/
{
@@ -500,7 +500,7 @@ int DLLEXPORT EN_closeH(EN_Project p)
** Input: none
** Output: none
** Returns: error code
** Purpose: closes EPANET's hydraulic solver
** Purpose: closes a project's hydraulic solver
**----------------------------------------------------------------
*/
{
@@ -516,7 +516,7 @@ int DLLEXPORT EN_savehydfile(EN_Project p, char *filename)
** Output: none
** Returns: error code
** Purpose: saves results from a scratch hydraulics file to a
** permanent one.
** permanent one
**----------------------------------------------------------------
*/
{
@@ -543,8 +543,8 @@ int DLLEXPORT EN_usehydfile(EN_Project p, char *filename)
** Input: filename = name of previously saved hydraulics file
** Output: none
** Returns: error code
** Purpose: uses contents of a previous saved hydraulics file to
** run a water quality analysis.
** Purpose: uses contents of a previously saved hydraulics file to
** run a water quality analysis
**----------------------------------------------------------------
*/
{
@@ -626,7 +626,7 @@ int DLLEXPORT EN_openQ(EN_Project p)
** Input: none
** Output: none
** Returns: error code
** Purpose: opens EPANET's water quality solver
** Purpose: opens a project's water quality solver
**----------------------------------------------------------------
*/
{
@@ -694,7 +694,7 @@ int DLLEXPORT EN_nextQ(EN_Project p, long *tStep)
** Output: tStep = time step over which water quality is updated (sec)
** Returns: error code
** Purpose: updates water quality throughout the network until
** next hydraulic event occurs.
** next hydraulic event occurs
**----------------------------------------------------------------
*/
{
@@ -717,7 +717,7 @@ int DLLEXPORT EN_stepQ(EN_Project p, long *timeLeft)
** Output: timeLeft = amount of simulation time remaining (sec)
** Returns: error code
** Purpose: updates water quality throughout the network over
** fixed time step.
** fixed time step
**----------------------------------------------------------------
*/
{
@@ -739,7 +739,7 @@ int DLLEXPORT EN_closeQ(EN_Project p)
** Input: none
** Output: none
** Returns: error code
** Purpose: closes EPANET's water quality solver
** Purpose: closes a project's water quality solver
**----------------------------------------------------------------
*/
{
@@ -760,7 +760,7 @@ int DLLEXPORT EN_writeline(EN_Project p, char *line)
** Input: line = line of text
** Output: none
** Returns: error code
** Purpose: write a line of text to the project's report file
** Purpose: write a line of text to a project's report file
**----------------------------------------------------------------
*/
{
@@ -774,7 +774,7 @@ int DLLEXPORT EN_report(EN_Project p)
** Input: none
** Output: none
** Returns: error code
** Purpose: writes formatted simulation results to the project's
** Purpose: writes formatted simulation results to a project's
** report file
**----------------------------------------------------------------
*/
@@ -858,11 +858,11 @@ int DLLEXPORT EN_getversion(int *version)
** Input: none
** Output: version = version number of the source code
** Returns: error code (should always be 0)
** Purpose: retrieves a number assigned to the most recent
** update of the source code. This number, set by the
** constant CODEVERSION found in TYPES.H, is to be
** interpreted with implied decimals, i.e.,
** "20100" == "2(.)01(.)00"
** Purpose: retrieves the toolkit API version number
**
** The version number is set by the constant CODEVERSION found in
** TYPES.H and is to be interpreted with implied decimals, i.e.,
** "20100" == "2(.)01(.)00".
**----------------------------------------------------------------
*/
{
@@ -875,7 +875,7 @@ int DLLEXPORT EN_getcount(EN_Project p, int object, int *count)
** Input: object = type of object to count (see EN_CountType)
** Output: count = number of objects of the specified type
** Returns: error code
** Purpose: Retrieves number of network objects of a given type.
** Purpose: Retrieves number of network objects of a given type
**----------------------------------------------------------------
*/
{
@@ -1283,7 +1283,7 @@ int DLLEXPORT EN_setflowunits(EN_Project p, int units)
int DLLEXPORT EN_gettimeparam(EN_Project p, int param, long *value)
/*----------------------------------------------------------------
** Input: param = time parameter code (see EN_TimeProperty)
** Input: param = time parameter code (see EN_TimeParameter)
** Output: value = time parameter value
** Returns: error code
** Purpose: retrieves the value of a time parameter
@@ -1297,7 +1297,7 @@ int DLLEXPORT EN_gettimeparam(EN_Project p, int param, long *value)
*value = 0;
if (!p->Openflag) return 102;
if (param < EN_DURATION || param > EN_NEXTEVENTIDX) return 251;
if (param < EN_DURATION || param > EN_NEXTEVENTTANK) return 251;
switch (param)
{
case EN_DURATION:
@@ -1341,7 +1341,7 @@ int DLLEXPORT EN_gettimeparam(EN_Project p, int param, long *value)
// or the time to next full/empty tank
tanktimestep(p, value);
break;
case EN_NEXTEVENTIDX:
case EN_NEXTEVENTTANK:
*value = time->Hstep;
i = tanktimestep(p, value);
*value = i;
@@ -1352,7 +1352,7 @@ int DLLEXPORT EN_gettimeparam(EN_Project p, int param, long *value)
int DLLEXPORT EN_settimeparam(EN_Project p, int param, long value)
/*----------------------------------------------------------------
** Input: param = time parameter code (see EN_TimeProperty)
** Input: param = time parameter code (see EN_TimeParameter)
** value = time parameter value
** Output: none
** Returns: error code
@@ -1493,7 +1493,7 @@ int DLLEXPORT EN_setqualtype(EN_Project p, int qualType, char *chemName,
** Input: qualType = type of quality analysis to run (see EN_QualityType)
** chemname = name of chemical constituent
** chemunits = concentration units of constituent
** tracenode = index of node being traced (if applicable)
** tracenode = ID name of node being traced (if applicable)
** Output: none
** Returns: error code
** Purpose: sets water quality analysis options
@@ -1701,13 +1701,13 @@ int DLLEXPORT EN_deletenode(EN_Project p, int index, int actionCode)
** its links appear in a control and returns an error code
** Output: none
** Returns: error code
** Purpose: deletes a node from a project.
** Purpose: deletes a node from a project
**----------------------------------------------------------------
*/
{
Network *net = &p->network;
int i, nodeType, tankindex, numControls = 0;
int i, nodeType, tankindex;
Snode *node;
Pdemand demand, nextdemand;
Psource source;
@@ -2350,7 +2350,7 @@ int DLLEXPORT EN_setjuncdata(EN_Project p, int index, double elev,
** dmndpat = name of primary demand time pattern
** Output: none
** Returns: error code
** Purpose: sets several properties for a junction node.
** Purpose: sets several properties for a junction node
**----------------------------------------------------------------
*/
{
@@ -2406,7 +2406,7 @@ int DLLEXPORT EN_settankdata(EN_Project p, int index, double elev,
** volCurve = name of curve for volume v. level
** Output: none
** Returns: error code
** Purpose: sets several properties for a tank node.
** Purpose: sets several properties for a tank node
**----------------------------------------------------------------
*/
{
@@ -2415,7 +2415,6 @@ int DLLEXPORT EN_settankdata(EN_Project p, int index, double elev,
int i, j, n, curveIndex = 0;
double area, elevation = elev;
double *Ucf = p->Ucf;
Snode *Node = net->Node;
Stank *Tank = net->Tank;
Scurve *curve;
@@ -2823,8 +2822,8 @@ int DLLEXPORT EN_addlink(EN_Project p, char *id, int linkType,
link = &net->Link[n];
strncpy(link->ID, id, MAXID);
if (linkType <= EN_PIPE) net->Npipes++;
else if (linkType == EN_PUMP)
if (linkType <= PIPE) net->Npipes++;
else if (linkType == PUMP)
{
// Grow pump array to accomodate the new link
net->Npumps++;
@@ -2860,13 +2859,13 @@ int DLLEXPORT EN_addlink(EN_Project p, char *id, int linkType,
link->N2 = n2;
link->Status = OPEN;
if (linkType == EN_PUMP)
if (linkType == PUMP)
{
link->Kc = 1.0; // Speed factor
link->Km = 0.0; // Horsepower
link->Len = 0.0;
}
else if (linkType <= EN_PIPE) // pipe or cvpipe
else if (linkType <= PIPE) // pipe or cvpipe
{
link->Diam = 10 / p->Ucf[DIAM];
link->Kc = 100; // Rough. coeff
@@ -2901,7 +2900,7 @@ int DLLEXPORT EN_deletelink(EN_Project p, int index, int actionCode)
** in a control and returns an error code
** Output: none
** Returns: error code
** Purpose: deletes a link from a project.
** Purpose: deletes a link from a project
**----------------------------------------------------------------
*/
{
@@ -2918,7 +2917,7 @@ int DLLEXPORT EN_deletelink(EN_Project p, int index, int actionCode)
if (p->hydraul.OpenHflag || p->quality.OpenQflag) return 262;
// Check that link exists
if (index <= 0 || index > net->Nlinks) 204;
if (index <= 0 || index > net->Nlinks) return 204;
if (actionCode < EN_UNCONDITIONAL || actionCode > EN_CONDITIONAL) return 251;
// Deletion will be cancelled if link appears in any controls
@@ -2964,7 +2963,7 @@ int DLLEXPORT EN_deletelink(EN_Project p, int index, int actionCode)
net->Npumps--;
}
// Delete any valve (linkType > EN_PUMP) associated with the deleted link
// Delete any valve (linkType > PUMP) associated with the deleted link
if (linkType > PUMP)
{
valveindex = findvalve(net, index);
@@ -3235,7 +3234,7 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, int property, double *val
switch (property)
{
case EN_DIAMETER:
if (Link[index].Type == EN_PUMP) v = 0.0;
if (Link[index].Type == PUMP) v = 0.0;
else v = Link[index].Diam * Ucf[DIAM];
break;
@@ -3244,7 +3243,7 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, int property, double *val
break;
case EN_ROUGHNESS:
if (Link[index].Type <= EN_PIPE)
if (Link[index].Type <= PIPE)
{
if (hyd->Formflag == DW) v = Link[index].Kc * (1000.0 * Ucf[ELEV]);
else v = Link[index].Kc;
@@ -3253,7 +3252,7 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, int property, double *val
break;
case EN_MINORLOSS:
if (Link[index].Type != EN_PUMP)
if (Link[index].Type != PUMP)
{
v = Link[index].Km;
v *= (SQR(Link[index].Diam) * SQR(Link[index].Diam) / 0.02517);
@@ -3267,19 +3266,19 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, int property, double *val
break;
case EN_INITSETTING:
if (Link[index].Type == EN_PIPE || Link[index].Type == EN_CVPIPE)
if (Link[index].Type == PIPE || Link[index].Type == CVPIPE)
{
return EN_getlinkvalue(p, index, EN_ROUGHNESS, value);
}
v = Link[index].Kc;
switch (Link[index].Type)
{
case EN_PRV:
case EN_PSV:
case EN_PBV:
case PRV:
case PSV:
case PBV:
v *= Ucf[PRESSURE];
break;
case EN_FCV:
case FCV:
v *= Ucf[FLOW];
default:
break;
@@ -3300,7 +3299,7 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, int property, double *val
break;
case EN_VELOCITY:
if (Link[index].Type == EN_PUMP) v = 0.0;
if (Link[index].Type == PUMP) v = 0.0;
else if (hyd->LinkStatus[index] <= CLOSED) v = 0.0;
else
{
@@ -3315,7 +3314,7 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, int property, double *val
else
{
h = hyd->NodeHead[Link[index].N1] - hyd->NodeHead[Link[index].N2];
if (Link[index].Type != EN_PUMP) h = ABS(h);
if (Link[index].Type != PUMP) h = ABS(h);
v = h * Ucf[HEADLOSS];
}
break;
@@ -3326,7 +3325,7 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, int property, double *val
break;
case EN_SETTING:
if (Link[index].Type == EN_PIPE || Link[index].Type == EN_CVPIPE)
if (Link[index].Type == PIPE || Link[index].Type == CVPIPE)
{
return EN_getlinkvalue(p, index, EN_ROUGHNESS, value);
}
@@ -3334,12 +3333,12 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, int property, double *val
else v = LinkSetting[index];
switch (Link[index].Type)
{
case EN_PRV:
case EN_PSV:
case EN_PBV:
case PRV:
case PSV:
case PBV:
v *= Ucf[PRESSURE];
break;
case EN_FCV:
case FCV:
v *= Ucf[FLOW];
default:
break;
@@ -3355,7 +3354,7 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, int property, double *val
break;
case EN_LINKPATTERN:
if (Link[index].Type == EN_PUMP)
if (Link[index].Type == PUMP)
{
v = (double)Pump[findpump(&p->network, index)].Upat;
}
@@ -3364,7 +3363,7 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, int property, double *val
case EN_PUMP_STATE:
v = hyd->LinkStatus[index];
if (Link[index].Type == EN_PUMP)
if (Link[index].Type == PUMP)
{
pmp = findpump(net, index);
if (hyd->LinkStatus[index] >= OPEN)
@@ -3384,7 +3383,7 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, int property, double *val
case EN_PUMP_POWER:
v = 0;
if (Link[index].Type == EN_PUMP)
if (Link[index].Type == PUMP)
{
pmp = findpump(net, index);
if (Pump[pmp].Ptype == CONST_HP) v = Link[index].Km; // Power in HP or KW
@@ -3392,28 +3391,28 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, int property, double *val
break;
case EN_PUMP_HCURVE:
if (Link[index].Type == EN_PUMP)
if (Link[index].Type == PUMP)
{
v = (double)Pump[findpump(&p->network, index)].Hcurve;
}
break;
case EN_PUMP_ECURVE:
if (Link[index].Type == EN_PUMP)
if (Link[index].Type == PUMP)
{
v = (double)Pump[findpump(&p->network, index)].Ecurve;
}
break;
case EN_PUMP_ECOST:
if (Link[index].Type == EN_PUMP)
if (Link[index].Type == PUMP)
{
v = (double)Pump[findpump(&p->network, index)].Ecost;
}
break;
case EN_PUMP_EPAT:
if (Link[index].Type == EN_PUMP)
if (Link[index].Type == PUMP)
{
v = (double)Pump[findpump(&p->network, index)].Epat;
}
@@ -3453,7 +3452,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
switch (property)
{
case EN_DIAMETER:
if (Link[index].Type != EN_PUMP)
if (Link[index].Type != PUMP)
{
if (value <= 0.0) return 211;
value /= Ucf[DIAM]; // Convert to feet
@@ -3465,7 +3464,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
break;
case EN_LENGTH:
if (Link[index].Type <= EN_PIPE)
if (Link[index].Type <= PIPE)
{
if (value <= 0.0) return 211;
Link[index].Len = value / Ucf[ELEV];
@@ -3474,7 +3473,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
break;
case EN_ROUGHNESS:
if (Link[index].Type <= EN_PIPE)
if (Link[index].Type <= PIPE)
{
if (value <= 0.0) return 211;
Link[index].Kc = value;
@@ -3484,7 +3483,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
break;
case EN_MINORLOSS:
if (Link[index].Type != EN_PUMP)
if (Link[index].Type != PUMP)
{
if (value <= 0.0) return 211;
Link[index].Km = 0.02517 * value / SQR(Link[index].Diam) /
@@ -3495,7 +3494,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
case EN_INITSTATUS:
case EN_STATUS:
// Cannot set status for a check valve
if (Link[index].Type == EN_CVPIPE) return 207;
if (Link[index].Type == CVPIPE) return 207;
s = (char)ROUND(value);
if (s < 0 || s > 1) return 211;
if (property == EN_INITSTATUS)
@@ -3511,7 +3510,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
case EN_INITSETTING:
case EN_SETTING:
if (value < 0.0) return 211;
if (Link[index].Type == EN_PIPE || Link[index].Type == EN_CVPIPE)
if (Link[index].Type == PIPE || Link[index].Type == CVPIPE)
{
return EN_setlinkvalue(p, index, EN_ROUGHNESS, value);
}
@@ -3519,19 +3518,19 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
{
switch (Link[index].Type)
{
case EN_PUMP:
case PUMP:
break;
case EN_PRV:
case EN_PSV:
case EN_PBV:
case PRV:
case PSV:
case PBV:
value /= Ucf[PRESSURE];
break;
case EN_FCV:
case FCV:
value /= Ucf[FLOW];
break;
case EN_TCV:
case TCV:
break;
case EN_GPV:
case GPV:
return 207; // Cannot modify setting for GPV
default:
return 0;
@@ -3549,7 +3548,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
break;
case EN_KBULK:
if (Link[index].Type <= EN_PIPE)
if (Link[index].Type <= PIPE)
{
Link[index].Kb = value / SECperDAY;
qual->Reactflag = 1;
@@ -3557,7 +3556,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
break;
case EN_KWALL:
if (Link[index].Type <= EN_PIPE)
if (Link[index].Type <= PIPE)
{
Link[index].Kw = value / SECperDAY;
qual->Reactflag = 1;
@@ -3565,7 +3564,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
break;
case EN_LINKPATTERN:
if (Link[index].Type == EN_PUMP)
if (Link[index].Type == PUMP)
{
patIndex = ROUND(value);
if (patIndex <= 0 || patIndex > net->Npats) return 205;
@@ -3575,7 +3574,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
break;
case EN_PUMP_POWER:
if (Link[index].Type == EN_PUMP)
if (Link[index].Type == PUMP)
{
if (value <= 0.0) return 211;
pumpIndex = findpump(&p->network, index);
@@ -3591,14 +3590,14 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
break;
case EN_PUMP_HCURVE:
if (Link[index].Type == EN_PUMP)
if (Link[index].Type == PUMP)
{
return EN_setheadcurveindex(p, index, ROUND(value));
}
break;
case EN_PUMP_ECURVE:
if (Link[index].Type == EN_PUMP)
if (Link[index].Type == PUMP)
{
curveIndex = ROUND(value);
if (curveIndex <= 0 || curveIndex > net->Ncurves) return 205;
@@ -3608,7 +3607,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
break;
case EN_PUMP_ECOST:
if (Link[index].Type == EN_PUMP)
if (Link[index].Type == PUMP)
{
if (value < 0.0) return 211;
pumpIndex = findpump(&p->network, index);
@@ -3617,7 +3616,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
break;
case EN_PUMP_EPAT:
if (Link[index].Type == EN_PUMP)
if (Link[index].Type == PUMP)
{
patIndex = ROUND(value);
if (patIndex <= 0 || patIndex > net->Npats) return 205;
@@ -3642,7 +3641,7 @@ int DLLEXPORT EN_setpipedata(EN_Project p, int index, double length,
** mloss = minor loss coefficient
** Output: none
** Returns: error code
** Purpose: sets several properties for a pipe link.
** Purpose: sets several properties for a pipe link
**----------------------------------------------------------------
*/
{
@@ -3655,7 +3654,7 @@ int DLLEXPORT EN_setpipedata(EN_Project p, int index, double length,
// Check that pipe exists
if (!p->Openflag) return 102;
if (index <= 0 || index > net->Nlinks) return 204;
if (Link[index].Type > EN_PIPE) return 0;
if (Link[index].Type > PIPE) return 0;
// Check for valid parameters
if (length <= 0.0 || diam <= 0.0 || rough <= 0.0 || mloss < 0.0) return 211;
@@ -3698,7 +3697,7 @@ int DLLEXPORT EN_getpumptype(EN_Project p, int linkIndex, int *pumpType)
*pumpType = -1;
if (!p->Openflag) return 102;
if (linkIndex < 1 || linkIndex > Nlinks) return 204;
if (EN_PUMP != Link[linkIndex].Type) return 216;
if (PUMP != Link[linkIndex].Type) return 216;
*pumpType = Pump[findpump(&p->network, linkIndex)].Ptype;
return 0;
}
@@ -3721,7 +3720,7 @@ int DLLEXPORT EN_getheadcurveindex(EN_Project p, int linkIndex, int *curveIndex)
*curveIndex = 0;
if (!p->Openflag) return 102;
if (linkIndex < 1 || linkIndex > Nlinks) return 204;
if (EN_PUMP != Link[linkIndex].Type) return 216;
if (PUMP != Link[linkIndex].Type) return 216;
*curveIndex = Pump[findpump(net, linkIndex)].Hcurve;
return 0;
}
@@ -3738,9 +3737,6 @@ int DLLEXPORT EN_setheadcurveindex(EN_Project p, int linkIndex, int curveIndex)
{
Network *net = &p->network;
Slink *Link = net->Link;
const int Nlinks = net->Nlinks;
const int Ncurves = net->Ncurves;
double *Ucf = p->Ucf;
int pumpIndex;
Spump *pump;
@@ -3748,7 +3744,7 @@ int DLLEXPORT EN_setheadcurveindex(EN_Project p, int linkIndex, int curveIndex)
// Check for valid parameters
if (!p->Openflag) return 102;
if (linkIndex < 1 || linkIndex > net->Nlinks) return 204;
if (EN_PUMP != net->Link[linkIndex].Type) return 0;
if (PUMP != net->Link[linkIndex].Type) return 0;
if (curveIndex <= 0 || curveIndex > net->Ncurves) return 206;
// Assign the new curve to the pump
@@ -4275,7 +4271,7 @@ int DLLEXPORT EN_addcontrol(EN_Project p, int type, int linkIndex, double settin
if (linkIndex <= 0 || linkIndex > net->Nlinks) return 204;
// Cannot control check valve
if (net->Link[linkIndex].Type == EN_CVPIPE) return 207;
if (net->Link[linkIndex].Type == CVPIPE) return 207;
// Check for valid parameters
if (type < 0 || type > EN_TIMEOFDAY) return 251;
@@ -4289,22 +4285,22 @@ int DLLEXPORT EN_addcontrol(EN_Project p, int type, int linkIndex, double settin
// Adjust units of control parameters
switch (net->Link[linkIndex].Type)
{
case EN_PRV:
case EN_PSV:
case EN_PBV:
case PRV:
case PSV:
case PBV:
s /= Ucf[PRESSURE];
break;
case EN_FCV:
case FCV:
s /= Ucf[FLOW];
break;
case EN_GPV:
case GPV:
if (s == 0.0) status = CLOSED;
else if (s == 1.0) status = OPEN;
else return 202;
s = net->Link[linkIndex].Kc;
break;
case EN_PIPE:
case EN_PUMP:
case PIPE:
case PUMP:
status = OPEN;
if (s == 0.0) status = CLOSED;
default:
@@ -4407,12 +4403,12 @@ int DLLEXPORT EN_getcontrol(EN_Project p, int index, int *type, int *linkIndex,
{
switch (net->Link[*linkIndex].Type)
{
case EN_PRV:
case EN_PSV:
case EN_PBV:
case PRV:
case PSV:
case PBV:
s *= Ucf[PRESSURE];
break;
case EN_FCV:
case FCV:
s *= Ucf[FLOW];
default:
break;
@@ -4487,7 +4483,7 @@ int DLLEXPORT EN_setcontrol(EN_Project p, int index, int type, int linkIndex,
if (linkIndex < 0 || linkIndex > net->Nlinks) return 204;
// Cannot control check valve
if (net->Link[linkIndex].Type == EN_CVPIPE) return 207;
if (net->Link[linkIndex].Type == CVPIPE) return 207;
// Check for valid control properties
if (type < 0 || type > EN_TIMEOFDAY) return 251;
@@ -4502,22 +4498,22 @@ int DLLEXPORT EN_setcontrol(EN_Project p, int index, int type, int linkIndex,
link = &net->Link[linkIndex];
switch (link->Type)
{
case EN_PRV:
case EN_PSV:
case EN_PBV:
case PRV:
case PSV:
case PBV:
s /= Ucf[PRESSURE];
break;
case EN_FCV:
case FCV:
s /= Ucf[FLOW];
break;
case EN_GPV:
case GPV:
if (s == 0.0) status = CLOSED;
else if (s == 1.0) status = OPEN;
else return 202;
s = link->Kc;
break;
case EN_PIPE:
case EN_PUMP:
case PIPE:
case PUMP:
status = OPEN;
if (s == 0.0) status = CLOSED;
default:
@@ -4609,7 +4605,7 @@ int DLLEXPORT EN_deleterule(EN_Project p, int index)
** Input: index = rule index
** Output: none
** Returns: error code
** Purpose: deletes a rule from a project.
** Purpose: deletes a rule from a project
**----------------------------------------------------------------
*/
{
@@ -4810,7 +4806,7 @@ int DLLEXPORT EN_setpremisestatus(EN_Project p, int ruleIndex, int premiseIndex,
if (ruleIndex < 1 || ruleIndex > p->network.Nrules) return 257;
premises = p->network.Rule[ruleIndex].Premises;
premise = getpremise(premises, ruleIndex);
premise = getpremise(premises, premiseIndex);
if (premise == NULL) return 258;
premise->status = status;

View File

@@ -100,6 +100,8 @@ int hydsolve(Project *pr, int *iter, double *relerr)
// Initialize status checking & relaxation factor
nextcheck = hyd->CheckFreq;
hyd->RelaxFactor = 1.0;
hydbal.maxheaderror = 0.0;
hydbal.maxflowchange = 0.0;
// Repeat iterations until convergence or trial limit is exceeded.
// (ExtraIter used to increase trials in case of status cycling.)
@@ -360,7 +362,6 @@ double newflows(Project *pr, Hydbalance *hbal)
**----------------------------------------------------------------
*/
{
Network *net = &pr->network;
Hydraul *hyd = &pr->hydraul;
double dqsum, // Network flow change

View File

@@ -102,7 +102,6 @@ int saveinpfile(Project *pr, const char *fname)
Times *time = &pr->times;
int i, j, n;
int errcode;
double d, kc, ke, km, ucf;
char s[MAXLINE + 1], s1[MAXLINE + 1], s2[MAXLINE + 1];
Pdemand demand;
@@ -451,7 +450,7 @@ int saveinpfile(Project *pr, const char *fname)
for (i = 1; i <= net->Nrules; i++)
{
fprintf(f, "\nRULE %s", pr->network.Rule[i].label);
errcode = writerule(pr, f, i); // see RULES.C
writerule(pr, f, i); // see RULES.C
fprintf(f, "\n");
}
@@ -489,7 +488,7 @@ int saveinpfile(Project *pr, const char *fname)
fprintf(f, s_MIXING);
for (i = 1; i <= net->Ntanks; i++)
{
Stank *tank = &net->Tank[i];
tank = &net->Tank[i];
if (tank->A == 0.0) continue;
fprintf(f, "\n %-31s %-8s %12.4f", net->Node[tank->Node].ID,
MixTxt[tank->MixModel], (tank->V1max / tank->Vmax));
@@ -719,7 +718,7 @@ int saveinpfile(Project *pr, const char *fname)
j = 0;
for (i = 1; i <= net->Nlinks; i++)
{
Slink *link = &net->Link[i];
link = &net->Link[i];
if (link->Rpt == 1)
{
if (j % 5 == 0) fprintf(f, "\n LINKS ");

View File

@@ -499,7 +499,7 @@ int valvedata(Project *pr)
else if (match(parser->Tok[4], w_GPV)) type = GPV;
else return setError(parser, 4, 213);
if (!getfloat(parser->Tok[3], &diam)) return setError(parser, 3, 202); 202;
if (!getfloat(parser->Tok[3], &diam)) return setError(parser, 3, 202);
if (diam <= 0.0) return setError(parser, 3, 211);
// Find headloss curve for GPV

View File

@@ -579,7 +579,6 @@ int incontrols(Project *pr, int objType, int index)
*/
{
Network *net = &pr->network;
Rules *rules = &pr->rules;
int i, ruleObject;
Spremise *premise;

View File

@@ -35,7 +35,7 @@ const double Q_STAGNANT = 0.005 / GPMperCFS; // 0.005 gpm = 1.114e-5 cfs
//int stepqual(Project *, long *);
//int closequal(Project *);
//double avgqual(Project *, int);
double findsourcequal(Project *, int, double, double, long);
double findsourcequal(Project *, int, double, long);
// Imported functions
extern char setreactflag(Project *);
@@ -202,8 +202,8 @@ int runqual(Project *pr, long *t)
Quality *qual = &pr->quality;
Times *time = &pr->times;
long hydtime; // Hydraulic solution time
long hydstep; // Hydraulic time step
long hydtime = 0; // Hydraulic solution time
long hydstep = 0; // Hydraulic time step
int errcode = 0;
// Update reported simulation time
@@ -452,11 +452,10 @@ double avgqual(Project *pr, int k)
}
double findsourcequal(Project *pr, int n, double volin, double volout, long tstep)
double findsourcequal(Project *pr, int n, double volout, long tstep)
/*
**---------------------------------------------------------------------
** Input: n = node index
** volin = volume of node inflow over time step
** volout = volume of node outflow over time step
** tstep = current quality time step
** Output: returns concentration added by an external quality source.
@@ -543,7 +542,6 @@ double sourcequal(Project *pr, Psource source)
*/
{
Network *net = &pr->network;
Quality *qual = &pr->quality;
Times *time = &pr->times;
int i;

View File

@@ -445,7 +445,6 @@ double mixtank(Project *pr, int n, double volin, double massin, double volout)
*/
{
Network *net = &pr->network;
Quality *qual = &pr->quality;
int i;
double vnet;
@@ -475,7 +474,6 @@ void tankmix1(Project *pr, int i, double vin, double win, double vnet)
*/
{
Network *net = &pr->network;
Hydraul *hyd = &pr->hydraul;
Quality *qual = &pr->quality;
int k;
@@ -589,7 +587,6 @@ void tankmix3(Project *pr, int i, double vin, double win, double vnet)
*/
{
Network *net = &pr->network;
Hydraul *hyd = &pr->hydraul;
Quality *qual = &pr->quality;
int k;
@@ -662,7 +659,7 @@ void tankmix4(Project *pr, int i, double vin, double win, double vnet)
Network *net = &pr->network;
Quality *qual = &pr->quality;
int k, n;
int k;
double cin, vsum, wsum, vseg;
Pseg seg;
Stank *tank = &pr->network.Tank[i];
@@ -671,7 +668,6 @@ void tankmix4(Project *pr, int i, double vin, double win, double vnet)
if (qual->LastSeg[k] == NULL || qual->FirstSeg[k] == NULL) return;
// Find inflows & outflows
n = tank->Node;
if (vin > 0.0) cin = win / vin;
else cin = 0.0;

View File

@@ -35,7 +35,7 @@ void reversesegs(Project *, int);
void addseg(Project *, int, double, double);
// Imported functions
extern double findsourcequal(Project *, int, double, double, long);
extern double findsourcequal(Project *, int, double, long);
extern void reactpipes(Project *, long);
extern void reacttanks(Project *, long);
extern double mixtank(Project *, int, double, double, double);
@@ -147,7 +147,6 @@ void evalnodeinflow(Project *pr, int k, long tstep, double *volin,
**--------------------------------------------------------------
*/
{
Network *net = &pr->network;
Hydraul *hyd = &pr->hydraul;
Quality *qual = &pr->quality;
@@ -251,7 +250,7 @@ double findnodequal(Project *pr, int n, double volin,
}
// Find quality contribued by any external chemical source
else qual->SourceQual = findsourcequal(pr, n, volin, volout, tstep);
else qual->SourceQual = findsourcequal(pr, n, volout, tstep);
if (qual->SourceQual == 0.0) return qual->NodeQual[n];
// Combine source quality with node quality
@@ -285,7 +284,6 @@ double noflowqual(Project *pr, int n)
*/
{
Network *net = &pr->network;
Hydraul *hyd = &pr->hydraul;
Quality *qual = &pr->quality;
int k, inflow, kount = 0;
@@ -428,7 +426,6 @@ int sortnodes(Project *pr)
*/
{
Network *net = &pr->network;
Hydraul *hyd = &pr->hydraul;
Quality *qual = &pr->quality;
int i, j, k, n;
@@ -578,7 +575,6 @@ void initsegs(Project *pr)
*/
{
Network *net = &pr->network;
Hydraul *hyd = &pr->hydraul;
Quality *qual = &pr->quality;
int j, k;

View File

@@ -70,7 +70,7 @@ int writereport(Project *pr)
Report *rpt = &pr->report;
Parser *parser = &pr->parser;
char tflag;
int tflag;
FILE *tfile;
int errcode = 0;
@@ -399,7 +399,7 @@ void writemassbalance(Project *pr)
writeline(pr, s1);
snprintf(s1, MAXMSG, "Final Mass: %12.5e", qual->MassBalance.final);
writeline(pr, s1);
snprintf(s1, MAXMSG, "Mass Ratio: %-0.5f", qual->MassBalance.ratio);
snprintf(s1, MAXMSG, "Mass Ratio: %-.5f", qual->MassBalance.ratio);
writeline(pr, s1);
snprintf(s1, MAXMSG, "================================\n");
writeline(pr, s1);
@@ -1001,7 +1001,7 @@ int writehydwarn(Project *pr, int iter, double relerr)
int i, j;
char flag = 0;
char s;
int s;
Snode *Node = net->Node;
Slink *Link = net->Link;
Spump *Pump = net->Pump;

View File

@@ -328,7 +328,6 @@ void adjustrules(Project *pr, int objtype, int index)
//-----------------------------------------------------------
{
Network *net = &pr->network;
Rules *rules = &pr->rules;
int i, delete;
Spremise *p;
@@ -453,7 +452,6 @@ int writerule(Project *pr, FILE *f, int ruleIndex)
//-----------------------------------------------------------------------------
{
Network *net = &pr->network;
Rules *rules = &pr->rules;
Srule *rule = &net->Rule[ruleIndex];
Spremise *p;

View File

@@ -198,7 +198,6 @@ void freesparse(Project *pr)
**----------------------------------------------------------------
*/
{
Network *net = &pr->network;
Smatrix *sm = &pr->hydraul.smatrix;
// stoptimer(SmatrixTimer);

View File

@@ -384,7 +384,7 @@ typedef struct // Node Object
Psource S; // source pointer
double C0; // initial quality
double Ke; // emitter coeff.
char Rpt; // reporting flag
int Rpt; // reporting flag
NodeType Type; // node type
char Comment[MAXMSG+1]; // node comment
} Snode;
@@ -405,7 +405,7 @@ typedef struct // Link Object
double Qa; // low flow limit
LinkType Type; // link type
StatusType Status; // initial status
char Rpt; // reporting flag
int Rpt; // reporting flag
char Comment[MAXMSG+1]; // link Comment
} Slink;
@@ -466,7 +466,7 @@ typedef struct // Field Object of Report Table
{
char Name[MAXID+1]; // name of reported variable
char Units[MAXID+1]; // units of reported variable
char Enabled; // enabled if in table
int Enabled; // enabled if in table
int Precision; // number of decimal places
double RptLim[2]; // lower/upper report limits
} SField;
@@ -544,9 +544,6 @@ typedef struct {
FILE *InFile; // Input file handle
char
Unitsflag, // Unit system flag
Flowflag, // Flow units flag
Pressflag, // Pressure units flag
DefPatID[MAXID+1], // Default demand pattern ID
InpFname[MAXFNAME+1], // Input file name
*Tok[MAXTOKS], // Array of token strings
@@ -566,7 +563,10 @@ typedef struct {
MaxCurves, // Curve count " " "
Ntokens, // Number of tokens in line of input
Ntitle, // Number of title lines
ErrTok; // Index of error-producing token
ErrTok, // Index of error-producing token
Unitsflag, // Unit system flag
Flowflag, // Flow units flag
Pressflag; // Pressure units flag
STmplist
*Patlist, // Temporary time pattern list
@@ -605,13 +605,7 @@ typedef struct {
int
Nperiods, // Number of reporting periods
PageSize; // Lines/page in output report/
long
LineNum, // Current line number
PageNum; // Current page number
char
PageSize, // Lines/page in output report/
Rptflag, // Report flag
Tstatflag, // Report time series statistic flag
Summaryflag, // Report summary flag
@@ -620,11 +614,17 @@ typedef struct {
Energyflag, // Energy report flag
Nodeflag, // Node report flag
Linkflag, // Link report flag
Fprinterr; // File write error flag
long
LineNum, // Current line number
PageNum; // Current page number
char
Atime[13], // Clock time (hrs:min:sec)
Rpt1Fname[MAXFNAME+1], // Primary report file name
Rpt2Fname[MAXFNAME+1], // Secondary report file name
DateStamp[26], // Current date & time
Fprinterr; // File write error flag
DateStamp[26]; // Current date & time
SField Field[MAXVAR]; // Output reporting fields
@@ -635,7 +635,9 @@ typedef struct {
char
HydFname[MAXFNAME+1], // Hydraulics file name
OutFname[MAXFNAME+1], // Binary output file name
OutFname[MAXFNAME+1]; // Binary output file name
int
Outflag, // Output file flag
Hydflag, // Hydraulics flag
SaveHflag, // Hydraulic results saved flag
@@ -732,21 +734,19 @@ typedef struct {
DefPat, // Default demand pattern
Epat, // Energy cost time pattern
DemandModel, // Fixed or pressure dependent
Formflag, // Head loss formula flag
Iterations, // Number of hydraulic trials taken
MaxIter, // Max. hydraulic trials allowed
ExtraIter, // Extra hydraulic trials
CheckFreq, // Hydraulic trials between status checks
MaxCheck, // Hydraulic trials limit on status checks
OpenHflag, // Hydraulic system opened flag
Haltflag; // Flag to halt simulation
StatusType
*LinkStatus, // Link status
*OldStatus; // Previous link/tank status
char
OpenHflag, // Hydraulic system opened flag
Formflag; // Head loss formula flag
Smatrix smatrix; // Sparse matrix storage
} Hydraul;
@@ -757,20 +757,18 @@ struct Mempool;
// Water Quality Solver Wrapper
typedef struct {
char
int
Qualflag, // Water quality analysis flag
OpenQflag, // Quality system opened flag
Reactflag, // Reaction indicator
OutOfMemory; // Out of memory indicator
OutOfMemory, // Out of memory indicator
TraceNode, // Source node for flow tracing
*SortedNodes; // Topologically sorted node indexes
char
ChemName[MAXID + 1], // Name of chemical
ChemUnits[MAXID + 1]; // Units of chemical
int
TraceNode, // Source node for flow tracing
*SortedNodes; // Topologically sorted node indexes
double
Ctol, // Water quality tolerance
Diffus, // Diffusivity (sq ft/sec)
@@ -854,9 +852,11 @@ typedef struct Project {
double Ucf[MAXVAR]; // Unit conversion factors
char
int
Openflag, // Project open flag
Warnflag, // Warning flag
Warnflag; // Warning flag
char
Msg[MAXMSG+1], // General-purpose string: errors, messages
Title[MAXTITLE][TITLELEN+1], // Project title
MapFname[MAXFNAME+1], // Map file name

View File

@@ -45,14 +45,14 @@ int main(int argc, char *argv[])
EN_init(ph, "", "", EN_GPM, EN_HW);
// Build a network
EN_addnode(ph, "N1", EN_JUNCTION);
EN_addnode(ph, "N2", EN_JUNCTION);
EN_addnode(ph, "N3", EN_RESERVOIR);
EN_addnode(ph, "N4", EN_TANK);
EN_addlink(ph, "L1", EN_PUMP, "N3", "N1");
EN_addlink(ph, "L2", EN_PIPE, "N1", "N3");
EN_addlink(ph, "L3", EN_PIPE, "N1", "N2");
EN_addcurve(ph, "C1");
EN_addnode(ph, (char *)"N1", EN_JUNCTION);
EN_addnode(ph, (char *)"N2", EN_JUNCTION);
EN_addnode(ph, (char *)"N3", EN_RESERVOIR);
EN_addnode(ph, (char *)"N4", EN_TANK);
EN_addlink(ph, (char *)"L1", EN_PUMP, (char *)"N3", (char *)"N1");
EN_addlink(ph, (char *)"L2", EN_PIPE, (char *)"N1", (char *)"N3");
EN_addlink(ph, (char *)"L3", EN_PIPE, (char *)"N1", (char *)"N2");
EN_addcurve(ph, (char *)"C1");
// Set network data using the new helper functions
EN_setcurvevalue(ph, 1, 1, 1500, 250);
@@ -88,9 +88,9 @@ int main(int argc, char *argv[])
// Save these new results
EN_getnodevalue(ph, 1, EN_PRESSURE, &p1_2);
EN_getnodevalue(ph, 2, EN_PRESSURE, &p2_2);
EN_getlinkindex(ph, "L1", &index);
EN_getlinkindex(ph, (char *)"L1", &index);
EN_getlinkvalue(ph, index, EN_FLOW, &q1_2);
EN_getlinkindex(ph, "L2", &index);
EN_getlinkindex(ph, (char *)"L2", &index);
EN_getlinkvalue(ph, index, EN_FLOW, &q2_2);
// Display old & new results