Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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 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/****************************************************************************/
21//
22/****************************************************************************/
23#include <config.h>
24
25#include "Helpers.h"
26#include "Constants.h"
27
28
29namespace 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
98
99 //Get the vehicle class
100 if (VEH.find(Constants::strPKW) != std::string::npos) {
102 return true;
103 }
104 else if (VEH.find(Constants::strLNF) != std::string::npos) {
106 return true;
107 }
108 else if (VEH.find(Constants::strLKW) != std::string::npos) {
110 return true;
111 }
112 else if (VEH.find(Constants::strLSZ) != std::string::npos) {
114 return true;
115 }
116 else if (VEH.find(Constants::strRB) != std::string::npos) {
118 return true;
119 }
120 else if (VEH.find(Constants::strLB) != std::string::npos) {
123 return true;
124 }
125 else if (VEH.find(Constants::strMR2) != std::string::npos) {
127 return true;
128 }
129 else if (VEH.find(Constants::strMR4) != std::string::npos) {
131 return true;
132 }
133 else if (VEH.find(Constants::strKKR) != std::string::npos) {
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) {
146 return true;
147 }
148 else {
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) {
157 return true;
158 }
159 else {
161 return true;
162 }
163 }
164 else if ((int)VEH.find(std::string("_") + Constants::strCNG) > 0) {
166 return true;
167 }
168 else if ((int)VEH.find(std::string("_") + Constants::strBEV) > 0) {
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) {
181 return true;
182 }
183 else if ((int)VEH.find(std::string("_") + Constants::strSI) > 0) {
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) {
196 return true;
197 }
198 else if ((int)VEH.find(std::string("_") + Constants::strSII) > 0) {
200 return true;
201 }
202 else if ((int)VEH.find(std::string("_") + Constants::strSI) > 0) {
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}
static const std::string strBEV
static const std::string strMR4
static const std::string strLSZ
static const std::string strPKW
static const std::string strLB
static const std::string strKKR
static const double DRIVE_TRAIN_EFFICIENCY_All
static const std::string strRB
static void setDRIVE_TRAIN_EFFICIENCY(const double &value)
set drive train efficiency
static const std::string strDiesel
static const std::string strMR2
static const std::string strSII
static const double DRIVE_TRAIN_EFFICIENCY_CB
static const std::string strEU
static const std::string strHybrid
static const std::string strGasoline
static const std::string strCNG
static const std::string strSIII
static const std::string strLNF
static const std::string strLKW
static const std::string strSI
const std::string & getvClass() const
const std::string & geteClass() const
void setgClass(const std::string &value)
bool geteclass(const std::string &VEH)
void setsClass(const std::string &value)
const std::string & getErrMsg() const
bool getsclass(const std::string &VEH)
bool getvclass(const std::string &VEH)
const std::string & getCommentPrefix() const
const std::string & getPHEMDataV() const
void setErrMsg(const std::string &value)
void setPHEMDataV(const std::string &value)
void setCommentPrefix(const std::string &value)
bool gettclass(const std::string &VEH)
void seteClass(const std::string &value)
const std::string & getgClass() const
void setvClass(const std::string &value)
const std::string & gettClass() const
const std::string & getsClass() const
std::string _PHEMDataV
Definition cpp/Helpers.h:70
void settClass(const std::string &value)
bool setclass(const std::string &VEH)
std::string _commentPrefix
Definition cpp/Helpers.h:65