|
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-2011 DLR (http://www.dlr.de/) and contributors 00012 /****************************************************************************/ 00013 // 00014 // This program is free software; you can redistribute it and/or modify 00015 // it under the terms of the GNU General Public License as published by 00016 // the Free Software Foundation; either version 2 of the License, or 00017 // (at your option) any later version. 00018 // 00019 /****************************************************************************/ 00020 #ifndef NBLoadedSUMOTLDef_h 00021 #define NBLoadedSUMOTLDef_h 00022 00023 00024 // =========================================================================== 00025 // included modules 00026 // =========================================================================== 00027 #ifdef _MSC_VER 00028 #include <windows_config.h> 00029 #else 00030 #include <config.h> 00031 #endif 00032 00033 #include <vector> 00034 #include <string> 00035 #include <set> 00036 #include "NBNode.h" 00037 #include "NBEdgeCont.h" 00038 #include "NBTrafficLightDefinition.h" 00039 #include "NBTrafficLightLogic.h" 00040 #include <utils/common/SUMOTime.h> 00041 00042 00043 // =========================================================================== 00044 // class definitions 00045 // =========================================================================== 00050 class NBLoadedSUMOTLDef : public NBTrafficLightDefinition { 00051 public: 00052 00058 NBLoadedSUMOTLDef(const std::string& id, const std::string& programID, SUMOTime offset); 00059 00064 NBLoadedSUMOTLDef(NBTrafficLightDefinition* def, NBTrafficLightLogic* logic); 00065 00066 00068 ~NBLoadedSUMOTLDef() throw(); 00069 00073 void setTLControllingInformation(const NBEdgeCont& ec) const throw(); 00074 00080 void remapRemoved(NBEdge* removed, 00081 const EdgeVector& incoming, const EdgeVector& outgoing) throw(); 00082 00083 00090 void replaceRemoved(NBEdge* removed, int removedLane, 00091 NBEdge* by, int byLane) throw(); 00092 00098 void addPhase(SUMOTime duration, const std::string& state); 00099 00100 00103 void addConnection(NBEdge* from, NBEdge* to, int fromLane, int toLane, int linkIndex); 00104 00105 00110 void removeConnection(const NBConnection& conn, bool reconstruct=true); 00111 00114 NBTrafficLightLogic* getLogic() { 00115 return myTLLogic; 00116 } 00117 00118 00119 protected: 00123 void collectLinks() throw(ProcessError) {} 00124 00125 00131 NBTrafficLightLogic* myCompute(const NBEdgeCont& ec, 00132 unsigned int brakingTime) throw(); 00133 00134 bool amInvalid() const; 00135 00136 private: 00137 00139 NBTrafficLightLogic* myTLLogic; 00140 00142 std::set<NBNode*> myOriginalNodes; 00143 00145 void setTLControllingInformation() const; 00146 00147 private: 00149 class connection_equal { 00150 public: 00152 connection_equal(const NBConnection& c) : myC(c) {} 00153 00154 bool operator()(const NBConnection& c) const { 00155 return c.getFrom() == myC.getFrom() && c.getTo() == myC.getTo() && 00156 c.getFromLane() == myC.getFromLane() && c.getToLane() == myC.getToLane(); 00157 } 00158 private: 00159 const NBConnection& myC; 00160 private: 00162 connection_equal& operator=(const connection_equal& s); 00163 00164 }; 00165 00166 }; 00167 00168 00169 #endif 00170 00171 /****************************************************************************/ 00172