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.org/sumo
3 // Copyright (C) 2001-2022 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>
33 #include <utils/common/SUMOTime.h>
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class GUINet;
40 class GUIEvent;
41 class OutputDevice;
42 
43 
44 // ===========================================================================
45 // class definition
46 // ===========================================================================
55 public:
58  double& simDelay, FXSynchQue<GUIEvent*>& eq, FXEX::FXThreadEvent& ev);
59 
61  virtual ~GUIRunThread();
62 
64  virtual bool init(GUINet* net, SUMOTime start, SUMOTime end);
65 
67  virtual FXint run();
68 
71  void resume();
72 
75  void singleStep();
76 
78  virtual void begin();
79 
81  void stop();
82 
84  bool simulationAvailable() const;
85 
86  virtual bool simulationIsStartable() const;
87  virtual bool simulationIsStopable() const;
88  virtual bool simulationIsStepable() const;
89 
91  virtual void deleteSim();
92 
94  GUINet& getNet() const;
95 
97  void prepareDestruction();
98 
100  void retrieveMessage(const MsgHandler::MsgType type, const std::string& msg);
101 
103  return mySimEndTime;
104  }
105 
106  std::vector<SUMOTime>& getBreakpoints() {
107  return myBreakpoints;
108  }
109 
110  FXMutex& getBreakpointLock() {
111  return myBreakpointLock;
112  }
113 
114 protected:
115  void makeStep();
116 
117  void waitForSnapshots(const SUMOTime snapshotTime);
118 
119 protected:
122 
125 
127  bool myHalting;
128 
131  bool myQuit;
132 
137 
138  bool myOk;
139 
141  bool mySingle;
142 
145 
149 
150  double& mySimDelay;
151 
153 
155 
157 
159  std::vector<SUMOTime> myBreakpoints;
160 
163 
166 
167 };
long long int SUMOTime
Definition: SUMOTime.h:32
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:81
double & mySimDelay
Definition: GUIRunThread.h:150
OutputDevice * myErrorRetriever
The instances of message retriever encapsulations Needed to be deleted from the handler later on.
Definition: GUIRunThread.h:148
GUINet * myNet
the loaded simulation network
Definition: GUIRunThread.h:121
SUMOTime mySimEndTime
Definition: GUIRunThread.h:124
FXMutex & getBreakpointLock()
Definition: GUIRunThread.h:110
FXMutex myBreakpointLock
Lock for modifying the list of breakpoints.
Definition: GUIRunThread.h:162
FXEX::FXThreadEvent & myEventThrow
Definition: GUIRunThread.h:154
GUINet & getNet() const
std::vector< SUMOTime > myBreakpoints
List of breakpoints.
Definition: GUIRunThread.h:159
virtual FXint run()
starts the execution
virtual void begin()
std::vector< SUMOTime > & getBreakpoints()
Definition: GUIRunThread.h:106
virtual bool simulationIsStartable() const
GUIRunThread(FXApp *app, MFXInterThreadEventClient *mw, double &simDelay, FXSynchQue< GUIEvent * > &eq, FXEX::FXThreadEvent &ev)
constructor
FXSynchQue< GUIEvent * > & myEventQue
Definition: GUIRunThread.h:152
virtual bool simulationIsStepable() const
bool mySimulationInProgress
Definition: GUIRunThread.h:136
virtual bool init(GUINet *net, SUMOTime start, SUMOTime end)
initialises the thread with the new simulation
bool myHalting
information whether the simulation is halting (is not being executed)
Definition: GUIRunThread.h:127
SUMOTime getSimEndTime() const
Definition: GUIRunThread.h:102
virtual ~GUIRunThread()
destructor
virtual bool simulationIsStopable() const
OutputDevice * myMessageRetriever
Definition: GUIRunThread.h:148
OutputDevice * myWarningRetriever
Definition: GUIRunThread.h:148
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:124
void prepareDestruction()
long myLastBreakMillis
last time the simulation took a microsecond break for the fox event loop to catch up (#9028)
Definition: GUIRunThread.h:165
FXMutex mySimulationLock
Definition: GUIRunThread.h:156
bool myHaveSignaledEnd
whether the simulation already ended
Definition: GUIRunThread.h:144
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61