52 List<double> Velocity,
53 List<double> Gradient,
54 out List<VehicleResult> VehicleResultsOrg,
55 bool fleetMix =
false,
56 string CommentPref =
"c")
61 List<VehicleResult> _VehicleResult =
new List<VehicleResult>();
67 Helper.CommentPrefix = CommentPref;
70 for (i = 0; i < DataFiles.Count; i++)
72 if ((DataFiles[i].LastIndexOf(
@"\")) >= 0)
79 _DataPath.Add(DataFiles[i + 1].Substring(0, DataFiles[i + 1].LastIndexOf(
@"\")));
80 _DataPath.Add(DataFiles[i + 1].Substring(0, DataFiles[i + 1].LastIndexOf(
@"\")));
81 _DataPath.Add(DataFiles[i + 1].Substring(0, DataFiles[i + 1].LastIndexOf(
@"\")));
99 VehicleResultsOrg =
null;
105 VehicleResultsOrg =
null;
115 VehicleResultsOrg =
null;
125 VehicleResultsOrg =
null;
131 for (i = 1; i <= Time.Count - 1; i++)
134 acc = (Velocity[i] - Velocity[i - 1]) / (Time[i] - Time[i - 1]);
145 VehicleResultsOrg =
null;
149 VehicleResultsOrg = _VehicleResult;
244 public bool ExportData(
string path,
string vehicle, List<VehicleResult> _VehicleResult)
246 if (path ==
null || vehicle ==
null || _VehicleResult ==
null || _VehicleResult.Count == 0)
return false;
249 StringBuilder allLines =
new StringBuilder();
250 string lineEnding =
"\r\n";
252 allLines.AppendLine(
"Vehicletype: ," + vehicle);
253 allLines.AppendLine(
"Time, Speed, Gradient, Accelaration, Engine power raw, P_pos, P_norm_rated, P_norm_drive, FC, Electric Power, CO2, NOx, CO, HC, PM");
254 allLines.AppendLine(
"[s], [m/s], [%], [m/s^2], [kW], [kW], [-], [-], [g/h], [kWh/h], [g/h], [g/h], [g/h], [g/h], [g/h]");
257 foreach (VehicleResult Result
in _VehicleResult)
259 allLines.Append(Result.Time.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
260 allLines.Append(Result.Speed.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
261 allLines.Append(Result.Grad.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
262 allLines.Append(Result.Accelaration.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
263 allLines.Append(Result.Power.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
264 allLines.Append(Result.PPos.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
265 allLines.Append(Result.PNormRated.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
266 allLines.Append(Result.PNormDrive.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
267 allLines.Append(Result.EmissionData.FC.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
268 allLines.Append(Result.EmissionData.FCel.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
269 allLines.Append(Result.EmissionData.CO2.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
270 allLines.Append(Result.EmissionData.NOx.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
271 allLines.Append(Result.EmissionData.CO.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
272 allLines.Append(Result.EmissionData.HC.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
273 allLines.Append(Result.EmissionData.PM.ToString(
"0.0000", CultureInfo.InvariantCulture) + lineEnding);
277 if (path.IndexOf(
".", 0) < 0)
279 path = path +
".sta";
283 StreamWriter file =
new StreamWriter(path);
284 file.WriteLine(allLines);
294 public bool ExportSumData(
string path,
string vehicle,
string cycle, VehicleResult _VehicleResult)
296 if (path ==
null || vehicle ==
null || cycle ==
null || _VehicleResult ==
null)
return false;
297 StringBuilder allLines =
new StringBuilder();
299 if (path.IndexOf(
".", 0) < 0)
301 path = path +
".erg";
304 if (!File.Exists(path))
307 allLines.AppendLine(
"PHEMLight Results");
308 allLines.AppendLine(
"");
309 allLines.AppendLine(
"Vehicle, Cycle, Time, Speed, Gradient, Accelaration, Engine power raw, P_pos, P_norm_rated, P_norm_drive, FC, Electric Power, CO2, NOx, CO, HC, PM");
310 allLines.AppendLine(
"[-], [-], [s], [km/h], [%], [m/s^2], [kW], [kW], [-], [-], [g/km], [kWh/km], [g/km], [g/km], [g/km], [g/km], [g/km]");
314 allLines.Append(vehicle +
",");
315 allLines.Append(cycle +
",");
316 allLines.Append(_VehicleResult.Time.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
317 allLines.Append(_VehicleResult.Speed.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
318 allLines.Append(_VehicleResult.Grad.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
319 allLines.Append(_VehicleResult.Accelaration.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
320 allLines.Append(_VehicleResult.Power.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
321 allLines.Append(_VehicleResult.PPos.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
322 allLines.Append(_VehicleResult.PNormRated.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
323 allLines.Append(_VehicleResult.PNormDrive.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
324 allLines.Append(_VehicleResult.EmissionData.FC.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
325 allLines.Append(_VehicleResult.EmissionData.FCel.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
326 allLines.Append(_VehicleResult.EmissionData.CO2.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
327 allLines.Append(_VehicleResult.EmissionData.NOx.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
328 allLines.Append(_VehicleResult.EmissionData.CO.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
329 allLines.Append(_VehicleResult.EmissionData.HC.ToString(
"0.0000", CultureInfo.InvariantCulture) +
",");
330 allLines.Append(_VehicleResult.EmissionData.PM.ToString(
"0.0000", CultureInfo.InvariantCulture));
335 StreamWriter file =
new StreamWriter(path,
true);
336 file.WriteLine(allLines);
350 double sum_speed = 0;
352 double sum_power = 0;
354 double sum_pNormRated = 0;
355 double sum_pNormDrive = 0;
365 if (_VehicleResult ==
null || _VehicleResult.Count == 0)
return new VehicleResult(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
368 foreach (VehicleResult Result
in _VehicleResult)
370 sum_speed += Result.Speed * 3.6;
371 sum_power += Result.Power;
372 if (Result.PPos > 0) { sum_pPos += Result.PPos; }
373 sum_grad += Result.Grad;
374 sum_pNormRated += Result.PNormRated;
375 sum_pNormDrive += Result.PNormDrive;
376 sum_acc += Result.Accelaration;
377 sum_fcel += Result.EmissionData.FCel;
378 sum_fc += Result.EmissionData.FC;
379 sum_cO2 += Result.EmissionData.CO2;
380 sum_nOx += Result.EmissionData.NOx;
381 sum_hC += Result.EmissionData.HC;
382 sum_pM += Result.EmissionData.PM;
383 sum_cO += Result.EmissionData.CO;
387 sum_time = _VehicleResult[_VehicleResult.Count - 1].Time - _VehicleResult[0].Time;
388 sum_power /= _VehicleResult.Count;
389 sum_pPos /= _VehicleResult.Count;
390 sum_grad /= _VehicleResult.Count;
391 sum_pNormRated /= _VehicleResult.Count;
392 sum_pNormDrive /= _VehicleResult.Count;
393 sum_acc /= _VehicleResult.Count;
397 sum_fcel /= sum_speed;
398 sum_cO2 /= sum_speed;
399 sum_nOx /= sum_speed;
414 sum_speed /= _VehicleResult.Count;
416 return new VehicleResult(sum_time,
bool CALC_Array(List< string > DataFiles, List< double > Time, List< double > Velocity, List< double > Gradient, out List< VehicleResult > VehicleResultsOrg, bool fleetMix=false, string CommentPref="c")
bool CALC_Single(List< string > DataFiles, double Time, double Velocity, double acc, double Gradient, out List< VehicleResult > VehicleResultsOrg, bool fleetMix=false, string CommentPref="c")