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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // The thread that runs the simulation
18 /****************************************************************************/
19 #ifndef GUIRunThread_h
20 #define GUIRunThread_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <string>
29 #include <vector>
30 #include <set>
31 #include <iostream>
32 #include <fx.h>
37 #include <utils/common/SUMOTime.h>
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class GUINet;
44 class GUIEvent;
45 class OutputDevice;
46 
47 
48 // ===========================================================================
49 // class definition
50 // ===========================================================================
59 public:
62  double& simDelay, MFXEventQue<GUIEvent*>& eq, FXEX::FXThreadEvent& ev);
63 
65  virtual ~GUIRunThread();
66 
68  virtual bool init(GUINet* net, SUMOTime start, SUMOTime end);
69 
71  virtual FXint run();
72 
75  void resume();
76 
79  void singleStep();
80 
82  virtual void begin();
83 
85  void stop();
86 
88  bool simulationAvailable() const;
89 
90  virtual bool simulationIsStartable() const;
91  virtual bool simulationIsStopable() const;
92  virtual bool simulationIsStepable() const;
93 
95  virtual void deleteSim();
96 
98  GUINet& getNet() const;
99 
101  void prepareDestruction();
102 
104  void retrieveMessage(const MsgHandler::MsgType type, const std::string& msg);
105 
107  return mySimEndTime;
108  }
109 
110  std::vector<SUMOTime>& getBreakpoints() {
111  return myBreakpoints;
112  }
113 
114  FXMutex& getBreakpointLock() {
115  return myBreakpointLock;
116  }
117 
118 protected:
119  void makeStep();
120 
121  void waitForSnapshots(const SUMOTime snapshotTime);
122 
123 protected:
126 
129 
131  bool myHalting;
132 
135  bool myQuit;
136 
141 
142  bool myOk;
143 
145  bool mySingle;
146 
149 
153 
154  double& mySimDelay;
155 
157 
159 
161 
163  std::vector<SUMOTime> myBreakpoints;
164 
167 
168 };
169 
170 
171 #endif
172 
173 /****************************************************************************/
long long int SUMOTime
Definition: SUMOTime.h:36
virtual FXint run()
starts the execution
GUIRunThread(FXApp *app, MFXInterThreadEventClient *mw, double &simDelay, MFXEventQue< GUIEvent *> &eq, FXEX::FXThreadEvent &ev)
constructor
virtual void deleteSim()
virtual bool init(GUINet *net, SUMOTime start, SUMOTime end)
initialises the thread with the new simulation
double & mySimDelay
Definition: GUIRunThread.h:154
GUINet & getNet() const
virtual bool simulationIsStopable() const
virtual bool simulationIsStepable() const
std::vector< SUMOTime > & getBreakpoints()
Definition: GUIRunThread.h:110
void retrieveMessage(const MsgHandler::MsgType type, const std::string &msg)
Retrieves messages from the loading module.
bool myHalting
information whether the simulation is halting (is not being executed)
Definition: GUIRunThread.h:131
bool myHaveSignaledEnd
whether the simulation already ended
Definition: GUIRunThread.h:148
std::vector< SUMOTime > myBreakpoints
List of breakpoints.
Definition: GUIRunThread.h:163
MFXMutex mySimulationLock
Definition: GUIRunThread.h:160
virtual ~GUIRunThread()
destructor
SUMOTime mySimEndTime
Definition: GUIRunThread.h:128
virtual bool simulationIsStartable() const
bool simulationAvailable() const
bool mySimulationInProgress
Definition: GUIRunThread.h:140
OutputDevice * myWarningRetriever
Definition: GUIRunThread.h:152
GUINet * myNet
the loaded simulation network
Definition: GUIRunThread.h:125
FXMutex & getBreakpointLock()
Definition: GUIRunThread.h:114
OutputDevice * myMessageRetriever
Definition: GUIRunThread.h:152
OutputDevice * myErrorRetriever
The instances of message retriever encapsulations Needed to be deleted from the handler later on...
Definition: GUIRunThread.h:152
void prepareDestruction()
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:82
MFXEventQue< GUIEvent * > & myEventQue
Definition: GUIRunThread.h:156
void waitForSnapshots(const SUMOTime snapshotTime)
FXMutex myBreakpointLock
Lock for modifying the list of breakpoints.
Definition: GUIRunThread.h:166
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
virtual void begin()
FXEX::FXThreadEvent & myEventThrow
Definition: GUIRunThread.h:158
SUMOTime mySimStartTime
the times the simulation starts and ends with
Definition: GUIRunThread.h:128
SUMOTime getSimEndTime() const
Definition: GUIRunThread.h:106