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

include HVAC Option 'None' in declaration mode

parent c3d047b5
No related branches found
No related tags found
No related merge requests found
......@@ -310,7 +310,8 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
aux.ID = Constants.Auxiliaries.IDs.SteeringPump;
break;
case AuxiliaryType.HVAC:
aux.PowerDemand = DeclarationData.HeatingVentilationAirConditioning.Lookup(mission, hvdClass);
aux.PowerDemand = DeclarationData.HeatingVentilationAirConditioning.Lookup(mission,
auxData.Technology.FirstOrDefault(), hvdClass);
aux.ID = Constants.Auxiliaries.IDs.HeatingVentilationAirCondition;
break;
case AuxiliaryType.PneumaticSystem:
......
......@@ -30,15 +30,19 @@
*/
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public sealed class HeatingVentilationAirConditioning : LookupData<MissionType, VehicleClass, Watt>,
public sealed class HeatingVentilationAirConditioning : LookupData<MissionType, string, VehicleClass, Watt>,
IDeclarationAuxiliaryTable
{
private List<string> Technologies;
protected override string ResourceId
{
get { return DeclarationData.DeclarationDataResourcePrefix + ".VAUX.HVAC-Table.csv"; }
......@@ -46,25 +50,29 @@ namespace TUGraz.VectoCore.Models.Declaration
protected override string ErrorMessage
{
get { return "Auxiliary Lookup Error: No value found for HVAC. Mission: '{0}', HDVClass: '{1}'"; }
get {
return "Auxiliary Lookup Error: No value found for HVAC. Mission: '{0}', Technology: '{1}' , HDVClass: '{2}'";
}
}
protected override void ParseData(DataTable table)
{
foreach (DataRow row in table.Rows) {
var hdvClass = VehicleClassHelper.Parse(row.Field<string>("hdvclass"));
var technology = row.Field<string>("technology");
foreach (DataColumn col in table.Columns) {
var value = row.ParseDoubleOrGetDefault(col.Caption, double.NaN);
if (col.Caption != "hdvclass" && !double.IsNaN(value)) {
Data[Tuple.Create(col.Caption.ParseEnum<MissionType>(), hdvClass)] = value.SI<Watt>();
if (col.Caption != "hdvclass" && col.Caption != "technology" && !double.IsNaN(value)) {
Data[Tuple.Create(col.Caption.ParseEnum<MissionType>(), technology, hdvClass)] = value.SI<Watt>();
}
}
}
Technologies = Data.Select(x => x.Key.Item2).Distinct().ToList();
}
public string[] GetTechnologies()
{
return new[] { "Default" };
return Technologies.ToArray();
}
}
}
\ No newline at end of file
......@@ -88,13 +88,30 @@ namespace TUGraz.VectoCore.Models.Declaration
public virtual TValue Lookup(TKey1 key1, TKey2 key2)
{
try {
return Data[new Tuple<TKey1, TKey2>(key1, key2)];
return Data[Tuple.Create(key1, key2)];
} catch (KeyNotFoundException) {
throw new VectoException(string.Format(ErrorMessage, key1, key2));
}
}
}
public abstract class LookupData<TKey1, TKey2, TKey3, TValue> : LookupData
{
protected readonly Dictionary<Tuple<TKey1, TKey2, TKey3>, TValue> Data =
new Dictionary<Tuple<TKey1, TKey2, TKey3>, TValue>();
public virtual TValue Lookup(TKey1 key1, TKey2 key2, TKey3 key3)
{
try {
return Data[Tuple.Create(key1, key2, key3)];
} catch (KeyNotFoundException) {
throw new VectoException(string.Format(ErrorMessage, key1, key2, key3));
}
}
//public abstract TValue Lookup(TKey1 key1, TKey2 key2, TKey3 key3);
}
public abstract class LookupData<TKey1, TKey2, TKey3, TKey4, TValue> : LookupData
{
public abstract TValue Lookup(TKey1 key1, TKey2 key2, TKey3 key3, TKey4 key4);
......
HDV Class , Long haul , Regional delivery , Urban delivery , Municipal utility , Construction
1 , , 150 , 150 , ,
2 , 200 , 200 , 150 , ,
3 , , 200 , 150 , ,
4 , 350 , 200 , , 300 ,
5 , 350 , 200 , , ,
9 , 350 , 200 , , 300 ,
10 , 350 , 200 , , ,
11 , 350 , 200 , , 300 , 200
12 , 350 , 200 , , , 200
16 , , , , , 200
Technology , HDV Class , Long haul , Regional delivery , Urban delivery , Municipal utility , Construction
None , 1 , 0 , 0 , 0 , 0 , 0
None , 2 , 0 , 0 , 0 , 0 , 0
None , 3 , 0 , 0 , 0 , 0 , 0
None , 4 , 0 , 0 , 0 , 0 , 0
None , 5 , 0 , 0 , 0 , 0 , 0
None , 9 , 0 , 0 , 0 , 0 , 0
None , 10 , 0 , 0 , 0 , 0 , 0
None , 11 , 0 , 0 , 0 , 0 , 0
None , 12 , 0 , 0 , 0 , 0 , 0
None , 16 , 0 , 0 , 0 , 0 , 0
#
Default , 1 , , 150 , 150 , ,
Default , 2 , 200 , 200 , 150 , ,
Default , 3 , , 200 , 150 , ,
Default , 4 , 350 , 200 , , 300 ,
Default , 5 , 350 , 200 , , ,
Default , 9 , 350 , 200 , , 300 ,
Default , 10 , 350 , 200 , , ,
Default , 11 , 350 , 200 , , 300 , 200
Default , 12 , 350 , 200 , , , 200
Default , 16 , , , , , 200
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