OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::OutputReader Class Reference

Reads SWMM 5.x binary .out files produced by DefaultOutputPlugin. More...

#include <OutputReader.hpp>

Collaboration diagram for openswmm::OutputReader:

Public Member Functions

 OutputReader ()=default
 
 ~OutputReader ()
 
 OutputReader (const OutputReader &)=delete
 
OutputReaderoperator= (const OutputReader &)=delete
 
bool open (const char *path)
 Open and parse the header/footer of a binary output file.
 
bool openLive (const char *path)
 Open a file that is still being written (no footer yet).
 
int refresh ()
 Re-count periods on a live file.
 
bool is_live () const noexcept
 True while opened via openLive() and the footer has not yet been seen.
 
void close ()
 Close the file and release resources.
 
bool is_open () const noexcept
 Whether the reader has a file open and valid.
 
int version () const noexcept
 
int flow_units () const noexcept
 
int subcatch_count () const noexcept
 
int node_count () const noexcept
 
int link_count () const noexcept
 
int pollut_count () const noexcept
 
int period_count () const noexcept
 
double start_date () const noexcept
 
int report_step () const noexcept
 
int error_code () const noexcept
 
int subcatch_var_count () const noexcept
 
int node_var_count () const noexcept
 
int link_var_count () const noexcept
 
int system_var_count () const noexcept
 
const char * subcatch_id (int index) const
 
const char * node_id (int index) const
 
const char * link_id (int index) const
 
const char * pollut_id (int index) const
 Species (pollutant) ID at a column index, or nullptr.
 
bool get_subcatch_result (int period, int var, float *values) const
 Read one subcatch variable for all subcatchments at a period.
 
bool get_node_result (int period, int var, float *values) const
 Read one node variable for all nodes at a period.
 
bool get_link_result (int period, int var, float *values) const
 Read one link variable for all links at a period.
 
bool get_system_result (int period, int var, float *value) const
 Read one system variable at a period.
 
bool get_subcatch_series (int obj_idx, int var, int start_period, int end_period, float *values) const
 
bool get_node_series (int obj_idx, int var, int start_period, int end_period, float *values) const
 
bool get_link_series (int obj_idx, int var, int start_period, int end_period, float *values) const
 
bool get_system_series (int var, int start_period, int end_period, float *values) const
 
bool get_subcatch_attribute (int obj_idx, int period, float *values, int *count) const
 All variables for one subcatchment at one period.
 
bool get_node_attribute (int obj_idx, int period, float *values, int *count) const
 All variables for one node at one period.
 
bool get_link_attribute (int obj_idx, int period, float *values, int *count) const
 All variables for one link at one period.
 
bool get_period_time (int period, double *time) const
 Get the simulation time for a given period.
 
bool get_node_stat_max_depth (int node_idx, double *value) const
 
bool get_node_stat_max_overflow (int node_idx, double *value) const
 
bool get_node_stat_vol_flooded (int node_idx, double *value) const
 
bool get_node_stat_time_flooded (int node_idx, double *value) const
 

Detailed Description

Reads SWMM 5.x binary .out files produced by DefaultOutputPlugin.

Constructor & Destructor Documentation

◆ OutputReader() [1/2]

openswmm::OutputReader::OutputReader ( )
default
Here is the caller graph for this function:

◆ ~OutputReader()

openswmm::OutputReader::~OutputReader ( )
Here is the call graph for this function:

◆ OutputReader() [2/2]

openswmm::OutputReader::OutputReader ( const OutputReader & )
delete
Here is the call graph for this function:

Member Function Documentation

◆ close()

void openswmm::OutputReader::close ( )

Close the file and release resources.

Here is the caller graph for this function:

◆ error_code()

int openswmm::OutputReader::error_code ( ) const
inlinenoexcept

◆ flow_units()

int openswmm::OutputReader::flow_units ( ) const
inlinenoexcept

◆ get_link_attribute()

bool openswmm::OutputReader::get_link_attribute ( int obj_idx,
int period,
float * values,
int * count ) const

All variables for one link at one period.

◆ get_link_result()

bool openswmm::OutputReader::get_link_result ( int period,
int var,
float * values ) const

Read one link variable for all links at a period.

◆ get_link_series()

bool openswmm::OutputReader::get_link_series ( int obj_idx,
int var,
int start_period,
int end_period,
float * values ) const

◆ get_node_attribute()

bool openswmm::OutputReader::get_node_attribute ( int obj_idx,
int period,
float * values,
int * count ) const

All variables for one node at one period.

◆ get_node_result()

bool openswmm::OutputReader::get_node_result ( int period,
int var,
float * values ) const

Read one node variable for all nodes at a period.

◆ get_node_series()

bool openswmm::OutputReader::get_node_series ( int obj_idx,
int var,
int start_period,
int end_period,
float * values ) const
Here is the caller graph for this function:

◆ get_node_stat_max_depth()

bool openswmm::OutputReader::get_node_stat_max_depth ( int node_idx,
double * value ) const
Here is the call graph for this function:

◆ get_node_stat_max_overflow()

bool openswmm::OutputReader::get_node_stat_max_overflow ( int node_idx,
double * value ) const
Here is the call graph for this function:

