SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
SimulationStatusModel Class Reference

Two-level QAbstractItemModel for the Simulation Status dock. More...

#include <simulationstatusmodel.h>

Inheritance diagram for SimulationStatusModel:
Collaboration diagram for SimulationStatusModel:

Public Member Functions

 SimulationStatusModel (QObject *parent=nullptr)
 
int addJob (const QString &instanceName, const QString &inpPath, const QString &engineVersion=QString())
 
int addOrReuseJobForModel (SWMMVisProjectWindow *model, const QString &instanceName, const QString &inpPath, const QString &engineVersion=QString())
 Add or reuse a job row bound to a model instance.
 
int ensureJobForModel (SWMMVisProjectWindow *model, const QString &instanceName, const QString &inpPath, const QString &engineVersion)
 Return the job row bound to (model, engine version), creating an Idle row if none exists yet. Used so an opened model shows its simulation start / end dates before any run.
 
void updateProgress (int jobId, double fraction, const QDateTime &currentSimDate, double runoffErrFrac=0.0, double routingErrFrac=0.0, double avgTimestepSec=0.0, double twoDErrFrac=qQNaN())
 Update progress for a running job.
 
void updateTwoDSolverStats (int jobId, const QString &backend, int momentum, int ltsTiers, qint64 steps, const QVector< qint64 > &tierCells)
 
void setSimulationDates (int jobId, const QDateTime &startSimDate, const QDateTime &endSimDate)
 
void addWarning (int jobId, int code, const QString &message)
 
void finishJob (int jobId, bool success, int errCode, const QString &errMsg, double runoffErrFrac, double routingErrFrac, double twoDErrFrac=qQNaN())
 
const SimulationJobRecordjobRecord (int jobId) const
 
int jobIdForRow (int row) const
 
QList< int > clearJobsForModel (SWMMVisProjectWindow *model)
 Remove every row bound to the given model.
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
 
QModelIndex parent (const QModelIndex &child) const override
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 

Static Public Attributes

static constexpr int ColName = 0
 
static constexpr int ColStatus = 1
 
static constexpr int ColProgress = 2
 
static constexpr int ColStartDate = 3
 
static constexpr int ColCurrentDate = 4
 
static constexpr int ColEndDate = 5
 
static constexpr int ColRunoffErr = 6
 
static constexpr int ColRoutingErr = 7
 
static constexpr int ColTwoDErr = 8
 
static constexpr int ColDuration = 9
 
static constexpr int ColAvgTimestep = 10
 
static constexpr int ColVersion = 11
 
static constexpr int Col2DBackend = 12
 "cpu · LOCAL_INERTIAL", "—" for 1D runs
 
static constexpr int ColLtsTiers = 13
 "4 tiers · t3 84 %"
 
static constexpr int NumColumns = 14
 

Detailed Description

Two-level QAbstractItemModel for the Simulation Status dock.

Level-0 rows: one per simulation job. Level-1 rows: individual warning messages under each job.

Columns (level-0): 0 Name project file name 1 Status Running / Success / Failed / Cancelled 2 Progress "45.2 %" while running 3 Sim Time decimal days (updated each step) 4 Runoff Err % (populated after finish) 5 Routing Err % (populated after finish) 6 2D Err % ("—" when the run has no 2D model) 7 Duration wall-clock seconds once finished 8 Avg Timestep running average engine step size (seconds)

Level-1 columns: Col 0 carries the warning text; others are empty.

Constructor & Destructor Documentation

◆ SimulationStatusModel()

SimulationStatusModel::SimulationStatusModel ( QObject *  parent = nullptr)
explicit

Member Function Documentation

◆ addJob()

int SimulationStatusModel::addJob ( const QString &  instanceName,
const QString &  inpPath,
const QString &  engineVersion = QString() 
)

Add a new job row; returns the job id.

Here is the caller graph for this function:

◆ addOrReuseJobForModel()

int SimulationStatusModel::addOrReuseJobForModel ( SWMMVisProjectWindow model,
const QString &  instanceName,
const QString &  inpPath,
const QString &  engineVersion = QString() 
)

Add or reuse a job row bound to a model instance.

If the model already has a row (was run before), reuse and reset it. Otherwise, create a new row. Returns the job id (reused or new).

Here is the call graph for this function:

◆ addWarning()

void SimulationStatusModel::addWarning ( int  jobId,
int  code,
const QString &  message 
)

Append a warning child under the given job.

◆ clearJobsForModel()

QList< int > SimulationStatusModel::clearJobsForModel ( SWMMVisProjectWindow model)

Remove every row bound to the given model.

Used when the project's output is removed or the project window is closed — the rows describe runs against that model and become meaningless once it goes away. Returns the job IDs that were removed so the caller can drop the matching per-job state it owns (runner handles, running-progress map, etc.).

