SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSFullExport.cpp
Go to the documentation of this file.
1 /****************************************************************************/
6 // Dumping a hugh List of Parameters available in the Simulation
7 /****************************************************************************/
8 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
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 <string>
31 #include <microsim/MSEdgeControl.h>
32 #include <microsim/MSEdge.h>
33 #include <microsim/MSLane.h>
34 #include <microsim/MSGlobals.h>
36 #include "MSFullExport.h"
37 #include <microsim/MSNet.h>
38 #include <microsim/MSVehicle.h>
40 
41 #ifdef HAVE_MESOSIM
42 #include <mesosim/MELoop.h>
43 #include <mesosim/MESegment.h>
44 #endif
45 
46 #ifdef CHECK_MEMORY_LEAKS
47 #include <foreign/nvwa/debug_new.h>
48 #endif // CHECK_MEMORY_LEAKS
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
54 void
56 
57  of.openTag("data") << " timestep=\"" << time2string(timestep) << "\">\n";
58 
59  //Vehicles
60  writeVehicles(of);
61 
62  //Edges
63  writeEdge(of);
64 
65  //TrafficLights
66  writeTLS(of, timestep);
67 
68 
69  of.closeTag();
70 }
71 
72 void
74 
75  of.openTag("vehicles") << ">\n";
76 
77  const std::string indent(" ");
81 
82 
83  for (; it != end; ++it) {
84  const MSVehicle* veh = static_cast<const MSVehicle*>((*it).second);
85 
86  if (veh->isOnRoad()) {
87 
88  std::string fclass = veh->getVehicleType().getID();
89  fclass = fclass.substr(0, fclass.find_first_of("@"));
90 
92 
93  of.openTag("vehicle") << " id=\"" << veh->getID() << "\" eclass=\"" << veh->getVehicleType().getEmissionClass() << "\" co2=\"" << veh->getHBEFA_CO2Emissions()
94  << "\" co=\"" << veh->getHBEFA_COEmissions() << "\" hc=\"" << veh->getHBEFA_HCEmissions()
95  << "\" nox=\"" << veh->getHBEFA_NOxEmissions() << "\" pmx=\"" << veh->getHBEFA_PMxEmissions()
96  << "\" noise=\"" << veh->getHarmonoise_NoiseEmissions() << "\" route=\"" << veh->getRoute().getID()
97  << "\" type=\"" << fclass << "\" waiting=\"" << veh->getWaitingSeconds()
98  << "\" lane=\"" << veh->getLane()->getID()
99  << "\" pos_lane=\"" << veh->getPositionOnLane() << "\" speed=\"" << veh->getSpeed() * 3.6
100  << "\" angle=\"" << veh->getAngle() << "\" x=\"" << pos.x() << "\" y=\"" << pos.y() << "\"";
101 
102  of.closeTag();
103 
104  }
105 
106  }
107 
108  of.closeTag();
109 
110 
111 
112 }
113 
114 void
116 
117  of.openTag("edges") << ">\n";
118 
120 
121  const std::vector<MSEdge*>& edges = ec.getEdges();
122  for (std::vector<MSEdge*>::const_iterator e = edges.begin(); e != edges.end(); ++e) {
123 
124  MSEdge& edge = **e;
125 
126  of.openTag("edge") << " id=\"" << edge.getID() << "\" traveltime=\"" << edge.getCurrentTravelTime() << "\">\n";
127 
128  const std::vector<MSLane*>& lanes = edge.getLanes();
129  for (std::vector<MSLane*>::const_iterator lane = lanes.begin(); lane != lanes.end(); ++lane) {
130 
131  writeLane(of, **lane);
132 
133  }
134 
135  of.closeTag();
136 
137  }
138 
139  of.closeTag();
140 
141 }
142 
143 void
145 
146  of.openTag("lane")
147  << " id=\"" << lane.getID()
148  << "\" co=\"" << lane.getHBEFA_COEmissions()
149  << "\" co2=\"" << lane.getHBEFA_CO2Emissions()
150  << "\" nox=\"" << lane.getHBEFA_NOxEmissions()
151  << "\" pmx=\"" << lane.getHBEFA_PMxEmissions()
152  << "\" hc=\"" << lane.getHBEFA_HCEmissions()
153  << "\" noise=\"" << lane.getHarmonoise_NoiseEmissions()
154  << "\" fuel=\"" << lane.getHBEFA_FuelConsumption()
155  << "\" maxspeed=\"" << lane.getSpeedLimit() * 3.6
156  << "\" meanspeed=\"" << lane.getMeanSpeed() * 3.6
157  << "\" occupancy=\"" << lane.getOccupancy()
158  << "\" vehicle_count=\"" << lane.getVehicleNumber() << "\"";
159 
160  of.closeTag();
161 
162 }
163 
164 void
166  of.openTag("tls") << ">\n";
168  std::vector<std::string> ids = vc.getAllTLIds();
169  for (std::vector<std::string>::const_iterator id_it = ids.begin(); id_it != ids.end(); ++id_it) {
172 
173  std::vector<std::string> laneIDs;
174  for (MSTrafficLightLogic::LaneVectorVector::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
175  const MSTrafficLightLogic::LaneVector& llanes = (*i);
176  for (MSTrafficLightLogic::LaneVector::const_iterator j = llanes.begin(); j != llanes.end(); ++j) {
177  laneIDs.push_back((*j)->getID());
178  }
179  }
180 
181  std::string lane_output = "";
182  for (unsigned int i1 = 0; i1 < laneIDs.size(); ++i1) {
183  lane_output += laneIDs[i1] + " ";
184  }
185 
186  std::string state = vars.getActive()->getCurrentPhaseDef().getState();
187  of.openTag("trafficlight") << " id=\"" << *id_it << "\" state=\"" << state << "\"";
188  of.closeTag();
189 
190  }
191 
192  of.closeTag();
193 
194 }