00001 /****************************************************************************/ 00007 // A SUMO-compliant built logic for a traffic light 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright 2001-2010 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 NBTrafficLightLogic_h 00020 #define NBTrafficLightLogic_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 <vector> 00033 #include <string> 00034 #include <bitset> 00035 #include <utility> 00036 #include <set> 00037 #include "NBConnectionDefs.h" 00038 #include <utils/common/SUMOTime.h> 00039 #include <utils/common/Named.h> 00040 00041 00042 // =========================================================================== 00043 // class declarations 00044 // =========================================================================== 00045 class OutputDevice; 00046 00047 00048 // =========================================================================== 00049 // class definitions 00050 // =========================================================================== 00055 class NBTrafficLightLogic : public Named { 00056 public: 00062 NBTrafficLightLogic(const std::string &id, const std::string &subid, unsigned int noLinks) throw(); 00063 00064 00066 ~NBTrafficLightLogic() throw(); 00067 00068 00076 void addStep(SUMOTime duration, const std::string &state) throw(); 00077 00078 00082 void writeXML(OutputDevice &into) const throw(); 00083 00084 00089 void closeBuilding() throw(); 00090 00091 00095 SUMOTime getDuration() const throw(); 00096 00097 00101 void setOffset(SUMOTime offset) throw() { 00102 myOffset = offset; 00103 } 00104 00105 00106 private: 00111 class PhaseDefinition { 00112 public: 00114 SUMOTime duration; 00115 00117 std::string state; 00118 00125 PhaseDefinition(SUMOTime durationArg, const std::string &stateArg) throw() 00126 : duration(durationArg), state(stateArg) { } 00127 00129 ~PhaseDefinition() throw() { } 00130 00135 bool operator!=(const PhaseDefinition &pd) const throw() { 00136 return pd.duration != duration || pd.state != state; 00137 } 00138 00139 }; 00140 00141 00142 private: 00144 unsigned int myNoLinks; 00145 00147 std::string mySubID; 00148 00150 SUMOTime myOffset; 00151 00153 typedef std::vector<PhaseDefinition> PhaseDefinitionVector; 00154 00156 PhaseDefinitionVector myPhases; 00157 00158 00159 }; 00160 00161 00162 #endif 00163 00164 /****************************************************************************/ 00165
1.5.6