Eclipse 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-2019 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 /****************************************************************************/
16 // Builder of microsim-junctions and tls
17 /****************************************************************************/
18 #ifndef NLJunctionControlBuilder_h
19 #define NLJunctionControlBuilder_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <string>
28 #include <vector>
29 #include <microsim/MSJunction.h>
32 #include <utils/geom/Position.h>
37 #include <microsim/MSBitSetLogic.h>
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class OptionsCont;
46 class NLDetectorBuilder;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
63 private:
65  typedef std::vector<MSLane*> LaneVector;
66 
67 public:
76 
77 
83  virtual ~NLJunctionControlBuilder();
84 
85 
99  void openJunction(const std::string& id, const std::string& key,
100  const SumoXMLNodeType type,
101  const Position pos,
102  const PositionVector& shape,
103  const std::vector<MSLane*>& incomingLanes,
104  const std::vector<MSLane*>& internalLanes);
105 
106 
119  void closeJunction(const std::string& basePath);
120 
121 
129  MSJunctionControl* build() const;
130 
131 
135  void initJunctionLogic(const std::string& id);
136 
137 
149  void addLogicItem(int request, const std::string& response,
150  const std::string& foes, bool cont);
151 
152 
162  void initTrafficLightLogic(const std::string& id, const std::string& programID,
163  TrafficLightType type, SUMOTime offset);
164 
165 
175  void addPhase(SUMOTime duration, const std::string& state, const std::vector<int>& nextPhases,
176  SUMOTime min, SUMOTime max, const std::string& name);
177 
188  void addPhase(SUMOTime duration, const std::string& state, const std::vector<int>& nextPhases, SUMOTime minDuration, SUMOTime maxDuration, const std::string& name, bool transient_notdecisional, bool commit, MSPhaseDefinition::LaneIdVector* targetLanes = nullptr);
189 
190 
197  MSTLLogicControl::TLSLogicVariants& getTLLogic(const std::string& id)
198  const;
199 
200 
211 
212 
221  virtual void closeTrafficLightLogic(const std::string& basePath);
222 
223 
234  void closeJunctionLogic();
235 
236 
244  void addParam(const std::string& key, const std::string& value);
245 
246 
250  const std::string& getActiveKey() const;
251 
252 
256  const std::string& getActiveSubKey() const;
257 
258 
267 
269  void postLoadInitialization();
270 
272  MSJunction* retrieve(const std::string id);
273 
276  return (int)myActivePhases.size();
277  }
278 
279 
280 protected:
291 
292 
293 protected:
296 
303  virtual MSJunction* buildNoLogicJunction();
304 
305 
314  virtual MSJunction* buildLogicJunction();
315 
316 
325 
326 
327 protected:
330 
333 
336 
339 
342 
345 
347  std::bitset<SUMO_MAX_CONNECTIONS> myActiveConts;
348 
351 
354 
357 
360 
363 
366 
368  std::string myActiveID;
369 
372 
375 
378 
381 
384 
385 
387  std::vector<MSTrafficLightLogic*> myLogics2PostLoadInit;
388 
389 
392 
393 
395  typedef std::map<std::string, std::string> StringParameterMap;
396 
399 
400 
402  std::map<std::string, MSJunctionLogic*> myLogics;
403 
406 
407 
408 private:
411 
414 
415  static const int NO_REQUEST_SIZE;
416 
419 
420 };
421 
422 
423 #endif
424 
425 /****************************************************************************/
426 
NLJunctionControlBuilder::~NLJunctionControlBuilder
virtual ~NLJunctionControlBuilder()
Destructor.
Definition: NLJunctionControlBuilder.cpp:80
NLJunctionControlBuilder::initTrafficLightLogic
void initTrafficLightLogic(const std::string &id, const std::string &programID, TrafficLightType type, SUMOTime offset)
Begins the reading of a traffic lights logic.
Definition: NLJunctionControlBuilder.cpp:388
MSRightOfWayJunction.h
NLJunctionControlBuilder::myDetectorBuilder
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
Definition: NLJunctionControlBuilder.h:332
NLJunctionControlBuilder::myActiveConts
std::bitset< SUMO_MAX_CONNECTIONS > myActiveConts
The description about which lanes have an internal follower.
Definition: NLJunctionControlBuilder.h:347
NLJunctionControlBuilder::postLoadInitialization
void postLoadInitialization()
initialize junctions after all connections have been loaded
Definition: NLJunctionControlBuilder.cpp:485
MSTLLogicControl.h
MSJunction
The base class for an intersection.
Definition: MSJunction.h:60
NLJunctionControlBuilder::myActiveInternalLanes
LaneVector myActiveInternalLanes
The list of the internal lanes of the currently chosen junction.
Definition: NLJunctionControlBuilder.h:365
NLJunctionControlBuilder::myActiveLogic
MSBitsetLogic::Logic myActiveLogic
The right-of-way-logic of the currently chosen bitset-logic.
Definition: NLJunctionControlBuilder.h:341
MSTrafficLightLogic::Phases
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Definition: MSTrafficLightLogic.h:61
NLJunctionControlBuilder::myActiveKey
std::string myActiveKey
The key of the currently chosen junction.
Definition: NLJunctionControlBuilder.h:371
MSNet
The simulated network and simulation perfomer.
Definition: MSNet.h:91
NLJunctionControlBuilder::myActiveProgram
std::string myActiveProgram
Definition: NLJunctionControlBuilder.h:371
MSBitSetLogic.h
NLJunctionControlBuilder::closeJunctionLogic
void closeJunctionLogic()
Ends the building of a junction logic (row-logic)
Definition: NLJunctionControlBuilder.cpp:421
NLJunctionControlBuilder::NO_REQUEST_SIZE
static const int NO_REQUEST_SIZE
Definition: NLJunctionControlBuilder.h:415
MSActuatedTrafficLightLogic.h
NLJunctionControlBuilder::buildInternalJunction
virtual MSJunction * buildInternalJunction()
Builds an internal junction.
Definition: NLJunctionControlBuilder.cpp:180
MSBitSetLogic::Foes
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:55
TrafficLightType
TrafficLightType
Definition: SUMOXMLDefinitions.h:1197
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
NLJunctionControlBuilder::myAbsDuration
SUMOTime myAbsDuration
The absolute duration of a tls-control loop.
Definition: NLJunctionControlBuilder.h:380
NLJunctionControlBuilder::myNet
MSNet & myNet
The net to use.
Definition: NLJunctionControlBuilder.h:329
MSJunctionControl.h
MSPhaseDefinition::LaneIdVector
std::vector< std::string > LaneIdVector
Definition: MSPhaseDefinition.h:66
PositionVector
A list of positions.
Definition: PositionVector.h:45
NLJunctionControlBuilder::getActiveSubKey
const std::string & getActiveSubKey() const
Returns the active sub key.
Definition: NLJunctionControlBuilder.cpp:479
MSSimpleTrafficLightLogic.h
NLJunctionControlBuilder::myShape
PositionVector myShape
The shape of the current junction.
Definition: NLJunctionControlBuilder.h:383
NLJunctionControlBuilder::closeJunction
void closeJunction(const std::string &basePath)
Closes (ends) the processing of the current junction.
Definition: NLJunctionControlBuilder.cpp:106
NLJunctionControlBuilder::myPosition
Position myPosition
The position of the junction.
Definition: NLJunctionControlBuilder.h:377
NLJunctionControlBuilder
Builder of microsim-junctions and tls.
Definition: NLJunctionControlBuilder.h:62
NLJunctionControlBuilder::myOffset
SUMOTime myOffset
The switch offset within the tls.
Definition: NLJunctionControlBuilder.h:335
MSJunctionControl
Container for junctions; performs operations on all stored junctions.
Definition: MSJunctionControl.h:44
NLJunctionControlBuilder::getNumberOfLoadedPhases
int getNumberOfLoadedPhases() const
return the number of phases loaded so far (for error reporting)
Definition: NLJunctionControlBuilder.h:275
NLJunctionControlBuilder::getTLLogic
MSTLLogicControl::TLSLogicVariants & getTLLogic(const std::string &id) const
Returns a previously build tls logic.
Definition: NLJunctionControlBuilder.cpp:198
MSJunctionLogic
Definition: MSJunctionLogic.h:38
NLJunctionControlBuilder::myJunctions
MSJunctionControl * myJunctions
The junctions controls.
Definition: NLJunctionControlBuilder.h:359
NLJunctionControlBuilder::myActiveID
std::string myActiveID
The id of the currently chosen junction.
Definition: NLJunctionControlBuilder.h:368
MSJunction.h
NLJunctionControlBuilder::myActivePhases
MSSimpleTrafficLightLogic::Phases myActivePhases
The current phase definitions for a simple traffic light.
Definition: NLJunctionControlBuilder.h:350
MSBitSetLogic::Logic
std::vector< std::bitset< N > > Logic
Container that holds the right of way bitsets. Each link has it's own bitset. The bits in the bitsets...
Definition: MSBitSetLogic.h:51
NLJunctionControlBuilder::buildLogicJunction
virtual MSJunction * buildLogicJunction()
Builds a junction with a logic.
Definition: NLJunctionControlBuilder.cpp:170
NLJunctionControlBuilder::myLogicType
TrafficLightType myLogicType
The current logic type.
Definition: NLJunctionControlBuilder.h:338
NLJunctionControlBuilder::closeTrafficLightLogic
virtual void closeTrafficLightLogic(const std::string &basePath)
Ends the building of a traffic lights logic.
Definition: NLJunctionControlBuilder.cpp:204
SumoXMLNodeType
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
Definition: SUMOXMLDefinitions.h:1054
NLJunctionControlBuilder::openJunction
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.
Definition: NLJunctionControlBuilder.cpp:87
NLJunctionControlBuilder::myLogics
std::map< std::string, MSJunctionLogic * > myLogics
Map of loaded junction logics.
Definition: NLJunctionControlBuilder.h:402
NLJunctionControlBuilder::operator=
NLJunctionControlBuilder & operator=(const NLJunctionControlBuilder &s)
invalidated assignment operator
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
NLJunctionControlBuilder::myRequestSize
int myRequestSize
The size of the request.
Definition: NLJunctionControlBuilder.h:353
NLJunctionControlBuilder::retrieve
MSJunction * retrieve(const std::string id)
try to retrieve junction by id
Definition: NLJunctionControlBuilder.cpp:494
NLJunctionControlBuilder::myNetIsLoaded
bool myNetIsLoaded
whether the network has been loaded
Definition: NLJunctionControlBuilder.h:418
UtilExceptions.h
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
NLJunctionControlBuilder::addParam
void addParam(const std::string &key, const std::string &value)
Adds a parameter.
Definition: NLJunctionControlBuilder.cpp:457
NLJunctionControlBuilder::myRequestItemNumber
int myRequestItemNumber
Counter for the inserted items.
Definition: NLJunctionControlBuilder.h:356
NLJunctionControlBuilder::NLJunctionControlBuilder
NLJunctionControlBuilder(MSNet &net, NLDetectorBuilder &db)
Constructor.
Definition: NLJunctionControlBuilder.cpp:69
NLJunctionControlBuilder::getTLLogicControlToUse
MSTLLogicControl & getTLLogicControlToUse() const
Returns the used tls control.
Definition: NLJunctionControlBuilder.cpp:464
NLJunctionControlBuilder::myCurrentHasError
bool myCurrentHasError
Information whether the current logic had an error.
Definition: NLJunctionControlBuilder.h:405
NLJunctionControlBuilder::myActiveFoes
MSBitsetLogic::Foes myActiveFoes
The description about which lanes disallow other passing the junction simultaneously.
Definition: NLJunctionControlBuilder.h:344
Position.h
NLJunctionControlBuilder::buildNoLogicJunction
virtual MSJunction * buildNoLogicJunction()
Builds a junction that does not use a logic.
Definition: NLJunctionControlBuilder.cpp:163
NLJunctionControlBuilder::myType
SumoXMLNodeType myType
The type of the currently chosen junction.
Definition: NLJunctionControlBuilder.h:374
NLJunctionControlBuilder::myAdditionalParameter
StringParameterMap myAdditionalParameter
Parameter map (key->value)
Definition: NLJunctionControlBuilder.h:398
NLJunctionControlBuilder::myActiveIncomingLanes
LaneVector myActiveIncomingLanes
The list of the incoming lanes of the currently chosen junction.
Definition: NLJunctionControlBuilder.h:362
NLJunctionControlBuilder::addPhase
void addPhase(SUMOTime duration, const std::string &state, const std::vector< int > &nextPhases, SUMOTime min, SUMOTime max, const std::string &name)
Adds a phase to the currently built traffic lights logic.
Definition: NLJunctionControlBuilder.cpp:411
NLJunctionControlBuilder::myLogicControl
MSTLLogicControl * myLogicControl
The tls control to use (0 if net's tls control shall be used)
Definition: NLJunctionControlBuilder.h:391
NLJunctionControlBuilder::initJunctionLogic
void initJunctionLogic(const std::string &id)
Initialises a junction logic.
Definition: NLJunctionControlBuilder.cpp:333
MSTLLogicControl::TLSLogicVariants
Storage for all programs of a single tls.
Definition: MSTLLogicControl.h:85
NLJunctionControlBuilder::myLogics2PostLoadInit
std::vector< MSTrafficLightLogic * > myLogics2PostLoadInit
The container for information which junctions shall be initialised using which values.
Definition: NLJunctionControlBuilder.h:387
config.h
MSTLLogicControl
A class that stores and controls tls and switching of their programs.
Definition: MSTLLogicControl.h:59
NLJunctionControlBuilder::getJunctionLogicSecure
MSJunctionLogic * getJunctionLogicSecure()
Returns the current junction logic.
Definition: NLJunctionControlBuilder.cpp:188
NLJunctionControlBuilder::build
MSJunctionControl * build() const
Builds the MSJunctionControl which holds all of the simulations junctions.
Definition: NLJunctionControlBuilder.cpp:155
NLJunctionControlBuilder::buildTLLogics
MSTLLogicControl * buildTLLogics()
Returns the built tls-logic control.
Definition: NLJunctionControlBuilder.cpp:445
NLJunctionControlBuilder::LaneVector
std::vector< MSLane * > LaneVector
Definition of a lane vector.
Definition: NLJunctionControlBuilder.h:65
PositionVector.h
NLDetectorBuilder
Builds detectors for microsim.
Definition: NLDetectorBuilder.h:55
NLJunctionControlBuilder::getActiveKey
const std::string & getActiveKey() const
Returns the active key.
Definition: NLJunctionControlBuilder.cpp:473
NLJunctionControlBuilder::addLogicItem
void addLogicItem(int request, const std::string &response, const std::string &foes, bool cont)
Adds a logic item.
Definition: NLJunctionControlBuilder.cpp:346
NLJunctionControlBuilder::StringParameterMap
std::map< std::string, std::string > StringParameterMap
Definition of a parameter map (key->value)
Definition: NLJunctionControlBuilder.h:395
MSRailSignal.h