SUMO - Simulation of Urban MObility
NBRequest.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 /****************************************************************************/
18 // This class computes the logic of a junction
19 /****************************************************************************/
20 #ifndef NBRequest_h
21 #define NBRequest_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <string>
30 #include <vector>
31 #include <map>
32 #include <bitset>
33 #include "NBConnectionDefs.h"
34 #include "NBContHelper.h"
36 
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 class NBEdge;
42 class NBJunctionTypeIO;
44 class OptionsCont;
46 class NBEdgeCont;
47 class OutputDevice;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
59 class NBRequest {
60 public:
66  NBRequest(const NBEdgeCont& ec,
67  NBNode* junction,
68  const EdgeVector& all,
69  const EdgeVector& incoming,
70  const EdgeVector& outgoing,
71  const NBConnectionProhibits& loadedProhibits);
72 
74  ~NBRequest();
75 
77  void buildBitfieldLogic();
78 
80  std::pair<int, int> getSizes() const;
81 
89  bool mustBrake(const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo,
90  const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo) const;
91 
92 
100  bool mustBrake(const NBEdge* const from, const NBEdge* const to, int fromLane, int toLane, bool includePedCrossings) const;
101 
109  static bool mustBrakeForCrossing(const NBNode* node, const NBEdge* const from, const NBEdge* const to, const NBNode::Crossing& crossing);
110 
118  bool foes(const NBEdge* const from1, const NBEdge* const to1,
119  const NBEdge* const from2, const NBEdge* const to2) const;
120 
121 
130  bool forbids(const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo,
131  const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo,
132  bool regardNonSignalisedLowerPriority) const;
133 
135  void writeLogic(std::string key, OutputDevice& into, const bool checkLaneFoes) const;
136 
138  friend std::ostream& operator<<(std::ostream& os, const NBRequest& r);
139 
141  static void reportWarnings();
142 
144  bool mergeConflict(const NBEdge* from, const NBEdge::Connection& con,
145  const NBEdge* prohibitorFrom, const NBEdge::Connection& prohibitorCon, bool foes) const;
146 
148  bool oppositeLeftTurnConflict(const NBEdge* from, const NBEdge::Connection& con,
149  const NBEdge* prohibitorFrom, const NBEdge::Connection& prohibitorCon, bool foes) const;
150 
151 
152 private:
155  void setBlocking(NBEdge* from1, NBEdge* to1, NBEdge* from2, NBEdge* to2);
156 
159  int writeLaneResponse(OutputDevice& od, NBEdge* from, int lane,
160  int pos, const bool checkLaneFoes, bool padding) const;
161 
164  int writeCrossingResponse(OutputDevice& od, const NBNode::Crossing& crossing, int pos) const;
165 
185  std::string getResponseString(const NBEdge* const from, const NBEdge::Connection& c, const bool checkLaneFoes) const;
186 
187 
189  std::string getFoesString(NBEdge* from, NBEdge* to,
190  int fromLane, int toLane, const bool checkLaneFoes) const;
191 
192 
201  int getIndex(const NBEdge* const from, const NBEdge* const to) const;
202 
203 
205  int distanceCounterClockwise(NBEdge* from, NBEdge* to);
206 
209 
212 
213 
214  void resetSignalised();
215 
217  void resetCooperating();
218 
221  const NBEdge* prohibitorFrom, const NBEdge::Connection& prohibitorCon) const;
222 
226  bool laneConflict(const NBEdge* from, const NBEdge* to, int toLane, const NBEdge* prohibitorFrom, const NBEdge* prohibitorTo, int prohibitorToLane) const;
227 
228 
230  inline int numLinks() const;
231 
232 private:
235 
238 
241 
244 
246  typedef std::vector<bool> LinkInfoCont;
247 
249  typedef std::vector<LinkInfoCont> CombinationsCont;
250 
252  typedef std::map<NBEdge*, LaneVector> OccupiedLanes;
253 
255  CombinationsCont myForbids;
256 
258  CombinationsCont myDone;
259 
260 private:
262 
264  NBRequest& operator=(const NBRequest& s) = delete;
265 };
266 
267 #endif
268 
269 /****************************************************************************/
270 
std::pair< int, int > getSizes() const
returns the number of the junction&#39;s lanes and the number of the junction&#39;s links in respect...
Definition: NBRequest.cpp:433
void computeLeftOutgoingLinkCrossings(NBEdge *from, NBEdge *to)
computes the relationships between links outgoing left of the given link
Definition: NBRequest.cpp:181
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:160
std::vector< bool > LinkInfoCont
definition of a container to store boolean informations about a link into
Definition: NBRequest.h:246
static int myNotBuild
Definition: NBRequest.h:261
bool mergeConflict(const NBEdge *from, const NBEdge::Connection &con, const NBEdge *prohibitorFrom, const NBEdge::Connection &prohibitorCon, bool foes) const
whether multple connections from the same edge target the same lane
Definition: NBRequest.cpp:683
NBRequest(const NBEdgeCont &ec, NBNode *junction, const EdgeVector &all, const EdgeVector &incoming, const EdgeVector &outgoing, const NBConnectionProhibits &loadedProhibits)
Definition: NBRequest.cpp:58
A SUMO-compliant built logic for a traffic light.
The representation of a single edge during network building.
Definition: NBEdge.h:65
NBNode * myJunction
the node the request is assigned to
Definition: NBRequest.h:234
The base class for traffic light logic definitions.
std::string getResponseString(const NBEdge *const from, const NBEdge::Connection &c, const bool checkLaneFoes) const
Writes the response of a certain link.
Definition: NBRequest.cpp:562
static int myGoodBuilds
Definition: NBRequest.h:261
std::vector< LinkInfoCont > CombinationsCont
definition of a container for link(edge->edge) X link(edge->edge) combinations (size = |myIncoming|*|...
Definition: NBRequest.h:249
void buildBitfieldLogic()
builds the bitset-representation of the logic
Definition: NBRequest.cpp:147
const EdgeVector & myOutgoing
edges outgoing from the junction
Definition: NBRequest.h:243
void setBlocking(NBEdge *from1, NBEdge *to1, NBEdge *from2, NBEdge *to2)
Definition: NBRequest.cpp:199
bool checkLaneFoesByClass(const NBEdge::Connection &con, const NBEdge *prohibitorFrom, const NBEdge::Connection &prohibitorCon) const
whether the given connections must be check for lane conflicts due to the vClasses involved ...
Definition: NBRequest.cpp:761
int writeLaneResponse(OutputDevice &od, NBEdge *from, int lane, int pos, const bool checkLaneFoes, bool padding) const
writes the response of a certain lane Returns the next link index within the junction ...
Definition: NBRequest.cpp:503
const EdgeVector & myIncoming
edges incoming to the junction
Definition: NBRequest.h:240
int numLinks() const
return to total number of edge-to-edge connections of this request-logic
Definition: NBRequest.cpp:953
CombinationsCont myDone
the link X link is done-checks
Definition: NBRequest.h:258
int getIndex(const NBEdge *const from, const NBEdge *const to) const
Returns the index to the internal combination container for the given edge combination.
Definition: NBRequest.cpp:795
bool mustBrake(const NBEdge *const possProhibitorFrom, const NBEdge *const possProhibitorTo, const NBEdge *const possProhibitedFrom, const NBEdge *const possProhibitedTo) const
Returns the information whether "prohibited" flow must let "prohibitor" flow pass.
Definition: NBRequest.cpp:902
static void reportWarnings()
reports warnings if any occurred
Definition: NBRequest.cpp:912
static bool mustBrakeForCrossing(const NBNode *node, const NBEdge *const from, const NBEdge *const to, const NBNode::Crossing &crossing)
Returns the information whether the described flow must brake for the given crossing.
Definition: NBRequest.cpp:886
~NBRequest()
destructor
Definition: NBRequest.cpp:143
bool forbids(const NBEdge *const possProhibitorFrom, const NBEdge *const possProhibitorTo, const NBEdge *const possProhibitedFrom, const NBEdge *const possProhibitedTo, bool regardNonSignalisedLowerPriority) const
Returns the information whether "prohibited" flow must let "prohibitor" flow pass.
Definition: NBRequest.cpp:471
void computeRightOutgoingLinkCrossings(NBEdge *from, NBEdge *to)
computes the relationships between links outgoing right of the given link */
Definition: NBRequest.cpp:163
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:61
int writeCrossingResponse(OutputDevice &od, const NBNode::Crossing &crossing, int pos) const
writes the response of a certain crossing Returns the next link index within the junction ...
Definition: NBRequest.cpp:526
bool foes(const NBEdge *const from1, const NBEdge *const to1, const NBEdge *const from2, const NBEdge *const to2) const
Returns the information whether the given flows cross.
Definition: NBRequest.cpp:452
const EdgeVector & myAll
all (icoming and outgoing) of the junctions edges
Definition: NBRequest.h:237
bool oppositeLeftTurnConflict(const NBEdge *from, const NBEdge::Connection &con, const NBEdge *prohibitorFrom, const NBEdge::Connection &prohibitorCon, bool foes) const
whether opposite left turns intersect
Definition: NBRequest.cpp:726
bool laneConflict(const NBEdge *from, const NBEdge *to, int toLane, const NBEdge *prohibitorFrom, const NBEdge *prohibitorTo, int prohibitorToLane) const
return whether the given laneToLane connections prohibit each other under the assumption that the edg...
Definition: NBRequest.cpp:774
NBRequest & operator=(const NBRequest &s)=delete
Invalidated assignment operator.
std::map< NBEdge *, LaneVector > OccupiedLanes
a container for approached lanes of a certain edge
Definition: NBRequest.h:252
std::map< NBConnection, NBConnectionVector > NBConnectionProhibits
Definition of a container for connection block dependencies Includes a list of all connections which ...
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:34
void writeLogic(std::string key, OutputDevice &into, const bool checkLaneFoes) const
writes the XML-representation of the logic as a bitset-logic XML representation
Definition: NBRequest.cpp:353
A storage for options typed value containers)
Definition: OptionsCont.h:92
friend std::ostream & operator<<(std::ostream &os, const NBRequest &r)
prints the request
Definition: NBRequest.cpp:807
std::string getFoesString(NBEdge *from, NBEdge *to, int fromLane, int toLane, const bool checkLaneFoes) const
Definition: NBRequest.cpp:635
Represents a single node (junction) during network building.
Definition: NBNode.h:68
A definition of a pedestrian crossing.
Definition: NBNode.h:125
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
int distanceCounterClockwise(NBEdge *from, NBEdge *to)
returns the distance between the incoming (from) and the outgoing (to) edge clockwise in edges ...
Definition: NBRequest.cpp:338
void resetCooperating()
reset foes it the number of lanes matches (or exceeds) the number of incoming connections for an edge...
Definition: NBRequest.cpp:921
CombinationsCont myForbids
the link X link blockings
Definition: NBRequest.h:255
void resetSignalised()
Definition: NBRequest.cpp:373