3using System.Collections.Generic;
6using System.Threading.Tasks;
18 Year = DateTime.Now.Year;
20 DETFilePath = Path.Combine(PathCor,
"Deterioration.det");
25 #region ReadDetoriationFiles
37 public int Year {
get;
set; }
66 using (StreamReader r =
new StreamReader(
DETFilePath))
70 string json = r.ReadToEnd();
71 DETdata = JsonConvert.DeserializeObject<
DET>(json);
75 ErrMSG =
"Error during file read! " +
"(" +
DETFilePath +
")";
94 using (StreamReader r =
new StreamReader(
VMAFilePath))
98 string json = r.ReadToEnd();
99 VMAdata = JsonConvert.DeserializeObject<
VMA>(json);
103 ErrMSG =
"Error during file read! " +
"(" +
VMAFilePath +
")";
113 #region CalcDetoriation
118 DETFactors =
new Dictionary<string, double>();
124 foreach (
string Key
in DETdata.
Vehicle[Helper.
vClass].PropulsionClass[Helper.pClass].Emission.Keys)
126 string EUclass = Helper.
eClass.Replace(
"EU",
"EURO ");
131 string EUclassShort = EUclass.Substring(0, 6);
133 if (!
DETdata.
Vehicle[Helper.
vClass].PropulsionClass[Helper.pClass].Emission[Key].EUClass.ContainsKey(EUclass) &
134 DETdata.
Vehicle[Helper.
vClass].PropulsionClass[Helper.pClass].Emission[Key].EUClass.ContainsKey(EUclassShort))
135 EUclass = EUclassShort;
139 if (
DETdata.
Vehicle[Helper.
vClass].PropulsionClass[Helper.pClass].Emission[Key].EUClass.ContainsKey(EUclass))
141 List<double> Mileage =
DETdata.
Vehicle[Helper.
vClass].PropulsionClass[Helper.pClass].Emission[Key].Mileage;
142 List<double> Factor =
DETdata.
Vehicle[Helper.
vClass].PropulsionClass[Helper.pClass].Emission[Key].EUClass[EUclass];
145 for (
int i = 1; i < Mileage.Count; i++)
152 else if (i == Mileage.Count - 1 &&
VehMileage > Mileage[i])
203 if (
VMAdata.
Vehicle[Helper.
vClass].PropulsionClass[Helper.pClass].SizeClass.ContainsKey(Sclass))
205 string EUclass = Helper.
eClass.Replace(
"EU",
"EURO ");
210 string EUclassShort = EUclass.Substring(0, 6);
212 if (!
VMAdata.
Vehicle[Helper.
vClass].PropulsionClass[Helper.pClass].SizeClass[Sclass].EUClass.ContainsKey(EUclass) &
213 VMAdata.
Vehicle[Helper.
vClass].PropulsionClass[Helper.pClass].SizeClass[Sclass].EUClass.ContainsKey(EUclassShort))
214 EUclass = EUclassShort;
217 if (
VMAdata.
Vehicle[Helper.
vClass].PropulsionClass[Helper.pClass].SizeClass[Sclass].EUClass.ContainsKey(EUclass))
220 List<double> Factor =
VMAdata.
Vehicle[Helper.
vClass].PropulsionClass[Helper.pClass].SizeClass[Sclass].EUClass[EUclass];
221 int AnzYear =
Year - 2020 + 1;
222 Mileage = Factor[0] * Math.Pow(AnzYear, 3) + Factor[1] * Math.Pow(AnzYear, 2) + Factor[2] * AnzYear + Factor[3];
225 if (Mileage < 0) Mileage = 0;
266 string json = r.ReadToEnd();
271 ErrMSG =
"Error during file read! " +
" (" +
TNOxFilePath +
")";
281 #region Calculate TNOx
292 string EUclass = Helper.
eClass.Replace(
"EU",
"EURO ");
297 string EUclassShort = EUclass.Substring(0, 6);
301 EUclass = EUclassShort;
323 private double Interpolate(
double px,
double p1,
double p2,
double e1,
double e2)
328 return e1 + (px - p1) / (p2 - p1) * (e2 - e1);
337 public string Type {
get;
set; }
339 public Dictionary<string, VehicledataDET>
Vehicle {
get;
set; }
343 Vehicle =
new Dictionary<string, VehicledataDET>();
359 public Dictionary<string, EmissionClassDET>
Emission {
get;
set; }
363 Emission =
new Dictionary<string, EmissionClassDET>();
370 public Dictionary<string, List<double>>
EUClass {
get;
set; }
375 EUClass =
new Dictionary<string, List<double>>();
380 #region Vehicle Mileage
384 public string Type {
get;
set; }
386 public Dictionary<string, VehicledataVMA>
Vehicle {
get;
set; }
390 Vehicle =
new Dictionary<string, VehicledataVMA>();
406 public Dictionary<string, EmissionClassVMA>
SizeClass {
get;
set; }
410 SizeClass =
new Dictionary<string, EmissionClassVMA>();
416 public Dictionary<string, List<double>>
EUClass {
get;
set; }
420 EUClass =
new Dictionary<string, List<double>>();
429 public string Type {
get;
set; }
431 public Dictionary<string, Vehicledata>
Vehicle {
get;
set; }
435 Vehicle =
new Dictionary<string, Vehicledata>();
441 public Dictionary<string, EmissionClass>
EUClass {
get;
set; }
445 EUClass =
new Dictionary<string, EmissionClass>();
451 public double m {
get;
set; }
452 public double c {
get;
set; }
453 public List<double>
TB {
get;
set; }
457 TB =
new List<double>();
static const std::string strPKW
static const std::string strDiesel
static const std::string strLNF
Dictionary< string, VehicledataDET > Vehicle
Dictionary< string, List< double > > EUClass
Dictionary< string, List< double > > EUClass
Dictionary< string, EmissionClassDET > Emission
Dictionary< string, EmissionClassVMA > SizeClass
Dictionary< string, Vehicledata > Vehicle
Dictionary< string, VehicledataVMA > Vehicle
Dictionary< string, PropClassDET > PropulsionClass
Dictionary< string, EmissionClass > EUClass
Dictionary< string, PropClassVMA > PropulsionClass
bool ReadVMAFile(ref string ErrMSG)
bool IniDETfactor(Helpers Helper)
double GetMileage(Helpers Helper)
double Interpolate(double px, double p1, double p2, double e1, double e2)
bool ReadDet(ref string ErrMSG)
Dictionary< string, double > DETFactors
Correction(string PathCor)
bool ReadTNOx(ref string ErrMSG)
bool ReadDETFile(ref string ErrMSG)
bool IniTNOxfactor(Helpers Helper)
C++ TraCI client API implementation.