This example shows how simple it is for the Toolkit to provide a network analysis engine for other applications. There are three steps that the application would need to take:
- Have the application write network data to an EPANET-formatted input file.
- Create a project and call EN_runproject, supplying the name of the EPANET input file, the name of a Report file where status and error messages are written, and the name of a binary Output file which will contain analysis results.
- Have the application access the output file to display desired analysis results (see Output File).
Here is an example where a callback function writeConsole
is provided to write EPANET's progress messages to the console:
void writeConsole(char *s)
{
fprintf(stdout, "\n%s", s);
}
int runEpanet(char* inpFile, char* rptFile, char* outFile)
{
int errcode;
EN_project ph;
errcode =
EN_runproject(ph, inpFile, rptFile, outFile, &writeConsole);
return errcode;
}