Eclipse SUMO - Simulation of Urban MObility
GUIRunThread Class Reference

#include <GUIRunThread.h>

Inheritance diagram for GUIRunThread:
[legend]
Collaboration diagram for GUIRunThread:
[legend]

Public Types

enum  { ID_THREAD_EVENT }
 FOX declaration. More...
 

Public Member Functions

virtual void begin ()
 starts the simulation (execution of one step after another) More...
 
virtual void deleteSim ()
 deletes the existing simulation More...
 
void enableLibsumo ()
 enable lib SUMO More...
 
FXMutex & getBreakpointLock ()
 get breakpoint lock More...
 
std::vector< SUMOTime > & getBreakpoints ()
 get list of breakpoints More...
 
GUINetgetNet () const
 returns the loaded network More...
 
SUMOTime getSimBegin ()
 get simulation begin time More...
 
SUMOTime getSimEndTime () const
 get simulation end time More...
 
 GUIRunThread (FXApp *app, MFXInterThreadEventClient *mw, double &simDelay, MFXSynchQue< GUIEvent * > &eq, FXEX::MFXThreadEvent &ev)
 constructor More...
 
virtual bool init (GUINet *net, SUMOTime start, SUMOTime end)
 initialises the thread with the new simulation More...
 
bool networkAvailable () const
 returns the information whether a network has been loaded More...
 
long onThreadEvent (FXObject *, FXSelector, void *)
 
long onThreadSignal (FXObject *, FXSelector, void *)
 
void prepareDestruction ()
 halts the thread before it shall be deleted More...
 
void resume ()
 called when the user presses the "resume"-button More...
 
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)
 
virtual bool simulationIsStartable () const
 check if simulation is startable More...
 
virtual bool simulationIsStepable () const
 check if simulation is stepable More...
 
virtual bool simulationIsStopable () const
 check if simulation is stopableo More...
 
void singleStep ()
 called when the user presses the "single step"-button More...
 
void stop ()
 halts the simulation execution More...
 
void tryStep ()
 try simulation step More...
 
virtual ~GUIRunThread ()
 destructor More...
 

Static Public Member Functions

static void sleep (long ms)
 

Protected Member Functions

void makeStep ()
 make simulation step More...
 
void waitForSnapshots (const SUMOTime snapshotTime)
 wait for snapshots More...
 

Protected Attributes

bool myAmLibsumo
 whether we are running in libsumo More...
 
FXApp * myApp = nullptr
 pointer to APP More...
 
FXMutex myBreakpointLock
 Lock for modifying the list of breakpoints. More...
 
std::vector< SUMOTimemyBreakpoints
 List of breakpoints. More...
 
MFXInterThreadEventClientmyClient = nullptr
 thread client More...
 
OutputDevicemyErrorRetriever
 The instances of message retriever encapsulations. More...
 
MFXSynchQue< GUIEvent * > & myEventQue
 event queue More...
 
FXEX::MFXThreadEventmyEventThrow
 thrower events More...
 
bool myHalting
 information whether the simulation is halting (is not being executed) More...
 
bool myHaveSignaledEnd
 whether the simulation already ended More...
 