◆ get_node_stat_time_flooded()

bool openswmm::OutputReader::get_node_stat_time_flooded ( int node_idx,
double * value ) const
Here is the call graph for this function:

◆ get_node_stat_vol_flooded()

bool openswmm::OutputReader::get_node_stat_vol_flooded ( int node_idx,
double * value ) const
Here is the call graph for this function:

◆ get_period_time()

bool openswmm::OutputReader::get_period_time ( int period,
double * time ) const

Get the simulation time for a given period.

◆ get_subcatch_attribute()

bool openswmm::OutputReader::get_subcatch_attribute ( int obj_idx,
int period,
float * values,
int * count ) const

All variables for one subcatchment at one period.

◆ get_subcatch_result()

bool openswmm::OutputReader::get_subcatch_result ( int period,
int var,
float * values ) const

Read one subcatch variable for all subcatchments at a period.

Parameters
periodZero-based period index.
varVariable index within the subcatch result block.
valuesCaller-allocated array of subcatch_count floats.
Returns
true on success.

◆ get_subcatch_series()

bool openswmm::OutputReader::get_subcatch_series ( int obj_idx,
int var,
int start_period,
int end_period,
float * values ) const

◆ get_system_result()

bool openswmm::OutputReader::get_system_result ( int period,
int var,
float * value ) const

Read one system variable at a period.

◆ get_system_series()

bool openswmm::OutputReader::get_system_series ( int var,
int start_period,
int end_period,
float * values ) const

◆ is_live()

bool openswmm::OutputReader::is_live ( ) const
inlinenoexcept

True while opened via openLive() and the footer has not yet been seen.

◆ is_open()

bool openswmm::OutputReader::is_open ( ) const
inlinenoexcept

Whether the reader has a file open and valid.

Here is the caller graph for this function:

◆ link_count()

int openswmm::OutputReader::link_count ( ) const
inlinenoexcept

◆ link_id()

const char * openswmm::OutputReader::link_id ( int index) const

◆ link_var_count()

int openswmm::OutputReader::link_var_count ( ) const
inlinenoexcept

◆ node_count()

int openswmm::OutputReader::node_count ( ) const
inlinenoexcept

◆ node_id()

const char * openswmm::OutputReader::node_id ( int index) const

◆ node_var_count()

int openswmm::OutputReader::node_var_count ( ) const
inlinenoexcept

◆ open()

bool openswmm::OutputReader::open ( const char * path)

Open and parse the header/footer of a binary output file.

Parameters
pathFile path to the .out file.
Returns
true on success, false on error (bad magic, I/O failure, etc.).
Here is the call graph for this function:

◆ openLive()

bool openswmm::OutputReader::openLive ( const char * path)

Open a file that is still being written (no footer yet).

Every offset the footer would supply is derived by parsing the header forward, and the period count is derived from the file size: floor((size - output_start) / bytes_per_period), so a partially flushed last record is never counted. Call refresh() to pick up periods appended since. Works on any file with a complete header — including one from a run that died before writing its footer. Never writes to the file.

Returns
true on success (possibly with zero periods yet).
Here is the call graph for this function:

◆ operator=()

OutputReader & openswmm::OutputReader::operator= ( const OutputReader & )
delete
Here is the call graph for this function:

◆ period_count()

int openswmm::OutputReader::period_count ( ) const
inlinenoexcept

◆ pollut_count()

int openswmm::OutputReader::pollut_count ( ) const
inlinenoexcept

◆ pollut_id()

const char * openswmm::OutputReader::pollut_id ( int index) const

Species (pollutant) ID at a column index, or nullptr.

The writer has always emitted a fourth ID list after the link IDs — the species names, one per pollutant column — but the reader stopped after three and no public entry point exposed them. Water age reports as a trailing __WATER_AGE__ column whose unit field necessarily reuses a concentration code (the .out unit enum has no HOURS slot), so the NAME is the only way a consumer can tell hours from mg/L. That made this reader a prerequisite for water age being usable at all, not a convenience.

◆ refresh()

int openswmm::OutputReader::refresh ( )

Re-count periods on a live file.

Re-reads the file size and updates period_count(). When the footer has appeared (the run finished) it is adopted — period count and error code become the writer's own — and the reader leaves live mode; subsequent calls are no-ops. On a reader opened with open() this returns period_count() unchanged.

Returns
the current period count, or -1 if no file is open.
Here is the caller graph for this function:

◆ report_step()

int openswmm::OutputReader::report_step ( ) const
inlinenoexcept

◆ start_date()

double openswmm::OutputReader::start_date ( ) const
inlinenoexcept

◆ subcatch_count()

int openswmm::OutputReader::subcatch_count ( ) const
inlinenoexcept

◆ subcatch_id()

const char * openswmm::OutputReader::subcatch_id ( int index) const

◆ subcatch_var_count()

int openswmm::OutputReader::subcatch_var_count ( ) const
inlinenoexcept

◆ system_var_count()

int openswmm::OutputReader::system_var_count ( ) const
inlinenoexcept

◆ version()

int openswmm::OutputReader::version ( ) const
inlinenoexcept

The documentation for this class was generated from the following files: