rethinking the python wrapper (#511)
* renames certain function parameter declarations and removes double pointer call from the deleteproject function * deprecates conditonal compilation, removes python-specific headers and function renaming * fixes tests and docs * fixes test
This commit is contained in:
@@ -81,7 +81,6 @@ IF (MSVC)
|
|||||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||||
ENDIF (MSVC)
|
ENDIF (MSVC)
|
||||||
|
|
||||||
|
|
||||||
# configure file groups
|
# configure file groups
|
||||||
file(GLOB EPANET_SOURCES RELATIVE ${PROJECT_SOURCE_DIR} src/*.c src/util/*.c)
|
file(GLOB EPANET_SOURCES RELATIVE ${PROJECT_SOURCE_DIR} src/*.c src/util/*.c)
|
||||||
file(GLOB EPANET_LIB_ALL RELATIVE ${PROJECT_SOURCE_DIR} src/* src/util/*)
|
file(GLOB EPANET_LIB_ALL RELATIVE ${PROJECT_SOURCE_DIR} src/* src/util/*)
|
||||||
@@ -89,49 +88,12 @@ file(GLOB EPANET_LIB_ALL RELATIVE ${PROJECT_SOURCE_DIR} src/* src/util/*)
|
|||||||
list(REMOVE_ITEM EPANET_LIB_ALL "src/epanet_py.c")
|
list(REMOVE_ITEM EPANET_LIB_ALL "src/epanet_py.c")
|
||||||
source_group("Library" FILES ${EPANET_LIB_ALL})
|
source_group("Library" FILES ${EPANET_LIB_ALL})
|
||||||
|
|
||||||
|
# the shared library
|
||||||
# create build target for epanet library with python API
|
IF("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)" OR NOT MSVC)
|
||||||
IF (BUILD_PY_LIB)
|
|
||||||
|
|
||||||
# exclude legacy epanet 2.0 API and include epanet py API
|
|
||||||
list(REMOVE_ITEM EPANET_LIB_ALL "src/epanet2.c")
|
|
||||||
add_library(epanet_py SHARED ${EPANET_LIB_ALL} src/epanet_py.c src/util/errormanager.c)
|
|
||||||
target_include_directories(epanet_py PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
|
||||||
|
|
||||||
include(GenerateExportHeader)
|
|
||||||
GENERATE_EXPORT_HEADER(epanet_py
|
|
||||||
BASE_NAME epanet_py
|
|
||||||
EXPORT_MACRO_NAME EXPORT_PY_API
|
|
||||||
EXPORT_FILE_NAME epanet_py_export.h
|
|
||||||
STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC)
|
|
||||||
|
|
||||||
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/epanet_py_export.h
|
|
||||||
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
||||||
|
|
||||||
|
|
||||||
# create build target for code coverage
|
|
||||||
ELSEIF (BUILD_COVERAGE)
|
|
||||||
|
|
||||||
include(CodeCoverage)
|
|
||||||
set(CMAKE_BUILD_TYPE "Debug")
|
|
||||||
APPEND_COVERAGE_COMPILER_FLAGS()
|
|
||||||
set(CMAKE_C_FLAGS_DEBUG "-O0")
|
|
||||||
|
|
||||||
add_library(epanet2 SHARED ${EPANET_LIB_ALL})
|
|
||||||
target_include_directories(epanet2 PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
|
||||||
|
|
||||||
|
|
||||||
# create build target for default epanet library with 2.0 and 2.2 API
|
|
||||||
ELSE (BUILD_PY_LIB)
|
|
||||||
|
|
||||||
# the shared library
|
|
||||||
IF("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)" OR NOT MSVC)
|
|
||||||
add_library(epanet2 SHARED ${EPANET_LIB_ALL})
|
add_library(epanet2 SHARED ${EPANET_LIB_ALL})
|
||||||
ELSE(TRUE)
|
ELSE(TRUE)
|
||||||
add_library(epanet2 SHARED ${EPANET_LIB_ALL} ${PROJECT_SOURCE_DIR}/include/epanet2.def)
|
add_library(epanet2 SHARED ${EPANET_LIB_ALL} ${PROJECT_SOURCE_DIR}/include/epanet2.def)
|
||||||
set_source_files_properties(${PROJECT_SOURCE_DIR}/include/epanet2.def PROPERTIES_HEADER_FILE_ONLY TRUE)
|
set_source_files_properties(${PROJECT_SOURCE_DIR}/include/epanet2.def PROPERTIES_HEADER_FILE_ONLY TRUE)
|
||||||
ENDIF("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)" OR NOT MSVC)
|
ENDIF("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)" OR NOT MSVC)
|
||||||
|
|
||||||
target_include_directories(epanet2 PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
target_include_directories(epanet2 PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
ENDIF (BUILD_PY_LIB)
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ int runEpanet(char *finp, char *frpt)
|
|||||||
if (!err) err = EN_solveH(ph);
|
if (!err) err = EN_solveH(ph);
|
||||||
if (!err) err = EN_report(ph);
|
if (!err) err = EN_report(ph);
|
||||||
EN_close(ph);
|
EN_close(ph);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -68,7 +68,7 @@ int buildandrunEpanet(char *rptfile)
|
|||||||
|
|
||||||
// Close and delete the project
|
// Close and delete the project
|
||||||
EN_close(ph);
|
EN_close(ph);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ These are the toolkit's enumerated types whose members are used as function argu
|
|||||||
@addtogroup Project
|
@addtogroup Project
|
||||||
@{
|
@{
|
||||||
@fn int EN_createproject(EN_Project *ph)
|
@fn int EN_createproject(EN_Project *ph)
|
||||||
@fn int EN_deleteproject(EN_Project *ph)
|
@fn int EN_deleteproject(EN_Project ph)
|
||||||
@fn int EN_runproject(EN_Project ph, const char *f1, const char *f2, const char *f3, void (*pviewprog)(char *))
|
@fn int EN_runproject(EN_Project ph, const char *f1, const char *f2, const char *f3, void (*pviewprog)(char *))
|
||||||
@fn int EN_init(EN_Project ph, const char *rptFile, const char *outFile, int unitsType, int headLossType)
|
@fn int EN_init(EN_Project ph, const char *rptFile, const char *outFile, int unitsType, int headLossType)
|
||||||
@fn int EN_open(EN_Project ph, const char *inpFile, const char *rptFile, const char *binOutFile)
|
@fn int EN_open(EN_Project ph, const char *inpFile, const char *rptFile, const char *binOutFile)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ int runEpanet(char* inpFile, char* rptFile, char* outFile)
|
|||||||
EN_project ph;
|
EN_project ph;
|
||||||
EN_createproject(&pH);
|
EN_createproject(&pH);
|
||||||
errcode = EN_runproject(ph, inpFile, rptFile, outFile, &writeConsole);
|
errcode = EN_runproject(ph, inpFile, rptFile, outFile, &writeConsole);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
return errcode;
|
return errcode;
|
||||||
}
|
}
|
||||||
\endcode
|
\endcode
|
||||||
@@ -109,7 +109,7 @@ void netbuilder()
|
|||||||
EN_saveinpfile(ph, "example2.inp");
|
EN_saveinpfile(ph, "example2.inp");
|
||||||
|
|
||||||
// Delete the project
|
// Delete the project
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
\endcode
|
\endcode
|
||||||
*/
|
*/
|
||||||
@@ -154,7 +154,7 @@ void HydrantRating(char *MyNode, int N, double D[], double P[])
|
|||||||
|
|
||||||
// Close hydraulics solver & delete the project
|
// Close hydraulics solver & delete the project
|
||||||
EN_closeH(ph);
|
EN_closeH(ph);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
\endcode
|
\endcode
|
||||||
*/
|
*/
|
||||||
@@ -221,7 +221,7 @@ double cl2dose(char *SourceID, double Ctarget)
|
|||||||
|
|
||||||
// Close up the WQ solver and delete the project
|
// Close up the WQ solver and delete the project
|
||||||
EN_closeQ(ph);
|
EN_closeQ(ph);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
return csource;
|
return csource;
|
||||||
}
|
}
|
||||||
\endcode
|
\endcode
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ EN_createproject(&ph);
|
|||||||
|
|
||||||
// Call functions that perform desired analysis
|
// Call functions that perform desired analysis
|
||||||
|
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
@section DetectingErrors Detecting Error Conditions
|
@section DetectingErrors Detecting Error Conditions
|
||||||
@@ -52,7 +52,7 @@ if (errcode == 0)
|
|||||||
{
|
{
|
||||||
// Call functions that perform desired analysis
|
// Call functions that perform desired analysis
|
||||||
}
|
}
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
After an input file has been loaded in this fashion the resulting network can have objects added or deleted, and their properties set using the various Toolkit functions .
|
After an input file has been loaded in this fashion the resulting network can have objects added or deleted, and their properties set using the various Toolkit functions .
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ typedef struct Project *EN_Project;
|
|||||||
|
|
||||||
EN_deleteproject should be called after all network analysis has been completed.
|
EN_deleteproject should be called after all network analysis has been completed.
|
||||||
*/
|
*/
|
||||||
int DLLEXPORT EN_deleteproject(EN_Project *ph);
|
int DLLEXPORT EN_deleteproject(EN_Project ph);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Runs a complete EPANET simulation.
|
@brief Runs a complete EPANET simulation.
|
||||||
@@ -94,7 +94,7 @@ typedef struct Project *EN_Project;
|
|||||||
the pviewprog argument should be `NULL`.
|
the pviewprog argument should be `NULL`.
|
||||||
*/
|
*/
|
||||||
int DLLEXPORT EN_runproject(EN_Project ph, const char *inpFile, const char *rptFile,
|
int DLLEXPORT EN_runproject(EN_Project ph, const char *inpFile, const char *rptFile,
|
||||||
const char *outFile, void (*pviewprog)(char *));
|
const char *outputFile, void (*pviewprog)(char *));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Initializes an EPANET project.
|
@brief Initializes an EPANET project.
|
||||||
@@ -134,7 +134,7 @@ typedef struct Project *EN_Project;
|
|||||||
@param[out] line3 third title line
|
@param[out] line3 third title line
|
||||||
@return an error code
|
@return an error code
|
||||||
*/
|
*/
|
||||||
int DLLEXPORT EN_gettitle(EN_Project ph, char *line1, char *line2, char *line3);
|
int DLLEXPORT EN_gettitle(EN_Project ph, char *out_line1, char *out_line2, char *out_line3);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Sets the title lines of the project
|
@brief Sets the title lines of the project
|
||||||
@@ -154,7 +154,7 @@ typedef struct Project *EN_Project;
|
|||||||
@param[out] comment the comment string assigned to the object
|
@param[out] comment the comment string assigned to the object
|
||||||
@return an error code
|
@return an error code
|
||||||
*/
|
*/
|
||||||
int DLLEXPORT EN_getcomment(EN_Project ph, int object, int index, char *comment);
|
int DLLEXPORT EN_getcomment(EN_Project ph, int object, int index, char *out_comment);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Assigns a descriptive comment to a Node, Link, Pattern or Curve.
|
@brief Assigns a descriptive comment to a Node, Link, Pattern or Curve.
|
||||||
@@ -627,7 +627,7 @@ typedef struct Project *EN_Project;
|
|||||||
|
|
||||||
Error message strings should be at least @ref EN_SizeLimits "EN_MAXMSG" characters in length.
|
Error message strings should be at least @ref EN_SizeLimits "EN_MAXMSG" characters in length.
|
||||||
*/
|
*/
|
||||||
int DLLEXPORT EN_geterror(int errcode, char *errmsg, int maxLen);
|
int DLLEXPORT EN_geterror(int errcode, char *out_errmsg, int maxLen);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Retrieves a particular simulation statistic.
|
@brief Retrieves a particular simulation statistic.
|
||||||
@@ -712,8 +712,8 @@ typedef struct Project *EN_Project;
|
|||||||
@param[out] traceNode index of the node being traced (if applicable).
|
@param[out] traceNode index of the node being traced (if applicable).
|
||||||
@return an error code.
|
@return an error code.
|
||||||
*/
|
*/
|
||||||
int DLLEXPORT EN_getqualinfo(EN_Project ph, int *qualType, char *chemName,
|
int DLLEXPORT EN_getqualinfo(EN_Project ph, int *qualType, char *out_chemName,
|
||||||
char *chemUnits, int *traceNode);
|
char *out_chemUnits, int *traceNode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Retrieves the type of water quality analysis to be run.
|
@brief Retrieves the type of water quality analysis to be run.
|
||||||
@@ -792,7 +792,7 @@ typedef struct Project *EN_Project;
|
|||||||
|
|
||||||
The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
|
The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
|
||||||
*/
|
*/
|
||||||
int DLLEXPORT EN_getnodeid(EN_Project ph, int index, char *id);
|
int DLLEXPORT EN_getnodeid(EN_Project ph, int index, char *out_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Changes the ID name of a node.
|
@brief Changes the ID name of a node.
|
||||||
@@ -1037,7 +1037,7 @@ typedef struct Project *EN_Project;
|
|||||||
|
|
||||||
\b demandName must be sized to contain at least @ref EN_SizeLimits "EN_MAXID" characters.
|
\b demandName must be sized to contain at least @ref EN_SizeLimits "EN_MAXID" characters.
|
||||||
*/
|
*/
|
||||||
int DLLEXPORT EN_getdemandname(EN_Project ph, int nodeIndex, int demandIndex, char *demandName);
|
int DLLEXPORT EN_getdemandname(EN_Project ph, int nodeIndex, int demandIndex, char *out_demandName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Assigns a name to a node's demand category.
|
@brief Assigns a name to a node's demand category.
|
||||||
@@ -1116,7 +1116,7 @@ typedef struct Project *EN_Project;
|
|||||||
|
|
||||||
The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
|
The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
|
||||||
*/
|
*/
|
||||||
int DLLEXPORT EN_getlinkid(EN_Project ph, int index, char *id);
|
int DLLEXPORT EN_getlinkid(EN_Project ph, int index, char *out_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Changes the ID name of a link.
|
@brief Changes the ID name of a link.
|
||||||
@@ -1151,7 +1151,7 @@ typedef struct Project *EN_Project;
|
|||||||
\b EN_CONDITIONAL then the type change is cancelled if the link appears in any
|
\b EN_CONDITIONAL then the type change is cancelled if the link appears in any
|
||||||
control and error 261 is returned.
|
control and error 261 is returned.
|
||||||
*/
|
*/
|
||||||
int DLLEXPORT EN_setlinktype(EN_Project ph, int *index, int linkType, int actionCode);
|
int DLLEXPORT EN_setlinktype(EN_Project ph, int *inout_index, int linkType, int actionCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Gets the indexes of a link's start- and end-nodes.
|
@brief Gets the indexes of a link's start- and end-nodes.
|
||||||
@@ -1288,7 +1288,7 @@ typedef struct Project *EN_Project;
|
|||||||
|
|
||||||
The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
|
The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
|
||||||
*/
|
*/
|
||||||
int DLLEXPORT EN_getpatternid(EN_Project ph, int index, char *id);
|
int DLLEXPORT EN_getpatternid(EN_Project ph, int index, char *out_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Changes the ID name of a time pattern given its index.
|
@brief Changes the ID name of a time pattern given its index.
|
||||||
@@ -1396,7 +1396,7 @@ typedef struct Project *EN_Project;
|
|||||||
|
|
||||||
The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
|
The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
|
||||||
*/
|
*/
|
||||||
int DLLEXPORT EN_getcurveid(EN_Project ph, int index, char *id);
|
int DLLEXPORT EN_getcurveid(EN_Project ph, int index, char *out_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Changes the ID name of a data curve given its index.
|
@brief Changes the ID name of a data curve given its index.
|
||||||
@@ -1465,7 +1465,7 @@ typedef struct Project *EN_Project;
|
|||||||
to hold `nPoints` number of data points and for sizing `id` to hold at least
|
to hold `nPoints` number of data points and for sizing `id` to hold at least
|
||||||
@ref EN_SizeLimits "EN_MAXID" characters.
|
@ref EN_SizeLimits "EN_MAXID" characters.
|
||||||
*/
|
*/
|
||||||
int DLLEXPORT EN_getcurve(EN_Project ph, int index, char* id, int *nPoints,
|
int DLLEXPORT EN_getcurve(EN_Project ph, int index, char *out_id, int *nPoints,
|
||||||
double *xValues, double *yValues);
|
double *xValues, double *yValues);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1595,7 +1595,7 @@ typedef struct Project *EN_Project;
|
|||||||
|
|
||||||
The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
|
The ID name must be sized to hold at least @ref EN_SizeLimits "EN_MAXID" characters.
|
||||||
*/
|
*/
|
||||||
int DLLEXPORT EN_getruleID(EN_Project ph, int index, char* id);
|
int DLLEXPORT EN_getruleID(EN_Project ph, int index, char *out_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Gets the properties of a premise in a rule-based control.
|
@brief Gets the properties of a premise in a rule-based control.
|
||||||
|
|||||||
@@ -1,178 +0,0 @@
|
|||||||
/*
|
|
||||||
******************************************************************************
|
|
||||||
Project: OWA EPANET
|
|
||||||
Version: 2.2
|
|
||||||
Module: epanet_py.h
|
|
||||||
Description: EPANET API functions for Python SWIG wrap
|
|
||||||
Authors: see AUTHORS
|
|
||||||
Copyright: see AUTHORS
|
|
||||||
License: see LICENSE
|
|
||||||
Last Updated: 02/08/2019
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef EPANET_PY_H
|
|
||||||
#define EPANET_PY_H
|
|
||||||
|
|
||||||
|
|
||||||
// Opaque pointer to project
|
|
||||||
typedef void *Handle;
|
|
||||||
|
|
||||||
|
|
||||||
#include "epanet2_enums.h"
|
|
||||||
#include "epanet_py_export.h"
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API proj_create(Handle *ph_out);
|
|
||||||
int EXPORT_PY_API proj_delete(Handle *ph_inout);
|
|
||||||
int EXPORT_PY_API proj_run(Handle ph, const char *input_path, const char *report_path, const char *output_path);
|
|
||||||
int EXPORT_PY_API proj_init(Handle ph, const char *rptFile, const char *outFile, EN_FlowUnits unitsType, EN_HeadLossType headLossType);
|
|
||||||
int EXPORT_PY_API proj_open(Handle ph, const char *inpFile, const char *rptFile, const char *binOutFile);
|
|
||||||
int EXPORT_PY_API proj_gettitle(Handle ph, char *line1, char *line2, char *line3);
|
|
||||||
int EXPORT_PY_API proj_settitle(Handle ph, const char *line1, const char *line2, const char *line3);
|
|
||||||
int EXPORT_PY_API proj_getcount(Handle ph, EN_CountType code, int *count);
|
|
||||||
int EXPORT_PY_API proj_savefile(Handle ph, const char *inpfilename);
|
|
||||||
int EXPORT_PY_API proj_close(Handle ph);
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API hydr_solve(Handle ph);
|
|
||||||
int EXPORT_PY_API hydr_save(Handle ph);
|
|
||||||
int EXPORT_PY_API hydr_open(Handle ph);
|
|
||||||
int EXPORT_PY_API hydr_init(Handle ph, EN_InitHydOption saveFlag);
|
|
||||||
int EXPORT_PY_API hydr_run(Handle ph, long *currentTime);
|
|
||||||
int EXPORT_PY_API hydr_next(Handle ph, long *tStep);
|
|
||||||
int EXPORT_PY_API hydr_close(Handle ph);
|
|
||||||
int EXPORT_PY_API hydr_savefile(Handle ph, char *filename);
|
|
||||||
int EXPORT_PY_API hydr_usefile(Handle ph, char *filename);
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API qual_solve(Handle ph);
|
|
||||||
int EXPORT_PY_API qual_open(Handle ph);
|
|
||||||
int EXPORT_PY_API qual_init(Handle ph, EN_InitHydOption saveFlag);
|
|
||||||
int EXPORT_PY_API qual_run(Handle ph, long *currentTime);
|
|
||||||
int EXPORT_PY_API qual_next(Handle ph, long *tStep);
|
|
||||||
int EXPORT_PY_API qual_step(Handle ph, long *timeLeft);
|
|
||||||
int EXPORT_PY_API qual_close(Handle ph);
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API rprt_writeline(Handle ph, char *line);
|
|
||||||
int EXPORT_PY_API rprt_writeresults(Handle ph);
|
|
||||||
int EXPORT_PY_API rprt_clear(Handle ph);
|
|
||||||
int EXPORT_PY_API rprt_reset(Handle ph);
|
|
||||||
int EXPORT_PY_API rprt_set(Handle ph, char *reportCommand);
|
|
||||||
int EXPORT_PY_API rprt_setlevel(Handle ph, EN_StatusReport code);
|
|
||||||
int EXPORT_PY_API rprt_anlysstats(Handle ph, EN_AnalysisStatistic code, double* value);
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API anlys_getoption(Handle ph, EN_Option code, double *value);
|
|
||||||
int EXPORT_PY_API anlys_setoption(Handle ph, EN_Option code, double value);
|
|
||||||
int EXPORT_PY_API anlys_getflowunits(Handle ph, int *code);
|
|
||||||
int EXPORT_PY_API anlys_setflowunits(Handle ph, EN_FlowUnits code);
|
|
||||||
int EXPORT_PY_API anlys_gettimeparam(Handle ph, EN_TimeParameter code, long *value);
|
|
||||||
int EXPORT_PY_API anlys_settimeparam(Handle ph, EN_TimeParameter code, long value);
|
|
||||||
int EXPORT_PY_API anlys_getqualinfo(Handle ph, int *qualcode, char *chemname, char *chemunits, int *tracenode);
|
|
||||||
int EXPORT_PY_API anlys_getqualtype(Handle ph, int *qualcode, int *tracenode);
|
|
||||||
int EXPORT_PY_API anlys_setqualtype(Handle ph, EN_QualityType qualcode, char *chemname, char *chemunits, char *tracenode);
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API node_add(Handle ph, char *id, EN_NodeType nodeType, int *index);
|
|
||||||
int EXPORT_PY_API node_delete(Handle ph, int index, int actionCode);
|
|
||||||
int EXPORT_PY_API node_getindex(Handle ph, char *id, int *index);
|
|
||||||
int EXPORT_PY_API node_getid(Handle ph, int index, char *id);
|
|
||||||
int EXPORT_PY_API node_setid(Handle ph, int index, char *newid);
|
|
||||||
int EXPORT_PY_API node_gettype(Handle ph, int index, int *code);
|
|
||||||
int EXPORT_PY_API node_getvalue(Handle ph, int index, EN_NodeProperty code, double *value);
|
|
||||||
int EXPORT_PY_API node_setvalue(Handle ph, int index, EN_NodeProperty code, double value);
|
|
||||||
int EXPORT_PY_API node_getcoord(Handle ph, int index, double *x, double *y);
|
|
||||||
int EXPORT_PY_API node_setcoord(Handle ph, int index, double x, double y);
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API dmnd_getmodel(Handle ph, int *type, double *pmin, double *preq, double *pexp);
|
|
||||||
int EXPORT_PY_API dmnd_setmodel(Handle ph, int type, double pmin, double preq, double pexp);
|
|
||||||
int EXPORT_PY_API dmnd_getcount(Handle ph, int nodeIndex, int *numDemands);
|
|
||||||
int EXPORT_PY_API dmnd_getbase(Handle ph, int nodeIndex, int demandIndex, double *baseDemand);
|
|
||||||
int EXPORT_PY_API dmnd_setbase(Handle ph, int nodeIndex, int demandIndex, double baseDemand);
|
|
||||||
int EXPORT_PY_API dmnd_getpattern(Handle ph, int nodeIndex, int demandIndex, int *pattIndex);
|
|
||||||
int EXPORT_PY_API dmnd_setpattern(Handle ph, int nodeIndex, int demandIndex, int patIndex);
|
|
||||||
int EXPORT_PY_API dmnd_getname(Handle ph, int nodeIndex, int demandIdx, char *demandName);
|
|
||||||
int EXPORT_PY_API dmnd_setname(Handle ph, int nodeIndex, int demandIdx, char *demandName);
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API link_add(Handle ph, char *id, EN_LinkType linkType, char *fromNode, char *toNode, int *index);
|
|
||||||
int EXPORT_PY_API link_delete(Handle ph, int index, int actionCode);
|
|
||||||
int EXPORT_PY_API link_getindex(Handle ph, char *id, int *index);
|
|
||||||
int EXPORT_PY_API link_getid(Handle ph, int index, char *id);
|
|
||||||
int EXPORT_PY_API link_setid(Handle ph, int index, char *newid);
|
|
||||||
int EXPORT_PY_API link_gettype(Handle ph, int index, int *code);
|
|
||||||
int EXPORT_PY_API link_settype(Handle ph, int *index, EN_LinkType type, int actionCode);
|
|
||||||
int EXPORT_PY_API link_getnodes(Handle ph, int index, int *node1, int *node2);
|
|
||||||
int EXPORT_PY_API link_setnodes(Handle ph, int index, int node1, int node2);
|
|
||||||
int EXPORT_PY_API link_getvalue(Handle ph, int index, EN_LinkProperty code, double *value);
|
|
||||||
int EXPORT_PY_API link_setvalue(Handle ph, int index, int code, double v);
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API pump_gettype(Handle ph, int linkIndex, int *outType);
|
|
||||||
int EXPORT_PY_API pump_getheadcurveindex(Handle ph, int pumpIndex, int *curveIndex);
|
|
||||||
int EXPORT_PY_API pump_setheadcurveindex(Handle ph, int pumpIndex, int curveIndex);
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API ptrn_add(Handle ph, char *id);
|
|
||||||
int EXPORT_PY_API ptrn_getindex(Handle ph, char *id, int *index);
|
|
||||||
int EXPORT_PY_API ptrn_getid(Handle ph, int index, char *id);
|
|
||||||
int EXPORT_PY_API ptrn_getlength(Handle ph, int index, int *len);
|
|
||||||
int EXPORT_PY_API ptrn_getvalue(Handle ph, int index, int period, double *value);
|
|
||||||
int EXPORT_PY_API ptrn_setvalue(Handle ph, int index, int period, double value);
|
|
||||||
int EXPORT_PY_API ptrn_getavgvalue(Handle ph, int index, double *value);
|
|
||||||
int EXPORT_PY_API ptrn_set(Handle ph, int index, double *f, int len);
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API curv_add(Handle ph, char *id);
|
|
||||||
int EXPORT_PY_API curv_getindex(Handle ph, char *id, int *index);
|
|
||||||
int EXPORT_PY_API curv_getid(Handle ph, int index, char *id);
|
|
||||||
int EXPORT_PY_API curv_getlength(Handle ph, int index, int *len);
|
|
||||||
int EXPORT_PY_API curv_gettype(Handle ph, int curveIndex, int *outType);
|
|
||||||
int EXPORT_PY_API curv_getvalue(Handle ph, int curveIndex, int pointIndex, double *x, double *y);
|
|
||||||
int EXPORT_PY_API curv_setvalue(Handle ph, int curveIndex, int pointIndex, double x, double y);
|
|
||||||
int EXPORT_PY_API curv_get(Handle ph, int curveIndex, char* id, int *nValues, double *xValues, double *yValues);
|
|
||||||
int EXPORT_PY_API curv_set(Handle ph, int index, double *x, double *y, int len);
|
|
||||||
|
|
||||||
int EXPORT_PY_API scntl_add(Handle ph, int type, int linkIndex, double setting, int nodeIndex, double level, int *index);
|
|
||||||
int EXPORT_PY_API scntl_delete(Handle ph, int index);
|
|
||||||
int EXPORT_PY_API scntl_get(Handle ph, int controlIndex, int *controlType, int *linkIndex, double *setting, int *nodeIndex, double *level);
|
|
||||||
int EXPORT_PY_API scntl_set(Handle ph, int cindex, int ctype, int lindex, double setting, int nindex, double level);
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API rcntl_add(Handle ph, char *rule);
|
|
||||||
int EXPORT_PY_API rcntl_delete(Handle ph, int index);
|
|
||||||
int EXPORT_PY_API rcntl_get(Handle ph, int index, int *nPremises, int *nThenActions, int *nElseActions, double *priority);
|
|
||||||
int EXPORT_PY_API rcntl_getid(Handle ph, int index, char* id);
|
|
||||||
int EXPORT_PY_API rcntl_getpremise(Handle ph, int ruleIndex, int premiseIndex, int *logop, int *object, int *objIndex, int *variable, int *relop, int *status, double *value);
|
|
||||||
int EXPORT_PY_API rcntl_setpremise(Handle ph, int ruleIndex, int premiseIndex, int logop, int object, int objIndex, int variable, int relop, int status, double value);
|
|
||||||
int EXPORT_PY_API rcntl_setpremiseindex(Handle ph, int ruleIndex, int premiseIndex, int objIndex);
|
|
||||||
int EXPORT_PY_API rcntl_setpremisestatus(Handle ph, int ruleIndex, int premiseIndex, int status);
|
|
||||||
int EXPORT_PY_API rcntl_setpremisevalue(Handle ph, int ruleIndex, int premiseIndex, double value);
|
|
||||||
int EXPORT_PY_API rcntl_getthenaction(Handle ph, int ruleIndex, int actionIndex, int *linkIndex, int *status, double *setting);
|
|
||||||
int EXPORT_PY_API rcntl_setthenaction(Handle ph, int ruleIndex, int actionIndex, int linkIndex, int status, double setting);
|
|
||||||
int EXPORT_PY_API rcntl_getelseaction(Handle ph, int ruleIndex, int actionIndex, int *linkIndex, int *status, double *setting);
|
|
||||||
int EXPORT_PY_API rcntl_setelseaction(Handle ph, int ruleIndex, int actionIndex, int linkIndex, int status, double setting);
|
|
||||||
int EXPORT_PY_API rcntl_setrulepriority(Handle ph, int index, double priority);
|
|
||||||
|
|
||||||
|
|
||||||
void EXPORT_PY_API err_clear(Handle ph);
|
|
||||||
int EXPORT_PY_API err_check(Handle ph, char** msg_buffer);
|
|
||||||
void EXPORT_PY_API toolkit_free(void **memory);
|
|
||||||
int EXPORT_PY_API toolkit_getversion(int *version);
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif //EPANET_PY_H
|
|
||||||
18
src/epanet.c
18
src/epanet.c
@@ -51,7 +51,7 @@ int DLLEXPORT EN_createproject(EN_Project *p)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT EN_deleteproject(EN_Project *p)
|
int DLLEXPORT EN_deleteproject(EN_Project p)
|
||||||
/*----------------------------------------------------------------
|
/*----------------------------------------------------------------
|
||||||
** Input: none
|
** Input: none
|
||||||
** Output: none
|
** Output: none
|
||||||
@@ -60,13 +60,15 @@ int DLLEXPORT EN_deleteproject(EN_Project *p)
|
|||||||
**----------------------------------------------------------------
|
**----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
if (*p == NULL) return -1;
|
if (p == NULL) return -1;
|
||||||
if ((*p)->Openflag) EN_close(*p);
|
if (p->Openflag) {
|
||||||
remove((*p)->TmpHydFname);
|
EN_close(p);
|
||||||
remove((*p)->TmpOutFname);
|
}
|
||||||
remove((*p)->TmpStatFname);
|
remove(p->TmpHydFname);
|
||||||
free(*p);
|
remove(p->TmpOutFname);
|
||||||
*p = NULL;
|
remove(p->TmpStatFname);
|
||||||
|
free(p);
|
||||||
|
p = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
809
src/epanet_py.c
809
src/epanet_py.c
@@ -1,809 +0,0 @@
|
|||||||
/*
|
|
||||||
******************************************************************************
|
|
||||||
Project: OWA EPANET
|
|
||||||
Version: 2.2
|
|
||||||
Module: epanet_py.c
|
|
||||||
Description: EPANET API functions for Python SWIG wrap
|
|
||||||
Authors: see AUTHORS
|
|
||||||
Copyright: see AUTHORS
|
|
||||||
License: see LICENSE
|
|
||||||
Last Updated: 05/15/2019
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "epanet_py.h"
|
|
||||||
#include "util/errormanager.h"
|
|
||||||
#include "epanet2_2.h"
|
|
||||||
#include "text.h"
|
|
||||||
#include "types.h"
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
Project *project;
|
|
||||||
error_handle_t *error;
|
|
||||||
} handle_t;
|
|
||||||
|
|
||||||
// Extern functions
|
|
||||||
extern char *geterrmsg(int, char *);
|
|
||||||
|
|
||||||
// Local functions
|
|
||||||
void error_lookup(int errcode, char *errmsg, int len);
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API proj_create(Handle *ph)
|
|
||||||
{
|
|
||||||
handle_t *handle = (handle_t *)calloc(1, sizeof(handle_t));
|
|
||||||
|
|
||||||
if (handle != NULL)
|
|
||||||
{
|
|
||||||
EN_createproject(&handle->project);
|
|
||||||
handle->error = create_error_manager(&error_lookup);
|
|
||||||
*ph = handle;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API proj_delete(Handle *ph)
|
|
||||||
{
|
|
||||||
handle_t *handle = (handle_t *)*ph;
|
|
||||||
|
|
||||||
if (handle == NULL)
|
|
||||||
return -1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EN_deleteproject(&handle->project);
|
|
||||||
delete_error_manager(handle->error);
|
|
||||||
}
|
|
||||||
free(handle);
|
|
||||||
*ph = NULL;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API proj_run(Handle ph, const char *input_path,
|
|
||||||
const char *report_path, const char *output_path)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_runproject(pr->project, input_path, report_path, output_path, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API proj_init(Handle ph, const char *rptFile, const char *outFile,
|
|
||||||
EN_FlowUnits unitsType, EN_HeadLossType headLossType)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_init(pr->project, rptFile, outFile, unitsType, headLossType));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API proj_open(Handle ph, const char *inpFile, const char *rptFile,
|
|
||||||
const char *binOutFile)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_open(pr->project, inpFile, rptFile, binOutFile));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API proj_gettitle(Handle ph, char *line1, char *line2, char *line3)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_gettitle(pr->project, line1, line2, line3));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API proj_settitle(Handle ph, const char *line1, const char *line2, const char *line3)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_settitle(pr->project, (char *)line1, (char *)line2, (char *)line3));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API proj_getcount(Handle ph, EN_CountType code, int *count)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getcount(pr->project, code, count));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API proj_savefile(Handle ph, const char *filename)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_saveinpfile(pr->project, filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API proj_close(Handle ph)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_close(pr->project));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API hydr_solve(Handle ph)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_solveH(pr->project));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API hydr_save(Handle ph)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_saveH(pr->project));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API hydr_open(Handle ph)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_openH(pr->project));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API hydr_init(Handle ph, EN_InitHydOption saveFlag)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_initH(pr->project, saveFlag));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API hydr_run(Handle ph, long *currentTime)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_runH(pr->project, currentTime));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API hydr_next(Handle ph, long *tStep)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_nextH(pr->project, tStep));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API hydr_close(Handle ph)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_closeH(pr->project));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API hydr_savefile(Handle ph, char *filename)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_savehydfile(pr->project, filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API hydr_usefile(Handle ph, char *filename)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_usehydfile(pr->project, filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API qual_solve(Handle ph)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_solveQ(pr->project));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API qual_open(Handle ph)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_openQ(pr->project));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API qual_init(Handle ph, EN_InitHydOption saveFlag)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_initQ(pr->project, saveFlag));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API qual_run(Handle ph, long *currentTime)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_runQ(pr->project, currentTime));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API qual_next(Handle ph, long *tStep)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_nextQ(pr->project, tStep));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API qual_step(Handle ph, long *timeLeft)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_stepQ(pr->project, timeLeft));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API qual_close(Handle ph)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_closeQ(pr->project));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API rprt_writeline(Handle ph, char *line)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_writeline(pr->project, line));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rprt_writeresults(Handle ph)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_report(pr->project));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rprt_clear(Handle ph)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_clearreport(pr->project));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rprt_reset(Handle ph)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_resetreport(pr->project));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rprt_set(Handle ph, char *reportCommand)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setreport(pr->project, reportCommand));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rprt_setlevel(Handle ph, EN_StatusReport code)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setstatusreport(pr->project, code));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rprt_anlysstats(Handle ph, EN_AnalysisStatistic code, double* value)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getstatistic(pr->project, code, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API anlys_getoption(Handle ph, EN_Option code, double *value)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getoption(pr->project, (int)code, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API anlys_setoption(Handle ph, EN_Option code, double value)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setoption(pr->project, (int)code, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API anlys_getflowunits(Handle ph, int *code)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getflowunits(pr->project, code));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API anlys_setflowunits(Handle ph, EN_FlowUnits code)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setflowunits(pr->project, code));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API anlys_gettimeparam(Handle ph, EN_TimeParameter code, long *value)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_gettimeparam(pr->project, code, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API anlys_settimeparam(Handle ph, EN_TimeParameter code, long value)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_settimeparam(pr->project, code, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API anlys_getqualinfo(Handle ph, int *qualcode, char *chemname, char *chemunits, int *tracenode)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getqualinfo(pr->project, qualcode, chemname, chemunits, tracenode));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API anlys_getqualtype(Handle ph, int *qualcode, int *tracenode)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getqualtype(pr->project, qualcode, tracenode));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API anlys_setqualtype(Handle ph, EN_QualityType qualcode, char *chemname, char *chemunits, char *tracenode)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setqualtype(pr->project, qualcode, chemname, chemunits, tracenode));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API node_add(Handle ph, char *id, EN_NodeType nodeType, int *index)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_addnode(pr->project, id, nodeType, index));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API node_delete(Handle ph, int index, int actionCode)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_deletenode(pr->project, index, actionCode));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API node_getindex(Handle ph, char *id, int *index)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getnodeindex(pr->project, id, index));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API node_getid(Handle ph, int index, char *id)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getnodeid(pr->project, index, id));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API node_setid(Handle ph, int index, char *newid)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getnodeid(pr->project, index, newid));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API node_gettype(Handle ph, int index, int *code)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getnodetype(pr->project, index, code));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API node_getvalue(Handle ph, int index, EN_NodeProperty code, double *value)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getnodevalue(pr->project, index, (int)code, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API node_setvalue(Handle ph, int index, EN_NodeProperty code, double value)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setnodevalue(pr->project, index, (int)code, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API node_getcoord(Handle ph, int index, double *x, double *y)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getcoord(pr->project, index, x, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API node_setcoord(Handle ph, int index, double x, double y)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setcoord(pr->project, index, x, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API dmnd_getmodel(Handle ph, int *type, double *pmin, double *preq, double *pexp)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getdemandmodel(pr->project, type, pmin, preq, pexp));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API dmnd_setmodel(Handle ph, int type, double pmin, double preq, double pexp)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setdemandmodel(pr->project, type, pmin, preq, pexp));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API dmnd_getcount(Handle ph, int nodeIndex, int *numDemands)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getnumdemands(pr->project, nodeIndex, numDemands));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API dmnd_getbase(Handle ph, int nodeIndex, int demandIndex, double *baseDemand)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getbasedemand(pr->project, nodeIndex, demandIndex, baseDemand));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API dmnd_setbase(Handle ph, int nodeIndex, int demandIndex, double baseDemand)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setbasedemand(pr->project, nodeIndex, demandIndex, baseDemand));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API dmnd_getpattern(Handle ph, int nodeIndex, int demandIndex, int *patIndex)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getdemandpattern(pr->project, nodeIndex, demandIndex, patIndex));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API dmnd_setpattern(Handle ph, int nodeIndex, int demandIndex, int patIndex)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setdemandpattern(pr->project, nodeIndex, demandIndex, patIndex));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API dmnd_getname(Handle ph, int nodeIndex, int demandIdx, char *demandName)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getdemandname(pr->project, nodeIndex, demandIdx, demandName));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API dmnd_setname(Handle ph, int nodeIndex, int demandIdx, char *demandName)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setdemandname(pr->project, nodeIndex, demandIdx, demandName));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API link_add(Handle ph, char *id, EN_LinkType linkType, char *fromNode, char *toNode, int *index)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_addlink(pr->project, id, linkType, fromNode, toNode, index));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API link_delete(Handle ph, int index, int actionCode)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_deletelink(pr->project, index, actionCode));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API link_getindex(Handle ph, char *id, int *index)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getlinkindex(pr->project, id, index));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API link_getid(Handle ph, int index, char *id)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getlinkid(pr->project, index, id));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API link_setid(Handle ph, int index, char *newid)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setlinkid(pr->project, index, newid));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API link_gettype(Handle ph, int index, int *code)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getlinktype(pr->project, index, code));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API link_settype(Handle ph, int *index, EN_LinkType type, int actionCode)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setlinktype(pr->project, index, type, actionCode));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API link_getnodes(Handle ph, int index, int *node1, int *node2)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getlinknodes(pr->project, index, node1, node2));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API link_setnodes(Handle ph, int index, int node1, int node2)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setlinknodes(pr->project, index, node1, node2));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API link_getvalue(Handle ph, int index, EN_LinkProperty code, double *value)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getlinkvalue(pr->project, index, code, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API link_setvalue(Handle ph, int index, int code, double value)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setlinkvalue(pr->project, index, code, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API pump_gettype(Handle ph, int linkIndex, int *outType)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getpumptype(pr->project, linkIndex, outType));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API pump_getheadcurveindex(Handle ph, int pumpIndex, int *curveIndex)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getheadcurveindex(pr->project, pumpIndex, curveIndex));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API pump_setheadcurveindex(Handle ph, int pumpIndex, int curveIndex)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setheadcurveindex(pr->project, pumpIndex, curveIndex));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API ptrn_add(Handle ph, char *id)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_addpattern(pr->project, id));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API ptrn_getindex(Handle ph, char *id, int *index)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getpatternindex(pr->project, id, index));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API ptrn_getid(Handle ph, int index, char *id)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getpatternid(pr->project, index, id));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API ptrn_getlength(Handle ph, int index, int *len)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getpatternlen(pr->project, index, len));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API ptrn_getvalue(Handle ph, int index, int period, double *value)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getpatternvalue(pr->project, index, period, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API ptrn_setvalue(Handle ph, int index, int period, double value)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setpatternvalue(pr->project, index, period, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API ptrn_getavgvalue(Handle ph, int index, double *value)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getaveragepatternvalue(pr->project, index, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API ptrn_set(Handle ph, int index, double *values, int len)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setpattern(pr->project, index, values, len));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API curv_add(Handle ph, char *id)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_addcurve(pr->project, id));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API curv_getindex(Handle ph, char *id, int *index)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getcurveindex(pr->project, id, index));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API curv_getid(Handle ph, int index, char *id)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getcurveid(pr->project, index, id));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API curv_getlength(Handle ph, int index, int *len)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getcurvelen(pr->project, index, len));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API curv_gettype(Handle ph, int index, int *type)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getcurvetype(pr->project, index, type));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API curv_getvalue(Handle ph, int curveIndex, int pointIndex, double *x, double *y)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getcurvevalue(pr->project, curveIndex, pointIndex, x, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API curv_setvalue(Handle ph, int curveIndex, int pointIndex, double x, double y)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setcurvevalue(pr->project, curveIndex, pointIndex, x, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API curv_get(Handle ph, int curveIndex, char* id, int *nValues, double *xValues, double *yValues)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getcurve(pr->project, curveIndex, id, nValues, xValues, yValues));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API curv_set(Handle ph, int index, double *x, double *y, int len)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setcurve(pr->project, index, x, y, len));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API scntl_add(Handle ph, int type, int linkIndex, double setting, int nodeIndex, double level, int *index)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_addcontrol(pr->project, type, linkIndex, setting, nodeIndex, level, index));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API scntl_delete(Handle ph, int index)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_deletecontrol(pr->project, index));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API scntl_get(Handle ph, int controlIndex, int *controlType, int *linkIndex, double *setting, int *nodeIndex, double *level)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getcontrol(pr->project, controlIndex, controlType, linkIndex, setting, nodeIndex, level));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API scntl_set(Handle ph, int cindex, int ctype, int lindex, double setting, int nindex, double level)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setcontrol(pr->project, cindex, ctype, lindex, setting, nindex, level));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int EXPORT_PY_API rcntl_add(Handle ph, char *rule)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_addrule(pr->project, rule));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rcntl_delete(Handle ph, int index)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_deleterule(pr->project, index));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rcntl_get(Handle ph, int index, int *nPremises, int *nThenActions, int *nElseActions, double *priority)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getrule(pr->project, index, nPremises, nThenActions, nElseActions, priority));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rcntl_getid(Handle ph, int index, char *id)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getruleID(pr->project, index, id));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rcntl_getpremise(Handle ph, int ruleIndex, int premiseIndex, int *logop, int *object, int *objIndex, int *variable, int *relop, int *status, double *value)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getpremise(pr->project, ruleIndex, premiseIndex, logop, object, objIndex, variable, relop, status, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rcntl_setpremise(Handle ph, int ruleIndex, int premiseIndex, int logop, int object, int objIndex, int variable, int relop, int status, double value)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setpremise(pr->project, ruleIndex, premiseIndex, logop, object, objIndex, variable, relop, status, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rcntl_setpremiseindex(Handle ph, int ruleIndex, int premiseIndex, int objIndex)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setpremiseindex(pr->project, ruleIndex, premiseIndex, objIndex));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rcntl_setpremisestatus(Handle ph, int ruleIndex, int premiseIndex, int status)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setpremisestatus(pr->project, ruleIndex, premiseIndex, status));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rcntl_setpremisevalue(Handle ph, int ruleIndex, int premiseIndex, double value)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setpremisevalue(pr->project, ruleIndex, premiseIndex, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rcntl_getthenaction(Handle ph, int ruleIndex, int actionIndex, int *linkIndex, int *status, double *setting)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getthenaction(pr->project, ruleIndex, actionIndex, linkIndex, status, setting));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rcntl_setthenaction(Handle ph, int ruleIndex, int actionIndex, int linkIndex, int status, double setting)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setthenaction(pr->project, ruleIndex, actionIndex, linkIndex, status, setting));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rcntl_getelseaction(Handle ph, int ruleIndex, int actionIndex, int *linkIndex, int *status, double *setting)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_getelseaction(pr->project, ruleIndex, actionIndex, linkIndex, status, setting));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rcntl_setelseaction(Handle ph, int ruleIndex, int actionIndex, int linkIndex, int status, double setting)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setelseaction(pr->project, ruleIndex, actionIndex, linkIndex, status, setting));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API rcntl_setrulepriority(Handle ph, int index, double priority)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return set_error(pr->error, EN_setrulepriority(pr->project, index, priority));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void EXPORT_PY_API err_clear(Handle ph)
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
clear_error(pr->error);
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API err_check(Handle ph, char** msg_buffer)
|
|
||||||
//
|
|
||||||
// Purpose: Returns the error code and message or 0 and NULL respectively.
|
|
||||||
//
|
|
||||||
// Note: Caller must free memory allocated by EN_check_error
|
|
||||||
//
|
|
||||||
{
|
|
||||||
handle_t *pr = (handle_t *)ph;
|
|
||||||
return check_error(pr->error, msg_buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
int EXPORT_PY_API toolkit_getversion(int *version)
|
|
||||||
{
|
|
||||||
return EN_getversion(version);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EXPORT_PY_API toolkit_free(void **memory)
|
|
||||||
{
|
|
||||||
free(*memory);
|
|
||||||
*memory = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void error_lookup(int errcode, char *dest_msg, int dest_len)
|
|
||||||
// Purpose: takes error code returns error message
|
|
||||||
{
|
|
||||||
char *msg = NULL;
|
|
||||||
char new_msg[MAXMSG + 1];
|
|
||||||
|
|
||||||
switch (errcode)
|
|
||||||
{
|
|
||||||
case 1: msg = WARN1;
|
|
||||||
break;
|
|
||||||
case 2: msg = WARN2;
|
|
||||||
break;
|
|
||||||
case 3: msg = WARN3;
|
|
||||||
break;
|
|
||||||
case 4: msg = WARN4;
|
|
||||||
break;
|
|
||||||
case 5: msg = WARN5;
|
|
||||||
break;
|
|
||||||
case 6: msg = WARN6;
|
|
||||||
break;
|
|
||||||
default: msg = geterrmsg(errcode, new_msg);
|
|
||||||
}
|
|
||||||
strncpy(dest_msg, msg, dest_len);
|
|
||||||
}
|
|
||||||
@@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE(test_categories_save)
|
|||||||
|
|
||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
error = EN_deleteproject(&ph);
|
error = EN_deleteproject(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ BOOST_AUTO_TEST_CASE(test_categories_reopen, * boost::unit_test::depends_on("tes
|
|||||||
|
|
||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
error = EN_deleteproject(&ph);
|
error = EN_deleteproject(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ BOOST_AUTO_TEST_CASE(test_setlinktype)
|
|||||||
// Close and delete project
|
// Close and delete project
|
||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ BOOST_AUTO_TEST_CASE(test_link_setid_save)
|
|||||||
|
|
||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_link_setid_reopen, * boost::unit_test::depends_on("test_link/test_link_setid_save"))
|
BOOST_AUTO_TEST_CASE(test_link_setid_reopen, * boost::unit_test::depends_on("test_link/test_link_setid_save"))
|
||||||
@@ -200,7 +200,7 @@ BOOST_AUTO_TEST_CASE(test_link_setid_reopen, * boost::unit_test::depends_on("tes
|
|||||||
|
|
||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE(test_link_comments, FixtureOpenClose)
|
BOOST_FIXTURE_TEST_CASE(test_link_comments, FixtureOpenClose)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ struct FixtureInitClose {
|
|||||||
|
|
||||||
~FixtureInitClose() {
|
~FixtureInitClose() {
|
||||||
EN_close(ph);
|
EN_close(ph);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
int error;
|
int error;
|
||||||
EN_Project ph;
|
EN_Project ph;
|
||||||
@@ -286,7 +286,7 @@ BOOST_AUTO_TEST_CASE(test_open_net1, * boost::unit_test::depends_on("test_net_bu
|
|||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// if we got this far we can compare results
|
// if we got this far we can compare results
|
||||||
@@ -408,7 +408,7 @@ BOOST_AUTO_TEST_CASE(test_reopen_net2, *boost::unit_test::depends_on("test_net_b
|
|||||||
|
|
||||||
// Close project
|
// Close project
|
||||||
EN_close(ph);
|
EN_close(ph);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ BOOST_AUTO_TEST_CASE(test_setid_save)
|
|||||||
|
|
||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ BOOST_AUTO_TEST_CASE(test_setid_reopen, * boost::unit_test::depends_on("setid_sa
|
|||||||
|
|
||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
@@ -345,7 +345,7 @@ BOOST_AUTO_TEST_CASE(test_reopen_comment, * boost::unit_test::depends_on("node_c
|
|||||||
|
|
||||||
// Close project
|
// Close project
|
||||||
EN_close(ph);
|
EN_close(ph);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE(test_tank_overflow)
|
|||||||
// Clean up
|
// Clean up
|
||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
error = EN_deleteproject(&ph);
|
error = EN_deleteproject(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ BOOST_AUTO_TEST_CASE(test_add_set)
|
|||||||
BOOST_REQUIRE(y == y3[0]);
|
BOOST_REQUIRE(y == y3[0]);
|
||||||
|
|
||||||
EN_close(ph);
|
EN_close(ph);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE(test_pattern_comments, FixtureOpenClose)
|
BOOST_FIXTURE_TEST_CASE(test_pattern_comments, FixtureOpenClose)
|
||||||
|
|||||||
@@ -31,10 +31,9 @@ BOOST_AUTO_TEST_CASE (test_create_delete)
|
|||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
BOOST_CHECK(ph != NULL);
|
BOOST_CHECK(ph != NULL);
|
||||||
|
|
||||||
error = EN_deleteproject(&ph);
|
error = EN_deleteproject(ph);
|
||||||
|
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
BOOST_CHECK(ph == NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE (test_open_close)
|
BOOST_AUTO_TEST_CASE (test_open_close)
|
||||||
@@ -51,7 +50,7 @@ BOOST_AUTO_TEST_CASE (test_open_close)
|
|||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_init_close)
|
BOOST_AUTO_TEST_CASE(test_init_close)
|
||||||
@@ -65,7 +64,7 @@ BOOST_AUTO_TEST_CASE(test_init_close)
|
|||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_save)
|
BOOST_AUTO_TEST_CASE(test_save)
|
||||||
@@ -85,7 +84,7 @@ BOOST_AUTO_TEST_CASE(test_save)
|
|||||||
|
|
||||||
error = EN_close(ph_save);
|
error = EN_close(ph_save);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
EN_deleteproject(&ph_save);
|
EN_deleteproject(ph_save);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_reopen, * boost::unit_test::depends_on("test_project/test_save"))
|
BOOST_AUTO_TEST_CASE(test_reopen, * boost::unit_test::depends_on("test_project/test_save"))
|
||||||
@@ -100,7 +99,7 @@ BOOST_AUTO_TEST_CASE(test_reopen, * boost::unit_test::depends_on("test_project/t
|
|||||||
|
|
||||||
error = EN_close(ph_reopen);
|
error = EN_close(ph_reopen);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
EN_deleteproject(&ph_reopen);
|
EN_deleteproject(ph_reopen);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_run)
|
BOOST_AUTO_TEST_CASE(test_run)
|
||||||
@@ -114,7 +113,7 @@ BOOST_AUTO_TEST_CASE(test_run)
|
|||||||
error = EN_runproject(ph, DATA_PATH_NET1, DATA_PATH_RPT, DATA_PATH_OUT, NULL);
|
error = EN_runproject(ph, DATA_PATH_NET1, DATA_PATH_RPT, DATA_PATH_OUT, NULL);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ void epanet_thread(long i)
|
|||||||
|
|
||||||
EN_createproject(&ph);
|
EN_createproject(&ph);
|
||||||
errorcode = EN_runproject(ph, input.c_str(), report.c_str(), output.c_str(), NULL);
|
errorcode = EN_runproject(ph, input.c_str(), report.c_str(), output.c_str(), NULL);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
|
|
||||||
printf("Thread #%ld EPANET done. Status = %d\n", i, errorcode);
|
printf("Thread #%ld EPANET done. Status = %d\n", i, errorcode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ struct FixtureOpenClose{
|
|||||||
|
|
||||||
~FixtureOpenClose() {
|
~FixtureOpenClose() {
|
||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
|
|
||||||
int error;
|
int error;
|
||||||
@@ -52,7 +52,7 @@ struct FixtureInitClose {
|
|||||||
|
|
||||||
~FixtureInitClose() {
|
~FixtureInitClose() {
|
||||||
EN_close(ph);
|
EN_close(ph);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
int error;
|
int error;
|
||||||
EN_Project ph;
|
EN_Project ph;
|
||||||
@@ -94,7 +94,7 @@ struct FixtureAfterStep{
|
|||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
error = EN_close(ph);
|
error = EN_close(ph);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
|
|
||||||
int error, flag;
|
int error, flag;
|
||||||
@@ -115,7 +115,7 @@ struct FixtureSingleNode {
|
|||||||
|
|
||||||
~FixtureSingleNode() {
|
~FixtureSingleNode() {
|
||||||
EN_close(ph);
|
EN_close(ph);
|
||||||
EN_deleteproject(&ph);
|
EN_deleteproject(ph);
|
||||||
}
|
}
|
||||||
int error, index, node_qhut;
|
int error, index, node_qhut;
|
||||||
EN_Project ph;
|
EN_Project ph;
|
||||||
|
|||||||
Reference in New Issue
Block a user