SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
MSDevice_Emissions.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// A device which collects vehicular emissions
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12
// Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
13
/****************************************************************************/
14
//
15
// This file is part of SUMO.
16
// SUMO is free software: you can redistribute it and/or modify
17
// it under the terms of the GNU General Public License as published by
18
// the Free Software Foundation, either version 3 of the License, or
19
// (at your option) any later version.
20
//
21
/****************************************************************************/
22
23
// ===========================================================================
24
// included modules
25
// ===========================================================================
26
#ifdef _MSC_VER
27
#include <
windows_config.h
>
28
#else
29
#include <
config.h
>
30
#endif
31
32
#include "
MSDevice_Emissions.h
"
33
#include <
microsim/MSNet.h
>
34
#include <
microsim/MSLane.h
>
35
#include <
microsim/MSVehicleControl.h
>
36
#include <
utils/options/OptionsCont.h
>
37
#include <
utils/emissions/PollutantsInterface.h
>
38
#include <
utils/iodevices/OutputDevice.h
>
39
40
#ifdef CHECK_MEMORY_LEAKS
41
#include <
foreign/nvwa/debug_new.h
>
42
#endif // CHECK_MEMORY_LEAKS
43
44
45
// ===========================================================================
46
// method definitions
47
// ===========================================================================
48
// ---------------------------------------------------------------------------
49
// static initialisation methods
50
// ---------------------------------------------------------------------------
51
void
52
MSDevice_Emissions::insertOptions
() {
53
insertDefaultAssignmentOptions
(
"emissions"
,
"Emissions"
,
OptionsCont::getOptions
());
54
}
55
56
57
void
58
MSDevice_Emissions::buildVehicleDevices
(
SUMOVehicle
& v, std::vector<MSDevice*>& into) {
59
if
(
equippedByDefaultAssignmentOptions
(
OptionsCont::getOptions
(),
"emissions"
, v)) {
60
// build the device
61
MSDevice_Emissions
* device =
new
MSDevice_Emissions
(v,
"emissions_"
+ v.
getID
());
62
into.push_back(device);
63
}
64
}
65
66
67
// ---------------------------------------------------------------------------
68
// MSDevice_Emissions-methods
69
// ---------------------------------------------------------------------------
70
MSDevice_Emissions::MSDevice_Emissions
(
SUMOVehicle
& holder,
const
std::string&
id
)
71
:
MSDevice
(holder, id), myEmissions() {
72
}
73
74
75
MSDevice_Emissions::~MSDevice_Emissions
() {
76
}
77
78
79
bool
80
MSDevice_Emissions::notifyMove
(
SUMOVehicle
& veh,
SUMOReal
/*oldPos*/
,
SUMOReal
/*newPos*/
,
SUMOReal
newSpeed) {
81
const
SUMOEmissionClass
c = veh.
getVehicleType
().
getEmissionClass
();
82
const
SUMOReal
a = veh.
getAcceleration
();
83
const
SUMOReal
slope = veh.
getSlope
();
84
myEmissions
.
addScaled
(
PollutantsInterface::computeAll
(c, newSpeed, a, slope),
TS
);
85
return
true
;
86
}
87
88
89
void
90
MSDevice_Emissions::generateOutput
()
const
{
91
if
(
OptionsCont::getOptions
().isSet(
"tripinfo-output"
)) {
92
OutputDevice
& os =
OutputDevice::getDeviceByOption
(
"tripinfo-output"
);
93
(os.
openTag
(
"emissions"
) <<
94
" CO_abs=\""
<<
OutputDevice::realString
(
myEmissions
.
CO
, 6) <<
95
"\" CO2_abs=\""
<<
OutputDevice::realString
(
myEmissions
.
CO2
, 6) <<
96
"\" HC_abs=\""
<<
OutputDevice::realString
(
myEmissions
.
HC
, 6) <<
97
"\" PMx_abs=\""
<<
OutputDevice::realString
(
myEmissions
.
PMx
, 6) <<
98
"\" NOx_abs=\""
<<
OutputDevice::realString
(
myEmissions
.
NOx
, 6) <<
99
"\" fuel_abs=\""
<<
OutputDevice::realString
(
myEmissions
.
fuel
, 6) <<
100
"\""
).closeTag();
101
}
102
}
103
104
105
106
/****************************************************************************/
107
tmp
buildd
sumo-0.21.0+dfsg
src
microsim
devices
MSDevice_Emissions.cpp
Generated on Thu Nov 20 2014 19:49:55 for SUMO - Simulation of Urban MObility by
1.8.1.2