![]() |
SUMO - Simulation of Urban MObility
|
#include <GUIRunThread.h>
Public Types | |
enum | { ID_THREAD_EVENT } |
Public Member Functions | |
virtual void | begin () |
virtual void | deleteSim () |
FXMutex & | getBreakpointLock () |
std::vector< SUMOTime > & | getBreakpoints () |
GUINet & | getNet () const |
SUMOTime | getSimEndTime () const |
std::set< SUMOTime > & | getSnapshots () |
FXMutex & | getSnapshotsLock () |
GUIRunThread (FXApp *app, MFXInterThreadEventClient *mw, FXRealSpinDial &simDelay, MFXEventQue< GUIEvent *> &eq, FXEX::FXThreadEvent &ev) | |
constructor More... | |
virtual bool | init (GUINet *net, SUMOTime start, SUMOTime end) |
initialises the thread with the new simulation More... | |
long | onThreadEvent (FXObject *, FXSelector, void *) |
long | onThreadSignal (FXObject *, FXSelector, void *) |
void | prepareDestruction () |
void | resume () |
void | retrieveMessage (const MsgHandler::MsgType type, const std::string &msg) |
Retrieves messages from the loading module. More... | |
virtual FXint | run () |
starts the execution More... | |
void | signal () |
void | signal (FXuint seltype) |
bool | simulationAvailable () const |
virtual bool | simulationIsStartable () const |
virtual bool | simulationIsStepable () const |
virtual bool | simulationIsStopable () const |
void | singleStep () |
void | stop () |
virtual | ~GUIRunThread () |
destructor More... | |
Static Public Member Functions | |
static void | sleep (long ms) |
Protected Member Functions | |
void | makeStep () |
void | waitForSnapshots (SUMOTime snapShotTime) |
Protected Attributes | |
std::set< SUMOTime > | myApplicationSnapshots |
List of snapshot times. More... | |
FXMutex | myApplicationSnapshotsLock |
Lock for modifying the list of snapshot times. More... | |
FXMutex | myBreakpointLock |
Lock for modifying the list of breakpoints. More... | |
std::vector< SUMOTime > | myBreakpoints |
List of breakpoints. More... | |
OutputDevice * | myErrorRetriever |
The instances of message retriever encapsulations Needed to be deleted from the handler later on. More... | |
MFXEventQue< GUIEvent * > & | myEventQue |
FXEX::FXThreadEvent & | myEventThrow |
bool | myHalting |
information whether the simulation is halting (is not being executed) More... | |
bool | myHaveSignaledEnd |
whether the simulation already ended More... | |
OutputDevice * | myMessageRetriever |
GUINet * | myNet |
the loaded simulation network More... | |
bool | myOk |
bool | myQuit |
FXRealSpinDial & | mySimDelay |
SUMOTime | mySimEndTime |
SUMOTime | mySimStartTime |
the times the simulation starts and ends with More... | |
bool | mySimulationInProgress |
MFXMutex | mySimulationLock |
bool | mySingle |
OutputDevice * | myWarningRetriever |
This thread executes the given simulation stepwise to allow parallel visualisation. The avoidance of collisions between the simulation execution and its visualisation is done individually for every lane using mutexes
Definition at line 62 of file GUIRunThread.h.
|
inherited |
Enumerator | |
---|---|
ID_THREAD_EVENT |
Definition at line 52 of file FXSingleEventThread.h.
GUIRunThread::GUIRunThread | ( | FXApp * | app, |
MFXInterThreadEventClient * | mw, | ||
FXRealSpinDial & | simDelay, | ||
MFXEventQue< GUIEvent *> & | eq, | ||
FXEX::FXThreadEvent & | ev | ||
) |
constructor
Definition at line 62 of file GUIRunThread.cpp.
References MsgHandler::MT_ERROR, MsgHandler::MT_MESSAGE, MsgHandler::MT_WARNING, myErrorRetriever, myMessageRetriever, myWarningRetriever, and retrieveMessage().
|
virtual |
destructor
Definition at line 74 of file GUIRunThread.cpp.
References deleteSim(), myErrorRetriever, myMessageRetriever, myNet, myQuit, mySimulationInProgress, and myWarningRetriever.
|
virtual |
starts the simulation (execution of one step after another)
Definition at line 269 of file GUIRunThread.cpp.
References myOk, mySimStartTime, time2string(), and WRITE_MESSAGE.
Referenced by GUIApplicationWindow::onCmdStart(), and GUIApplicationWindow::onCmdStep().
|
virtual |
deletes the existing simulation
Definition at line 290 of file GUIRunThread.cpp.
References MsgHandler::cleanupOnEnd(), GUIGlObjectStorage::clear(), OutputDevice::closeAll(), MSNet::closeSimulation(), MsgHandler::getErrorInstance(), MsgHandler::getMessageInstance(), MsgHandler::getWarningInstance(), GUIGlObjectStorage::gIDStorage, MFXMutex::lock(), myErrorRetriever, myHalting, myMessageRetriever, myNet, mySimStartTime, mySimulationInProgress, mySimulationLock, myWarningRetriever, MsgHandler::removeRetriever(), and MFXMutex::unlock().
Referenced by GUIApplicationWindow::closeAllWindows(), run(), and ~GUIRunThread().
|
inline |
Definition at line 118 of file GUIRunThread.h.
References myBreakpointLock.
Referenced by GUIApplicationWindow::handleEvent_SimulationLoaded(), and GUIApplicationWindow::onCmdEditBreakpoints().
|
inline |
Definition at line 114 of file GUIRunThread.h.
References myBreakpoints.
Referenced by GUIApplicationWindow::handleEvent_SimulationLoaded(), and GUIApplicationWindow::onCmdEditBreakpoints().
GUINet & GUIRunThread::getNet | ( | ) | const |
returns the loaded network
Definition at line 312 of file GUIRunThread.cpp.
References myNet.
Referenced by GUIApplicationWindow::getCurrentSimTime(), GUIApplicationWindow::handleEvent_SimulationStep(), GUIApplicationWindow::onCmdOpenShapes(), GUIApplicationWindow::onCmdTimeToggle(), GUIApplicationWindow::openNewView(), and run().
|
inline |
Definition at line 110 of file GUIRunThread.h.
References mySimEndTime.
Referenced by GUIApplicationWindow::updateTimeLCD().
|
inline |
Definition at line 122 of file GUIRunThread.h.
References myApplicationSnapshots.
Referenced by GUIApplicationWindow::openNewView().
|
inline |
Definition at line 126 of file GUIRunThread.h.
References makeStep(), myApplicationSnapshotsLock, and waitForSnapshots().
Referenced by GUIApplicationWindow::openNewView().
initialises the thread with the new simulation
Definition at line 87 of file GUIRunThread.cpp.
References MsgHandler::addRetriever(), MsgHandler::getErrorInstance(), MsgHandler::getMessageInstance(), OptionsCont::getOptions(), MsgHandler::getWarningInstance(), MsgHandler::inform(), MSNet::loadRoutes(), MFXMutex::lock(), myErrorRetriever, myHalting, myMessageRetriever, myNet, myOk, mySimEndTime, mySimStartTime, mySimulationInProgress, mySimulationLock, myWarningRetriever, MSNet::setCurrentTimeStep(), MFXMutex::unlock(), and WRITE_ERROR.
Referenced by GUIApplicationWindow::handleEvent_SimulationLoaded().
|
protected |
Definition at line 172 of file GUIRunThread.cpp.
References MFXEventQue< T >::add(), DELTA_T, MSNet::getCurrentTimeStep(), MsgHandler::getErrorInstance(), TraCIServer::getInstance(), TraCIServer::getLoadArgs(), MSNet::getStateMessage(), GUINet::guiSimulationStep(), MsgHandler::inform(), MFXMutex::lock(), myEventQue, myEventThrow, myHalting, myHaveSignaledEnd, myNet, myOk, mySimEndTime, mySimulationInProgress, mySimulationLock, mySingle, OptionsIO::setArgs(), FXEX::FXThreadEvent::signal(), MSNet::SIMSTATE_CONNECTION_CLOSED, MSNet::SIMSTATE_END_STEP_REACHED, MSNet::SIMSTATE_ERROR_IN_SIM, MSNet::SIMSTATE_LOADING, MSNet::SIMSTATE_NO_FURTHER_VEHICLES, MSNet::SIMSTATE_RUNNING, MSNet::SIMSTATE_TOO_MANY_TELEPORTS, MSNet::simulationState(), GUINet::simulationStep(), time2string(), MFXMutex::unlock(), TraCIServer::wasClosed(), WRITE_ERROR, and WRITE_MESSAGE.
Referenced by getSnapshotsLock(), and run().
|
inherited |
Definition at line 131 of file FXSingleEventThread.cpp.
|
inherited |
Definition at line 116 of file FXSingleEventThread.cpp.
References PIPE_READ, FXEX::SEL_THREAD, and UNUSED_PARAMETER.
void GUIRunThread::prepareDestruction | ( | ) |
halts the thread before it shall be deleted
Definition at line 318 of file GUIRunThread.cpp.
References myHalting, and myQuit.
Referenced by GUIApplicationWindow::~GUIApplicationWindow().
void GUIRunThread::resume | ( | ) |
called when the user presses the "resume"-button, this method resumes the execution after a break
Definition at line 255 of file GUIRunThread.cpp.
References myHalting, and mySingle.
Referenced by GUIApplicationWindow::onCmdStart().
void GUIRunThread::retrieveMessage | ( | const MsgHandler::MsgType | type, |
const std::string & | msg | ||
) |
Retrieves messages from the loading module.
Definition at line 325 of file GUIRunThread.cpp.
References MFXEventQue< T >::add(), myEventQue, myEventThrow, and FXEX::FXThreadEvent::signal().
Referenced by GUIRunThread().
|
virtual |
starts the execution
Reimplemented from FXSingleEventThread.
Definition at line 126 of file GUIRunThread.cpp.
References deleteSim(), DELTA_T, SysUtils::getCurrentMillis(), MSNet::getCurrentTimeStep(), getNet(), FX::FXRealSpinDial::getValue(), makeStep(), myBreakpointLock, myBreakpoints, myHalting, myNet, myOk, myQuit, mySimDelay, GUINet::setIdleDuration(), GUINet::setSimDuration(), FXSingleEventThread::sleep(), stop(), and waitForSnapshots().
|
inherited |
Definition at line 92 of file FXSingleEventThread.cpp.
References PIPE_WRITE, FXEX::SEL_THREAD, and UNUSED_PARAMETER.
|
inherited |
Definition at line 104 of file FXSingleEventThread.cpp.
References PIPE_WRITE, and UNUSED_PARAMETER.
bool GUIRunThread::simulationAvailable | ( | ) | const |
returns the information whether a simulation has been loaded
Definition at line 284 of file GUIRunThread.cpp.
References myNet.
Referenced by GUIApplicationWindow::eventOccured(), GUIApplicationWindow::onCmdEditChosen(), GUIApplicationWindow::onCmdStart(), GUIApplicationWindow::onCmdStep(), GUIApplicationWindow::onCmdTimeToggle(), GUIApplicationWindow::onUpdAddView(), GUIApplicationWindow::onUpdNeedsSimulation(), and GUIApplicationWindow::openNewView().
|
virtual |
Definition at line 333 of file GUIRunThread.cpp.
References myHalting, and myNet.
Referenced by GUIApplicationWindow::handleEvent_SimulationLoaded(), GUIApplicationWindow::handleEvent_SimulationStep(), and GUIApplicationWindow::onUpdStart().
|
virtual |
Definition at line 345 of file GUIRunThread.cpp.
References myHalting, and myNet.
Referenced by GUIApplicationWindow::onUpdStep().
|
virtual |
Definition at line 339 of file GUIRunThread.cpp.
References myHalting, and myNet.
Referenced by GUIApplicationWindow::onUpdStop().
void GUIRunThread::singleStep | ( | ) |
called when the user presses the "single step"-button, this method allows the thread to perform a single simulation step
Definition at line 262 of file GUIRunThread.cpp.
References myHalting, and mySingle.
Referenced by GUIApplicationWindow::onCmdStep().
|
staticinherited |
Definition at line 145 of file FXSingleEventThread.cpp.
Referenced by GUISUMOAbstractView::makeSnapshot(), FXSingleEventThread::run(), run(), and waitForSnapshots().
void GUIRunThread::stop | ( | ) |
halts the simulation execution
Definition at line 277 of file GUIRunThread.cpp.
References myHalting, and mySingle.
Referenced by GUIApplicationWindow::onCmdStop(), and run().
|
protected |
Definition at line 351 of file GUIRunThread.cpp.
References myApplicationSnapshots, myApplicationSnapshotsLock, myHalting, and FXSingleEventThread::sleep().
Referenced by getSnapshotsLock(), and run().
|
protected |
List of snapshot times.
Definition at line 181 of file GUIRunThread.h.
Referenced by getSnapshots(), and waitForSnapshots().
|
protected |
Lock for modifying the list of snapshot times.
Definition at line 184 of file GUIRunThread.h.
Referenced by getSnapshotsLock(), and waitForSnapshots().
|
protected |
Lock for modifying the list of breakpoints.
Definition at line 178 of file GUIRunThread.h.
Referenced by getBreakpointLock(), and run().
|
protected |
List of breakpoints.
Definition at line 175 of file GUIRunThread.h.
Referenced by getBreakpoints(), and run().
|
protected |
The instances of message retriever encapsulations Needed to be deleted from the handler later on.
Definition at line 164 of file GUIRunThread.h.
Referenced by deleteSim(), GUIRunThread(), init(), and ~GUIRunThread().
|
protected |
Definition at line 168 of file GUIRunThread.h.
Referenced by makeStep(), and retrieveMessage().
|
protected |
Definition at line 170 of file GUIRunThread.h.
Referenced by makeStep(), and retrieveMessage().
|
protected |
information whether the simulation is halting (is not being executed)
Definition at line 143 of file GUIRunThread.h.
Referenced by deleteSim(), init(), makeStep(), prepareDestruction(), resume(), run(), simulationIsStartable(), simulationIsStepable(), simulationIsStopable(), singleStep(), stop(), and waitForSnapshots().
|
protected |
whether the simulation already ended
Definition at line 160 of file GUIRunThread.h.
Referenced by makeStep().
|
protected |
Definition at line 164 of file GUIRunThread.h.
Referenced by deleteSim(), GUIRunThread(), init(), and ~GUIRunThread().
|
protected |
the loaded simulation network
Definition at line 137 of file GUIRunThread.h.
Referenced by deleteSim(), getNet(), init(), makeStep(), run(), simulationAvailable(), simulationIsStartable(), simulationIsStepable(), simulationIsStopable(), and ~GUIRunThread().
|
protected |
Definition at line 154 of file GUIRunThread.h.
Referenced by begin(), init(), makeStep(), and run().
|
protected |
information whether the thread shall be stopped (if not, the thread stays in an endless loop)
Definition at line 147 of file GUIRunThread.h.
Referenced by prepareDestruction(), run(), and ~GUIRunThread().
|
protected |
Definition at line 166 of file GUIRunThread.h.
Referenced by run().
|
protected |
Definition at line 140 of file GUIRunThread.h.
Referenced by getSimEndTime(), init(), and makeStep().
|
protected |
the times the simulation starts and ends with
Definition at line 140 of file GUIRunThread.h.
Referenced by begin(), deleteSim(), and init().
|
protected |
information whether a simulation step is being performed (otherwise the thread may be waiting or the simulation is maybe not performed at all)
Definition at line 152 of file GUIRunThread.h.
Referenced by deleteSim(), init(), makeStep(), and ~GUIRunThread().
|
protected |
Definition at line 172 of file GUIRunThread.h.
Referenced by deleteSim(), init(), and makeStep().
|
protected |
information whether the thread is running in single step mode
Definition at line 157 of file GUIRunThread.h.
Referenced by makeStep(), resume(), singleStep(), and stop().
|
protected |
Definition at line 164 of file GUIRunThread.h.
Referenced by deleteSim(), GUIRunThread(), init(), and ~GUIRunThread().