SUMO - Simulation of Urban MObility
Helpers.cpp
Go to the documentation of this file.
1 #include "Helpers.h"
2 #include "Constants.h"
3 
4 
5 namespace PHEMlightdll {
6 
7  const std::string& Helpers::getvClass() const {
8  return _vClass;
9  }
10 
11  void Helpers::setvClass(const std::string& value) {
12  _vClass = value;
13  }
14 
15  const std::string& Helpers::geteClass() const {
16  return _eClass;
17  }
18 
19  void Helpers::seteClass(const std::string& value) {
20  _eClass = value;
21  }
22 
23  const std::string& Helpers::gettClass() const {
24  return _tClass;
25  }
26 
27  void Helpers::settClass(const std::string& value) {
28  _tClass = value;
29  }
30 
31  const std::string& Helpers::getsClass() const {
32  return _sClass;
33  }
34 
35  void Helpers::setsClass(const std::string& value) {
36  _sClass = value;
37  }
38 
39  const std::string& Helpers::getgClass() const {
40  return _Class;
41  }
42 
43  void Helpers::setgClass(const std::string& value) {
44  _Class = value;
45  }
46 
47  const std::string& Helpers::getErrMsg() const {
48  return _ErrMsg;
49  }
50 
51  void Helpers::setErrMsg(const std::string& value) {
52  _ErrMsg = value;
53  }
54 
55  const std::string& Helpers::getCommentPrefix() const {
56  return _commentPrefix;
57  }
58 
59  void Helpers::setCommentPrefix(const std::string& value) {
60  _commentPrefix = value;
61  }
62 
63  const std::string& Helpers::getPHEMDataV() const {
64  return _PHEMDataV;
65  }
66 
67  void Helpers::setPHEMDataV(const std::string& value) {
68  _PHEMDataV = value;
69  }
70 
71  bool Helpers::getvclass(const std::string& VEH) {
72  // Set the drive train efficency
74 
75  //Get the vehicle class
76  if (VEH.find(Constants::strPKW) != std::string::npos) {
78  return true;
79  }
80  else if (VEH.find(Constants::strLNF) != std::string::npos) {
82  return true;
83  }
84  else if (VEH.find(Constants::strLKW) != std::string::npos) {
86  return true;
87  }
88  else if (VEH.find(Constants::strLSZ) != std::string::npos) {
90  return true;
91  }
92  else if (VEH.find(Constants::strRB) != std::string::npos) {
94  return true;
95  }
96  else if (VEH.find(Constants::strLB) != std::string::npos) {
99  return true;
100  }
101  else if (VEH.find(Constants::strMR2) != std::string::npos) {
103  return true;
104  }
105  else if (VEH.find(Constants::strMR4) != std::string::npos) {
107  return true;
108  }
109  else if (VEH.find(Constants::strKKR) != std::string::npos) {
111  return true;
112  }
113  //Should never happens
114  _ErrMsg = std::string("Vehicle class not defined! (") + VEH + std::string(")");
115  return false;
116  }
117 
118  bool Helpers::gettclass(const std::string& VEH) {
119  if ((int)VEH.find(std::string("_") + Constants::strDiesel) > 0) {
120  if ((int)VEH.find(std::string("_") + Constants::strHybrid) > 0) {
121  _tClass = Constants::strDiesel + std::string("_") + Constants::strHybrid;
122  return true;
123  }
124  else {
126  return true;
127  }
128 
129  }
130  else if ((int)VEH.find(std::string("_") + Constants::strGasoline) > 0) {
131  if ((int)VEH.find(std::string("_") + Constants::strHybrid) > 0) {
132  _tClass = Constants::strGasoline + std::string("_") + Constants::strHybrid;
133  return true;
134  }
135  else {
137  return true;
138  }
139  }
140  else if ((int)VEH.find(std::string("_") + Constants::strCNG) > 0) {
142  return true;
143  }
144  else if ((int)VEH.find(std::string("_") + Constants::strBEV) > 0) {
146  return true;
147  }
148  //Should never happens
149  _ErrMsg = std::string("Fuel class not defined! (") + VEH + std::string(")");
150  return false;
151  }
152 
153  bool Helpers::getsclass(const std::string& VEH) {
154  if (VEH.find(Constants::strLKW) != std::string::npos) {
155  if ((int)VEH.find(std::string("_") + Constants::strSII) > 0) {
157  return true;
158  }
159  else if ((int)VEH.find(std::string("_") + Constants::strSI) > 0) {
161  return true;
162  }
163  else {
164  //Should never happen
165  _ErrMsg = std::string("Size class not defined! (") + VEH + std::string(")");
166  return false;
167  }
168  }
169  else if (VEH.find(Constants::strLNF) != std::string::npos) {
170  if ((int)VEH.find(std::string("_") + Constants::strSIII) > 0) {
172  return true;
173  }
174  else if ((int)VEH.find(std::string("_") + Constants::strSII) > 0) {
176  return true;
177  }
178  else if ((int)VEH.find(std::string("_") + Constants::strSI) > 0) {
180  return true;
181  }
182  else {
183  _ErrMsg = std::string("Size class not defined! (") + VEH.substr((int)VEH.rfind("\\"), VEH.length() - (int)VEH.rfind("\\")) + std::string(")");
184  return false;
185  }
186  }
187  else {
188  _sClass = "";
189  return true;
190  }
191  }
192 
193  bool Helpers::geteclass(const std::string& VEH) {
194  if ((int)VEH.find(std::string("_") + Constants::strEU) > 0) {
195  if ((int)VEH.find("_", (int)VEH.find(std::string("_") + Constants::strEU) + 1) > 0) {
196  _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));
197  return true;
198  }
199  else if ((int)VEH.find(".", (int)VEH.find(std::string("_") + Constants::strEU) + 1) > 0) {
200  _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));
201  return true;
202  }
203  else {
204  _eClass = Constants::strEU + VEH.substr((int)VEH.find(std::string("_") + Constants::strEU) + 3, VEH.length() - ((int)VEH.find(std::string("_") + Constants::strEU) + 3));
205  return true;
206  }
207  }
208  else if ((int)VEH.find(std::string("_") + Constants::strBEV) > 0) {
209  _eClass = "";
210  return true;
211  }
212  //Should never happens
213  _ErrMsg = std::string("Euro class not defined! (") + VEH + std::string(")");
214  return false;
215  }
216 
217  bool Helpers::setclass(const std::string& VEH) {
218  if (getvclass(VEH)) {
219  _Class = _vClass;
220  }
221  else {
222  return false;
223  }
224  if (getsclass(VEH)) {
225  if (_sClass != "") {
226  _Class = _Class + std::string("_") + getsClass();
227  }
228  }
229  else {
230  return false;
231  }
232  if (gettclass(VEH)) {
233  _Class = _Class + std::string("_") + gettClass();
234  }
235  else {
236  return false;
237  }
238  if (geteclass(VEH)) {
239  if (_eClass != "") {
240  _Class = _Class + std::string("_") + geteClass();
241  }
242  }
243  else {
244  return false;
245  }
246  return true;
247  }
248 }
std::string _commentPrefix
Definition: Helpers.h:43
static const std::string strSIII
Definition: Constants.h:49
static const std::string strCNG
Definition: Constants.h:39
const std::string & getvClass() const
Definition: Helpers.cpp:7
static const std::string strPKW
Definition: Constants.h:26
static const std::string strLSZ
Definition: Constants.h:29
bool gettclass(const std::string &VEH)
Definition: Helpers.cpp:118
void seteClass(const std::string &value)
Definition: Helpers.cpp:19
std::string _eClass
Definition: Helpers.h:18
bool getvclass(const std::string &VEH)
Definition: Helpers.cpp:71
bool setclass(const std::string &VEH)
Definition: Helpers.cpp:217
bool geteclass(const std::string &VEH)
Definition: Helpers.cpp:193
void setErrMsg(const std::string &value)
Definition: Helpers.cpp:51
static const std::string strSI
Definition: Constants.h:47
void setgClass(const std::string &value)
Definition: Helpers.cpp:43
static const std::string strSII
Definition: Constants.h:48
static const std::string strHybrid
Definition: Constants.h:40
const std::string & getPHEMDataV() const
Definition: Helpers.cpp:63
static const double DRIVE_TRAIN_EFFICIENCY_CB
Definition: Constants.h:19
static const std::string strKKR
Definition: Constants.h:34
static const std::string strMR2
Definition: Constants.h:32
std::string _sClass
Definition: Helpers.h:28
const std::string & getsClass() const
Definition: Helpers.cpp:31
static const double DRIVE_TRAIN_EFFICIENCY_All
Definition: Constants.h:18
std::string _ErrMsg
Definition: Helpers.h:38
const std::string & getgClass() const
Definition: Helpers.cpp:39
void setvClass(const std::string &value)
Definition: Helpers.cpp:11
static const std::string strEU
Definition: Constants.h:44
static const std::string strDiesel
Definition: Constants.h:38
std::string _PHEMDataV
Definition: Helpers.h:48
void setsClass(const std::string &value)
Definition: Helpers.cpp:35
std::string _tClass
Definition: Helpers.h:23
std::string _Class
Definition: Helpers.h:33
static void setDRIVE_TRAIN_EFFICIENCY(const double &value)
Definition: Constants.cpp:39
static const std::string strGasoline
Definition: Constants.h:37
const std::string & getErrMsg() const
Definition: Helpers.cpp:47
static const std::string strLNF
Definition: Constants.h:27
bool getsclass(const std::string &VEH)
Definition: Helpers.cpp:153
const std::string & getCommentPrefix() const
Definition: Helpers.cpp:55
static const std::string strLKW
Definition: Constants.h:28
static const std::string strMR4
Definition: Constants.h:33
static const std::string strBEV
Definition: Constants.h:41
const std::string & gettClass() const
Definition: Helpers.cpp:23
void setCommentPrefix(const std::string &value)
Definition: Helpers.cpp:59
const std::string & geteClass() const
Definition: Helpers.cpp:15
void settClass(const std::string &value)
Definition: Helpers.cpp:27
std::string _vClass
Definition: Helpers.h:13
static const std::string strRB
Definition: Constants.h:30
static const std::string strLB
Definition: Constants.h:31
void setPHEMDataV(const std::string &value)
Definition: Helpers.cpp:67