SUMO - Simulation of Urban MObility
NLJunctionControlBuilder.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Builder of microsim-junctions and tls
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef NLJunctionControlBuilder_h
23 #define NLJunctionControlBuilder_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <vector>
37 #include <microsim/MSJunction.h>
40 #include <utils/geom/Position.h>
45 #include <microsim/MSBitSetLogic.h>
48 
49 
50 // ===========================================================================
51 // class declarations
52 // ===========================================================================
53 class OptionsCont;
54 class NLDetectorBuilder;
55 
56 
57 // ===========================================================================
58 // class definitions
59 // ===========================================================================
71 private:
73  typedef std::vector<MSLane*> LaneVector;
74 
75 public:
84 
85 
91  virtual ~NLJunctionControlBuilder();
92 
93 
107  void openJunction(const std::string& id, const std::string& key,
108  const SumoXMLNodeType type, SUMOReal x, SUMOReal y,
109  const PositionVector& shape,
110  const std::vector<MSLane*>& incomingLanes,
111  const std::vector<MSLane*>& internalLanes);
112 
113 
126  void closeJunction(const std::string& basePath);
127 
128 
136  MSJunctionControl* build() const;
137 
138 
142  void initJunctionLogic(const std::string& id);
143 
144 
156  void addLogicItem(int request, const std::string& response,
157  const std::string& foes, bool cont);
158 
159 
169  void initTrafficLightLogic(const std::string& id, const std::string& programID,
170  TrafficLightType type, SUMOTime offset);
171 
172 
182  void addPhase(SUMOTime duration, const std::string& state,
184 
194  void addPhase(SUMOTime duration, const std::string& state, SUMOTime minDuration, SUMOTime maxDuration, bool transient_notdecisional, bool commit) throw();
195 
196 
207  void addPhase(SUMOTime duration, const std::string& state, SUMOTime minDuration, SUMOTime maxDuration, bool transient_notdecisional, bool commit, MSPhaseDefinition::LaneIdVector& targetLanes) throw();
208 
209 
216  MSTLLogicControl::TLSLogicVariants& getTLLogic(const std::string& id)
217  const;
218 
219 
230 
231 
240  virtual void closeTrafficLightLogic(const std::string& basePath);
241 
242 
253  void closeJunctionLogic();
254 
255 
263  void addParam(const std::string& key, const std::string& value);
264 
265 
269  const std::string& getActiveKey() const;
270 
271 
275  const std::string& getActiveSubKey() const;
276 
277 
286 
288  void postLoadInitialization();
289 
291  MSJunction* retrieve(const std::string id);
292 
295  return (int)myActivePhases.size();
296  }
297 
298 
299 protected:
310 
311 
312 protected:
315 
322  virtual MSJunction* buildNoLogicJunction();
323 
324 
333  virtual MSJunction* buildLogicJunction();
334 
335 
336 #ifdef HAVE_INTERNAL_LANES
337 
343  virtual MSJunction* buildInternalJunction();
344 #endif
345 
347 
348 protected:
351 
354 
357 
360 
363 
366 
368  std::bitset<SUMO_MAX_CONNECTIONS> myActiveConts;
369 
372 
375 
378 
381 
384 
385 #ifdef HAVE_INTERNAL_LANES
386  LaneVector myActiveInternalLanes;
388 #endif
389 
391  std::string myActiveID;
392 
395 
398 
401 
404 
407 
408 
410  std::vector<MSTrafficLightLogic*> myLogics2PostLoadInit;
411 
412 
415 
416 
418  typedef std::map<std::string, std::string> StringParameterMap;
419 
421  StringParameterMap myAdditionalParameter;
422 
423 
425  std::map<std::string, MSJunctionLogic*> myLogics;
426 
429 
430 
431 private:
434 
437 
438  static const int NO_REQUEST_SIZE;
439 
442 
443 };
444 
445 
446 #endif
447 
448 /****************************************************************************/
449 
void postLoadInitialization()
initialize junctions after all connections have been loaded
std::map< std::string, std::string > StringParameterMap
Definition of a parameter map (key->value)
void initTrafficLightLogic(const std::string &id, const std::string &programID, TrafficLightType type, SUMOTime offset)
Begins the reading of a traffic lights logic.
Builds detectors for microsim.
virtual ~NLJunctionControlBuilder()
Destructor.
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
long long int SUMOTime
Definition: SUMOTime.h:43
std::bitset< SUMO_MAX_CONNECTIONS > myActiveConts
The description about which lanes have an internal follower.
Storage for all programs of a single tls.
#define min(a, b)
Definition: polyfonts.c:66
std::string myActiveKey
The key of the currently chosen junction.
The base class for an intersection.
Definition: MSJunction.h:64
MSNet & myNet
The net to use.
MSBitsetLogic::Logic myActiveLogic
The right-of-way-logic of the currently chosen bitset-logic.
void closeJunctionLogic()
Ends the building of a junction logic (row-logic)
SUMOTime myAbsDuration
The absolute duration of a tls-control loop.
const std::string & getActiveSubKey() const
Returns the active sub key.
Position myPosition
The position of the junction.
PositionVector myShape
The shape of the current junction.
The simulated network and simulation perfomer.
Definition: MSNet.h:93
int getNumberOfLoadedPhases() const
return the number of phases loaded so far (for error reporting)
Container for junctions; performs operations on all stored junctions.
SUMOTime myOffset
The switch offset within the tls.
void closeJunction(const std::string &basePath)
Closes (ends) the processing of the current junction.
MSTLLogicControl::TLSLogicVariants & getTLLogic(const std::string &id) const
Returns a previously build tls logic.
A class that stores and controls tls and switching of their programs.
void addPhase(SUMOTime duration, const std::string &state, SUMOTime min, SUMOTime max)
Adds a phase to the currently built traffic lights logic.
MSSimpleTrafficLightLogic::Phases myActivePhases
The current phase definitions for a simple traffic light.
TrafficLightType myLogicType
The current logic type.
#define max(a, b)
Definition: polyfonts.c:65
std::string myActiveID
The id of the currently chosen junction.
MSJunctionControl * myJunctions
The junctions controls.
Builder of microsim-junctions and tls.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
virtual MSJunction * buildLogicJunction()
Builds a junction with a logic.
virtual void closeTrafficLightLogic(const std::string &basePath)
Ends the building of a traffic lights logic.
void openJunction(const std::string &id, const std::string &key, const SumoXMLNodeType type, SUMOReal x, SUMOReal y, const PositionVector &shape, const std::vector< MSLane *> &incomingLanes, const std::vector< MSLane *> &internalLanes)
Begins the processing of the named junction.
std::map< std::string, MSJunctionLogic * > myLogics
Map of loaded junction logics.
int myRequestSize
The size of the request.
std::vector< std::bitset< N > > Foes
Container holding the information which internal lanes prohibt which links Build the same way as Logi...
Definition: MSBitSetLogic.h:63
bool myNetIsLoaded
whether the network has been loaded
MSJunction * retrieve(const std::string id)
try to retrieve junction by id
NLJunctionControlBuilder & operator=(const NLJunctionControlBuilder &s)
invalidated assignment operator
NLJunctionControlBuilder(MSNet &net, NLDetectorBuilder &db)
Constructor.
void addParam(const std::string &key, const std::string &value)
Adds a parameter.
int myRequestItemNumber
Counter for the inserted items.
bool myCurrentHasError
Information whether the current logic had an error.
MSBitsetLogic::Foes myActiveFoes
The description about which lanes disallow other passing the junction simultaneously.
MSTLLogicControl & getTLLogicControlToUse() const
Returns the used tls control.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
virtual MSJunction * buildNoLogicJunction()
Builds a junction that does not use a logic.
StringParameterMap myAdditionalParameter
Parameter map (key->value)
std::vector< std::string > LaneIdVector
SumoXMLNodeType myType
The type of the currently chosen junction.
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
void initJunctionLogic(const std::string &id)
Initialises a junction logic.
LaneVector myActiveIncomingLanes
The list of the incoming lanes of the currently chosen junction.
std::vector< std::bitset< N > > Logic
Container that holds the right of way bitsets. Each link has it&#39;s own bitset. The bits in the bitsets...
Definition: MSBitSetLogic.h:59
std::vector< MSTrafficLightLogic * > myLogics2PostLoadInit
The container for information which junctions shall be initialised using which values.
A storage for options typed value containers)
Definition: OptionsCont.h:99
MSTLLogicControl * myLogicControl
The tls control to use (0 if net&#39;s tls control shall be used)
#define SUMOReal
Definition: config.h:213
MSJunctionLogic * getJunctionLogicSecure()
Returns the current junction logic.
MSJunctionControl * build() const
Builds the MSJunctionControl which holds all of the simulations junctions.
MSTLLogicControl * buildTLLogics()
Returns the built tls-logic control.
const std::string & getActiveKey() const
Returns the active key.
std::vector< MSLane * > LaneVector
Definition of a lane vector.
TrafficLightType
void addLogicItem(int request, const std::string &response, const std::string &foes, bool cont)
Adds a logic item.