Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit bb38d661 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

DrivingCycleDataReader: Aux Column check corrected

parent e1e6a831
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,7 @@ using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.InputData.Reader
{
public class DrivingCycleDataReader : LoggingObject
public static class DrivingCycleDataReader
{
/// <summary>
/// Detects the appropriate cycle type for a cycle in a DataTable.
......@@ -136,7 +136,8 @@ namespace TUGraz.VectoCore.InputData.Reader
public static DrivingCycleData ReadFromDataTable(DataTable data, string name, bool crossWindRequired)
{
if (data == null) {
Logger<DistanceBasedCycleDataParser>().Warn("Invalid data for DrivingCycle -- dataTable is null");
LogManager.GetLogger(typeof(DrivingCycleDataReader).FullName)
.Warn("Invalid data for DrivingCycle -- dataTable is null");
throw new VectoException("Invalid data for DrivingCycle -- dataTable is null");
}
return ReadFromDataTable(data, DetectCycleType(data), name, crossWindRequired);
......@@ -153,7 +154,8 @@ namespace TUGraz.VectoCore.InputData.Reader
public static DrivingCycleData ReadFromDataTable(DataTable data, CycleType type, string name, bool crossWindRequired)
{
if (data == null) {
Logger<DistanceBasedCycleDataParser>().Warn("Invalid data for DrivingCycle -- dataTable is null");
LogManager.GetLogger(typeof(DrivingCycleDataReader).FullName)
.Warn("Invalid data for DrivingCycle -- dataTable is null");
throw new VectoException("Invalid data for DrivingCycle -- dataTable is null");
}
var entries = GetDataParser(type).Parse(data, crossWindRequired).ToList();
......@@ -232,7 +234,7 @@ namespace TUGraz.VectoCore.InputData.Reader
distance = entry.Distance;
}
Logger<DrivingCycleDataReader>()
LogManager.GetLogger(typeof(DrivingCycleDataReader).FullName)
.Info("Data loaded. Number of Entries: {0}, filtered Entries: {1}", entries.Count, filtered.Count);
entries = filtered;
......@@ -243,13 +245,14 @@ namespace TUGraz.VectoCore.InputData.Reader
private static void AdjustDistanceAfterStop(List<DrivingCycleData.DrivingCycleEntry> entries)
{
var currentIt = entries.GetEnumerator();
var nextIt = entries.GetEnumerator();
nextIt.MoveNext();
while (currentIt.MoveNext() && nextIt.MoveNext()) {
if (currentIt.Current != null && !currentIt.Current.StoppingTime.IsEqual(0)) {
if (nextIt.Current != null) {
nextIt.Current.Distance = currentIt.Current.Distance;
using (var currentIt = entries.GetEnumerator())
using (var nextIt = entries.GetEnumerator()) {
nextIt.MoveNext();
while (currentIt.MoveNext() && nextIt.MoveNext()) {
if (currentIt.Current != null && !currentIt.Current.StoppingTime.IsEqual(0)) {
if (nextIt.Current != null) {
nextIt.Current.Distance = currentIt.Current.Distance;
}
}
}
}
......@@ -297,7 +300,6 @@ namespace TUGraz.VectoCore.InputData.Reader
public const string VehicleSpeed = "v";
public const string RoadGradient = "grad";
public const string StoppingTime = "stop";
public const string AuxiliarySupplyPower = "Aux_";
public const string EngineSpeed = "n";
public const string Gear = "gear";
public const string AdditionalAuxPowerDemand = "Padd";
......@@ -320,7 +322,7 @@ namespace TUGraz.VectoCore.InputData.Reader
IEnumerable<DrivingCycleData.DrivingCycleEntry> Parse(DataTable table, bool crossWindRequired);
}
private abstract class AbstractCycleDataParser : ICycleDataParser
private abstract class AbstractCycleDataParser : LoggingObject, ICycleDataParser
{
protected static bool CheckColumns(string[] header, IEnumerable<string> allowedCols, IEnumerable<string> requiredCols,
bool throwExceptions, bool allowAux)
......@@ -334,7 +336,7 @@ namespace TUGraz.VectoCore.InputData.Reader
}
if (allowAux) {
header = header.Where(c => !c.StartsWith(Fields.AuxiliarySupplyPower)).ToArray();
header = header.Where(c => !c.ToUpper().StartsWith(Constants.Auxiliaries.Prefix)).ToArray();
}
diff = header.Except(allowedCols).ToList();
......@@ -488,8 +490,9 @@ namespace TUGraz.VectoCore.InputData.Reader
var containsBoth = header.Contains(Fields.EngineTorque) && header.Contains(Fields.EnginePower);
if (containsBoth) {
Logger<DrivingCycleDataReader>().Warn("Found column '{0}' and column '{1}': Only column '{0}' will be used.",
Fields.EngineTorque, Fields.EnginePower);
LogManager.GetLogger(typeof(EngineOnlyCycleDataParser).FullName)
.Warn("Found column '{0}' and column '{1}': Only column '{0}' will be used.",
Fields.EngineTorque, Fields.EnginePower);
}
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment