Eclipse SUMO - Simulation of Urban MObility
V5/cs/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  #region Members
12  private string _vClass;
13  public string vClass
14  {
15  get { return _vClass; }
16  set { _vClass = value; }
17  }
18  private string _eClass;
19  public string eClass
20  {
21  get { return _eClass; }
22  set { _eClass = value; }
23  }
24  private string _pClass;
25  public string pClass
26  {
27  get { return _pClass; }
28  set { _pClass = value; }
29  }
30  private string _sClass;
31  public string sClass
32  {
33  get { return _sClass; }
34  set { _sClass = value; }
35  }
36  private string _Class;
37  public string gClass
38  {
39  get { return _Class; }
40  set { _Class = value; }
41  }
42  private string _uClass;
43  public string uClass
44  {
45  get { return _uClass; }
46  set { _uClass = value; }
47  }
48  private string _ErrMsg;
49  public string ErrMsg
50  {
51  get { return _ErrMsg; }
52  set { _ErrMsg = value; }
53  }
54  private string _commentPrefix;
55  public string CommentPrefix
56  {
57  get { return _commentPrefix; }
58  set { _commentPrefix = value; }
59  }
60  private string _PHEMDataV;
61  public string PHEMDataV
62  {
63  get { return _PHEMDataV; }
64  set { _PHEMDataV = value; }
65  }
66  #endregion
67 
68  #region Classes
69  //Get vehicle class
70  private bool getvclass(string VEH)
71  {
72  // Set the drive train efficency
74 
75  //Get the vehicle class
76  if (VEH.IndexOf(Constants.strPKW) >= 0)
77  {
79  return true;
80  }
81  else if (VEH.IndexOf(Constants.strLNF) >= 0)
82  {
84  return true;
85  }
86  else if (VEH.IndexOf(Constants.strLKW) >= 0)
87  {
89  return true;
90  }
91  else if (VEH.IndexOf(Constants.strLSZ) >= 0)
92  {
94  return true;
95  }
96  else if (VEH.IndexOf(Constants.strRB) >= 0)
97  {
99  return true;
100  }
101  else if (VEH.IndexOf(Constants.strLB) >= 0)
102  {
105  return true;
106  }
107  else if (VEH.IndexOf(Constants.strMR2) >= 0)
108  {
110  return true;
111  }
112  else if (VEH.IndexOf(Constants.strMR4) >= 0)
113  {
115  return true;
116  }
117  else if (VEH.IndexOf(Constants.strMR) >= 0)
118  {
120  return true;
121  }
122  else if (VEH.IndexOf(Constants.strKKR) >= 0)
123  {
125  return true;
126  }
127  //Should never happens
128  _ErrMsg = "Vehicle class not defined! (" + VEH + ")";
129  return false;
130  }
131 
132  //Get propulsion Class
133  private bool getpclass(string VEH)
134  {
135  if (VEH.IndexOf("_" + Constants.strBEV) > 0)
136  {
138  return true;
139  }
140  else if (VEH.IndexOf("_" + Constants.strDiesel) > 0)
141  {
143  return true;
144  }
145  else if (VEH.IndexOf("_" + Constants.strGasoline) > 0)
146  {
148  return true;
149  }
150  else if (VEH.IndexOf("_" + Constants.strCNG) > 0)
151  {
153  return true;
154  }
155  else if (VEH.IndexOf("_" + Constants.strLPG) > 0)
156  {
158  return true;
159  }
160  //Should never happens
161  _ErrMsg = "Fuel class not defined! (" + VEH + ")";
162  return false;
163  }
164 
165  //Get size class
166  private bool getsclass(string VEH)
167  {
168  if (VEH.IndexOf(Constants.strLKW) >= 0)
169  {
170  if (VEH.IndexOf("_" + Constants.strSII) > 0)
171  {
173  return true;
174  }
175  else if (VEH.IndexOf("_" + Constants.strSI) > 0)
176  {
178  return true;
179  }
180  else
181  {
182  //Should never happen
183  _ErrMsg = "Size class not defined! (" + VEH + ")";
184  return false;
185  }
186  }
187  else if (VEH.IndexOf(Constants.strLNF) >= 0)
188  {
189  if (VEH.IndexOf("_" + Constants.strSIII) > 0)
190  {
192  return true;
193  }
194  else if (VEH.IndexOf("_" + Constants.strSII) > 0)
195  {
197  return true;
198  }
199  else if (VEH.IndexOf("_" + Constants.strSI) > 0)
200  {
202  return true;
203  }
204  else
205  {
206  _ErrMsg = "Size class not defined! (" + VEH.Substring(VEH.LastIndexOf(@"\"), VEH.Length - VEH.LastIndexOf(@"\")) + ")";
207  return false;
208  }
209  }
210  else if (VEH.IndexOf(Constants.strLB) >= 0)
211  {
212  if (VEH.IndexOf("_" + Constants.strMidi) > 0)
213  {
215  return true;
216  }
217  else if (VEH.IndexOf("_" + Constants.strHeavy) > 0)
218  {
220  return true;
221  }
222  else
223  {
224  _sClass = "";
225  return true;
226  }
227  }
228  else
229  {
230  _sClass = "";
231  return true;
232  }
233  }
234 
235  //Get euro class
236  private bool geteclass(string VEH)
237  {
238  if (VEH.IndexOf("_" + Constants.strEU) > 0)
239  {
240  if (VEH.IndexOf("_", VEH.IndexOf("_" + Constants.strEU) + 1) > 0)
241  {
242  _eClass = Constants.strEU + VEH.Substring(VEH.IndexOf("_" + Constants.strEU) + 3, VEH.IndexOf("_", VEH.IndexOf("_" + Constants.strEU) + 1) - (VEH.IndexOf("_" + Constants.strEU) + 3));
243  return true;
244  }
245  else if (VEH.IndexOf(".", VEH.IndexOf("_" + Constants.strEU) + 1) > 0)
246  {
247  _eClass = Constants.strEU + VEH.Substring(VEH.IndexOf("_" + Constants.strEU) + 3, VEH.IndexOf(".", VEH.IndexOf("_" + Constants.strEU) + 1) - (VEH.IndexOf("_" + Constants.strEU) + 3));
248  return true;
249  }
250  else
251  {
252  _eClass = Constants.strEU + VEH.Substring(VEH.IndexOf("_" + Constants.strEU) + 3, VEH.Length - (VEH.IndexOf("_" + Constants.strEU) + 3));
253  return true;
254  }
255  }
256  else if (VEH.IndexOf("_" + Constants.strBEV) > 0)
257  {
258  _eClass = "";
259  return true;
260  }
261  //Should never happens
262  _ErrMsg = "Euro class not defined! (" + VEH + ")";
263  return false;
264  }
265 
266  //Get use Class
267  private bool getuclass(string VEH)
268  {
269  if (VEH.IndexOf("_" + Constants.strHybrid) > 0)
270  {
272  return true;
273  }
274  else if (VEH.IndexOf("_" + Constants.strSU) > 0)
275  {
277  return true;
278  }
279  else
280  {
281  _uClass = "";
282  return true;
283  }
284  }
285 
286  //Set complete class string
287  public bool setclass(string VEH)
288  {
289  //Get the classes
290  if (!getvclass(VEH)) return false;
291  if (!geteclass(VEH)) return false;
292  if (!getpclass(VEH)) return false;
293  if (!getsclass(VEH)) return false;
294  if (!getuclass(VEH)) return false;
295 
296  if (VEH.LastIndexOf(@"\") <= 0)
297  _Class = VEH;
298  else
299  {
300  string vehstr = VEH.Substring(VEH.LastIndexOf(@"\") + 1, VEH.Length - VEH.LastIndexOf(@"\") - 1);
301  _Class = vehstr.Substring(0, vehstr.IndexOf("."));
302  }
303  return true;
304  }
305  #endregion
306  }
307 }
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 strLPG
Definition: cpp/Constants.h:61
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)
std::string _commentPrefix
Definition: cpp/Helpers.h:65
bool getsclass(const std::string &VEH)
bool getvclass(const std::string &VEH)
Definition: cpp/Helpers.cpp:95
bool setclass(string VEH)
std::string _eClass
Definition: cpp/Helpers.h:40
std::string _sClass
Definition: cpp/Helpers.h:50
std::string _vClass
Definition: cpp/Helpers.h:35
bool geteclass(string VEH)
bool getpclass(string VEH)
bool getuclass(string VEH)
bool getsclass(string VEH)
std::string _PHEMDataV
Definition: cpp/Helpers.h:70
std::string _Class
Definition: cpp/Helpers.h:55
std::string _ErrMsg
Definition: cpp/Helpers.h:60
bool getvclass(string VEH)
@ value
the parser finished reading a JSON value