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_HBEFA.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// A device which collects vehicular emissions (using HBEFA-reformulation)
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12
// Copyright (C) 2001-2013 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_HBEFA.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/common/HelpersHBEFA.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_HBEFA::insertOptions
(
OptionsCont
& oc) {
53
insertDefaultAssignmentOptions
(
"hbefa"
,
"Emissions"
, oc);
54
}
55
56
57
void
58
MSDevice_HBEFA::buildVehicleDevices
(
SUMOVehicle
& v, std::vector<MSDevice*>& into) {
59
OptionsCont
& oc =
OptionsCont::getOptions
();
60
// route computation is enabled
61
if
(
equippedByDefaultAssignmentOptions
(oc,
"hbefa"
, v)) {
62
// build the device
63
MSDevice_HBEFA
* device =
new
MSDevice_HBEFA
(v,
"hbefa_"
+ v.
getID
());
64
into.push_back(device);
65
}
66
}
67
68
69
// ---------------------------------------------------------------------------
70
// MSDevice_HBEFA-methods
71
// ---------------------------------------------------------------------------
72
MSDevice_HBEFA::MSDevice_HBEFA
(
SUMOVehicle
& holder,
const
std::string&
id
)
73
:
MSDevice
(holder, id),
74
myCO2(0), myCO(0), myHC(0), myPMx(0), myNOx(0), myFuel(0) {
75
}
76
77
78
MSDevice_HBEFA::~MSDevice_HBEFA
() {
79
}
80
81
82
bool
83
MSDevice_HBEFA::notifyMove
(
SUMOVehicle
& veh,
SUMOReal
/*oldPos*/
,
SUMOReal
/*newPos*/
,
SUMOReal
newSpeed) {
84
const
SUMOEmissionClass
c = veh.
getVehicleType
().
getEmissionClass
();
85
const
SUMOReal
a = veh.
getAcceleration
();
86
myCO2
+=
TS
*
HelpersHBEFA::computeCO2
(c, newSpeed, a);
87
myCO
+=
TS
*
HelpersHBEFA::computeCO
(c, newSpeed, a);
88
myHC
+=
TS
*
HelpersHBEFA::computeHC
(c, newSpeed, a);
89
myPMx
+=
TS
*
HelpersHBEFA::computePMx
(c, newSpeed, a);
90
myNOx
+=
TS
*
HelpersHBEFA::computeNOx
(c, newSpeed, a);
91
myFuel
+=
TS
*
HelpersHBEFA::computeFuel
(c, newSpeed, a);
92
return
true
;
93
}
94
95
96
void
97
MSDevice_HBEFA::generateOutput
()
const
{
98
if
(
OptionsCont::getOptions
().isSet(
"tripinfo-output"
)) {
99
OutputDevice
& os =
OutputDevice::getDeviceByOption
(
"tripinfo-output"
);
100
(os.
openTag
(
"emissions"
) <<
101
" CO_abs=\""
<<
OutputDevice::realString
(
myCO
, 6) <<
102
"\" CO2_abs=\""
<<
OutputDevice::realString
(
myCO2
, 6) <<
103
"\" HC_abs=\""
<<
OutputDevice::realString
(
myHC
, 6) <<
104
"\" PMx_abs=\""
<<
OutputDevice::realString
(
myPMx
, 6) <<
105
"\" NOx_abs=\""
<<
OutputDevice::realString
(
myNOx
, 6) <<
106
"\" fuel_abs=\""
<<
OutputDevice::realString
(
myFuel
, 6) <<
107
"\""
).closeTag();
108
}
109
}
110
111
112
113
/****************************************************************************/
114
build
buildd
sumo-0.18~dfsg
src
microsim
devices
MSDevice_HBEFA.cpp
Generated on Wed Oct 23 2013 01:15:09 for SUMO - Simulation of Urban MObility by
1.8.4