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
PollutantsInterface.cpp
Go to the documentation of this file.
1
/****************************************************************************/
8
// Interface to capsulate different emission models
9
/****************************************************************************/
10
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
11
// Copyright (C) 2013-2014 DLR (http://www.dlr.de/) and contributors
12
/****************************************************************************/
13
//
14
// This file is part of SUMO.
15
// SUMO is free software: you can redistribute it and/or modify
16
// it under the terms of the GNU General Public License as published by
17
// the Free Software Foundation, either version 3 of the License, or
18
// (at your option) any later version.
19
//
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 <limits>
33
#include <cmath>
34
#include <
utils/common/SUMOVehicleClass.h
>
35
#include "
PollutantsInterface.h
"
36
#include "
HelpersHBEFA.h
"
37
#include "
HelpersHBEFA3.h
"
38
#include "
HelpersPHEMlight.h
"
39
40
#ifdef CHECK_MEMORY_LEAKS
41
#include <
foreign/nvwa/debug_new.h
>
42
#endif // CHECK_MEMORY_LEAKS
43
44
45
// ===========================================================================
46
// static definitions
47
// ===========================================================================
48
HelpersHBEFA
PollutantsInterface::myHBEFA2Helper
;
49
HelpersHBEFA3
PollutantsInterface::myHBEFA3Helper
;
50
HelpersPHEMlight
PollutantsInterface::myPHEMlightHelper
;
51
PollutantsInterface::Helper
*
PollutantsInterface::myHelpers
[] = {&
PollutantsInterface::myHBEFA2Helper
, &
PollutantsInterface::myHBEFA3Helper
, &PollutantsInterface::myPHEMlightHelper};
52
53
54
// ===========================================================================
55
// method definitions
56
// ===========================================================================
57
SUMOEmissionClass
58
PollutantsInterface::getClassByName
(
const
std::string& eClass,
const
SUMOVehicleClass
vc) {
59
size_t
sep = eClass.find(
"/"
);
60
if
(sep != std::string::npos) {
61
const
std::string model = eClass.substr(0, sep);
62
const
std::string subClass = eClass.substr(sep + 1);
63
for
(
int
i = 0; i < 3; i++) {
64
if
(
myHelpers
[i]->
getName
() == model) {
65
return
myHelpers
[i]->
getClassByName
(subClass, vc);
66
}
67
}
68
}
else
{
69
// default HBEFA2
70
return
myHelpers
[0]->
getClassByName
(eClass, vc);
71
}
72
throw
InvalidArgument
(
"Unknown emission class '"
+ eClass +
"'."
);
73
}
74
75
76
const
std::vector<SUMOEmissionClass>
77
PollutantsInterface::getAllClasses
() {
78
std::vector<SUMOEmissionClass> result;
79
for
(
int
i = 0; i < 3; i++) {
80
myHelpers
[i]->
addAllClassesInto
(result);
81
}
82
return
result;
83
}
84
85
86
std::string
87
PollutantsInterface::getName
(
const
SUMOEmissionClass
c) {
88
return
myHelpers
[c >> 16]->
getClassName
(c);
89
}
90
91
92
bool
93
PollutantsInterface::isHeavy
(
const
SUMOEmissionClass
c) {
94
return
(c &
HEAVY_BIT
) != 0;
95
}
96
97
98
bool
99
PollutantsInterface::isSilent
(
const
SUMOEmissionClass
c) {
100
return
myHelpers
[c >> 16]->
isSilent
(c);
101
}
102
103
104
SUMOReal
105
PollutantsInterface::getMaxAccel
(
SUMOEmissionClass
c,
double
v,
double
a,
double
slope) {
106
return
myHelpers
[c >> 16]->
getMaxAccel
(c, v, a, slope);
107
}
108
109
110
SUMOEmissionClass
111
PollutantsInterface::getClass
(
const
SUMOEmissionClass
base,
const
std::string& vClass,
112
const
std::string& fuel,
const
std::string& eClass,
const
double
weight) {
113
return
myHelpers
[base >> 16]->
getClass
(base, vClass, fuel, eClass, weight);
114
}
115
116
117
std::string
118
PollutantsInterface::getAmitranVehicleClass
(
const
SUMOEmissionClass
c) {
119
return
myHelpers
[c >> 16]->
getAmitranVehicleClass
(c);
120
}
121
122
123
std::string
124
PollutantsInterface::getFuel
(
const
SUMOEmissionClass
c) {
125
return
myHelpers
[c >> 16]->
getFuel
(c);
126
}
127
128
129
int
130
PollutantsInterface::getEuroClass
(
const
SUMOEmissionClass
c) {
131
return
myHelpers
[c >> 16]->
getEuroClass
(c);
132
}
133
134
135
SUMOReal
136
PollutantsInterface::getWeight
(
const
SUMOEmissionClass
c) {
137
return
myHelpers
[c >> 16]->
getWeight
(c);
138
}
139
140
141
SUMOReal
142
PollutantsInterface::compute
(
const
SUMOEmissionClass
c,
const
EmissionType
e,
const
double
v,
const
double
a,
const
double
slope) {
143
return
myHelpers
[c >> 16]->
compute
(c, e, v, a, slope);
144
}
145
146
147
PollutantsInterface::Emissions
148
PollutantsInterface::computeAll
(
const
SUMOEmissionClass
c,
const
double
v,
const
double
a,
const
double
slope) {
149
const
Helper
*
const
h =
myHelpers
[c >> 16];
150
return
Emissions
(h->
compute
(c,
CO2
, v, a, slope), h->
compute
(c,
CO
, v, a, slope), h->
compute
(c,
HC
, v, a, slope),
151
h->
compute
(c,
FUEL
, v, a, slope), h->
compute
(c,
NO_X
, v, a, slope), h->
compute
(c,
PM_X
, v, a, slope));
152
}
153
154
155
SUMOReal
156
PollutantsInterface::computeDefault
(
const
SUMOEmissionClass
c,
const
EmissionType
e,
const
double
v,
const
double
a,
const
double
slope,
const
SUMOReal
tt) {
157
const
Helper
*
const
h =
myHelpers
[c >> 16];
158
return
(h->
compute
(c, e, v, 0, slope) + h->
compute
(c, e, v - a, a, slope)) * tt / 2.;
159
}
160
161
162
/****************************************************************************/
163
tmp
buildd
sumo-0.21.0+dfsg
src
utils
emissions
PollutantsInterface.cpp
Generated on Thu Nov 20 2014 19:49:58 for SUMO - Simulation of Urban MObility by
1.8.1.2