OWA-EPANET Toolkit  2.2
Project Functions

These functions are used to manage a project. More...

Functions

int EN_createproject (EN_Project *ph)
 Creates an EPANET project. More...
 
int EN_deleteproject (EN_Project ph)
 Deletes a currently opened EPANET project. More...
 
int EN_runproject (EN_Project ph, const char *inpFile, const char *rptFile, const char *outFile, void(*pviewprog)(char *))
 Runs a complete EPANET simulation. More...
 
int EN_init (EN_Project ph, const char *rptFile, const char *outFile, int unitsType, int headLossType)
 Initializes an EPANET project. More...
 
int EN_open (EN_Project ph, const char *inpFile, const char *rptFile, const char *outFile)
 Opens an EPANET input file & reads in network data. More...
 
int EN_getcount (EN_Project ph, int object, int *out_count)
 Retrieves the number of objects of a given type in a project. More...
 
int EN_gettitle (EN_Project ph, char *out_line1, char *out_line2, char *out_line3)
 Retrieves the title lines of the project. More...
 
int EN_settitle (EN_Project ph, char *line1, char *line2, char *line3)
 Sets the title lines of the project. More...
 
int EN_saveinpfile (EN_Project ph, const char *filename)
 Saves a project's data to an EPANET-formatted text file. More...
 
int EN_close (EN_Project ph)
 Closes a project and frees all of its memory. More...
 

Overview

These functions are used to manage a project.

Function Documentation

◆ EN_close()

int EN_close ( EN_Project  ph)

Closes a project and frees all of its memory.

Parameters
phan EPANET project handle.
Returns
Error code

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. Use EN_deleteproject to actually delete a project from memory.

◆ EN_createproject()

int EN_createproject ( EN_Project ph)

Creates an EPANET project.

Parameters
[out]phan EPANET project handle that is passed into all other API functions.
Returns
an error code.

EN_createproject must be called before any other API functions are used.

◆ EN_deleteproject()

int EN_deleteproject ( EN_Project  ph)

Deletes a currently opened EPANET project.

Parameters
[in,out]phan EPANET project handle which is returned as NULL.
Returns
an error code.

EN_deleteproject should be called after all network analysis has been completed.

◆ EN_getcount()

int EN_getcount ( EN_Project  ph,
int  object,
int *  out_count 
)

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

Parameters
phan EPANET project handle.
objecta type of object to count (see EN_CountType)
[out]countnumber of objects of the specified type
Returns
an error code

◆ EN_gettitle()

int EN_gettitle ( EN_Project  ph,
char *  out_line1,
char *  out_line2,
char *  out_line3 
)

Retrieves the title lines of the project.

Parameters
phan EPANET project handle.
[out]out_line1first title line
[out]out_line2second title line
[out]out_line3third title line
Returns
an error code

◆ EN_init()

int EN_init ( EN_Project  ph,
const char *  rptFile,
const char *  outFile,
int  unitsType,
int  headLossType 
)

Initializes an EPANET project.

Parameters
phan EPANET project handle.
rptFilethe name of a report file to be created (or "" if not needed).
outFilethe name of a binary output file to be created (or "" if not needed).
unitsTypethe choice of flow units (see EN_FlowUnits).
headLossTypethe choice of head loss formula (see EN_HeadLossType).
Returns
an error code.

This function should be called immediately after EN_createproject 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.

◆ EN_open()

int EN_open ( EN_Project  ph,
const char *  inpFile,
const char *  rptFile,
const char *  outFile 
)

Opens an EPANET input file & reads in network data.

Parameters
phan EPANET project handle.
inpFilethe name of an existing EPANET-formatted input file.
rptFilethe name of a report file to be created (or "" if not needed).
outFilethe name of a binary output file to be created (or "" if not needed).
Returns
an error code.

This function should be called immediately after EN_createproject if an EPANET-formatted input file will be used to supply network data.

◆ EN_runproject()

int EN_runproject ( EN_Project  ph,
const char *  inpFile,
const char *  rptFile,
const char *  outFile,
void(*)(char *)  pviewprog 
)

Runs a complete EPANET simulation.

Parameters
phan EPANET project handle.
inpFilethe name of an existing EPANET-formatted input file.
rptFilethe name of a report file to be created (or "" if not needed)
outFilethe name of a binary output file to be created (or "" if not needed)
pviewproga callback function that takes a character string (char *) as its only parameter.
Returns
an error code

The callback function should reside in and be used by the calling code to display the progress messages that EPANET generates as it carries out its computations. Here is an example of a such a function that displays progress messages to stdout:

void writeConsole(char *s)
{
fprintf(stdout, "\n%s", s);
}

It would be passed into EN_runproject as &writeConsole. If this feature is not needed then the pviewprog argument should be NULL.

◆ EN_saveinpfile()

int EN_saveinpfile ( EN_Project  ph,
const char *  filename 
)

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

Parameters
phan EPANET project handle.
filenamethe name of the file to create.
Returns
Error code

◆ EN_settitle()

int EN_settitle ( EN_Project  ph,
char *  line1,
char *  line2,
char *  line3 
)

Sets the title lines of the project.

Parameters
phan EPANET project handle.
line1first title line
line2second title line
line3third title line
Returns
an error code