Eclipse SUMO - Simulation of Urban MObility
Helpers.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2016-2019 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
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 // SPDX-License-Identifier: EPL-2.0
11 /****************************************************************************/
17 //
18 /****************************************************************************/
19 
20 
21 #include "Helpers.h"
22 #include "Constants.h"
23 
24 
25 namespace PHEMlightdll {
26 
27  const std::string& Helpers::getvClass() const {
28  return _vClass;
29  }
30 
31  void Helpers::setvClass(const std::string& value) {
32  _vClass = value;
33  }
34 
35  const std::string& Helpers::geteClass() const {
36  return _eClass;
37  }
38 
39  void Helpers::seteClass(const std::string& value) {
40  _eClass = value;
41  }
42 
43  const std::string& Helpers::gettClass() const {
44  return _tClass;
45  }
46 
47  void Helpers::settClass(const std::string& value) {
48  _tClass = value;
49  }
50 
51  const std::string& Helpers::getsClass() const {
52  return _sClass;
53  }
54 
55  void Helpers::setsClass(const std::string& value) {
56  _sClass = value;
57  }
58 
59  const std::string& Helpers::getgClass() const {
60  return _Class;
61  }
62 
63  void Helpers::setgClass(const std::string& value) {
64  _Class = value;
65  }
66 
67  const std::string& Helpers::getErrMsg() const {
68  return _ErrMsg;
69  }
70 
71  void Helpers::setErrMsg(const std::string& value) {
72  _ErrMsg = value;
73  }
74 
75  const std::string& Helpers::getCommentPrefix() const {
76  return _commentPrefix;
77  }
78 
79  void Helpers::setCommentPrefix(const std::string& value) {
80  _commentPrefix = value;
81  }
82 
83  const std::string& Helpers::getPHEMDataV() const {
84  return _PHEMDataV;
85  }
86 
87  void Helpers::setPHEMDataV(const std::string& value) {
88  _PHEMDataV = value;
89  }
90 
91  bool Helpers::getvclass(const std::string& VEH) {
92  // Set the drive train efficency
94 
95  //Get the vehicle class
96  if (VEH.find(Constants::strPKW) != std::string::npos) {
98  return true;
99  }
100  else if (VEH.find(Constants::strLNF) != std::string::npos) {
102  return true;
103  }
104  else if (VEH.find(Constants::strLKW) != std::string::npos) {
106  return true;
107  }
108  else if (VEH.find(Constants::strLSZ) != std::string::npos) {
110  return true;
111  }
112  else if (VEH.find(Constants::strRB) != std::string::npos) {
114  return true;
115  }
116  else if (VEH.find(Constants::strLB) != std::string::npos) {
119  return true;
120  }
121  else if (VEH.find(Constants::strMR2) != std::string::npos) {
123  return true;
124  }
125  else if (VEH.find(Constants::strMR4) != std::string::npos) {
127  return true;
128  }
129  else if (VEH.find(Constants::strKKR) != std::string::npos) {
131  return true;
132  }
133  //Should never happens
134  _ErrMsg = std::string("Vehicle class not defined! (") + VEH + std::string(")");
135  return false;
136  }
137 
138  bool Helpers::gettclass(const std::string& VEH) {
139  if ((int)VEH.find(std::string("_") + Constants::strDiesel) > 0) {
140  if ((int)VEH.find(std::string("_") + Constants::strHybrid) > 0) {
141  _tClass = Constants::strDiesel + std::string("_") + Constants::strHybrid;
142  return true;
143  }
144  else {
146  return true;
147  }
148 
149  }
150  else if ((int)VEH.find(std::string("_") + Constants::strGasoline) > 0) {
151  if ((int)VEH.find(std::string("_") + Constants::strHybrid) > 0) {
152  _tClass = Constants::strGasoline + std::string("_") + Constants::strHybrid;
153  return true;
154  }
155  else {
157  return true;
158  }
159  }
160  else if ((int)VEH.find(std::string("_") + Constants::strCNG) > 0) {
162  return true;
163  }
164  else if ((int)VEH.find(std::string("_") + Constants::strBEV) > 0) {
166  return true;
167  }
168  //Should never happens
169  _ErrMsg = std::string("Fuel class not defined! (") + VEH + std::string(")");
170  return false;
171  }
172 
173  bool Helpers::getsclass(const std::string& VEH) {
174  if (VEH.find(Constants::strLKW) != std::string::npos) {
175  if ((int)VEH.find(std::string("_") + Constants::strSII) > 0) {
177  return true;
178  }
179  else if ((int)VEH.find(std::string("_") + Constants::strSI) > 0) {
181  return true;
182  }
183  else {
184  //Should never happen
185  _ErrMsg = std::string("Size class not defined! (") + VEH + std::string(")");
186  return false;
187  }
188  }
189  else if (VEH.find(Constants::strLNF) != std::string::npos) {
190  if ((int)VEH.find(std::string("_") + Constants::strSIII) > 0) {
192  return true;
193  }
194  else if ((int)VEH.find(std::string("_") + Constants::strSII) > 0) {
196  return true;
197  }
198  else if ((int)VEH.find(std::string("_") + Constants::strSI) > 0) {
200  return true;
201  }
202  else {
203  _ErrMsg = std::string("Size class not defined! (") + VEH.substr((int)VEH.rfind("\\"), VEH.length() - (int)VEH.rfind("\\")) + std::string(")");
204  return false;
205  }
206  }
207  else {
208  _sClass = "";
209  return true;
210  }
211  }
212 
213  bool Helpers::geteclass(const std::string& VEH) {
214  if ((int)VEH.find(std::string("_") + Constants::strEU) > 0) {
215  if ((int)VEH.find("_", (int)VEH.find(std::string("_") + Constants::strEU) + 1) > 0) {
216  _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));
217  return true;
218  }
219  else 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 {
224  _eClass = Constants::strEU + VEH.substr((int)VEH.find(std::string("_") + Constants::strEU) + 3, VEH.length() - ((int)VEH.find(std::string("_") + Constants::strEU) + 3));
225  return true;
226  }
227  }
228  else if ((int)VEH.find(std::string("_") + Constants::strBEV) > 0) {
229  _eClass = "";
230  return true;
231  }
232  //Should never happens
233  _ErrMsg = std::string("Euro class not defined! (") + VEH + std::string(")");
234  return false;
235  }
236 
237  bool Helpers::setclass(const std::string& VEH) {
238  if (getvclass(VEH)) {
239  _Class = _vClass;
240  }
241  else {
242  return false;
243  }
244  if (getsclass(VEH)) {
245  if (_sClass != "") {
246  _Class = _Class + std::string("_") + getsClass();
247  }
248  }
249  else {
250  return false;
251  }
252  if (gettclass(VEH)) {
253  _Class = _Class + std::string("_") + gettClass();
254  }
255  else {
256  return false;
257  }
258  if (geteclass(VEH)) {
259  if (_eClass != "") {
260  _Class = _Class + std::string("_") + geteClass();
261  }
262  }
263  else {
264  return false;
265  }
266  return true;
267  }
268 }
PHEMlightdll::Constants::DRIVE_TRAIN_EFFICIENCY_CB
static const double DRIVE_TRAIN_EFFICIENCY_CB
Definition: Constants.h:39
PHEMlightdll::Helpers::setCommentPrefix
void setCommentPrefix(const std::string &value)
Definition: Helpers.cpp:79
PHEMlightdll::Constants::strEU
static const std::string strEU
Definition: Constants.h:65
PHEMlightdll::Helpers::getvclass
bool getvclass(const std::string &VEH)
Definition: Helpers.cpp:91
PHEMlightdll::Helpers::geteClass
const std::string & geteClass() const
Definition: Helpers.cpp:35
PHEMlightdll::Helpers::setPHEMDataV
void setPHEMDataV(const std::string &value)
Definition: Helpers.cpp:87
PHEMlightdll::Constants::setDRIVE_TRAIN_EFFICIENCY
static void setDRIVE_TRAIN_EFFICIENCY(const double &value)
Definition: Constants.cpp:60
PHEMlightdll::Helpers::_ErrMsg
std::string _ErrMsg
Definition: Helpers.h:58
PHEMlightdll::Constants::strLSZ
static const std::string strLSZ
Definition: Constants.h:49
PHEMlightdll::Constants::strBEV
static const std::string strBEV
Definition: Constants.h:62
PHEMlightdll::Helpers::getsClass
const std::string & getsClass() const
Definition: Helpers.cpp:51
PHEMlightdll::Helpers::gettclass
bool gettclass(const std::string &VEH)
Definition: Helpers.cpp:138
PHEMlightdll::Helpers::seteClass
void seteClass(const std::string &value)
Definition: Helpers.cpp:39
PHEMlightdll::Constants::strMR2
static const std::string strMR2
Definition: Constants.h:52
PHEMlightdll::Helpers::_vClass
std::string _vClass
Definition: Helpers.h:33
PHEMlightdll::Helpers::getErrMsg
const std::string & getErrMsg() const
Definition: Helpers.cpp:67
PHEMlightdll::Helpers::_sClass
std::string _sClass
Definition: Helpers.h:48
PHEMlightdll::Helpers::_Class
std::string _Class
Definition: Helpers.h:53
PHEMlightdll::Constants::strSI
static const std::string strSI
Definition: Constants.h:68
PHEMlightdll::Helpers::setvClass
void setvClass(const std::string &value)
Definition: Helpers.cpp:31
PHEMlightdll::Constants::strLNF
static const std::string strLNF
Definition: Constants.h:47
Helpers.h
PHEMlightdll::Helpers::_eClass
std::string _eClass
Definition: Helpers.h:38
PHEMlightdll::Helpers::getvClass
const std::string & getvClass() const
Definition: Helpers.cpp:27
PHEMlightdll::Helpers::setgClass
void setgClass(const std::string &value)
Definition: Helpers.cpp:63
PHEMlightdll::Helpers::setErrMsg
void setErrMsg(const std::string &value)
Definition: Helpers.cpp:71
PHEMlightdll::Helpers::gettClass
const std::string & gettClass() const
Definition: Helpers.cpp:43
PHEMlightdll::Helpers::setsClass
void setsClass(const std::string &value)
Definition: Helpers.cpp:55
PHEMlightdll::Constants::strRB
static const std::string strRB
Definition: Constants.h:50
PHEMlightdll::Constants::strCNG
static const std::string strCNG
Definition: Constants.h:59
PHEMlightdll::Constants::strLKW
static const std::string strLKW
Definition: Constants.h:48
PHEMlightdll
Definition: CEP.cpp:26
PHEMlightdll::Constants::strHybrid
static const std::string strHybrid
Definition: Constants.h:61
PHEMlightdll::Constants::strDiesel
static const std::string strDiesel
Definition: Constants.h:58
PHEMlightdll::Constants::strKKR
static const std::string strKKR
Definition: Constants.h:54
PHEMlightdll::Constants::DRIVE_TRAIN_EFFICIENCY_All
static const double DRIVE_TRAIN_EFFICIENCY_All
Definition: Constants.h:38
PHEMlightdll::Constants::strGasoline
static const std::string strGasoline
Definition: Constants.h:57
PHEMlightdll::Helpers::getsclass
bool getsclass(const std::string &VEH)
Definition: Helpers.cpp:173
PHEMlightdll::Helpers::getCommentPrefix
const std::string & getCommentPrefix() const
Definition: Helpers.cpp:75
PHEMlightdll::Helpers::getPHEMDataV
const std::string & getPHEMDataV() const
Definition: Helpers.cpp:83
PHEMlightdll::Helpers::getgClass
const std::string & getgClass() const
Definition: Helpers.cpp:59
PHEMlightdll::Helpers::_PHEMDataV
std::string _PHEMDataV
Definition: Helpers.h:68
PHEMlightdll::Constants::strMR4
static const std::string strMR4
Definition: Constants.h:53
PHEMlightdll::Helpers::_commentPrefix
std::string _commentPrefix
Definition: Helpers.h:63
PHEMlightdll::Helpers::_tClass
std::string _tClass
Definition: Helpers.h:43
PHEMlightdll::Helpers::geteclass
bool geteclass(const std::string &VEH)
Definition: Helpers.cpp:213
PHEMlightdll::Helpers::setclass
bool setclass(const std::string &VEH)
Definition: Helpers.cpp:237
PHEMlightdll::Constants::strSIII
static const std::string strSIII
Definition: Constants.h:70
PHEMlightdll::Constants::strLB
static const std::string strLB
Definition: Constants.h:51
Constants.h
PHEMlightdll::Constants::strSII
static const std::string strSII
Definition: Constants.h:69
PHEMlightdll::Constants::strPKW
static const std::string strPKW
Definition: Constants.h:46
PHEMlightdll::Helpers::settClass
void settClass(const std::string &value)
Definition: Helpers.cpp:47