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