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 <iostream>
30 #include <fx.h>
34 #include <utils/common/SUMOTime.h>
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class GUINet;
41 class GUIEvent;
42 class OutputDevice;
43 
44 
45 // ===========================================================================
46 // class definition
47 // ===========================================================================
56 public:
59  double& simDelay, MFXEventQue<GUIEvent*>& eq, FXEX::FXThreadEvent& ev);
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 
115  std::set<SUMOTime>& getSnapshots() {
116  return myApplicationSnapshots;
117  }
118 
119  FXMutex& getSnapshotsLock() {
121  }
122 
123 protected:
124  void makeStep();
125 
126  void waitForSnapshots(SUMOTime snapShotTime);
127 
128 protected:
131 
134 
136  bool myHalting;
137 
140  bool myQuit;
141 
146 
147  bool myOk;
148 
150  bool mySingle;
151 
154 
158 
159  double& mySimDelay;
160 
162 
164 
166 
168  std::vector<SUMOTime> myBreakpoints;
169 
172 
174  std::set<SUMOTime> myApplicationSnapshots;
175 
178 
179 };
180 
181 
182 #endif
183 
184 /****************************************************************************/
185 
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:159
void waitForSnapshots(SUMOTime snapShotTime)
std::set< SUMOTime > myApplicationSnapshots
List of snapshot times.
Definition: GUIRunThread.h:174
GUINet & getNet() const
virtual bool simulationIsStopable() const
virtual bool simulationIsStepable() const
std::vector< SUMOTime > & getBreakpoints()
Definition: GUIRunThread.h:107
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:136
bool myHaveSignaledEnd
whether the simulation already ended
Definition: GUIRunThread.h:153
std::vector< SUMOTime > myBreakpoints
List of breakpoints.
Definition: GUIRunThread.h:168
MFXMutex mySimulationLock
Definition: GUIRunThread.h:165
std::set< SUMOTime > & getSnapshots()
Definition: GUIRunThread.h:115
virtual ~GUIRunThread()
destructor
SUMOTime mySimEndTime
Definition: GUIRunThread.h:133
virtual bool simulationIsStartable() const
bool simulationAvailable() const
bool mySimulationInProgress
Definition: GUIRunThread.h:145
OutputDevice * myWarningRetriever
Definition: GUIRunThread.h:157
GUINet * myNet
the loaded simulation network
Definition: GUIRunThread.h:130
FXMutex & getBreakpointLock()
Definition: GUIRunThread.h:111
OutputDevice * myMessageRetriever
Definition: GUIRunThread.h:157
OutputDevice * myErrorRetriever
The instances of message retriever encapsulations Needed to be deleted from the handler later on...
Definition: GUIRunThread.h:157
void prepareDestruction()
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:82
MFXEventQue< GUIEvent * > & myEventQue
Definition: GUIRunThread.h:161
FXMutex myBreakpointLock
Lock for modifying the list of breakpoints.
Definition: GUIRunThread.h:171
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
virtual void begin()
FXEX::FXThreadEvent & myEventThrow
Definition: GUIRunThread.h:163
SUMOTime mySimStartTime
the times the simulation starts and ends with
Definition: GUIRunThread.h:133
SUMOTime getSimEndTime() const
Definition: GUIRunThread.h:103
FXMutex & getSnapshotsLock()
Definition: GUIRunThread.h:119
FXMutex myApplicationSnapshotsLock
Lock for modifying the list of snapshot times.
Definition: GUIRunThread.h:177