NBTrafficLightDefinition.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // The base class for traffic light logic definitions
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 NBTrafficLightDefinition_h
00020 #define NBTrafficLightDefinition_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 <utils/common/Named.h>
00038 #include <utils/common/VectorHelper.h>
00039 #include <utils/common/SUMOTime.h>
00040 #include <utils/common/UtilExceptions.h>
00041 #include "NBCont.h"
00042 #include "NBConnection.h"
00043 #include "NBConnectionDefs.h"
00044 #include "NBLinkPossibilityMatrix.h"
00045 
00046 
00047 // ===========================================================================
00048 // class declarations
00049 // ===========================================================================
00050 class NBNode;
00051 class OptionsCont;
00052 class NBTrafficLightLogic;
00053 
00054 
00055 // ===========================================================================
00056 // class definitions
00057 // ===========================================================================
00070 class NBTrafficLightDefinition : public Named {
00071 public:
00076     enum TLColor {
00078         TLCOLOR_RED,
00080         TLCOLOR_YELLOW,
00082         TLCOLOR_REDYELLOW,
00084         TLCOLOR_GREEN,
00086         TLCOLOR_BLINK
00087     };
00088 
00089 
00094     NBTrafficLightDefinition(const std::string &id,
00095                              const std::vector<NBNode*> &junctions) throw();
00096 
00097 
00102     NBTrafficLightDefinition(const std::string &id,
00103                              NBNode *junction) throw();
00104 
00105 
00109     NBTrafficLightDefinition(const std::string &id) throw();
00110 
00111 
00113     virtual ~NBTrafficLightDefinition() throw();
00114 
00115 
00125     NBTrafficLightLogic *compute(const NBEdgeCont &ec, OptionsCont &oc) throw();
00126 
00127 
00128 
00131 
00135     void addNode(NBNode *node) throw();
00136 
00137 
00141     void removeNode(NBNode *node) throw();
00142 
00143 
00147     const std::vector<NBNode*> &getNodes() const throw() {
00148         return myControlledNodes;
00149     }
00151 
00152 
00163     bool mustBrake(const NBEdge * const from, const NBEdge * const to) const throw();
00164 
00165 
00173     bool mustBrake(const NBConnection &possProhibited,
00174                    const NBConnection &possProhibitor,
00175                    bool regardNonSignalisedLowerPriority) const throw();
00176 
00186     bool mustBrake(const NBEdge * const possProhibitedFrom, const NBEdge * const possProhibitedTo,
00187                    const NBEdge * const possProhibitorFrom, const NBEdge * const possProhibitorTo,
00188                    bool regardNonSignalisedLowerPriority) const throw();
00189 
00190 
00200     bool forbids(const NBEdge * const possProhibitorFrom, const NBEdge * const possProhibitorTo,
00201                  const NBEdge * const possProhibitedFrom, const NBEdge * const possProhibitedTo,
00202                  bool regardNonSignalisedLowerPriority) const throw();
00203 
00204 
00212     bool foes(const NBEdge * const from1, const NBEdge * const to1,
00213               const NBEdge * const from2, const NBEdge * const to2) const throw();
00214 
00215 
00219     virtual void setTLControllingInformation(const NBEdgeCont &ec) const throw() = 0;
00220 
00221 
00224     virtual void setParticipantsInformation() throw();
00225 
00226 
00230     void addControlledInnerEdges(const std::vector<std::string> &edges) throw();
00231 
00232 
00238     virtual void remapRemoved(NBEdge *removed,
00239                               const EdgeVector &incoming, const EdgeVector &outgoing) throw() = 0;
00240 
00241 
00248     virtual void replaceRemoved(NBEdge *removed, int removedLane,
00249                                 NBEdge *by, int byLane) throw() = 0;
00250 
00251 
00257     bool isLeftMover(const NBEdge * const from, const NBEdge * const to) const throw();
00258 
00259 
00263     const EdgeVector &getIncomingEdges() const throw();
00264 
00265 
00266 protected:
00272     virtual NBTrafficLightLogic *myCompute(const NBEdgeCont &ec,
00273                                            unsigned int brakingTime) throw() = 0;
00274 
00275 
00279     std::pair<unsigned int, unsigned int> getSizes() const throw();
00280 
00281 
00285     virtual void collectLinks() throw(ProcessError);
00286 
00287 
00290     void collectEdges() throw();
00291 
00292 
00298     unsigned int computeBrakingTime(SUMOReal minDecel) const throw();
00299 
00300 
00301 protected:
00303     std::vector<NBNode*> myControlledNodes;
00304 
00306     EdgeVector myIncomingEdges;
00307 
00309     EdgeVector myEdgesWithin;
00310 
00312     NBConnectionVector myControlledLinks;
00313 
00315     std::vector<std::string> myControlledInnerEdges;
00316 
00317 
00318 };
00319 
00320 
00321 #endif
00322 
00323 /****************************************************************************/
00324 

Generated on Wed May 5 00:06:33 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6