SWMM-Docs  5.2.0.dev4
Stormwater Management Model
Data Structures | Enumerations | Functions
toolkitAPI.h File Reference

Exportable Functions for Toolkit API. More...

#include "../src/datetime.h"

Go to the source code of this file.

Data Structures

struct  SM_NodeStats
 Node Statatistics. More...
 
struct  SM_StorageStats
 Storage Statatistics. More...
 
struct  SM_OutfallStats
 Outfall Statatistics. More...
 
struct  SM_LinkStats
 Link Statatistics. More...
 
struct  SM_PumpStats
 Pump Statistics. More...
 
struct  SM_SubcatchStats
 Subcatchment Statistics. More...
 
struct  SM_RoutingTotals
 System Flow Routing Statistics. More...
 
struct  SM_RunoffTotals
 System runoff stats structure. More...
 

Enumerations

enum  SM_ObjectType {
  SM_GAGE = 0, SM_SUBCATCH = 1, SM_NODE = 2, SM_LINK = 3,
  SM_POLLUT = 4, SM_LANDUSE = 5, SM_TIMEPATTERN = 6, SM_CURVE = 7,
  SM_TSERIES = 8, SM_CONTROL = 9, SM_TRANSECT = 10, SM_AQUIFER = 11,
  SM_UNITHYD = 12, SM_SNOWMELT = 13, SM_SHAPE = 14, SM_LID = 15
}
 Object type codes. More...
 
enum  SM_NodeType { SM_JUNCTION = 0, SM_OUTFALL = 1, SM_STORAGE = 2, SM_DIVIDER = 3 }
 Node object type codes. More...
 
enum  SM_LinkType {
  SM_CONDUIT = 0, SM_PUMP = 1, SM_ORIFICE = 2, SM_WEIR = 3,
  SM_OUTLET = 4
}
 Link object type codes. More...
 
enum  SM_TimePropety { SM_STARTDATE = 0, SM_ENDDATE = 1, SM_REPORTDATE = 2 }
 Simulation Option codes. More...
 
enum  SM_Units { SM_SYSTEMUNIT = 0, SM_FLOWUNIT = 1 }
 Simulation Unit Codes. More...
 
enum  SM_SimOption {
  SM_ALLOWPOND = 0, SM_SKIPSTEADY = 1, SM_IGNORERAIN = 2, SM_IGNORERDII = 3,
  SM_IGNORESNOW = 4, SM_IGNOREGW = 5, SM_IGNOREROUTE = 6, SM_IGNORERQUAL = 7
}
 Simulation Options. More...
 
enum  SM_SimSetting {
  SM_ROUTESTEP = 0, SM_MINROUTESTEP = 1, SM_LENGTHSTEP = 2, SM_STARTDRYDAYS = 3,
  SM_COURANTFACTOR = 4, SM_MINSURFAREA = 5, SM_MINSLOPE = 6, SM_RUNOFFERROR = 7,
  SM_GWERROR = 8, SM_FLOWERROR = 9, SM_QUALERROR = 10, SM_HEADTOL = 11,
  SM_SYSFLOWTOL = 12, SM_LATFLOWTOL = 13
}
 Simulation Settings. More...
 
enum  SM_NodeProperty {
  SM_INVERTEL = 0, SM_FULLDEPTH = 1, SM_SURCHDEPTH = 2, SM_PONDAREA = 3,
  SM_INITDEPTH = 4
}
 Node property codes. More...
 
enum  SM_LinkProperty {
  SM_OFFSET1 = 0, SM_OFFSET2 = 1, SM_INITFLOW = 2, SM_FLOWLIMIT = 3,
  SM_INLETLOSS = 4, SM_OUTLETLOSS = 5, SM_AVELOSS = 6
}
 Link property codes. More...
 
enum  SM_SubcProperty {
  SM_WIDTH = 0, SM_AREA = 1, SM_FRACIMPERV = 2, SM_SLOPE = 3,
  SM_CURBLEN = 4
}
 Subcatchment property codes. More...
 
enum  SM_NodeResult {
  SM_TOTALINFLOW = 0, SM_TOTALOUTFLOW = 1, SM_LOSSES = 2, SM_NODEVOL = 3,
  SM_NODEFLOOD = 4, SM_NODEDEPTH = 5, SM_NODEHEAD = 6, SM_LATINFLOW = 7
}
 Node result property codes. More...
 
enum  SM_LinkResult {
  SM_LINKFLOW = 0, SM_LINKDEPTH = 1, SM_LINKVOL = 2, SM_USSURFAREA = 3,
  SM_DSSURFAREA = 4, SM_SETTING = 5, SM_TARGETSETTING = 6, SM_FROUDE = 7
}
 Link result property codes. More...
 
