SUMO - Simulation of Urban MObility
|
#include <GUIRunThread.h>
Public Types | |
enum | { ID_THREAD_EVENT } |
Public Member Functions | |
virtual void | begin () |
virtual void | deleteSim () |
GUINet & | getNet () const |
GUIRunThread (FXApp *app, MFXInterThreadEventClient *mw, FXRealSpinDial &simDelay, MFXEventQue &eq, FXEX::FXThreadEvent &ev) | |
constructor | |
virtual void | init (GUINet *net, SUMOTime start, SUMOTime end) |
initialises the thread with the new simulation | |
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. | |
virtual FXint | run () |
starts the execution | |
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 | |
Static Public Member Functions | |
static void | sleep (long ms) |
Protected Member Functions | |
void | makeStep () |
Protected Attributes | |
OutputDevice * | myErrorRetriever |
The instances of message retriever encapsulations Needed to be deleted from the handler later on. | |
MFXEventQue & | myEventQue |
FXEX::FXThreadEvent & | myEventThrow |
bool | myHalting |
information whether the simulation is halting (is not being executed) | |
OutputDevice * | myMessageRetriever |
GUINet * | myNet |
the loaded simulation network | |
bool | myOk |
bool | myQuit |
FXRealSpinDial & | mySimDelay |
SUMOTime | mySimEndTime |
SUMOTime | mySimStartTime |
the times the simulation starts and ends with | |
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.
anonymous enum [inherited] |
Definition at line 31 of file FXSingleEventThread.h.
GUIRunThread::GUIRunThread | ( | FXApp * | app, |
MFXInterThreadEventClient * | mw, | ||
FXRealSpinDial & | simDelay, | ||
MFXEventQue & | eq, | ||
FXEX::FXThreadEvent & | ev | ||
) |
constructor
Definition at line 72 of file GUIRunThread.cpp.
References MsgHandler::MT_ERROR, MsgHandler::MT_MESSAGE, MsgHandler::MT_WARNING, myErrorRetriever, myMessageRetriever, myWarningRetriever, and retrieveMessage().
GUIRunThread::~GUIRunThread | ( | ) | [virtual] |
destructor
Definition at line 84 of file GUIRunThread.cpp.
References deleteSim(), myErrorRetriever, myMessageRetriever, myNet, myQuit, mySimulationInProgress, and myWarningRetriever.
void GUIRunThread::begin | ( | ) | [virtual] |
starts the simulation (execution of one step after another)
Definition at line 243 of file GUIRunThread.cpp.
References myOk, mySimStartTime, time2string(), and WRITE_MESSAGE.
Referenced by GUIApplicationWindow::onCmdStart(), GUIApplicationWindow::onCmdStep(), and run().
void GUIRunThread::deleteSim | ( | ) | [virtual] |
deletes the existing simulation
Definition at line 264 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().
GUINet & GUIRunThread::getNet | ( | ) | const |
returns the loaded network
Definition at line 286 of file GUIRunThread.cpp.
References myNet.
Referenced by GUIApplicationWindow::getCurrentSimTime(), GUIApplicationWindow::handleEvent_SimulationStep(), GUIApplicationWindow::openNewView(), and run().
void GUIRunThread::init | ( | GUINet * | net, |
SUMOTime | start, | ||
SUMOTime | end | ||
) | [virtual] |
initialises the thread with the new simulation
Definition at line 97 of file GUIRunThread.cpp.
References MsgHandler::addRetriever(), MsgHandler::getErrorInstance(), MsgHandler::getMessageInstance(), MsgHandler::getWarningInstance(), myErrorRetriever, myMessageRetriever, myNet, mySimEndTime, mySimStartTime, and myWarningRetriever.
Referenced by GUIApplicationWindow::handleEvent_SimulationLoaded().
void GUIRunThread::makeStep | ( | ) | [protected] |
Definition at line 153 of file GUIRunThread.cpp.
References MFXEventQue::add(), DELTA_T, MSNet::getCurrentTimeStep(), MsgHandler::getErrorInstance(), OptionsCont::getOptions(), MSNet::getStateMessage(), GUINet::guiSimulationStep(), MsgHandler::inform(), MFXMutex::lock(), myEventQue, myEventThrow, myHalting, myNet, myOk, mySimEndTime, mySimulationInProgress, mySimulationLock, mySingle, FXEX::FXThreadEvent::signal(), MSNet::SIMSTATE_CONNECTION_CLOSED, MSNet::SIMSTATE_END_STEP_REACHED, MSNet::SIMSTATE_ERROR_IN_SIM, MSNet::SIMSTATE_NO_FURTHER_VEHICLES, MSNet::SIMSTATE_RUNNING, MSNet::SIMSTATE_TOO_MANY_VEHICLES, MSNet::simulationState(), MSNet::simulationStep(), time2string(), MFXMutex::unlock(), traci::TraCIServer::wasClosed(), WRITE_ERROR, and WRITE_MESSAGE.
Referenced by run().
long FXSingleEventThread::onThreadEvent | ( | FXObject * | , |
FXSelector | , | ||
void * | |||
) | [inherited] |
Definition at line 108 of file FXSingleEventThread.cpp.
long FXSingleEventThread::onThreadSignal | ( | FXObject * | , |
FXSelector | , | ||
void * | |||
) | [inherited] |
Definition at line 94 of file FXSingleEventThread.cpp.
References PIPE_READ.
void GUIRunThread::prepareDestruction | ( | ) |
halts the thread before it shall be deleted
Definition at line 292 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 229 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 299 of file GUIRunThread.cpp.
References MFXEventQue::add(), myEventQue, myEventThrow, and FXEX::FXThreadEvent::signal().
Referenced by GUIRunThread().
FXint GUIRunThread::run | ( | ) | [virtual] |
starts the execution
Reimplemented from FXSingleEventThread.
Definition at line 110 of file GUIRunThread.cpp.
References begin(), deleteSim(), GUIGlobals::gBreakpoints, SysUtils::getCurrentMillis(), MSNet::getCurrentTimeStep(), getNet(), FX::FXRealSpinDial::getValue(), makeStep(), myHalting, myNet, myOk, myQuit, mySimDelay, GUINet::setIdleDuration(), GUINet::setSimDuration(), FXSingleEventThread::sleep(), and stop().
void FXSingleEventThread::signal | ( | ) | [inherited] |
Definition at line 72 of file FXSingleEventThread.cpp.
References PIPE_WRITE.
void FXSingleEventThread::signal | ( | FXuint | seltype | ) | [inherited] |
Definition at line 83 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 258 of file GUIRunThread.cpp.
References myNet.
Referenced by GUIApplicationWindow::eventOccured(), GUIApplicationWindow::onCmdStart(), GUIApplicationWindow::onCmdStep(), GUIApplicationWindow::onUpdAddView(), GUIApplicationWindow::onUpdEditBreakpoints(), GUIApplicationWindow::onUpdEditChosen(), GUIApplicationWindow::onUpdReload(), and GUIApplicationWindow::openNewView().
bool GUIRunThread::simulationIsStartable | ( | ) | const [virtual] |
Definition at line 307 of file GUIRunThread.cpp.
References myHalting, and myNet.
Referenced by GUIApplicationWindow::handleEvent_SimulationLoaded(), and GUIApplicationWindow::onUpdStart().
bool GUIRunThread::simulationIsStepable | ( | ) | const [virtual] |
Definition at line 319 of file GUIRunThread.cpp.
References myHalting, and myNet.
Referenced by GUIApplicationWindow::onUpdStep().
bool GUIRunThread::simulationIsStopable | ( | ) | const [virtual] |
Definition at line 313 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 236 of file GUIRunThread.cpp.
References myHalting, and mySingle.
Referenced by GUIApplicationWindow::onCmdStep().
void FXSingleEventThread::sleep | ( | long | ms | ) | [static, inherited] |
Definition at line 122 of file FXSingleEventThread.cpp.
Referenced by GUISUMOAbstractView::makeSnapshot(), and run().
void GUIRunThread::stop | ( | ) |
halts the simulation execution
Definition at line 251 of file GUIRunThread.cpp.
References myHalting, and mySingle.
Referenced by GUIApplicationWindow::onCmdStop(), and run().
OutputDevice* GUIRunThread::myErrorRetriever [protected] |
The instances of message retriever encapsulations Needed to be deleted from the handler later on.
Definition at line 139 of file GUIRunThread.h.
Referenced by deleteSim(), GUIRunThread(), init(), and ~GUIRunThread().
MFXEventQue& GUIRunThread::myEventQue [protected] |
Definition at line 143 of file GUIRunThread.h.
Referenced by makeStep(), and retrieveMessage().
FXEX::FXThreadEvent& GUIRunThread::myEventThrow [protected] |
Definition at line 145 of file GUIRunThread.h.
Referenced by makeStep(), and retrieveMessage().
bool GUIRunThread::myHalting [protected] |
information whether the simulation is halting (is not being executed)
Definition at line 121 of file GUIRunThread.h.
Referenced by deleteSim(), makeStep(), prepareDestruction(), resume(), run(), simulationIsStartable(), simulationIsStepable(), simulationIsStopable(), singleStep(), and stop().
OutputDevice * GUIRunThread::myMessageRetriever [protected] |
Definition at line 139 of file GUIRunThread.h.
Referenced by deleteSim(), GUIRunThread(), init(), and ~GUIRunThread().
GUINet* GUIRunThread::myNet [protected] |
the loaded simulation network
Definition at line 115 of file GUIRunThread.h.
Referenced by deleteSim(), getNet(), init(), makeStep(), run(), simulationAvailable(), simulationIsStartable(), simulationIsStepable(), simulationIsStopable(), and ~GUIRunThread().
bool GUIRunThread::myOk [protected] |
Definition at line 132 of file GUIRunThread.h.
Referenced by begin(), makeStep(), and run().
bool GUIRunThread::myQuit [protected] |
information whether the thread shall be stopped (if not, the thread stays in an endless loop)
Definition at line 125 of file GUIRunThread.h.
Referenced by prepareDestruction(), run(), and ~GUIRunThread().
FXRealSpinDial& GUIRunThread::mySimDelay [protected] |
Definition at line 141 of file GUIRunThread.h.
Referenced by run().
SUMOTime GUIRunThread::mySimEndTime [protected] |
Definition at line 118 of file GUIRunThread.h.
Referenced by init(), and makeStep().
SUMOTime GUIRunThread::mySimStartTime [protected] |
the times the simulation starts and ends with
Definition at line 118 of file GUIRunThread.h.
Referenced by begin(), deleteSim(), and init().
bool GUIRunThread::mySimulationInProgress [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 130 of file GUIRunThread.h.
Referenced by deleteSim(), makeStep(), and ~GUIRunThread().
MFXMutex GUIRunThread::mySimulationLock [protected] |
Definition at line 147 of file GUIRunThread.h.
Referenced by deleteSim(), and makeStep().
bool GUIRunThread::mySingle [protected] |
information whether the thread is running in single step mode
Definition at line 135 of file GUIRunThread.h.
Referenced by makeStep(), resume(), singleStep(), and stop().
OutputDevice * GUIRunThread::myWarningRetriever [protected] |
Definition at line 139 of file GUIRunThread.h.
Referenced by deleteSim(), GUIRunThread(), init(), and ~GUIRunThread().