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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // This class computes the logic of a junction
21 /****************************************************************************/
22 #ifndef NBRequest_h
23 #define NBRequest_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <vector>
37 #include <map>
38 #include <bitset>
39 #include "NBConnectionDefs.h"
40 #include "NBContHelper.h"
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class NBEdge;
48 class NBJunctionTypeIO;
50 class OptionsCont;
52 class NBEdgeCont;
53 class OutputDevice;
54 
55 
56 // ===========================================================================
57 // class definitions
58 // ===========================================================================
65 class NBRequest {
66 public:
72  NBRequest(const NBEdgeCont& ec,
73  NBNode* junction,
74  const EdgeVector& all,
75  const EdgeVector& incoming,
76  const EdgeVector& outgoing,
77  const NBConnectionProhibits& loadedProhibits);
78 
80  ~NBRequest();
81 
83  void buildBitfieldLogic();
84 
87  std::pair<int, int> getSizes() const;
88 
96  bool mustBrake(const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo,
97  const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo) const;
98 
99 
107  bool mustBrake(const NBEdge* const from, const NBEdge* const to, int fromLane, int toLane, bool includePedCrossings) const;
108 
116  static bool mustBrakeForCrossing(const NBNode* node, const NBEdge* const from, const NBEdge* const to, const NBNode::Crossing& crossing);
117 
125  bool foes(const NBEdge* const from1, const NBEdge* const to1,
126  const NBEdge* const from2, const NBEdge* const to2) const;
127 
128 
137  bool forbids(const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo,
138  const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo,
139  bool regardNonSignalisedLowerPriority) const;
140 
143  void writeLogic(std::string key, OutputDevice& into, const bool checkLaneFoes) const;
144 
146  friend std::ostream& operator<<(std::ostream& os, const NBRequest& r);
147 
149  static void reportWarnings();
150 
152  static bool mergeConflict(const NBEdge* from, const NBEdge::Connection& con,
153  const NBEdge* prohibitorFrom, const NBEdge::Connection& prohibitorCon, bool foes);
154 
155 
156 private:
159  void setBlocking(NBEdge* from1, NBEdge* to1, NBEdge* from2, NBEdge* to2);
160 
163  int writeLaneResponse(OutputDevice& od, NBEdge* from, int lane,
164  int pos, const bool checkLaneFoes) const;
165 
168  int writeCrossingResponse(OutputDevice& od, const NBNode::Crossing& crossing, int pos) const;
169 
189  std::string getResponseString(int tlIndex, const NBEdge* const from, const NBEdge* const to,
190  int fromLane, int toLane, bool mayDefinitelyPass, const bool checkLaneFoes) const;
191 
192 
194  std::string getFoesString(NBEdge* from, NBEdge* to,
195  int fromLane, int toLane, const bool checkLaneFoes) const;
196 
197 
206  int getIndex(const NBEdge* const from, const NBEdge* const to) const;
207 
208 
211  int distanceCounterClockwise(NBEdge* from, NBEdge* to);
212 
216 
220 
221 
222  void resetSignalised();
223 
224 
226  void resetCooperating();
227 
231  bool laneConflict(const NBEdge* from, const NBEdge* to, int toLane, const NBEdge* prohibitorFrom, const NBEdge* prohibitorTo, int prohibitorToLane) const;
232 
234  inline int numLinks() const;
235 
236 
237 private:
240 
243 
246 
249 
251  std::vector<NBNode::Crossing*> myCrossings;
252 
255  typedef std::vector<bool> LinkInfoCont;
256 
259  typedef std::vector<LinkInfoCont> CombinationsCont;
260 
262  typedef std::map<NBEdge*, LaneVector> OccupiedLanes;
263 
265  CombinationsCont myForbids;
266 
268  CombinationsCont myDone;
269 
270 private:
272 
273 private:
275  NBRequest& operator=(const NBRequest& s);
276 };
277 
278 #endif
279 
280 /****************************************************************************/
281 
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:398
void computeLeftOutgoingLinkCrossings(NBEdge *from, NBEdge *to)
Definition: NBRequest.cpp:185
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:161
std::vector< bool > LinkInfoCont
Definition: NBRequest.h:255
static int myNotBuild
Definition: NBRequest.h:271
NBRequest(const NBEdgeCont &ec, NBNode *junction, const EdgeVector &all, const EdgeVector &incoming, const EdgeVector &outgoing, const NBConnectionProhibits &loadedProhibits)
Definition: NBRequest.cpp:61
A SUMO-compliant built logic for a traffic light.
The representation of a single edge during network building.
Definition: NBEdge.h:70
NBNode * myJunction
the node the request is assigned to
Definition: NBRequest.h:239
The base class for traffic light logic definitions.
static int myGoodBuilds
Definition: NBRequest.h:271
std::vector< LinkInfoCont > CombinationsCont
Definition: NBRequest.h:259
void buildBitfieldLogic()
Definition: NBRequest.cpp:151
const EdgeVector & myOutgoing
Definition: NBRequest.h:248
static bool mergeConflict(const NBEdge *from, const NBEdge::Connection &con, const NBEdge *prohibitorFrom, const NBEdge::Connection &prohibitorCon, bool foes)
whether multple connections from the same edge target the same lane
Definition: NBRequest.cpp:619
void setBlocking(NBEdge *from1, NBEdge *to1, NBEdge *from2, NBEdge *to2)
Definition: NBRequest.cpp:203
NBRequest & operator=(const NBRequest &s)
Invalidated assignment operator.
const EdgeVector & myIncoming
Definition: NBRequest.h:245
int numLinks() const
return to total number of edge-to-edge connections of this request-logic
Definition: NBRequest.cpp:814
CombinationsCont myDone
Definition: NBRequest.h:268
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:657
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:763
static void reportWarnings()
reports warnings if any occured
Definition: NBRequest.cpp:773
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:747
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:436
std::vector< NBNode::Crossing * > myCrossings
Definition: NBRequest.h:251
void computeRightOutgoingLinkCrossings(NBEdge *from, NBEdge *to)
Definition: NBRequest.cpp:167
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
std::string getResponseString(int tlIndex, const NBEdge *const from, const NBEdge *const to, int fromLane, int toLane, bool mayDefinitelyPass, const bool checkLaneFoes) const
Writes the response of a certain link.
Definition: NBRequest.cpp:526
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:490
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:417
const EdgeVector & myAll
Definition: NBRequest.h:242
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:635
std::map< NBEdge *, LaneVector > OccupiedLanes
Definition: NBRequest.h:262
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:40
void writeLogic(std::string key, OutputDevice &into, const bool checkLaneFoes) const
Definition: NBRequest.cpp:320
A storage for options typed value containers)
Definition: OptionsCont.h:98
friend std::ostream & operator<<(std::ostream &os, const NBRequest &r)
prints the request
Definition: NBRequest.cpp:669
int writeLaneResponse(OutputDevice &od, NBEdge *from, int lane, int pos, const bool checkLaneFoes) const
writes the response of a certain lane Returns the next link index within the junction ...
Definition: NBRequest.cpp:468
std::string getFoesString(NBEdge *from, NBEdge *to, int fromLane, int toLane, const bool checkLaneFoes) const
Definition: NBRequest.cpp:577
Represents a single node (junction) during network building.
Definition: NBNode.h:74
A definition of a pedestrian crossing.
Definition: NBNode.h:131
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
int distanceCounterClockwise(NBEdge *from, NBEdge *to)
Definition: NBRequest.cpp:305
void resetCooperating()
reset foes it the number of lanes matches (or exceeds) the number of incoming connections for an edge...
Definition: NBRequest.cpp:782
CombinationsCont myForbids
Definition: NBRequest.h:265
void resetSignalised()
Definition: NBRequest.cpp:338