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

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

adding testcase for minimal powertrain

parent b989f15c
No related branches found
No related tags found
No related merge requests found
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TUGraz.VectoCore.FileIO.Reader.Impl;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Declaration;
using TUGraz.VectoCore.Models.Simulation.Impl;
using TUGraz.VectoCore.Models.SimulationComponent;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Impl;
using TUGraz.VectoCore.Tests.Utils;
using TUGraz.VectoCore.Utils;
using Wheels = TUGraz.VectoCore.Models.SimulationComponent.Impl.Wheels;
namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns
{
[TestClass]
public class MinimalPowertrain
{
public const string CycleFile = @"TestData\Cycles\Coach_24t_xshort.vdri";
public const string EngineFile = @"TestData\Components\24t Coach.veng";
[TestMethod]
public void TestWheelsAndEngine()
{
var engineData = EngineeringModeSimulationDataReader.CreateEngineDataFromFile(EngineFile);
var cycleData = DrivingCycleData.ReadFromFileDistanceBased(CycleFile);
var vehicleData = new VehicleData() {
AxleConfiguration = AxleConfiguration.AxleConfig_4x2,
CrossSectionArea = 0.SI<SquareMeter>(),
CrossWindCorrectionMode = CrossWindCorrectionMode.NoCorrection,
CurbWeight = 1000.SI<Kilogram>(),
CurbWeigthExtra = 0.SI<Kilogram>(),
Loading = 0.SI<Kilogram>(),
DynamicTyreRadius = 0.56.SI<Meter>(),
Retarder = new RetarderData() { Type = RetarderData.RetarderType.None },
AxleData = new List<Axle>(),
SavedInDeclarationMode = false,
};
var vehicleContainer = new VehicleContainer();
var cycle = new DistanceBasedDrivingCycle(vehicleContainer, cycleData);
dynamic tmp = AddComponent(cycle, new MockDriver(vehicleContainer));
tmp = AddComponent(tmp, new Vehicle(vehicleContainer, vehicleData));
tmp = AddComponent(tmp, new Wheels(vehicleContainer, vehicleData.DynamicTyreRadius));
AddComponent(tmp, new CombustionEngine(vehicleContainer, engineData));
var run = new VectoRun(vehicleContainer);
run.Run();
}
// ========================
protected virtual IDriver AddComponent(IDrivingCycleDemandDrivingCycle prev, IDriver next)
{
prev.InShaft().Connect(next.OutShaft());
return next;
}
protected virtual IVehicle AddComponent(IDriver prev, IVehicle next)
{
prev.InShaft().Connect(next.OutShaft());
return next;
}
protected virtual IWheels AddComponent(IRoadPortInProvider prev, IWheels next)
{
prev.InPort().Connect(next.OutPort());
return next;
}
protected virtual void AddComponent(IWheels prev, IOutShaft next)
{
prev.InShaft().Connect(next.OutShaft());
//return next;
}
protected virtual IPowerTrainComponent AddComponent(IPowerTrainComponent prev, IPowerTrainComponent next)
{
prev.InShaft().Connect(next.OutShaft());
return next;
}
protected virtual void AddComponent(IPowerTrainComponent prev, IOutShaft next)
{
prev.InShaft().Connect(next.OutShaft());
}
}
}
\ No newline at end of file
using System;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Tests.Utils
{
public class MockDriver : VectoSimulationComponent, IDriver, IDrivingCycleDemandOutPort, IDriverDemandInPort
{
private IDriverDemandOutPort _next;
public MockDriver(IVehicleContainer container) : base(container) {}
public override void CommitSimulationStep(IModalDataWriter writer) {}
public IDrivingCycleDemandOutPort OutShaft()
{
return this;
}
public IDriverDemandInPort InShaft()
{
return this;
}
public IResponse Request(TimeSpan absTime, TimeSpan dt, MeterPerSecond velocity, Radian gradient)
{
var acc = 0.SI<MeterPerSquareSecond>();
return _next.Request(absTime, dt, acc, 0.SI<Radian>());
}
public void Connect(IDriverDemandOutPort other)
{
_next = other;
}
}
}
\ No newline at end of file
......@@ -46,6 +46,7 @@
<Reference Include="Common.Logging.NLog31">
<HintPath>..\packages\Common.Logging.NLog31.3.0.0\lib\net40\Common.Logging.NLog31.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="NLog">
<HintPath>..\packages\NLog.3.2.0.0\lib\net45\NLog.dll</HintPath>
</Reference>
......@@ -70,6 +71,7 @@
<ItemGroup>
<Compile Include="Exceptions\ExceptionTests.cs" />
<Compile Include="Integration\EngineOnlyCycle\EngineOnlyCycleTest.cs" />
<Compile Include="Integration\SimulationRuns\MinimalPowertrain.cs" />
<Compile Include="Models\Declaration\DeclarationDataTest.cs" />
<Compile Include="Models\SimulationComponentData\AccelerationCurveTest.cs" />
<Compile Include="Models\SimulationComponentData\FuelConsumptionMapTest.cs" />
......@@ -84,6 +86,7 @@
<Compile Include="Models\SimulationComponent\VehicleTest.cs" />
<Compile Include="Models\Simulation\DrivingCycleTests.cs" />
<Compile Include="Utils\AssertHelper.cs" />
<Compile Include="Utils\MockDriver.cs" />
<Compile Include="Utils\ResultFileHelper.cs" />
<Compile Include="Utils\MockPorts.cs" />
<Compile Include="Models\Simulation\SimulationTests.cs" />
......
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