Merging upstream dev
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
Release Notes for EPANET 2.2 (Draft)
|
||||
============================
|
||||
|
||||
@@ -29,7 +28,7 @@ int runEpanet(char *finp, char *frpt)
|
||||
if (!err) err = EN_solveH(ph);
|
||||
if (!err) err = EN_report(ph);
|
||||
EN_close(ph);
|
||||
EN_deleteproject(ph);
|
||||
EN_deleteproject(&ph);
|
||||
return err;
|
||||
}
|
||||
```
|
||||
@@ -129,35 +128,35 @@ Both network files are available [here](https://doi.org/10.23719/1375314).
|
||||
## New API functions
|
||||
|Function|Description|
|
||||
|--|--|
|
||||
|`ENaddlink`| |
|
||||
|`ENaddnode`| |
|
||||
|`ENgetcurvetype`| |
|
||||
|`ENgetdemandmodel`||
|
||||
|`ENsetdemandmodel`||
|
||||
|`ENsetflowunits`||
|
||||
|`ENaddcontrol`||
|
||||
|`ENsetdemandpattern`||
|
||||
|`ENgetrule`||
|
||||
|`ENsetrulepriority`||
|
||||
|`ENgetpremise`||
|
||||
|`ENsetpremise`||
|
||||
|`ENsetpremiseindex`||
|
||||
|`ENsetpremisestatus`||
|
||||
|`ENsetpremisevalue`||
|
||||
|`ENgettrueaction`||
|
||||
|`ENsettrueaction`||
|
||||
|`ENgetfalseaction`||
|
||||
|`ENsetfalseaction`||
|
||||
|`ENgetruleID`||
|
||||
|`ENinit`||
|
||||
|`ENsetheadcurveindex`||
|
||||
|`ENsetlinktype`||
|
||||
|`ENaddnode`||
|
||||
|`ENaddlink`||
|
||||
|`ENdeletelink`||
|
||||
|`ENdeletenode`||
|
||||
|`ENgetdemandname`||
|
||||
|`ENsetdemandname`||
|
||||
|`ENgetcurvetype`|Get the type of a curve|
|
||||
|`ENgetdemandmodel`|Retrieves the type of demand model in use and its parameters|
|
||||
|`ENsetdemandmodel`|Sets the type of demand model to use and its parameters|
|
||||
|`ENsetflowunits`|Sets the flow units|
|
||||
|`ENaddcontrol`|Specify parameters to add a new simple control|
|
||||
|`ENsetdemandpattern`|Sets the index of the demand pattern assigned to a node for a category index|
|
||||
|`ENgetrule`|Gets the number of premises, true actions, and false actions and the priority of an existing rule-based control|
|
||||
|`ENsetrulepriority`|Sets the priority of the existing rule-based control|
|
||||
|`ENgetpremise`|Gets the components of a premise/condition in an existing rule-based control|
|
||||
|`ENsetpremise`|Sets the components of a premise/condition in an existing rule-based control|
|
||||
|`ENsetpremiseindex`|Sets the index of an object in a premise of an existing rule-based control|
|
||||
|`ENsetpremisestatus`|Sets the status in a premise of an existing rule-based control|
|
||||
|`ENsetpremisevalue`|Sets the value in a premise of an existing rule-based control|
|
||||
|`ENgettrueaction`|Gets the components of a true-action in an existing rule-based control|
|
||||
|`ENsettrueaction`|Sets the components of a true-action in an existing rule-based control|
|
||||
|`ENgetfalseaction`|Gets the components of a false-action in an existing rule-based control|
|
||||
|`ENsetfalseaction`|Sets the components of a false-action in an existing rule-based control|
|
||||
|`ENgetruleID`|Returns the ID of a rule|
|
||||
|`ENinit`|Initializes an EPANET session|
|
||||
|`ENsetheadcurveindex`|Sets the curve id for a specified pump index|
|
||||
|`ENsetlinktype`|Set the link type code for a specified link|
|
||||
|`ENaddnode`|Adds a new node|
|
||||
|`ENaddlink`|Adds a new link|
|
||||
|`ENdeletelink`|Deletes a link|
|
||||
|`ENdeletenode`|Deletes a node|
|
||||
| `ENsetnodeid` |Change the ID name for a node|
|
||||
| `ENsetlinkid` |Change the ID name for a link|
|
||||
|`ENgetdemandname`|Sets the node's demand name for a category|
|
||||
|`ENsetdemandname`|Sets the node's demand name for a category|
|
||||
|
||||
## API Extensions (additional definitions)
|
||||
### Link value types:
|
||||
@@ -174,10 +173,14 @@ Both network files are available [here](https://doi.org/10.23719/1375314).
|
||||
- `EN_HW`
|
||||
- `EN_DW`
|
||||
- `EN_CM`
|
||||
### Misc. options:
|
||||
### Option types:
|
||||
- `EN_HEADERROR`
|
||||
- `EN_FLOWCHANGE`
|
||||
- `EN_DEMANDDEFPAT`
|
||||
- `EN_HEADLOSSFORM`
|
||||
### Time statistic types:
|
||||
- `EN_MAXHEADERROR`
|
||||
- `EN_MAXFLOWCHANGE`
|
||||
- `EN_MASSBALANCE`
|
||||
### Curve types:
|
||||
- `EN_V_CURVE`
|
||||
@@ -185,7 +188,10 @@ Both network files are available [here](https://doi.org/10.23719/1375314).
|
||||
- `EN_E_CURVE`
|
||||
- `EN_H_CURVE`
|
||||
- `EN_G_CURVE`
|
||||
|
||||
### Demand model types:
|
||||
- `EN_DDA`
|
||||
- `EN_PDA`
|
||||
|
||||
## Authors contributing to this release:
|
||||
- List item
|
||||
|
||||
|
||||
@@ -175,11 +175,15 @@ Public Const EN_G_CURVE = 4 ' General\default curve
|
||||
|
||||
'These are the external functions that comprise the DLL
|
||||
|
||||
'System Functions
|
||||
Declare Function ENgetversion Lib "epanet2.dll" (value As Long) As Long
|
||||
Declare Function ENepanet Lib "epanet2.dll" (ByVal F1 As String, ByVal F2 As String, ByVal F3 As String, ByVal F4 As Any) As Long
|
||||
Declare Function ENinit Lib "epanet2.dll" (ByVal rptFile As String, ByVal binOutFile As String, ByVal UnitsType As Long, ByVal HeadlossFormula As Long) As Long
|
||||
Declare Function ENopen Lib "epanet2.dll" (ByVal F1 As String, ByVal F2 As String, ByVal F3 As String) As Long
|
||||
Declare Function ENsaveinpfile Lib "epanet2.dll" (ByVal F As String) As Long
|
||||
Declare Function ENclose Lib "epanet2.dll" () As Long
|
||||
|
||||
'Hydraulic Analysis Functions
|
||||
Declare Function ENsolveH Lib "epanet2.dll" () As Long
|
||||
Declare Function ENsaveH Lib "epanet2.dll" () As Long
|
||||
Declare Function ENopenH Lib "epanet2.dll" () As Long
|
||||
@@ -190,6 +194,7 @@ Public Const EN_G_CURVE = 4 ' General\default curve
|
||||
Declare Function ENsavehydfile Lib "epanet2.dll" (ByVal F As String) As Long
|
||||
Declare Function ENusehydfile Lib "epanet2.dll" (ByVal F As String) As Long
|
||||
|
||||
'Water Quality Analysis Functions
|
||||
Declare Function ENsolveQ Lib "epanet2.dll" () As Long
|
||||
Declare Function ENopenQ Lib "epanet2.dll" () As Long
|
||||
Declare Function ENinitQ Lib "epanet2.dll" (ByVal SaveFlag As Long) As Long
|
||||
@@ -198,80 +203,97 @@ Public Const EN_G_CURVE = 4 ' General\default curve
|
||||
Declare Function ENstepQ Lib "epanet2.dll" (Tleft As Long) As Long
|
||||
Declare Function ENcloseQ Lib "epanet2.dll" () As Long
|
||||
|
||||
'Reporting Functions
|
||||
Declare Function ENwriteline Lib "epanet2.dll" (ByVal S As String) As Long
|
||||
Declare Function ENreport Lib "epanet2.dll" () As Long
|
||||
Declare Function ENresetreport Lib "epanet2.dll" () As Long
|
||||
Declare Function ENsetreport Lib "epanet2.dll" (ByVal S As String) As Long
|
||||
|
||||
Declare Function ENgetcontrol Lib "epanet2.dll" (ByVal Cindex As Long, Ctype As Long, Lindex As Long, setting As Single, Nindex As Long, Level As Single) As Long
|
||||
Declare Function ENsetstatusreport Lib "epanet2.dll" (ByVal code As Long) As Long
|
||||
Declare Function ENgetcount Lib "epanet2.dll" (ByVal code As Long, value As Long) As Long
|
||||
Declare Function ENgeterror Lib "epanet2.dll" (ByVal ErrCode As Long, ByVal ErrMsg As String, ByVal N As Long) As Long
|
||||
|
||||
'Analysis Options Functions
|
||||
Declare Function ENgetoption Lib "epanet2.dll" (ByVal code As Long, value As Single) As Long
|
||||
Declare Function ENgettimeparam Lib "epanet2.dll" (ByVal code As Long, value As Long) As Long
|
||||
Declare Function ENsetoption Lib "epanet2.dll" (ByVal code As Long, ByVal value As Single) As Long
|
||||
Declare Function ENgetflowunits Lib "epanet2.dll" (code As Long) As Long
|
||||
Declare Function ENsetflowunits Lib "epanet2.dll" (ByVal code As Long) As Long
|
||||
Declare Function ENgettimeparam Lib "epanet2.dll" (ByVal code As Long, value As Long) As Long
|
||||
Declare Function ENsettimeparam Lib "epanet2.dll" (ByVal code As Long, ByVal value As Long) As Long
|
||||
Declare Function ENgetqualtype Lib "epanet2.dll" (QualCode As Long, TraceNode As Long) As Long
|
||||
Declare Function ENgetqualinfo Lib "epanet2.dll" (QualCode As Long, ByVal ChemName As String, ByVal ChemUnits As String, TraceNode As Long) As Long
|
||||
Declare Function ENsetqualtype Lib "epanet2.dll" (ByVal QualCode As Long, ByVal ChemName As String, ByVal ChemUnits As String, ByVal TraceNode As String) As Long
|
||||
|
||||
'Basic Node Functions
|
||||
Declare Function ENaddnode Lib "epanet2.dll" (ByVal id As String, ByVal nodeType As Long) As Long
|
||||
Declare Function ENdeletenode Lib "epanet2.dll" (ByVal linkIndex As Long) As Long
|
||||
Declare Function ENgetnodeindex Lib "epanet2.dll" (ByVal id As String, index As Long) As Long
|
||||
Declare Function ENgetnodeid Lib "epanet2.dll" (ByVal index As Long, ByVal id As String) As Long
|
||||
Declare Function ENsetnodeid Lib "epanet2.dll" (ByVal index As Long, ByVal newid As String) As Long
|
||||
Declare Function ENgetnodetype Lib "epanet2.dll" (ByVal index As Long, code As Long) As Long
|
||||
Declare Function ENgetnodevalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, value As Single) As Long
|
||||
Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, ByVal value As Single) As Long
|
||||
Declare Function ENgetcoord Lib "epanet2.dll" (ByVal index As Long, X As Single, Y As Single) As Long
|
||||
Declare Function ENsetcoord Lib "epanet2.dll" (ByVal index As Long, ByVal X As Single, ByVal Y As Single) As Long
|
||||
|
||||
'Nodal Demand Functions
|
||||
Declare Function ENgetdemandmodel Lib "epanet2.dll" (mtype As Long, pmin As Single, preq As Single, pexp As Single) As Long
|
||||
Declare Function ENsetdemandmodel Lib "epanet2.dll" (ByVal mtype As Long, ByVal pmin As Single, ByVal preq As Single, ByVal pexp As Single) As Long
|
||||
Declare Function ENgetnumdemands Lib "epanet2.dll" (ByVal index As Long, numDemands As Long) As Long
|
||||
Declare Function ENgetbasedemand Lib "epanet2.dll" (ByVal index As Long, ByVal DemandIndex As Long, value As Single) As Long
|
||||
Declare Function ENsetbasedemand Lib "epanet2.dll" (ByVal Index As Long, ByVal DemandIndex As Long, ByVal BaseDemand As Single) As Long
|
||||
Declare Function ENgetdemandpattern Lib "epanet2.dll" (ByVal index As Long, ByVal DemandIndex As Long, PatIndex As Long) As Long
|
||||
Declare Function ENsetdemandpattern Lib "epanet2.dll" (ByVal Index As Long, ByVal DemandIndex As Long, ByVal PatIndex As Long) As Long
|
||||
Declare Function ENgetdemandname Lib "epanet2.dll" (ByVal index As Long, ByVal DemandIndex As Long, ByVal demandName As String) As Long
|
||||
Declare Function ENsetdemandname Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal DemandIndex As Long, ByVal demandName As String) As Long
|
||||
|
||||
'Basic Link Functions
|
||||
Declare Function ENaddlink Lib "epanet2.dll" (ByVal id As String, ByVal linkType As Long, ByVal fromNode As String, ByVal toNode As String) As Long
|
||||
Declare Function ENdeletelink Lib "epanet2.dll" (ByVal nodeIndex As Long) As Long
|
||||
Declare Function ENgetlinkindex Lib "epanet2.dll" (ByVal id As String, index As Long) As Long
|
||||
Declare Function ENgetlinkid Lib "epanet2.dll" (ByVal index As Long, ByVal id As String) As Long
|
||||
Declare Function ENsetlinkid Lib "epanet2.dll" (ByVal index As Long, ByVal newid As String) As Long
|
||||
Declare Function ENgetlinktype Lib "epanet2.dll" (ByVal index As Long, code As Long) As Long
|
||||
Declare Function ENsetlinktype Lib "epanet2.dll" (index As Long, ByVal code As Long) As Long
|
||||
Declare Function ENgetlinknodes Lib "epanet2.dll" (ByVal index As Long, Node1 As Long, Node2 As Long) As Long
|
||||
Declare Function ENsetlinknodes Lib "epanet2.dll" (ByVal index As Long, ByVal node1 As Long, ByVal node2 As Long) As Long
|
||||
Declare Function ENgetlinkvalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, value As Single) As Long
|
||||
Declare Function ENsetlinkvalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, ByVal value As Single) As Long
|
||||
|
||||
'Pump Functions
|
||||
Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal pumpIndex As Long, curveIndex As Long) As Long
|
||||
Declare Function ENsetheadcurveindex Lib "epanet2.dll" (ByVal pumpIndex As Long, ByVal curveIndex As Long) As Long
|
||||
Declare Function ENgetpumptype Lib "epanet2.dll" (ByVal index As Long, PumpType As Long) As Long
|
||||
|
||||
'Time Pattern Functions
|
||||
Declare Function ENaddpattern Lib "epanet2.dll" (ByVal id As String) As Long
|
||||
Declare Function ENgetpatternindex Lib "epanet2.dll" (ByVal id As String, index As Long) As Long
|
||||
Declare Function ENgetpatternid Lib "epanet2.dll" (ByVal index As Long, ByVal id As String) As Long
|
||||
Declare Function ENgetpatternlen Lib "epanet2.dll" (ByVal index As Long, L As Long) As Long
|
||||
Declare Function ENgetpatternvalue Lib "epanet2.dll" (ByVal index As Long, ByVal Period As Long, value As Single) As Long
|
||||
Declare Function ENgetaveragepatternvalue Lib "epanet2.dll" (ByVal index As Long, value As Single) As Long
|
||||
Declare Function ENgetqualtype Lib "epanet2.dll" (QualCode As Long, TraceNode As Long) As Long
|
||||
Declare Function ENgeterror Lib "epanet2.dll" (ByVal ErrCode As Long, ByVal ErrMsg As String, ByVal N As Long) As Long
|
||||
Declare Function ENgetstatistic Lib "epanet2.dll" (ByVal code As Long, value As Single) As Long
|
||||
|
||||
Declare Function ENgetnodeindex Lib "epanet2.dll" (ByVal id As String, index As Long) As Long
|
||||
Declare Function ENgetnodeid Lib "epanet2.dll" (ByVal index As Long, ByVal id As String) As Long
|
||||
Declare Function ENgetnodetype Lib "epanet2.dll" (ByVal index As Long, code As Long) As Long
|
||||
Declare Function ENgetnodevalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, value As Single) As Long
|
||||
Declare Function ENgetcoord Lib "epanet2.dll" (ByVal index As Long, X As Single, Y As Single) As Long
|
||||
Declare Function ENsetcoord Lib "epanet2.dll" (ByVal index As Long, ByVal X As Single, ByVal Y As Single) As Long
|
||||
|
||||
Declare Function ENgetnumdemands Lib "epanet2.dll" (ByVal index As Long, numDemands As Long) As Long
|
||||
Declare Function ENgetbasedemand Lib "epanet2.dll" (ByVal index As Long, ByVal DemandIndex As Long, value As Single) As Long
|
||||
Declare Function ENgetdemandpattern Lib "epanet2.dll" (ByVal index As Long, ByVal DemandIndex As Long, PatIndex As Long) As Long
|
||||
|
||||
Declare Function ENgetdemandname Lib "epanet2.dll" (ByVal index As Long, ByVal DemandIndex As Long, ByVal demandName As String) As Long
|
||||
Declare Function ENsetdemandname Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal DemandIndex As Long, ByVal demandName As String) As Long
|
||||
|
||||
Declare Function ENgetlinkindex Lib "epanet2.dll" (ByVal id As String, index As Long) As Long
|
||||
Declare Function ENgetlinkid Lib "epanet2.dll" (ByVal index As Long, ByVal id As String) As Long
|
||||
Declare Function ENgetlinktype Lib "epanet2.dll" (ByVal index As Long, code As Long) As Long
|
||||
Declare Function ENgetlinknodes Lib "epanet2.dll" (ByVal index As Long, Node1 As Long, Node2 As Long) As Long
|
||||
Declare Function ENgetlinkvalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, value As Single) As Long
|
||||
|
||||
Declare Function ENgetcurve Lib "epanet2.dll" (ByVal curveIndex As Long, ByVal CurveID As String, nValues As Long, xValues As Any, yValues As Any) As Long
|
||||
Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal pumpIndex As Long, curveIndex As Long) As Long
|
||||
Declare Function ENgetpumptype Lib "epanet2.dll" (ByVal index As Long, PumpType As Long) As Long
|
||||
Declare Function ENgetcurvetype Lib "epanet2.dll" (ByVal curveIndex As Long, CurveType As Long) As Long
|
||||
|
||||
Declare Function ENgetversion Lib "epanet2.dll" (value As Long) As Long
|
||||
|
||||
Declare Function ENgetdemandmodel Lib "epanet2.dll" (mtype As Long, pmin As Single, preq As Single, pexp As Single) As Long
|
||||
Declare Function ENsetdemandmodel Lib "epanet2.dll" (ByVal mtype As Long, ByVal pmin As Single, ByVal preq As Single, ByVal pexp As Single) As Long
|
||||
|
||||
Declare Function ENsetflowunits Lib "epanet2.dll" (ByVal code As Long) As Long
|
||||
Declare Function ENaddcontrol Lib "epanet2.dll" (Cindex As Long, ByVal Ctype As Long, ByVal Lindex As Long, ByVal setting As Single, ByVal Nindex As Long, ByVal Level As Single) As Long
|
||||
Declare Function ENsetcontrol Lib "epanet2.dll" (ByVal Cindex As Long, ByVal Ctype As Long, ByVal Lindex As Long, ByVal setting As Single, ByVal Nindex As Long, ByVal Level As Single) As Long
|
||||
Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, ByVal value As Single) As Long
|
||||
Declare Function ENsetlinkvalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, ByVal value As Single) As Long
|
||||
Declare Function ENaddpattern Lib "epanet2.dll" (ByVal id As String) As Long
|
||||
Declare Function ENsetpattern Lib "epanet2.dll" (ByVal index As Long, F As Any, ByVal N As Long) As Long
|
||||
Declare Function ENsetpatternvalue Lib "epanet2.dll" (ByVal index As Long, ByVal Period As Long, ByVal value As Single) As Long
|
||||
Declare Function ENsettimeparam Lib "epanet2.dll" (ByVal code As Long, ByVal value As Long) As Long
|
||||
Declare Function ENsetoption Lib "epanet2.dll" (ByVal code As Long, ByVal value As Single) As Long
|
||||
Declare Function ENsetstatusreport Lib "epanet2.dll" (ByVal code As Long) As Long
|
||||
Declare Function ENsetqualtype Lib "epanet2.dll" (ByVal QualCode As Long, ByVal ChemName As String, ByVal ChemUnits As String, ByVal TraceNode As String) As Long
|
||||
Declare Function ENgetqualinfo Lib "epanet2.dll" (QualCode As Long, ByVal ChemName As String, ByVal ChemUnits As String, TraceNode As Long) As Long
|
||||
Declare Function ENsetbasedemand Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal DemandIndex As Long, ByVal BaseDemand As Single) As Long
|
||||
Declare Function ENsetdemandpattern Lib "epanet2.dll" (ByVal index As Long, ByVal DemandIndex As Long, ByVal PatIndex As Long) As Long
|
||||
Declare Function ENgetaveragepatternvalue Lib "epanet2.dll" (ByVal index As Long, value As Single) As Long
|
||||
Declare Function ENsetpattern Lib "epanet2.dll" (ByVal index As Long, F As Any, ByVal N As Long) As Long
|
||||
|
||||
'Data Curve Functions
|
||||
Declare Function ENaddcurve Lib "epanet2.dll" (ByVal id As String) As Long
|
||||
Declare Function ENgetcurveindex Lib "epanet2.dll" (ByVal id As String, index As Long) As Long
|
||||
Declare Function ENgetcurveid Lib "epanet2.dll" (ByVal index As Long, ByVal id As String) As Long
|
||||
Declare Function ENgetcurvelen Lib "epanet2.dll" (ByVal index As Long, L As Long) As Long
|
||||
Declare Function ENgetcurvetype Lib "epanet2.dll" (ByVal curveIndex As Long, CurveType As Long) As Long
|
||||
Declare Function ENgetcurvevalue Lib "epanet2.dll" (ByVal index As Long, ByVal Ptn As Long, X As Single, Y As Single) As Long
|
||||
Declare Function ENsetcurvevalue Lib "epanet2.dll" (ByVal index As Long, ByVal Ptn As Long, ByVal X As Single, ByVal Y As Single) As Long
|
||||
Declare Function ENgetcurve Lib "epanet2.dll" (ByVal curveIndex As Long, ByVal CurveID As String, nValues As Long, xValues As Any, yValues As Any) As Long
|
||||
Declare Function ENsetcurve Lib "epanet2.dll" (ByVal index As Long, X As Any, Y As Any, ByVal N As Long) As Long
|
||||
Declare Function ENaddcurve Lib "epanet2.dll" (ByVal id As String) As Long
|
||||
|
||||
'Simple Control Functions
|
||||
Declare Function ENaddcontrol Lib "epanet2.dll" (Cindex As Long, ByVal Ctype As Long, ByVal Lindex As Long, ByVal setting As Single, ByVal Nindex As Long, ByVal Level As Single) As Long
|
||||
Declare Function ENdeletecontrol Lib "epanet2.dll" (ByVal Cindex as Long) As Long
|
||||
Declare Function ENgetcontrol Lib "epanet2.dll" (ByVal Cindex As Long, Ctype As Long, Lindex As Long, setting As Single, Nindex As Long, Level As Single) As Long
|
||||
Declare Function ENsetcontrol Lib "epanet2.dll" (ByVal Cindex As Long, ByVal Ctype As Long, ByVal Lindex As Long, ByVal setting As Single, ByVal Nindex As Long, ByVal Level As Single) As Long
|
||||
|
||||
'Rue-Based Control Functions
|
||||
Declare Function ENgetrule Lib "epanet2.dll" (ByVal index As Long, nPremises As Long, nTrueActions As Long, nFalseActions As Long, priority As Single) As Long
|
||||
Declare Function ENgetruleID Lib "epanet2.dll" (ByVal indexRule As Long, ByVal id As String) As Long
|
||||
Declare Function ENsetrulepriority Lib "epanet2.dll" (ByVal index As Long, ByVal priority As Single) As Long
|
||||
Declare Function ENgetpremise Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexPremise As Long, logop As Long, object As Long, indexObj As Long, variable As Long, relop As Long, status As Long, value As Single) As Long
|
||||
Declare Function ENsetpremise Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexPremise As Long, ByVal logop As Long, ByVal object As Long, ByVal indexObj As Long, ByVal variable As Long, ByVal relop As Long, ByVal status As Long, ByVal value As Single) As Long
|
||||
@@ -282,12 +304,3 @@ Public Const EN_G_CURVE = 4 ' General\default curve
|
||||
Declare Function ENsettrueaction Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexAction As Long, ByVal indexLink As Long, ByVal status As Long, ByVal setting As Single) As Long
|
||||
Declare Function ENgetfalseaction Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexAction As Long, indexLink As Long, status As Long, setting As Single) As Long
|
||||
Declare Function ENsetfalseaction Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexAction As Long, ByVal indexLink As Long, ByVal status As Long, ByVal setting As Single) As Long
|
||||
Declare Function ENgetruleID Lib "epanet2.dll" (ByVal indexRule As Long, ByVal id As String) As Long
|
||||
|
||||
Declare Function ENinit Lib "epanet2.dll" (ByVal rptFile As String, ByVal binOutFile As String, ByVal UnitsType As Long, ByVal HeadlossFormula As Long) As Long
|
||||
Declare Function ENsetheadcurveindex Lib "epanet2.dll" (ByVal pumpIndex As Long, ByVal curveIndex As Long) As Long
|
||||
Declare Function ENsetlinktype Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long) As Long
|
||||
Declare Function ENaddnode Lib "epanet2.dll" (ByVal id As String, ByVal nodeType As Long) As Long
|
||||
Declare Function ENaddlink Lib "epanet2.dll" (ByVal id As String, ByVal linkType As Long, ByVal fromNode As String, ByVal toNode As String) As Long
|
||||
Declare Function ENdeletelink Lib "epanet2.dll" (ByVal nodeIndex As Long) As Long
|
||||
Declare Function ENdeletenode Lib "epanet2.dll" (ByVal linkIndex As Long) As Long
|
||||
|
||||
@@ -67,6 +67,9 @@
|
||||
|
||||
// --- Define the EPANET toolkit constants
|
||||
|
||||
#define EN_MAXID 31 /**< Max. # characters in ID name */
|
||||
#define EN_MAXMSG 255 /**< Max. # characters in message text */
|
||||
|
||||
/// Node property codes
|
||||
typedef enum {
|
||||
EN_ELEVATION = 0, /**< Node Elevation */
|
||||
@@ -740,12 +743,12 @@ extern "C" {
|
||||
|
||||
/**
|
||||
@brief Set the link type code for a specified link
|
||||
@param id The id of a link
|
||||
@param type The type code of the link.
|
||||
@param[in,out] index The index of a link before [in] and after [out] the type change.
|
||||
@param code The new type code of the link.
|
||||
@return Error code
|
||||
@see EN_LinkType
|
||||
*/
|
||||
int DLLEXPORT ENsetlinktype(char *id, EN_LinkType type);
|
||||
int DLLEXPORT ENsetlinktype(int *index, EN_LinkType code);
|
||||
|
||||
/**
|
||||
@brief Get the indexes of a link's start- and end-nodes.
|
||||
@@ -830,6 +833,13 @@ extern "C" {
|
||||
@return Error code.
|
||||
*/
|
||||
int DLLEXPORT ENaddcontrol(int *cindex, int ctype, int lindex, EN_API_FLOAT_TYPE setting, int nindex, EN_API_FLOAT_TYPE level);
|
||||
|
||||
/**
|
||||
@brief Delete an existing simple control
|
||||
@param cindex The index of the control. First control is index 1.
|
||||
@return Error code.
|
||||
*/
|
||||
int DLLEXPORT ENdeletecontrol(int cindex);
|
||||
|
||||
/**
|
||||
@brief Specify parameters to define a simple control
|
||||
@@ -842,6 +852,14 @@ extern "C" {
|
||||
@return Error code.
|
||||
*/
|
||||
int DLLEXPORT ENsetcontrol(int cindex, int ctype, int lindex, EN_API_FLOAT_TYPE setting, int nindex, EN_API_FLOAT_TYPE level);
|
||||
|
||||
/**
|
||||
@brief Change the ID name for a node.
|
||||
@param index The index of a node. First node is index 1.
|
||||
@param newid A string containing the node's new ID name.
|
||||
@return Error code.
|
||||
*/
|
||||
int DLLEXPORT ENsetnodeid(int index, char *newid);
|
||||
|
||||
/**
|
||||
@brief Set a property value for a node.
|
||||
@@ -852,6 +870,24 @@ extern "C" {
|
||||
@see EN_NodeProperty
|
||||
*/
|
||||
int DLLEXPORT ENsetnodevalue(int index, int code, EN_API_FLOAT_TYPE v);
|
||||
|
||||
/**
|
||||
@brief Change the ID name for a link.
|
||||
@param index The index of a link. First link is index 1.
|
||||
@param newid A string containing the link's new ID name.
|
||||
@return Error code.
|
||||
*/
|
||||
int DLLEXPORT ENsetlinkid(int index, char *newid);
|
||||
|
||||
/**
|
||||
@brief Set the indexes of a link's start- and end-nodes.
|
||||
@param index The index of a link (first link is index 1)
|
||||
@param node1 The index of the link's start node (first node is index 1).
|
||||
@param node2 The index of the link's end node (first node is index 1).
|
||||
@return Error code
|
||||
@see ENsetnodeid, ENsetlinkid
|
||||
*/
|
||||
int DLLEXPORT ENsetlinknodes(int index, int node1, int node2);
|
||||
|
||||
/**
|
||||
@brief Set a property value for a link.
|
||||
@@ -1045,7 +1081,6 @@ extern "C" {
|
||||
@see ENgetcurveindex ENsetcurve
|
||||
*/
|
||||
int DLLEXPORT ENaddcurve(char *id);
|
||||
|
||||
|
||||
/**
|
||||
@brief Gets the number of premises, true actions, and false actions and the priority of an existing rule-based control.
|
||||
@@ -1284,7 +1319,6 @@ extern "C" {
|
||||
int DLLEXPORT EN_getlinkindex(EN_ProjectHandle ph, char *id, int *index);
|
||||
int DLLEXPORT EN_getlinkid(EN_ProjectHandle ph, int index, char *id);
|
||||
int DLLEXPORT EN_getlinktype(EN_ProjectHandle ph, int index, EN_LinkType *code);
|
||||
int DLLEXPORT EN_setlinktype(EN_ProjectHandle ph, char *id, EN_LinkType type);
|
||||
int DLLEXPORT EN_getlinknodes(EN_ProjectHandle ph, int index, int *node1, int *node2);
|
||||
int DLLEXPORT EN_getlinkvalue(EN_ProjectHandle ph, int index, EN_LinkProperty code, EN_API_FLOAT_TYPE *value);
|
||||
int DLLEXPORT EN_getcurve(EN_ProjectHandle ph, int curveIndex, char* id, int *nValues, EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues);
|
||||
@@ -1297,7 +1331,11 @@ extern "C" {
|
||||
|
||||
int DLLEXPORT EN_addcontrol(EN_ProjectHandle ph, int *cindex, int ctype, int lindex, EN_API_FLOAT_TYPE setting, int nindex, EN_API_FLOAT_TYPE level);
|
||||
int DLLEXPORT EN_setcontrol(EN_ProjectHandle ph, int cindex, int ctype, int lindex, EN_API_FLOAT_TYPE setting, int nindex, EN_API_FLOAT_TYPE level);
|
||||
int DLLEXPORT EN_setnodeid(EN_ProjectHandle ph, int index, char *newid);
|
||||
int DLLEXPORT EN_setnodevalue(EN_ProjectHandle ph, int index, int code, EN_API_FLOAT_TYPE v);
|
||||
int DLLEXPORT EN_setlinkid(EN_ProjectHandle ph, int index, char *newid);
|
||||
int DLLEXPORT EN_setlinknodes(EN_ProjectHandle ph, int index, int node1, int node2);
|
||||
int DLLEXPORT EN_setlinktype(EN_ProjectHandle ph, int *index, EN_LinkType code);
|
||||
int DLLEXPORT EN_setlinkvalue(EN_ProjectHandle ph, int index, int code, EN_API_FLOAT_TYPE v);
|
||||
int DLLEXPORT EN_addpattern(EN_ProjectHandle ph, char *id);
|
||||
int DLLEXPORT EN_setpattern(EN_ProjectHandle ph, int index, EN_API_FLOAT_TYPE *f, int len);
|
||||
@@ -1340,6 +1378,7 @@ extern "C" {
|
||||
int DLLEXPORT EN_addlink(EN_ProjectHandle ph, char *id, EN_LinkType linkType, char *fromNode, char *toNode);
|
||||
int DLLEXPORT EN_deletenode(EN_ProjectHandle ph, int nodeIndex);
|
||||
int DLLEXPORT EN_deletelink(EN_ProjectHandle ph, int linkIndex);
|
||||
int DLLEXPORT EN_deletecontrol(EN_ProjectHandle ph, int controlIndex);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ Public Const EN_MIXFRACTION = 22
|
||||
Public Const EN_TANK_KBULK = 23
|
||||
|
||||
Public Const EN_TANKVOLUME = 24 'ES
|
||||
Public Const EN_MAXVOLUME = 25
|
||||
|
||||
Public Const EN_DIAMETER = 0 ' Link parameters
|
||||
Public Const EN_LENGTH = 1
|
||||
@@ -60,6 +61,9 @@ Public Const EN_EFFICIENCY = 16
|
||||
Public Const EN_HEADCURVE = 17
|
||||
Public Const EN_EFFICIENCYCURVE = 18
|
||||
Public Const EN_PRICEPATTERN = 19
|
||||
Public Const EN_STATE = 20
|
||||
Public Const EN_CONST_POWER = 21
|
||||
Public Const EN_SPEED = 22
|
||||
|
||||
Public Const EN_DURATION = 0 ' Time parameters
|
||||
Public Const EN_HYDSTEP = 1
|
||||
@@ -115,6 +119,10 @@ Public Const EN_MASS = 1
|
||||
Public Const EN_SETPOINT = 2
|
||||
Public Const EN_FLOWPACED = 3
|
||||
|
||||
Public Const EN_HW = 0 ' Head loss formula
|
||||
Public Const EN_DW = 1
|
||||
Public Const EN_CM = 2
|
||||
|
||||
Public Const EN_CFS = 0 ' Flow units types
|
||||
Public Const EN_GPM = 1
|
||||
Public Const EN_MGD = 2
|
||||
@@ -126,6 +134,9 @@ Public Const EN_MLD = 7
|
||||
Public Const EN_CMH = 8
|
||||
Public Const EN_CMD = 9
|
||||
|
||||
Public Const EN_DDA = 0 ' Demand driven analysis
|
||||
Public Const EN_PDA = 1 ' Pressure driven analysis
|
||||
|
||||
Public Const EN_TRIALS = 0 ' Misc. options
|
||||
Public Const EN_ACCURACY = 1
|
||||
Public Const EN_TOLERANCE = 2
|
||||
@@ -159,13 +170,23 @@ Public Const EN_CONST_HP = 0 ' constant horsepower
|
||||
Public Const EN_POWER_FUNC = 1 ' power function
|
||||
Public Const EN_CUSTOM = 2 ' user-defined custom curve
|
||||
|
||||
Public Const EN_V_CURVE = 0 ' volume curve
|
||||
Public Const EN_P_CURVE = 1 ' pump curve
|
||||
Public Const EN_E_CURVE = 2 ' efficiency curve
|
||||
Public Const EN_H_CURVE = 3 ' head loss curve
|
||||
Public Const EN_G_CURVE = 4 ' General\default curve
|
||||
|
||||
'These are the external functions that comprise the DLL
|
||||
|
||||
'System Functions
|
||||
Declare Function ENgetversion Lib "epanet2.dll" (ByRef Value As Int32) As Int32
|
||||
Declare Function ENepanet Lib "epanet2.dll" (ByVal F1 As String, ByVal F2 As String, ByVal F3 As String, ByVal F4 As String) As Int32
|
||||
Declare Function ENinit Lib "epanet2.dll" (ByVal rptFile As String, ByVal binOutFile As String, ByVal UnitsType As Int32, ByVal HeadlossFormula As Int32) As Int32
|
||||
Declare Function ENopen Lib "epanet2.dll" (ByVal F1 As String, ByVal F2 As String, ByVal F3 As String) As Int32
|
||||
Declare Function ENsaveinpfile Lib "epanet2.dll" (ByVal F As String) As Int32
|
||||
Declare Function ENclose Lib "epanet2.dll" () As Int32
|
||||
|
||||
'Hydraulic Analysis Functions
|
||||
Declare Function ENsolveH Lib "epanet2.dll" () As Int32
|
||||
Declare Function ENsaveH Lib "epanet2.dll" () As Int32
|
||||
Declare Function ENopenH Lib "epanet2.dll" () As Int32
|
||||
@@ -176,6 +197,7 @@ Public Const EN_CUSTOM = 2 ' user-defined custom curve
|
||||
Declare Function ENsavehydfile Lib "epanet2.dll" (ByVal F As String) As Int32
|
||||
Declare Function ENusehydfile Lib "epanet2.dll" (ByVal F As String) As Int32
|
||||
|
||||
'Water Quality Analysis Functions
|
||||
Declare Function ENsolveQ Lib "epanet2.dll" () As Int32
|
||||
Declare Function ENopenQ Lib "epanet2.dll" () As Int32
|
||||
Declare Function ENinitQ Lib "epanet2.dll" (ByVal SaveFlag As Int32) As Int32
|
||||
@@ -184,71 +206,98 @@ Public Const EN_CUSTOM = 2 ' user-defined custom curve
|
||||
Declare Function ENstepQ Lib "epanet2.dll" (ByRef Tleft As Int32) As Int32
|
||||
Declare Function ENcloseQ Lib "epanet2.dll" () As Int32
|
||||
|
||||
'Reporting Functions
|
||||
Declare Function ENwriteline Lib "epanet2.dll" (ByVal S As String) As Int32
|
||||
Declare Function ENreport Lib "epanet2.dll" () As Int32
|
||||
Declare Function ENresetreport Lib "epanet2.dll" () As Int32
|
||||
Declare Function ENsetreport Lib "epanet2.dll" (ByVal S As String) As Int32
|
||||
|
||||
Declare Function ENgetcontrol Lib "epanet2.dll" (ByVal Cindex As Int32, ByRef CtlType As Int32, ByRef Lindex As Int32, ByRef Setting As Single, ByRef Nindex As Int32, ByRef Level As Single) As Int32
|
||||
Declare Function ENsetstatusreport Lib "epanet2.dll" (ByVal Code As Int32) As Int32
|
||||
Declare Function ENgetcount Lib "epanet2.dll" (ByVal Code As Int32, ByRef Value As Int32) As Int32
|
||||
Declare Function ENgetoption Lib "epanet2.dll" (ByVal Code As Int32, ByRef Value As Single) As Int32
|
||||
Declare Function ENgettimeparam Lib "epanet2.dll" (ByVal Code As Int32, ByRef Value As Int32) As Int32
|
||||
Declare Function ENgetflowunits Lib "epanet2.dll" (ByRef Code As Int32) As Int32
|
||||
Declare Function ENgetpatternindex Lib "epanet2.dll" (ByVal ID As String, ByRef Index As Int32) As Int32
|
||||
Declare Function ENgetpatternid Lib "epanet2.dll" (ByVal Index As Int32, ByVal ID As StringBuilder) As Int32
|
||||
Declare Function ENgetpatternlen Lib "epanet2.dll" (ByVal Index As Int32, ByRef L As Int32) As Int32
|
||||
Declare Function ENgetpatternvalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Period As Int32, ByRef Value As Single) As Int32
|
||||
Declare Function ENgetqualtype Lib "epanet2.dll" (ByRef QualCode As Int32, ByRef TraceNode As Int32) As Int32
|
||||
Declare Function ENgeterror Lib "epanet2.dll" (ByVal ErrCode As Int32, ByVal ErrMsg As StringBuilder, ByVal N As Int32)
|
||||
Declare Function ENgeterror Lib "epanet2.dll" (ByVal ErrCode As Int32, ByVal ErrMsg As StringBuilder, ByVal N As Int32) As Int32
|
||||
Declare Function ENgetstatistic Lib "epanet2.dll" (ByVal code As Int32, ByRef value As Single) As Int32
|
||||
|
||||
'Analysis Options Functions
|
||||
Declare Function ENgetoption Lib "epanet2.dll" (ByVal Code As Int32, ByRef Value As Single) As Int32
|
||||
Declare Function ENsetoption Lib "epanet2.dll" (ByVal Code As Int32, ByVal Value As Single) As Int32
|
||||
Declare Function ENgetflowunits Lib "epanet2.dll" (ByRef Code As Int32) As Int32
|
||||
Declare Function ENsetflowunits Lib "epanet2.dll" (ByVal code As Int32) As Int32
|
||||
Declare Function ENgettimeparam Lib "epanet2.dll" (ByVal Code As Int32, ByRef Value As Int32) As Int32
|
||||
Declare Function ENsettimeparam Lib "epanet2.dll" (ByVal Code As Int32, ByVal Value As Int32) As Int32
|
||||
Declare Function ENgetqualtype Lib "epanet2.dll" (ByRef QualCode As Int32, ByRef TraceNode As Int32) As Int32
|
||||
Declare Function ENgetqualinfo Lib "epanet2.dll" (ByRef QualCode As Int32, ByVal ChemName As String, ByVal ChemUnits As String, ByRef TraceNode As Int32) As Int32
|
||||
Declare Function ENsetqualtype Lib "epanet2.dll" (ByVal QualCode As Int32, ByVal ChemName As String, ByVal ChemUnits As String, ByVal TraceNode As String) As Int32
|
||||
|
||||
'Basic Node Functions
|
||||
Declare Function ENaddnode Lib "epanet2.dll" (ByVal id As String, ByVal nodeType As Int32) As Int32
|
||||
Declare Function ENdeletenode Lib "epanet2.dll" (ByVal linkIndex As Long) As Long
|
||||
Declare Function ENgetnodeindex Lib "epanet2.dll" (ByVal ID As String, ByRef Index As Int32) As Int32
|
||||
Declare Function ENgetnodeid Lib "epanet2.dll" (ByVal Index As Int32, ByVal ID As StringBuilder) As Int32
|
||||
Declare Function ENsetnodeid Lib "epanet2.dll" (ByVal index As Int32, ByVal newid As String) As Int32
|
||||
Declare Function ENgetnodetype Lib "epanet2.dll" (ByVal Index As Int32, ByRef Code As Int32) As Int32
|
||||
Declare Function ENgetnodevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByRef Value As Single) As Int32
|
||||
Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByVal Value As Single) As Int32
|
||||
Declare Function ENgetcoord Lib "epanet2.dll" (ByVal Index As Int32, ByRef X As Single, ByRef Y As Single) As Int32
|
||||
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" (ByRef mtype As Int32, ByRef pmin As Single, ByRef preq As Single, ByRef pexp As Single) As Int32
|
||||
Declare Function ENsetdemandmodel Lib "epanet2.dll" (ByVal mtype As Int32, ByVal pmin As Single, ByVal preq As Single, ByVal pexp As Single) As Int32
|
||||
Declare Function ENgetnumdemands Lib "epanet2.dll" (ByVal Index As Int32, ByRef numDemands As Int32) As Int32 'ES
|
||||
Declare Function ENgetbasedemand Lib "epanet2.dll" (ByVal Index As Int32, ByVal DemandIndex As Int32, ByRef BaseDemand As Single) As Int32 'ES
|
||||
Declare Function ENsetbasedemand Lib "epanet2.dll" (ByVal Index As Int32, ByVal DemandIndex As Int32, ByVal BaseDemand As Single) As Int32 'ES
|
||||
Declare Function ENgetdemandpattern Lib "epanet2.dll" (ByVal Index As Int32, ByVal DemandIndex As Int32, ByRef PatIndex As Int32) As Int32 'ES
|
||||
Declare Function ENsetdemandpattern Lib "epanet2.dll" (ByVal Index As Int32, ByVal DemandIndex As Int32, ByVal PatIndex As Int32) As Int32 'ES
|
||||
Declare Function ENsetdemandpattern Lib "epanet2.dll" (ByVal index As Int32, ByVal DemandIndex As Int32, ByVal PatIndex As Int32) As Int32
|
||||
Declare Function ENgetdemandname Lib "epanet2.dll" (ByVal index As Int32, ByVal DemandIndex As Int32, ByVal demandName As String) As Int32
|
||||
Declare Function ENsetdemandname Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal DemandIndex As Int32, ByVal demandName As String) As Int32
|
||||
|
||||
'Basic Link Functions
|
||||
Declare Function ENaddlink Lib "epanet2.dll" (ByVal id As String, ByVal linkType As Int32, ByVal fromNode As String, ByVal toNode As String) As Int32
|
||||
Declare Function ENdeletelink Lib "epanet2.dll" (ByVal nodeIndex As Long) As Long
|
||||
Declare Function ENgetlinkindex Lib "epanet2.dll" (ByVal ID As String, ByRef Index As Int32) As Int32
|
||||
Declare Function ENgetlinkid Lib "epanet2.dll" (ByVal Index As Int32, ByVal ID As StringBuilder) As Int32
|
||||
Declare Function ENsetlinkid Lib "epanet2.dll" (ByVal index As Int32, ByVal newid As String) As Int32
|
||||
Declare Function ENgetlinktype Lib "epanet2.dll" (ByVal Index As Int32, ByRef Code As Int32) As Int32
|
||||
Declare Function ENsetlinktype Lib "epanet2.dll" (ByRef index As Int32, ByVal code As Int32) As Int32
|
||||
Declare Function ENgetlinknodes Lib "epanet2.dll" (ByVal Index As Int32, ByRef Node1 As Int32, ByRef Node2 As Int32) As Int32
|
||||
Declare Function ENsetlinknodes Lib "epanet2.dll" (ByVal index As Int32, ByVal node1 As Int32, ByVal node2 As Int32) As Int32
|
||||
Declare Function ENgetlinkvalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByRef Value As Single) As Int32
|
||||
|
||||
Declare Function ENgetcurve Lib "epanet2.dll" (ByVal CurveIndex As Int32, ByRef nValues As Int32, ByRef xValues As Single, ByRef yValues As Single) As Int32 'ES
|
||||
Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal Index As Int32, ByVal CurveIndex As int32) As Int32 'ES
|
||||
Declare Function ENgetpumptype Lib "epanet2.dll" (ByVal Index As Int32, ByRef PumpType As Int32) As Int32 'ES
|
||||
|
||||
Declare Function ENgetversion Lib "epanet2.dll" (ByRef Value As Int32) As Int32
|
||||
|
||||
Declare Function ENsetcontrol Lib "epanet2.dll" (ByVal Cindex As Int32, ByVal CtlType As Int32, ByVal Lindex As Int32, ByVal Setting As Single, ByVal Nindex As Int32, ByVal Level As Single) As Int32
|
||||
Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByVal Value As Single) As Int32
|
||||
Declare Function ENsetlinkvalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByVal Value As Single) As Int32
|
||||
Declare Function ENsetpattern Lib "epanet2.dll" (ByVal Index as Int32, ByRef F as Single, ByVal N as Int32) as Int32
|
||||
Declare Function ENsetpatternvalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Period As Int32, ByVal Value As Single) As Int32
|
||||
Declare Function ENsettimeparam Lib "epanet2.dll" (ByVal Code As Int32, ByVal Value As Int32) As Int32
|
||||
Declare Function ENsetoption Lib "epanet2.dll" (ByVal Code As Int32, ByVal Value As Single) As Int32
|
||||
Declare Function ENsetstatusreport Lib "epanet2.dll" (ByVal Code As Int32) As Int32
|
||||
Declare Function ENsetqualtype Lib "epanet2.dll" (ByVal QualCode As Int32, ByVal ChemName As String, ByVal ChemUnits As String, ByVal TraceNode As String) As Int32
|
||||
|
||||
|
||||
'Pump Functions
|
||||
Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal Index As Int32, ByVal CurveIndex As int32) As Int32 'ES
|
||||
Declare Function ENsetheadcurveindex Lib "epanet2.dll" (ByVal pumpIndex As Int32, ByVal curveIndex As Int32) As Int32
|
||||
Declare Function ENgetpumptype Lib "epanet2.dll" (ByVal Index As Int32, ByRef PumpType As Int32) As Int32 'ES
|
||||
|
||||
'Time Pattern Functions
|
||||
Declare Function ENaddpattern Lib "epanet2.dll" (ByVal ID As String) As Int32
|
||||
|
||||
Declare Function ENgetpatternindex Lib "epanet2.dll" (ByVal ID As String, ByRef Index As Int32) As Int32
|
||||
Declare Function ENgetpatternid Lib "epanet2.dll" (ByVal Index As Int32, ByVal ID As StringBuilder) As Int32
|
||||
Declare Function ENgetpatternlen Lib "epanet2.dll" (ByVal Index As Int32, ByRef L As Int32) As Int32
|
||||
Declare Function ENgetpatternvalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Period As Int32, ByRef 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, ByRef value As Single) As Int32
|
||||
Declare Function ENsetpattern Lib "epanet2.dll" (ByVal Index as Int32, ByRef F as Single, ByVal N 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, ByRef Index As Int32) As Int32
|
||||
Declare Function ENgetcurveid Lib "epanet2.dll" (ByVal Index As Int32, ByVal ID As StringBuilder) As Int32
|
||||
Declare Function ENgetcurvelen Lib "epanet2.dll" (ByVal Index As Int32, ByRef L As Int32) As Int32
|
||||
Declare Function ENgetcurvetype Lib "epanet2.dll" (ByVal curveIndex As Int32, ByRef CurveType As Int32) As Int32
|
||||
Declare Function ENgetcurvevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Pnt As Int32, ByRef X As Single, ByRef Y As Single) As Int32
|
||||
Declare Function ENsetcurvevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Pnt As Int32, ByVal X As Single, ByVal Y As Single) As Int32
|
||||
Declare Function ENgetcurve Lib "epanet2.dll" (ByVal CurveIndex As Int32, ByRef nValues As Int32, ByRef xValues As Single, ByRef yValues As Single) As Int32 'ES
|
||||
Declare Function ENsetcurve Lib "epanet2.dll" (ByVal Index as Int32, ByRef X as Single, ByRef Y as Single, ByVal N as Int32) as Int32
|
||||
Declare Function ENaddcurve Lib "epanet2.dll" (ByVal ID As String) As Int32
|
||||
|
||||
Declare Function ENaddcurve Lib "epanet2.dll" (ByVal ID As String) As Long
|
||||
'Simple Control Functions
|
||||
Declare Function ENaddcontrol Lib "epanet2.dll" (ByRef Cindex As Int32, ByVal Ctype As Int32, ByVal Lindex As Int32, ByVal setting As Single, ByVal Nindex As Int32, ByVal Level As Single) As Int32
|
||||
Declare Function ENdeletecontrol Lib "epanet2.dll" (ByVal Cindex as Int32) As Int32
|
||||
Declare Function ENgetcontrol Lib "epanet2.dll" (ByVal Cindex As Int32, ByRef CtlType As Int32, ByRef Lindex As Int32, ByRef Setting As Single, ByRef Nindex As Int32, ByRef Level As Single) As Int32
|
||||
Declare Function ENsetcontrol Lib "epanet2.dll" (ByVal Cindex As Int32, ByVal CtlType As Int32, ByVal Lindex As Int32, ByVal Setting As Single, ByVal Nindex As Int32, ByVal Level As Single) As Int32
|
||||
|
||||
'Rule-Based Control Functions
|
||||
Declare Function ENgetrule Lib "epanet2.dll" (ByVal index As Int32, ByRef nPremises As Int32, ByRef nTrueActions As Int32, ByRef nFalseActions As Int32, ByRef priority As Single) As Int32
|
||||
Declare Function ENgetruleID Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal id As StringBuilder) As Int32
|
||||
Declare Function ENsetrulepriority Lib "epanet2.dll" (ByVal index As Int32, ByVal priority As Single) As Int32
|
||||
Declare Function ENgetpremise Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexPremise As Int32, ByRef logop As Int32, ByRef object As Int32, ByRef indexObj As Int32, ByRef variable As Int32, ByRef relop As Int32, ByRef status As Int32, ByRef value As Single) As Int32
|
||||
Declare Function ENsetpremise Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexPremise As Int32, ByVal logop As Int32, ByVal object As Int32, ByVal indexObj As Int32, ByVal variable As Int32, ByVal relop As Int32, ByVal status As Int32, ByVal value As Single) As Int32
|
||||
@@ -257,10 +306,7 @@ Declare Function ENaddcurve Lib "epanet2.dll" (ByVal ID As String) As Long
|
||||
Declare Function ENsetpremisevalue Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexPremise As Int32, ByVal value As Single) As Int32
|
||||
Declare Function ENgettrueaction Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexAction As Int32, ByRef indexLink As Int32, ByRef status As Int32, ByRef setting As Single) As Int32
|
||||
Declare Function ENsettrueaction Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexAction As Int32, ByVal indexLink As Int32, ByVal status As Int32, ByVal setting As Single) As Int32
|
||||
Decalre FUnction ENgetfalseaction Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexAction As Int32, ByRef indexLink As Int32, ByRef status As Int32, ByRef setting As Single) As Int32
|
||||
Declare Function ENgetfalseaction Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexAction As Int32, ByRef indexLink As Int32, ByRef status As Int32, ByRef setting As Single) As Int32
|
||||
Declare Function ENsetfalseaction Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexAction As Int32, ByVal indexLink As Int32, ByVal status As Int32, ByVal setting As Single) As Int32
|
||||
Declare Function ENgetruleID Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal id As StringBuilder) As Int32
|
||||
|
||||
|
||||
|
||||
End Module
|
||||
|
||||
700
src/epanet.c
700
src/epanet.c
File diff suppressed because it is too large
Load Diff
@@ -52,7 +52,6 @@ int findvalve(EN_Network *n, int); /* Find valve index from node
|
||||
int findpump(EN_Network *n, int); /* Find pump index from node index */ // (AH)
|
||||
char *geterrmsg(int errcode, char *msg); /* Gets text of error message */
|
||||
void errmsg(EN_Project *p, int); /* Reports program error */
|
||||
void writecon(const char *); /* Writes text to console */
|
||||
void writewin(void (*vp)(char *), char *); /* Passes text to calling app */
|
||||
|
||||
/* ------- INPUT1.C --------------------*/
|
||||
@@ -75,6 +74,7 @@ int addcurve(parser_data_t *par, char *); /* Adds curve to data base
|
||||
STmplist *findID(char *, STmplist *); /* Locates ID on linked list */
|
||||
int unlinked(EN_Project *pr); /* Checks for unlinked nodes */
|
||||
int getpumpparams(EN_Project *pr); /* Computes pump curve coeffs.*/
|
||||
int updatepumpparams(EN_Project *pr, int); // Updates pump curve coeffs.
|
||||
int getpatterns(EN_Project *pr); /* Gets pattern data from list*/
|
||||
int getcurves(EN_Project *pr); /* Gets curve data from list */
|
||||
int findmatch(char *, char *[]); /* Finds keyword in line */
|
||||
@@ -121,6 +121,8 @@ void changestatus(EN_Network *net, int, StatType,
|
||||
void initrules(rules_t *rules); /* Initializes rule base */
|
||||
void addrule(parser_data_t *par, char *); /* Adds rule to rule base */
|
||||
int allocrules(EN_Project *pr); /* Allocates memory for rule */
|
||||
void adjustrules(EN_Project *pr, int, int); // Shifts object indices down
|
||||
void adjusttankrules(EN_Project *pr); // Shifts tank indices up
|
||||
int ruledata(EN_Project *pr); /* Processes rule input data */
|
||||
int checkrules(EN_Project *pr, long); /* Checks all rules */
|
||||
void freerules(EN_Project *pr); /* Frees rule base memory */
|
||||
|
||||
268
src/hash.c
268
src/hash.c
@@ -1,21 +1,20 @@
|
||||
/*-----------------------------------------------------------------------------
|
||||
** hash.c
|
||||
**
|
||||
** Implementation of a simple Hash Table for string storage & retrieval
|
||||
** Implementation of a simple Hash Table that uses a string as a key
|
||||
** and an associated integer as data.
|
||||
**
|
||||
** Written by L. Rossman
|
||||
** Last Updated on 6/19/03
|
||||
** Last Updated on 10/19/18
|
||||
**
|
||||
** The hash table data structure (HTable) is defined in "hash.h".
|
||||
** Interface Functions:
|
||||
** HTcreate() - creates a hash table
|
||||
** HTinsert() - inserts a string & its index value into a hash table
|
||||
** HTfind() - retrieves the index value of a string from a table
|
||||
** HTfree() - frees a hash table
|
||||
** hashtable_create - creates a hash table
|
||||
** hashtable_insert - inserts a string & its data value into a table
|
||||
** hashtable_find - retrieves the data value associated with a string
|
||||
** hashtable_findkey - retrieves the key associated with a data value
|
||||
** hashtable_delete - deletes an entry from a table
|
||||
** hashtable_free - frees a hash table
|
||||
**
|
||||
*********************************************************************
|
||||
** NOTE: This is a modified version of the original HASH.C module.
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __APPLE__
|
||||
@@ -26,144 +25,153 @@
|
||||
#include <string.h>
|
||||
#include "hash.h"
|
||||
|
||||
unsigned int _enHash(char *str);
|
||||
unsigned int _enHash(char *str)
|
||||
{
|
||||
unsigned int hash = 5381;
|
||||
unsigned int retHash;
|
||||
int c;
|
||||
while ((c = *str++)) {
|
||||
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
|
||||
}
|
||||
retHash = hash % ENHASHTABLEMAXSIZE;
|
||||
|
||||
return retHash;
|
||||
}
|
||||
#define HASHTABLEMAXSIZE 128000
|
||||
|
||||
ENHashTable *ENHashTableCreate()
|
||||
typedef struct DataEntryStruct
|
||||
{
|
||||
int i;
|
||||
ENHashTable *ht = (ENHashTable *) calloc(ENHASHTABLEMAXSIZE, sizeof(ENHashTable));
|
||||
if (ht != NULL) {
|
||||
for (i=0; i<ENHASHTABLEMAXSIZE; i++) {
|
||||
ht[i] = NULL;
|
||||
char *key;
|
||||
int data;
|
||||
struct DataEntryStruct *next;
|
||||
} DataEntry;
|
||||
|
||||
unsigned int gethash(char *str)
|
||||
{
|
||||
unsigned int hash = 5381;
|
||||
unsigned int retHash;
|
||||
int c;
|
||||
while ((c = *str++))
|
||||
{
|
||||
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
|
||||
}
|
||||
}
|
||||
return(ht);
|
||||
retHash = hash % HASHTABLEMAXSIZE;
|
||||
return retHash;
|
||||
}
|
||||
|
||||
int ENHashTableInsert(ENHashTable *ht, char *key, int data)
|
||||
char *dupstr(const char *s)
|
||||
{
|
||||
size_t len;
|
||||
unsigned int i = _enHash(key);
|
||||
ENHashEntry *entry;
|
||||
if ( i >= ENHASHTABLEMAXSIZE ) {
|
||||
return(0);
|
||||
}
|
||||
entry = (ENHashEntry *) malloc(sizeof(ENHashEntry));
|
||||
if (entry == NULL) {
|
||||
return(0);
|
||||
}
|
||||
len = strlen(key) + 1;
|
||||
entry->key = calloc(len, sizeof(char));
|
||||
strncpy(entry->key, key, len);
|
||||
entry->data = data;
|
||||
entry->next = ht[i];
|
||||
ht[i] = entry;
|
||||
return(1);
|
||||
size_t size = strlen(s) + 1;
|
||||
char *p = malloc(size);
|
||||
if (p) memcpy(p, s, size);
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Abel Heinsbroek: Added function to update the hash table value for a given key */
|
||||
int ENHashTableUpdate(ENHashTable *ht, char *key, int new_data)
|
||||
HashTable *hashtable_create()
|
||||
{
|
||||
unsigned int i = _enHash(key);
|
||||
ENHashEntry *entry;
|
||||
if ( i >= ENHASHTABLEMAXSIZE ) {
|
||||
return(NOTFOUND);
|
||||
}
|
||||
entry = ht[i];
|
||||
while (entry != NULL)
|
||||
{
|
||||
if ( strcmp(entry->key,key) == 0 ) {
|
||||
entry->data = new_data;
|
||||
return(1);
|
||||
int i;
|
||||
HashTable *ht = (HashTable *) calloc(HASHTABLEMAXSIZE, sizeof(HashTable));
|
||||
if (ht != NULL)
|
||||
{
|
||||
for (i = 0; i < HASHTABLEMAXSIZE; i++) ht[i] = NULL;
|
||||
}
|
||||
entry = entry->next;
|
||||
}
|
||||
return(NOTFOUND);
|
||||
return ht;
|
||||
}
|
||||
|
||||
int ENHashTableDelete(ENHashTable *ht, char *key) {
|
||||
unsigned int i = _enHash(key);
|
||||
ENHashEntry *entry;
|
||||
if ( i >= ENHASHTABLEMAXSIZE ) {
|
||||
return(NOTFOUND);
|
||||
}
|
||||
entry = ht[i];
|
||||
while (entry != NULL)
|
||||
{
|
||||
if (strcmp(entry->key, key) == 0) {
|
||||
entry->key = "";
|
||||
return(1);
|
||||
}
|
||||
entry = entry->next;
|
||||
}
|
||||
|
||||
return(NOTFOUND);
|
||||
}
|
||||
|
||||
int ENHashTableFind(ENHashTable *ht, char *key)
|
||||
int hashtable_insert(HashTable *ht, char *key, int data)
|
||||
{
|
||||
unsigned int i = _enHash(key);
|
||||
|
||||
ENHashEntry *entry;
|
||||
if ( i >= ENHASHTABLEMAXSIZE ) {
|
||||
return(NOTFOUND);
|
||||
}
|
||||
|
||||
entry = ht[i];
|
||||
while (entry != NULL)
|
||||
{
|
||||
if ( strcmp(entry->key,key) == 0 ) {
|
||||
return(entry->data);
|
||||
}
|
||||
entry = entry->next;
|
||||
}
|
||||
return(NOTFOUND);
|
||||
unsigned int i = gethash(key);
|
||||
DataEntry *entry;
|
||||
if ( i >= HASHTABLEMAXSIZE ) return 0;
|
||||
entry = (DataEntry *) malloc(sizeof(DataEntry));
|
||||
if (entry == NULL) return(0);
|
||||
entry->key = dupstr(key);
|
||||
entry->data = data;
|
||||
entry->next = ht[i];
|
||||
ht[i] = entry;
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *ENHashTableFindKey(ENHashTable *ht, char *key)
|
||||
int hashtable_update(HashTable *ht, char *key, int new_data)
|
||||
{
|
||||
unsigned int i = _enHash(key);
|
||||
ENHashEntry *entry;
|
||||
if ( i >= ENHASHTABLEMAXSIZE ) {
|
||||
return(NULL);
|
||||
}
|
||||
entry = ht[i];
|
||||
while (entry != NULL)
|
||||
{
|
||||
if ( strcmp(entry->key,key) == 0 ) {
|
||||
return(entry->key);
|
||||
}
|
||||
entry = entry->next;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
void ENHashTableFree(ENHashTable *ht)
|
||||
{
|
||||
ENHashEntry *entry, *nextentry;
|
||||
int i;
|
||||
for (i=0; i<ENHASHTABLEMAXSIZE; i++)
|
||||
{
|
||||
unsigned int i = gethash(key);
|
||||
DataEntry *entry;
|
||||
|
||||
if ( i >= HASHTABLEMAXSIZE ) return NOTFOUND;
|
||||
entry = ht[i];
|
||||
while (entry != NULL)
|
||||
{
|
||||
nextentry = entry->next;
|
||||
free(entry->key);
|
||||
free(entry);
|
||||
entry = nextentry;
|
||||
if ( strcmp(entry->key, key) == 0 )
|
||||
{
|
||||
entry->data = new_data;
|
||||
return 1;
|
||||
}
|
||||
entry = entry->next;
|
||||
}
|
||||
}
|
||||
free(ht);
|
||||
return NOTFOUND;
|
||||
}
|
||||
|
||||
int hashtable_delete(HashTable *ht, char *key)
|
||||
{
|
||||
unsigned int i = gethash(key);
|
||||
DataEntry *entry, *preventry;
|
||||
|
||||
if ( i >= HASHTABLEMAXSIZE ) return NOTFOUND;
|
||||
|
||||
preventry = NULL;
|
||||
entry = ht[i];
|
||||
while (entry != NULL)
|
||||
{
|
||||
if (strcmp(entry->key, key) == 0)
|
||||
{
|
||||
if (preventry == NULL) ht[i] = entry->next;
|
||||
else preventry->next = entry->next;
|
||||
free(entry->key);
|
||||
free(entry);
|
||||
return 1;
|
||||
}
|
||||
preventry = entry;
|
||||
entry = entry->next;
|
||||
}
|
||||
return NOTFOUND;
|
||||
}
|
||||
|
||||
int hashtable_find(HashTable *ht, char *key)
|
||||
{
|
||||
unsigned int i = gethash(key);
|
||||
DataEntry *entry;
|
||||
|
||||
if ( i >= HASHTABLEMAXSIZE ) return NOTFOUND;
|
||||
entry = ht[i];
|
||||
while (entry != NULL)
|
||||
{
|
||||
if ( strcmp(entry->key, key) == 0 )
|
||||
{
|
||||
return entry->data;
|
||||
}
|
||||
entry = entry->next;
|
||||
}
|
||||
return NOTFOUND;
|
||||
}
|
||||
|
||||
char *hashtable_findkey(HashTable *ht, char *key)
|
||||
{
|
||||
unsigned int i = gethash(key);
|
||||
DataEntry *entry;
|
||||
if ( i >= HASHTABLEMAXSIZE ) return NULL;
|
||||
entry = ht[i];
|
||||
while (entry != NULL)
|
||||
{
|
||||
if ( strcmp(entry->key, key) == 0 ) return entry->key;
|
||||
entry = entry->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void hashtable_free(HashTable *ht)
|
||||
{
|
||||
DataEntry *entry, *nextentry;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < HASHTABLEMAXSIZE; i++)
|
||||
{
|
||||
entry = ht[i];
|
||||
while (entry != NULL)
|
||||
{
|
||||
nextentry = entry->next;
|
||||
free(entry->key);
|
||||
free(entry);
|
||||
entry = nextentry;
|
||||
}
|
||||
ht[i] = NULL;
|
||||
}
|
||||
free(ht);
|
||||
}
|
||||
|
||||
24
src/hash.h
24
src/hash.h
@@ -7,24 +7,16 @@
|
||||
#ifndef HASH_H
|
||||
#define HASH_H
|
||||
|
||||
#define ENHASHTABLEMAXSIZE 128000
|
||||
#define NOTFOUND 0
|
||||
|
||||
typedef struct HTentryStruct
|
||||
{
|
||||
char *key;
|
||||
int data;
|
||||
struct HTentryStruct *next;
|
||||
} ENHashEntry;
|
||||
typedef struct DataEntryStruct *HashTable;
|
||||
|
||||
typedef ENHashEntry *ENHashTable;
|
||||
HashTable *hashtable_create(void);
|
||||
int hashtable_insert(HashTable *, char *, int);
|
||||
int hashtable_find(HashTable *, char *);
|
||||
char *hashtable_findkey(HashTable *, char *);
|
||||
void hashtable_free(HashTable *);
|
||||
int hashtable_update(HashTable *ht, char *key, int new_data);
|
||||
int hashtable_delete(HashTable *ht, char *key);
|
||||
|
||||
ENHashTable *ENHashTableCreate(void);
|
||||
int ENHashTableInsert(ENHashTable *, char *, int);
|
||||
int ENHashTableFind(ENHashTable *, char *);
|
||||
char *ENHashTableFindKey(ENHashTable *, char *);
|
||||
void ENHashTableFree(ENHashTable *);
|
||||
int ENHashTableUpdate(ENHashTable *ht, char *key, int new_data);
|
||||
int ENHashTableDelete(ENHashTable *ht, char *key);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -104,9 +104,9 @@ void setdefaults(EN_Project *pr)
|
||||
time_options_t *time = &pr->time_options;
|
||||
out_file_t *out = &pr->out_files;
|
||||
|
||||
strncpy(pr->Title[0], "", MAXMSG);
|
||||
strncpy(pr->Title[1], "", MAXMSG);
|
||||
strncpy(pr->Title[2], "", MAXMSG);
|
||||
strncpy(pr->Title[0], "", TITLELEN);
|
||||
strncpy(pr->Title[1], "", TITLELEN);
|
||||
strncpy(pr->Title[2], "", TITLELEN);
|
||||
strncpy(out->TmpDir, "", MAXFNAME);
|
||||
strncpy(out->TmpFname, "", MAXFNAME);
|
||||
strncpy(out->HydFname, "", MAXFNAME);
|
||||
@@ -356,6 +356,7 @@ void adjustdata(EN_Project *pr)
|
||||
for (demand = node->D; demand != NULL; demand = demand->next) {
|
||||
if (demand->Pat == 0) {
|
||||
demand->Pat = hyd->DefPat;
|
||||
strcpy(demand->Name, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
221
src/input2.c
221
src/input2.c
@@ -40,10 +40,10 @@ The following utility functions are all called from INPUT3.C
|
||||
|
||||
#define MAXERRS 10 /* Max. input errors reported */
|
||||
|
||||
|
||||
/* Defined in enumstxt.h in EPANET.C */
|
||||
extern char *SectTxt[]; /* Input section keywords */
|
||||
|
||||
|
||||
int netsize(EN_Project *pr)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
@@ -206,9 +206,10 @@ int readdata(EN_Project *pr)
|
||||
|
||||
/* Check if max. length exceeded */
|
||||
if (strlen(line) >= MAXLINE) {
|
||||
char errMsg[MAXMSG+1];
|
||||
EN_geterror(214, errMsg, MAXMSG);
|
||||
sprintf(pr->Msg, "%s section: %s", errMsg, SectTxt[sect]);
|
||||
// char errMsg[MAXMSG+1];
|
||||
// EN_geterror(214, errMsg, MAXMSG);
|
||||
// sprintf(pr->Msg, "%s section: %s", errMsg, SectTxt[sect]);
|
||||
sprintf(pr->Msg, "%s section: %s", geterrmsg(214, pr->Msg), SectTxt[sect]);
|
||||
writeline(pr, pr->Msg);
|
||||
writeline(pr, line);
|
||||
errsum++;
|
||||
@@ -292,7 +293,7 @@ int newline(EN_Project *pr, int sect, char *line)
|
||||
n = (int)strlen(line);
|
||||
if (line[n - 1] == 10)
|
||||
line[n - 1] = ' ';
|
||||
strncpy(pr->Title[par->Ntitle], line, MAXMSG);
|
||||
strncpy(pr->Title[par->Ntitle], line, TITLELEN);
|
||||
par->Ntitle++;
|
||||
}
|
||||
return (0);
|
||||
@@ -363,101 +364,121 @@ int getpumpparams(EN_Project *pr)
|
||||
**-------------------------------------------------------------
|
||||
** Input: none
|
||||
** Output: returns error code
|
||||
** Purpose: computes & checks pump curve parameters
|
||||
** Purpose: computes pump curve coefficients for all pumps
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
int i, j = 0, k, m, n = 0;
|
||||
double a, b, c, h0 = 0.0, h1 = 0.0, h2 = 0.0, q1 = 0.0, q2 = 0.0;
|
||||
char errMsg[MAXMSG+1];
|
||||
Spump *pump;
|
||||
Slink *link;
|
||||
Scurve *curve;
|
||||
|
||||
EN_Network *net = &pr->network;
|
||||
|
||||
for (i = 1; i <= net->Npumps; i++) {
|
||||
pump = &net->Pump[i];
|
||||
k = pump->Link;
|
||||
link = &net->Link[k];
|
||||
if (pump->Ptype == CONST_HP) { /* Constant Hp pump */
|
||||
pump->H0 = 0.0;
|
||||
pump->R = -8.814 * link->Km;
|
||||
pump->N = -1.0;
|
||||
pump->Hmax = BIG; /* No head limit */
|
||||
pump->Qmax = BIG; /* No flow limit */
|
||||
pump->Q0 = 1.0; /* Init. flow = 1 cfs */
|
||||
continue;
|
||||
}
|
||||
else if (pump->Ptype == NOCURVE) { /* Pump curve specified */
|
||||
j = pump->Hcurve; /* Get index of head curve */
|
||||
if (j == 0) { /* Error: No head curve */
|
||||
EN_geterror(226, errMsg, MAXMSG);
|
||||
sprintf(pr->Msg, "%s link: %s", errMsg, link->ID);
|
||||
writeline(pr, pr->Msg);
|
||||
return (200);
|
||||
}
|
||||
curve = &net->Curve[j];
|
||||
curve->Type = P_CURVE;
|
||||
n = curve->Npts;
|
||||
if (n == 1) { /* Only a single h-q point supplied so use generic */
|
||||
pump->Ptype = POWER_FUNC; /* power function curve. */
|
||||
q1 = curve->X[0];
|
||||
h1 = curve->Y[0];
|
||||
h0 = 1.33334 * h1;
|
||||
q2 = 2.0 * q1;
|
||||
h2 = 0.0;
|
||||
} else if (n == 3 && curve->X[0] == 0.0) /* 3 h-q points supplied with */
|
||||
{ /* shutoff head so use fitted */
|
||||
pump->Ptype = POWER_FUNC; /* power function curve. */
|
||||
h0 = curve->Y[0];
|
||||
q1 = curve->X[1];
|
||||
h1 = curve->Y[1];
|
||||
q2 = curve->X[2];
|
||||
h2 = curve->Y[2];
|
||||
}
|
||||
else { // use a custom curve, referenced by ID
|
||||
pump->Ptype = CUSTOM; /* Else use custom pump curve.*/
|
||||
// at this point, j is set to that curve's index.
|
||||
}
|
||||
|
||||
/* Compute shape factors & limits of power function pump curves */
|
||||
if (pump->Ptype == POWER_FUNC) {
|
||||
if (!powercurve(h0, h1, h2, q1, q2, &a, &b, &c)) { /* Error: Invalid curve */
|
||||
EN_geterror(227, errMsg, MAXMSG);
|
||||
sprintf(pr->Msg, "%s link: %s", errMsg, link->ID);
|
||||
writeline(pr, pr->Msg);
|
||||
return (200);
|
||||
} else {
|
||||
pump->H0 = -a;
|
||||
pump->R = -b;
|
||||
pump->N = c;
|
||||
pump->Q0 = q1;
|
||||
pump->Qmax = pow((-a / b), (1.0 / c));
|
||||
pump->Hmax = h0;
|
||||
int i, k, errcode = 0;
|
||||
EN_Network *net = &pr->network;
|
||||
|
||||
for (i = 1; i <= net->Npumps; i++)
|
||||
{
|
||||
errcode = updatepumpparams(pr, i);
|
||||
if (errcode)
|
||||
{
|
||||
k = net->Pump[i].Link;
|
||||
sprintf(pr->Msg, "%s link: %s", geterrmsg(errcode, pr->Msg),
|
||||
net->Link[k].ID);
|
||||
writeline(pr, pr->Msg);
|
||||
return 200;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int updatepumpparams(EN_Project *pr, int pumpindex)
|
||||
/*
|
||||
**-------------------------------------------------------------
|
||||
** Input: pumpindex = index of a pump
|
||||
** Output: returns error code
|
||||
** Purpose: computes & checks a pump's head curve coefficients
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
int m;
|
||||
int curveindex;
|
||||
int npts = 0;
|
||||
int errcode = 0;
|
||||
double a, b, c, h0 = 0.0, h1 = 0.0, h2 = 0.0, q1 = 0.0, q2 = 0.0;
|
||||
|
||||
EN_Network *net = &pr->network;
|
||||
Spump *pump;
|
||||
Scurve *curve;
|
||||
|
||||
pump = &net->Pump[pumpindex];
|
||||
if (pump->Ptype == CONST_HP) // Constant Hp pump
|
||||
{
|
||||
pump->H0 = 0.0;
|
||||
pump->R = -8.814 * net->Link[pump->Link].Km;
|
||||
pump->N = -1.0;
|
||||
pump->Hmax = BIG; // No head limit
|
||||
pump->Qmax = BIG; // No flow limit
|
||||
pump->Q0 = 1.0; // Init. flow = 1 cfs
|
||||
return errcode;
|
||||
}
|
||||
|
||||
/* Assign limits to custom pump curves */
|
||||
if (pump->Ptype == CUSTOM) {
|
||||
curve = &net->Curve[j];
|
||||
for (m = 1; m < n; m++) {
|
||||
if (curve->Y[m] >= curve->Y[m - 1]) { /* Error: Invalid curve */
|
||||
EN_geterror(227, errMsg, MAXMSG);
|
||||
sprintf(pr->Msg, "%s link: %s", errMsg, link->ID);
|
||||
writeline(pr, pr->Msg);
|
||||
return (200);
|
||||
else if (pump->Ptype == NOCURVE) // Pump curve specified
|
||||
{
|
||||
curveindex = pump->Hcurve;
|
||||
if (curveindex == 0) return 226;
|
||||
curve = &net->Curve[curveindex];
|
||||
curve->Type = P_CURVE;
|
||||
npts = curve->Npts;
|
||||
|
||||
// Generic power function curve
|
||||
if (npts == 1)
|
||||
{
|
||||
pump->Ptype = POWER_FUNC;
|
||||
q1 = curve->X[0];
|
||||
h1 = curve->Y[0];
|
||||
h0 = 1.33334 * h1;
|
||||
q2 = 2.0 * q1;
|
||||
h2 = 0.0;
|
||||
}
|
||||
|
||||
// 3 point curve with shutoff head
|
||||
else if (npts == 3 && curve->X[0] == 0.0)
|
||||
{
|
||||
pump->Ptype = POWER_FUNC;
|
||||
h0 = curve->Y[0];
|
||||
q1 = curve->X[1];
|
||||
h1 = curve->Y[1];
|
||||
q2 = curve->X[2];
|
||||
h2 = curve->Y[2];
|
||||
}
|
||||
|
||||
// Custom pump curve
|
||||
else
|
||||
{
|
||||
pump->Ptype = CUSTOM;
|
||||
for (m = 1; m < npts; m++)
|
||||
{
|
||||
if (curve->Y[m] >= curve->Y[m - 1]) return 227;
|
||||
}
|
||||
pump->Qmax = curve->X[npts - 1];
|
||||
pump->Q0 = (curve->X[0] + pump->Qmax) / 2.0;
|
||||
pump->Hmax = curve->Y[0];
|
||||
}
|
||||
|
||||
// Compute shape factors & limits of power function curves
|
||||
if (pump->Ptype == POWER_FUNC)
|
||||
{
|
||||
if (!powercurve(h0, h1, h2, q1, q2, &a, &b, &c)) return 227;
|
||||
else
|
||||
{
|
||||
pump->H0 = -a;
|
||||
pump->R = -b;
|
||||
pump->N = c;
|
||||
pump->Q0 = q1;
|
||||
pump->Qmax = pow((-a / b), (1.0 / c));
|
||||
pump->Hmax = h0;
|
||||
}
|
||||
}
|
||||
}
|
||||
pump->Qmax = curve->X[n - 1];
|
||||
pump->Q0 = (curve->X[0] + pump->Qmax) / 2.0;
|
||||
pump->Hmax = curve->Y[0];
|
||||
}
|
||||
} /* Next pump */
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int addnodeID(EN_Network *net, int n, char *id)
|
||||
/*
|
||||
**-------------------------------------------------------------
|
||||
@@ -472,7 +493,7 @@ int addnodeID(EN_Network *net, int n, char *id)
|
||||
return (0); /* see EPANET.C */
|
||||
}
|
||||
strncpy(net->Node[n].ID, id, MAXID);
|
||||
ENHashTableInsert(net->NodeHashTable, net->Node[n].ID, n); /* see HASH.C */
|
||||
hashtable_insert(net->NodeHashTable, net->Node[n].ID, n); /* see HASH.C */
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -490,7 +511,7 @@ int addlinkID(EN_Network *net, int n, char *id)
|
||||
return (0); /* see EPANET.C */
|
||||
}
|
||||
strncpy(net->Link[n].ID, id, MAXID);
|
||||
ENHashTableInsert(net->LinkHashTable, net->Link[n].ID, n); /* see HASH.C */
|
||||
hashtable_insert(net->LinkHashTable, net->Link[n].ID, n); /* see HASH.C */
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -603,7 +624,6 @@ int unlinked(EN_Project *pr)
|
||||
EN_Network *net = &pr->network;
|
||||
int *marked;
|
||||
int i, err, errcode;
|
||||
char errMsg[MAXMSG+1];
|
||||
|
||||
errcode = 0;
|
||||
err = 0;
|
||||
@@ -621,8 +641,7 @@ int unlinked(EN_Project *pr)
|
||||
if (marked[i] == 0) /* If not marked then error */
|
||||
{
|
||||
err++;
|
||||
EN_geterror(233, errMsg, MAXMSG);
|
||||
sprintf(pr->Msg, "%s node: %s", errMsg, net->Node[i].ID);
|
||||
sprintf(pr->Msg, "%s link: %s", geterrmsg(233, pr->Msg), net->Node[i].ID);
|
||||
writeline(pr, pr->Msg);
|
||||
}
|
||||
if (err >= MAXERRS)
|
||||
@@ -732,9 +751,7 @@ int getcurves(EN_Project *pr)
|
||||
|
||||
/* Check that curve has data points */
|
||||
if (curve->Npts <= 0) {
|
||||
char errMsg[MAXMSG+1];
|
||||
EN_geterror(230, errMsg, MAXMSG);
|
||||
sprintf(pr->Msg, "%s curve: %s", errMsg, curve->ID);
|
||||
sprintf(pr->Msg, "%s link: %s", geterrmsg(230, pr->Msg), curve->ID);
|
||||
writeline(pr, pr->Msg);
|
||||
return (200);
|
||||
}
|
||||
@@ -754,9 +771,7 @@ int getcurves(EN_Project *pr)
|
||||
|
||||
/* Check that x data is in ascending order */
|
||||
if (fx->value >= x) {
|
||||
char errMsg[MAXMSG+1];
|
||||
EN_geterror(230, errMsg, MAXMSG);
|
||||
sprintf(pr->Msg, "%s node: %s", errMsg, curve->ID);
|
||||
sprintf(pr->Msg, "%s link: %s", geterrmsg(230, pr->Msg), curve->ID);
|
||||
writeline(pr, pr->Msg);
|
||||
return (200);
|
||||
}
|
||||
@@ -1012,10 +1027,8 @@ void inperrmsg(EN_Project *pr, int err, int sect, char *line)
|
||||
char errStr[MAXMSG + 1];
|
||||
char id[MAXMSG + 1];
|
||||
|
||||
EN_geterror(err, errStr, MAXMSG);
|
||||
|
||||
/* get text for error message */
|
||||
sprintf(pr->Msg, "%s - section: %s", errStr, SectTxt[sect]);
|
||||
sprintf(pr->Msg, "%s - section: %s", geterrmsg(err, errStr), SectTxt[sect]);
|
||||
|
||||
// append ID?
|
||||
/* Retrieve ID label of object with input error */
|
||||
|
||||
@@ -87,9 +87,9 @@ int savenetdata(EN_Project *pr)
|
||||
fwrite(ibuf, sizeof(INT4), 15, outFile);
|
||||
|
||||
/* Write string variables to outFile */
|
||||
fwrite(pr->Title[0], sizeof(char), MAXMSG + 1, outFile);
|
||||
fwrite(pr->Title[1], sizeof(char), MAXMSG + 1, outFile);
|
||||
fwrite(pr->Title[2], sizeof(char), MAXMSG + 1, outFile);
|
||||
fwrite(pr->Title[0], sizeof(char), TITLELEN + 1, outFile);
|
||||
fwrite(pr->Title[1], sizeof(char), TITLELEN + 1, outFile);
|
||||
fwrite(pr->Title[2], sizeof(char), TITLELEN + 1, outFile);
|
||||
fwrite(par->InpFname, sizeof(char), MAXFNAME + 1, outFile);
|
||||
fwrite(rep->Rpt2Fname, sizeof(char), MAXFNAME + 1, outFile);
|
||||
fwrite(qu->ChemName, sizeof(char), MAXID + 1, outFile);
|
||||
|
||||
@@ -82,8 +82,6 @@ int writereport(EN_Project *pr)
|
||||
/* write formatted output to primary report file. */
|
||||
rep->Fprinterr = FALSE;
|
||||
if (rep->Rptflag && strlen(rep->Rpt2Fname) == 0 && rep->RptFile != NULL) {
|
||||
writecon(FMT17);
|
||||
writecon(rep->Rpt1Fname);
|
||||
if (rep->Energyflag)
|
||||
writeenergy(pr);
|
||||
errcode = writeresults(pr);
|
||||
@@ -95,8 +93,6 @@ int writereport(EN_Project *pr)
|
||||
/* If secondary report file has same name as either input */
|
||||
/* or primary report file then use primary report file. */
|
||||
if (strcomp(rep->Rpt2Fname, par->InpFname) || strcomp(rep->Rpt2Fname, rep->Rpt1Fname)) {
|
||||
writecon(FMT17);
|
||||
writecon(rep->Rpt1Fname);
|
||||
if (rep->Energyflag)
|
||||
writeenergy(pr);
|
||||
errcode = writeresults(pr);
|
||||
@@ -117,8 +113,6 @@ int writereport(EN_Project *pr)
|
||||
/* Write full formatted report to file */
|
||||
else {
|
||||
rep->Rptflag = 1;
|
||||
writecon(FMT17);
|
||||
writecon(rep->Rpt2Fname);
|
||||
writelogo(pr);
|
||||
if (rep->Summaryflag)
|
||||
writesummary(pr);
|
||||
|
||||
191
src/rules.c
191
src/rules.c
@@ -90,29 +90,24 @@ char *Operator[] = {"=", "<>", "<=", ">=", "<", ">",
|
||||
enum Values { IS_NUMBER, IS_OPEN, IS_CLOSED, IS_ACTIVE };
|
||||
char *Value[] = {"XXXX", w_OPEN, w_CLOSED, w_ACTIVE, NULL};
|
||||
|
||||
/* External variables declared in INPUT2.C */
|
||||
// Local Functions
|
||||
static void newrule(EN_Project *pr);
|
||||
static int newpremise(EN_Project *pr, int);
|
||||
static int newaction(EN_Project *pr);
|
||||
static int newpriority(EN_Project *pr);
|
||||
static int evalpremises(EN_Project *pr, int);
|
||||
static void updateactlist(rules_t *rules, int, Action *);
|
||||
static int checkaction(rules_t *rules, int, Action *);
|
||||
static int checkpremise(EN_Project *pr, Premise *);
|
||||
static int checktime(EN_Project *pr, Premise *);
|
||||
static int checkstatus(EN_Project *pr, Premise *);
|
||||
static int checkvalue(EN_Project *pr, Premise *);
|
||||
static int takeactions(EN_Project *pr);
|
||||
static void clearactlist(rules_t *rules);
|
||||
static void ruleerrmsg(EN_Project *pr, int);
|
||||
static void clearrule(EN_Project *pr, int);
|
||||
static void deleterule(EN_Project *pr, int);
|
||||
|
||||
/*
|
||||
** Local function prototypes are defined here and not in FUNCS.H
|
||||
** because some of them utilize the Premise and Action structures
|
||||
** defined locally in this module.
|
||||
*/
|
||||
void newrule(EN_Project *pr);
|
||||
int newpremise(EN_Project *pr, int);
|
||||
int newaction(EN_Project *pr);
|
||||
int newpriority(EN_Project *pr);
|
||||
int evalpremises(EN_Project *pr, int);
|
||||
void updateactlist(rules_t *rules, int, Action *);
|
||||
int checkaction(rules_t *rules, int, Action *);
|
||||
int checkpremise(EN_Project *pr, Premise *);
|
||||
int checktime(EN_Project *pr, Premise *);
|
||||
int checkstatus(EN_Project *pr, Premise *);
|
||||
int checkvalue(EN_Project *pr, Premise *);
|
||||
int takeactions(EN_Project *pr);
|
||||
void clearactlist(rules_t *rules);
|
||||
void clearrules(EN_Project *pr);
|
||||
void ruleerrmsg(EN_Project *pr, int);
|
||||
//int writeRuleinInp(EN_Project *pr, FILE *f, int RuleIdx);
|
||||
|
||||
void initrules(rules_t *rules)
|
||||
/*
|
||||
@@ -166,8 +161,9 @@ void freerules(EN_Project *pr)
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
clearrules(pr);
|
||||
free(pr->rules.Rule);
|
||||
int i;
|
||||
for (i = 1; i <= pr->network.Nrules; i++) clearrule(pr, i);
|
||||
free(pr->rules.Rule);
|
||||
}
|
||||
|
||||
int checkrules(EN_Project *pr, long dt)
|
||||
@@ -217,7 +213,7 @@ int ruledata(EN_Project *pr)
|
||||
**--------------------------------------------------------------
|
||||
** Parses a line from [RULES] section of input.
|
||||
** Called by newline() in INPUT2.C module.
|
||||
** Tok[] is global array of tokens parsed from input line.
|
||||
** Tok[] is an array of tokens parsed from input line.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
@@ -305,6 +301,132 @@ int ruledata(EN_Project *pr)
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
void adjustrules(EN_Project *pr, int objtype, int index)
|
||||
/*
|
||||
**-----------------------------------------------------------
|
||||
** Adjusts rules when a specific node or link is deleted.
|
||||
** Called by EN_deletenode & EN_deletelink in EPANET.C.
|
||||
**-----------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
int i, delete;
|
||||
EN_Network *net = &pr->network;
|
||||
rules_t *rules = &pr->rules;
|
||||
Premise *p;
|
||||
Action *a;
|
||||
|
||||
// Delete rules that refer to objtype and index
|
||||
for (i = net->Nrules; i >= 1; i--)
|
||||
{
|
||||
delete = FALSE;
|
||||
p = rules->Rule[i].Pchain;
|
||||
while (p != NULL && !delete)
|
||||
{
|
||||
if (objtype == p->object && p->index == index) delete = TRUE;
|
||||
p = p->next;
|
||||
}
|
||||
if (objtype == r_LINK)
|
||||
{
|
||||
a = rules->Rule[i].Tchain;
|
||||
while (a != NULL && !delete)
|
||||
{
|
||||
if (a->link == index) delete = TRUE;
|
||||
a = a->next;
|
||||
}
|
||||
a = rules->Rule[i].Fchain;
|
||||
while (a != NULL && !delete)
|
||||
{
|
||||
if (a->link == index) delete = TRUE;
|
||||
a = a->next;
|
||||
}
|
||||
}
|
||||
if (delete) deleterule(pr, i);
|
||||
}
|
||||
|
||||
// Adjust all higher object indices to reflect deletion of object index
|
||||
for (i = 1; i <= net->Nrules; i++)
|
||||
{
|
||||
p = rules->Rule[i].Pchain;
|
||||
while (p != NULL)
|
||||
{
|
||||
if (objtype == p->object && p->index > index) p->index--;
|
||||
p = p->next;
|
||||
}
|
||||
if (objtype == r_LINK)
|
||||
{
|
||||
a = rules->Rule[i].Tchain;
|
||||
while (a != NULL)
|
||||
{
|
||||
if (a->link > index) a->link--;
|
||||
a = a->next;
|
||||
}
|
||||
a = rules->Rule[i].Fchain;
|
||||
while (a != NULL)
|
||||
{
|
||||
if (a->link > index) a->link--;
|
||||
a = a->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void adjusttankrules(EN_Project *pr)
|
||||
/*
|
||||
**-----------------------------------------------------------
|
||||
** Adjusts tank indices in rule premises.
|
||||
** Called by EN_addnode in EPANET.C.
|
||||
**-----------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
int i, njuncs;
|
||||
EN_Network *net = &pr->network;
|
||||
rules_t *rules = &pr->rules;
|
||||
Premise *p;
|
||||
|
||||
njuncs = net->Njuncs;
|
||||
for (i = 1; i <= net->Nrules; i++)
|
||||
{
|
||||
p = rules->Rule[i].Pchain;
|
||||
while (p != NULL)
|
||||
{
|
||||
if (p->object == r_NODE && p->index > njuncs) p->index++;
|
||||
p = p->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void deleterule(EN_Project *pr, int index)
|
||||
/*
|
||||
**-----------------------------------------------------------
|
||||
** Deletes a specific rule
|
||||
**-----------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
int i;
|
||||
EN_Network *net = &pr->network;
|
||||
rules_t *rules = &pr->rules;
|
||||
aRule *lastRule;
|
||||
|
||||
// Free memory allocated to rule's premises & actions
|
||||
clearrule(pr, index);
|
||||
|
||||
// Shift position of higher indexed rules down one
|
||||
for (i = index; i <= net->Nrules - 1; i++)
|
||||
{
|
||||
rules->Rule[i] = rules->Rule[i + 1];
|
||||
}
|
||||
|
||||
// Remove premises & actions from last (inactive) entry in Rule array
|
||||
lastRule = &rules->Rule[net->Nrules];
|
||||
lastRule->Pchain = NULL;
|
||||
lastRule->Tchain = NULL;
|
||||
lastRule->Fchain = NULL;
|
||||
|
||||
// Reduce active rule count by one
|
||||
net->Nrules--;
|
||||
}
|
||||
|
||||
void clearactlist(rules_t *rules)
|
||||
/*
|
||||
**----------------------------------------------------------
|
||||
@@ -322,23 +444,19 @@ void clearactlist(rules_t *rules)
|
||||
}
|
||||
}
|
||||
|
||||
void clearrules(EN_Project *pr)
|
||||
void clearrule(EN_Project *pr, int i)
|
||||
/*
|
||||
**-----------------------------------------------------------
|
||||
** Clears memory used for premises & actions for all rules
|
||||
** Clears memory used by a rule for premises & actions
|
||||
**-----------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
EN_Network *net = &pr->network;
|
||||
rules_t *rules = &pr->rules;
|
||||
Premise *p;
|
||||
Premise *pnext;
|
||||
Action *a;
|
||||
Action *anext;
|
||||
|
||||
rules_t *rules = &pr->rules;
|
||||
|
||||
Premise *p;
|
||||
Premise *pnext;
|
||||
Action *a;
|
||||
Action *anext;
|
||||
int i;
|
||||
for (i = 1; i <= net->Nrules; i++) {
|
||||
p = rules->Rule[i].Pchain;
|
||||
while (p != NULL) {
|
||||
pnext = p->next;
|
||||
@@ -357,7 +475,6 @@ void clearrules(EN_Project *pr)
|
||||
free(a);
|
||||
a = anext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void newrule(EN_Project *pr)
|
||||
|
||||
14
src/text.h
14
src/text.h
@@ -449,19 +449,15 @@ AUTHOR: L. Rossman
|
||||
#define FMT82 "\n\f\n Page %-d %60.60s\n"
|
||||
|
||||
/* ------------------- Progress Messages ---------------------- */
|
||||
#define FMT100 "Retrieving network data..."
|
||||
#define FMT101 "Computing hydraulics at hour %s"
|
||||
#define FMT102 "Computing water quality at hour %s"
|
||||
#define FMT103 "Saving results to file..."
|
||||
#define FMT100 " Retrieving network data ... "
|
||||
#define FMT101 " Computing hydraulics at hour %-10s "
|
||||
#define FMT102 " Computing water quality at hour %-10s "
|
||||
#define FMT103 " Writing output report ... "
|
||||
#define FMT106 " Transferring results to file ... "
|
||||
#define FMT104 "Analysis begun %s"
|
||||
#define FMT105 "Analysis ended %s"
|
||||
|
||||
/*------------------- Error Messages --------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define R_ERR201 "Input Error 201: syntax error in following line of "
|
||||
#define R_ERR202 "Input Error 202: illegal numeric value in following line of "
|
||||
#define R_ERR203 "Input Error 203: undefined node in following line of "
|
||||
|
||||
16
src/types.h
16
src/types.h
@@ -48,9 +48,10 @@ typedef int INT4;
|
||||
#define ENGINE_VERSION 201
|
||||
#define EOFMARK 0x1A /* Use 0x04 for UNIX systems */
|
||||
#define MAXTITLE 3 /* Max. # title lines */
|
||||
#define TITLELEN 79 // Max. # characters in a title line
|
||||
#define MAXID 31 /* Max. # characters in ID name */
|
||||
#define MAXMSG 79 /* Max. # characters in message text */
|
||||
#define MAXLINE 255 /* Max. # characters read from input line */
|
||||
#define MAXMSG 255 /* Max. # characters in message text */
|
||||
#define MAXLINE 1024 /* Max. # characters read from input line */
|
||||
#define MAXFNAME 259 /* Max. # characters in file name */
|
||||
#define MAXTOKS 40 /* Max. items per line of input */
|
||||
#define TZERO 1.E-4 /* Zero time tolerance */
|
||||
@@ -530,7 +531,7 @@ typedef struct s_aRule /* Control Rule Structure */
|
||||
Premise *Pchain; /* Linked list of premises */
|
||||
Action *Tchain; /* Linked list of actions if true */
|
||||
Action *Fchain; /* Linked list of actions if false */
|
||||
struct s_aRule *next;
|
||||
//struct s_aRule *next;
|
||||
} aRule;
|
||||
|
||||
typedef struct s_ActItem /* Action list item */
|
||||
@@ -873,9 +874,10 @@ typedef struct {
|
||||
Scurve *Curve; /* Curve data */
|
||||
Scoord *Coord; /* Coordinate data */
|
||||
Scontrol *Control; /* Control data */
|
||||
ENHashTable *NodeHashTable,
|
||||
*LinkHashTable; /* Hash tables for ID labels */
|
||||
Padjlist *Adjlist; /* Node adjacency lists */
|
||||
HashTable
|
||||
*NodeHashTable,
|
||||
*LinkHashTable; /* Hash tables for ID labels */
|
||||
Padjlist *Adjlist; /* Node adjacency lists */
|
||||
|
||||
} EN_Network;
|
||||
|
||||
@@ -900,7 +902,7 @@ typedef struct EN_Project {
|
||||
Openflag, /// Toolkit open flag
|
||||
Warnflag, /// Warning flag
|
||||
Msg[MAXMSG+1], /// General-purpose string: errors, messages
|
||||
Title[MAXTITLE][MAXMSG+1], /// Problem title
|
||||
Title[MAXTITLE][TITLELEN+1],/// Project title
|
||||
MapFname[MAXFNAME+1]; /// Map file name
|
||||
|
||||
error_handle_t* error_handle; //Simple error manager
|
||||
|
||||
87
tests/test_setid.cpp
Normal file
87
tests/test_setid.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
// Test of ENsetid EPANET API Function
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
|
||||
/*
|
||||
This is a test for the API functions that change a node or link ID name.
|
||||
A node and link name are changed, the network is saved, reopened and the new names are checked.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_MODULE "toolkit"
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include <string>
|
||||
#include "epanet2.h"
|
||||
|
||||
#define DATA_PATH_INP "./net1.inp"
|
||||
#define DATA_PATH_RPT "./test.rpt"
|
||||
#define DATA_PATH_OUT "./test.out"
|
||||
|
||||
using namespace std;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (test_toolkit)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_setid)
|
||||
{
|
||||
int error = 0;
|
||||
int index;
|
||||
string newid;
|
||||
|
||||
EN_ProjectHandle ph = NULL;
|
||||
EN_createproject(&ph);
|
||||
|
||||
std::string path_inp = std::string(DATA_PATH_INP);
|
||||
std::string path_rpt = std::string(DATA_PATH_RPT);
|
||||
std::string path_out = std::string(DATA_PATH_OUT);
|
||||
|
||||
error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), "");
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Test of illegal node name change
|
||||
newid = "Illegal; node name";
|
||||
error = EN_setnodeid(ph, 3, (char *)newid.c_str());
|
||||
BOOST_REQUIRE(error > 0);
|
||||
|
||||
// Test of legal node name change
|
||||
newid = "Node3";
|
||||
error = EN_setnodeid(ph, 3, (char *)newid.c_str());
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Test of illegal link name change
|
||||
newid = "Illegal; link name";
|
||||
error = EN_setlinkid(ph, 3, (char *)newid.c_str());
|
||||
BOOST_REQUIRE(error > 0);
|
||||
|
||||
// Test of legal link name change
|
||||
newid = "Link3";
|
||||
error = EN_setlinkid(ph, 3, (char *)newid.c_str());
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Save the project
|
||||
error = EN_saveinpfile(ph, "net1_setid.inp");
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
error = EN_close(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
EN_deleteproject(&ph);
|
||||
|
||||
// Re-open the saved project
|
||||
EN_createproject(&ph);
|
||||
error = EN_open(ph, "net1_setid.inp", path_rpt.c_str(), "");
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Check that 3rd node has its new name
|
||||
error = EN_getnodeindex(ph, "Node3", &index);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_REQUIRE(index == 3);
|
||||
|
||||
// Check that 3rd link has its new name
|
||||
error = EN_getlinkindex(ph, "Link3", &index);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_REQUIRE(index == 3);
|
||||
|
||||
error = EN_close(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
EN_deleteproject(&ph);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
100
tests/test_setlinktype.cpp
Normal file
100
tests/test_setlinktype.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
// Test of ENsetlinktype EPANET API Function
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
|
||||
/*
|
||||
This is a test for the API function that changes a link's type.
|
||||
Two links in Net1.inp are changed: Pipe 113 is reversed with a CV added
|
||||
and Pipe 121 is changed to a 100 psi PRV. After running the revised model,
|
||||
at hour 0 the flow in Pipe 113 should be zero and the pressure at node 31
|
||||
of the PRV 121 should be 100.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_MODULE "toolkit"
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include <string>
|
||||
#include "epanet2.h"
|
||||
|
||||
#define DATA_PATH_INP "./net1.inp"
|
||||
#define DATA_PATH_RPT "./test.rpt"
|
||||
#define DATA_PATH_OUT "./test.out"
|
||||
|
||||
using namespace std;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (test_toolkit)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_setlinktype)
|
||||
{
|
||||
int error = 0;
|
||||
int p113, n31, p121, n113_1, n113_2;
|
||||
float q113 = 0.0f, p31 = 0.0f, diam;
|
||||
|
||||
EN_ProjectHandle ph = NULL;
|
||||
EN_createproject(&ph);
|
||||
|
||||
std::string path_inp = std::string(DATA_PATH_INP);
|
||||
std::string path_rpt = std::string(DATA_PATH_RPT);
|
||||
std::string path_out = std::string(DATA_PATH_OUT);
|
||||
|
||||
error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), "");
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Change duration to 0
|
||||
error = EN_settimeparam(ph, EN_DURATION, 0);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Get indexes of pipe 113 and node 31
|
||||
error = EN_getlinkindex(ph, (char *)"113", &p113);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_getnodeindex(ph, (char *)"31", &n31);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Reverse pipe 113 and give it a check valve
|
||||
error = EN_getlinknodes(ph, p113, &n113_1, &n113_2);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_setlinknodes(ph, p113, n113_2, n113_1);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_setlinktype(ph, &p113, EN_CVPIPE);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Get index & diameter of pipe 121 connected to node 31
|
||||
error = EN_getlinkindex(ph, (char *)"121", &p121);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_getlinkvalue(ph, p121, EN_DIAMETER, &diam);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Replace it with a PRV
|
||||
error = EN_setlinktype(ph, &p121, EN_PRV);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Set diameter & setting of new PRV
|
||||
error = EN_setlinkvalue(ph, p121, EN_INITSETTING, 100);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_setlinkvalue(ph, p121, EN_DIAMETER, diam);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Solve for hydraulics
|
||||
error = EN_solveH(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Get flow in link 113 and pressure at node 31
|
||||
error = EN_getlinkvalue(ph, p113, EN_FLOW, &q113);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_getnodevalue(ph, n31, EN_PRESSURE, &p31);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Require that link 113 flow be 0
|
||||
q113 = fabs(q113);
|
||||
BOOST_REQUIRE(q113 < 0.001);
|
||||
|
||||
// Require that node 31 pressure be 100
|
||||
p31 = fabs(p31 - 100.0f);
|
||||
BOOST_REQUIRE(p31 < 0.001);
|
||||
|
||||
// Close and delete project
|
||||
error = EN_close(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
EN_deleteproject(&ph);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
@@ -13,6 +13,7 @@ EXPORTS
|
||||
ENgetlinkid = _ENgetlinkid@8
|
||||
ENgetlinkindex = _ENgetlinkindex@8
|
||||
ENgetlinknodes = _ENgetlinknodes@12
|
||||
ENsetlinknodes = _ENsetlinknodes@12
|
||||
ENgetlinktype = _ENgetlinktype@8
|
||||
ENgetlinkvalue = _ENgetlinkvalue@12
|
||||
ENgetnodeid = _ENgetnodeid@8
|
||||
|
||||
Reference in New Issue
Block a user