|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // A traffic lights logic which represents a tls in an off-mode 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 // =========================================================================== 00020 // included modules 00021 // =========================================================================== 00022 #ifdef _MSC_VER 00023 #include <windows_config.h> 00024 #else 00025 #include <config.h> 00026 #endif 00027 00028 #include <cassert> 00029 #include <utility> 00030 #include <vector> 00031 #include <bitset> 00032 #include <sstream> 00033 #include <microsim/MSEventControl.h> 00034 #include "MSTrafficLightLogic.h" 00035 #include "MSOffTrafficLightLogic.h" 00036 00037 #ifdef CHECK_MEMORY_LEAKS 00038 #include <foreign/nvwa/debug_new.h> 00039 #endif // CHECK_MEMORY_LEAKS 00040 00041 00042 // =========================================================================== 00043 // member method definitions 00044 // =========================================================================== 00045 MSOffTrafficLightLogic::MSOffTrafficLightLogic(MSTLLogicControl& tlcontrol, 00046 const std::string& id) 00047 : MSTrafficLightLogic(tlcontrol, id, "off", 0) { 00048 myDefaultCycleTime = TIME2STEPS(120); 00049 } 00050 00051 00052 MSOffTrafficLightLogic::~MSOffTrafficLightLogic() { 00053 for (MSTrafficLightLogic::Phases::const_iterator i=myPhaseDefinition.begin(); i!=myPhaseDefinition.end(); ++i) { 00054 delete *i; 00055 } 00056 } 00057 00058 00059 void 00060 MSOffTrafficLightLogic::init(NLDetectorBuilder&) { 00061 rebuildPhase(); 00062 } 00063 00064 00065 // ----------- Handling of controlled links 00066 void 00067 MSOffTrafficLightLogic::adaptLinkInformationFrom(const MSTrafficLightLogic& logic) { 00068 MSTrafficLightLogic::adaptLinkInformationFrom(logic); 00069 rebuildPhase(); 00070 } 00071 00072 00073 void 00074 MSOffTrafficLightLogic::rebuildPhase() { 00075 size_t no = getLinks().size(); 00076 std::string state; 00077 for (unsigned int i=0; i<no; ++i) { 00078 // !!! no brake mask! 00079 state += 'o'; 00080 } 00081 for (MSTrafficLightLogic::Phases::const_iterator i=myPhaseDefinition.begin(); i!=myPhaseDefinition.end(); ++i) { 00082 delete *i; 00083 } 00084 myPhaseDefinition.clear(); 00085 myPhaseDefinition.push_back(new MSPhaseDefinition(TIME2STEPS(120), state)); 00086 } 00087 00088 00089 // ------------ Static Information Retrieval 00090 unsigned int 00091 MSOffTrafficLightLogic::getPhaseNumber() const { 00092 return 0; 00093 } 00094 00095 00096 const MSOffTrafficLightLogic::Phases& 00097 MSOffTrafficLightLogic::getPhases() const { 00098 return myPhaseDefinition; 00099 } 00100 00101 00102 const MSPhaseDefinition& 00103 MSOffTrafficLightLogic::getPhase(unsigned int) const { 00104 return *myPhaseDefinition[0]; 00105 } 00106 00107 00108 // ------------ Dynamic Information Retrieval 00109 unsigned int 00110 MSOffTrafficLightLogic::getCurrentPhaseIndex() const { 00111 return 0; 00112 } 00113 00114 00115 const MSPhaseDefinition& 00116 MSOffTrafficLightLogic::getCurrentPhaseDef() const { 00117 return *myPhaseDefinition[0]; 00118 } 00119 00120 00121 // ------------ Conversion between time and phase 00122 SUMOTime 00123 MSOffTrafficLightLogic::getPhaseIndexAtTime(SUMOTime) const { 00124 return 0; 00125 } 00126 00127 00128 SUMOTime 00129 MSOffTrafficLightLogic::getOffsetFromIndex(unsigned int) const { 00130 return 0; 00131 } 00132 00133 00134 unsigned int 00135 MSOffTrafficLightLogic::getIndexFromOffset(SUMOTime) const { 00136 return 0; 00137 } 00138 00139 00140 00141 /****************************************************************************/ 00142