Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

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

Implemented Wheels, Test for Wheels

parent adfac040
Branches
Tags
No related merge requests found
...@@ -9,15 +9,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -9,15 +9,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public class Wheels : VectoSimulationComponent, IWheels, IFvOutPort, ITnInPort public class Wheels : VectoSimulationComponent, IWheels, IFvOutPort, ITnInPort
{ {
private ITnOutPort _outPort; private ITnOutPort _outPort;
private Meter _dynamicWheelRadius;
public Wheels(IVehicleContainer cockpit) public Wheels(IVehicleContainer cockpit, Meter rdyn)
: base(cockpit) {} : base(cockpit)
{
_dynamicWheelRadius = rdyn;
}
#region IRoadPortOutProvider #region IRoadPortOutProvider
IFvOutPort IRoadPortOutProvider.OutPort() IFvOutPort IRoadPortOutProvider.OutPort()
{ {
throw new NotImplementedException(); return this;
} }
#endregion #endregion
...@@ -26,7 +30,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -26,7 +30,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
ITnInPort IInShaft.InShaft() ITnInPort IInShaft.InShaft()
{ {
throw new NotImplementedException(); return this;
} }
#endregion #endregion
...@@ -35,7 +39,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -35,7 +39,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
IResponse IFvOutPort.Request(TimeSpan absTime, TimeSpan dt, Newton force, MeterPerSecond velocity) IResponse IFvOutPort.Request(TimeSpan absTime, TimeSpan dt, Newton force, MeterPerSecond velocity)
{ {
throw new NotImplementedException(); NewtonMeter torque = (force * _dynamicWheelRadius).Cast<NewtonMeter>();
var angularVelocity = (velocity / _dynamicWheelRadius).Cast<PerSecond>();
return _outPort.Request(absTime, dt, torque, angularVelocity);
} }
#endregion #endregion
......
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
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.Utils;
namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
{
[TestClass]
public class WheelsTest
{
private const string VehicleDataFile = @"TestData\Components\24t Coach.vveh";
[TestMethod]
public void WheelsRequestTest()
{
var container = new VehicleContainer();
var vehicleData = VehicleData.ReadFromFile(VehicleDataFile);
IWheels wheels = new Wheels(container, vehicleData.DynamicTyreRadius);
var mockPort = new MockTnOutPort();
wheels.InShaft().Connect(mockPort);
var requestPort = wheels.OutPort();
var absTime = TimeSpan.FromSeconds(0);
var dt = TimeSpan.FromSeconds(1);
var force = 5000.SI<Newton>();
var velocity = 20.SI<MeterPerSecond>();
var retVal = requestPort.Request(absTime, dt, force, velocity);
Assert.AreEqual(250.0, mockPort.Torque.Double(), 0.0001);
Assert.AreEqual(38.4615384615, mockPort.AngularVelocity.Double(), 0.0001);
}
}
}
\ No newline at end of file
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
<Compile Include="Models\SimulationComponent\CombustionEngineTest.cs" /> <Compile Include="Models\SimulationComponent\CombustionEngineTest.cs" />
<Compile Include="Models\SimulationComponent\GearboxTest.cs" /> <Compile Include="Models\SimulationComponent\GearboxTest.cs" />
<Compile Include="Models\SimulationComponent\RetarderTest.cs" /> <Compile Include="Models\SimulationComponent\RetarderTest.cs" />
<Compile Include="Models\SimulationComponent\WheelsTest.cs" />
<Compile Include="Models\SimulationComponent\VehicleTest.cs" /> <Compile Include="Models\SimulationComponent\VehicleTest.cs" />
<Compile Include="Models\Simulation\DrivingCycleTests.cs" /> <Compile Include="Models\Simulation\DrivingCycleTests.cs" />
<Compile Include="Models\SimulationComponent\MockPorts.cs" /> <Compile Include="Models\SimulationComponent\MockPorts.cs" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment