SWMM-Docs  5.2.0.dev5
Stormwater Management Model
Functions
toolkitAPI.c File Reference

Exportable Functions for Toolkit API. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "headers.h"
#include "swmm5.h"
#include "toolkitAPI.h"
#include "hash.h"

Go to the source code of this file.

Functions

double * newDoubleArray (int n)
 
void DLLEXPORT swmm_getAPIError (int errcode, char *s)
 Get the text of an error code. More...
 
int DLLEXPORT swmm_project_findObject (int type, char *id, int *index)
 Finds the index of an object given its ID. More...
 
int DLLEXPORT swmm_getSimulationDateTime (int timetype, int *year, int *month, int *day, int *hour, int *minute, int *second)
 Get the current simulation datetime information. More...
 
int DLLEXPORT swmm_setSimulationDateTime (int timetype, char *dtimestr)
 Set simulation datetime information. More...
 
int DLLEXPORT swmm_getSimulationUnit (int type, int *value)
 Gets Simulation Unit. More...
 
int DLLEXPORT swmm_getSimulationAnalysisSetting (int type, int *value)
 Gets Simulation Analysis Setting. More...
 
int DLLEXPORT swmm_getSimulationParam (int type, double *value)
 Gets Simulation Analysis Setting. More...
 
int DLLEXPORT swmm_countObjects (int type, int *count)
 Gets Object Count. More...
 
int DLLEXPORT swmm_getObjectIndex (SM_ObjectType type, char *id, int *index)
 Gets Object Index. More...
 
int DLLEXPORT swmm_getObjectId (int type, int index, char *id)
 Gets Object ID. More...
 
int DLLEXPORT swmm_getNodeType (int index, int *Ntype)
 Get the type of node with specified index. More...
 
int DLLEXPORT swmm_getLinkType (int index, int *Ltype)
 Get the type of link with specified index. More...
 
int DLLEXPORT swmm_getLinkConnections (int index, int *Node1, int *Node2)
 Get the link Connection Node Indeces. If the conduit has a negative slope, the dynamic wave solver will automatically reverse the nodes. To check the direction, call swmm_getLinkDirection(). More...
 
