Eclipse SUMO - Simulation of Urban MObility
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 
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
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) {
145  _tClass = Constants::strDiesel + std::string("_") + Constants::strHybrid;
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) {
156  _tClass = Constants::strGasoline + std::string("_") + Constants::strHybrid;
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
Definition: cpp/Constants.h:63
static const std::string strMR4
Definition: cpp/Constants.h:54
static const std::string strLSZ
Definition: cpp/Constants.h:50
static const std::string strPKW
Definition: cpp/Constants.h:47
static const std::string strLB
Definition: cpp/Constants.h:52
static const std::string strKKR
Definition: cpp/Constants.h:55
static const double DRIVE_TRAIN_EFFICIENCY_All
Definition: cpp/Constants.h:40
static const std::string strRB
Definition: cpp/Constants.h:51
static void setDRIVE_TRAIN_EFFICIENCY(const double &value)
set drive train efficiency
static const std::string strDiesel
Definition: cpp/Constants.h:59
static const std::string strMR2
Definition: cpp/Constants.h:53
static const std::string strSII
Definition: cpp/Constants.h:70
static const double DRIVE_TRAIN_EFFICIENCY_CB
Definition: cpp/Constants.h:41
static const std::string strEU
Definition: cpp/Constants.h:66
static const std::string strHybrid
Definition: cpp/Constants.h:62
static const std::string strGasoline
Definition: cpp/Constants.h:58
static const std::string strCNG
Definition: cpp/Constants.h:60
static const std::string strSIII
Definition: cpp/Constants.h:71
static const std::string strLNF
Definition: cpp/Constants.h:48
static const std::string strLKW
Definition: cpp/Constants.h:49
static const std::string strSI
Definition: cpp/Constants.h:69
const std::string & getvClass() const
Definition: cpp/Helpers.cpp:31
const std::string & geteClass() const
Definition: cpp/Helpers.cpp:39
void setgClass(const std::string &value)
Definition: cpp/Helpers.cpp:67
bool geteclass(const std::string &VEH)
std::string _commentPrefix
Definition: cpp/Helpers.h:65
void setsClass(const std::string &value)
Definition: cpp/Helpers.cpp:59
const std::string & getErrMsg() const
Definition: cpp/Helpers.cpp:71
bool getsclass(const std::string &VEH)
bool getvclass(const std::string &VEH)
Definition: cpp/Helpers.cpp:95
const std::string & getCommentPrefix() const
Definition: cpp/Helpers.cpp:79
const std::string & getPHEMDataV() const
Definition: cpp/Helpers.cpp:87
void setErrMsg(const std::string &value)
Definition: cpp/Helpers.cpp:75
std::string _eClass
Definition: cpp/Helpers.h:40
std::string _sClass
Definition: cpp/Helpers.h:50
std::string _vClass
Definition: cpp/Helpers.h:35
void setPHEMDataV(const std::string &value)
Definition: cpp/Helpers.cpp:91
void setCommentPrefix(const std::string &value)
Definition: cpp/Helpers.cpp:83
bool gettclass(const std::string &VEH)
void seteClass(const std::string &value)
Definition: cpp/Helpers.cpp:43
const std::string & getgClass() const
Definition: cpp/Helpers.cpp:63
std::string _tClass
Definition: cpp/Helpers.h:45
void setvClass(const std::string &value)
Definition: cpp/Helpers.cpp:35
const std::string & gettClass() const
Definition: cpp/Helpers.cpp:47
const std::string & getsClass() const
Definition: cpp/Helpers.cpp:55
std::string _PHEMDataV
Definition: cpp/Helpers.h:70
void settClass(const std::string &value)
Definition: cpp/Helpers.cpp:51
bool setclass(const std::string &VEH)
std::string _Class
Definition: cpp/Helpers.h:55
std::string _ErrMsg
Definition: cpp/Helpers.h:60