00001 /****************************************************************************/ 00007 // The thread that runs the simulation 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright 2001-2010 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 <fx.h> 00036 #include <utils/foxtools/FXSingleEventThread.h> 00037 #include <utils/foxtools/FXRealSpinDial.h> 00038 #include <utils/foxtools/FXThreadEvent.h> 00039 #include <utils/foxtools/MFXEventQue.h> 00040 #include <utils/foxtools/MFXMutex.h> 00041 #include <utils/common/SUMOTime.h> 00042 00043 00044 // =========================================================================== 00045 // class declarations 00046 // =========================================================================== 00047 class GUINet; 00048 class GUIApplicationWindow; 00049 class OutputDevice; 00050 00051 00052 // =========================================================================== 00053 // class definition 00054 // =========================================================================== 00062 class GUIRunThread : public FXSingleEventThread { 00063 public: 00065 GUIRunThread(MFXInterThreadEventClient *mw, 00066 FXRealSpinDial &simDelay, MFXEventQue &eq, FXEX::FXThreadEvent &ev); 00067 00069 virtual ~GUIRunThread(); 00070 00072 virtual void init(GUINet *net, SUMOTime start, SUMOTime end); 00073 00075 virtual FXint run(); 00076 00079 void resume(); 00080 00083 void singleStep(); 00084 00086 virtual void begin(); 00087 00089 void stop(); 00090 00092 bool simulationAvailable() const; 00093 00094 virtual bool simulationIsStartable() const; 00095 virtual bool simulationIsStopable() const; 00096 virtual bool simulationIsStepable() const; 00097 00099 virtual void deleteSim(); 00100 00102 GUINet &getNet() const; 00103 00105 void prepareDestruction(); 00106 00108 void retrieveMessage(const MsgHandler::MsgType type, const std::string &msg); 00109 00110 protected: 00111 void makeStep() throw(); 00112 00113 protected: 00115 GUINet *myNet; 00116 00118 SUMOTime mySimStartTime, mySimEndTime; 00119 00121 bool myHalting; 00122 00125 bool myQuit; 00126 00130 bool mySimulationInProgress; 00131 00132 bool myOk; 00133 00135 bool mySingle; 00136 00139 OutputDevice *myErrorRetriever, *myMessageRetriever, *myWarningRetriever; 00140 00141 FXRealSpinDial &mySimDelay; 00142 00143 MFXEventQue &myEventQue; 00144 00145 FXEX::FXThreadEvent &myEventThrow; 00146 00147 MFXMutex mySimulationLock; 00148 00149 }; 00150 00151 00152 #endif 00153 00154 /****************************************************************************/ 00155
1.5.6