|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // The thread that runs the simulation 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 #ifndef GUIRunThread_h 00020 #define GUIRunThread_h 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include <string> 00033 #include <iostream> 00034 #include <fx.h> 00035 #include <utils/foxtools/FXSingleEventThread.h> 00036 #include <utils/foxtools/FXRealSpinDial.h> 00037 #include <utils/foxtools/FXThreadEvent.h> 00038 #include <utils/foxtools/MFXEventQue.h> 00039 #include <utils/common/SUMOTime.h> 00040 00041 00042 // =========================================================================== 00043 // class declarations 00044 // =========================================================================== 00045 class GUINet; 00046 class OutputDevice; 00047 00048 00049 // =========================================================================== 00050 // class definition 00051 // =========================================================================== 00059 class GUIRunThread : public FXSingleEventThread { 00060 public: 00062 GUIRunThread(MFXInterThreadEventClient* mw, 00063 FXRealSpinDial& simDelay, MFXEventQue& eq, FXEX::FXThreadEvent& ev); 00064 00066 virtual ~GUIRunThread(); 00067 00069 virtual void init(GUINet* net, SUMOTime start, SUMOTime end); 00070 00072 virtual FXint run(); 00073 00076 void resume(); 00077 00080 void singleStep(); 00081 00083 virtual void begin(); 00084 00086 void stop(); 00087 00089 bool simulationAvailable() const; 00090 00091 virtual bool simulationIsStartable() const; 00092 virtual bool simulationIsStopable() const; 00093 virtual bool simulationIsStepable() const; 00094 00096 virtual void deleteSim(); 00097 00099 GUINet& getNet() const; 00100 00102 void prepareDestruction(); 00103 00105 void retrieveMessage(const MsgHandler::MsgType type, const std::string& msg); 00106 00107 protected: 00108 void makeStep() throw(); 00109 00110 protected: 00112 GUINet* myNet; 00113 00115 SUMOTime mySimStartTime, mySimEndTime; 00116 00118 bool myHalting; 00119 00122 bool myQuit; 00123 00127 bool mySimulationInProgress; 00128 00129 bool myOk; 00130 00132 bool mySingle; 00133 00136 OutputDevice* myErrorRetriever, *myMessageRetriever, *myWarningRetriever; 00137 00138 FXRealSpinDial& mySimDelay; 00139 00140 MFXEventQue& myEventQue; 00141 00142 FXEX::FXThreadEvent& myEventThrow; 00143 00144 MFXMutex mySimulationLock; 00145 00146 }; 00147 00148 00149 #endif 00150 00151 /****************************************************************************/ 00152