Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
V5/cpp/Helpers.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2016-2024 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/****************************************************************************/
21//
22/****************************************************************************/
23#include <config.h>
24
25#include "Helpers.h"
26#include "Constants.h"
27
28
29namespace 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
106
107 //Get the vehicle class
108 if (VEH.find(Constants::strPKW) != std::string::npos) {
110 return true;
111 }
112 else if (VEH.find(Constants::strLNF) != std::string::npos) {
114 return true;
115 }
116 else if (VEH.find(Constants::strLKW) != std::string::npos) {
118 return true;
119 }
120 else if (VEH.find(Constants::strLSZ) != std::string::npos) {
122 return true;
123 }
124 else if (VEH.find(Constants::strRB) != std::string::npos) {
126 return true;
127 }
128 else if (VEH.find(Constants::strLB) != std::string::npos) {
131 return true;
132 }
133 else if (VEH.find(Constants::strMR2) != std::string::npos) {
135 return true;
136 }
137 else if (VEH.find(Constants::strMR4) != std::string::npos) {
139 return true;
140 }
141 else if (VEH.find(Constants::strMR) != std::string::npos) {
143 return true;
144 }
145 else if (VEH.find(Constants::strKKR) != std::string::npos) {
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) {
157 return true;
158 }
159 else if ((int)VEH.find(std::string("_") + Constants::strDiesel) > 0) {
161 return true;
162 }
163 else if ((int)VEH.find(std::string("_") + Constants::strGasoline) > 0) {
165 return true;
166 }
167 else if ((int)VEH.find(std::string("_") + Constants::strCNG) > 0) {
169 return true;
170 }
171 else if ((int)VEH.find(std::string("_") + Constants::strLPG) > 0) {
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) {
184 return true;
185 }
186 else if ((int)VEH.find(std::string("_") + Constants::strSI) > 0) {
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) {
199 return true;
200 }
201 else if ((int)VEH.find(std::string("_") + Constants::strSII) > 0) {
203 return true;
204 }
205 else if ((int)VEH.find(std::string("_") + Constants::strSI) > 0) {
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) {
217 return true;
218 }
219 else if ((int)VEH.find(std::string("_") + Constants::strHeavy) > 0) {
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) {
261 return true;
262 }
263 else if ((int)VEH.find(std::string("_") + Constants::strSU) > 0) {
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}
static const std::string strLNF
static void setDRIVE_TRAIN_EFFICIENCY(const double &value)
static const std::string strBEV
static const std::string strSIII
static const std::string strLSZ
static const double DRIVE_TRAIN_EFFICIENCY_CB
static const std::string strMR4
static const std::string strMR
static const std::string strSII
static const std::string strMidi
static const std::string strLPG
static const std::string strCNG
static const std::string strLKW
static const std::string strEU
static const std::string strLB
static const std::string strKKR
static const std::string strHeavy
static const std::string strSU
static const double DRIVE_TRAIN_EFFICIENCY_All
static const std::string strSI
static const std::string strMR2
static const std::string strRB
static const std::string strPKW
static const std::string strHybrid
static const std::string strGasoline
static const std::string strDiesel
const std::string & getPHEMDataV() const
const std::string & getpClass() const
void setPHEMDataV(const std::string &value)
const std::string & getvClass() const
void seteClass(const std::string &value)
const std::string & getuClass() const
bool getuclass(const std::string &VEH)
bool setclass(const std::string &VEH)
const std::string & getgClass() const
const std::string & getCommentPrefix() const
void setvClass(const std::string &value)
void setgClass(const std::string &value)
void setpClass(const std::string &value)
void setsClass(const std::string &value)
bool geteclass(const std::string &VEH)
bool getvclass(const std::string &VEH)
const std::string & getsClass() const
const std::string & geteClass() const
void setCommentPrefix(const std::string &value)
bool getsclass(const std::string &VEH)
void setuClass(const std::string &value)
bool getpclass(const std::string &VEH)
const std::string & getErrMsg() const
void setErrMsg(const std::string &value)