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-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
OutputDevice * myErrorRetriever
The instances of message retriever encapsulations Needed to be deleted from the handler later on.
GUINet * myNet
the loaded simulation network
SUMOTime mySimEndTime
FXMutex myBreakpointLock
Lock for modifying the list of breakpoints.
GUINet & getNet() const
std::vector< SUMOTime > myBreakpoints
List of breakpoints.
virtual FXint run()
starts the execution
virtual void begin()
FXEX::MFXThreadEvent & myEventThrow
virtual bool simulationIsStartable() const
virtual bool simulationIsStepable() const
bool mySimulationInProgress
std::vector< SUMOTime > & getBreakpoints()
virtual bool init(GUINet *net, SUMOTime start, SUMOTime end)
initialises the thread with the new simulation
FXMutex & getBreakpointLock()
bool myHalting
information whether the simulation is halting (is not being executed)
SUMOTime getSimEndTime() const
virtual ~GUIRunThread()
destructor
virtual bool simulationIsStopable() const
void enableLibsumo()
OutputDevice * myMessageRetriever
long myLastEndMillis
end of the last simulation step
OutputDevice * myWarningRetriever
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
bool myAmLibsumo
whether we are running in libsumo
void prepareDestruction()
long myLastBreakMillis
last time the simulation took a microsecond break for the fox event loop to catch up (#9028)
MFXSynchQue< GUIEvent * > & myEventQue
FXMutex mySimulationLock
SUMOTime & getSimBegin()
bool myHaveSignaledEnd
whether the simulation already ended
Static storage of an output device and its base (abstract) implementation.