OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
openswmm_output_impl.cpp File Reference

C FFI wrapper for the OutputReader class. More...

Include dependency graph for openswmm_output_impl.cpp:

Macros

#define CHECK_READER(h)   do { if (!(h)) return -1; } while(0)
 

Functions

SWMM_ENGINE_API SWMM_Output swmm_output_open (const char *path)
 Open a binary output file for reading.
 
SWMM_ENGINE_API void swmm_output_close (SWMM_Output handle)
 Close the output file and free all resources.
 
SWMM_ENGINE_API int swmm_output_get_version (SWMM_Output handle)
 Get the SWMM version stored in the output file.
 
SWMM_ENGINE_API int swmm_output_get_flow_units (SWMM_Output handle)
 Get the flow units code.
 
SWMM_ENGINE_API int swmm_output_get_subcatch_count (SWMM_Output handle)
 Get the number of subcatchments in the output file.
 
SWMM_ENGINE_API int swmm_output_get_node_count (SWMM_Output handle)
 Get the number of nodes in the output file.
 
SWMM_ENGINE_API int swmm_output_get_link_count (SWMM_Output handle)
 Get the number of links in the output file.
 
SWMM_ENGINE_API int swmm_output_get_pollut_count (SWMM_Output handle)
 Get the number of pollutants in the output file.
 
SWMM_ENGINE_API int swmm_output_get_period_count (SWMM_Output handle)
 Get the number of reporting periods (timesteps) in the output file.
 
SWMM_ENGINE_API int swmm_output_get_start_date (SWMM_Output handle, double *start_date)
 Get the simulation start date as a Julian date (double).
 
SWMM_ENGINE_API int swmm_output_get_report_step (SWMM_Output handle)
 Get the report step in seconds.
 
SWMM_ENGINE_API const char * swmm_output_get_subcatch_id (SWMM_Output handle, int index)
 Get the string ID of a subcatchment by index.
 
SWMM_ENGINE_API const char * swmm_output_get_node_id (SWMM_Output handle, int index)
 Get the string ID of a node by index.
 
SWMM_ENGINE_API const char * swmm_output_get_link_id (SWMM_Output handle, int index)
 Get the string ID of a link by index.
 
SWMM_ENGINE_API int swmm_output_get_subcatch_result (SWMM_Output handle, int period, int var, float *values)
 Get one subcatchment variable for all subcatchments at a given period.
 
SWMM_ENGINE_API int swmm_output_get_node_result (SWMM_Output handle, int period, int var, float *values)
 Get one node variable for all nodes at a given period.
 
SWMM_ENGINE_API int swmm_output_get_link_result (SWMM_Output handle, int period, int var, float *values)
 Get one link variable for all links at a given period.
 
SWMM_ENGINE_API int swmm_output_get_system_result (SWMM_Output handle, int period, int var, float *value)
 Get system-wide results at a given period.
 
SWMM_ENGINE_API int swmm_output_get_subcatch_series (SWMM_Output handle, int subcatch_idx, int var, int start_period, int end_period, float *values)
 Get a subcatchment variable time series across a range of periods.
 
SWMM_ENGINE_API int swmm_output_get_node_series (SWMM_Output handle, int node_idx, int var, int start_period, int end_period, float *values)
 Get a node variable time series across a range of periods.
 
SWMM_ENGINE_API int swmm_output_get_link_series (SWMM_Output handle, int link_idx, int var, int start_period, int end_period, float *values)
 Get a link variable time series across a range of periods.
 
SWMM_ENGINE_API int swmm_output_get_system_series (SWMM_Output handle, int var, int start_period, int end_period, float *values)
 Get a system variable time series across a range of periods.
 
SWMM_ENGINE_API int swmm_output_get_subcatch_attribute (SWMM_Output handle, int subcatch_idx, int period, float *values, int *count)
 Get all result variables for a single subcatchment at one period.
 
SWMM_ENGINE_API int swmm_output_get_node_attribute (SWMM_Output handle, int node_idx, int period, float *values, int *count)
 Get all result variables for a single node at one period.
 
SWMM_ENGINE_API int swmm_output_get_link_attribute (SWMM_Output handle, int link_idx, int period, float *values, int *count)
 Get all result variables for a single link at one period.
 
SWMM_ENGINE_API int swmm_output_get_period_time (SWMM_Output handle, int period, double *time)
 Get the simulation time (Julian date) for a given period.
 
SWMM_ENGINE_API int swmm_output_get_error_code (SWMM_Output handle)
 Get the error code stored in the output file footer.
 

Detailed Description

C FFI wrapper for the OutputReader class.

Maps the C API declared in openswmm_output.h to the C++ OutputReader implementation. Each function casts the opaque SWMM_Output handle to an OutputReader pointer.

