Select Git revision
PwheelModeTests.cs
Forked from
VECTO / VECTO Sim
Source project has a limited visibility.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
PwheelModeTests.cs 7.05 KiB
/*
* Copyright 2015, 2016 Graz University of Technology,
* Institute of Internal Combustion Engines and Thermodynamics,
* Institute of Technical Informatics
*
* Licensed under the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://ec.europa.eu/idabc/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
using System.IO;
using System.Text;
using System.Data;
using System.Linq;
using TUGraz.VectoCore.Utils;
using System.Collections.Generic;
using TUGraz.VectoCore.OutputData;
using TUGraz.VectoCore.Tests.Utils;
using TUGraz.VectoCore.InputData.Reader;
using TUGraz.VectoCore.OutputData.FileIO;
using TUGraz.VectoCore.InputData.FileIO.JSON;
using TUGraz.VectoCore.Models.Simulation.Impl;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine;
using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox;
using TUGraz.VectoCore.Models.SimulationComponent.Impl;
namespace TUGraz.VectoCore.Tests.Models.Simulation
{
[TestClass]
public class PwheelModeTests
{
/// <summary>
/// Test if the cycle file can be read.
/// </summary>
/// <remarks>VECTO-177</remarks>
[TestMethod]
public void Pwheel_ReadCycle_Test()
{
var container = new VehicleContainer();
var inputData = @"<t>,<Pwheel>,<gear>,<n>,<Padd>
1,89,2,1748,1.300
2,120,2,1400,0.4";
var cycleFile = new MemoryStream(Encoding.UTF8.GetBytes(inputData));
var drivingCycle = DrivingCycleDataReader.ReadFromStream(cycleFile, CycleType.PWheel);
var gearbox = new CycleGearbox(container,
new GearboxData {
Gears = new Dictionary<uint, GearData> { { 1, new GearData { Ratio = 2.0 } }, { 2, new GearData { Ratio = 3.5 } } }
});
var cycle = new PWheelCycle(container, drivingCycle, 2.3,
gearbox.ModelData.Gears.ToDictionary(g => g.Key, g => g.Value.Ratio));
Assert.AreEqual(container.CycleData.LeftSample.Time, 1.SI<Second>());
Assert.AreEqual(container.CycleData.RightSample.Time, 2.SI<Second>());
Assert.AreEqual(1748.RPMtoRad() / (2.3 * 3.5), container.CycleData.LeftSample.WheelAngularVelocity);
Assert.AreEqual(1400.RPMtoRad() / (2.3 * 3.5), container.CycleData.RightSample.WheelAngularVelocity);