enum  SM_SubcResult {
  SM_SUBCRAIN = 0, SM_SUBCEVAP = 1, SM_SUBCINFIL = 2, SM_SUBCRUNON = 3,
  SM_SUBCRUNOFF = 4, SM_SUBCSNOW = 5
}
 Subcatchment result property codes. More...
 
enum  SM_SubcPollut { SM_BUILDUP = 0, SM_CPONDED = 1 }
 Subcatchment pollutant result property codes. More...
 
enum  SM_GagePrecip { SM_TOTALPRECIP = 0, SM_RAINFALL = 1, SM_SNOWFALL = 2 }
 Gage precip array property codes. More...
 

Functions

void DLLEXPORT swmm_getAPIError (int errcode, char *s)
 Get the text of an error code. 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_getObjectId (int type, int index, char *id)
 Gets Object ID. More...
 
int DLLEXPORT swmm_getObjectIndex (int type, char *id, int *errcode)
 Gets Object ID Index. 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_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_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_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_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_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.h

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

Definition in file toolkitAPI.h.

Enumeration Type Documentation

◆ SM_GagePrecip

Gage precip array property codes.

Enumerator
SM_TOTALPRECIP 

Total Precipitation Rate

SM_RAINFALL 

Rainfall Rate

SM_SNOWFALL 

Snowfall Rate

Definition at line 182 of file toolkitAPI.h.

◆ SM_LinkProperty

Link property codes.

Enumerator
SM_OFFSET1 

Inlet Offset

SM_OFFSET2 

Outlet Offset

SM_INITFLOW 

Initial Flow Rate

SM_FLOWLIMIT 

Flow limit

SM_INLETLOSS 

Inlet Loss

SM_OUTLETLOSS 

Outles Loss

SM_AVELOSS 

Average Loss

Definition at line 122 of file toolkitAPI.h.

◆ SM_LinkResult

Link result property codes.

Enumerator
SM_LINKFLOW 

Flowrate

SM_LINKDEPTH 

Depth

SM_LINKVOL 

Volume

SM_USSURFAREA 

Upstream Surface Area

SM_DSSURFAREA 

Downstream Surface Area

SM_SETTING 

Setting

SM_TARGETSETTING 

Target Setting

SM_FROUDE 

Froude Number

Definition at line 154 of file toolkitAPI.h.

◆ SM_LinkType

Link object type codes.

Enumerator
SM_CONDUIT 

Conduit

SM_PUMP 

Pump

SM_ORIFICE 

Orifice

SM_WEIR 

Weir

SM_OUTLET 

Outlet

Definition at line 61 of file toolkitAPI.h.

◆ SM_NodeProperty

Node property codes.

Enumerator
SM_INVERTEL 

Invert Elevation

SM_FULLDEPTH 

Full Depth

SM_SURCHDEPTH 

Surcharge Depth

SM_PONDAREA 

Ponding Area

SM_INITDEPTH 

Initial Depth

Definition at line 113 of file toolkitAPI.h.

◆ SM_NodeResult

Node result property codes.

Enumerator
SM_TOTALINFLOW 

Total Inflow

SM_TOTALOUTFLOW 

Total Outflow

SM_LOSSES 

Node Losses

SM_NODEVOL 

Stored Volume

SM_NODEFLOOD 

Flooding Rate

SM_NODEDEPTH 

Node Depth

SM_NODEHEAD 

Node Head

SM_LATINFLOW 

Lateral Inflow Rate

Definition at line 142 of file toolkitAPI.h.

◆ SM_NodeType

Node object type codes.

Enumerator
SM_JUNCTION 

Manhole Junction

SM_OUTFALL 

Outfall

SM_STORAGE 

Storage

SM_DIVIDER 

Divider

Definition at line 53 of file toolkitAPI.h.

◆ SM_ObjectType

Object type codes.

Enumerator
SM_GAGE 

Rain gage

SM_SUBCATCH 

Subcatchment

SM_NODE 

Conveyance system node

SM_LINK 

Conveyance system link

SM_POLLUT 

Pollutant

SM_LANDUSE 

Land use category

SM_TIMEPATTERN 

Dry weather flow time pattern

SM_CURVE 

Generic table of values

SM_TSERIES 

Generic time series of values

SM_CONTROL 

Conveyance system control rules

SM_TRANSECT 

Irregular channel cross-section

SM_AQUIFER 

Groundwater aquifer

SM_UNITHYD 

RDII unit hydrograph

SM_SNOWMELT 

Snowmelt parameter set

SM_SHAPE 

Custom conduit shape

SM_LID 

LID treatment units

Definition at line 33 of file toolkitAPI.h.

◆ SM_SimOption