int DLLEXPORT swmm_getLinkDirection (int index, signed char *value)
 Get the link flow direction (see swmm_getLinkType() for notes. More...
 
int DLLEXPORT swmm_getNodeParam (int index, int Param, double *value)
 Get a property value for specified node. More...
 
int DLLEXPORT swmm_setNodeParam (int index, int Param, double value)
 Set a property value for specified node. More...
 
int DLLEXPORT swmm_getLinkParam (int index, int Param, double *value)
 Get a property value for specified link. More...
 
int DLLEXPORT swmm_setLinkParam (int index, int Param, double value)
 Set a property value for specified link. More...
 
int DLLEXPORT swmm_getSubcatchParam (int index, int Param, double *value)
 Get a property value for specified subcatchment. More...
 
int DLLEXPORT swmm_setSubcatchParam (int index, int Param, double value)
 Set a property value for specified subcatchment. More...
 
int DLLEXPORT swmm_getSubcatchOutConnection (int index, int *type, int *out_index)
 Get the Subcatchment connection. Subcatchments can load to a node, another subcatchment, or itself. More...
 
int DLLEXPORT swmm_getLidUCount (int index, int *value)
 Get the number of lid units on a subcatchment. More...
 
int DLLEXPORT swmm_getLidUParam (int index, int lidIndex, int param, double *value)
 Get a property value for a specified lid unit on a specified subcatchment. More...
 
int DLLEXPORT swmm_setLidUParam (int index, int lidIndex, int Param, double value)
 Set a property value for a specified lid unit on a specified subcatchment. More...
 
int DLLEXPORT swmm_getLidUOption (int index, int lidIndex, int param, int *value)
 Get the lid option for a specified lid unit on a specified subcatchment. More...
 
int DLLEXPORT swmm_setLidUOption (int index, int lidIndex, int param, int value)
 Set the lid option for a specified lid unit on a specified subcatchment. More...
 
int DLLEXPORT swmm_getLidCOverflow (int lidControlIndex, char *condition)
 Get the lid control surface immediate overflow condition. More...
 
int DLLEXPORT swmm_getLidCParam (int lidControlIndex, int layerIndex, int param, double *value)
 Get a property value for specified lid control. More...
 
int DLLEXPORT swmm_setLidCParam (int lidControlIndex, int layerIndex, int param, double value)
 Set a property value for specified lid control. More...
 
int DLLEXPORT swmm_getCurrentDateTimeStr (char *dtimestr)
 Get the simulation current datetime as a string. More...
 
int DLLEXPORT swmm_getNodeResult (int index, int type, double *result)
 Get a result value for specified node. More...
 
int DLLEXPORT swmm_getLinkResult (int index, int type, double *result)
 Get a result value for specified link. More...
 
int DLLEXPORT swmm_getSubcatchResult (int index, int type, double *result)
 Get a result value for specified subcatchment. More...
 
int DLLEXPORT swmm_getSubcatchPollut (int index, int type, double **PollutArray)
 Gets pollutant values for a specified subcatchment. More...
 
int DLLEXPORT swmm_getGagePrecip (int index, double **GageArray)
 Get precipitation rates for a gage. More...
 
int DLLEXPORT swmm_getNodeStats (int index, SM_NodeStats *nodeStats)
 Get a node statistics. More...
 
int DLLEXPORT swmm_getNodeTotalInflow (int index, double *value)
 Get the cumulative inflow for a node. More...
 
int DLLEXPORT swmm_getStorageStats (int index, SM_StorageStats *storageStats)
 Get a storage statistics. More...
 
int DLLEXPORT swmm_getOutfallStats (int index, SM_OutfallStats *outfallStats)
 Get outfall statistics. More...
 
void DLLEXPORT swmm_freeOutfallStats (SM_OutfallStats *outfallStats)
 Free outfall statistics structure. More...
 
int DLLEXPORT swmm_getLinkStats (int index, SM_LinkStats *linkStats)
 Get link statistics. More...
 
int DLLEXPORT swmm_getPumpStats (int index, SM_PumpStats *pumpStats)
 Get pump statistics. More...
 
int DLLEXPORT swmm_getSubcatchStats (int index, SM_SubcatchStats **subcatchStats)
 Get subcatchment statistics. More...
 
int DLLEXPORT swmm_getSystemRoutingStats (SM_RoutingTotals *routingTot)
 Get system routing statistics. More...
 
int DLLEXPORT swmm_getSystemRunoffStats (SM_RunoffTotals *runoffTot)
 Get system runoff statistics. More...
 
int DLLEXPORT swmm_getLidUFluxRates (int index, int lidIndex, int layerIndex, double *result)
 Get the lid unit water balance simulated value at current time. More...
 
int DLLEXPORT swmm_getLidGResult (int index, int type, double *result)
 Get the lid group of a specified subcatchment result at current time. More...
 
int DLLEXPORT swmm_getLidUResult (int index, int lidIndex, int type, double *result)
 Get the lid unit of a specified subcatchment result at current time. More...
 
int DLLEXPORT swmm_setLinkSetting (int index, double setting)
 Set a link setting (pump, orifice, or weir). Setting for an orifice and a weir should be [0, 1]. A setting for a pump can range from [0, inf). However, if a pump is set to 1, it will pump at its maximum curve setting. More...
 
int DLLEXPORT swmm_setNodeInflow (int index, double flowrate)
 Set an inflow rate to a node. The inflow rate is held constant until the caller changes it. More...
 
int DLLEXPORT swmm_setOutfallStage (int index, double stage)
 Set outfall stage. More...
 
int DLLEXPORT swmm_setGagePrecip (int index, double total_precip)
 Set a total precipitation intensity to the gage. More...
 
void DLLEXPORT freeArray (void **array)
 Helper function to free memory array allocated in SWMM. More...
 

Detailed Description

Exportable Functions for Toolkit API.

See also
http://github.com/openwateranalytics/stormwater-management-model

toolkitAPI.c

Date
08/30/2016 (First Contribution)
Authors
B. McDonnell (EmNet LLC), OpenWaterAnalytics members: see AUTHORS.

Definition in file toolkitAPI.c.

Function Documentation

◆ freeArray()

void DLLEXPORT freeArray ( void **  array)

Helper function to free memory array allocated in SWMM.

Helper function used to free array allocated memory by API.

Definition at line 2502 of file toolkitAPI.c.

◆ newDoubleArray()

double * newDoubleArray ( int  n)

Warning: Caller must free memory allocated by this function.

Definition at line 2493 of file toolkitAPI.c.

◆ swmm_getGagePrecip()

int DLLEXPORT swmm_getGagePrecip ( int  index,
double **  GageArray 
)

Get precipitation rates for a gage.

Input: index = Index of desired ID Output: GageArray pointer (three elements) Return: API Error Purpose: Gets the precipitation value in the gage.

Definition at line 1741 of file toolkitAPI.c.

◆ swmm_getLidCOverflow()

int DLLEXPORT swmm_getLidCOverflow ( int  lidControlIndex,
char *  condition 
)

Get the lid control surface immediate overflow condition.

Parameters
lidControlIndexThe index of specified lid control
[out]conditionThe value of surface immediate overflow condition
Returns
Error code

Definition at line 1089 of file toolkitAPI.c.

◆ swmm_getLidCParam()

int DLLEXPORT swmm_getLidCParam ( int  lidControlIndex,
int  layerIndex,
int  Param,
double *  value 
)

Get a property value for specified lid control.

Parameters
lidControlIndexThe index of specified lid control
layerIndexThe index of specified lid layer (See SM_LidLayer)
ParamThe property type code (See SM_LidLayerProperty)
[out]valueThe value of lid control's property
Returns
Error code

Definition at line 1121 of file toolkitAPI.c.

◆ swmm_getLidGResult()

int DLLEXPORT swmm_getLidGResult ( int  index,
int  type,
double *  result 
)

Get the lid group of a specified subcatchment result at current time.

Parameters
indexThe index of a subcatchment
typeThe result type code (See SM_LidResult)
[out]resultThe result for the specified lid group
Returns
Error code

Definition at line 2160 of file toolkitAPI.c.

◆ swmm_getLidUCount()

int DLLEXPORT swmm_getLidUCount ( int  index,
int *  value 
)

Get the number of lid units on a subcatchment.

Parameters
indexThe index of a subcatchment
[out]valueThe number of lid units on a subcatchment
Returns
Error code

Definition at line 824 of file toolkitAPI.c.

◆ swmm_getLidUFluxRates()

int DLLEXPORT swmm_getLidUFluxRates ( int  index,
int  lidIndex,
int  layerIndex,
double *  result 
)

Get the lid unit water balance simulated value at current time.

Parameters
indexThe index of a subcatchment
lidIndexThe index of specified lid unit
layerIndexThe index of specified lid layer (See SM_LidLayer)
ParamThe result type code (See SM_LidResult)
[out]resultThe result for the specified lid unit
Returns
Error code

Definition at line 2109 of file toolkitAPI.c.

◆ swmm_getLidUOption()

int DLLEXPORT swmm_getLidUOption ( int  index,
int  lidIndex,
int  Param,
int *  value 
)

Get the lid option for a specified lid unit on a specified subcatchment.

Parameters
indexThe index of a subcatchment
lidIndexThe index of specified lid unit
ParamThe lid option type code (See SM_LidUOptions)
[out]valueThe value of the option for the lid unit
Returns
Error code

Definition at line 970 of file toolkitAPI.c.

◆ swmm_getLidUParam()

int DLLEXPORT swmm_getLidUParam ( int  index,
int  lidIndex,
int  Param,
double *  value 
)

Get a property value for a specified lid unit on a specified subcatchment.

Parameters
indexThe index of a subcatchment
lidIndexThe index of specified lid unit
ParamThe property type code (See SM_LidUProperty)
[out]valueThe value of the lid unit's property
Returns
Error code

Definition at line 851 of file toolkitAPI.c.

◆ swmm_getLidUResult()

int DLLEXPORT swmm_getLidUResult ( int  index,
int  lidIndex,
int  type,
double *  result 
)

Get the lid unit of a specified subcatchment result at current time.

Parameters
indexThe index of a subcatchment
lidIndexThe index of specified lid unit
typeThe result type code (See SM_LidResult)
[out]resultThe result for the specified lid unit
Returns
Error code

Definition at line 2209 of file toolkitAPI.c.

◆ swmm_getObjectIndex()

int DLLEXPORT swmm_getObjectIndex ( SM_ObjectType  type,
char *  id,
int *  index 
)

Gets Object Index.

Input: type = object type (Based on SM_ObjectType enum) char* = ID name Output: object index Return: error Purpose: Gets object id index

Definition at line 310 of file toolkitAPI.c.

◆ swmm_getSubcatchPollut()

int DLLEXPORT swmm_getSubcatchPollut ( int  index,
int  type,
double **  PollutArray 
)

Gets pollutant values for a specified subcatchment.

Input: index = Index of desired ID type = Result Type (SM_SubcPollut) Output: PollutArray pointer (pollutant data desired, byref) Return: API Error Purpose: Gets Subcatchment Simulated Pollutant Value at Current Time

Definition at line 1687 of file toolkitAPI.c.

◆ swmm_getSubcatchStats()

int DLLEXPORT swmm_getSubcatchStats ( int  index,
SM_SubcatchStats **  subcatchStats 
)

Get subcatchment statistics.

Output: Subcatchment Stats Structure (SM_SubcatchStats) Return: API Error Purpose: Gets Subcatchment Stats and Converts Units

Definition at line 1981 of file toolkitAPI.c.

◆ swmm_project_findObject()

int DLLEXPORT swmm_project_findObject ( int  type,
char *  id,
int *  index 
)

Finds the index of an object given its ID.

Parameters
typeAn object type
idThe object ID
[out]indexThe objects index
Returns
Error code

Definition at line 54 of file toolkitAPI.c.

◆ swmm_setGagePrecip()

int DLLEXPORT swmm_setGagePrecip ( int  index,
double  total_precip 
)

Set a total precipitation intensity to the gage.

Input: index = Index of desired ID total_precip = rainfall intensity to be set Return: API Error Purpose: Sets the precipitation in from the external database

Definition at line 2451 of file toolkitAPI.c.

◆ swmm_setLidCParam()

int DLLEXPORT swmm_setLidCParam ( int  lidControlIndex,
int  layerIndex,
int  Param,
double  value 
)

Set a property value for specified lid control.

Parameters
lidControlIndexThe index of specified lid control
layerIndexThe index of specified lid layer (See SM_LidLayer)
ParamThe property type code (See SM_LidLayerProperty)
valueThe new value for the lid control's property
Returns
Error code

Definition at line 1304 of file toolkitAPI.c.

◆ swmm_setLidUOption()

int DLLEXPORT swmm_setLidUOption ( int  index,
int  lidIndex,
int  Param,
int  value 
)

Set the lid option for a specified lid unit on a specified subcatchment.

Parameters
indexThe index of a subcatchment
lidIndexThe index of specified lid unit
ParamThe lid option type code (See SM_LidUOptions)
valueThe new value of the option for the lid unit
Returns
Error code

Definition at line 1022 of file toolkitAPI.c.

◆ swmm_setLidUParam()

int DLLEXPORT swmm_setLidUParam ( int  index,
int  lidIndex,
int  Param,
double  value 
)

Set a property value for a specified lid unit on a specified subcatchment.

Parameters
indexThe index of a subcatchment
lidIndexThe index of specified lid unit
ParamThe property type code (See SM_LidUProperty)
valueThe new value of the lid unit's property
Returns
Error code

Definition at line 905 of file toolkitAPI.c.