Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUIRunThread.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
20// The thread that runs the simulation
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#include <string>
26#include <vector>
27#include <set>
28#include <iostream>
34
35
36// ===========================================================================
37// class declarations
38// ===========================================================================
39class GUINet;
40class GUIEvent;
41class OutputDevice;
42
43// ===========================================================================
44// class definition
45// ===========================================================================
54
55public:
58 double& simDelay, MFXSynchQue<GUIEvent*>& eq,
60
62 virtual ~GUIRunThread();
63
65 virtual bool init(GUINet* net, SUMOTime start, SUMOTime end);
66
68 virtual FXint run();
69
72 void resume();
73
76 void singleStep();
77
79 virtual void begin();
80
82 void stop();
83
85 bool networkAvailable() const;
86
88 virtual bool simulationIsStartable() const;
89
91 virtual bool simulationIsStopable() const;
92
94 virtual bool simulationIsStepable() const;
95
97 virtual void deleteSim();
98
100 GUINet& getNet() const;
101
103 void prepareDestruction();
104
106 void retrieveMessage(const MsgHandler::MsgType type, const std::string& msg);
107
110 return mySimStartTime;
111 }
112
115 return mySimEndTime;
116 }
117
119 std::vector<SUMOTime>& getBreakpoints() {
120 return myBreakpoints;
121 }
122
124 FXMutex& getBreakpointLock() {
125 return myBreakpointLock;
126 }
127
130 myAmLibsumo = true;
131 }
132
134 void tryStep();
135
136protected:
138 void makeStep();
139
141 void waitForSnapshots(const SUMOTime snapshotTime);
142
143protected:
146
149
152
155 bool myQuit;
156
160
162 bool myOk;
163
166
169
173
175 double& mySimDelay;
176
179
182
185
187 std::vector<SUMOTime> myBreakpoints;
188
191
194
197
200};
long long int SUMOTime
Definition GUI.h:36
A MSNet extended by some values for usage within the gui.
Definition GUINet.h:82
double & mySimDelay
simulation delay
void singleStep()
called when the user presses the "single step"-button
OutputDevice * myErrorRetriever
The instances of message retriever encapsulations.
GUINet * myNet
the loaded simulation network
SUMOTime mySimEndTime
FXMutex myBreakpointLock
Lock for modifying the list of breakpoints.
GUINet & getNet() const
returns the loaded network
std::vector< SUMOTime > myBreakpoints
List of breakpoints.
virtual FXint run()
starts the execution
virtual void begin()
starts the simulation (execution of one step after another)
SUMOTime getSimBegin()
get simulation begin time
void resume()
called when the user presses the "resume"-button
FXEX::MFXThreadEvent & myEventThrow
thrower events
virtual bool simulationIsStartable() const
check if simulation is startable
bool networkAvailable() const
returns the information whether a network has been loaded
bool myOk
flag to check if all is ok
virtual bool simulationIsStepable() const
check if simulation is stepable
bool mySimulationInProgress
information whether a simulation step is being performed
std::vector< SUMOTime > & getBreakpoints()
get list of breakpoints
virtual bool init(GUINet *net, SUMOTime start, SUMOTime end)
initialises the thread with the new simulation
void makeStep()
make simulation step
FXMutex & getBreakpointLock()
get breakpoint lock
bool myHalting
information whether the simulation is halting (is not being executed)
SUMOTime getSimEndTime() const
get simulation end time
virtual ~GUIRunThread()
destructor
void tryStep()
try simulation step
virtual bool simulationIsStopable() const
check if simulation is stopableo
void enableLibsumo()
enable lib SUMO
OutputDevice * myMessageRetriever
long myLastEndMillis
end of the last simulation step
bool mySingle
information whether the thread is running in single step mode
OutputDevice * myWarningRetriever
virtual void deleteSim()
deletes the existing simulation
void retrieveMessage(const MsgHandler::MsgType type, const std::string &msg)
Retrieves messages from the loading module.
void waitForSnapshots(const SUMOTime snapshotTime)
wait for snapshots
SUMOTime mySimStartTime
the times the simulation starts and ends with
bool myQuit
information whether the thread shall be stopped
void stop()
halts the simulation execution
bool myAmLibsumo
whether we are running in libsumo
void prepareDestruction()
halts the thread before it shall be deleted
long myLastBreakMillis
last time the simulation took a microsecond break for the fox event loop to catch up (#9028)
MFXSynchQue< GUIEvent * > & myEventQue
event queue
FXMutex mySimulationLock
mutex for lock simulation
bool myHaveSignaledEnd
whether the simulation already ended
Static storage of an output device and its base (abstract) implementation.