Eclipse SUMO - Simulation of Urban MObility
dll_code/Helpers.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6 
7 namespace PHEMlightdll
8 {
9  public class Helpers
10  {
11  //--------------------------------------------------------------------------------------------------
12  // Members
13  //--------------------------------------------------------------------------------------------------
14  #region Members
15  private string _vClass;
16  public string vClass
17  {
18  get { return _vClass; }
19  set { _vClass = value; }
20  }
21  private string _eClass;
22  public string eClass
23  {
24  get { return _eClass; }
25  set { _eClass = value; }
26  }
27  private string _tClass;
28  public string tClass
29  {
30  get { return _tClass; }
31  set { _tClass = value; }
32  }
33  private string _sClass;
34  public string sClass
35  {
36  get { return _sClass; }
37  set { _sClass = value; }
38  }
39  private string _Class;
40  public string gClass
41  {
42  get { return _Class; }
43  set { _Class = value; }
44  }
45  private string _ErrMsg;
46  public string ErrMsg
47  {
48  get { return _ErrMsg; }
49  set { _ErrMsg = value; }
50  }
51  private string _commentPrefix;
52  public string CommentPrefix
53  {
54  get { return _commentPrefix; }
55  set { _commentPrefix = value; }
56  }
57  private string _PHEMDataV;
58  public string PHEMDataV
59  {
60  get { return _PHEMDataV; }
61  set { _PHEMDataV = value; }
62  }
63  #endregion
64 
65  #region Classes
66  //Get vehicle class
67  private bool getvclass(string VEH)
68  {
69  // Set the drive train efficency
71 
72  //Get the vehicle class
73  if (VEH.IndexOf(Constants.strPKW) >= 0)
74  {
76  return true;
77  }
78  else if (VEH.IndexOf(Constants.strLNF) >= 0)
79  {
81  return true;
82  }
83  else if (VEH.IndexOf(Constants.strLKW) >= 0)
84  {
86  return true;
87  }
88  else if (VEH.IndexOf(Constants.strLSZ) >= 0)
89  {
91  return true;
92  }
93  else if (VEH.IndexOf(Constants.strRB) >= 0)
94  {
96  return true;
97  }
98  else if (VEH.IndexOf(Constants.strLB) >= 0)
99  {
102  return true;
103  }
104  else if (VEH.IndexOf(Constants.strMR2) >= 0)
105  {
107  return true;
108  }
109  else if (VEH.IndexOf(Constants.strMR4) >= 0)
110  {
112  return true;
113  }
114  else if (VEH.IndexOf(Constants.strKKR) >= 0)
115  {
117  return true;
118  }
119  //Should never happens
120  _ErrMsg = "Vehicle class not defined! (" + VEH + ")";
121  return false;
122  }
123 
124  //Get technologie Class
125  private bool gettclass(string VEH)
126  {
127  if (VEH.IndexOf("_" + Constants.strDiesel) > 0)
128  {
129  if (VEH.IndexOf("_" + Constants.strHybrid) > 0)
130  {
132  return true;
133  }
134  else
135  {
137  return true;
138  }
139 
140  }
141  else if (VEH.IndexOf("_" + Constants.strGasoline) > 0)
142  {
143  if (VEH.IndexOf("_" + Constants.strHybrid) > 0)
144  {
146  return true;
147  }
148  else
149  {
151  return true;
152  }
153  }
154  else if (VEH.IndexOf("_" + Constants.strCNG) > 0)
155  {
157  return true;
158  }
159  else if (VEH.IndexOf("_" + Constants.strBEV) > 0)
160  {
162  return true;
163  }
164  //Should never happens
165  _ErrMsg = "Fuel class not defined! (" + VEH + ")";
166  return false;
167  }
168 
169  //Get size class
170  private bool getsclass(string VEH)
171  {
172  if (VEH.IndexOf(Constants.strLKW) >= 0)
173  {
174  if (VEH.IndexOf("_" + Constants.strSII) > 0)
175  {
177  return true;
178  }
179  else if (VEH.IndexOf("_" + Constants.strSI) > 0)
180  {
182  return true;
183  }
184  else
185  {
186  //Should never happen
187  _ErrMsg = "Size class not defined! (" + VEH + ")";
188  return false;
189  }
190  }
191  else if (VEH.IndexOf(Constants.strLNF) >= 0)
192  {
193  if (VEH.IndexOf("_" + Constants.strSIII) > 0)
194  {
196  return true;
197  }
198  else if (VEH.IndexOf("_" + Constants.strSII) > 0)
199  {
201  return true;
202  }
203  else if (VEH.IndexOf("_" + Constants.strSI) > 0)
204  {
206  return true;
207  }
208  else
209  {
210  _ErrMsg = "Size class not defined! (" + VEH.Substring(VEH.LastIndexOf(@"\"), VEH.Length - VEH.LastIndexOf(@"\")) + ")";
211  return false;
212  }
213  }
214  else
215  {
216  _sClass = "";
217  return true;
218  }
219  }
220 
221  //Get euro class
222  private bool geteclass(string VEH)
223  {
224  if (VEH.IndexOf("_" + Constants.strEU) > 0)
225  {
226  if (VEH.IndexOf("_", VEH.IndexOf("_" + Constants.strEU) + 1) > 0)
227  {
228  _eClass = Constants.strEU + VEH.Substring(VEH.IndexOf("_" + Constants.strEU) + 3, VEH.IndexOf("_", VEH.IndexOf("_" + Constants.strEU) + 1) - (VEH.IndexOf("_" + Constants.strEU) + 3));
229  return true;
230  }
231  else if (VEH.IndexOf(".", VEH.IndexOf("_" + Constants.strEU) + 1) > 0)
232  {
233  _eClass = Constants.strEU + VEH.Substring(VEH.IndexOf("_" + Constants.strEU) + 3, VEH.IndexOf(".", VEH.IndexOf("_" + Constants.strEU) + 1) - (VEH.IndexOf("_" + Constants.strEU) + 3));
234  return true;
235  }
236  else
237  {
238  _eClass = Constants.strEU + VEH.Substring(VEH.IndexOf("_" + Constants.strEU) + 3, VEH.Length - (VEH.IndexOf("_" + Constants.strEU) + 3));
239  return true;
240  }
241  }
242  else if (VEH.IndexOf("_" + Constants.strBEV) > 0)
243  {
244  _eClass = "";
245  return true;
246  }
247  //Should never happens
248  _ErrMsg = "Euro class not defined! (" + VEH + ")";
249  return false;
250  }
251 
252  //Set complete class string
253  public bool setclass(string VEH)
254  {
255  if (getvclass(VEH)) { _Class = _vClass; } else { return false; }
256  if (getsclass(VEH)) { if (_sClass != "") { _Class = _Class + "_" + sClass; } } else { return false; }
257  if (gettclass(VEH)) { _Class = _Class + "_" + tClass; } else { return false; }
258  if (geteclass(VEH)) { if (_eClass != "") { _Class = _Class + "_" + eClass; } } else { return false; }
259  return true;
260  }
261  #endregion
262 
263 
264  }
265 }
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 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 double DRIVE_TRAIN_EFFICIENCY
static const std::string strSI
Definition: cpp/Constants.h:69
bool geteclass(const std::string &VEH)
bool getsclass(const std::string &VEH)
bool getvclass(const std::string &VEH)
Definition: cpp/Helpers.cpp:95
bool setclass(string VEH)
bool gettclass(const std::string &VEH)
bool geteclass(string VEH)
std::string _tClass
Definition: cpp/Helpers.h:45
bool getsclass(string VEH)
bool gettclass(string VEH)
bool getvclass(string VEH)