Eclipse SUMO - Simulation of Urban MObility
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-2023 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// ===========================================================================
45// class definition
46// ===========================================================================
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 simulationAvailable() const;
86
87 virtual bool simulationIsStartable() const;
88 virtual bool simulationIsStopable() const;
89 virtual bool simulationIsStepable() const;
90
92 virtual void deleteSim();
93
95 GUINet& getNet() const;
96
98 void prepareDestruction();
99
101 void retrieveMessage(const MsgHandler::MsgType type, const std::string& msg);
102
104 return mySimEndTime;
105 }
106
107 std::vector<SUMOTime>& getBreakpoints() {
108 return myBreakpoints;
109 }
110
111 FXMutex& getBreakpointLock() {
112 return myBreakpointLock;
113 }
114
116 return mySimStartTime;
117 }
118
120 myAmLibsumo = true;
121 }
122
123 void tryStep();
124
125protected:
126 void makeStep();
127
128 void waitForSnapshots(const SUMOTime snapshotTime);
129
130protected:
133
136
139
142 bool myQuit;
143
148
149 bool myOk;
150
153
156
160
161 double& mySimDelay;
162
164
166
168
170 std::vector<SUMOTime> myBreakpoints;
171
174
177
180
183
184};
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
Definition: GUIRunThread.h:161
OutputDevice * myErrorRetriever
The instances of message retriever encapsulations Needed to be deleted from the handler later on.
Definition: GUIRunThread.h:159
GUINet * myNet
the loaded simulation network
Definition: GUIRunThread.h:132
SUMOTime mySimEndTime
Definition: GUIRunThread.h:135
FXMutex myBreakpointLock
Lock for modifying the list of breakpoints.
Definition: GUIRunThread.h:173
GUINet & getNet() const
std::vector< SUMOTime > myBreakpoints
List of breakpoints.
Definition: GUIRunThread.h:170
virtual FXint run()
starts the execution
virtual void begin()
FXEX::MFXThreadEvent & myEventThrow
Definition: GUIRunThread.h:165
virtual bool simulationIsStartable() const
virtual bool simulationIsStepable() const
bool mySimulationInProgress
Definition: GUIRunThread.h:147
std::vector< SUMOTime > & getBreakpoints()
Definition: GUIRunThread.h:107
virtual bool init(GUINet *net, SUMOTime start, SUMOTime end)
initialises the thread with the new simulation
FXMutex & getBreakpointLock()
Definition: GUIRunThread.h:111
bool myHalting
information whether the simulation is halting (is not being executed)
Definition: GUIRunThread.h:138
SUMOTime getSimEndTime() const
Definition: GUIRunThread.h:103
virtual ~GUIRunThread()
destructor
virtual bool simulationIsStopable() const
void enableLibsumo()
Definition: GUIRunThread.h:119
OutputDevice * myMessageRetriever
Definition: GUIRunThread.h:159
long myLastEndMillis
end of the last simulation step
Definition: GUIRunThread.h:176
OutputDevice * myWarningRetriever
Definition: GUIRunThread.h:159
bool simulationAvailable() const
virtual void deleteSim()
void retrieveMessage(const MsgHandler::MsgType type, const std::string &msg)
Retrieves messages from the loading module.
void waitForSnapshots(const SUMOTime snapshotTime)
SUMOTime mySimStartTime
the times the simulation starts and ends with
Definition: GUIRunThread.h:135
bool myAmLibsumo
whether we are running in libsumo
Definition: GUIRunThread.h:182
void prepareDestruction()
long myLastBreakMillis
last time the simulation took a microsecond break for the fox event loop to catch up (#9028)
Definition: GUIRunThread.h:179
MFXSynchQue< GUIEvent * > & myEventQue
Definition: GUIRunThread.h:163
FXMutex mySimulationLock
Definition: GUIRunThread.h:167
GUIRunThread(FXApp *app, MFXInterThreadEventClient *mw, double &simDelay, MFXSynchQue< GUIEvent * > &eq, FXEX::MFXThreadEvent &ev)
constructor
SUMOTime & getSimBegin()
Definition: GUIRunThread.h:115
bool myHaveSignaledEnd
whether the simulation already ended
Definition: GUIRunThread.h:155
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61