SUMO - Simulation of Urban MObility
NLJunctionControlBuilder.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // Builder of microsim-junctions and tls
18 /****************************************************************************/
19 #ifndef NLJunctionControlBuilder_h
20 #define NLJunctionControlBuilder_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <string>
29 #include <vector>
30 #include <microsim/MSJunction.h>
33 #include <utils/geom/Position.h>
38 #include <microsim/MSBitSetLogic.h>
41 
42 
43 // ===========================================================================
44 // class declarations
45 // ===========================================================================
46 class OptionsCont;
47 class NLDetectorBuilder;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
64 private:
66  typedef std::vector<MSLane*> LaneVector;
67 
68 public:
77 
78 
84  virtual ~NLJunctionControlBuilder();
85 
86 
100  void openJunction(const std::string& id, const std::string& key,
101  const SumoXMLNodeType type,
102  const Position pos,
103  const PositionVector& shape,
104  const std::vector<MSLane*>& incomingLanes,
105  const std::vector<MSLane*>& internalLanes);
106 
107 
120  void closeJunction(const std::string& basePath);
121 
122 
130  MSJunctionControl* build() const;
131 
132 
136  void initJunctionLogic(const std::string& id);
137 
138 
150  void addLogicItem(int request, const std::string& response,
151  const std::string& foes, bool cont);
152 
153 
163  void initTrafficLightLogic(const std::string& id, const std::string& programID,
164  TrafficLightType type, SUMOTime offset);
165 
166 
176  void addPhase(SUMOTime duration, const std::string& state, int nextPhase,
177  SUMOTime min, SUMOTime max);
178 
188  void addPhase(SUMOTime duration, const std::string& state, int nextPhase, SUMOTime minDuration, SUMOTime maxDuration, bool transient_notdecisional, bool commit);
189 
190 
201  void addPhase(SUMOTime duration, const std::string& state, int nextPhase, SUMOTime minDuration, SUMOTime maxDuration, bool transient_notdecisional, bool commit, MSPhaseDefinition::LaneIdVector& targetLanes);
202 
203 
210  MSTLLogicControl::TLSLogicVariants& getTLLogic(const std::string& id)
211  const;
212 
213 
224 
225 
234  virtual void closeTrafficLightLogic(const std::string& basePath);
235 
236 
247  void closeJunctionLogic();
248 
249 
257  void addParam(const std::string& key, const std::string& value);
258 
259 
263  const std::string& getActiveKey() const;
264 
265 
269  const std::string& getActiveSubKey() const;
270 
271 
280 
282  void postLoadInitialization();
283 
285  MSJunction* retrieve(const std::string id);
286 
289  return (int)myActivePhases.size();
290  }
291 
292 
293 protected:
304 
305 
306 protected:
309 
316  virtual MSJunction* buildNoLogicJunction();
317 
318 
327  virtual MSJunction* buildLogicJunction();
328 
329 
338 
339 
340 protected:
343 
346 
349 
352 
355 
358 
360  std::bitset<SUMO_MAX_CONNECTIONS> myActiveConts;
361 
364 
367 
370 
373 
376 
379 
381  std::string myActiveID;
382 
385 
388 
391 
394 
397 
398 
400  std::vector<MSTrafficLightLogic*> myLogics2PostLoadInit;
401 
402 
405 
406 
408  typedef std::map<std::string, std::string> StringParameterMap;
409 
411  StringParameterMap myAdditionalParameter;
412 
413 
415  std::map<std::string, MSJunctionLogic*> myLogics;
416 
419 
420 
421 private:
424 
427 
428  static const int NO_REQUEST_SIZE;
429 
432 
433 };
434 
435 
436 #endif
437 
438 /****************************************************************************/
439 
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:36
std::bitset< SUMO_MAX_CONNECTIONS > myActiveConts
The description about which lanes have an internal follower.
Storage for all programs of a single tls.
LaneVector myActiveInternalLanes
The list of the internal lanes of the currently chosen junction.
void openJunction(const std::string &id, const std::string &key, const SumoXMLNodeType type, const Position pos, const PositionVector &shape, const std::vector< MSLane *> &incomingLanes, const std::vector< MSLane *> &internalLanes)
Begins the processing of the named junction.
std::string myActiveKey
The key of the currently chosen junction.
The base class for an intersection.
Definition: MSJunction.h:61
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)
virtual MSJunction * buildInternalJunction()
Builds an internal junction.
SUMOTime myAbsDuration
The absolute duration of a tls-control loop.
void addPhase(SUMOTime duration, const std::string &state, int nextPhase, SUMOTime min, SUMOTime max)
Adds a phase to the currently built traffic lights logic.
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:84
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.
MSSimpleTrafficLightLogic::Phases myActivePhases
The current phase definitions for a simple traffic light.
TrafficLightType myLogicType
The current logic type.
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:39
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.
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:56
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:52
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:92
MSTLLogicControl * myLogicControl
The tls control to use (0 if net&#39;s tls control shall be used)
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.