SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSEmissionExport.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // Realises dumping Emission Data
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 <microsim/MSEdgeControl.h>
32 #include <microsim/MSEdge.h>
33 #include <microsim/MSLane.h>
34 #include <microsim/MSGlobals.h>
36 #include "MSEmissionExport.h"
37 #include <microsim/MSNet.h>
38 #include <microsim/MSVehicle.h>
39 
40 #ifdef HAVE_MESOSIM
41 #include <mesosim/MELoop.h>
42 #include <mesosim/MESegment.h>
43 #endif
44 
45 #ifdef CHECK_MEMORY_LEAKS
46 #include <foreign/nvwa/debug_new.h>
47 #endif // CHECK_MEMORY_LEAKS
48 
49 
50 // ===========================================================================
51 // method definitions
52 // ===========================================================================
53 void
55 
56  of.openTag("timestep").writeAttr("time", time2string(timestep));
57 
61  for (; it != end; ++it) {
62  const MSVehicle* veh = static_cast<const MSVehicle*>((*it).second);
63  if (!veh->isOnRoad()) {
64  continue;
65  }
66 
67  std::string fclass = veh->getVehicleType().getID();
68  fclass = fclass.substr(0, fclass.find_first_of("@"));
69 
71  of.openTag("vehicle").writeAttr("id", veh->getID()).writeAttr("eclass", veh->getVehicleType().getEmissionClass()).writeAttr("CO2", veh->getHBEFA_CO2Emissions());
72  of.writeAttr("CO", veh->getHBEFA_COEmissions()).writeAttr("HC", veh->getHBEFA_HCEmissions()).writeAttr("NOx", veh->getHBEFA_NOxEmissions());
73  of.writeAttr("PMx", veh->getHBEFA_PMxEmissions()).writeAttr("fuel", veh->getHBEFA_FuelConsumption()).writeAttr("noise", veh->getHarmonoise_NoiseEmissions());
74  of.writeAttr("route", veh->getRoute().getID()).writeAttr("type", fclass).writeAttr("waiting", veh->getWaitingSeconds());
75  of.writeAttr("lane", veh->getLane()->getID()).writeAttr("pos", veh->getPositionOnLane()).writeAttr("speed", veh->getSpeed());
76  of.writeAttr("angle", veh->getAngle()).writeAttr("x", pos.x()).writeAttr("y", pos.y());
77  of.closeTag();
78  }
79  of.closeTag();
80 }