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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // Builder of microsim-junctions and tls
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <string>
26 #include <vector>
27 #include <microsim/MSJunction.h>
30 #include <utils/geom/Position.h>
35 #include <microsim/MSBitSetLogic.h>
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class OptionsCont;
44 class NLDetectorBuilder;
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
61 private:
63  typedef std::vector<MSLane*> LaneVector;
64 
65 public:
74 
75 
81  virtual ~NLJunctionControlBuilder();
82 
83 
97  void openJunction(const std::string& id, const std::string& key,
98  const SumoXMLNodeType type,
99  const Position pos,
100  const PositionVector& shape,
101  const std::vector<MSLane*>& incomingLanes,
102  const std::vector<MSLane*>& internalLanes,
103  const std::string& name);
104 
105 
118  void closeJunction(const std::string& basePath);
119 
120 
128  MSJunctionControl* build() const;
129 
130 
134  void initJunctionLogic(const std::string& id);
135 
136 
148  void addLogicItem(int request, const std::string& response,
149  const std::string& foes, bool cont);
150 
151 
161  void initTrafficLightLogic(const std::string& id, const std::string& programID,
162  TrafficLightType type, SUMOTime offset);
163 
164 
169  void addPhase(MSPhaseDefinition* phase);
170 
176  bool addCondition(const std::string& id, const std::string& value);
177 
184  MSTLLogicControl::TLSLogicVariants& getTLLogic(const std::string& id)
185  const;
186 
187 
198 
199 
208  virtual void closeTrafficLightLogic(const std::string& basePath);
209 
210 
221  void closeJunctionLogic();
222 
223 
231  void addParam(const std::string& key, const std::string& value);
232 
233 
237  const std::string& getActiveKey() const;
238 
239 
243  const std::string& getActiveSubKey() const;
244 
245 
254 
256  void postLoadInitialization();
257 
259  MSJunction* retrieve(const std::string id);
260 
263  return (int)myActivePhases.size();
264  }
265 
266 
267 protected:
278 
279 
280 protected:
283 
290  virtual MSJunction* buildNoLogicJunction();
291 
292 
301  virtual MSJunction* buildLogicJunction();
302 
303 
312 
313 
314 protected:
317 
320 
323 
326 
329 
332 
334  std::bitset<SUMO_MAX_CONNECTIONS> myActiveConts;
335 
338 
340  std::map<std::string, std::string> myActiveConditions;
341 
344 
347 
350 
353 
356 
358  std::string myActiveID;
359 
362 
365 
368 
371 
374 
376  std::string myActiveName;
377 
379  std::vector<MSTrafficLightLogic*> myLogics2PostLoadInit;
380 
381 
384 
385 
387  typedef std::map<std::string, std::string> StringParameterMap;
388 
391 
392 
394  std::map<std::string, MSJunctionLogic*> myLogics;
395 
398 
399 
400 private:
403 
406 
407  static const int NO_REQUEST_SIZE;
408 
411 
412 };
long long int SUMOTime
Definition: SUMOTime.h:32
TrafficLightType
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
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:53
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:49
Container for junctions; performs operations on all stored junctions.
The base class for an intersection.
Definition: MSJunction.h:58
The simulated network and simulation perfomer.
Definition: MSNet.h:88
The definition of a single phase of a tls logic.
Storage for all programs of a single tls.
A class that stores and controls tls and switching of their programs.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Builds detectors for microsim.
Builder of microsim-junctions and tls.
PositionVector myShape
The shape of the current junction.
NLJunctionControlBuilder(MSNet &net, NLDetectorBuilder &db)
Constructor.
void closeJunctionLogic()
Ends the building of a junction logic (row-logic)
int myRequestItemNumber
Counter for the inserted items.
SumoXMLNodeType myType
The type of the currently chosen junction.
MSTLLogicControl::TLSLogicVariants & getTLLogic(const std::string &id) const
Returns a previously build tls logic.
std::string myActiveName
the name of the current junction
virtual ~NLJunctionControlBuilder()
Destructor.
MSJunction * retrieve(const std::string id)
try to retrieve junction by id
MSBitsetLogic::Foes myActiveFoes
The description about which lanes disallow other passing the junction simultaneously.
std::string myActiveID
The id of the currently chosen junction.
SUMOTime myOffset
The switch offset within the tls.
MSTLLogicControl * myLogicControl
The tls control to use (0 if net's tls control shall be used)
int getNumberOfLoadedPhases() const
return the number of phases loaded so far (for error reporting)
std::string myActiveKey
The key of the currently chosen junction.
TrafficLightType myLogicType
The current logic type.
bool myCurrentHasError
Information whether the current logic had an error.
MSTLLogicControl * buildTLLogics()
Returns the built tls-logic control.
MSJunctionControl * build() const
Builds the MSJunctionControl which holds all of the simulations junctions.
int myRequestSize
The size of the request.
void addPhase(MSPhaseDefinition *phase)
Adds a phase to the currently built traffic lights logic.
MSTLLogicControl & getTLLogicControlToUse() const
Returns the used tls control.
LaneVector myActiveIncomingLanes
The list of the incoming lanes of the currently chosen junction.
std::map< std::string, MSJunctionLogic * > myLogics
Map of loaded junction logics.
const std::string & getActiveSubKey() const
Returns the active sub key.
bool addCondition(const std::string &id, const std::string &value)
Adds a condition to the currently built traffic lights logic.
StringParameterMap myAdditionalParameter
Parameter map (key->value)
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, const std::string &name)
Begins the processing of the named junction.
void addParam(const std::string &key, const std::string &value)
Adds a parameter.
LaneVector myActiveInternalLanes
The list of the internal lanes of the currently chosen junction.
void initJunctionLogic(const std::string &id)
Initialises a junction logic.
void initTrafficLightLogic(const std::string &id, const std::string &programID, TrafficLightType type, SUMOTime offset)
Begins the reading of a traffic lights logic.
NLJunctionControlBuilder & operator=(const NLJunctionControlBuilder &s)
invalidated assignment operator
virtual MSJunction * buildLogicJunction()
Builds a junction with a logic.
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
virtual MSJunction * buildNoLogicJunction()
Builds a junction that does not use a logic.
virtual MSJunction * buildInternalJunction()
Builds an internal junction.
MSJunctionControl * myJunctions
The junctions controls.
const std::string & getActiveKey() const
Returns the active key.
Position myPosition
The position of the junction.
NLJunctionControlBuilder(const NLJunctionControlBuilder &s)
invalidated copy operator
MSJunctionLogic * getJunctionLogicSecure()
Returns the current junction logic.
void postLoadInitialization()
initialize junctions after all connections have been loaded
std::map< std::string, std::string > myActiveConditions
The current switching conditions for an actuated traffic light.
void addLogicItem(int request, const std::string &response, const std::string &foes, bool cont)
Adds a logic item.
std::vector< MSTrafficLightLogic * > myLogics2PostLoadInit
The container for information which junctions shall be initialised using which values.
MSBitsetLogic::Logic myActiveLogic
The right-of-way-logic of the currently chosen bitset-logic.
std::map< std::string, std::string > StringParameterMap
Definition of a parameter map (key->value)
SUMOTime myAbsDuration
The absolute duration of a tls-control loop.
void closeJunction(const std::string &basePath)
Closes (ends) the processing of the current junction.
MSSimpleTrafficLightLogic::Phases myActivePhases
The current phase definitions for a simple traffic light.
bool myNetIsLoaded
whether the network has been loaded
virtual void closeTrafficLightLogic(const std::string &basePath)
Ends the building of a traffic lights logic.
std::vector< MSLane * > LaneVector
Definition of a lane vector.
std::bitset< SUMO_MAX_CONNECTIONS > myActiveConts
The description about which lanes have an internal follower.
A storage for options typed value containers)
Definition: OptionsCont.h:89
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.