SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // A traffic lights logic which represents a tls in an off-mode 00010 /****************************************************************************/ 00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00013 /****************************************************************************/ 00014 // 00015 // This file is part of SUMO. 00016 // SUMO is free software: you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation, either version 3 of the License, or 00019 // (at your option) any later version. 00020 // 00021 /****************************************************************************/ 00022 // =========================================================================== 00023 // included modules 00024 // =========================================================================== 00025 #ifdef _MSC_VER 00026 #include <windows_config.h> 00027 #else 00028 #include <config.h> 00029 #endif 00030 00031 #include <cassert> 00032 #include <utility> 00033 #include <vector> 00034 #include <bitset> 00035 #include <sstream> 00036 #include <microsim/MSEventControl.h> 00037 #include "MSTrafficLightLogic.h" 00038 #include "MSOffTrafficLightLogic.h" 00039 00040 #ifdef CHECK_MEMORY_LEAKS 00041 #include <foreign/nvwa/debug_new.h> 00042 #endif // CHECK_MEMORY_LEAKS 00043 00044 00045 // =========================================================================== 00046 // member method definitions 00047 // =========================================================================== 00048 MSOffTrafficLightLogic::MSOffTrafficLightLogic(MSTLLogicControl& tlcontrol, 00049 const std::string& id) 00050 : MSTrafficLightLogic(tlcontrol, id, "off", 0) { 00051 myDefaultCycleTime = TIME2STEPS(120); 00052 } 00053 00054 00055 MSOffTrafficLightLogic::~MSOffTrafficLightLogic() { 00056 for (MSTrafficLightLogic::Phases::const_iterator i = myPhaseDefinition.begin(); i != myPhaseDefinition.end(); ++i) { 00057 delete *i; 00058 } 00059 } 00060 00061 00062 void 00063 MSOffTrafficLightLogic::init(NLDetectorBuilder&) { 00064 rebuildPhase(); 00065 } 00066 00067 00068 // ----------- Handling of controlled links 00069 void 00070 MSOffTrafficLightLogic::adaptLinkInformationFrom(const MSTrafficLightLogic& logic) { 00071 MSTrafficLightLogic::adaptLinkInformationFrom(logic); 00072 rebuildPhase(); 00073 } 00074 00075 00076 void 00077 MSOffTrafficLightLogic::rebuildPhase() { 00078 size_t no = getLinks().size(); 00079 std::string state; 00080 for (unsigned int i = 0; i < no; ++i) { 00081 // !!! no brake mask! 00082 state += 'o'; 00083 } 00084 for (MSTrafficLightLogic::Phases::const_iterator i = myPhaseDefinition.begin(); i != myPhaseDefinition.end(); ++i) { 00085 delete *i; 00086 } 00087 myPhaseDefinition.clear(); 00088 myPhaseDefinition.push_back(new MSPhaseDefinition(TIME2STEPS(120), state)); 00089 } 00090 00091 00092 // ------------ Static Information Retrieval 00093 unsigned int 00094 MSOffTrafficLightLogic::getPhaseNumber() const { 00095 return 0; 00096 } 00097 00098 00099 const MSOffTrafficLightLogic::Phases& 00100 MSOffTrafficLightLogic::getPhases() const { 00101 return myPhaseDefinition; 00102 } 00103 00104 00105 const MSPhaseDefinition& 00106 MSOffTrafficLightLogic::getPhase(unsigned int) const { 00107 return *myPhaseDefinition[0]; 00108 } 00109 00110 00111 // ------------ Dynamic Information Retrieval 00112 unsigned int 00113 MSOffTrafficLightLogic::getCurrentPhaseIndex() const { 00114 return 0; 00115 } 00116 00117 00118 const MSPhaseDefinition& 00119 MSOffTrafficLightLogic::getCurrentPhaseDef() const { 00120 return *myPhaseDefinition[0]; 00121 } 00122 00123 00124 // ------------ Conversion between time and phase 00125 SUMOTime 00126 MSOffTrafficLightLogic::getPhaseIndexAtTime(SUMOTime) const { 00127 return 0; 00128 } 00129 00130 00131 SUMOTime 00132 MSOffTrafficLightLogic::getOffsetFromIndex(unsigned int) const { 00133 return 0; 00134 } 00135 00136 00137 unsigned int 00138 MSOffTrafficLightLogic::getIndexFromOffset(SUMOTime) const { 00139 return 0; 00140 } 00141 00142 00143 00144 /****************************************************************************/ 00145