SWMM-Docs  5.2.0.dev5
Stormwater Management Model
toolkitAPI.h
Go to the documentation of this file.
1 
11 #ifndef TOOLKITAPI_H
12 #define TOOLKITAPI_H
13 
14 #ifdef WINDOWS
15 #ifdef __MINGW32__
16 #define DLLEXPORT __declspec(dllexport) __cdecl
17 #else
18 #define DLLEXPORT __declspec(dllexport) __stdcall
19 #endif
20 #else
21 #define DLLEXPORT
22 #endif
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #define _CRT_SECURE_NO_DEPRECATE
29 
30 #include "../src/datetime.h"
31 
33 typedef enum {
34  SM_GAGE = 0,
36  SM_NODE = 2,
37  SM_LINK = 3,
38  SM_POLLUT = 4,
39  SM_LANDUSE = 5,
41  SM_CURVE = 7,
42  SM_TSERIES = 8,
43  SM_CONTROL = 9,
44  SM_TRANSECT = 10,
45  SM_AQUIFER = 11,
46  SM_UNITHYD = 12,
47  SM_SNOWMELT = 13,
48  SM_SHAPE = 14,
49  SM_LID = 15
51 
53 typedef enum {
55  SM_OUTFALL = 1,
56  SM_STORAGE = 2,
58 } SM_NodeType;
59 
61 typedef enum {
62  SM_CONDUIT = 0,
63  SM_PUMP = 1,
64  SM_ORIFICE = 2,
65  SM_WEIR = 3,
66  SM_OUTLET = 4
67 } SM_LinkType;
68 
70 typedef enum {
72  SM_ENDDATE = 1,
75 
77 typedef enum {
80 } SM_Units;
81 
83 typedef enum {
92 } SM_SimOption;
93 
95 typedef enum {
107  SM_HEADTOL = 11,
110 } SM_SimSetting;
111 
113 typedef enum {
120 
122 typedef enum {
131 
133 typedef enum {
134  SM_WIDTH = 0,
135  SM_AREA = 1,
137  SM_SLOPE = 3,
140 
142 typedef enum {
145  SM_LOSSES = 2,
151 } SM_NodeResult;
152 
154 typedef enum {
163 } SM_LinkResult;
164 
166 typedef enum {
173 } SM_SubcResult;
174 
176 typedef enum {
179 } SM_SubcPollut;
180 
182 typedef enum {
186 } SM_GagePrecip;
187 
189 typedef enum {
191  SM_SOIL = 1,
192  SM_STOR = 2,
193  SM_PAVE = 3,
194  SM_DRAIN = 4,
196 } SM_LidLayer;
197 
199 typedef enum {
205  SM_ALPHA = 5,
210  SM_KSAT = 10,
211  SM_KSLOPE = 11,
214  SM_COEFF = 14,
215  SM_EXPON = 15,
216  SM_OFFSET = 16,
217  SM_DELAY = 17,
218  SM_HOPEN = 18,
219  SM_HCLOSE = 19,
220  SM_QCURVE = 20,
224 
226 typedef enum {
228  SM_FWIDTH = 1,
229  SM_BWIDTH = 2,
234 
236 typedef enum {
237  SM_INDEX = 0,
238  SM_NUMBER = 1,
239  SM_TOPERV = 2,
243 
245 typedef enum {
246  SM_INFLOW = 0,
247  SM_EVAP = 1,
248  SM_INFIL = 2,
257  SM_DRYTIME = 11,
260  SM_PERVAREA = 14,
262  SM_EVAPRATE = 16,
266  SM_SURFEVAP = 20,
268  SM_PAVEEVAP = 22,
269  SM_PAVEPERC = 23,
270  SM_SOILEVAP = 24,
271  SM_SOILPERC = 25,
276 } SM_LidResult;
277 
278 // --- Define the SWMM toolkit structures
279 
281 typedef struct
282 {
283  double avgDepth;
284  double maxDepth;
285  DateTime maxDepthDate;
286  double maxRptDepth;
287  double volFlooded;
288  double timeFlooded;
289  double timeSurcharged;
290  double timeCourantCritical;
291  double totLatFlow;
292  double maxLatFlow;
293  double maxInflow;
294  double maxOverflow;
295  double maxPondedVol;
296  DateTime maxInflowDate;
297  DateTime maxOverflowDate;
298 } SM_NodeStats;
299 
318 typedef struct
319 {
320  double initVol;
321  double avgVol;
322  double maxVol;
323  double maxFlow;
324  double evapLosses;
325  double exfilLosses;
326  DateTime maxVolDate;
328 
341 typedef struct
342 {
343  double avgFlow;
344  double maxFlow;
345  double* totalLoad;
348 
392 typedef struct
393 {
394  double maxFlow;
395  DateTime maxFlowDate;
396  double maxVeloc;
397  double maxDepth;
403  double timeFullFlow;
405  double timeInFlowClass[7];
407  long flowTurns;
409 } SM_LinkStats;
410 
435 typedef struct
436 {
437  double utilized;
438  double minFlow;
439  double avgFlow;
440  double maxFlow;
441  double volume;
442  double energy;
443  double offCurveLow;
444  double offCurveHigh;
445  int startUps;
447 } SM_PumpStats;
448 
465 typedef struct
466 {
467  double precip;
468  double runon;
469  double evap;
470  double infil;
471  double runoff;
472  double maxFlow;
474 
505 typedef struct
506 {
507  double dwInflow;
508  double wwInflow;
509  double gwInflow;
510  double iiInflow;
511  double exInflow;
512  double flooding;
513  double outflow;
514  double evapLoss;
515  double seepLoss;
516  double reacted;
517  double initStorage;
518  double finalStorage;
519  double pctError;
521 
523 
524 
553 typedef struct
554 {
555  double rainfall;
556  double evap;
557  double infil;
558  double runoff;
559  double drains;
560  double runon;
561  double initStorage;
562  double finalStorage;
565  double snowRemoved;
566  double pctError;
568 
574 void DLLEXPORT swmm_getAPIError(int errcode, char *s);
575 
583 int DLLEXPORT swmm_project_findObject(int type, char *id, int *index);
584 
591 int DLLEXPORT swmm_getSimulationUnit(int type, int *value);
592 
599 int DLLEXPORT swmm_getSimulationAnalysisSetting(int type, int *value);
600 
607 int DLLEXPORT swmm_getSimulationParam(int type, double *value);
608 
615 int DLLEXPORT swmm_countObjects(int type, int *count);
616 
624 int DLLEXPORT swmm_getObjectId(int type, int index, char *id);
625 
633 int DLLEXPORT swmm_getObjectIndex(SM_ObjectType type, char *id, int *index);
634 
642 int DLLEXPORT swmm_getNodeType(int index, int *Ntype);
643 
650 int DLLEXPORT swmm_getLinkType(int index, int *Ltype);
651 
661 int DLLEXPORT swmm_getLinkConnections(int index, int *Node1, int *Node2);
662 
669 int DLLEXPORT swmm_getLinkDirection(int index, signed char *value);
670 
679 int DLLEXPORT swmm_getSubcatchOutConnection(int index, int *type, int *out_index);
680 
687 int DLLEXPORT swmm_getLidUCount(int index, int *value);
688 
697 int DLLEXPORT swmm_getLidUParam(int index, int lidIndex, int Param, double *value);
698 
707 int DLLEXPORT swmm_setLidUParam(int index, int lidIndex, int Param, double value);
708 
717 int DLLEXPORT swmm_getLidUOption(int index, int lidIndex, int Param, int *value);
718 
727 int DLLEXPORT swmm_setLidUOption(int index, int lidIndex, int Param, int value);
728 
735 int DLLEXPORT swmm_getLidCOverflow(int lidControlIndex, char *condition);
736 
743 int DLLEXPORT swmm_setLidCOverflow(int lidControlIndex, char condition);
744 
753 int DLLEXPORT swmm_getLidCParam(int lidControlIndex, int layerIndex, int Param, double *value);
754 
763 int DLLEXPORT swmm_setLidCParam(int lidControlIndex, int layerIndex, int Param, double value);
764 
774 int DLLEXPORT swmm_getLidUFluxRates(int index, int lidIndex, int layerIndex, double *result);
775 
783 int DLLEXPORT swmm_getLidGResult(int index, int type, double *result);
784 
793 int DLLEXPORT swmm_getLidUResult(int index, int lidIndex, int type, double *result);
794 
802 int DLLEXPORT swmm_getNodeParam(int index, int Param, double *value);
803 
811 int DLLEXPORT swmm_setNodeParam(int index, int Param, double value);
812 
820 int DLLEXPORT swmm_getLinkParam(int index, int Param, double *value);
821 
829 int DLLEXPORT swmm_setLinkParam(int index, int Param, double value);
830 
838 int DLLEXPORT swmm_getSubcatchParam(int index, int Param, double *value);
839 
847 int DLLEXPORT swmm_setSubcatchParam(int index, int Param, double value);
848 
860 int DLLEXPORT swmm_getSimulationDateTime(int timetype, int *year, int *month,
861  int *day, int *hour, int *minute,
862  int *second);
863 
871 int DLLEXPORT swmm_setSimulationDateTime(int timetype, char *dtimestr);
872 
879 int DLLEXPORT swmm_getCurrentDateTimeStr(char *dtimestr);
880 
888 int DLLEXPORT swmm_getNodeResult(int index, int type, double *result);
889 
897 int DLLEXPORT swmm_getLinkResult(int index, int type, double *result);
898 
906 int DLLEXPORT swmm_getSubcatchResult(int index, int type, double *result);
907 
915 int DLLEXPORT swmm_getSubcatchPollut(int index, int type, double **PollutArray);
916 
923 int DLLEXPORT swmm_getGagePrecip(int index, double **GageArray);
924 
932 int DLLEXPORT swmm_getNodeStats(int index, SM_NodeStats *nodeStats);
933 
940 int DLLEXPORT swmm_getNodeTotalInflow(int index, double *value);
941 
949 int DLLEXPORT swmm_getStorageStats(int index, SM_StorageStats *storageStats);
950 
960 int DLLEXPORT swmm_getOutfallStats(int index, SM_OutfallStats *outfallStats);
961 
968 void DLLEXPORT swmm_freeOutfallStats(SM_OutfallStats *outfallStats);
969 
977 int DLLEXPORT swmm_getLinkStats(int index, SM_LinkStats *linkStats);
978 
986 int DLLEXPORT swmm_getPumpStats(int index, SM_PumpStats *pumpStats);
987 
997 int DLLEXPORT swmm_getSubcatchStats(int index, SM_SubcatchStats **subcatchStats);
998 
1005 int DLLEXPORT swmm_getSystemRoutingStats(SM_RoutingTotals *routingTot);
1006 
1013 int DLLEXPORT swmm_getSystemRunoffStats(SM_RunoffTotals *runoffTot);
1014 
1023 int DLLEXPORT swmm_setLinkSetting(int index, double setting);
1024 
1032 int DLLEXPORT swmm_setNodeInflow(int index, double flowrate);
1033 
1040 int DLLEXPORT swmm_setOutfallStage(int index, double stage);
1041 
1048 int DLLEXPORT swmm_setGagePrecip(int index, double total_precip);
1049 
1055 void DLLEXPORT freeArray(void** array);
1056 
1057 #ifdef __cplusplus
1058 } // matches the linkage specification from above */
1059 #endif
1060 
1061 
1062 #endif
int DLLEXPORT swmm_setLidCOverflow(int lidControlIndex, char condition)
Set the lid control's surface immediate overflow condition.
double energy
Definition: toolkitAPI.h:442
int DLLEXPORT swmm_getObjectId(int type, int index, char *id)
Gets Object ID.
Definition: toolkitAPI.c:329
double volume
Definition: toolkitAPI.h:441
int DLLEXPORT swmm_setGagePrecip(int index, double total_precip)
Set a total precipitation intensity to the gage.
Definition: toolkitAPI.c:2451
int DLLEXPORT swmm_getLinkResult(int index, int type, double *result)
Get a result value for specified link.
Definition: toolkitAPI.c:1597
SM_LidResult
Lid unit result codes.
Definition: toolkitAPI.h:245
double utilized
Definition: toolkitAPI.h:437
double finalSnowCover
Definition: toolkitAPI.h:564
SM_LinkResult
Link result property codes.
Definition: toolkitAPI.h:154
SM_LidUProperty
Lid unit property codes.
Definition: toolkitAPI.h:226
SM_LidLayer
Lid control layer codes.
Definition: toolkitAPI.h:189
int totalPeriods
Definition: toolkitAPI.h:446
double maxFlow
Definition: toolkitAPI.h:440
SM_NodeResult
Node result property codes.
Definition: toolkitAPI.h:142
SM_SimOption
Simulation Options.
Definition: toolkitAPI.h:83
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,...
Definition: toolkitAPI.c:2312
int DLLEXPORT swmm_getObjectIndex(SM_ObjectType type, char *id, int *index)
Gets Object Index.
Definition: toolkitAPI.c:310
Node stats structure.
Definition: toolkitAPI.h:281
int DLLEXPORT swmm_getLidCParam(int lidControlIndex, int layerIndex, int Param, double *value)
Get a property value for specified lid control.
Definition: toolkitAPI.c:1121
int DLLEXPORT swmm_getLidUFluxRates(int index, int lidIndex, int layerIndex, double *result)
Get the lid unit water balance simulated value at current time.
Definition: toolkitAPI.c:2109
int DLLEXPORT swmm_getLidUCount(int index, int *value)
Get the number of lid units on a subcatchment.
Definition: toolkitAPI.c:824
SM_SubcResult
Subcatchment result property codes.
Definition: toolkitAPI.h:166
int DLLEXPORT swmm_getNodeResult(int index, int type, double *result)
Get a result value for specified node.
Definition: toolkitAPI.c:1549
int DLLEXPORT swmm_getStorageStats(int index, SM_StorageStats *storageStats)
Get a storage statistics.
Definition: toolkitAPI.c:1834
int DLLEXPORT swmm_getSubcatchStats(int index, SM_SubcatchStats **subcatchStats)
Get subcatchment statistics.
Definition: toolkitAPI.c:1981
int DLLEXPORT swmm_getSubcatchResult(int index, int type, double *result)
Get a result value for specified subcatchment.
Definition: toolkitAPI.c:1644
int DLLEXPORT swmm_getGagePrecip(int index, double **GageArray)
Get precipitation rates for a gage.
Definition: toolkitAPI.c:1741
int DLLEXPORT swmm_setSimulationDateTime(int timetype, char *dtimestr)
Set simulation datetime information.
Definition: toolkitAPI.c:110
double offCurveHigh
Definition: toolkitAPI.h:444
int DLLEXPORT swmm_getSubcatchPollut(int index, int type, double **PollutArray)
Gets pollutant values for a specified subcatchment.
Definition: toolkitAPI.c:1687
SM_LidUOptions
Lid unit option codes.
Definition: toolkitAPI.h:236
int DLLEXPORT swmm_getLidGResult(int index, int type, double *result)
Get the lid group of a specified subcatchment result at current time.
Definition: toolkitAPI.c:2160
SM_SubcPollut
Subcatchment pollutant result property codes.
Definition: toolkitAPI.h:176
int DLLEXPORT swmm_getNodeStats(int index, SM_NodeStats *nodeStats)
Get a node statistics.
Definition: toolkitAPI.c:1780
Pump Statistics.
Definition: toolkitAPI.h:435
double initSnowCover
Definition: toolkitAPI.h:563
int DLLEXPORT swmm_getNodeParam(int index, int Param, double *value)
Get a property value for specified node.
Definition: toolkitAPI.c:501
int DLLEXPORT swmm_setNodeParam(int index, int Param, double value)
Set a property value for specified node.
Definition: toolkitAPI.c:541
SM_NodeType
Node object type codes.
Definition: toolkitAPI.h:53
void DLLEXPORT swmm_getAPIError(int errcode, char *s)
Get the text of an error code.
Definition: toolkitAPI.c:42
SM_SubcProperty
Subcatchment property codes.
Definition: toolkitAPI.h:133
Subcatchment Statistics.
Definition: toolkitAPI.h:465
double offCurveLow
Definition: toolkitAPI.h:443
double avgFlow
Definition: toolkitAPI.h:439
int DLLEXPORT swmm_setLidCParam(int lidControlIndex, int layerIndex, int Param, double value)
Set a property value for specified lid control.
Definition: toolkitAPI.c:1304
int DLLEXPORT swmm_getPumpStats(int index, SM_PumpStats *pumpStats)
Get pump statistics.
Definition: toolkitAPI.c:1950
int DLLEXPORT swmm_countObjects(int type, int *count)
Gets Object Count.
Definition: toolkitAPI.c:297
System runoff stats structure.
Definition: toolkitAPI.h:553
int DLLEXPORT swmm_getSimulationAnalysisSetting(int type, int *value)
Gets Simulation Analysis Setting.
Definition: toolkitAPI.c:202
Storage Statatistics.
Definition: toolkitAPI.h:318
SM_SimSetting
Simulation Settings.
Definition: toolkitAPI.h:95
int DLLEXPORT swmm_getSystemRunoffStats(SM_RunoffTotals *runoffTot)
Get system runoff statistics.
Definition: toolkitAPI.c:2069
int DLLEXPORT swmm_getSubcatchParam(int index, int Param, double *value)
Get a property value for specified subcatchment.
Definition: toolkitAPI.c:689
SM_LidLayerProperty
Lid control layer property codes.
Definition: toolkitAPI.h:199
int DLLEXPORT swmm_getSimulationParam(int type, double *value)
Gets Simulation Analysis Setting.
Definition: toolkitAPI.c:243
double finalStorage
Definition: toolkitAPI.h:562
SM_NodeProperty
Node property codes.
Definition: toolkitAPI.h:113
double minFlow
Definition: toolkitAPI.h:438
int DLLEXPORT swmm_getNodeType(int index, int *Ntype)
Get the type of node with specified index.
Definition: toolkitAPI.c:399
double snowRemoved
Definition: toolkitAPI.h:565
Outfall Statatistics.
Definition: toolkitAPI.h:341
int DLLEXPORT swmm_getSubcatchOutConnection(int index, int *type, int *out_index)
Get the Subcatchment connection. Subcatchments can load to a node, another subcatchment,...
Definition: toolkitAPI.c:780
int DLLEXPORT swmm_getLinkType(int index, int *Ltype)
Get the type of link with specified index.
Definition: toolkitAPI.c:423
int DLLEXPORT swmm_setLinkParam(int index, int Param, double value)
Set a property value for specified link.
Definition: toolkitAPI.c:631
double initStorage
Definition: toolkitAPI.h:517
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.
Definition: toolkitAPI.c:2355
SM_Units
Simulation Unit Codes.
Definition: toolkitAPI.h:77
int DLLEXPORT swmm_getSimulationDateTime(int timetype, int *year, int *month, int *day, int *hour, int *minute, int *second)
Get the current simulation datetime information.
Definition: toolkitAPI.c:69
SM_LinkProperty
Link property codes.
Definition: toolkitAPI.h:122
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 wi...
Definition: toolkitAPI.c:447
int DLLEXPORT swmm_getLidCOverflow(int lidControlIndex, char *condition)
Get the lid control surface immediate overflow condition.
Definition: toolkitAPI.c:1089
int DLLEXPORT swmm_project_findObject(int type, char *id, int *index)
Finds the index of an object given its ID.
Definition: toolkitAPI.c:54
SM_TimePropety
Simulation Option codes.
Definition: toolkitAPI.h:70
int DLLEXPORT swmm_setSubcatchParam(int index, int Param, double value)
Set a property value for specified subcatchment.
Definition: toolkitAPI.c:729
int DLLEXPORT swmm_getSystemRoutingStats(SM_RoutingTotals *routingTot)
Get system routing statistics.
Definition: toolkitAPI.c:2034
double evapLosses
Definition: toolkitAPI.h:324
double finalStorage
Definition: toolkitAPI.h:518
System Flow Routing Statistics.
Definition: toolkitAPI.h:505
int DLLEXPORT swmm_getCurrentDateTimeStr(char *dtimestr)
Get the simulation current datetime as a string.
Definition: toolkitAPI.c:1517
double exfilLosses
Definition: toolkitAPI.h:325
int DLLEXPORT swmm_getLinkStats(int index, SM_LinkStats *linkStats)
Get link statistics.
Definition: toolkitAPI.c:1912
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.
Definition: toolkitAPI.c:970
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.
Definition: toolkitAPI.c:905
int DLLEXPORT swmm_setOutfallStage(int index, double stage)
Set outfall stage.
Definition: toolkitAPI.c:2416
void DLLEXPORT swmm_freeOutfallStats(SM_OutfallStats *outfallStats)
Free outfall statistics structure.
Definition: toolkitAPI.c:1900
int DLLEXPORT swmm_getSimulationUnit(int type, int *value)
Gets Simulation Unit.
Definition: toolkitAPI.c:170
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.
Definition: toolkitAPI.c:851
int DLLEXPORT swmm_getOutfallStats(int index, SM_OutfallStats *outfallStats)
Get outfall statistics.
Definition: toolkitAPI.c:1861
double initStorage
Definition: toolkitAPI.h:561
DateTime maxVolDate
Definition: toolkitAPI.h:326
SM_GagePrecip
Gage precip array property codes.
Definition: toolkitAPI.h:182
SM_ObjectType
Object type codes.
Definition: toolkitAPI.h:33
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.
Definition: toolkitAPI.c:1022
int DLLEXPORT swmm_getNodeTotalInflow(int index, double *value)
Get the cumulative inflow for a node.
Definition: toolkitAPI.c:1816
double * totalLoad
Definition: toolkitAPI.h:345
SM_LinkType
Link object type codes.
Definition: toolkitAPI.h:61
int DLLEXPORT swmm_getLidUResult(int index, int lidIndex, int type, double *result)
Get the lid unit of a specified subcatchment result at current time.
Definition: toolkitAPI.c:2209
int DLLEXPORT swmm_getLinkDirection(int index, signed char *value)
Get the link flow direction (see swmm_getLinkType() for notes.
Definition: toolkitAPI.c:475
void DLLEXPORT freeArray(void **array)
Helper function to free memory array allocated in SWMM.
Definition: toolkitAPI.c:2502
int DLLEXPORT swmm_getLinkParam(int index, int Param, double *value)
Get a property value for specified link.
Definition: toolkitAPI.c:587