SUMO - Simulation of Urban MObility
GUIRunThread.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // The thread that runs the simulation
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef GUIRunThread_h
23 #define GUIRunThread_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <iostream>
37 #include <fx.h>
42 #include <utils/common/SUMOTime.h>
43 
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 class GUINet;
49 class GUIEvent;
50 class OutputDevice;
51 
52 
53 // ===========================================================================
54 // class definition
55 // ===========================================================================
64 public:
68 
70  virtual ~GUIRunThread();
71 
73  virtual bool init(GUINet* net, SUMOTime start, SUMOTime end);
74 
76  virtual FXint run();
77 
80  void resume();
81 
84  void singleStep();
85 
87  virtual void begin();
88 
90  void stop();
91 
93  bool simulationAvailable() const;
94 
95  virtual bool simulationIsStartable() const;
96  virtual bool simulationIsStopable() const;
97  virtual bool simulationIsStepable() const;
98 
100  virtual void deleteSim();
101 
103  GUINet& getNet() const;
104 
106  void prepareDestruction();
107 
109  void retrieveMessage(const MsgHandler::MsgType type, const std::string& msg);
110 
112  return mySimEndTime;
113  }
114 
115  std::vector<SUMOTime>& getBreakpoints() {
116  return myBreakpoints;
117  }
118 
119  FXMutex& getBreakpointLock() {
120  return myBreakpointLock;
121  }
122 
123  std::set<SUMOTime>& getSnapshots() {
124  return myApplicationSnapshots;
125  }
126 
127  FXMutex& getSnapshotsLock() {
129  }
130 
131 protected:
132  void makeStep();
133 
134  void waitForSnapshots(SUMOTime snapShotTime);
135 
136 protected:
139 
142 
144  bool myHalting;
145 
148  bool myQuit;
149 
154 
155  bool myOk;
156 
158  bool mySingle;
159 
162 
166 
168 
170 
172 
174 
176  std::vector<SUMOTime> myBreakpoints;
177 
180 
182  std::set<SUMOTime> myApplicationSnapshots;
183 
186 
187 };
188 
189 
190 #endif
191 
192 /****************************************************************************/
193 
virtual bool simulationIsStepable() const
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:182
virtual bool simulationIsStartable() const
std::vector< SUMOTime > & getBreakpoints()
Definition: GUIRunThread.h:115
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:144
bool myHaveSignaledEnd
whether the simulation already ended
Definition: GUIRunThread.h:161
std::vector< SUMOTime > myBreakpoints
List of breakpoints.
Definition: GUIRunThread.h:176
MFXMutex mySimulationLock
Definition: GUIRunThread.h:173
std::set< SUMOTime > & getSnapshots()
Definition: GUIRunThread.h:123
virtual ~GUIRunThread()
destructor
SUMOTime mySimEndTime
Definition: GUIRunThread.h:141
bool mySimulationInProgress
Definition: GUIRunThread.h:153
virtual bool simulationIsStopable() const
OutputDevice * myWarningRetriever
Definition: GUIRunThread.h:165
GUINet * myNet
the loaded simulation network
Definition: GUIRunThread.h:138
FXMutex & getBreakpointLock()
Definition: GUIRunThread.h:119
GUINet & getNet() const
OutputDevice * myMessageRetriever
Definition: GUIRunThread.h:165
OutputDevice * myErrorRetriever
The instances of message retriever encapsulations Needed to be deleted from the handler later on...
Definition: GUIRunThread.h:165
void prepareDestruction()
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:89
MFXEventQue< GUIEvent * > & myEventQue
Definition: GUIRunThread.h:169
SUMOTime getSimEndTime() const
Definition: GUIRunThread.h:111
bool simulationAvailable() const
FXMutex myBreakpointLock
Lock for modifying the list of breakpoints.
Definition: GUIRunThread.h:179
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
long long int SUMOTime
Definition: TraCIDefs.h:52
virtual void begin()
FXEX::FXThreadEvent & myEventThrow
Definition: GUIRunThread.h:171
SUMOTime mySimStartTime
the times the simulation starts and ends with
Definition: GUIRunThread.h:141
Spinner control.
FXRealSpinDial & mySimDelay
Definition: GUIRunThread.h:167
FXMutex & getSnapshotsLock()
Definition: GUIRunThread.h:127
FXMutex myApplicationSnapshotsLock
Lock for modifying the list of snapshot times.
Definition: GUIRunThread.h:185
GUIRunThread(FXApp *app, MFXInterThreadEventClient *mw, FXRealSpinDial &simDelay, MFXEventQue< GUIEvent * > &eq, FXEX::FXThreadEvent &ev)
constructor