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 8a51c928 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

adding lookup table for tyre efficiency labels

parent 45956f45
No related branches found
No related tags found
No related merge requests found
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public sealed class TyreClass : LookupData
{
private readonly List<Entry> _data = new List<Entry>();
public string Lookup(double rrc)
{
var rrcRounded = Math.Round(rrc * 1000, 1, MidpointRounding.AwayFromZero);
var entries = _data.FindAll(x => x.RRCMin <= rrcRounded && x.RRCMax >= rrcRounded);
return entries.Count == 0 ? "G" : entries.First().Label;
}
#region Overrides of LookupData
protected override string ResourceId { get { return DeclarationData.DeclarationDataResourcePrefix + ".TyreLabeling.csv"; } }
protected override string ErrorMessage { get { return "No Tyre class found for RRC {0}"; } }
protected override void ParseData(DataTable table)
{
foreach (DataRow row in table.Rows) {
_data.Add(new Entry {
RRCMin = row.ParseDouble("rrc_min"),
RRCMax = row.ParseDouble("rrc_max"),
Label = row.Field<string>("energyefficiencyclass")
});
}
}
#endregion
private class Entry
{
public double RRCMin;
public double RRCMax;
public string Label;
}
}
}
......@@ -40,6 +40,7 @@ namespace TUGraz.VectoCore.Models.Declaration
public sealed class Wheels : LookupData<string, Wheels.Entry>
{
private string[] _dimensions;
public TyreClass TyreClass = new TyreClass();
protected override string ResourceId
{
......
RRC_min [kg/t] , RRC_max [kg/t] , Energy Efficiency Class
0 , 4.0 , A
4.1 , 5.0 , B
5.1 , 6.0 , C
6.1 , 7.0 , D
7.1 , 8.0 , E
8.1 , 999 , F
\ No newline at end of file
......@@ -175,6 +175,7 @@
<Compile Include="Models\Declaration\FuelData.cs" />
<Compile Include="Models\Declaration\PTOTransmission.cs" />
<Compile Include="Models\Declaration\IDeclarationAuxiliaryTable.cs" />
<Compile Include="Models\Declaration\TyreClass.cs" />
<Compile Include="Models\Declaration\WeightingFactors.cs" />
<Compile Include="Models\Declaration\WeightingGroups.cs" />
<Compile Include="Models\SimulationComponent\Data\AngledriveData.cs" />
......@@ -473,6 +474,7 @@
<EmbeddedResource Include="Resources\Declaration\ADAS\ADAS_Combinations.csv" />
<EmbeddedResource Include="Resources\Declaration\CO2Standards\MissionProfileWeights.csv" />
<EmbeddedResource Include="Resources\Declaration\CO2Standards\WeightingGroups.csv" />
<EmbeddedResource Include="Resources\Declaration\TyreLabeling.csv" />
<None Include="Utils\VectoVersionCore.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>VectoVersionCore.cs</LastGenOutput>
......
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