See also
openswmm_output.h — public C API
OutputReader.hpp — internal C++ reader
Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License\n MIT License

Macro Definition Documentation

◆ CHECK_READER

#define CHECK_READER (   h)    do { if (!(h)) return -1; } while(0)

Function Documentation

◆ swmm_output_close()

SWMM_ENGINE_API void swmm_output_close ( SWMM_Output  handle)

Close the output file and free all resources.

Parameters
handleOutput reader handle (NULL safe).

◆ swmm_output_get_error_code()

SWMM_ENGINE_API int swmm_output_get_error_code ( SWMM_Output  handle)

Get the error code stored in the output file footer.

Parameters
handleOutput reader handle.
Returns
Error code from the simulation (0 = success), or -1 on reader error.
Here is the call graph for this function:

◆ swmm_output_get_flow_units()

SWMM_ENGINE_API int swmm_output_get_flow_units ( SWMM_Output  handle)

Get the flow units code.

Parameters
handleOutput reader handle.
Returns
Flow units code (0=CFS, 1=GPM, 2=MGD, 3=CMS, 4=LPS, 5=MLD), or -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_link_attribute()

SWMM_ENGINE_API int swmm_output_get_link_attribute ( SWMM_Output  handle,
int  link_idx,
int  period,
float *  values,
int *  count 
)

Get all result variables for a single link at one period.

Parameters
handleOutput reader handle.
link_idxZero-based link index.
periodZero-based period index.
valuesCaller-allocated array of n_link_vars floats.
countPointer to receive the number of variables written.
Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_link_count()

SWMM_ENGINE_API int swmm_output_get_link_count ( SWMM_Output  handle)

Get the number of links in the output file.

Parameters
handleOutput reader handle.
Returns
Link count, or -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_link_id()

SWMM_ENGINE_API const char * swmm_output_get_link_id ( SWMM_Output  handle,
int  index 
)

Get the string ID of a link by index.

Parameters
handleOutput reader handle.
indexZero-based link index.
Returns
Null-terminated string owned by the reader, or NULL on error.
Here is the call graph for this function:

◆ swmm_output_get_link_result()

SWMM_ENGINE_API int swmm_output_get_link_result ( SWMM_Output  handle,
int  period,
int  var,
float *  values 
)

Get one link variable for all links at a given period.

Parameters
handleOutput reader handle.
periodZero-based period index.
varLink variable (see SWMM_OutLinkVar).
valuesCaller-allocated array of at least link_count floats.
Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_link_series()

SWMM_ENGINE_API int swmm_output_get_link_series ( SWMM_Output  handle,
int  link_idx,
int  var,
int  start_period,
int  end_period,
float *  values 
)

Get a link variable time series across a range of periods.

Parameters
handleOutput reader handle.
link_idxZero-based link index.
varLink variable.
start_periodFirst period (inclusive, zero-based).
end_periodLast period (inclusive, zero-based).
valuesCaller-allocated array of (end_period - start_period + 1) floats.
Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_node_attribute()

SWMM_ENGINE_API int swmm_output_get_node_attribute ( SWMM_Output  handle,
int  node_idx,
int  period,
float *  values,
int *  count 
)

Get all result variables for a single node at one period.

Parameters
handleOutput reader handle.
node_idxZero-based node index.
periodZero-based period index.
valuesCaller-allocated array of n_node_vars floats.
countPointer to receive the number of variables written.
Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_node_count()

SWMM_ENGINE_API int swmm_output_get_node_count ( SWMM_Output  handle)

Get the number of nodes in the output file.

Parameters
handleOutput reader handle.
Returns
Node count, or -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_node_id()

SWMM_ENGINE_API const char * swmm_output_get_node_id ( SWMM_Output  handle,
int  index 
)

Get the string ID of a node by index.

Parameters
handleOutput reader handle.
indexZero-based node index.
Returns
Null-terminated string owned by the reader, or NULL on error.
Here is the call graph for this function:

◆ swmm_output_get_node_result()

SWMM_ENGINE_API int swmm_output_get_node_result ( SWMM_Output  handle,
int  period,
int  var,
float *  values 
)

Get one node variable for all nodes at a given period.

Parameters
handleOutput reader handle.
periodZero-based period index.
varNode variable (see SWMM_OutNodeVar).
valuesCaller-allocated array of at least node_count floats.
Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_node_series()

SWMM_ENGINE_API int swmm_output_get_node_series ( SWMM_Output  handle,
int  node_idx,
int  var,
int  start_period,
int  end_period,
float *  values 
)

Get a node variable time series across a range of periods.

Parameters
handleOutput reader handle.
node_idxZero-based node index.
varNode variable.
start_periodFirst period (inclusive, zero-based).
end_periodLast period (inclusive, zero-based).
valuesCaller-allocated array of (end_period - start_period + 1) floats.
Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_period_count()

