Skip to content

Project Functions

These functions are used to manage a project.

FunctionDescription
openOpens an EPANET input file & reads in network data.
closeCloses a project and frees all of its memory.
runProjectRuns a complete EPANET simulation.
initInitializes an EPANET project.
getCountRetrieves the number of objects of a given type in a project.
getTitleRetrieves the title lines of the project.
setTitleSets the title lines of the project.
saveInpFileSaves a project’s data to an EPANET-formatted text file.

Runs a complete EPANET simulation.

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

Parameters

ParameterTypeDescription
inputFileString the name of an existing EPANET-formatted input file.
reportFileString the name of a report file to be created (or "" if not needed)
outputFileString 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): void

Parameters

ParameterTypeDescription
rptFileStringthe name of a report file to be created (or "" if not needed)
outFileStringthe name of a binary output file to be created (or "" if not needed).
unitTypeFlowUnitsthe choice of flow units (see FlowUnits)
headLosstypeHeadLossTypethe 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): void

Parameters

ParameterTypeDescription
inputFile Stringthe name of an existing EPANET-formatted input file.
reportFileString the name of a report file to be created (or "" if not needed).
outputFile Stringthe name of a binary output file to be created (or "" if not needed).

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

getCount(obj: CountType): Number

Parameters

ParameterTypeDescription
objCountTypea type of object to count. (see CountType)

Returns

Number The number of objects of the specified type


Retrieves the title lines of the project.

getTitle(): Object

Returns

Object

{
line1: String;
line2: String;
line3: String;
}
PropertyTypeDescription
line1Stringfirst title line.
line2Stringsecond title line.
line3Stringthird title line.

Sets the title lines of the project.

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

Parameters

ParameterTypeDescription
line1Stringfirst title line.
line2Stringsecond title line.
line3Stringthird title line.

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

saveInpFile( filename: String): void

Parameters

ParameterTypeDescription
filenameString the name of the file to create.

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.