Eclipse SUMO - Simulation of Urban MObility
|
#include <GUIRunThread.h>
Public Types | |
enum | { ID_THREAD_EVENT } |
FOX declaration. More... | |
Public Member Functions | |
virtual void | begin () |
starts the simulation (execution of one step after another) | |
virtual void | deleteSim () |
deletes the existing simulation | |
void | enableLibsumo () |
enable lib SUMO | |
FXMutex & | getBreakpointLock () |
get breakpoint lock | |
std::vector< SUMOTime > & | getBreakpoints () |
get list of breakpoints | |
GUINet & | getNet () const |
returns the loaded network | |
SUMOTime | getSimBegin () |
get simulation begin time | |
SUMOTime | getSimEndTime () const |
get simulation end time | |
GUIRunThread (FXApp *app, MFXInterThreadEventClient *mw, double &simDelay, MFXSynchQue< GUIEvent * > &eq, FXEX::MFXThreadEvent &ev) | |
constructor | |
virtual bool | init (GUINet *net, SUMOTime start, SUMOTime end) |
initialises the thread with the new simulation | |
bool | networkAvailable () const |
returns the information whether a network has been loaded | |
long | onThreadEvent (FXObject *, FXSelector, void *) |
long | onThreadSignal (FXObject *, FXSelector, void *) |
void | prepareDestruction () |
halts the thread before it shall be deleted | |
void | resume () |
called when the user presses the "resume"-button | |
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) |
virtual bool | simulationIsStartable () const |
check if simulation is startable | |
virtual bool | simulationIsStepable () const |
check if simulation is stepable | |
virtual bool | simulationIsStopable () const |
check if simulation is stopableo | |
void | singleStep () |
called when the user presses the "single step"-button | |
void | stop () |
halts the simulation execution | |
void | tryStep () |
try simulation step | |
virtual | ~GUIRunThread () |
destructor | |
Static Public Member Functions | |
static void | sleep (long ms) |
Protected Member Functions | |
void | makeStep () |
make simulation step | |
void | waitForSnapshots (const SUMOTime snapshotTime) |
wait for snapshots | |
Protected Attributes | |
bool | myAmLibsumo |
whether we are running in libsumo | |
FXApp * | myApp = nullptr |
pointer to APP | |
FXMutex | myBreakpointLock |
Lock for modifying the list of breakpoints. | |
std::vector< SUMOTime > | myBreakpoints |
List of breakpoints. | |
MFXInterThreadEventClient * | myClient = nullptr |
thread client | |
OutputDevice * | myErrorRetriever |
The instances of message retriever encapsulations. | |
MFXSynchQue< GUIEvent * > & | myEventQue |
event queue | |
FXEX::MFXThreadEvent & | myEventThrow |
thrower events | |
bool | myHalting |
information whether the simulation is halting (is not being executed) | |
bool | myHaveSignaledEnd |
whether the simulation already ended | |
long | myLastBreakMillis |
last time the simulation took a microsecond break for the fox event loop to catch up (#9028) | |
long | myLastEndMillis |
end of the last simulation step | |
OutputDevice * | myMessageRetriever |
GUINet * | myNet |
the loaded simulation network | |
bool | myOk |
flag to check if all is ok | |
bool | myQuit |
information whether the thread shall be stopped | |
double & | mySimDelay |
simulation delay | |
SUMOTime | mySimEndTime |
SUMOTime | mySimStartTime |
the times the simulation starts and ends with | |
bool | mySimulationInProgress |
information whether a simulation step is being performed | |
FXMutex | mySimulationLock |
mutex for lock simulation | |
bool | mySingle |
information whether the thread is running in single step mode | |
OutputDevice * | myWarningRetriever |
Private Attributes | |
FXEX::MFXThreadEventHandle | event |
event | |
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 53 of file GUIRunThread.h.
|
inherited |
GUIRunThread::GUIRunThread | ( | FXApp * | app, |
MFXInterThreadEventClient * | mw, | ||
double & | simDelay, | ||
MFXSynchQue< GUIEvent * > & | eq, | ||
FXEX::MFXThreadEvent & | ev | ||
) |
constructor
Definition at line 51 of file GUIRunThread.cpp.
References MsgHandler::MT_ERROR, MsgHandler::MT_MESSAGE, MsgHandler::MT_WARNING, myErrorRetriever, myMessageRetriever, myWarningRetriever, and retrieveMessage().
|
virtual |
destructor
Definition at line 72 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 271 of file GUIRunThread.cpp.
References myOk, mySimStartTime, time2string(), TL, and WRITE_MESSAGEF.
Referenced by GUIApplicationWindow::onCmdStart(), and GUIApplicationWindow::onCmdStep().
|
virtual |
deletes the existing simulation
Definition at line 292 of file GUIRunThread.cpp.
References MsgHandler::cleanupOnEnd(), GUIGlObjectStorage::clear(), MsgHandler::clear(), OutputDevice::closeAll(), MSNet::closeSimulation(), MsgHandler::getErrorInstance(), MsgHandler::getMessageInstance(), MSNet::getStateMessage(), MsgHandler::getWarningInstance(), GUIGlObjectStorage::gIDStorage, myErrorRetriever, myHalting, myMessageRetriever, myNet, mySimEndTime, mySimStartTime, mySimulationInProgress, mySimulationLock, myWarningRetriever, MsgHandler::removeRetriever(), MSNet::simulationState(), and MFXSingleEventThread::sleep().
Referenced by GUIApplicationWindow::closeAllWindows(), run(), and ~GUIRunThread().
|
inline |
|
inline |
get breakpoint lock
Definition at line 124 of file GUIRunThread.h.
References myBreakpointLock.
Referenced by GUIApplicationWindow::handleEvent_SimulationLoaded(), GUIApplicationWindow::onCmdEditBreakpoints(), GUIApplicationWindow::retrieveBreakpoints(), and GUIApplicationWindow::setBreakpoints().
|
inline |
get list of breakpoints
Definition at line 119 of file GUIRunThread.h.
References myBreakpoints.
Referenced by GUIApplicationWindow::handleEvent_SimulationLoaded(), GUIApplicationWindow::onCmdEditBreakpoints(), GUIApplicationWindow::retrieveBreakpoints(), and GUIApplicationWindow::setBreakpoints().
GUINet & GUIRunThread::getNet | ( | ) | const |
returns the loaded network
Definition at line 318 of file GUIRunThread.cpp.
References myNet.
Referenced by GUIApplicationWindow::checkGamingEventsDRT(), GUIApplicationWindow::getCurrentSimTime(), GUIApplicationWindow::handleEvent_SimulationLoaded(), GUIApplicationWindow::handleEvent_SimulationStep(), GUIApplicationWindow::onCmdDemandScale(), GUIApplicationWindow::onCmdOpenShapes(), GUIApplicationWindow::onCmdTimeToggle(), GUIApplicationWindow::openNewView(), and tryStep().
|
inline |
get simulation begin time
Definition at line 109 of file GUIRunThread.h.
References mySimStartTime.
Referenced by GUIApplicationWindow::onCmdEditBreakpoints().
|
inline |
get simulation end time
Definition at line 114 of file GUIRunThread.h.
References mySimEndTime.
Referenced by GUIApplicationWindow::updateTimeLCD().
initialises the thread with the new simulation
Definition at line 85 of file GUIRunThread.cpp.
References MsgHandler::addRetriever(), MsgHandler::getErrorInstance(), MsgHandler::getMessageInstance(), OptionsCont::getOptions(), MsgHandler::getWarningInstance(), MsgHandler::inform(), MSNet::loadRoutes(), myErrorRetriever, myHalting, myHaveSignaledEnd, myMessageRetriever, myNet, myOk, mySimEndTime, mySimStartTime, mySimulationInProgress, mySimulationLock, myWarningRetriever, MSNet::setCurrentTimeStep(), TL, and WRITE_ERROR.
Referenced by GUIApplicationWindow::handleEvent_SimulationLoaded().
|
protected |
make simulation step
Definition at line 187 of file GUIRunThread.cpp.
References MSNet::adaptToState(), DELTA_T, MSNet::getCurrentTimeStep(), MsgHandler::getErrorInstance(), GUINet::guiSimulationStep(), MsgHandler::inform(), myAmLibsumo, myEventQue, myEventThrow, myHalting, myHaveSignaledEnd, myNet, myOk, mySimEndTime, mySimulationInProgress, mySimulationLock, MFXSynchQue< T, Container >::push_back(), FXEX::MFXThreadEvent::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_TOO_MANY_TELEPORTS, MSNet::simulationState(), GUINet::simulationStep(), and WRITE_ERROR.
Referenced by tryStep().
bool GUIRunThread::networkAvailable | ( | ) | const |
returns the information whether a network has been loaded
Definition at line 286 of file GUIRunThread.cpp.
References myNet.
Referenced by GUIApplicationWindow::eventOccurred(), GUIApplicationWindow::onCmdBreakpoint(), GUIApplicationWindow::onCmdBreakpointEarly(), GUIApplicationWindow::onCmdDemandScale(), GUIApplicationWindow::onCmdEditChosen(), GUIApplicationWindow::onCmdStart(), GUIApplicationWindow::onCmdStep(), GUIApplicationWindow::onCmdTimeToggle(), GUIApplicationWindow::onUpdAddView(), GUIApplicationWindow::onUpdNeedsNetwork(), GUIApplicationWindow::onUpdNeedsSumoConfig(), and GUIApplicationWindow::openNewView().
|
inherited |
Definition at line 128 of file MFXSingleEventThread.cpp.
References MFXInterThreadEventClient::eventOccurred(), and MFXSingleEventThread::myClient.
Referenced by FXDEFMAP().
|
inherited |
Definition at line 113 of file MFXSingleEventThread.cpp.
References MFXSingleEventThread::event, PIPE_READ, FXEX::SEL_THREAD, and UNUSED_PARAMETER.
Referenced by FXDEFMAP().
void GUIRunThread::prepareDestruction | ( | ) |
halts the thread before it shall be deleted
Definition at line 324 of file GUIRunThread.cpp.
References myHalting, and myQuit.
Referenced by GUIApplicationWindow::~GUIApplicationWindow().
void GUIRunThread::resume | ( | ) |
called when the user presses the "resume"-button
Definition at line 257 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 331 of file GUIRunThread.cpp.
References myEventQue, myEventThrow, MFXSynchQue< T, Container >::push_back(), and FXEX::MFXThreadEvent::signal().
Referenced by GUIRunThread().
|
virtual |
starts the execution
Reimplemented from MFXSingleEventThread.
Definition at line 126 of file GUIRunThread.cpp.
References deleteSim(), myAmLibsumo, MFXSingleEventThread::myApp, myQuit, and tryStep().
|
inherited |
Definition at line 89 of file MFXSingleEventThread.cpp.
References MFXSingleEventThread::event, PIPE_WRITE, FXEX::SEL_THREAD, and UNUSED_PARAMETER.
|
inherited |
Definition at line 101 of file MFXSingleEventThread.cpp.
References MFXSingleEventThread::event, PIPE_WRITE, and UNUSED_PARAMETER.
|
virtual |
check if simulation is startable
Definition at line 339 of file GUIRunThread.cpp.
References myHalting, and myNet.
Referenced by GUIApplicationWindow::handleEvent_SimulationLoaded(), GUIApplicationWindow::handleEvent_SimulationStep(), and GUIApplicationWindow::onUpdStart().
|
virtual |
check if simulation is stepable
Definition at line 351 of file GUIRunThread.cpp.
References myHalting, and myNet.
Referenced by GUIApplicationWindow::onUpdStep().
|
virtual |
check if simulation is stopableo
Definition at line 345 of file GUIRunThread.cpp.
References myHalting, and myNet.
Referenced by GUIApplicationWindow::onUpdStop().
void GUIRunThread::singleStep | ( | ) |
called when the user presses the "single step"-button
Definition at line 264 of file GUIRunThread.cpp.
References myHalting, and mySingle.
Referenced by GUIApplicationWindow::onCmdStep().
|
staticinherited |
Definition at line 142 of file MFXSingleEventThread.cpp.
Referenced by deleteSim(), GUIApplicationWindow::loadOnStartup(), GUISUMOAbstractView::makeSnapshot(), and tryStep().
void GUIRunThread::stop | ( | ) |
halts the simulation execution
Definition at line 279 of file GUIRunThread.cpp.
References myHalting, and mySingle.
Referenced by GUIApplicationWindow::onCmdStop(), and tryStep().
void GUIRunThread::tryStep | ( | ) |
try simulation step
Definition at line 143 of file GUIRunThread.cpp.
References DELTA_T, SysUtils::getCurrentMillis(), MSNet::getCurrentTimeStep(), getNet(), makeStep(), myBreakpointLock, myBreakpoints, myHalting, myLastBreakMillis, myLastEndMillis, myNet, myOk, mySimDelay, mySingle, GUINet::setIdleDuration(), GUINet::setSimDuration(), MFXSingleEventThread::sleep(), stop(), TS, and waitForSnapshots().
Referenced by run().
|
protected |
wait for snapshots
Definition at line 357 of file GUIRunThread.cpp.
References GUIMainWindow::getInstance(), and GUIMainWindow::getViews().
Referenced by tryStep().
|
privateinherited |
event
Definition at line 72 of file MFXSingleEventThread.h.
Referenced by MFXSingleEventThread::onThreadSignal(), MFXSingleEventThread::signal(), MFXSingleEventThread::signal(), and MFXSingleEventThread::~MFXSingleEventThread().
|
protected |
whether we are running in libsumo
Definition at line 199 of file GUIRunThread.h.
Referenced by enableLibsumo(), makeStep(), and run().
|
protectedinherited |
pointer to APP
Definition at line 65 of file MFXSingleEventThread.h.
Referenced by run(), and MFXSingleEventThread::~MFXSingleEventThread().
|
protected |
Lock for modifying the list of breakpoints.
Definition at line 190 of file GUIRunThread.h.
Referenced by getBreakpointLock(), and tryStep().
|
protected |
List of breakpoints.
Definition at line 187 of file GUIRunThread.h.
Referenced by getBreakpoints(), and tryStep().
|
protectedinherited |
thread client
Definition at line 68 of file MFXSingleEventThread.h.
Referenced by MFXSingleEventThread::onThreadEvent().
|
protected |
The instances of message retriever encapsulations.
Definition at line 172 of file GUIRunThread.h.
Referenced by deleteSim(), GUIRunThread(), init(), and ~GUIRunThread().
|
protected |
event queue
Definition at line 178 of file GUIRunThread.h.
Referenced by makeStep(), and retrieveMessage().
|
protected |
thrower events
Definition at line 181 of file GUIRunThread.h.
Referenced by makeStep(), and retrieveMessage().
|
protected |
information whether the simulation is halting (is not being executed)
Definition at line 151 of file GUIRunThread.h.
Referenced by deleteSim(), init(), makeStep(), prepareDestruction(), resume(), simulationIsStartable(), simulationIsStepable(), simulationIsStopable(), singleStep(), stop(), and tryStep().
|
protected |
whether the simulation already ended
Definition at line 168 of file GUIRunThread.h.
Referenced by init(), and makeStep().
|
protected |
last time the simulation took a microsecond break for the fox event loop to catch up (#9028)
Definition at line 196 of file GUIRunThread.h.
Referenced by tryStep().
|
protected |
end of the last simulation step
Definition at line 193 of file GUIRunThread.h.
Referenced by tryStep().
|
protected |
Definition at line 172 of file GUIRunThread.h.
Referenced by deleteSim(), GUIRunThread(), init(), and ~GUIRunThread().
|
protected |
the loaded simulation network
Definition at line 145 of file GUIRunThread.h.
Referenced by deleteSim(), getNet(), init(), makeStep(), networkAvailable(), simulationIsStartable(), simulationIsStepable(), simulationIsStopable(), tryStep(), and ~GUIRunThread().
|
protected |
flag to check if all is ok
Definition at line 162 of file GUIRunThread.h.
Referenced by begin(), init(), makeStep(), and tryStep().
|
protected |
information whether the thread shall be stopped
Definition at line 155 of file GUIRunThread.h.
Referenced by prepareDestruction(), run(), and ~GUIRunThread().
|
protected |
|
protected |
Definition at line 148 of file GUIRunThread.h.
Referenced by deleteSim(), getSimEndTime(), init(), and makeStep().
|
protected |
the times the simulation starts and ends with
Definition at line 148 of file GUIRunThread.h.
Referenced by begin(), deleteSim(), getSimBegin(), and init().
|
protected |
information whether a simulation step is being performed
Definition at line 159 of file GUIRunThread.h.
Referenced by deleteSim(), init(), makeStep(), and ~GUIRunThread().
|
protected |
mutex for lock simulation
Definition at line 184 of file GUIRunThread.h.
Referenced by deleteSim(), init(), and makeStep().
|
protected |
information whether the thread is running in single step mode
Definition at line 165 of file GUIRunThread.h.
Referenced by resume(), singleStep(), stop(), and tryStep().
|
protected |
Definition at line 172 of file GUIRunThread.h.
Referenced by deleteSim(), GUIRunThread(), init(), and ~GUIRunThread().