Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/foreign/PHEMlight/V5/cpp/Helpers.cpp
169687 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 (C) 2016-2023 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 PHEMlightdllV5 {
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::getpClass() const {
48
return _pClass;
49
}
50
51
void Helpers::setpClass(const std::string& value) {
52
_pClass = 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::getuClass() const {
72
return _uClass;
73
}
74
75
void Helpers::setuClass(const std::string& value) {
76
_uClass = value;
77
}
78
79
const std::string& Helpers::getErrMsg() const {
80
return _ErrMsg;
81
}
82
83
void Helpers::setErrMsg(const std::string& value) {
84
_ErrMsg = value;
85
}
86
87
const std::string& Helpers::getCommentPrefix() const {
88
return _commentPrefix;
89
}
90
91
void Helpers::setCommentPrefix(const std::string& value) {
92
_commentPrefix = value;
93
}
94
95
const std::string& Helpers::getPHEMDataV() const {
96
return _PHEMDataV;
97
}
98
99
void Helpers::setPHEMDataV(const std::string& value) {
100
_PHEMDataV = value;
101
}
102
103
bool Helpers::getvclass(const std::string& VEH) {
104
// Set the drive train efficency
105
Constants::setDRIVE_TRAIN_EFFICIENCY(Constants::DRIVE_TRAIN_EFFICIENCY_All);
106
107
//Get the vehicle class
108
if (VEH.find(Constants::strPKW) != std::string::npos) {
109
_vClass = Constants::strPKW;
110
return true;
111
}
112
else if (VEH.find(Constants::strLNF) != std::string::npos) {
113
_vClass = Constants::strLNF;
114
return true;
115
}
116
else if (VEH.find(Constants::strLKW) != std::string::npos) {
117
_vClass = Constants::strLKW;
118
return true;
119
}
120
else if (VEH.find(Constants::strLSZ) != std::string::npos) {
121
_vClass = Constants::strLSZ;
122
return true;
123
}
124
else if (VEH.find(Constants::strRB) != std::string::npos) {
125
_vClass = Constants::strRB;
126
return true;
127
}
128
else if (VEH.find(Constants::strLB) != std::string::npos) {
129
_vClass = Constants::strLB;
130
Constants::setDRIVE_TRAIN_EFFICIENCY(Constants::DRIVE_TRAIN_EFFICIENCY_CB);
131
return true;
132
}
133
else if (VEH.find(Constants::strMR2) != std::string::npos) {
134
_vClass = Constants::strMR2;
135
return true;
136
}
137
else if (VEH.find(Constants::strMR4) != std::string::npos) {
138
_vClass = Constants::strMR4;
139
return true;
140
}
141
else if (VEH.find(Constants::strMR) != std::string::npos) {
142
_vClass = Constants::strMR;
143
return true;
144
}
145
else if (VEH.find(Constants::strKKR) != std::string::npos) {
146
_vClass = Constants::strKKR;
147
return true;
148
}
149
//Should never happens
150
_ErrMsg = std::string("Vehicle class not defined! (") + VEH + std::string(")");
151
return false;
152
}
153
154
bool Helpers::getpclass(const std::string& VEH) {
155
if ((int)VEH.find(std::string("_") + Constants::strBEV) > 0) {
156
_pClass = Constants::strBEV;
157
return true;
158
}
159
else if ((int)VEH.find(std::string("_") + Constants::strDiesel) > 0) {
160
_pClass = Constants::strDiesel;
161
return true;
162
}
163
else if ((int)VEH.find(std::string("_") + Constants::strGasoline) > 0) {
164
_pClass = Constants::strGasoline;
165
return true;
166
}
167
else if ((int)VEH.find(std::string("_") + Constants::strCNG) > 0) {
168
_pClass = Constants::strCNG;
169
return true;
170
}
171
else if ((int)VEH.find(std::string("_") + Constants::strLPG) > 0) {
172
_pClass = Constants::strLPG;
173
return true;
174
}
175
//Should never happens
176
_ErrMsg = std::string("Fuel class not defined! (") + VEH + std::string(")");
177
return false;
178
}
179
180
bool Helpers::getsclass(const std::string& VEH) {
181
if (VEH.find(Constants::strLKW) != std::string::npos) {
182
if ((int)VEH.find(std::string("_") + Constants::strSII) > 0) {
183
_sClass = Constants::strSII;
184
return true;
185
}
186
else if ((int)VEH.find(std::string("_") + Constants::strSI) > 0) {
187
_sClass = Constants::strSI;
188
return true;
189
}
190
else {
191
//Should never happen
192
_ErrMsg = std::string("Size class not defined! (") + VEH + std::string(")");
193
return false;
194
}
195
}
196
else if (VEH.find(Constants::strLNF) != std::string::npos) {
197
if ((int)VEH.find(std::string("_") + Constants::strSIII) > 0) {
198
_sClass = Constants::strSIII;
199
return true;
200
}
201
else if ((int)VEH.find(std::string("_") + Constants::strSII) > 0) {
202
_sClass = Constants::strSII;
203
return true;
204
}
205
else if ((int)VEH.find(std::string("_") + Constants::strSI) > 0) {
206
_sClass = Constants::strSI;
207
return true;
208
}
209
else {
210
_ErrMsg = std::string("Size class not defined! (") + VEH.substr((int)VEH.rfind("\\"), VEH.length() - (int)VEH.rfind("\\")) + std::string(")");
211
return false;
212
}
213
}
214
else if (VEH.find(Constants::strLB) != std::string::npos) {
215
if ((int)VEH.find(std::string("_") + Constants::strMidi) > 0) {
216
_sClass = Constants::strMidi;
217
return true;
218
}
219
else if ((int)VEH.find(std::string("_") + Constants::strHeavy) > 0) {
220
_sClass = Constants::strHeavy;
221
return true;
222
}
223
else {
224
_sClass = "";
225
return true;
226
}
227
}
228
else {
229
_sClass = "";
230
return true;
231
}
232
}
233
234
bool Helpers::geteclass(const std::string& VEH) {
235
if ((int)VEH.find(std::string("_") + Constants::strEU) > 0) {
236
if ((int)VEH.find("_", (int)VEH.find(std::string("_") + Constants::strEU) + 1) > 0) {
237
_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));
238
return true;
239
}
240
else if ((int)VEH.find(".", (int)VEH.find(std::string("_") + Constants::strEU) + 1) > 0) {
241
_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));
242
return true;
243
}
244
else {
245
_eClass = Constants::strEU + VEH.substr((int)VEH.find(std::string("_") + Constants::strEU) + 3, VEH.length() - ((int)VEH.find(std::string("_") + Constants::strEU) + 3));
246
return true;
247
}
248
}
249
else if ((int)VEH.find(std::string("_") + Constants::strBEV) > 0) {
250
_eClass = "";
251
return true;
252
}
253
//Should never happens
254
_ErrMsg = std::string("Euro class not defined! (") + VEH + std::string(")");
255
return false;
256
}
257
258
bool Helpers::getuclass(const std::string& VEH) {
259
if ((int)VEH.find(std::string("_") + Constants::strHybrid) > 0) {
260
_uClass = Constants::strHybrid;
261
return true;
262
}
263
else if ((int)VEH.find(std::string("_") + Constants::strSU) > 0) {
264
_uClass = Constants::strSU;
265
return true;
266
}
267
else {
268
_uClass = "";
269
return true;
270
}
271
}
272
273
bool Helpers::setclass(const std::string& VEH) {
274
//Get the classes
275
if (!getvclass(VEH)) {
276
return false;
277
}
278
if (!geteclass(VEH)) {
279
return false;
280
}
281
if (!getpclass(VEH)) {
282
return false;
283
}
284
if (!getsclass(VEH)) {
285
return false;
286
}
287
if (!getuclass(VEH)) {
288
return false;
289
}
290
291
if ((int)VEH.rfind("\\") <= 0) {
292
_Class = VEH;
293
}
294
else {
295
std::string vehstr = VEH.substr((int)VEH.rfind("\\") + 1, VEH.length() - (int)VEH.rfind("\\") - 1);
296
_Class = vehstr.substr(0, (int)vehstr.find("."));
297
}
298
return true;
299
}
300
}
301
302