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