SWMM_ENGINE_API int swmm_output_get_period_count ( SWMM_Output  handle)

Get the number of reporting periods (timesteps) in the output file.

Parameters
handleOutput reader handle.
Returns
Period count, or -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_period_time()

SWMM_ENGINE_API int swmm_output_get_period_time ( SWMM_Output  handle,
int  period,
double *  time 
)

Get the simulation time (Julian date) for a given period.

Parameters
handleOutput reader handle.
periodZero-based period index.
timePointer to receive the simulation time as a double (Julian date).
Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_pollut_count()

SWMM_ENGINE_API int swmm_output_get_pollut_count ( SWMM_Output  handle)

Get the number of pollutants in the output file.

Parameters
handleOutput reader handle.
Returns
Pollutant count, or -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_report_step()

SWMM_ENGINE_API int swmm_output_get_report_step ( SWMM_Output  handle)

Get the report step in seconds.

Parameters
handleOutput reader handle.
Returns
Report step (seconds), or -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_start_date()

SWMM_ENGINE_API int swmm_output_get_start_date ( SWMM_Output  handle,
double *  start_date 
)

Get the simulation start date as a Julian date (double).

Parameters
handleOutput reader handle.
start_datePointer to receive the start date value.
Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_subcatch_attribute()

SWMM_ENGINE_API int swmm_output_get_subcatch_attribute ( SWMM_Output  handle,
int  subcatch_idx,
int  period,
float *  values,
int *  count 
)

Get all result variables for a single subcatchment at one period.

Parameters
handleOutput reader handle.
subcatch_idxZero-based subcatchment index.
periodZero-based period index.
valuesCaller-allocated array of n_subcatch_vars floats.
countPointer to receive the number of variables written.
Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_subcatch_count()

SWMM_ENGINE_API int swmm_output_get_subcatch_count ( SWMM_Output  handle)

Get the number of subcatchments in the output file.

Parameters
handleOutput reader handle.
Returns
Subcatchment count, or -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_subcatch_id()

SWMM_ENGINE_API const char * swmm_output_get_subcatch_id ( SWMM_Output  handle,
int  index 
)

Get the string ID of a subcatchment by index.

Parameters
handleOutput reader handle.
indexZero-based subcatchment index.
Returns
Null-terminated string owned by the reader, or NULL on error.
Here is the call graph for this function:

◆ swmm_output_get_subcatch_result()

SWMM_ENGINE_API int swmm_output_get_subcatch_result ( SWMM_Output  handle,
int  period,
int  var,
float *  values 
)

Get one subcatchment variable for all subcatchments at a given period.

Parameters
handleOutput reader handle.
periodZero-based period index.
varSubcatchment variable (see SWMM_OutSubcatchVar).
valuesCaller-allocated array of at least subcatch_count floats.
Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_subcatch_series()

SWMM_ENGINE_API int swmm_output_get_subcatch_series ( SWMM_Output  handle,
int  subcatch_idx,
int  var,
int  start_period,
int  end_period,
float *  values 
)

Get a subcatchment variable time series across a range of periods.

Parameters
handleOutput reader handle.
subcatch_idxZero-based subcatchment index.
varSubcatchment variable.
start_periodFirst period (inclusive, zero-based).
end_periodLast period (inclusive, zero-based).
valuesCaller-allocated array of (end_period - start_period + 1) floats.
Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_system_result()

SWMM_ENGINE_API int swmm_output_get_system_result ( SWMM_Output  handle,
int  period,
int  var,
float *  value 
)

Get system-wide results at a given period.

Parameters
handleOutput reader handle.
periodZero-based period index.
varSystem variable (see SWMM_OutSystemVar).
valuePointer to receive the single float value.
Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_system_series()

SWMM_ENGINE_API int swmm_output_get_system_series ( SWMM_Output  handle,
int  var,
int  start_period,
int  end_period,
float *  values 
)

Get a system variable time series across a range of periods.

Parameters
handleOutput reader handle.
varSystem variable.
start_periodFirst period (inclusive, zero-based).
end_periodLast period (inclusive, zero-based).
valuesCaller-allocated array of (end_period - start_period + 1) floats.
Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ swmm_output_get_version()

SWMM_ENGINE_API int swmm_output_get_version ( SWMM_Output  handle)

Get the SWMM version stored in the output file.

Parameters
handleOutput reader handle.
Returns
Version number (e.g. 52001), or -1 on error.
Here is the call graph for this function:

◆ swmm_output_open()

SWMM_ENGINE_API SWMM_Output swmm_output_open ( const char *  path)

Open a binary output file for reading.

Parameters
pathPath to a .out file produced by DefaultOutputPlugin.
Returns
Opaque handle, or NULL on failure (invalid file, I/O error).