Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit ac73a927 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

Merge branch 'feature/VECTO-1731-declaration-mode-xev-primary-bus' of...

Merge branch 'feature/VECTO-1731-declaration-mode-xev-primary-bus' of https://citnet.tech.ec.europa.eu/CITnet/stash/scm/vecto/mq_vecto-dev into feature/VECTO-1731-declaration-mode-xev-primary-bus

# Conflicts:
#	VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs
parents fd2d9704 1c4b1df5
No related branches found
No related tags found
No related merge requests found
......@@ -330,8 +330,11 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.CompletedBus.Gener
public class PEV_E3 : BatteryElectric { }
public class PEV_E4 : BatteryElectric { }
public class PEV_E_IEPC : BatteryElectric { }
public class PEV_E_IEPC : BatteryElectric
{
protected override IGearboxDataAdapter GearboxDataAdapter { get; } = new GenericCompletedBusIEPCGearboxDataAdapter();
}
......
......@@ -1151,7 +1151,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen
{
CompressorMap = DeclarationData.BusAuxiliaries.GetCompressorMap(primaryBusAuxiliaries.PneumaticSupply),
CompressorGearEfficiency = Constants.BusAuxiliaries.PneumaticUserConfig.CompressorGearEfficiency,
CompressorGearRatio = primaryVehicle.VehicleType == VectoSimulationJobType.BatteryElectricVehicle
CompressorGearRatio = primaryVehicle.ArchitectureID.IsBatteryElectricVehicle()
? 0 : primaryBusAuxiliaries.PneumaticSupply.Ratio,
SmartAirCompression = primaryBusAuxiliaries.PneumaticSupply.SmartAirCompression,
SmartRegeneration = primaryBusAuxiliaries.PneumaticSupply.SmartRegeneration,
......
......@@ -1005,8 +1005,19 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.CompletedBusRun
protected override void CreateGearboxAndGearshiftData(VectoRunData runData)
{
throw new NotImplementedException();
}
runData.GearshiftParameters =
DataAdapterGeneric.CreateGearshiftData(
runData.AxleGearData?.AxleGear.Ratio ?? 1.0,
null,
GearboxType.APTN,
PrimaryVehicle.Components.IEPC.Gears.Count
);
var shiftStrategyName =
PowertrainBuilder.GetShiftStrategyName(GearboxType.APTN,
PrimaryVehicle.VehicleType);
runData.GearboxData = DataAdapterGeneric.CreateGearboxData(PrimaryVehicle, runData,
ShiftPolygonCalculator.Create(shiftStrategyName, runData.GearshiftParameters));
}
#endregion
......
......@@ -88,6 +88,7 @@ public class PrimaryBusSimulation
TestCase(@"PrimaryCoach_S2_Base_AMT.RSLT_VIF.xml", @"HEV_completedBus_2.xml", 1, TestName = "2nd Amendment CompletedBus Coach HEV S2"),
TestCase(@"PrimaryCityBus_IEPC-S_Base.RSLT_VIF.xml", @"HEV_completedBus_2.xml", 1, TestName = "2nd Amendment CompletedBus CityBus HEV IEPC-S"),
TestCase(@"exempted_primary_heavyBus.RSLT_VIF.xml", @"exempted_completedBus_input_full.xml", 1, TestName = "2nd Amendment CompletedBus Exempted"),
TestCase(@"IHPC", @"IHPC_completed", 1, TestName="2nd Amendment Completed Bus IHPC")
]
public void CompletedBusSimulationTest(string vifFile, string completed, int runIdx)
{
......
using System.IO;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCore.InputData.Reader.ComponentData;
using TUGraz.VectoCore.Models.Declaration;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
namespace TUGraz.VectoCore.Tests.Utils
{
public class TestDeclarationCycleFactory : IDeclarationCycleFactory
{
private const string BASE_PATH = "Resources/Missions/";
public TestDeclarationCycleFactory()
{
}
public string Variant { get; set; } = "Short_10";
public virtual DrivingCycleData GetDeclarationCycle(Mission mission)
{
return ReadDeclarationCycle(mission.MissionType);
}
protected virtual DrivingCycleData ReadDeclarationCycle(MissionType missionType)
{
var cycleFile = Path.Combine(BASE_PATH, Variant,
missionType.ToString().Replace("EMS", "") + ".vdri");
if (File.Exists(cycleFile)) {
var cycle = File.OpenRead(cycleFile);
return DrivingCycleDataReader.ReadFromStream(cycle, CycleType.DistanceBased, "", false);
}
throw new VectoException($"Cycle data for mission type {missionType} not found!");
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.InputData.Reader.ComponentData;
using TUGraz.VectoCore.Models.Declaration;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Impl;
namespace TUGraz.VectoCore.Tests.Utils
{
public class TestDeclarationCycleFactoryVariant : IDeclarationCycleFactory
{
private const string BASE_PATH = "Resources/Missions/";
public TestDeclarationCycleFactoryVariant() { }
public string Variant { get; set; } = "Short_10";
public virtual DrivingCycleData GetDeclarationCycle(Mission mission)
{
return ReadDeclarationCycle(mission.MissionType);
}
protected virtual DrivingCycleData ReadDeclarationCycle(MissionType missionType)
{
var cycleFile = Path.Combine(BASE_PATH, Variant,
missionType.ToString().Replace("EMS", "") + ".vdri");
if (File.Exists(cycleFile)) {
var cycle = File.OpenRead(cycleFile);
return DrivingCycleDataReader.ReadFromStream(cycle, CycleType.DistanceBased, "", false);
}
throw new VectoException($"Cycle data for mission type {missionType} not found!");
}
}
public class TestDeclarationCycleFactoryStartPoint : DeclarationCycleFactory
{
private readonly Dictionary<MissionType, (Meter start, Meter distance)> _startPointDict = new Dictionary<MissionType, (Meter start, Meter distance)>();
#region Implementation of IDeclarationCycleFactory
/// <summary>
/// Sets start point for specific mission
/// </summary>
/// <param name="missionType"></param>
/// <param name="startPoint"></param>
/// <param name="distance"></param>
public void SetStartPoint(MissionType missionType, Meter startPoint, Meter distance = null)
{
_startPointDict[missionType] = (start: startPoint, distance: distance);
}
/// <summary>
/// Sets start point for all missions
/// </summary>
/// <param name="startPoint"></param>
/// <param name="distance"></param>
public void SetStartPoint(Meter startPoint, Meter distance = null)
{
foreach (var missionType in Enum.GetValues<MissionType>()) {
_startPointDict[missionType] = (start: startPoint, distance: distance);
}
}
public override DrivingCycleData GetDeclarationCycle(Mission mission)
{
var cycle = base.GetDeclarationCycle(mission);
if (_startPointDict.TryGetValue(mission.MissionType, out var entry)) {
RestrictCycle(cycle, entry);
}
return cycle;
}
private void RestrictCycle(DrivingCycleData cycle, (Meter start, Meter distance) startPoint)
{
var entries = cycle.Entries;
DrivingCycleData.DrivingCycleEntry startEntry = entries.First();
DrivingCycleData.DrivingCycleEntry endEntry = entries.Last();
startEntry = entries
.Where(e => e.Distance.IsSmallerOrEqual(startPoint.start) &&
e.VehicleTargetSpeed.IsEqual(0)) //Select all points before startpoint
.MinBy(e => startPoint.start - e.Distance) ?? startEntry; //select the nearest one;
//remove entries before selected start point
//var startIdx = entries.FindIndex(e => e.Distance.IsEqual(startEntry.Distance));
//entries.RemoveRange(0, startIdx);
if (startPoint.distance != null) {
var endIdx = entries.FindIndex(e =>
(e.Distance - startEntry.Distance).IsGreaterOrEqual(startPoint.distance) &&
e.VehicleTargetSpeed.IsEqual(0));
if (endIdx != -1) {
endEntry = entries[endIdx];
}
}
entries.RemoveAll(e =>
e.Distance.IsSmaller(startEntry.Distance) || e.Distance.IsGreater(endEntry.Distance));
}
#endregion
}
}
\ No newline at end of file
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