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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // The thread that runs the simulation
20 /****************************************************************************/
21 #ifndef GUIRunThread_h
22 #define GUIRunThread_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include <iostream>
36 #include <fx.h>
41 #include <utils/common/SUMOTime.h>
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class GUINet;
48 class GUIEvent;
49 class OutputDevice;
50 
51 
52 // ===========================================================================
53 // class definition
54 // ===========================================================================
63 public:
67 
69  virtual ~GUIRunThread();
70 
72  virtual bool init(GUINet* net, SUMOTime start, SUMOTime end);
73 
75  virtual FXint run();
76 
79  void resume();
80 
83  void singleStep();
84 
86  virtual void begin();
87 
89  void stop();
90 
92  bool simulationAvailable() const;
93 
94  virtual bool simulationIsStartable() const;
95  virtual bool simulationIsStopable() const;
96  virtual bool simulationIsStepable() const;
97 
99  virtual void deleteSim();
100 
102  GUINet& getNet() const;
103 
105  void prepareDestruction();
106 
108  void retrieveMessage(const MsgHandler::MsgType type, const std::string& msg);
109 
111  return mySimEndTime;
112  }
113 
114  std::vector<SUMOTime>& getBreakpoints() {
115  return myBreakpoints;
116  }
117 
118  FXMutex& getBreakpointLock() {
119  return myBreakpointLock;
120  }
121 
122  std::set<SUMOTime>& getSnapshots() {
123  return myApplicationSnapshots;
124  }
125 
126  FXMutex& getSnapshotsLock() {
128  }
129 
130 protected:
131  void makeStep();
132 
133  void waitForSnapshots(SUMOTime snapShotTime);
134 
135 protected:
138 
141 
143  bool myHalting;
144 
147  bool myQuit;
148 
153 
154  bool myOk;
155 
157  bool mySingle;
158 
161 
165 
167 
169 
171 
173 
175  std::vector<SUMOTime> myBreakpoints;
176 
179 
181  std::set<SUMOTime> myApplicationSnapshots;
182 
185 
186 };
187 
188 
189 #endif
190 
191 /****************************************************************************/
192 
GUIRunThread(FXApp *app, MFXInterThreadEventClient *mw, FXRealSpinDial &simDelay, MFXEventQue< GUIEvent *> &eq, FXEX::FXThreadEvent &ev)
constructor
virtual FXint run()
starts the execution
virtual void deleteSim()
virtual bool init(GUINet *net, SUMOTime start, SUMOTime end)
initialises the thread with the new simulation
void waitForSnapshots(SUMOTime snapShotTime)
std::set< SUMOTime > myApplicationSnapshots
List of snapshot times.
Definition: GUIRunThread.h:181
GUINet & getNet() const
virtual bool simulationIsStopable() const
virtual bool simulationIsStepable() const
std::vector< SUMOTime > & getBreakpoints()
Definition: GUIRunThread.h:114
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:143
bool myHaveSignaledEnd
whether the simulation already ended
Definition: GUIRunThread.h:160
std::vector< SUMOTime > myBreakpoints
List of breakpoints.
Definition: GUIRunThread.h:175
MFXMutex mySimulationLock
Definition: GUIRunThread.h:172
std::set< SUMOTime > & getSnapshots()
Definition: GUIRunThread.h:122
virtual ~GUIRunThread()
destructor
SUMOTime mySimEndTime
Definition: GUIRunThread.h:140
virtual bool simulationIsStartable() const
bool simulationAvailable() const
bool mySimulationInProgress
Definition: GUIRunThread.h:152
OutputDevice * myWarningRetriever
Definition: GUIRunThread.h:164
GUINet * myNet
the loaded simulation network
Definition: GUIRunThread.h:137
FXMutex & getBreakpointLock()
Definition: GUIRunThread.h:118
OutputDevice * myMessageRetriever
Definition: GUIRunThread.h:164
OutputDevice * myErrorRetriever
The instances of message retriever encapsulations Needed to be deleted from the handler later on...
Definition: GUIRunThread.h:164
void prepareDestruction()
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:88
MFXEventQue< GUIEvent * > & myEventQue
Definition: GUIRunThread.h:168
FXMutex myBreakpointLock
Lock for modifying the list of breakpoints.
Definition: GUIRunThread.h:178
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
long long int SUMOTime
Definition: TraCIDefs.h:51
virtual void begin()
FXEX::FXThreadEvent & myEventThrow
Definition: GUIRunThread.h:170
SUMOTime mySimStartTime
the times the simulation starts and ends with
Definition: GUIRunThread.h:140
Spinner control.
SUMOTime getSimEndTime() const
Definition: GUIRunThread.h:110
FXRealSpinDial & mySimDelay
Definition: GUIRunThread.h:166
FXMutex & getSnapshotsLock()
Definition: GUIRunThread.h:126
FXMutex myApplicationSnapshotsLock
Lock for modifying the list of snapshot times.
Definition: GUIRunThread.h:184