Skip to content

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

Runs a complete EPANET simulation.

runProject(
  inputFile: String,
  reportFile: String,
  outputFile: String
  ): void

Parameters

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.


init

Initializes an EPANET project.

init(rptFile: String, outFile: String, unitType: FlowUnits, headLosstype: HeadLossType): void

Parameters

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.


open

Opens an EPANET input file & reads in network data.

open(inputFile: String, reportFile: String, outputFile: String): void

Parameters

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

Retrieves the number of objects of a given type in a project.

getCount(obj: CountType): Number

Parameters

Parameter Type Description
obj CountType a type of object to count. (see CountType)

Returns

Number The number of objects of the specified type


getTitle

Retrieves the title lines of the project.

getTitle(): Object

Returns

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

Sets the title lines of the project.

setTitle( line1: String, line2: String, line3: String): void

Parameters

Parameter Type Description
line1 String first title line.
line2 String second title line.
line3 String third title line.

saveInpFile

Saves a project's data to an EPANET-formatted text file.

saveInpFile( filename: String): void

Parameters

Parameter Type Description
filename String the name of the file to create.

close

Closes a project and frees all of its memory.

close(): void

This 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.