long myLastBreakMillis
 last time the simulation took a microsecond break for the fox event loop to catch up (#9028) More...
 
long myLastEndMillis
 end of the last simulation step More...
 
OutputDevicemyMessageRetriever
 
GUINetmyNet
 the loaded simulation network More...
 
bool myOk
 flag to check if all is ok More...
 
bool myQuit
 information whether the thread shall be stopped More...
 
double & mySimDelay
 simulation delay More...
 
SUMOTime mySimEndTime
 
SUMOTime mySimStartTime
 the times the simulation starts and ends with More...
 
bool mySimulationInProgress
 information whether a simulation step is being performed More...
 
FXMutex mySimulationLock
 mutex for lock simulation More...
 
bool mySingle
 information whether the thread is running in single step mode More...
 
OutputDevicemyWarningRetriever
 

Private Attributes

FXEX::MFXThreadEventHandle event
 event More...
 

Detailed Description

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.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited

FOX declaration.

Enumerator
ID_THREAD_EVENT 

Definition at line 37 of file MFXSingleEventThread.h.

Constructor & Destructor Documentation

◆ GUIRunThread()

GUIRunThread::GUIRunThread ( FXApp *  app,
MFXInterThreadEventClient mw,
double &  simDelay,
MFXSynchQue< GUIEvent * > &  eq,
FXEX::MFXThreadEvent ev 
)

◆ ~GUIRunThread()

GUIRunThread::~GUIRunThread ( )
virtual

Member Function Documentation

◆ begin()

void GUIRunThread::begin ( )
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().

Here is the caller graph for this function:

◆ deleteSim()

◆ enableLibsumo()

void GUIRunThread::enableLibsumo ( )
inline

enable lib SUMO

Definition at line 129 of file GUIRunThread.h.

References myAmLibsumo.

◆ getBreakpointLock()

FXMutex& GUIRunThread::getBreakpointLock ( )
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().

Here is the caller graph for this function:

◆ getBreakpoints()

std::vector<SUMOTime>& GUIRunThread::getBreakpoints ( )
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().

Here is the caller graph for this function:

◆ getNet()

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().

Here is the caller graph for this function:

◆ getSimBegin()

SUMOTime GUIRunThread::getSimBegin ( )
inline

get simulation begin time

Definition at line 109 of file GUIRunThread.h.

References mySimStartTime.

Referenced by GUIApplicationWindow::onCmdEditBreakpoints().

Here is the caller graph for this function:

◆ getSimEndTime()

SUMOTime GUIRunThread::getSimEndTime ( ) const
inline

get simulation end time

Definition at line 114 of file GUIRunThread.h.

References mySimEndTime.

Referenced by GUIApplicationWindow::updateTimeLCD().

Here is the caller graph for this function:

◆ init()

bool GUIRunThread::init ( GUINet net,
SUMOTime  start,
SUMOTime  end 
)
virtual

◆ makeStep()

◆ networkAvailable()

bool GUIRunThread::networkAvailable ( ) const

◆ onThreadEvent()

long MFXSingleEventThread::onThreadEvent ( FXObject *  ,
FXSelector  ,
void *   
)
inherited

Definition at line 128 of file MFXSingleEventThread.cpp.

Referenced by FXDEFMAP().

Here is the caller graph for this function:

◆ onThreadSignal()

long MFXSingleEventThread::onThreadSignal ( FXObject *  ,
FXSelector  ,
void *   
)
inherited

Definition at line 113 of file MFXSingleEventThread.cpp.

References PIPE_READ, FXEX::SEL_THREAD, and UNUSED_PARAMETER.

Referenced by FXDEFMAP().

Here is the caller graph for this function:

◆ prepareDestruction()

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().

Here is the caller graph for this function:

◆ resume()

void GUIRunThread::resume ( )

called when the user presses the "resume"-button

Note
this method resumes the execution after a break

Definition at line 257 of file GUIRunThread.cpp.

References myHalting, and mySingle.

Referenced by GUIApplicationWindow::onCmdStart().

Here is the caller graph for this function:

◆ retrieveMessage()

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().

Here is the caller graph for this function:

◆ run()

FXint GUIRunThread::run ( )
virtual

starts the execution

Reimplemented from MFXSingleEventThread.

Definition at line 126 of file GUIRunThread.cpp.

References deleteSim(), myAmLibsumo, MFXSingleEventThread::myApp, myQuit, and tryStep().

◆ signal() [1/2]

void MFXSingleEventThread::signal ( )
inherited

Definition at line 89 of file MFXSingleEventThread.cpp.

References PIPE_WRITE, FXEX::SEL_THREAD, and UNUSED_PARAMETER.

◆ signal() [2/2]

void MFXSingleEventThread::signal ( FXuint  seltype)
inherited

Definition at line 101 of file MFXSingleEventThread.cpp.

References PIPE_WRITE, and UNUSED_PARAMETER.

◆ simulationIsStartable()

bool GUIRunThread::simulationIsStartable ( ) const
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().

Here is the caller graph for this function:

◆ simulationIsStepable()

bool GUIRunThread::simulationIsStepable ( ) const
virtual

check if simulation is stepable

Definition at line 351 of file GUIRunThread.cpp.

References myHalting, and myNet.

Referenced by GUIApplicationWindow::onUpdStep().

Here is the caller graph for this function:

◆ simulationIsStopable()

bool GUIRunThread::simulationIsStopable ( ) const
virtual

check if simulation is stopableo

Definition at line 345 of file GUIRunThread.cpp.

References myHalting, and myNet.

Referenced by GUIApplicationWindow::onUpdStop().

Here is the caller graph for this function:

◆ singleStep()

void GUIRunThread::singleStep ( )

called when the user presses the "single step"-button

Note
this method allows the thread to perform a single simulation step

Definition at line 264 of file GUIRunThread.cpp.

References myHalting, and mySingle.

Referenced by GUIApplicationWindow::onCmdStep().

Here is the caller graph for this function:

◆ sleep()

void MFXSingleEventThread::sleep ( long  ms)
staticinherited

Definition at line 142 of file MFXSingleEventThread.cpp.

Referenced by deleteSim(), GUIApplicationWindow::loadOnStartup(), GUISUMOAbstractView::makeSnapshot(), and tryStep().

Here is the caller graph for this function:

◆ stop()

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().

Here is the caller graph for this function:

◆ 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().

Here is the caller graph for this function:

◆ waitForSnapshots()

void GUIRunThread::waitForSnapshots ( const SUMOTime  snapshotTime)
protected

wait for snapshots

Definition at line 357 of file GUIRunThread.cpp.

References GUIMainWindow::getInstance(), and GUIMainWindow::getViews().

Referenced by tryStep().

Here is the caller graph for this function:

Field Documentation

◆ event

FXEX::MFXThreadEventHandle MFXSingleEventThread::event
privateinherited

event

Definition at line 72 of file MFXSingleEventThread.h.

◆ myAmLibsumo

bool GUIRunThread::myAmLibsumo
protected

whether we are running in libsumo

Definition at line 199 of file GUIRunThread.h.

Referenced by enableLibsumo(), makeStep(), and run().

◆ myApp

FXApp* MFXSingleEventThread::myApp = nullptr
protectedinherited

pointer to APP

Definition at line 65 of file MFXSingleEventThread.h.

Referenced by run().

◆ myBreakpointLock

FXMutex GUIRunThread::myBreakpointLock
protected

Lock for modifying the list of breakpoints.

Definition at line 190 of file GUIRunThread.h.

Referenced by getBreakpointLock(), and tryStep().

◆ myBreakpoints

std::vector<SUMOTime> GUIRunThread::myBreakpoints
protected

List of breakpoints.

Definition at line 187 of file GUIRunThread.h.

Referenced by getBreakpoints(), and tryStep().

◆ myClient

MFXInterThreadEventClient* MFXSingleEventThread::myClient = nullptr
protectedinherited

thread client

Definition at line 68 of file MFXSingleEventThread.h.

◆ myErrorRetriever

OutputDevice* GUIRunThread::myErrorRetriever
protected

The instances of message retriever encapsulations.

Note
Needed to be deleted from the handler later on

Definition at line 172 of file GUIRunThread.h.

Referenced by deleteSim(), GUIRunThread(), init(), and ~GUIRunThread().

◆ myEventQue

MFXSynchQue<GUIEvent*>& GUIRunThread::myEventQue
protected

event queue

Definition at line 178 of file GUIRunThread.h.

Referenced by makeStep(), and retrieveMessage().

◆ myEventThrow

FXEX::MFXThreadEvent& GUIRunThread::myEventThrow
protected

thrower events

Definition at line 181 of file GUIRunThread.h.

Referenced by makeStep(), and retrieveMessage().

◆ myHalting

bool GUIRunThread::myHalting
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().

◆ myHaveSignaledEnd

bool GUIRunThread::myHaveSignaledEnd
protected

whether the simulation already ended

Definition at line 168 of file GUIRunThread.h.

Referenced by init(), and makeStep().

◆ myLastBreakMillis

long GUIRunThread::myLastBreakMillis
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().

◆ myLastEndMillis

long GUIRunThread::myLastEndMillis
protected

end of the last simulation step

Definition at line 193 of file GUIRunThread.h.

Referenced by tryStep().

◆ myMessageRetriever

OutputDevice * GUIRunThread::myMessageRetriever
protected

Definition at line 172 of file GUIRunThread.h.

Referenced by deleteSim(), GUIRunThread(), init(), and ~GUIRunThread().

◆ myNet

GUINet* GUIRunThread::myNet
protected

◆ myOk

bool GUIRunThread::myOk
protected

flag to check if all is ok

Definition at line 162 of file GUIRunThread.h.

Referenced by begin(), init(), makeStep(), and tryStep().

◆ myQuit

bool GUIRunThread::myQuit
protected

information whether the thread shall be stopped

Note
if not, the thread stays in an endless loop)

