OWA-EPANET Toolkit  2.2
Embedded Engine Example

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:

  1. Have the application write network data to an EPANET-formatted input file.
  2. 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.
  3. 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:

#include "epanet2_2.h"
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;
int EN_createproject(EN_Project *ph)
Creates an EPANET project.
int EN_runproject(EN_Project ph, const char *inpFile, const char *rptFile, const char *outFile, void(*pviewprog)(char *))
Runs a complete EPANET simulation.
int EN_deleteproject(EN_Project ph)
Deletes a currently opened EPANET project.