Project Functions
These functions are used to manage a project.
| Function | Description |
|---|---|
open | Opens an EPANET input file & reads in network data. |
close | Closes a project and frees all of its memory. |
runProject | Runs a complete EPANET simulation. |
init | Initializes an EPANET project. |
getCount | Retrieves the number of objects of a given type in a project. |
getTitle | Retrieves the title lines of the project. |
setTitle | Sets the title lines of the project. |
saveInpFile | Saves a project’s data to an EPANET-formatted text file. |
runProject
Section titled “runProject”Runs a complete EPANET simulation.
runProject( inputFile: String, reportFile: String, outputFile: String ): voidParameters
| Parameter | Type | Description |
|---|---|---|
| inputFile | String | the name of an existing EPANET-formatted input file. |
| reportFile | String | the name of a report file to be created (or "" if not needed) |
| outputFile | String | the name of a binary output file to be created (or "" if not needed) |
Future versions of the epanetJS library will include the ability to attach a callback function similar to the EN_runproject function in OWA-EPANET.
Initializes an EPANET project.
init(rptFile: String, outFile: String, unitType: FlowUnits, headLosstype: HeadLossType): voidParameters
| Parameter | Type | Description |
|---|---|---|
| rptFile | String | the name of a report file to be created (or "" if not needed) |
| outFile | String | the name of a binary output file to be created (or "" if not needed). |
| unitType | FlowUnits | the choice of flow units (see FlowUnits) |
| headLosstype | HeadLossType | the choice of head loss formula (see HeadLossType) |
This function should be called immediately after a Project object is created if an EPANET-formatted input file will not be used to supply network data. If the project receives it’s network data from an input file then there is no need to call this function.
Opens an EPANET input file & reads in network data.
open(inputFile: String, reportFile: String, outputFile: String): voidParameters
| Parameter | Type | Description |
|---|---|---|
| inputFile | String | the name of an existing EPANET-formatted input file. |
| reportFile | String | the name of a report file to be created (or "" if not needed). |
| outputFile | String | the name of a binary output file to be created (or "" if not needed). |
getCount
Section titled “getCount”Retrieves the number of objects of a given type in a project.
getCount(obj: CountType): NumberParameters
| Parameter | Type | Description |
|---|---|---|
| obj | CountType | a type of object to count. (see CountType) |
Returns
Number
The number of objects of the specified type
getTitle
Section titled “getTitle”Retrieves the title lines of the project.
getTitle(): ObjectReturns
Object
{ line1: String; line2: String; line3: String;}| Property | Type | Description |
|---|---|---|
| line1 | String | first title line. |
| line2 | String | second title line. |
| line3 | String | third title line. |
setTitle
Section titled “setTitle”Sets the title lines of the project.
setTitle( line1: String, line2: String, line3: String): voidParameters
| Parameter | Type | Description |
|---|---|---|
| line1 | String | first title line. |
| line2 | String | second title line. |
| line3 | String | third title line. |
saveInpFile
Section titled “saveInpFile”Saves a project’s data to an EPANET-formatted text file.
saveInpFile( filename: String): voidParameters
| Parameter | Type | Description |
|---|---|---|
| filename | String | the name of the file to create. |
Closes a project and frees all of its memory.
close(): voidThis function clears all existing data from a project but does not delete the project, so it can be re-used with another set of network data.