NeTrainSim 0.1.1 beta
The Open-Source Network Trains Simulator
 
Loading...
Searching...
No Matches
SimulationWorker Class Reference

The SimulationWorker class performs simulation work in a separate thread. More...

#include <simulationworker.h>

Inheritance diagram for SimulationWorker:

Public Slots

void onProgressUpdated (int progressPercentage)
 Slot called when the progress is updated.
 
void onTrainsCoordinatesUpdated (Vector< std::pair< std::string, Vector< std::pair< double, double > > > > trainsStartEndPoints)
 Slot called when the coordinates of trains are updated.
 
void onSimulationFinished (const Vector< std::pair< std::string, std::string > > &summaryData, const string &trajectoryFile)
 Slot called when the simulation is finished.
 
void doWork ()
 Slot called to start the simulation work.
 

Signals

void simulationFinished (const Vector< std::pair< std::string, std::string > > &summaryData, const std::string &trajectoryFile)
 Signal emitted when the simulation is finished.
 
void trainsCoordinatesUpdated (Vector< std::pair< std::string, Vector< std::pair< double, double > > > > trainsStartEndPoints)
 Signal emitted when the coordinates of trains are updated.
 
void simulaionProgressUpdated (int progressPercentage)
 Signal emitted when the simulation progress is updated.
 
void errorOccurred (std::string error)
 Signal emitted when an error occurs during the simulation.
 
void trainSuddenAcceleration (std::string msg)
 
void trainSlowSpeed (std::string msg)
 

Public Member Functions

 SimulationWorker (Vector< std::tuple< int, double, double, std::string, double, double > > nodeRecords, Vector< tuple< int, int, int, double, int, double, double, int, double, bool, string, string, double > > linkRecords, Vector< std::tuple< std::string, Vector< int >, double, double, Vector< std::tuple< int, double, double, int, double, double, double, double, int > >, Vector< std::tuple< int, int, double, double, double, double, double, int > >, bool > > trainRecords, std::string networkName, double endTime, double timeStep, double plotFrequency, std::string exportDir, std::string summaryFilename, bool exportInsta, std::string instaFilename, bool exportAllTrainsSummary)
 Constructs a SimulationWorker object with the specified input data and parameters.
 
 ~SimulationWorker ()
 Destroys the SimulationWorker object.
 

Public Attributes

Simulator * sim
 < Pointer to the Simulator object for performing the simulation.
 
Networknet
 

Detailed Description

The SimulationWorker class performs simulation work in a separate thread.

Constructor & Destructor Documentation

◆ SimulationWorker()

SimulationWorker::SimulationWorker ( Vector< std::tuple< int, double, double, std::string, double, double > >  nodeRecords,
Vector< tuple< int, int, int, double, int, double, double, int, double, bool, string, string, double > >  linkRecords,
Vector< std::tuple< std::string, Vector< int >, double, double, Vector< std::tuple< int, double, double, int, double, double, double, double, int > >, Vector< std::tuple< int, int, double, double, double, double, double, int > >, bool > >  trainRecords,
std::string  networkName,
double  endTime,
double  timeStep,
double  plotFrequency,
std::string  exportDir,
std::string  summaryFilename,
bool  exportInsta,
std::string  instaFilename,
bool  exportAllTrainsSummary 
)

Constructs a SimulationWorker object with the specified input data and parameters.

Parameters
nodeRecordsThe node records for the simulation.
linkRecordsThe link records for the simulation.
trainRecordsThe train records for the simulation.
networkNameThe network name for the simulation.
endTimeThe end time for the simulation.
timeStepThe time step for the simulation.
plotFrequencyThe plot frequency for the simulation.
exportDirThe export directory for the simulation.
summaryFilenameThe summary filename for the simulation.
exportInstaIndicates whether to export instant data in the simulation.
instaFilenameThe instant data filename for the simulation.
exportAllTrainsSummaryIndicates whether to export summary data for all trains in the simulation.

◆ ~SimulationWorker()

SimulationWorker::~SimulationWorker ( )

Destroys the SimulationWorker object.

Member Function Documentation

◆ doWork

void SimulationWorker::doWork ( )
slot

Slot called to start the simulation work.

◆ errorOccurred

void SimulationWorker::errorOccurred ( std::string  error)
signal

Signal emitted when an error occurs during the simulation.

Parameters
errorThe error message.

◆ onProgressUpdated

void SimulationWorker::onProgressUpdated ( int  progressPercentage)
slot

Slot called when the progress is updated.

Parameters
progressPercentageThe progress percentage of the simulation.

◆ onSimulationFinished

void SimulationWorker::onSimulationFinished ( const Vector< std::pair< std::string, std::string > > &  summaryData,
const string &  trajectoryFile 
)
slot

Slot called when the simulation is finished.

Parameters
summaryDataThe summary data of the simulation.
trajectoryFileThe trajectory file path of the simulation.

◆ onTrainsCoordinatesUpdated

void SimulationWorker::onTrainsCoordinatesUpdated ( Vector< std::pair< std::string, Vector< std::pair< double, double > > > >  trainsStartEndPoints)
slot

Slot called when the coordinates of trains are updated.

Parameters
trainsStartEndPointsThe start and end points of trains' coordinates.

◆ simulaionProgressUpdated

void SimulationWorker::simulaionProgressUpdated ( int  progressPercentage)
signal

Signal emitted when the simulation progress is updated.

Parameters
progressPercentageThe progress percentage of the simulation.

◆ simulationFinished

void SimulationWorker::simulationFinished ( const Vector< std::pair< std::string, std::string > > &  summaryData,
const std::string &  trajectoryFile 
)
signal

Signal emitted when the simulation is finished.

Parameters
summaryDataThe summary data of the simulation.
trajectoryFileThe trajectory file path of the simulation.

◆ trainsCoordinatesUpdated

void SimulationWorker::trainsCoordinatesUpdated ( Vector< std::pair< std::string, Vector< std::pair< double, double > > > >  trainsStartEndPoints)
signal

Signal emitted when the coordinates of trains are updated.

Parameters
trainsStartEndPointsThe start and end points of trains' coordinates.

◆ trainSlowSpeed

void SimulationWorker::trainSlowSpeed ( std::string  msg)
signal

◆ trainSuddenAcceleration

void SimulationWorker::trainSuddenAcceleration ( std::string  msg)
signal

Member Data Documentation

◆ net

Network* SimulationWorker::net

◆ sim

Simulator* SimulationWorker::sim

< Pointer to the Simulator object for performing the simulation.

Pointer to the Network object used in the simulation.