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 /****************************************************************************/
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, const std::vector<int>& nextPhases,
177  SUMOTime min, SUMOTime max, const std::string& name);
178 
189  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);
190 
191 
198  MSTLLogicControl::TLSLogicVariants& getTLLogic(const std::string& id)
199  const;
200 
201 
212 
213 
222  virtual void closeTrafficLightLogic(const std::string& basePath);
223 
224 
235  void closeJunctionLogic();
236 
237 
245  void addParam(const std::string& key, const std::string& value);
246 
247 
251  const std::string& getActiveKey() const;
252 
253 
257  const std::string& getActiveSubKey() const;
258 
259 
268 
270  void postLoadInitialization();
271 
273  MSJunction* retrieve(const std::string id);
274 
277  return (int)myActivePhases.size();
278  }
279 
280 
281 protected:
292 
293 
294 protected:
297 
304  virtual MSJunction* buildNoLogicJunction();
305 
306 
315  virtual MSJunction* buildLogicJunction();
316 
317 
326 
327 
328 protected:
331 
334 
337 
340 
343 
346 
348  std::bitset<SUMO_MAX_CONNECTIONS> myActiveConts;
349 
352 
355 
358 
361 
364 
367 
369  std::string myActiveID;
370 
373 
376 
379 
382 
385 
386 
388  std::vector<MSTrafficLightLogic*> myLogics2PostLoadInit;
389 
390 
393 
394 
396  typedef std::map<std::string, std::string> StringParameterMap;
397 
400 
401 
403  std::map<std::string, MSJunctionLogic*> myLogics;
404 
407 
408 
409 private:
412 
415 
416  static const int NO_REQUEST_SIZE;
417 
420 
421 };
422 
423 
424 #endif
425 
426 /****************************************************************************/
427 
NLJunctionControlBuilder::~NLJunctionControlBuilder
virtual ~NLJunctionControlBuilder()
Destructor.
Definition: NLJunctionControlBuilder.cpp:83
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:391
MSRightOfWayJunction.h
NLJunctionControlBuilder::myDetectorBuilder
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
Definition: NLJunctionControlBuilder.h:333
NLJunctionControlBuilder::myActiveConts
std::bitset< SUMO_MAX_CONNECTIONS > myActiveConts
The description about which lanes have an internal follower.
Definition: NLJunctionControlBuilder.h:348
NLJunctionControlBuilder::postLoadInitialization
void postLoadInitialization()
initialize junctions after all connections have been loaded
Definition: NLJunctionControlBuilder.cpp:488
MSTLLogicControl.h
MSJunction
The base class for an intersection.
Definition: MSJunction.h:61
NLJunctionControlBuilder::myActiveInternalLanes
LaneVector myActiveInternalLanes
The list of the internal lanes of the currently chosen junction.
Definition: NLJunctionControlBuilder.h:366
NLJunctionControlBuilder::myActiveLogic
MSBitsetLogic::Logic myActiveLogic
The right-of-way-logic of the currently chosen bitset-logic.
Definition: NLJunctionControlBuilder.h:342
MSTrafficLightLogic::Phases
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Definition: MSTrafficLightLogic.h:62
NLJunctionControlBuilder::myActiveKey
std::string myActiveKey
The key of the currently chosen junction.
Definition: NLJunctionControlBuilder.h:372
MSNet
The simulated network and simulation perfomer.
Definition: MSNet.h:92
NLJunctionControlBuilder::myActiveProgram
std::string myActiveProgram
Definition: NLJunctionControlBuilder.h:372
MSBitSetLogic.h
NLJunctionControlBuilder::closeJunctionLogic
void closeJunctionLogic()
Ends the building of a junction logic (row-logic)
Definition: NLJunctionControlBuilder.cpp:424
NLJunctionControlBuilder::NO_REQUEST_SIZE
static const int NO_REQUEST_SIZE
Definition: NLJunctionControlBuilder.h:416
MSActuatedTrafficLightLogic.h
NLJunctionControlBuilder::buildInternalJunction
virtual MSJunction * buildInternalJunction()
Builds an internal junction.
Definition: NLJunctionControlBuilder.cpp:183
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:56
TrafficLightType
TrafficLightType
Definition: SUMOXMLDefinitions.h:1192
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
NLJunctionControlBuilder::myAbsDuration
SUMOTime myAbsDuration
The absolute duration of a tls-control loop.
Definition: NLJunctionControlBuilder.h:381
NLJunctionControlBuilder::myNet
MSNet & myNet
The net to use.
Definition: NLJunctionControlBuilder.h:330
MSJunctionControl.h
MSPhaseDefinition::LaneIdVector
std::vector< std::string > LaneIdVector
Definition: MSPhaseDefinition.h:67
PositionVector
A list of positions.
Definition: PositionVector.h:46
NLJunctionControlBuilder::getActiveSubKey
const std::string & getActiveSubKey() const
Returns the active sub key.
Definition: NLJunctionControlBuilder.cpp:482
MSSimpleTrafficLightLogic.h
NLJunctionControlBuilder::myShape
PositionVector myShape
The shape of the current junction.
Definition: NLJunctionControlBuilder.h:384
NLJunctionControlBuilder::closeJunction
void closeJunction(const std::string &basePath)
Closes (ends) the processing of the current junction.
Definition: NLJunctionControlBuilder.cpp:109
NLJunctionControlBuilder::myPosition
Position myPosition
The position of the junction.
Definition: NLJunctionControlBuilder.h:378
NLJunctionControlBuilder
Builder of microsim-junctions and tls.
Definition: NLJunctionControlBuilder.h:63
NLJunctionControlBuilder::myOffset
SUMOTime myOffset
The switch offset within the tls.
Definition: NLJunctionControlBuilder.h:336
MSJunctionControl
Container for junctions; performs operations on all stored junctions.
Definition: MSJunctionControl.h:45
NLJunctionControlBuilder::getNumberOfLoadedPhases
int getNumberOfLoadedPhases() const
return the number of phases loaded so far (for error reporting)
Definition: NLJunctionControlBuilder.h:276
NLJunctionControlBuilder::getTLLogic
MSTLLogicControl::TLSLogicVariants & getTLLogic(const std::string &id) const
Returns a previously build tls logic.
Definition: NLJunctionControlBuilder.cpp:201
MSJunctionLogic
Definition: MSJunctionLogic.h:39
NLJunctionControlBuilder::myJunctions
MSJunctionControl * myJunctions
The junctions controls.
Definition: NLJunctionControlBuilder.h:360
NLJunctionControlBuilder::myActiveID
std::string myActiveID
The id of the currently chosen junction.
Definition: NLJunctionControlBuilder.h:369
MSJunction.h
NLJunctionControlBuilder::myActivePhases
MSSimpleTrafficLightLogic::Phases myActivePhases
The current phase definitions for a simple traffic light.
Definition: NLJunctionControlBuilder.h:351
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:52
NLJunctionControlBuilder::buildLogicJunction
virtual MSJunction * buildLogicJunction()
Builds a junction with a logic.
Definition: NLJunctionControlBuilder.cpp:173
NLJunctionControlBuilder::myLogicType
TrafficLightType myLogicType
The current logic type.
Definition: NLJunctionControlBuilder.h:339
NLJunctionControlBuilder::closeTrafficLightLogic
virtual void closeTrafficLightLogic(const std::string &basePath)
Ends the building of a traffic lights logic.
Definition: NLJunctionControlBuilder.cpp:207
SumoXMLNodeType
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
Definition: SUMOXMLDefinitions.h:1049
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:90
NLJunctionControlBuilder::myLogics
std::map< std::string, MSJunctionLogic * > myLogics
Map of loaded junction logics.
Definition: NLJunctionControlBuilder.h:403
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:39
NLJunctionControlBuilder::myRequestSize
int myRequestSize
The size of the request.
Definition: NLJunctionControlBuilder.h:354
NLJunctionControlBuilder::retrieve
MSJunction * retrieve(const std::string id)
try to retrieve junction by id
Definition: NLJunctionControlBuilder.cpp:497
NLJunctionControlBuilder::myNetIsLoaded
bool myNetIsLoaded
whether the network has been loaded
Definition: NLJunctionControlBuilder.h:419
UtilExceptions.h
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:90
NLJunctionControlBuilder::addParam
void addParam(const std::string &key, const std::string &value)
Adds a parameter.
Definition: NLJunctionControlBuilder.cpp:460
NLJunctionControlBuilder::myRequestItemNumber
int myRequestItemNumber
Counter for the inserted items.
Definition: NLJunctionControlBuilder.h:357
NLJunctionControlBuilder::NLJunctionControlBuilder
NLJunctionControlBuilder(MSNet &net, NLDetectorBuilder &db)
Constructor.
Definition: NLJunctionControlBuilder.cpp:72
NLJunctionControlBuilder::getTLLogicControlToUse
MSTLLogicControl & getTLLogicControlToUse() const
Returns the used tls control.
Definition: NLJunctionControlBuilder.cpp:467
NLJunctionControlBuilder::myCurrentHasError
bool myCurrentHasError
Information whether the current logic had an error.
Definition: NLJunctionControlBuilder.h:406
NLJunctionControlBuilder::myActiveFoes
MSBitsetLogic::Foes myActiveFoes
The description about which lanes disallow other passing the junction simultaneously.
Definition: NLJunctionControlBuilder.h:345
Position.h
NLJunctionControlBuilder::buildNoLogicJunction
virtual MSJunction * buildNoLogicJunction()
Builds a junction that does not use a logic.
Definition: NLJunctionControlBuilder.cpp:166
NLJunctionControlBuilder::myType
SumoXMLNodeType myType
The type of the currently chosen junction.
Definition: NLJunctionControlBuilder.h:375
NLJunctionControlBuilder::myAdditionalParameter
StringParameterMap myAdditionalParameter
Parameter map (key->value)
Definition: NLJunctionControlBuilder.h:399
NLJunctionControlBuilder::myActiveIncomingLanes
LaneVector myActiveIncomingLanes
The list of the incoming lanes of the currently chosen junction.
Definition: NLJunctionControlBuilder.h:363
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:414
NLJunctionControlBuilder::myLogicControl
MSTLLogicControl * myLogicControl
The tls control to use (0 if net's tls control shall be used)
Definition: NLJunctionControlBuilder.h:392
NLJunctionControlBuilder::initJunctionLogic
void initJunctionLogic(const std::string &id)
Initialises a junction logic.
Definition: NLJunctionControlBuilder.cpp:336
MSTLLogicControl::TLSLogicVariants
Storage for all programs of a single tls.
Definition: MSTLLogicControl.h:86
NLJunctionControlBuilder::myLogics2PostLoadInit
std::vector< MSTrafficLightLogic * > myLogics2PostLoadInit
The container for information which junctions shall be initialised using which values.
Definition: NLJunctionControlBuilder.h:388
config.h
MSTLLogicControl
A class that stores and controls tls and switching of their programs.
Definition: MSTLLogicControl.h:60
NLJunctionControlBuilder::getJunctionLogicSecure
MSJunctionLogic * getJunctionLogicSecure()
Returns the current junction logic.
Definition: NLJunctionControlBuilder.cpp:191
NLJunctionControlBuilder::build
MSJunctionControl * build() const
Builds the MSJunctionControl which holds all of the simulations junctions.
Definition: NLJunctionControlBuilder.cpp:158
NLJunctionControlBuilder::buildTLLogics
MSTLLogicControl * buildTLLogics()
Returns the built tls-logic control.
Definition: NLJunctionControlBuilder.cpp:448
NLJunctionControlBuilder::LaneVector
std::vector< MSLane * > LaneVector
Definition of a lane vector.
Definition: NLJunctionControlBuilder.h:66
PositionVector.h
NLDetectorBuilder
Builds detectors for microsim.
Definition: NLDetectorBuilder.h:56
NLJunctionControlBuilder::getActiveKey
const std::string & getActiveKey() const
Returns the active key.
Definition: NLJunctionControlBuilder.cpp:476
NLJunctionControlBuilder::addLogicItem
void addLogicItem(int request, const std::string &response, const std::string &foes, bool cont)
Adds a logic item.
Definition: NLJunctionControlBuilder.cpp:349
NLJunctionControlBuilder::StringParameterMap
std::map< std::string, std::string > StringParameterMap
Definition of a parameter map (key->value)
Definition: NLJunctionControlBuilder.h:396
MSRailSignal.h