◆ columnCount()

int SimulationStatusModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
override

◆ data()

QVariant SimulationStatusModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
override

◆ ensureJobForModel()

int SimulationStatusModel::ensureJobForModel ( SWMMVisProjectWindow model,
const QString &  instanceName,
const QString &  inpPath,
const QString &  engineVersion 
)

Return the job row bound to (model, engine version), creating an Idle row if none exists yet. Used so an opened model shows its simulation start / end dates before any run.

Here is the call graph for this function:

◆ finishJob()

void SimulationStatusModel::finishJob ( int  jobId,
bool  success,
int  errCode,
const QString &  errMsg,
double  runoffErrFrac,
double  routingErrFrac,
double  twoDErrFrac = qQNaN() 
)

Mark a job finished.

Parameters
runoffErrFracrunoff continuity error fraction (e.g. 0.001 = 0.1 %)
routingErrFracrouting continuity error fraction
twoDErrFrac2D surface continuity error fraction; NaN = no 2D model

◆ headerData()

QVariant SimulationStatusModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
override

◆ index()

QModelIndex SimulationStatusModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
override

◆ jobIdForRow()

int SimulationStatusModel::jobIdForRow ( int  row) const

Return the job id at the given top-level row, or -1 if out of range.

◆ jobRecord()

const SimulationJobRecord * SimulationStatusModel::jobRecord ( int  jobId) const

Return a copy of the record for the given job id, or nullptr if not found.

◆ parent()

QModelIndex SimulationStatusModel::parent ( const QModelIndex &  child) const
override

◆ rowCount()

int SimulationStatusModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

◆ setSimulationDates()

void SimulationStatusModel::setSimulationDates ( int  jobId,
const QDateTime &  startSimDate,
const QDateTime &  endSimDate 
)

Set the engine-side simulation start / end dates for a job.

◆ updateProgress()

void SimulationStatusModel::updateProgress ( int  jobId,
double  fraction,
const QDateTime &  currentSimDate,
double  runoffErrFrac = 0.0,
double  routingErrFrac = 0.0,
double  avgTimestepSec = 0.0,
double  twoDErrFrac = qQNaN() 
)

Update progress for a running job.

Parameters
runoffErrFracLive continuity error fraction (0.001 = 0.1 %).
routingErrFracDitto for routing.
twoDErrFracDitto for the 2D surface; NaN = no 2D model.

◆ updateTwoDSolverStats()

void SimulationStatusModel::updateTwoDSolverStats ( int  jobId,
const QString &  backend,
int  momentum,
int  ltsTiers,
qint64  steps,
const QVector< qint64 > &  tierCells 
)

2D solver telemetry from SimulationRunner::twoDSolverStats: the backend label, momentum closure (0 LOCAL_INERTIAL, 1 FULL_SWE, 2 DIFFUSIVE_WAVE), configured LTS_TIERS, cumulative marcher substeps and the rebuild-sampled cells per LTS tier. Drives the "2D Solver" and "LTS Tiers" columns.

Member Data Documentation

◆ Col2DBackend

constexpr int SimulationStatusModel::Col2DBackend = 12
staticconstexpr

"cpu · LOCAL_INERTIAL", "—" for 1D runs

◆ ColAvgTimestep

constexpr int SimulationStatusModel::ColAvgTimestep = 10
staticconstexpr

◆ ColCurrentDate

constexpr int SimulationStatusModel::ColCurrentDate = 4
staticconstexpr

◆ ColDuration

constexpr int SimulationStatusModel::ColDuration = 9
staticconstexpr

◆ ColEndDate

constexpr int SimulationStatusModel::ColEndDate = 5
staticconstexpr

◆ ColLtsTiers

constexpr int SimulationStatusModel::ColLtsTiers = 13
staticconstexpr

"4 tiers · t3 84 %"

◆ ColName

constexpr int SimulationStatusModel::ColName = 0
staticconstexpr

◆ ColProgress

constexpr int SimulationStatusModel::ColProgress = 2
staticconstexpr

◆ ColRoutingErr

constexpr int SimulationStatusModel::ColRoutingErr = 7
staticconstexpr

◆ ColRunoffErr

constexpr int SimulationStatusModel::ColRunoffErr = 6
staticconstexpr

◆ ColStartDate

constexpr int SimulationStatusModel::ColStartDate = 3
staticconstexpr

◆ ColStatus

constexpr int SimulationStatusModel::ColStatus = 1
staticconstexpr

◆ ColTwoDErr

constexpr int SimulationStatusModel::ColTwoDErr = 8
staticconstexpr

◆ ColVersion

constexpr int SimulationStatusModel::ColVersion = 11
staticconstexpr

◆ NumColumns

constexpr int SimulationStatusModel::NumColumns = 14
staticconstexpr

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