Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get/Set Storage Nodes Parameters #192

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
92 changes: 92 additions & 0 deletions src/toolkitAPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,98 @@ int DLLEXPORT swmm_setNodeParam(int index, int Param, double value)
return(0);
}

// Get Storage
int DLLEXPORT swmm_getStorageParam(int index, int Param, double value)
//
// Input: index = Index of desired ID
// param = Parameter desired (Perhaps define enum )
// value = value to be input
// Return: API Error
// Purpose: Sets Storage Parameter
//
{
int errcode = 0;
*value = 0;
// Check if Open
if(swmm_IsOpenFlag() == FALSE)
{
errcode = ERR_API_INPUTNOTOPEN;
}
// Check if object index is within bounds
else if (index < 0 || index >= Nobjects[Node])
{
errcode = ERR_API_OBJECT_INDEX;
}
else
{
switch(Param)
{
// FUNCTIONAL COEFF
case 0: *value = Storage[index].aCoeff * UCF(LENGTH) * UCF(LENGTH); break;
// FUNCTIONAL EXPON
case 1: *value = Storage[index].aExpon * UCF(LENGTH) * UCF(LENGTH); break;
// FUNCTIONAL CONST
case 2: *value = Storage[index].aConst * UCF(LENGTH) * UCF(LENGTH); break
// STORAGE EXFIL
case 3: *value = Storage[index].exfil * UCF(RATE); break;
// STORAGE EVAP
case 4: *value = Storage[index].fEvap * UCF(RATE); break;
// Type not available
default: errcode = ERR_API_OUTBOUNDS; break;
}
//re-validate storage
storage_validate(index); // incorprate callback here
}
return(0);
}

// Set Storage Parameters

int DLLEXPORT swmm_setStorageParam(int index, int Param, double value)
//
// Input: index = Index of desired ID
// param = Parameter desired (Perhaps define enum )
// value = value to be input
// Return: API Error
// Purpose: Sets Storage Parameter
//
{
int errcode = 0;
*value = 0;
// Check if Open
if(swmm_IsOpenFlag() == FALSE)
{
errcode = ERR_API_INPUTNOTOPEN;
}
// Check if object index is within bounds
else if (index < 0 || index >= Nobjects[Node])
{
errcode = ERR_API_OBJECT_INDEX;
}
else
{
switch(Param)
{
// FUNCTIONAL COEFF
case 0: Storage[index].aCoeff = value / ( UCF(LENGTH) * UCF(LENGTH) ); break;
// FUNCTIONAL EXPON
case 1: Storage[index].aExpon = value / ( UCF(LENGTH) * UCF(LENGTH) ); break;
// FUNCTIONAL CONST
case 2: Storage[index].aConst = value / ( UCF(LENGTH) * UCF(LENGTH) ); break;
// STORAGE EXFIL
case 3: Storage[index].exfil = value / UCF(RATE); break;
// STORAGE EVAP
case 4: Storage[index].fEvap = value / UCF(RATE); break;
// Type not available
default: errcode = ERR_API_OUTBOUNDS; break;
}
//re-validate storage
storage_validate(index); // incorprate callback here
}
return(0);
}


int DLLEXPORT swmm_getLinkParam(int index, int Param, double *value)
//
// Input: index = Index of desired ID
Expand Down