Changing DLLEXPORT to EXPORT_OUT_API and creating epanet_output_enums.h

This commit is contained in:
Michael Tryby
2019-03-11 17:11:47 -04:00
parent 724bac732b
commit 516ae498c3
6 changed files with 157 additions and 201 deletions

View File

@@ -18,7 +18,6 @@
#include <string> #include <string>
#include <math.h> #include <math.h>
#include <boost/filesystem.hpp>
#define BOOST_TEST_MODULE "output" #define BOOST_TEST_MODULE "output"
#include <boost/test/included/unit_test.hpp> #include <boost/test/included/unit_test.hpp>

View File

@@ -4,12 +4,12 @@
# Created: March 9, 2018 # Created: March 9, 2018
# Author: Michael E. Tryby # Author: Michael E. Tryby
# US EPA ORD/NRMRL # US EPA ORD/NRMRL
# #
cmake_minimum_required (VERSION 3.0) cmake_minimum_required (VERSION 3.0)
# Sets for output directory for executables and libraries. # Sets for output directory for executables and libraries.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
@@ -25,16 +25,16 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(EPANET_OUT_SOURCES src/epanet_output.c src/errormanager.c) set(EPANET_OUT_SOURCES src/epanet_output.c src/errormanager.c)
# the binary output file API # the binary output file API
add_library(epanet-output SHARED ${EPANET_OUT_SOURCES}) add_library(epanet-output SHARED ${EPANET_OUT_SOURCES})
target_include_directories(epanet-output PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) target_include_directories(epanet-output PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
include(GenerateExportHeader) include(GenerateExportHeader)
generate_export_header(epanet-output generate_export_header(epanet-output
BASE_NAME epanet_output BASE_NAME epanet_output
EXPORT_MACRO_NAME DLLEXPORT EXPORT_MACRO_NAME EXPORT_OUT_API
EXPORT_FILE_NAME epanet_output_export.h EXPORT_FILE_NAME epanet_output_export.h
STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC) STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC)
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/epanet_output_export.h DESTINATION file(COPY ${CMAKE_CURRENT_BINARY_DIR}/epanet_output_export.h DESTINATION
${CMAKE_CURRENT_SOURCE_DIR}/include) ${CMAKE_CURRENT_SOURCE_DIR}/include)

View File

