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-2019 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>
36 #include <utils/common/SUMOTime.h>
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class GUINet;
43 class GUIEvent;
44 class OutputDevice;
45 
46 
47 // ===========================================================================
48 // class definition
49 // ===========================================================================
58 public:
61  double& simDelay, FXSynchQue<GUIEvent*>& eq, FXEX::FXThreadEvent& ev);
62 
64  virtual ~GUIRunThread();
65 
67  virtual bool init(GUINet* net, SUMOTime start, SUMOTime end);
68 
70  virtual FXint run();
71 
74  void resume();
75 
78  void singleStep();
79 
81  virtual void begin();
82 
84  void stop();
85 
87  bool simulationAvailable() const;
88 
89  virtual bool simulationIsStartable() const;
90  virtual bool simulationIsStopable() const;
91  virtual bool simulationIsStepable() const;
92 
94  virtual void deleteSim();
95 
97  GUINet& getNet() const;
98 
100  void prepareDestruction();
101 
103  void retrieveMessage(const MsgHandler::MsgType type, const std::string& msg);
104 
106  return mySimEndTime;
107  }
108 
109  std::vector<SUMOTime>& getBreakpoints() {
110  return myBreakpoints;
111  }
112 
113  FXMutex& getBreakpointLock() {
114  return myBreakpointLock;
115  }
116 
117 protected:
118  void makeStep();
119 
120  void waitForSnapshots(const SUMOTime snapshotTime);
121 
122 protected:
125 
128 
130  bool myHalting;
131 
134  bool myQuit;
135 
140 
141  bool myOk;
142 
144  bool mySingle;
145 
148 
152 
153  double& mySimDelay;
154 
156 
158 
160 
162  std::vector<SUMOTime> myBreakpoints;
163 
166 
167 };
168 
169 
170 #endif
171 
172 /****************************************************************************/
long long int SUMOTime
Definition: SUMOTime.h:35
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
double & mySimDelay
Definition: GUIRunThread.h:153
GUINet & getNet() const
virtual bool simulationIsStopable() const
virtual bool simulationIsStepable() const
std::vector< SUMOTime > & getBreakpoints()
Definition: GUIRunThread.h:109
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:130
bool myHaveSignaledEnd
whether the simulation already ended
Definition: GUIRunThread.h:147
std::vector< SUMOTime > myBreakpoints
List of breakpoints.
Definition: GUIRunThread.h:162
virtual ~GUIRunThread()
destructor
SUMOTime mySimEndTime
Definition: GUIRunThread.h:127
FXSynchQue< GUIEvent * > & myEventQue
Definition: GUIRunThread.h:155
virtual bool simulationIsStartable() const
bool simulationAvailable() const
bool mySimulationInProgress
Definition: GUIRunThread.h:139
OutputDevice * myWarningRetriever
Definition: GUIRunThread.h:151
GUINet * myNet
the loaded simulation network
Definition: GUIRunThread.h:124
FXMutex & getBreakpointLock()
Definition: GUIRunThread.h:113
OutputDevice * myMessageRetriever
Definition: GUIRunThread.h:151
FXMutex mySimulationLock
Definition: GUIRunThread.h:159
OutputDevice * myErrorRetriever
The instances of message retriever encapsulations Needed to be deleted from the handler later on...
Definition: GUIRunThread.h:151
void prepareDestruction()
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:83
void waitForSnapshots(const SUMOTime snapshotTime)
FXMutex myBreakpointLock
Lock for modifying the list of breakpoints.
Definition: GUIRunThread.h:165
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
virtual void begin()
FXEX::FXThreadEvent & myEventThrow
Definition: GUIRunThread.h:157
SUMOTime mySimStartTime
the times the simulation starts and ends with
Definition: GUIRunThread.h:127
SUMOTime getSimEndTime() const
Definition: GUIRunThread.h:105
GUIRunThread(FXApp *app, MFXInterThreadEventClient *mw, double &simDelay, FXSynchQue< GUIEvent *> &eq, FXEX::FXThreadEvent &ev)
constructor