11 #define _CRT_SECURE_NO_DEPRECATE 26 double massbal_getTotalArea(
void);
27 int massbal_getNodeTotalInflow(
int index,
double *value);
29 int stats_getNodeStat(
int index,
SM_NodeStats *nodeStats);
32 int stats_getLinkStat(
int index,
SM_LinkStats *linkStats);
33 int stats_getPumpStat(
int index,
SM_PumpStats *pumpStats);
34 TSubcatchStats *stats_getSubcatchStat(
int index);
49 char *errmsg = error_getMsg(errcode);
58 int idx = project_findObject(type,
id);
62 errorcode = ERR_API_OBJECT_INDEX;
70 int *hour,
int *minute,
int *second)
86 if (swmm_IsOpenFlag() == FALSE)
88 errcode = ERR_API_INPUTNOTOPEN;
101 default:
return(ERR_API_OUTBOUNDS);
103 datetime_decodeDate(_dtime, year, month, day);
104 datetime_decodeTime(_dtime, hour, minute, second);
123 if(swmm_IsOpenFlag() == FALSE)
125 errcode = ERR_API_INPUTNOTOPEN;
128 else if(swmm_IsStartedFlag() == TRUE)
130 errcode = ERR_API_SIM_NRUNNING;
134 strncpy(theDate, dtimestr, 10);
135 strncpy(theTime, dtimestr+11, 9);
141 project_readOption(
"START_DATE", theDate);
142 project_readOption(
"START_TIME", theTime);
143 StartDateTime = StartDate + StartTime;
144 TotalDuration = floor((EndDateTime - StartDateTime) * SECperDAY);
146 TotalDuration *= 1000.0;
150 project_readOption(
"END_DATE", theDate);
151 project_readOption(
"END_TIME", theTime);
152 EndDateTime = EndDate + EndTime;
153 TotalDuration = floor((EndDateTime - StartDateTime) * SECperDAY);
155 TotalDuration *= 1000.0;
159 project_readOption(
"REPORT_START_DATE", theDate);
160 project_readOption(
"REPORT_START_TIME", theTime);
161 ReportStart = ReportStartDate + ReportStartTime;
163 default: errcode = ERR_API_OUTBOUNDS;
break;
180 if(swmm_IsOpenFlag() == FALSE)
182 errcode = ERR_API_INPUTNOTOPEN;
195 default: errcode = ERR_API_OUTBOUNDS;
break;
212 if(swmm_IsOpenFlag() == FALSE)
214 errcode = ERR_API_INPUTNOTOPEN;
237 default: errcode = ERR_API_OUTBOUNDS;
break;
253 if(swmm_IsOpenFlag() == FALSE)
255 errcode = ERR_API_INPUTNOTOPEN;
291 default: errcode = ERR_API_OUTBOUNDS;
break;
305 if(type >= MAX_OBJ_TYPES)
return ERR_API_OUTBOUNDS;
306 *count = Nobjects[type];
321 if(swmm_IsOpenFlag() == TRUE)
322 *index = project_findObject(type,
id);
324 error = ERR_API_INPUTNOTOPEN;
343 if(swmm_IsOpenFlag() == FALSE)
345 errcode = ERR_API_INPUTNOTOPEN;
348 else if (index < 0 || index >= Nobjects[type])
350 errcode = ERR_API_OBJECT_INDEX;
357 strcpy(
id,Gage[index].ID);
break;
359 strcpy(
id,Subcatch[index].ID);
break;
361 strcpy(
id,Node[index].ID);
break;
363 strcpy(
id,Link[index].ID);
break;
365 strcpy(
id,Pollut[index].ID);
break;
367 strcpy(
id,Landuse[index].ID);
break;
369 strcpy(
id,Pattern[index].ID);
break;
371 strcpy(
id,Curve[index].ID);
break;
373 strcpy(
id,Tseries[index].ID);
break;
377 strcpy(
id,Transect[index].ID);
break;
379 strcpy(
id,Aquifer[index].ID);
break;
381 strcpy(
id,UnitHyd[index].ID);
break;
383 strcpy(
id,Snowmelt[index].ID);
break;
387 lidProc = lid_getLidProc(index);
390 strcpy(
id,lidProc->ID);
393 default: errcode = ERR_API_OUTBOUNDS;
break;
409 if(swmm_IsOpenFlag() == FALSE)
411 errcode = ERR_API_INPUTNOTOPEN;
414 else if (index < 0 || index >= Nobjects[NODE])
416 errcode = ERR_API_OBJECT_INDEX;
418 else *Ntype = Node[index].type;
433 if(swmm_IsOpenFlag() == FALSE)
435 errcode = ERR_API_INPUTNOTOPEN;
438 else if (index < 0 || index >= Nobjects[LINK])
440 errcode = ERR_API_OBJECT_INDEX;
442 else *Ltype = Link[index].type;
458 if(swmm_IsOpenFlag() == FALSE)
460 errcode = ERR_API_INPUTNOTOPEN;
463 else if (index < 0 || index >= Nobjects[LINK])
465 errcode = ERR_API_OBJECT_INDEX;
469 *Node1 = Link[index].node1;
470 *Node2 = Link[index].node2;
485 if(swmm_IsOpenFlag() == FALSE)
487 errcode = ERR_API_INPUTNOTOPEN;
490 else if (index < 0 || index >= Nobjects[LINK])
492 errcode = ERR_API_OBJECT_INDEX;
496 *value = Link[index].direction;
512 if(swmm_IsOpenFlag() == FALSE)
514 errcode = ERR_API_INPUTNOTOPEN;
517 else if (index < 0 || index >= Nobjects[NODE])
519 errcode = ERR_API_OBJECT_INDEX;
526 *value = Node[index].invertElev * UCF(LENGTH);
break;
528 *value = Node[index].fullDepth * UCF(LENGTH);
break;
530 *value = Node[index].surDepth * UCF(LENGTH);
break;
532 *value = Node[index].pondedArea * UCF(LENGTH) * UCF(LENGTH);
break;
534 *value = Node[index].initDepth * UCF(LENGTH);
break;
535 default: errcode = ERR_API_OUTBOUNDS;
break;
551 if(swmm_IsOpenFlag() == FALSE)
553 errcode = ERR_API_INPUTNOTOPEN;
556 else if(swmm_IsStartedFlag() == TRUE)
558 errcode = ERR_API_SIM_NRUNNING;
561 else if (index < 0 || index >= Nobjects[NODE])
563 errcode = ERR_API_OBJECT_INDEX;
570 Node[index].invertElev = value / UCF(LENGTH);
break;
572 Node[index].fullDepth = value / UCF(LENGTH);
break;
574 Node[index].surDepth = value / UCF(LENGTH);
break;
576 Node[index].pondedArea = value / ( UCF(LENGTH) * UCF(LENGTH) );
break;
578 Node[index].initDepth = value / UCF(LENGTH);
break;
579 default: errcode = ERR_API_OUTBOUNDS;
break;
598 if(swmm_IsOpenFlag() == FALSE)
600 errcode = ERR_API_INPUTNOTOPEN;
603 else if (index < 0 || index >= Nobjects[LINK])
605 errcode = ERR_API_OBJECT_INDEX;
612 *value = Link[index].offset1 * UCF(LENGTH);
break;
614 *value = Link[index].offset2 * UCF(LENGTH);
break;
616 *value = Link[index].q0 * UCF(FLOW);
break;
618 *value = Link[index].qLimit * UCF(FLOW);
break;
620 *value = Link[index].cLossInlet;
break;
622 *value = Link[index].cLossOutlet;
break;
624 *value = Link[index].cLossAvg;
break;
625 default: errcode = ERR_API_OUTBOUNDS;
break;
641 if(swmm_IsOpenFlag() == FALSE)
643 errcode = ERR_API_INPUTNOTOPEN;
646 else if (index < 0 || index >= Nobjects[LINK])
648 errcode = ERR_API_OBJECT_INDEX;
657 if(swmm_IsStartedFlag() == TRUE)
659 errcode = ERR_API_SIM_NRUNNING;
break;
661 Link[index].offset1 = value / UCF(LENGTH);
break;
664 if(swmm_IsStartedFlag() == TRUE)
666 errcode = ERR_API_SIM_NRUNNING;
break;
668 Link[index].offset2 = value / UCF(LENGTH);
break;
670 Link[index].q0 = value / UCF(FLOW);
break;
672 Link[index].qLimit = value / UCF(FLOW);
break;
674 Link[index].cLossInlet = value;
break;
676 Link[index].cLossOutlet = value;
break;
678 Link[index].cLossAvg = value;
break;
679 default: errcode = ERR_API_OUTBOUNDS;
break;
700 if(swmm_IsOpenFlag() == FALSE)
702 errcode = ERR_API_INPUTNOTOPEN;
705 else if (index < 0 || index >= Nobjects[SUBCATCH])
707 errcode = ERR_API_OBJECT_INDEX;
714 *value = Subcatch[index].width * UCF(LENGTH);
break;
716 *value = Subcatch[index].area * UCF(LANDAREA);
break;
718 *value = Subcatch[index].fracImperv;
break;
720 *value = Subcatch[index].slope;
break;
722 *value = Subcatch[index].curbLength * UCF(LENGTH);
break;
723 default: errcode = ERR_API_OUTBOUNDS;
break;
739 if(swmm_IsOpenFlag() == FALSE)
741 errcode = ERR_API_INPUTNOTOPEN;
744 else if(swmm_IsStartedFlag() == TRUE)
746 errcode = ERR_API_SIM_NRUNNING;
749 else if (index < 0 || index >= Nobjects[SUBCATCH])
751 errcode = ERR_API_OBJECT_INDEX;
758 Subcatch[index].width = value / UCF(LENGTH);
break;
760 Subcatch[index].area = value / UCF(LANDAREA);
break;
768 Subcatch[index].slope = value;
break;
770 Subcatch[index].curbLength = value / UCF(LENGTH);
break;
771 default: errcode = ERR_API_OUTBOUNDS;
break;
774 subcatch_validate(index);
793 if(swmm_IsOpenFlag() == FALSE)
795 errcode = ERR_API_INPUTNOTOPEN;
798 else if (index < 0 || index >= Nobjects[SUBCATCH])
800 errcode = ERR_API_OBJECT_INDEX;
804 if (Subcatch[index].outNode == -1 && Subcatch[index].outSubcatch == -1)
809 if (Subcatch[index].outNode >= 0)
811 *out_index = Subcatch[index].outNode;
814 if (Subcatch[index].outSubcatch >= 0)
816 *out_index = Subcatch[index].outSubcatch;
833 if(swmm_IsOpenFlag() == FALSE)
835 errcode = ERR_API_INPUTNOTOPEN;
838 else if(index < 0 || index >= Nobjects[SUBCATCH])
840 errcode = ERR_API_OBJECT_INDEX;
844 *value = lid_getLidUnitCount(index);
864 if(swmm_IsOpenFlag() == FALSE)
866 errcode = ERR_API_INPUTNOTOPEN;
869 else if(index < 0 || index >= Nobjects[SUBCATCH])
871 errcode = ERR_API_OBJECT_INDEX;
875 lidUnit = lid_getLidUnit(index, lidIndex, &errcode);
883 *value = lidUnit->area * SQR(UCF(LENGTH));
886 *value = lidUnit->fullWidth * UCF(LENGTH);
break;
888 *value = lidUnit->botWidth * UCF(LENGTH);
break;
890 *value = lidUnit->initSat * 100;
break;
892 *value = lidUnit->fromImperv * 100;
break;
894 *value = lidUnit->fromPerv * 100;
break;
896 errcode = ERR_API_OUTBOUNDS;
break;
918 if(swmm_IsOpenFlag() == FALSE)
920 errcode = ERR_API_INPUTNOTOPEN;
923 else if(index < 0 || index >= Nobjects[SUBCATCH])
925 errcode = ERR_API_OBJECT_INDEX;
928 else if(swmm_IsStartedFlag() == TRUE)
930 errcode = ERR_API_SIM_NRUNNING;
934 lidUnit = lid_getLidUnit(index, lidIndex, &errcode);
942 lidUnit->area = value / SQR(UCF(LENGTH));
945 lidUnit->fullWidth = value / UCF(LENGTH);
break;
949 lidUnit->initSat = value / 100;
break;
951 lidUnit->fromImperv = value / 100;
break;
953 lidUnit->fromPerv = value / 100;
break;
955 errcode = ERR_API_OUTBOUNDS;
break;
960 if(errcode == ERR_NONE)
962 lid_validateLidGroup(index);
963 lid_updateLidGroup(index);
983 if(swmm_IsOpenFlag() == FALSE)
985 errcode = ERR_API_INPUTNOTOPEN;
988 else if(index < 0 || index >= Nobjects[SUBCATCH])
990 errcode = ERR_API_OBJECT_INDEX;
994 lidUnit = lid_getLidUnit(index, lidIndex, &errcode);
1003 *value = lidUnit->lidIndex;
break;
1005 *value = lidUnit->number;
break;
1007 *value = lidUnit->toPerv;
break;
1009 *value = lidUnit->drainSubcatch;
break;
1011 *value = lidUnit->drainNode;
break;
1013 errcode = ERR_API_OUTBOUNDS;
break;
1035 if(swmm_IsOpenFlag() == FALSE)
1037 errcode = ERR_API_INPUTNOTOPEN;
1040 else if(index < 0 || index >= Nobjects[SUBCATCH])
1042 errcode = ERR_API_OBJECT_INDEX;
1045 else if(swmm_IsStartedFlag() == TRUE)
1047 errcode = ERR_API_SIM_NRUNNING;
1051 lidUnit = lid_getLidUnit(index, lidIndex, &errcode);
1059 lidUnit->lidIndex = value;
break;
1061 lidUnit->number = value;
1064 lidUnit->toPerv = (value > 0.0);
break;
1066 lidUnit->drainSubcatch = value;
1067 lidUnit->drainNode = -1;
1070 lidUnit->drainNode = value;
1071 lidUnit->drainSubcatch = -1;
1074 errcode = ERR_API_OUTBOUNDS;
break;
1079 if(errcode == ERR_NONE)
1081 lid_validateLidGroup(index);
1082 lid_updateLidGroup(index);
1100 if(swmm_IsOpenFlag() == FALSE)
1102 errcode = ERR_API_INPUTNOTOPEN;
1105 else if(lidControlIndex < 0 || lidControlIndex >= Nobjects[LID])
1107 errcode = ERR_API_OBJECT_INDEX;
1111 lidProc = lid_getLidProc(lidControlIndex);
1112 if (lidProc != NULL)
1114 *condition = lidProc->surface.canOverflow;
1134 if(swmm_IsOpenFlag() == FALSE)
1136 errcode = ERR_API_INPUTNOTOPEN;
1139 else if(lidControlIndex < 0 || lidControlIndex >= Nobjects[LID])
1141 errcode = ERR_API_OBJECT_INDEX;
1145 lidProc = lid_getLidProc(lidControlIndex);
1153 *value = lidProc->surface.thickness * UCF(RAINDEPTH);
break;
1155 *value = 1 - lidProc->surface.voidFrac;
break;
1157 *value = lidProc->surface.roughness;
break;
1159 *value = lidProc->surface.surfSlope * 100;
break;
1161 *value = lidProc->surface.sideSlope;
break;
1163 *value = lidProc->surface.alpha;
break;
1165 errcode = ERR_API_OUTBOUNDS;
break;
1172 *value = lidProc->soil.thickness * UCF(RAINDEPTH);
break;
1174 *value = lidProc->soil.porosity;
break;
1176 *value = lidProc->soil.fieldCap;
break;
1178 *value = lidProc->soil.wiltPoint;
break;
1180 *value = lidProc->soil.kSat * UCF(RAINFALL);
break;
1182 *value = lidProc->soil.kSlope;
break;
1184 *value = lidProc->soil.suction * UCF(RAINDEPTH);
break;
1186 errcode = ERR_API_OUTBOUNDS;
break;
1193 *value = lidProc->storage.thickness * UCF(RAINDEPTH);
break;
1195 if (lidProc->storage.voidFrac < 1)
1197 *value = lidProc->storage.voidFrac / (1 - lidProc->storage.voidFrac);
1201 *value = lidProc->storage.voidFrac;
1205 *value = lidProc->storage.kSat * UCF(RAINFALL);
break;
1207 if (lidProc->storage.thickness > 0.0)
1209 *value = lidProc->storage.clogFactor /
1210 (lidProc->storage.thickness *
1211 lidProc->storage.voidFrac);
1215 *value = lidProc->pavement.clogFactor;
1219 errcode = ERR_API_OUTBOUNDS;
break;
1226 *value = lidProc->pavement.thickness * UCF(RAINDEPTH);
break;
1228 if (lidProc->pavement.voidFrac < 1)
1230 *value = lidProc->pavement.voidFrac / (1 - lidProc->pavement.voidFrac);
1234 *value = lidProc->pavement.voidFrac;
1238 *value = lidProc->pavement.impervFrac;
break;
1240 *value = lidProc->pavement.kSat * UCF(RAINFALL);
break;
1242 if (lidProc->pavement.thickness > 0.0)
1244 *value = lidProc->pavement.clogFactor /
1245 (lidProc->pavement.thickness *
1246 lidProc->pavement.voidFrac *
1247 (1 - lidProc->pavement.impervFrac));
1251 *value = lidProc->pavement.clogFactor;
1255 *value = lidProc->pavement.regenDays;
break;
1257 *value = lidProc->pavement.regenDegree;
break;
1259 errcode = ERR_API_OUTBOUNDS;
break;
1266 *value = lidProc->drain.coeff;
break;
1268 *value = lidProc->drain.expon;
break;
1270 *value = lidProc->drain.offset * UCF(RAINDEPTH);
break;
1272 *value = lidProc->drain.delay / 3600;
break;
1274 *value = lidProc->drain.hOpen * UCF(RAINDEPTH);
break;
1276 *value = lidProc->drain.hClose * UCF(RAINDEPTH);
break;
1278 errcode = ERR_API_OUTBOUNDS;
break;
1285 *value = lidProc->drainMat.thickness * UCF(RAINDEPTH);
break;
1287 *value = lidProc->drainMat.voidFrac;
break;
1289 *value = lidProc->drainMat.roughness;
break;
1291 *value = lidProc->drainMat.alpha;
break;
1293 errcode = ERR_API_OUTBOUNDS;
break;
1297 errcode = ERR_API_OUTBOUNDS;
break;
1317 if(swmm_IsOpenFlag() == FALSE)
1319 errcode = ERR_API_INPUTNOTOPEN;
1322 else if(lidControlIndex < 0 || lidControlIndex >= Nobjects[LID])
1324 errcode = ERR_API_OBJECT_INDEX;
1328 lidProc = lid_getLidProc(lidControlIndex);
1336 lidProc->surface.thickness = value / UCF(RAINDEPTH);
break;
1338 lidProc->surface.voidFrac = 1 - value;
break;
1340 lidProc->surface.roughness = value;
break;
1342 lidProc->surface.surfSlope = value / 100;
break;
1344 lidProc->surface.sideSlope = value;
break;
1348 errcode = ERR_API_OUTBOUNDS;
break;
1355 lidProc->soil.thickness = value / UCF(RAINDEPTH);
break;
1357 lidProc->soil.porosity = value;
break;
1359 lidProc->soil.fieldCap = value;
break;
1361 lidProc->soil.wiltPoint = value;
break;
1363 lidProc->soil.kSat = value / UCF(RAINFALL);
break;
1365 lidProc->soil.kSlope = value;
break;
1367 lidProc->soil.suction = value / UCF(RAINDEPTH);
break;
1369 errcode = ERR_API_OUTBOUNDS;
break;
1376 if (lidProc->storage.thickness > 0)
1378 lidProc->storage.clogFactor /= lidProc->storage.thickness;
1379 lidProc->storage.thickness = value / UCF(RAINDEPTH);
1380 lidProc->storage.clogFactor *= lidProc->storage.thickness;
1384 lidProc->storage.thickness = value / UCF(RAINDEPTH);
1388 if (lidProc->storage.voidFrac > 0)
1390 lidProc->storage.clogFactor /= lidProc->storage.voidFrac;
1391 lidProc->storage.voidFrac = value / (value + 1);
1392 lidProc->storage.clogFactor *= lidProc->storage.voidFrac;
1396 lidProc->storage.voidFrac = value / (value + 1);
1401 lidProc->storage.kSat = value / UCF(RAINFALL);
break;
1403 lidProc->storage.clogFactor = value *
1404 lidProc->storage.thickness *
1405 lidProc->storage.voidFrac;
1408 errcode = ERR_API_OUTBOUNDS;
break;
1415 if (lidProc->pavement.thickness > 0)
1417 lidProc->pavement.clogFactor /= lidProc->pavement.thickness;
1418 lidProc->pavement.thickness = value / UCF(RAINDEPTH);
1419 lidProc->pavement.clogFactor *= lidProc->pavement.thickness;
1423 lidProc->pavement.thickness = value / UCF(RAINDEPTH);
1427 if (lidProc->pavement.voidFrac > 0)
1429 lidProc->pavement.clogFactor /= lidProc->pavement.voidFrac;
1430 lidProc->pavement.voidFrac = value / (value + 1);
1431 lidProc->pavement.clogFactor *= lidProc->pavement.voidFrac;
1435 lidProc->pavement.voidFrac = value / (value + 1);
1439 if (lidProc->pavement.impervFrac > 0)
1441 lidProc->pavement.clogFactor /= (1 - lidProc->pavement.impervFrac);
1442 lidProc->pavement.impervFrac = value;
1443 lidProc->pavement.clogFactor *= (1 - lidProc->pavement.impervFrac);
1447 lidProc->pavement.impervFrac = value;
1451 lidProc->pavement.kSat = value / UCF(RAINFALL);
break;
1453 lidProc->pavement.clogFactor = value *
1454 lidProc->pavement.thickness *
1455 lidProc->pavement.voidFrac *
1456 (1.0 - lidProc->pavement.impervFrac);
1459 lidProc->pavement.regenDays = value;
break;
1461 lidProc->pavement.regenDegree = value;
break;
1463 errcode = ERR_API_OUTBOUNDS;
break;
1470 lidProc->drain.coeff = value;
break;
1472 lidProc->drain.expon = value;
break;
1474 lidProc->drain.offset = value / UCF(RAINDEPTH);
break;
1476 lidProc->drain.delay = value * 3600;
break;
1478 lidProc->drain.hOpen = value / UCF(RAINDEPTH);
break;
1480 lidProc->drain.hClose = value / UCF(RAINDEPTH);
break;
1482 errcode = ERR_API_OUTBOUNDS;
break;
1489 lidProc->drainMat.thickness = value / UCF(RAINDEPTH);
break;
1491 lidProc->drainMat.voidFrac = value;
break;
1493 lidProc->drainMat.roughness = value;
break;
1497 errcode = ERR_API_OUTBOUNDS;
break;
1501 errcode = ERR_API_OUTBOUNDS;
break;
1505 if(errcode == ERR_NONE)
1507 lid_validateLidProc(lidControlIndex);
1508 lid_updateAllLidUnit(lidControlIndex);
1528 DateTime currentTime;
1531 if(swmm_IsStartedFlag() == FALSE)
return(ERR_API_SIM_NRUNNING);
1534 currentTime = getDateTime(NewRoutingTime);
1537 datetime_dateToStr(currentTime, theDate);
1538 datetime_timeToStr(currentTime, theTime);
1540 strcpy(_DTimeStr, theDate);
1541 strcat(_DTimeStr,
" ");
1542 strcat(_DTimeStr, theTime);
1544 strcpy(dtimestr, _DTimeStr);
1561 if(swmm_IsOpenFlag() == FALSE)
1563 errcode = ERR_API_INPUTNOTOPEN;
1566 else if (index < 0 || index >= Nobjects[NODE])
1568 errcode = ERR_API_OBJECT_INDEX;
1575 *result = Node[index].inflow * UCF(FLOW);
break;
1577 *result = Node[index].outflow * UCF(FLOW);
break;
1579 *result = Node[index].losses * UCF(FLOW);
break;
1581 *result = Node[index].newVolume * UCF(VOLUME);
break;
1583 *result = Node[index].overflow * UCF(FLOW);
break;
1585 *result = Node[index].newDepth * UCF(LENGTH);
break;
1587 *result = (Node[index].newDepth
1588 + Node[index].invertElev) * UCF(LENGTH);
break;
1590 *result = Node[index].newLatFlow * UCF(FLOW);
break;
1591 default: errcode = ERR_API_OUTBOUNDS;
break;
1609 if(swmm_IsOpenFlag() == FALSE)
1611 errcode = ERR_API_INPUTNOTOPEN;
1614 else if (index < 0 || index >= Nobjects[LINK])
1616 errcode = ERR_API_OBJECT_INDEX;
1623 *result = Link[index].newFlow * UCF(FLOW) ;
break;
1625 *result = Link[index].newDepth * UCF(LENGTH);
break;
1627 *result = Link[index].newVolume * UCF(VOLUME);
break;
1629 *result = Link[index].surfArea1 * UCF(LENGTH) * UCF(LENGTH);
break;
1631 *result = Link[index].surfArea2 * UCF(LENGTH) * UCF(LENGTH);
break;
1633 *result = Link[index].setting;
break;
1635 *result = Link[index].targetSetting;
break;
1637 *result = Link[index].froude;
break;
1638 default: errcode = ERR_API_OUTBOUNDS;
break;
1656 if(swmm_IsOpenFlag() == FALSE)
1658 errcode = ERR_API_INPUTNOTOPEN;
1661 else if (index < 0 || index >= Nobjects[SUBCATCH])
1663 errcode = ERR_API_OBJECT_INDEX;
1670 *result = Subcatch[index].rainfall * UCF(RAINFALL);
break;
1672 *result = Subcatch[index].evapLoss * UCF(EVAPRATE);
break;
1674 *result = Subcatch[index].infilLoss * UCF(RAINFALL);
break;
1676 *result = Subcatch[index].runon * UCF(FLOW);
break;
1678 *result = Subcatch[index].newRunoff * UCF(FLOW);
break;
1680 *result = Subcatch[index].newSnowDepth * UCF(RAINDEPTH);
break;
1681 default: errcode = ERR_API_OUTBOUNDS;
break;
1701 if(swmm_IsOpenFlag() == FALSE)
1703 errcode = ERR_API_INPUTNOTOPEN;
1706 else if (index < 0 || index >= Nobjects[SUBCATCH])
1708 errcode = ERR_API_OBJECT_INDEX;
1712 errcode = ERR_MEMORY;
1721 a = Subcatch[index].area;
1722 for (p = 0; p < Nobjects[POLLUT]; p++)
1724 result[p] = Subcatch[index].surfaceBuildup[p] /
1725 (a * UCF(LANDAREA));
1726 } *PollutArray = result;
1730 for (p = 0; p < Nobjects[POLLUT]; p++)
1732 result[p] = Subcatch[index].concPonded[p] / LperFT3;
1733 } *PollutArray = result;
1735 default: errcode = ERR_API_OUTBOUNDS;
break;
1749 double rainfall = 0;
1750 double snowfall = 0;
1755 if(swmm_IsOpenFlag() == FALSE)
1757 errcode = ERR_API_INPUTNOTOPEN;
1760 else if (index < 0 || index >= Nobjects[GAGE])
1762 errcode = ERR_API_OBJECT_INDEX;
1766 errcode = ERR_MEMORY;
1771 total = gage_getPrecip(index, &rainfall, &snowfall);
1772 temp[0] = total * UCF(RAINFALL);
1773 temp[1] = rainfall * UCF(RAINFALL);
1774 temp[2] = snowfall * UCF(RAINFALL);
1786 int errorcode = stats_getNodeStat(index, nodeStats);
1791 nodeStats->avgDepth *= (UCF(LENGTH) / (double)StepCount);
1793 nodeStats->maxDepth *= UCF(LENGTH);
1795 nodeStats->maxLatFlow *= UCF(FLOW);
1797 nodeStats->maxInflow *= UCF(FLOW);
1799 nodeStats->totLatFlow *= UCF(VOLUME);
1801 nodeStats->timeCourantCritical /= 3600.0;
1803 nodeStats->volFlooded *= UCF(VOLUME);
1805 nodeStats->timeFlooded /= 3600.0;
1807 nodeStats->maxOverflow *= UCF(FLOW);
1809 nodeStats->maxPondedVol *= UCF(VOLUME);
1811 nodeStats->timeSurcharged /= 3600.0;
1824 int errorcode = massbal_getNodeTotalInflow(index, value);
1828 *value *= UCF(VOLUME);
1840 int errorcode = stats_getStorageStat(index, storageStats);
1845 storageStats->
initVol *= UCF(VOLUME);
1847 storageStats->
avgVol *= (UCF(VOLUME) / (double)StepCount);
1849 storageStats->
maxVol *= UCF(VOLUME);
1851 storageStats->
maxFlow *= UCF(FLOW);
1870 int errorcode = stats_getOutfallStat(index, outfallStats);
1884 outfallStats->
maxFlow *= UCF(FLOW);
1886 if (Nobjects[POLLUT] > 0)
1888 for (p = 0; p < Nobjects[POLLUT]; p++)
1889 outfallStats->
totalLoad[p] *= (LperFT3 * Pollut[p].mcf);
1890 if (Pollut[p].units == COUNT)
1918 int errorcode = stats_getLinkStat(index, linkStats);
1923 linkStats->
maxFlow *= UCF(FLOW);
1925 linkStats->
maxVeloc *= UCF(LENGTH);
1927 linkStats->
maxDepth *= UCF(LENGTH);
1956 int errorcode = stats_getPumpStat(index, pumpStats);
1961 pumpStats->
minFlow *= UCF(FLOW);
1972 pumpStats->
maxFlow *= UCF(FLOW);
1974 pumpStats->
volume *= UCF(VOLUME);
1989 TSubcatchStats *tmp = (TSubcatchStats *)calloc(1,
sizeof(TSubcatchStats));
1992 if (swmm_IsOpenFlag() == FALSE)
1994 errorcode = ERR_API_INPUTNOTOPEN;
1998 else if (swmm_IsStartedFlag() == FALSE)
2000 errorcode = ERR_API_SIM_NRUNNING;
2004 else if (index < 0 || index >= Nobjects[SUBCATCH])
2006 errorcode = ERR_API_OBJECT_INDEX;
2011 memcpy(tmp, stats_getSubcatchStat(index),
sizeof(TSubcatchStats));
2014 a = Subcatch[index].area;
2017 (*subcatchStats)->runon *= UCF(VOLUME);
2019 (*subcatchStats)->infil *= UCF(VOLUME);
2021 (*subcatchStats)->runoff *= UCF(VOLUME);
2023 (*subcatchStats)->maxFlow *= UCF(FLOW);
2025 (*subcatchStats)->precip *= (UCF(RAINDEPTH) / a);
2027 (*subcatchStats)->evap *= UCF(VOLUME);
2040 int errorcode = massbal_getRoutingFlowTotal(routingTot);
2045 routingTot->
dwInflow *= UCF(VOLUME);
2047 routingTot->
wwInflow *= UCF(VOLUME);
2049 routingTot->
gwInflow *= UCF(VOLUME);
2051 routingTot->
iiInflow *= UCF(VOLUME);
2053 routingTot->
exInflow *= UCF(VOLUME);
2055 routingTot->
flooding *= UCF(VOLUME);
2057 routingTot->
outflow *= UCF(VOLUME);
2059 routingTot->
evapLoss *= UCF(VOLUME);
2061 routingTot->
seepLoss *= UCF(VOLUME);
2075 int errorcode = massbal_getRunoffTotal(runoffTot);
2079 double TotalArea = massbal_getTotalArea();
2081 runoffTot->
rainfall *= (UCF(RAINDEPTH) / TotalArea);
2083 runoffTot->
evap *= UCF(VOLUME);
2085 runoffTot->
infil *= UCF(VOLUME);
2087 runoffTot->
runoff *= UCF(VOLUME);
2089 runoffTot->
runon *= UCF(VOLUME);
2091 runoffTot->
drains *= UCF(VOLUME);
2093 runoffTot->
snowRemoved *= (UCF(RAINDEPTH) / TotalArea);
2095 runoffTot->
initStorage *= (UCF(RAINDEPTH) / TotalArea);
2097 runoffTot->
finalStorage *= (UCF(RAINDEPTH) / TotalArea);
2122 if (swmm_IsOpenFlag() == FALSE)
2124 errcode = ERR_API_INPUTNOTOPEN;
2127 else if (index < 0 || index >= Nobjects[SUBCATCH])
2129 errcode = ERR_API_OBJECT_INDEX;
2133 lidUnit = lid_getLidUnit(index, lidIndex, &errcode);
2141 *result = lidUnit->oldFluxRates[
SM_SURFACE] * UCF(LENGTH);
break;
2143 *result = lidUnit->oldFluxRates[
SM_SOIL] * UCF(LENGTH);
break;
2145 *result = lidUnit->oldFluxRates[
SM_STORAGE] * UCF(LENGTH);
break;
2147 *result = lidUnit->oldFluxRates[
SM_PAVE] * UCF(LENGTH);
break;
2149 errcode = ERR_API_OUTBOUNDS;
break;
2154 errcode = ERR_API_UNDEFINED_LID;
2172 if (swmm_IsOpenFlag() == FALSE)
2174 errcode = ERR_API_INPUTNOTOPEN;
2177 else if (index < 0 || index >= Nobjects[SUBCATCH])
2179 errcode = ERR_API_OBJECT_INDEX;
2183 lidGroup = lid_getLidGroup(index);
2190 *result = lidGroup->pervArea * SQR(UCF(LENGTH));
break;
2192 *result = lidGroup->flowToPerv * UCF(FLOW);
break;
2194 *result = lidGroup->oldDrainFlow * UCF(FLOW);
break;
2196 *result = lidGroup->newDrainFlow * UCF(FLOW);
break;
2198 errcode = ERR_API_OUTBOUNDS;
break;
2203 errcode = ERR_API_UNDEFINED_LID;
2222 if (swmm_IsOpenFlag() == FALSE)
2224 errcode = ERR_API_INPUTNOTOPEN;
2227 else if (index < 0 || index >= Nobjects[SUBCATCH])
2229 errcode = ERR_API_OBJECT_INDEX;
2233 lidUnit = lid_getLidUnit(index, lidIndex, &errcode);
2241 *result = lidUnit->waterBalance.inflow * UCF(RAINDEPTH);
break;
2243 *result = lidUnit->waterBalance.evap * UCF(RAINDEPTH);
break;
2245 *result = lidUnit->waterBalance.infil * UCF(RAINDEPTH);
break;
2247 *result = lidUnit->waterBalance.surfFlow * UCF(RAINDEPTH);
break;
2249 *result = lidUnit->waterBalance.drainFlow * UCF(RAINDEPTH);
break;
2251 *result = lidUnit->waterBalance.initVol * UCF(RAINDEPTH);
break;
2253 *result = lidUnit->waterBalance.finalVol * UCF(RAINDEPTH);
break;
2255 *result = lidUnit->surfaceDepth * UCF(RAINDEPTH);
break;
2257 *result = lidUnit->paveDepth * UCF(RAINDEPTH);
break;
2259 *result = lidUnit->soilMoisture;
break;
2261 *result = lidUnit->storageDepth * UCF(RAINDEPTH);
break;
2263 *result = lidUnit->dryTime;
break;
2265 *result = lidUnit->oldDrainFlow * UCF(FLOW);
break;
2267 *result = lidUnit->newDrainFlow * UCF(FLOW);
break;
2269 *result = lidUnit->waterRate.evap * UCF(RAINFALL);
break;
2271 *result = lidUnit->waterRate.maxNativeInfil * UCF(RAINFALL);
break;
2273 *result = lidUnit->waterRate.surfaceInflow * UCF(RAINFALL);
break;
2275 *result = lidUnit->waterRate.surfaceInfil * UCF(RAINFALL);
break;
2277 *result = lidUnit->waterRate.surfaceEvap * UCF(RAINFALL);
break;
2279 *result = lidUnit->waterRate.surfaceOutflow * UCF(RAINFALL);
break;
2281 *result = lidUnit->waterRate.paveEvap * UCF(RAINFALL);
break;
2283 *result = lidUnit->waterRate.pavePerc * UCF(RAINFALL);
break;
2285 *result = lidUnit->waterRate.soilEvap * UCF(RAINFALL);
break;
2287 *result = lidUnit->waterRate.soilPerc * UCF(RAINFALL);
break;
2289 *result = lidUnit->waterRate.storageInflow * UCF(RAINFALL);
break;
2291 *result = lidUnit->waterRate.storageExfil * UCF(RAINFALL);
break;
2293 *result = lidUnit->waterRate.storageEvap * UCF(RAINFALL);
break;
2295 *result = lidUnit->waterRate.storageDrain * UCF(RAINFALL);
break;
2297 errcode = ERR_API_OUTBOUNDS;
break;
2302 errcode = ERR_API_UNDEFINED_LID;
2319 DateTime currentTime;
2321 char _rule_[11] =
"ToolkitAPI";
2324 if (swmm_IsOpenFlag() == FALSE)
2326 errcode = ERR_API_INPUTNOTOPEN;
2329 else if (index < 0 || index >= Nobjects[LINK])
2331 errcode = ERR_API_OBJECT_INDEX;
2336 if (setting < 0.0) setting = 0.0;
2337 if (Link[index].type != PUMP && setting > 1.0) setting = 1.0;
2339 Link[index].targetSetting = setting;
2342 link_setSetting(index, 0.0);
2345 if (RptFlags.controls)
2347 currentTime = getDateTime(NewRoutingTime);
2348 report_writeControlAction(currentTime, Link[index].ID, setting, _rule_);
2365 if (swmm_IsOpenFlag() == FALSE)
2367 errcode = ERR_API_INPUTNOTOPEN;
2370 else if (index < 0 || index >= Nobjects[NODE])
2372 errcode = ERR_API_OBJECT_INDEX;
2380 inflow = Node[index].extInflow;
2383 if (inflow->param == -1)
break;
2384 inflow = inflow->next;
2390 int type = FLOW_INFLOW;
2395 double baseline = 0.0;
2398 errcode = inflow_setExtInflow(index, param, type, tSeries,
2399 basePat, cf, baseline, sf);
2404 inflow = Node[index].extInflow;
2410 inflow -> extIfaceInflow = flowrate;
2425 if (swmm_IsOpenFlag() == FALSE)
2427 errcode = ERR_API_INPUTNOTOPEN;
2430 else if ( index < 0 || index >= Nobjects[NODE] )
2432 errcode = ERR_API_OBJECT_INDEX;
2434 else if ( Node[index].type != OUTFALL )
2436 errcode = ERR_API_WRONG_TYPE;
2440 int k = Node[index].subIndex;
2441 if ( Outfall[k].type != STAGED_OUTFALL )
2444 Outfall[k].type = STAGED_OUTFALL;
2446 Outfall[k].outfallStage = stage / UCF(LENGTH);
2460 if(swmm_IsOpenFlag() == FALSE)
2462 errcode = ERR_API_INPUTNOTOPEN;
2465 else if (index < 0 || index >= Nobjects[GAGE])
2467 errcode = ERR_API_OBJECT_INDEX;
2472 if (Gage[index].dataSource != RAIN_API)
2474 Gage[index].dataSource = RAIN_API;
2476 if (Gage[index].isUsed == FALSE)
2478 Gage[index].isUsed = TRUE;
2480 if (Gage[index].coGage != -1)
2482 Gage[index].coGage = -1;
2484 Gage[index].externalRain = total_precip;
2498 return (
double*) malloc((n)*
sizeof(
double));
2507 if (array != NULL) {
int DLLEXPORT swmm_getObjectId(int type, int index, char *id)
Gets Object ID.
Prototypes for SWMM5 functions exported to swmm5.dll.
int DLLEXPORT swmm_getLinkResult(int index, int type, double *result)
Get a result value for specified link.
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,...
int DLLEXPORT swmm_getNodeResult(int index, int type, double *result)
Get a result value for specified node.
int DLLEXPORT swmm_getStorageStats(int index, SM_StorageStats *storageStats)
Get a storage statistics.
int DLLEXPORT swmm_getSubcatchResult(int index, int type, double *result)
Get a result value for specified subcatchment.
int DLLEXPORT swmm_setSimulationDateTime(int timetype, char *dtimestr)
Set simulation datetime information.
int DLLEXPORT swmm_getNodeStats(int index, SM_NodeStats *nodeStats)
Get a node statistics.
int DLLEXPORT swmm_getNodeParam(int index, int Param, double *value)
Get a property value for specified node.
int DLLEXPORT swmm_setNodeParam(int index, int Param, double value)
Set a property value for specified node.
void DLLEXPORT swmm_getAPIError(int errcode, char *s)
Get the text of an error code.
int DLLEXPORT swmm_getPumpStats(int index, SM_PumpStats *pumpStats)
Get pump statistics.
int DLLEXPORT swmm_countObjects(int type, int *count)
Gets Object Count.
System runoff stats structure.
int DLLEXPORT swmm_getSimulationAnalysisSetting(int type, int *value)
Gets Simulation Analysis Setting.
int DLLEXPORT swmm_getSystemRunoffStats(SM_RunoffTotals *runoffTot)
Get system runoff statistics.
int DLLEXPORT swmm_getSubcatchParam(int index, int Param, double *value)
Get a property value for specified subcatchment.
double timeCapacityLimited
int DLLEXPORT swmm_getSimulationParam(int type, double *value)
Gets Simulation Analysis Setting.
int DLLEXPORT swmm_getNodeType(int index, int *Ntype)
Get the type of node with specified index.
int DLLEXPORT swmm_getSubcatchOutConnection(int index, int *type, int *out_index)
Get the Subcatchment connection. Subcatchments can load to a node, another subcatchment,...
int DLLEXPORT swmm_getLinkType(int index, int *Ltype)
Get the type of link with specified index.
int DLLEXPORT swmm_setLinkParam(int index, int Param, double value)
Set a property value for specified link.
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.
int DLLEXPORT swmm_getSimulationDateTime(int timetype, int *year, int *month, int *day, int *hour, int *minute, int *second)
Get the current simulation datetime information.
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...
int DLLEXPORT swmm_setSubcatchParam(int index, int Param, double value)
Set a property value for specified subcatchment.
int DLLEXPORT swmm_getSystemRoutingStats(SM_RoutingTotals *routingTot)
Get system routing statistics.
System Flow Routing Statistics.
int DLLEXPORT swmm_getCurrentDateTimeStr(char *dtimestr)
Get the simulation current datetime as a string.
int DLLEXPORT swmm_getLinkStats(int index, SM_LinkStats *linkStats)
Get link statistics.
int DLLEXPORT swmm_setOutfallStage(int index, double stage)
Set outfall stage.
double timeCourantCritical
void DLLEXPORT swmm_freeOutfallStats(SM_OutfallStats *outfallStats)
Free outfall statistics structure.
int DLLEXPORT swmm_getSimulationUnit(int type, int *value)
Gets Simulation Unit.
int DLLEXPORT swmm_getOutfallStats(int index, SM_OutfallStats *outfallStats)
Get outfall statistics.
int DLLEXPORT swmm_getNodeTotalInflow(int index, double *value)
Get the cumulative inflow for a node.
int DLLEXPORT swmm_getLinkDirection(int index, signed char *value)
Get the link flow direction (see swmm_getLinkType() for notes.
int DLLEXPORT swmm_getLinkParam(int index, int Param, double *value)
Get a property value for specified link.