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 /****************************************************************************/
7 // Dumping a hugh List of Parameters available in the Simulation
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include <string>
32 #include <microsim/MSEdgeControl.h>
33 #include <microsim/MSEdge.h>
34 #include <microsim/MSLane.h>
35 #include <microsim/MSGlobals.h>
37 #include "MSFullExport.h"
38 #include <microsim/MSNet.h>
39 #include <microsim/MSVehicle.h>
41 
42 #ifdef HAVE_MESOSIM
43 #include <mesosim/MELoop.h>
44 #include <mesosim/MESegment.h>
45 #endif
46 
47 #ifdef CHECK_MEMORY_LEAKS
48 #include <foreign/nvwa/debug_new.h>
49 #endif // CHECK_MEMORY_LEAKS
50 
51 
52 // ===========================================================================
53 // method definitions
54 // ===========================================================================
55 void
57  of.openTag("data") << " timestep=\"" << time2string(timestep) << "\"";
58  //Vehicles
59  writeVehicles(of);
60  //Edges
61  writeEdge(of);
62  //TrafficLights
63  writeTLS(of, timestep);
64  of.closeTag();
65 }
66 
67 
68 void
70  of.openTag("vehicles");
74  for (; it != end; ++it) {
75  const MSVehicle* veh = static_cast<const MSVehicle*>((*it).second);
76  if (veh->isOnRoad()) {
77  std::string fclass = veh->getVehicleType().getID();
78  fclass = fclass.substr(0, fclass.find_first_of("@"));
80  of.openTag("vehicle").writeAttr("id", veh->getID()).writeAttr("eclass", toString(veh->getVehicleType().getEmissionClass()));
81  of.writeAttr("CO2", veh->getHBEFA_CO2Emissions()).writeAttr("CO", veh->getHBEFA_COEmissions()).writeAttr("HC", veh->getHBEFA_HCEmissions());
82  of.writeAttr("NOx", veh->getHBEFA_NOxEmissions()).writeAttr("PMx", veh->getHBEFA_PMxEmissions()).writeAttr("noise", veh->getHarmonoise_NoiseEmissions());
83  of.writeAttr("route", veh->getRoute().getID()).writeAttr("type", fclass).writeAttr("waiting", veh->getWaitingSeconds());
84  of.writeAttr("lane", veh->getLane()->getID()).writeAttr("pos_lane", veh->getPositionOnLane()).writeAttr("speed", veh->getSpeed());
85  of.writeAttr("angle", veh->getAngle()).writeAttr("x", pos.x()).writeAttr("y", pos.y());
86  of.closeTag();
87  }
88  }
89  of.closeTag();
90 }
91 
92 void
94  of.openTag("edges");
96  const std::vector<MSEdge*>& edges = ec.getEdges();
97  for (std::vector<MSEdge*>::const_iterator e = edges.begin(); e != edges.end(); ++e) {
98  MSEdge& edge = **e;
99  of.openTag("edge").writeAttr("id", edge.getID()).writeAttr("traveltime", edge.getCurrentTravelTime());
100  const std::vector<MSLane*>& lanes = edge.getLanes();
101  for (std::vector<MSLane*>::const_iterator lane = lanes.begin(); lane != lanes.end(); ++lane) {
102  writeLane(of, **lane);
103  }
104  of.closeTag();
105  }
106  of.closeTag();
107 }
108 
109 
110 void
112 
113  of.openTag("lane").writeAttr("id", lane.getID()).writeAttr("CO", lane.getHBEFA_COEmissions()).writeAttr("CO2", lane.getHBEFA_CO2Emissions());
114  of.writeAttr("NOx", lane.getHBEFA_NOxEmissions()).writeAttr("PMx", lane.getHBEFA_PMxEmissions()).writeAttr("HC", lane.getHBEFA_HCEmissions());
115  of.writeAttr("noise", lane.getHarmonoise_NoiseEmissions()).writeAttr("fuel", lane.getHBEFA_FuelConsumption()).writeAttr("maxspeed", lane.getSpeedLimit());
116  of.writeAttr("meanspeed", lane.getMeanSpeed() * 3.6).writeAttr("occupancy", lane.getNettoOccupancy()).writeAttr("vehicle_count", lane.getVehicleNumber());
117  of.closeTag();
118 }
119 
120 
121 void
123  of.openTag("tls");
125  std::vector<std::string> ids = vc.getAllTLIds();
126  for (std::vector<std::string>::const_iterator id_it = ids.begin(); id_it != ids.end(); ++id_it) {
129 
130  std::vector<std::string> laneIDs;
131  for (MSTrafficLightLogic::LaneVectorVector::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
132  const MSTrafficLightLogic::LaneVector& llanes = (*i);
133  for (MSTrafficLightLogic::LaneVector::const_iterator j = llanes.begin(); j != llanes.end(); ++j) {
134  laneIDs.push_back((*j)->getID());
135  }
136  }
137 
138  std::string lane_output = "";
139  for (unsigned int i1 = 0; i1 < laneIDs.size(); ++i1) {
140  lane_output += laneIDs[i1] + " ";
141  }
142 
143  std::string state = vars.getActive()->getCurrentPhaseDef().getState();
144  of.openTag("trafficlight").writeAttr("id", *id_it).writeAttr("state", state).closeTag();
145  }
146  of.closeTag();
147 }
148