|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // A MSNet extended by some values for usage within the gui 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 GUINet_h 00020 #define GUINet_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 <utility> 00034 #include <microsim/MSNet.h> 00035 #include <utils/geom/Boundary.h> 00036 #include <utils/geom/Position.h> 00037 #include <foreign/rtree/SUMORTree.h> 00038 #include <utils/geom/PositionVector.h> 00039 #include <utils/gui/globjects/GUIGlObjectStorage.h> 00040 #include <utils/gui/globjects/GUIGLObjectPopupMenu.h> 00041 #include <utils/gui/globjects/GUIGlObject.h> 00042 #include <utils/gui/globjects/GUIGlObject_AbstractAdd.h> 00043 00044 00045 // =========================================================================== 00046 // class declarations 00047 // =========================================================================== 00048 class MSEdgeControl; 00049 class MSJunctionControl; 00050 class MSRouteLoaderControl; 00051 class MSTLLogicControl; 00052 class MSTrafficLightLogic; 00053 class MSLink; 00054 class GUIJunctionWrapper; 00055 class GUIDetectorWrapper; 00056 class GUITrafficLightLogicWrapper; 00057 class RGBColor; 00058 class GUIEdge; 00059 class OutputDevice; 00060 class GUIVehicle; 00061 class MSVehicleControl; 00062 00063 00064 // =========================================================================== 00065 // class definitions 00066 // =========================================================================== 00082 class GUINet : public MSNet, public GUIGlObject { 00083 00084 friend class GUITrafficLightLogicWrapper; // see createTLWrapper 00085 00086 public: 00094 GUINet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents, 00095 MSEventControl* endOfTimestepEvents, MSEventControl* insertionEvents) throw(ProcessError); 00096 00097 00099 ~GUINet() throw(); 00100 00101 00102 00104 00105 00113 GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, 00114 GUISUMOAbstractView& parent) throw(); 00115 00116 00124 GUIParameterTableWindow* getParameterWindow( 00125 GUIMainWindow& app, GUISUMOAbstractView& parent) throw(); 00126 00127 00133 Boundary getCenteringBoundary() const throw(); 00134 00135 00140 void drawGL(const GUIVisualizationSettings& s) const throw(); 00142 00143 00145 const Boundary& getBoundary() const; 00146 00148 Position getJunctionPosition(const std::string& name) const; 00149 00151 bool vehicleExists(const std::string& name) const; 00152 00154 Boundary getEdgeBoundary(const std::string& name) const; 00155 00157 void guiSimulationStep(); 00158 00159 00162 00166 unsigned int getWholeDuration() const throw(); 00167 00168 00172 unsigned int getSimDuration() const throw(); 00173 00174 00176 SUMOReal getRTFactor() const; 00177 00179 SUMOReal getUPS() const; 00180 00182 SUMOReal getMeanRTFactor(int duration) const; 00183 00185 SUMOReal getMeanUPS() const; 00186 00187 // Returns the duration of the last step's visualisation part (in ms) 00188 //int getVisDuration() const; 00189 00191 unsigned int getIdleDuration() const throw(); 00192 00194 void setSimDuration(int val); 00195 00196 // Sets the duration of the last step's visualisation part 00197 //void setVisDuration(int val); 00198 00200 void setIdleDuration(int val); 00201 //} 00202 00203 00206 unsigned int getLinkTLID(MSLink* link) const; 00207 00210 int getLinkTLIndex(MSLink* link) const; 00211 00212 00214 00215 00216 /* @brief Returns the gl-ids of all junctions within the net 00217 * @param[in] includeInternal Whether to include ids of internal junctions 00218 */ 00219 std::vector<GUIGlID> getJunctionIDs(bool includeInternal) const; 00220 00222 std::vector<GUIGlID> getTLSIDs() const; 00224 00225 00227 void initGUIStructures(); 00228 00229 00233 SUMORTree& getVisualisationSpeedUp() throw() { 00234 return myGrid; 00235 } 00236 00237 00241 const SUMORTree& getVisualisationSpeedUp() const throw() { 00242 return myGrid; 00243 } 00244 00249 static GUINet* getGUIInstance(); 00250 00251 00252 private: 00254 void initTLMap(); 00255 00257 GUIGlID createTLWrapper(MSTrafficLightLogic* tll); 00258 00259 00260 protected: 00262 SUMORTree myGrid; 00263 00265 Boundary myBoundary; 00266 00268 std::vector<GUIEdge*> myEdgeWrapper; 00269 00271 std::vector<GUIJunctionWrapper*> myJunctionWrapper; 00272 00274 std::vector<MSTrafficLightLogic*> myTLLogicWrappers; 00275 00277 std::vector<GUIDetectorWrapper*> myDetectorDict; 00278 00279 00281 typedef std::map<MSLink*, std::string> Links2LogicMap; 00283 Links2LogicMap myLinks2Logic; 00284 00285 00287 typedef std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*> Logics2WrapperMap; 00289 Logics2WrapperMap myLogics2Wrapper; 00290 00291 00293 unsigned int myLastSimDuration, /*myLastVisDuration, */myLastIdleDuration; 00294 00295 long myLastVehicleMovementCount, myOverallVehicleCount; 00296 long myOverallSimDuration; 00297 00298 }; 00299 00300 00301 #endif 00302 00303 /****************************************************************************/ 00304