SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // A complete traffic light logic loaded from a sumo-net. (opted to reimplement 00008 // since NBLoadedTLDef is quite vissim specific) 00009 /****************************************************************************/ 00010 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00011 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00012 /****************************************************************************/ 00013 // 00014 // This file is part of SUMO. 00015 // SUMO is free software: you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation, either version 3 of the License, or 00018 // (at your option) any later version. 00019 // 00020 /****************************************************************************/ 00021 #ifndef NBLoadedSUMOTLDef_h 00022 #define NBLoadedSUMOTLDef_h 00023 00024 00025 // =========================================================================== 00026 // included modules 00027 // =========================================================================== 00028 #ifdef _MSC_VER 00029 #include <windows_config.h> 00030 #else 00031 #include <config.h> 00032 #endif 00033 00034 #include <vector> 00035 #include <string> 00036 #include <set> 00037 #include "NBNode.h" 00038 #include "NBEdgeCont.h" 00039 #include "NBTrafficLightDefinition.h" 00040 #include "NBTrafficLightLogic.h" 00041 #include <utils/common/SUMOTime.h> 00042 00043 00044 // =========================================================================== 00045 // class definitions 00046 // =========================================================================== 00051 class NBLoadedSUMOTLDef : public NBTrafficLightDefinition { 00052 public: 00053 00059 NBLoadedSUMOTLDef(const std::string& id, const std::string& programID, SUMOTime offset); 00060 00065 NBLoadedSUMOTLDef(NBTrafficLightDefinition* def, NBTrafficLightLogic* logic); 00066 00067 00069 ~NBLoadedSUMOTLDef() ; 00070 00074 void setTLControllingInformation(const NBEdgeCont& ec) const ; 00075 00081 void remapRemoved(NBEdge* removed, 00082 const EdgeVector& incoming, const EdgeVector& outgoing) ; 00083 00084 00091 void replaceRemoved(NBEdge* removed, int removedLane, 00092 NBEdge* by, int byLane) ; 00093 00099 void addPhase(SUMOTime duration, const std::string& state); 00100 00101 00104 void addConnection(NBEdge* from, NBEdge* to, int fromLane, int toLane, int linkIndex); 00105 00106 00111 void removeConnection(const NBConnection& conn, bool reconstruct = true); 00112 00115 NBTrafficLightLogic* getLogic() { 00116 return myTLLogic; 00117 } 00118 00119 00120 protected: 00124 void collectLinks() {} 00125 00126 00132 NBTrafficLightLogic* myCompute(const NBEdgeCont& ec, 00133 unsigned int brakingTime) ; 00134 00135 bool amInvalid() const; 00136 00137 private: 00138 00140 NBTrafficLightLogic* myTLLogic; 00141 00143 std::set<NBNode*> myOriginalNodes; 00144 00146 void setTLControllingInformation() const; 00147 00148 private: 00150 class connection_equal { 00151 public: 00153 connection_equal(const NBConnection& c) : myC(c) {} 00154 00155 bool operator()(const NBConnection& c) const { 00156 return c.getFrom() == myC.getFrom() && c.getTo() == myC.getTo() && 00157 c.getFromLane() == myC.getFromLane() && c.getToLane() == myC.getToLane(); 00158 } 00159 private: 00160 const NBConnection& myC; 00161 private: 00163 connection_equal& operator=(const connection_equal& s); 00164 00165 }; 00166 00167 }; 00168 00169 00170 #endif 00171 00172 /****************************************************************************/ 00173