@@ -11,87 +11,16 @@
#define EPANET_OUTPUT_H_ #define EPANET_OUTPUT_H_
/* Epanet Results binary file API */ /* Epanet Results binary file API */
#define MAXFNAME 259 // Max characters in file name #define MAXFNAME 259 // Max characters in file name
#define MAXID 31 // Max characters in ID name #define MAXID 31 // Max characters in ID name
// This is an opaque pointer to struct. Do not access variables. // This is an opaque pointer to struct. Do not access variables.
typedef void* ENR_Handle; typedef void* ENR_Handle;
typedef enum {
ENR_node = 1,
ENR_link = 2
} ENR_ElementType;
typedef enum {
ENR_flowUnits = 1,
ENR_pressUnits = 2,
ENR_qualUnits = 3
} ENR_Units;
typedef enum {
ENR_CFS = 0,
ENR_GPM = 1,
ENR_MGD = 2,
ENR_IMGD = 3,
ENR_AFD = 4,
ENR_LPS = 5,
ENR_LPM = 6,
ENR_MLD = 7,
ENR_CMH = 8,
ENR_CMD = 9
} ENR_FlowUnits;
typedef enum {
ENR_PSI = 0,
ENR_MTR = 1,
ENR_KPA = 2
} ENR_PressUnits;
typedef enum {
ENR_NONE = 0,
ENR_MGL = 1,
ENR_UGL = 2,
ENR_HOURS = 3,
ENR_PRCNT = 4
} ENR_QualUnits;
typedef enum {
ENR_reportStart = 1,
ENR_reportStep = 2,
ENR_simDuration = 3,
ENR_numPeriods = 4
}ENR_Time;
typedef enum {
ENR_demand = 1,
ENR_head = 2,
ENR_pressure = 3,
ENR_quality = 4
} ENR_NodeAttribute;
typedef enum {
ENR_flow = 1,
ENR_velocity = 2,
ENR_headloss = 3,
ENR_avgQuality = 4,
ENR_status = 5,
ENR_setting = 6,
ENR_rxRate = 7,
ENR_frctnFctr = 8
} ENR_LinkAttribute;
// #ifdef WINDOWS
// #ifdef __cplusplus
// #define DLLEXPORT __declspec(dllexport) __cdecl
// #else
// #define DLLEXPORT __declspec(dllexport) __stdcall
// #endif
// #else
// #define DLLEXPORT
// #endif
#include "epanet_output_enums.h"
#include "epanet_output_export.h" #include "epanet_output_export.h"
@@ -99,52 +28,52 @@ typedef enum {
extern "C" { extern "C" {
#endif #endif
int DLLEXPORT ENR_init(ENR_Handle* p_handle_out); int EXPORT_OUT_API ENR_init(ENR_Handle* p_handle_out);
int DLLEXPORT ENR_open(ENR_Handle p_handle_in, const char* path); int EXPORT_OUT_API ENR_open(ENR_Handle p_handle_in, const char* path);
int DLLEXPORT ENR_getVersion(ENR_Handle p_handle_in, int* int_out); int EXPORT_OUT_API ENR_getVersion(ENR_Handle p_handle_in, int* int_out);
int DLLEXPORT ENR_getNetSize(ENR_Handle p_handle_in, int** int_out, int* int_dim); int EXPORT_OUT_API ENR_getNetSize(ENR_Handle p_handle_in, int** int_out, int* int_dim);
int DLLEXPORT ENR_getUnits(ENR_Handle p_handle_in, ENR_Units t_enum, int* int_out); int EXPORT_OUT_API ENR_getUnits(ENR_Handle p_handle_in, ENR_Units t_enum, int* int_out);
int DLLEXPORT ENR_getTimes(ENR_Handle p_handle_in, ENR_Time t_enum, int* int_out); int EXPORT_OUT_API ENR_getTimes(ENR_Handle p_handle_in, ENR_Time t_enum, int* int_out);
int DLLEXPORT ENR_getElementName(ENR_Handle p_handle_in, ENR_ElementType t_enum, int EXPORT_OUT_API ENR_getElementName(ENR_Handle p_handle_in, ENR_ElementType t_enum,
int elementIndex, char** string_out, int* slen); int elementIndex, char** string_out, int* slen);
int DLLEXPORT ENR_getEnergyUsage(ENR_Handle p_handle_in, int pumpIndex, int EXPORT_OUT_API ENR_getEnergyUsage(ENR_Handle p_handle_in, int pumpIndex,
int* int_out, float** float_out, int* int_dim); int* int_out, float** float_out, int* int_dim);
int DLLEXPORT ENR_getNetReacts(ENR_Handle p_handle_in, float** float_out, int* int_dim); int EXPORT_OUT_API ENR_getNetReacts(ENR_Handle p_handle_in, float** float_out, int* int_dim);
int DLLEXPORT ENR_getNodeSeries(ENR_Handle p_handle_in, int nodeIndex, ENR_NodeAttribute t_enum, int EXPORT_OUT_API ENR_getNodeSeries(ENR_Handle p_handle_in, int nodeIndex, ENR_NodeAttribute t_enum,
int startPeriod, int endPeriod, float** outValueSeries, int* dim); int startPeriod, int endPeriod, float** outValueSeries, int* dim);
int DLLEXPORT ENR_getLinkSeries(ENR_Handle p_handle_in, int linkIndex, ENR_LinkAttribute t_enum, int EXPORT_OUT_API ENR_getLinkSeries(ENR_Handle p_handle_in, int linkIndex, ENR_LinkAttribute t_enum,
int startPeriod, int endPeriod, float** outValueSeries, int* dim); int startPeriod, int endPeriod, float** outValueSeries, int* dim);
int DLLEXPORT ENR_getNodeAttribute(ENR_Handle p_handle_in, int periodIndex, int EXPORT_OUT_API ENR_getNodeAttribute(ENR_Handle p_handle_in, int periodIndex,
ENR_NodeAttribute t_enum, float** outValueArray, int* dim); ENR_NodeAttribute t_enum, float** outValueArray, int* dim);
int DLLEXPORT ENR_getLinkAttribute(ENR_Handle p_handle_in, int periodIndex, int EXPORT_OUT_API ENR_getLinkAttribute(ENR_Handle p_handle_in, int periodIndex,
ENR_LinkAttribute t_enum, float** outValueArray, int* dim); ENR_LinkAttribute t_enum, float** outValueArray, int* dim);
int DLLEXPORT ENR_getNodeResult(ENR_Handle p_handle_in, int periodIndex, int nodeIndex, int EXPORT_OUT_API ENR_getNodeResult(ENR_Handle p_handle_in, int periodIndex, int nodeIndex,
float** float_out, int* int_dim); float** float_out, int* int_dim);
int DLLEXPORT ENR_getLinkResult(ENR_Handle p_handle_in, int periodIndex, int linkIndex, int EXPORT_OUT_API ENR_getLinkResult(ENR_Handle p_handle_in, int periodIndex, int linkIndex,
float** float_out, int* int_dim); float** float_out, int* int_dim);
int DLLEXPORT ENR_close(ENR_Handle* p_handle_out); int EXPORT_OUT_API ENR_close(ENR_Handle* p_handle_out);
void DLLEXPORT ENR_free(void** array); void EXPORT_OUT_API ENR_free(void** array);
void DLLEXPORT ENR_clearError(ENR_Handle p_handle_in); void EXPORT_OUT_API ENR_clearError(ENR_Handle p_handle_in);
int DLLEXPORT ENR_checkError(ENR_Handle p_handle_in, char** msg_buffer); int EXPORT_OUT_API ENR_checkError(ENR_Handle p_handle_in, char** msg_buffer);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -0,0 +1,79 @@
/*
* epanet_output_enums.h - EPANET Output API enums
*
* Created on: March 11, 2019
*
* Author: Michael E. Tryby
* US EPA - ORD/NRMRL
*/
#ifndef EPANET_OUTPUT_ENUMS_H_
#define EPANET_OUTPUT_ENUMS_H_
typedef enum {
ENR_node = 1,
ENR_link = 2
} ENR_ElementType;
typedef enum {
ENR_flowUnits = 1,
ENR_pressUnits = 2,
ENR_qualUnits = 3
} ENR_Units;
typedef enum {
ENR_CFS = 0,
ENR_GPM = 1,
ENR_MGD = 2,
ENR_IMGD = 3,
ENR_AFD = 4,
ENR_LPS = 5,
ENR_LPM = 6,
ENR_MLD = 7,
ENR_CMH = 8,
ENR_CMD = 9
} ENR_FlowUnits;
typedef enum {
ENR_PSI = 0,
ENR_MTR = 1,
ENR_KPA = 2
} ENR_PressUnits;
typedef enum {
ENR_NONE = 0,
ENR_MGL = 1,
ENR_UGL = 2,
ENR_HOURS = 3,
ENR_PRCNT = 4
} ENR_QualUnits;
typedef enum {
ENR_reportStart = 1,
ENR_reportStep = 2,
ENR_simDuration = 3,
ENR_numPeriods = 4
}ENR_Time;
typedef enum {
ENR_demand = 1,
ENR_head = 2,
ENR_pressure = 3,
ENR_quality = 4
} ENR_NodeAttribute;
typedef enum {
ENR_flow = 1,
ENR_velocity = 2,
ENR_headloss = 3,
ENR_avgQuality = 4,
ENR_status = 5,
ENR_setting = 6,
ENR_rxRate = 7,
ENR_frctnFctr = 8
} ENR_LinkAttribute;
#endif /* EPANET_OUTPUT_ENUMS_H_ */

View File

@@ -31,7 +31,7 @@
// data from the output file. As such they return arrays of data. The API // data from the output file. As such they return arrays of data. The API
// functions automatically allocate memory for the array to be returned. The // functions automatically allocate memory for the array to be returned. The
// caller is responsible for deallocating memory. The function ENR_free() is // caller is responsible for deallocating memory. The function ENR_free() is
// provided to deallocate memory. // provided for that purpose.
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -96,7 +96,7 @@ int* newIntArray(int n);
char* newCharArray(int n); char* newCharArray(int n);
int DLLEXPORT ENR_init(ENR_Handle* dp_handle) int EXPORT_OUT_API ENR_init(ENR_Handle* dp_handle)
// Purpose: Initialized pointer for the opaque ENR_Handle. // Purpose: Initialized pointer for the opaque ENR_Handle.
// //
// Returns: Error code 0 on success, -1 on failure // Returns: Error code 0 on success, -1 on failure
@@ -122,7 +122,7 @@ int DLLEXPORT ENR_init(ENR_Handle* dp_handle)
return errorcode; return errorcode;
} }
int DLLEXPORT ENR_close(ENR_Handle* p_handle) int EXPORT_OUT_API ENR_close(ENR_Handle* p_handle)
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
** Input: *p_handle = pointer to ENR_Handle struct ** Input: *p_handle = pointer to ENR_Handle struct
** **
@@ -157,7 +157,7 @@ int DLLEXPORT ENR_close(ENR_Handle* p_handle)
return errorcode; return errorcode;
} }
int DLLEXPORT ENR_open(ENR_Handle p_handle, const char* path) int EXPORT_OUT_API ENR_open(ENR_Handle p_handle, const char* path)
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
** Input: path ** Input: path
** Output: p_handle = pointer to ENR_Handle struct ** Output: p_handle = pointer to ENR_Handle struct
@@ -221,7 +221,7 @@ int DLLEXPORT ENR_open(ENR_Handle p_handle, const char* path)
return errorcode; return errorcode;
} }
int DLLEXPORT ENR_getVersion(ENR_Handle p_handle, int* version) int EXPORT_OUT_API ENR_getVersion(ENR_Handle p_handle, int* version)
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
** Input: p_handle = pointer to ENR_Handle struct ** Input: p_handle = pointer to ENR_Handle struct
** Output: version Epanet version ** Output: version Epanet version
@@ -247,7 +247,7 @@ int DLLEXPORT ENR_getVersion(ENR_Handle p_handle, int* version)
return set_error(p_data->error_handle, errorcode); return set_error(p_data->error_handle, errorcode);
} }
int DLLEXPORT ENR_getNetSize(ENR_Handle p_handle, int** elementCount, int* length) int EXPORT_OUT_API ENR_getNetSize(ENR_Handle p_handle, int** elementCount, int* length)
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
** Input: p_handle = pointer to ENR_Handle struct ** Input: p_handle = pointer to ENR_Handle struct
** Output: array of element counts (nodes, tanks, links, pumps, valves) ** Output: array of element counts (nodes, tanks, links, pumps, valves)
@@ -278,7 +278,7 @@ int DLLEXPORT ENR_getNetSize(ENR_Handle p_handle, int** elementCount, int* lengt
return set_error(p_data->error_handle, errorcode); return set_error(p_data->error_handle, errorcode);
} }
int DLLEXPORT ENR_getUnits(ENR_Handle p_handle, ENR_Units code, int* unitFlag) int EXPORT_OUT_API ENR_getUnits(ENR_Handle p_handle, ENR_Units code, int* unitFlag)
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
** Input: p_handle = pointer to ENR_Handle struct ** Input: p_handle = pointer to ENR_Handle struct
** code ** code
@@ -355,7 +355,7 @@ int DLLEXPORT ENR_getUnits(ENR_Handle p_handle, ENR_Units code, int* unitFlag)
return set_error(p_data->error_handle, errorcode); return set_error(p_data->error_handle, errorcode);
} }
int DLLEXPORT ENR_getTimes(ENR_Handle p_handle, ENR_Time code, int* time) int EXPORT_OUT_API ENR_getTimes(ENR_Handle p_handle, ENR_Time code, int* time)
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
** Input: p_handle = pointer to ENR_Handle struct ** Input: p_handle = pointer to ENR_Handle struct
** code = element code ** code = element code
@@ -403,13 +403,13 @@ int DLLEXPORT ENR_getTimes(ENR_Handle p_handle, ENR_Time code, int* time)
return set_error(p_data->error_handle, errorcode); return set_error(p_data->error_handle, errorcode);
} }
int DLLEXPORT ENR_getChemData(ENR_Handle p_handle, char** name, int* length) int EXPORT_OUT_API ENR_getChemData(ENR_Handle p_handle, char** name, int* length)
{ {
return 0; return 0;
} }
int DLLEXPORT ENR_getElementName(ENR_Handle p_handle, ENR_ElementType type, int EXPORT_OUT_API ENR_getElementName(ENR_Handle p_handle, ENR_ElementType type,
int elementIndex, char** name, int* length) int elementIndex, char** name, int* length)
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
** Input: p_handle = pointer to ENR_Handle struct ** Input: p_handle = pointer to ENR_Handle struct
@@ -469,7 +469,7 @@ int DLLEXPORT ENR_getElementName(ENR_Handle p_handle, ENR_ElementType type,
return set_error(p_data->error_handle, errorcode); return set_error(p_data->error_handle, errorcode);
} }
int DLLEXPORT ENR_getEnergyUsage(ENR_Handle p_handle, int pumpIndex, int EXPORT_OUT_API ENR_getEnergyUsage(ENR_Handle p_handle, int pumpIndex,
int* linkIndex, float** outValues, int* length) int* linkIndex, float** outValues, int* length)
/* /*
* Purpose: Returns pump energy usage statistics. * Purpose: Returns pump energy usage statistics.
@@ -514,7 +514,7 @@ int DLLEXPORT ENR_getEnergyUsage(ENR_Handle p_handle, int pumpIndex,
return set_error(p_data->error_handle, errorcode); return set_error(p_data->error_handle, errorcode);
} }
int DLLEXPORT ENR_getNetReacts(ENR_Handle p_handle, float** outValues, int* length) int EXPORT_OUT_API ENR_getNetReacts(ENR_Handle p_handle, float** outValues, int* length)
/* /*
* Purpose: Returns network wide average reaction rates and average * Purpose: Returns network wide average reaction rates and average
* source mass inflow: * source mass inflow:
@@ -549,7 +549,7 @@ int DLLEXPORT ENR_getNetReacts(ENR_Handle p_handle, float** outValues, int* leng
return set_error(p_data->error_handle, errorcode); return set_error(p_data->error_handle, errorcode);
} }
void DLLEXPORT ENR_free(void** array) void EXPORT_OUT_API ENR_free(void** array)
// //
// Purpose: Frees memory allocated by API calls // Purpose: Frees memory allocated by API calls
// //
@@ -560,7 +560,7 @@ void DLLEXPORT ENR_free(void** array)
} }
} }
int DLLEXPORT ENR_getNodeSeries(ENR_Handle p_handle, int nodeIndex, ENR_NodeAttribute attr, int EXPORT_OUT_API ENR_getNodeSeries(ENR_Handle p_handle, int nodeIndex, ENR_NodeAttribute attr,
int startPeriod, int endPeriod, float** outValueSeries, int* dim) int startPeriod, int endPeriod, float** outValueSeries, int* dim)
// //
// Purpose: Get time series results for particular attribute. Specify series // Purpose: Get time series results for particular attribute. Specify series
@@ -595,7 +595,7 @@ int DLLEXPORT ENR_getNodeSeries(ENR_Handle p_handle, int nodeIndex, ENR_NodeAttr
return set_error(p_data->error_handle, errorcode); return set_error(p_data->error_handle, errorcode);
} }
int DLLEXPORT ENR_getLinkSeries(ENR_Handle p_handle, int linkIndex, ENR_LinkAttribute attr, int EXPORT_OUT_API ENR_getLinkSeries(ENR_Handle p_handle, int linkIndex, ENR_LinkAttribute attr,
int startPeriod, int endPeriod, float** outValueSeries, int* dim) int startPeriod, int endPeriod, float** outValueSeries, int* dim)
// //
// Purpose: Get time series results for particular attribute. Specify series // Purpose: Get time series results for particular attribute. Specify series
@@ -630,7 +630,7 @@ int DLLEXPORT ENR_getLinkSeries(ENR_Handle p_handle, int linkIndex, ENR_LinkAttr
return set_error(p_data->error_handle, errorcode); return set_error(p_data->error_handle, errorcode);
} }
int DLLEXPORT ENR_getNodeAttribute(ENR_Handle p_handle, int periodIndex, int EXPORT_OUT_API ENR_getNodeAttribute(ENR_Handle p_handle, int periodIndex,
ENR_NodeAttribute attr, float** outValueArray, int* length) ENR_NodeAttribute attr, float** outValueArray, int* length)
// //
// Purpose: // Purpose:
@@ -679,7 +679,7 @@ int DLLEXPORT ENR_getNodeAttribute(ENR_Handle p_handle, int periodIndex,
return set_error(p_data->error_handle, errorcode); return set_error(p_data->error_handle, errorcode);
} }
int DLLEXPORT ENR_getLinkAttribute(ENR_Handle p_handle, int periodIndex, int EXPORT_OUT_API ENR_getLinkAttribute(ENR_Handle p_handle, int periodIndex,
ENR_LinkAttribute attr, float** outValueArray, int* length) ENR_LinkAttribute attr, float** outValueArray, int* length)
// //
// Purpose: // Purpose:
@@ -729,7 +729,7 @@ int DLLEXPORT ENR_getLinkAttribute(ENR_Handle p_handle, int periodIndex,
return set_error(p_data->error_handle, errorcode); return set_error(p_data->error_handle, errorcode);
} }
int DLLEXPORT ENR_getNodeResult(ENR_Handle p_handle, int periodIndex, int EXPORT_OUT_API ENR_getNodeResult(ENR_Handle p_handle, int periodIndex,
int nodeIndex, float** outValueArray, int* length) int nodeIndex, float** outValueArray, int* length)
// //
// Purpose: For a node at given time, get all attributes. // Purpose: For a node at given time, get all attributes.
@@ -759,7 +759,7 @@ int DLLEXPORT ENR_getNodeResult(ENR_Handle p_handle, int periodIndex,
return set_error(p_data->error_handle, errorcode); return set_error(p_data->error_handle, errorcode);
} }
int DLLEXPORT ENR_getLinkResult(ENR_Handle p_handle, int periodIndex, int EXPORT_OUT_API ENR_getLinkResult(ENR_Handle p_handle, int periodIndex,
int linkIndex, float** outValueArray, int* length) int linkIndex, float** outValueArray, int* length)
// //
// Purpose: For a link at given time, get all attributes // Purpose: For a link at given time, get all attributes
@@ -786,7 +786,7 @@ int DLLEXPORT ENR_getLinkResult(ENR_Handle p_handle, int periodIndex,
return set_error(p_data->error_handle, errorcode); return set_error(p_data->error_handle, errorcode);
} }
void DLLEXPORT ENR_clearError(ENR_Handle p_handle) void EXPORT_OUT_API ENR_clearError(ENR_Handle p_handle)
{ {
data_t* p_data; data_t* p_data;
@@ -794,7 +794,7 @@ void DLLEXPORT ENR_clearError(ENR_Handle p_handle)
clear_error(p_data->error_handle); clear_error(p_data->error_handle);
} }
int DLLEXPORT ENR_checkError(ENR_Handle p_handle, char** msg_buffer) int EXPORT_OUT_API ENR_checkError(ENR_Handle p_handle, char** msg_buffer)
{ {
int errorcode = 0; int errorcode = 0;
char *temp = NULL; char *temp = NULL;

View File

@@ -1,12 +1,12 @@
/* /*
* epanet_output.i - SWIG interface description file for EPANET Output API * epanet_output.i - SWIG interface description file for EPANET Output API
* *
* Created: 9/20/2017 * Created: 9/20/2017
* *
* Author: Michael E. Tryby * Author: Michael E. Tryby
* US EPA - ORD/NRMRL * US EPA - ORD/NRMRL
* *
*/ */
%module epanet_output %module epanet_output
%{ %{
#include "errormanager.h" #include "errormanager.h"
@@ -23,60 +23,9 @@
typedef void* ENR_Handle; typedef void* ENR_Handle;
typedef enum {
ENR_node = 1,
ENR_link = 2
} ENR_ElementType;
/* %include "epanet_output_enums.h"
typedef enum {
ENR_nodeCount = 1,
ENR_tankCount = 2,
ENR_linkCount = 3,
ENR_pumpCount = 4,
ENR_valveCount = 5
} ENR_ElementCount;
*/
typedef enum {
ENR_flowUnits = 1,
ENR_pressUnits = 2
} ENR_Units;
typedef enum {
ENR_reportStart = 1,
ENR_reportStep = 2,
ENR_simDuration = 3,
ENR_numPeriods = 4
}ENR_Time;
typedef enum {
ENR_demand = 1,
ENR_head = 2,
ENR_pressure = 3,
ENR_quality = 4
} ENR_NodeAttribute;
typedef enum {
ENR_flow = 1,
ENR_velocity = 2,
ENR_headloss = 3,
ENR_avgQuality = 4,
ENR_status = 5,
ENR_setting = 6,
ENR_rxRate = 7,
ENR_frctnFctr = 8
} ENR_LinkAttribute;
#ifdef WINDOWS
#ifdef __cplusplus
#define DLLEXPORT __declspec(dllexport) __cdecl
#else
#define DLLEXPORT __declspec(dllexport) __stdcall
#endif
#else
#define DLLEXPORT
#endif
/* TYPEMAPS FOR OPAQUE POINTER */ /* TYPEMAPS FOR OPAQUE POINTER */
/* Used for functions that output a new opaque pointer */ /* Used for functions that output a new opaque pointer */
@@ -92,7 +41,7 @@ and return a (possibly) different pointer */
{ {
/* OUTPUT argout */ /* OUTPUT argout */
%append_output(SWIG_NewPointerObj(SWIG_as_voidptr(retval$argnum), $1_descriptor, 0)); %append_output(SWIG_NewPointerObj(SWIG_as_voidptr(retval$argnum), $1_descriptor, 0));
} }
/* No need for special IN typemap for opaque pointers, it works anyway */ /* No need for special IN typemap for opaque pointers, it works anyway */
@@ -118,7 +67,7 @@ and return a (possibly) different pointer */
if (*$1) { if (*$1) {
PyObject* o; PyObject* o;
o = PyUnicode_FromStringAndSize(*$1, *$2); o = PyUnicode_FromStringAndSize(*$1, *$2);
$result = SWIG_Python_AppendOutput($result, o); $result = SWIG_Python_AppendOutput($result, o);
free(*$1); free(*$1);
} }
@@ -163,12 +112,12 @@ and return a (possibly) different pointer */
if (PyObject_HasAttrString($input,"value")) { if (PyObject_HasAttrString($input,"value")) {
PyObject* o; PyObject* o;
o = PyObject_GetAttrString($input, "value"); o = PyObject_GetAttrString($input, "value");
ecode = SWIG_AsVal_int(o, &val); ecode = SWIG_AsVal_int(o, &val);
} }
else { else {
SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "$symname" "', argument " "$argnum"" of type '" "$ltype""'"); SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "$symname" "', argument " "$argnum"" of type '" "$ltype""'");
} }
$1 = ($1_type)(val); $1 = ($1_type)(val);
} }
%apply EnumeratedType {ENR_ElementType, ENR_Units, ENR_Time, ENR_NodeAttribute, ENR_LinkAttribute} %apply EnumeratedType {ENR_ElementType, ENR_Units, ENR_Time, ENR_NodeAttribute, ENR_LinkAttribute}
@@ -189,33 +138,33 @@ and return a (possibly) different pointer */
SWIG_fail; SWIG_fail;
} }
} }
/* INSERT EXCEPTION HANDLING FOR THESE FUNCTIONS */ /* INSERT EXCEPTION HANDLING FOR THESE FUNCTIONS */
int DLLEXPORT ENR_open(ENR_Handle p_handle, const char* path); int ENR_open(ENR_Handle p_handle, const char* path);
int DLLEXPORT ENR_getVersion(ENR_Handle p_handle, int* int_out); int ENR_getVersion(ENR_Handle p_handle, int* int_out);
int DLLEXPORT ENR_getNetSize(ENR_Handle p_handle, int** int_out, int* int_dim); int ENR_getNetSize(ENR_Handle p_handle, int** int_out, int* int_dim);
int DLLEXPORT ENR_getUnits(ENR_Handle p_handle, ENR_Units t_enum, int* int_out); int ENR_getUnits(ENR_Handle p_handle, ENR_Units t_enum, int* int_out);
int DLLEXPORT ENR_getTimes(ENR_Handle p_handle, ENR_Time t_enum, int* int_out); int ENR_getTimes(ENR_Handle p_handle, ENR_Time t_enum, int* int_out);
int DLLEXPORT ENR_getElementName(ENR_Handle p_handle, ENR_ElementType t_enum, int ENR_getElementName(ENR_Handle p_handle, ENR_ElementType t_enum,
int elementIndex, char** string_out, int* slen); int elementIndex, char** string_out, int* slen);
int DLLEXPORT ENR_getEnergyUsage(ENR_Handle p_handle, int pumpIndex, int ENR_getEnergyUsage(ENR_Handle p_handle, int pumpIndex,
int* int_out, float** float_out, int* int_dim); int* int_out, float** float_out, int* int_dim);
int DLLEXPORT ENR_getNetReacts(ENR_Handle p_handle, float** float_out, int* int_dim); int ENR_getNetReacts(ENR_Handle p_handle, float** float_out, int* int_dim);
int DLLEXPORT ENR_getNodeAttribute(ENR_Handle p_handle, int periodIndex, int ENR_getNodeAttribute(ENR_Handle p_handle, int periodIndex,
ENR_NodeAttribute t_enum, float** float_out, int* int_dim); ENR_NodeAttribute t_enum, float** float_out, int* int_dim);
int DLLEXPORT ENR_getLinkAttribute(ENR_Handle p_handle, int periodIndex, int ENR_getLinkAttribute(ENR_Handle p_handle, int periodIndex,
ENR_LinkAttribute t_enum, float** float_out, int* int_dim); ENR_LinkAttribute t_enum, float** float_out, int* int_dim);
%exception; %exception;
/* NO EXCEPTION HANDLING FOR THESE FUNCTIONS */ /* NO EXCEPTION HANDLING FOR THESE FUNCTIONS */
int DLLEXPORT ENR_init(ENR_Handle* p_handle_out); int ENR_init(ENR_Handle* p_handle_out);
int DLLEXPORT ENR_close(ENR_Handle* p_handle_out); int ENR_close(ENR_Handle* p_handle_out);
void DLLEXPORT ENR_free(void** array); void ENR_free(void** array);
void DLLEXPORT ENR_clearError(ENR_Handle p_handle); void ENR_clearError(ENR_Handle p_handle);
int DLLEXPORT ENR_checkError(ENR_Handle p_handle, char** msg_buffer); int ENR_checkError(ENR_Handle p_handle, char** msg_buffer);
/* CODE ADDED DIRECTLY TO SWIGGED INTERFACE MODULE */ /* CODE ADDED DIRECTLY TO SWIGGED INTERFACE MODULE */
@@ -235,13 +184,13 @@ class Time(enum.Enum):
REPORT_STEP = ENR_reportStep REPORT_STEP = ENR_reportStep
SIM_DURATION = ENR_simDuration SIM_DURATION = ENR_simDuration
NUM_PERIODS = ENR_numPeriods NUM_PERIODS = ENR_numPeriods
class NodeAttribute(enum.Enum): class NodeAttribute(enum.Enum):
DEMAND = ENR_demand DEMAND = ENR_demand
HEAD = ENR_head HEAD = ENR_head
PRESSURE = ENR_pressure PRESSURE = ENR_pressure
QUALITY = ENR_quality QUALITY = ENR_quality
class LinkAttribute(enum.Enum): class LinkAttribute(enum.Enum):
FLOW = ENR_flow FLOW = ENR_flow
VELOCITY = ENR_velocity VELOCITY = ENR_velocity