Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/foreign/PHEMlight/cpp/Helpers.cpp
169684 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2016-2025 German Aerospace Center (DLR) and others.
4
// PHEMlight module
5
// Copyright 2016 Technische Universitaet Graz, https://www.tugraz.at/
6
// This program and the accompanying materials are made available under the
7
// terms of the Eclipse Public License 2.0 which is available at
8
// https://www.eclipse.org/legal/epl-2.0/
9
// This Source Code may also be made available under the following Secondary
10
// Licenses when the conditions for such availability set forth in the Eclipse
11
// Public License 2.0 are satisfied: GNU General Public License, version 2
12
// or later which is available at
13
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
14
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
15
/****************************************************************************/
16
/// @file Helpers.cpp
17
/// @author Martin Dippold
18
/// @author Michael Behrisch
19
/// @date July 2016
20
///
21
//
22
/****************************************************************************/
23
#include <config.h>
24
25
#include "Helpers.h"
26
#include "Constants.h"
27
28
29
namespace PHEMlightdll {
30
31
const std::string& Helpers::getvClass() const {
32
return _vClass;
33
}
34
35
void Helpers::setvClass(const std::string& value) {
36
_vClass = value;
37
}
38
39
const std::string& Helpers::geteClass() const {
40
return _eClass;
41
}
42
43
void Helpers::seteClass(const std::string& value) {
44
_eClass = value;
45
}
46
47
const std::string& Helpers::gettClass() const {
48
return _tClass;
49
}
50
51
void Helpers::settClass(const std::string& value) {
52
_tClass = value;
53
}
54
55
const std::string& Helpers::getsClass() const {
56
return _sClass;
57
}
58
59
void Helpers::setsClass(const std::string& value) {
60
_sClass = value;
61
}
62
63
const std::string& Helpers::getgClass() const {
64
return _Class;
65
}
66
67
void Helpers::setgClass(const std::string& value) {
68
_Class = value;
69
}
70
71
const std::string& Helpers::getErrMsg() const {
72
return _ErrMsg;
73
}
74
75
void Helpers::setErrMsg(const std::string& value) {
76
_ErrMsg = value;
77
}
78
79
const std::string& Helpers::getCommentPrefix() const {
80
return _commentPrefix;
81
}
82
83
void Helpers::setCommentPrefix(const std::string& value) {
84
_commentPrefix = value;
85
}
86
87
const std::string& Helpers::getPHEMDataV() const {
88
return _PHEMDataV;
89
}
90
91
void Helpers::setPHEMDataV(const std::string& value) {
92
_PHEMDataV = value;
93
}
94
95
bool Helpers::getvclass(const std::string& VEH) {
96
// Set the drive train efficency
97
Constants::setDRIVE_TRAIN_EFFICIENCY(Constants::DRIVE_TRAIN_EFFICIENCY_All);
98
99
//Get the vehicle class
100
if (VEH.find(Constants::strPKW) != std::string::npos) {
101
_vClass = Constants::strPKW;
102
return true;
103
}
104
else if (VEH.find(Constants::strLNF) != std::string::npos) {
105
_vClass = Constants::strLNF;
106
return true;
107
}
108
else if (VEH.find(Constants::strLKW) != std::string::npos) {
109
_vClass = Constants::strLKW;
110
return true;
111
}
112
else if (VEH.find(Constants::strLSZ) != std::string::npos) {
113
_vClass = Constants::strLSZ;
114
return true;
115
}
116
else if (VEH.find(Constants::strRB) != std::string::npos) {
117
_vClass = Constants::strRB;
118
return true;
119
}
120
else if (VEH.find(Constants::strLB) != std::string::npos) {
121
_vClass = Constants::strLB;
122
Constants::setDRIVE_TRAIN_EFFICIENCY(Constants::DRIVE_TRAIN_EFFICIENCY_CB);
123
return true;
124
}
125
else if (VEH.find(Constants::strMR2) != std::string::npos) {
126
_vClass = Constants::strMR2;
127
return true;
128
}
129
else if (VEH.find(Constants::strMR4) != std::string::npos) {
130
_vClass = Constants::strMR4;
131
return true;
132
}
133
else if (VEH.find(Constants::strKKR) != std::string::npos) {
134
_vClass = Constants::strKKR;
135
return true;
136
}
137
//Should never happens
138
_ErrMsg = std::string("Vehicle class not defined! (") + VEH + std::string(")");
139
return false;
140
}
141
142
bool Helpers::gettclass(const std::string& VEH) {
143
if ((int)VEH.find(std::string("_") + Constants::strDiesel) > 0) {
144
if ((int)VEH.find(std::string("_") + Constants::strHybrid) > 0) {
145
_tClass = Constants::strDiesel + std::string("_") + Constants::strHybrid;
146
return true;
147
}
148
else {
149
_tClass = Constants::strDiesel;
150
return true;
151
}
152
153
}
154
else if ((int)VEH.find(std::string("_") + Constants::strGasoline) > 0) {
155
if ((int)VEH.find(std::string("_") + Constants::strHybrid) > 0) {
156
_tClass = Constants::strGasoline + std::string("_") + Constants::strHybrid;
157
return true;
158
}
159
else {
160
_tClass = Constants::strGasoline;
161
return true;
162
}
163
}
164
else if ((int)VEH.find(std::string("_") + Constants::strCNG) > 0) {
165
_tClass = Constants::strCNG;
166
return true;
167
}
168
else if ((int)VEH.find(std::string("_") + Constants::strBEV) > 0) {
169
_tClass = Constants::strBEV;
170
return true;
171
}
172
//Should never happens
173
_ErrMsg = std::string("Fuel class not defined! (") + VEH + std::string(")");
174
return false;
175
}
176
177
bool Helpers::getsclass(const std::string& VEH) {
178
if (VEH.find(Constants::strLKW) != std::string::npos) {
179
if ((int)VEH.find(std::string("_") + Constants::strSII) > 0) {
180
_sClass = Constants::strSII;
181
return true;
182
}
183
else if ((int)VEH.find(std::string("_") + Constants::strSI) > 0) {
184
_sClass = Constants::strSI;
185
return true;
186
}
187
else {
188
//Should never happen
189
_ErrMsg = std::string("Size class not defined! (") + VEH + std::string(")");
190
return false;
191
}
192
}
193
else if (VEH.find(Constants::strLNF) != std::string::npos) {
194
if ((int)VEH.find(std::string("_") + Constants::strSIII) > 0) {
195
_sClass = Constants::strSIII;
196
return true;
197
}
198
else if ((int)VEH.find(std::string("_") + Constants::strSII) > 0) {
199
_sClass = Constants::strSII;
200
return true;
201
}
202
else if ((int)VEH.find(std::string("_") + Constants::strSI) > 0) {
203
_sClass = Constants::strSI;
204
return true;
205
}
206
else {
207
_ErrMsg = std::string("Size class not defined! (") + VEH.substr((int)VEH.rfind("\\"), VEH.length() - (int)VEH.rfind("\\")) + std::string(")");
208
return false;
209
}
210
}
211
else {
212
_sClass = "";
213
return true;
214
}
215
}
216
217
bool Helpers::geteclass(const std::string& VEH) {
218
if ((int)VEH.find(std::string("_") + Constants::strEU) > 0) {
219
if ((int)VEH.find("_", (int)VEH.find(std::string("_") + Constants::strEU) + 1) > 0) {
220
_eClass = Constants::strEU + VEH.substr((int)VEH.find(std::string("_") + Constants::strEU) + 3, (int)VEH.find("_", (int)VEH.find(std::string("_") + Constants::strEU) + 1) - ((int)VEH.find(std::string("_") + Constants::strEU) + 3));
221
return true;
222
}
223
else if ((int)VEH.find(".", (int)VEH.find(std::string("_") + Constants::strEU) + 1) > 0) {
224
_eClass = Constants::strEU + VEH.substr((int)VEH.find(std::string("_") + Constants::strEU) + 3, (int)VEH.find(".", (int)VEH.find(std::string("_") + Constants::strEU) + 1) - ((int)VEH.find(std::string("_") + Constants::strEU) + 3));
225
return true;
226
}
227
else {
228
_eClass = Constants::strEU + VEH.substr((int)VEH.find(std::string("_") + Constants::strEU) + 3, VEH.length() - ((int)VEH.find(std::string("_") + Constants::strEU) + 3));
229
return true;
230
}
231
}
232
else if ((int)VEH.find(std::string("_") + Constants::strBEV) > 0) {
233
_eClass = "";
234
return true;
235
}
236
//Should never happens
237
_ErrMsg = std::string("Euro class not defined! (") + VEH + std::string(")");
238
return false;
239
}
240
241
bool Helpers::setclass(const std::string& VEH) {
242
if (getvclass(VEH)) {
243
_Class = _vClass;
244
}
245
else {
246
return false;
247
}
248
if (getsclass(VEH)) {
249
if (_sClass != "") {
250
_Class = _Class + std::string("_") + getsClass();
251
}
252
}
253
else {
254
return false;
255
}
256
if (gettclass(VEH)) {
257
_Class = _Class + std::string("_") + gettClass();
258
}
259
else {
260
return false;
261
}
262
if (geteclass(VEH)) {
263
if (_eClass != "") {
264
_Class = _Class + std::string("_") + geteClass();
265
}
266
}
267
else {
268
return false;
269
}
270
return true;
271
}
272
}
273
274