Definition at line 155 of file GUIRunThread.h.

Referenced by prepareDestruction(), run(), and ~GUIRunThread().

◆ mySimDelay

double& GUIRunThread::mySimDelay
protected

simulation delay

Definition at line 175 of file GUIRunThread.h.

Referenced by tryStep().

◆ mySimEndTime

SUMOTime GUIRunThread::mySimEndTime
protected

Definition at line 148 of file GUIRunThread.h.

Referenced by deleteSim(), getSimEndTime(), init(), and makeStep().

◆ mySimStartTime

SUMOTime GUIRunThread::mySimStartTime
protected

the times the simulation starts and ends with

Definition at line 148 of file GUIRunThread.h.

Referenced by begin(), deleteSim(), getSimBegin(), and init().

◆ mySimulationInProgress

bool GUIRunThread::mySimulationInProgress
protected

information whether a simulation step is being performed

Note
otherwise the thread may be waiting or the simulation is maybe not performed at all

Definition at line 159 of file GUIRunThread.h.

Referenced by deleteSim(), init(), makeStep(), and ~GUIRunThread().

◆ mySimulationLock

FXMutex GUIRunThread::mySimulationLock
protected

mutex for lock simulation

Definition at line 184 of file GUIRunThread.h.

Referenced by deleteSim(), init(), and makeStep().

◆ mySingle

bool GUIRunThread::mySingle
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().

◆ myWarningRetriever

OutputDevice * GUIRunThread::myWarningRetriever
protected

Definition at line 172 of file GUIRunThread.h.

Referenced by deleteSim(), GUIRunThread(), init(), and ~GUIRunThread().


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