Simulation Options.

Enumerator
SM_ALLOWPOND 

Allow Ponding

SM_SKIPSTEADY 

Skip Steady State

SM_IGNORERAIN 

Ignore Rainfall

SM_IGNORERDII 

Ignore RDII

SM_IGNORESNOW 

Ignore Snowmelt

SM_IGNOREGW 

Ignore Groundwater

SM_IGNOREROUTE 

Ignore Routing

SM_IGNORERQUAL 

Ignore Quality

Definition at line 83 of file toolkitAPI.h.

◆ SM_SimSetting

Simulation Settings.

Enumerator
SM_ROUTESTEP 

Routing Step (sec)

SM_MINROUTESTEP 

Minimum Routing Step (sec)

SM_LENGTHSTEP 

Lengthening Step (sec)

SM_STARTDRYDAYS 

Antecedent dry days

SM_COURANTFACTOR 

Courant time step factor

SM_MINSURFAREA 

Minimum nodal surface area

SM_MINSLOPE 

Minimum conduit slope

SM_RUNOFFERROR 

Runoff continuity error

SM_GWERROR 

Groundwater continuity error

SM_FLOWERROR 

Flow routing error

SM_QUALERROR 

Quality routing error

SM_HEADTOL 

DW routing head tolerance (ft)

SM_SYSFLOWTOL 

Tolerance for steady system flow

SM_LATFLOWTOL 

Tolerance for steady nodal inflow

Definition at line 95 of file toolkitAPI.h.

◆ SM_SubcPollut

Subcatchment pollutant result property codes.

Enumerator
SM_BUILDUP 

Pollutant Buildup Load

SM_CPONDED 

Ponded Pollutant Concentration

Definition at line 176 of file toolkitAPI.h.

◆ SM_SubcProperty

Subcatchment property codes.

Enumerator
SM_WIDTH 

Width

SM_AREA 

Area

SM_FRACIMPERV 

Impervious Fraction

SM_SLOPE 

Slope

SM_CURBLEN 

Curb Length

Definition at line 133 of file toolkitAPI.h.

◆ SM_SubcResult

Subcatchment result property codes.

Enumerator
SM_SUBCRAIN 

Rainfall Rate

SM_SUBCEVAP 

Evaporation Loss

SM_SUBCINFIL 

Infiltration Loss

SM_SUBCRUNON 

Runon Rate

SM_SUBCRUNOFF 

Runoff Rate

SM_SUBCSNOW 

Snow Depth

Definition at line 166 of file toolkitAPI.h.

◆ SM_TimePropety

Simulation Option codes.

Enumerator
SM_STARTDATE 

Simulation Start Date

SM_ENDDATE 

Simulation End Date

SM_REPORTDATE 

Simulation Report Start Date

Definition at line 70 of file toolkitAPI.h.

◆ SM_Units

enum SM_Units

Simulation Unit Codes.

Enumerator
SM_SYSTEMUNIT 

System Units

SM_FLOWUNIT 

Flow Units

Definition at line 77 of file toolkitAPI.h.

Function Documentation

◆ freeArray()

void DLLEXPORT freeArray ( void **  array)

Helper function to free memory array allocated in SWMM.

Parameters
arrayThe pointer to the array
Returns
Void.

Helper function used to free array allocated memory by API.

Definition at line 1571 of file toolkitAPI.c.

◆ swmm_getGagePrecip()

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

Get precipitation rates for a gage.

Parameters
indexThe index of gage
[out]GageArrayprecipitation rates array [total, rainfall, snowfall]
Returns
Error code

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 1032 of file toolkitAPI.c.

◆ swmm_getObjectIndex()

int DLLEXPORT swmm_getObjectIndex ( int  type,
char *  id,
int *  errcode 
)

Gets Object ID Index.

Parameters
typeOption code (see SM_ObjectType)
[out]idof the Object
[out]errcodeError Code
Returns
Object Injdex

Input: type = object type (Based on SM_ObjectType enum) char* = ID name Output: errorcode = pointer to error code Return: Object Index Purpose: Gets object id index

Definition at line 292 of file toolkitAPI.c.

◆ swmm_getSubcatchPollut()

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

Gets pollutant values for a specified subcatchment.

Parameters
indexThe index of a subcatchment
typeThe property type code (see SM_SubcPollut)
[out]PollutArrayresult array
Returns
Error code

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 978 of file toolkitAPI.c.

◆ swmm_setGagePrecip()

int DLLEXPORT swmm_setGagePrecip ( int  index,
double  total_precip 
)

Set a total precipitation intensity to the gage.

Parameters
indexThe gage index.
total_precipThe new total precipitation intensity.
Returns
Error code

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 1520 of file toolkitAPI.c.