SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSQueueExport.cpp
Go to the documentation of this file.
1 /****************************************************************************/
6 // Export the queueing length in front of a junction (very experimental!)
7 /****************************************************************************/
8 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
9 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
10 /****************************************************************************/
11 //
12 // This file is part of SUMO.
13 // SUMO is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
30 #include <microsim/MSEdgeControl.h>
31 #include <microsim/MSEdge.h>
32 #include <microsim/MSLane.h>
33 #include <microsim/MSGlobals.h>
35 #include "MSQueueExport.h"
36 #include <microsim/MSNet.h>
37 #include <microsim/MSVehicle.h>
38 
39 #ifdef HAVE_MESOSIM
40 #include <mesosim/MELoop.h>
41 #include <mesosim/MESegment.h>
42 #endif
43 
44 #ifdef CHECK_MEMORY_LEAKS
45 #include <foreign/nvwa/debug_new.h>
46 #endif // CHECK_MEMORY_LEAKS
47 
48 
49 // ===========================================================================
50 // method definitions
51 // ===========================================================================
52 void
54  of.openTag("data").writeAttr("timestep", time2string(timestep));
55  writeEdge(of);
56  of.closeTag();
57 }
58 
59 
60 void
62  of.openTag("lanes");
64  const std::vector<MSEdge*>& edges = ec.getEdges();
65  for (std::vector<MSEdge*>::const_iterator e = edges.begin(); e != edges.end(); ++e) {
66  MSEdge& edge = **e;
67  const std::vector<MSLane*>& lanes = edge.getLanes();
68  for (std::vector<MSLane*>::const_iterator lane = lanes.begin(); lane != lanes.end(); ++lane) {
69  writeLane(of, **lane);
70  }
71  }
72  of.closeTag();
73 }
74 
75 
76 void
78  //Fahrzeug mit der höchsten Wartezeit
79  //Fahrzeug am Ende des Rückstaus
80  double queueing_time = 0.0;
81  double queueing_length = 0.0;
82  double queueing_length2 = 0.0;
83 
84  if (lane.getVehicleNumber() != 0) {
85  for (std::vector<MSVehicle*>::const_iterator veh = lane.myVehBuffer.begin(); veh != lane.myVehBuffer.end(); ++veh) {
86  const MSVehicle& veh_tmp = **veh;
87  if (!veh_tmp.isOnRoad()) {
88  continue;
89  }
90  if (veh_tmp.getWaitingSeconds() > 0) {
91  if (veh_tmp.getWaitingSeconds() > queueing_time) {
92  queueing_time = veh_tmp.getWaitingSeconds();
93  }
94  double tmp_length = (lane.getLength() - veh_tmp.getPositionOnLane()) + veh_tmp.getVehicleType().getLengthWithGap();
95  if (tmp_length > queueing_length) {
96  queueing_length = tmp_length;
97  }
98  }
99  }
100 
101  for (MSLane::VehCont::const_iterator veh = lane.myVehicles.begin(); veh != lane.myVehicles.end(); ++veh) {
102  const MSVehicle& veh_tmp = **veh;
103  if (!veh_tmp.isOnRoad()) {
104  continue;
105  }
106 
107  if (veh_tmp.getWaitingSeconds() > 0) {
108  if (veh_tmp.getWaitingSeconds() > queueing_time) {
109  queueing_time = veh_tmp.getWaitingSeconds();
110  }
111  double tmp_length = (lane.getLength() - veh_tmp.getPositionOnLane()) + veh_tmp.getVehicleType().getLengthWithGap();
112  if (tmp_length > queueing_length) {
113  queueing_length = tmp_length;
114  }
115  }
116  }
117 
118 
119  //Experimental
120  double tmp_length2 = 0.0;
121  for (MSLane::VehCont::const_iterator veh = lane.myVehicles.begin(); veh != lane.myVehicles.end(); ++veh) {
122  //wenn Fahrzeug langsamer als 5 km/h fährt = Rückstau
123  double threshold_velocity = 5 / 3.6;
124  const MSVehicle& veh_tmp = **veh;
125  if (!veh_tmp.isOnRoad()) {
126  continue;
127  }
128 
129  if (veh_tmp.getSpeed() < (threshold_velocity) && (veh_tmp.getPositionOnLane() > (veh_tmp.getLane()->getLength()) * 0.25)) {
130  tmp_length2 = (lane.getLength() - veh_tmp.getPositionOnLane()) + veh_tmp.getVehicleType().getLengthWithGap();
131  }
132  if (tmp_length2 > queueing_length2) {
133  queueing_length2 = tmp_length2;
134  }
135  }
136  }
137 
138  //Output
139  if (queueing_length > 1 || queueing_length2 > 1) {
140  of.openTag("lane").writeAttr("id", lane.getID()).writeAttr("queueing_time", queueing_time).writeAttr("queueing_length", queueing_length);
141  of.writeAttr("queueing_length_experimental", queueing_length2).closeTag();
142  }
143 }
144 
145 
146 /****************************************************************************/