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

adding tests for gearbox data, transmission loss map, shift polygons

parent f366f1b0
Branches
Tags
No related merge requests found
...@@ -2,12 +2,20 @@ ...@@ -2,12 +2,20 @@
{ {
public class Gear public class Gear
{ {
public ShiftPolygon ShiftPolygon { get; set; } public ShiftPolygon ShiftPolygon { get; protected set; }
public TransmissionLossMap LossMap { get; set; } public TransmissionLossMap LossMap { get; protected set; }
public double Ratio { get; set; } public double Ratio { get; protected set; }
public bool TorqueConverterActive { get; set; } // TODO: think about refactoring... public bool TorqueConverterActive { get; protected set; } // TODO: think about refactoring...
public Gear(TransmissionLossMap lossMap, Gearbox.ShiftPolygon shiftPolygon, double ratio, bool torqueconverterActive)
{
LossMap = lossMap;
ShiftPolygon = shiftPolygon;
Ratio = ratio;
TorqueConverterActive = torqueconverterActive;
}
} }
} }
\ No newline at end of file
...@@ -31,15 +31,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox ...@@ -31,15 +31,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox
} else { } else {
var log = LogManager.GetLogger<ShiftPolygon>(); var log = LogManager.GetLogger<ShiftPolygon>();
log.WarnFormat( log.WarnFormat(
"ShiftPolygon: Header Line is not valid. Expected: '{0}, {1}, {2}', Got: '{4}'. Falling back to column index"); "ShiftPolygon: Header Line is not valid. Expected: '{0}, {1}, {2}', Got: '{3}'. Falling back to column index");
entries = CreateFromColumnIndizes(data); entries = CreateFromColumnIndizes(data);
} }
return new ShiftPolygon { _entries = entries }; return new ShiftPolygon { _entries = entries };
} }
public ShiftPolygonEntry GetDummyEntry() public ShiftPolygonEntry this[int i]
{ {
return _entries.First(); get { return _entries[i]; }
} }
private static bool HeaderIsValid(DataColumnCollection columns) private static bool HeaderIsValid(DataColumnCollection columns)
......
...@@ -75,12 +75,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox ...@@ -75,12 +75,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox
}).ToList(); }).ToList();
} }
public GearLossMapEntry GetDummyEntry() public GearLossMapEntry this[int i]
{ {
return _entries.First(); get { return _entries[i]; }
} }
public class GearLossMapEntry public class GearLossMapEntry
{ {
public PerSecond InputSpeed { get; set; } public PerSecond InputSpeed { get; set; }
......
...@@ -25,6 +25,20 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -25,6 +25,20 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
/// "ModelName": "Generic 24t Coach", /// "ModelName": "Generic 24t Coach",
/// "Inertia": 0.0, /// "Inertia": 0.0,
/// "TracInt": 1.0, /// "TracInt": 1.0,
/// "TqReserve": 20.0,
/// "SkipGears": true,
/// "ShiftTime": 2,
/// "EaryShiftUp": true,
/// "StartTqReserve": 20.0,
/// "StartSpeed": 2.0,
/// "StartAcc": 0.6,
/// "GearboxType": "AMT",
/// "TorqueConverter": {
/// "Enabled": false,
/// "File": "<NOFILE>",
/// "RefRPM": 0.0,
/// "Inertia": 0.0
/// }
/// "Gears": [ /// "Gears": [
/// { /// {
/// "Ratio": 3.240355, /// "Ratio": 3.240355,
...@@ -77,12 +91,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -77,12 +91,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
var shiftPolygon = !String.IsNullOrEmpty(gearSettings.ShiftPolygon) var shiftPolygon = !String.IsNullOrEmpty(gearSettings.ShiftPolygon)
? ShiftPolygon.ReadFromFile(Path.Combine(basePath, gearSettings.ShiftPolygon)) ? ShiftPolygon.ReadFromFile(Path.Combine(basePath, gearSettings.ShiftPolygon))
: null; : null;
var gear = new Gear { var gear = new Gear(lossMap, shiftPolygon, gearSettings.Ratio, gearSettings.TCactive);
LossMap = lossMap,
ShiftPolygon = shiftPolygon,
Ratio = gearSettings.Ratio,
TorqueConverterActive = gearSettings.TCactive
};
gearboxData._gearData.Add(gearboxData._gearData.Count, gear); gearboxData._gearData.Add(gearboxData._gearData.Count, gear);
} }
switch (d.Body.GearboxTypeStr) { switch (d.Body.GearboxTypeStr) {
...@@ -102,6 +111,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -102,6 +111,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
return gearboxData; return gearboxData;
} }
public int GearsCount()
{
return _data.Body.Gears.Count;
}
public Gear this[int i]
{
get { return _gearData[i]; }
}
public bool SavedInDeclarationMode public bool SavedInDeclarationMode
{ {
get { return _data.Body.SavedInDeclarationMode; } get { return _data.Body.SavedInDeclarationMode; }
......
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData
{ {
...@@ -7,12 +8,26 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData ...@@ -7,12 +8,26 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData
public class GearboxDataTest public class GearboxDataTest
{ {
protected const string GearboxFile = @"Testdata\Components\24t Coach.vgbx"; protected const string GearboxFile = @"Testdata\Components\24t Coach.vgbx";
[TestMethod] [TestMethod]
public void TestGearboxDataReadTest() public void TestGearboxDataReadTest()
{ {
var gbxData = GearboxData.ReadFromFile(GearboxFile); var gbxData = GearboxData.ReadFromFile(GearboxFile);
Assert.AreEqual(GearboxData.GearboxType.AutomatedManualTransmission, gbxData.Type());
Assert.AreEqual(1.0, gbxData.TractionInterruption.Double(), 0.0001);
Assert.AreEqual(9, gbxData.GearsCount());
Assert.AreEqual(3.240355, gbxData[0].Ratio, 0.0001);
Assert.AreEqual(1.0, gbxData[7].Ratio, 0.0001);
Assert.AreEqual(-400, gbxData[1].ShiftPolygon[0].Torque.Double(), 0.0001);
Assert.AreEqual(560.RPMtoRad().Double(), gbxData[1].ShiftPolygon[0].AngularSpeedDown.Double(), 0.0001);
Assert.AreEqual(1289.RPMtoRad().Double(), gbxData[1].ShiftPolygon[0].AngularSpeedUp.Double(), 0.0001);
Assert.AreEqual(200.RPMtoRad().Double(), gbxData[1].LossMap[15].InputSpeed.Double(), 0.0001);
Assert.AreEqual(-350, gbxData[1].LossMap[15].InputTorque.Double(), 0.0001);
Assert.AreEqual(13.072, gbxData[1].LossMap[15].TorqueLoss.Double(), 0.0001);
} }
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment